login
Header Space

 
 

Re: [PATCH] mark read_crX() asm code as volatile

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Arjan van de Ven <arjan@...>
Cc: Kirill Korotaev <dev@...>, Andrew Morton <akpm@...>, Andi Kleen <ak@...>, Linux Kernel Mailing List <linux-kernel@...>, <devel@...>, <cebbert@...>, <hpa@...>, <nickpiggin@...>
Date: Wednesday, October 3, 2007 - 4:25 am

Arjan,

I can experiment with any constraints if you suggest which one.

From our experiments with gcc, it compares asm strings (sic!!!) to find matches
to be merged! Sigh...
Below are 2 programs which differ in one space in read_cr3_b() asm statement.
The first one compiles incorrectly, while 2nd one - correctly.

My personal feeling is that comparing asm strings is simply a "misfeature".

-------------------------- cut ----------------------------
static inline unsigned long read_cr3_a(void)
{
        unsigned long cr3;
        asm("movq %%cr3,%0" : "=r" (cr3));
        return cr3;
}

static inline unsigned long read_cr3_b(void)
{
        unsigned long cr3;
        asm("movq %%cr3,%0" : "=r" (cr3));
        return cr3;
}

static inline void write_cr3(unsigned long val)
{
        asm volatile("movq %0,%%cr3" :: "r" (val) : "memory");
}

void main()
{
        unsigned long c;
        c = read_cr3_a();
        write_cr3(c | 0x80);
        c = read_cr3_b();
        write_cr3(c | 0x100);
}
-------------------------- cut ----------------------------


-------------------------- cut ----------------------------
static inline unsigned long read_cr3_a(void)
{
        unsigned long cr3;
        asm("movq %%cr3,%0" : "=r" (cr3));
        return cr3;
}

static inline unsigned long read_cr3_b(void)
{
        unsigned long cr3;
        asm("movq  %%cr3,%0" : "=r" (cr3));
        return cr3;
}

static inline void write_cr3(unsigned long val)
{
        asm volatile("movq %0,%%cr3" :: "r" (val) : "memory");
}

void main()
{
        unsigned long c;
        c = read_cr3_a();
        write_cr3(c | 0x80);
        c = read_cr3_b();
        write_cr3(c | 0x100);
}
-------------------------- cut ----------------------------

Kirill

Arjan van de Ven wrote:

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] mark read_crX() asm code as volatile, Kirill Korotaev, (Tue Oct 2, 10:08 am)
Re: [PATCH] mark read_crX() asm code as volatile, Arjan van de Ven, (Tue Oct 2, 11:28 am)
Re: [PATCH] mark read_crX() asm code as volatile, Kirill Korotaev, (Wed Oct 3, 4:25 am)
Re: [PATCH] mark read_crX() asm code as volatile, H. Peter Anvin, (Tue Oct 2, 3:21 pm)
Re: [PATCH] mark read_crX() asm code as volatile, Chuck Ebbert, (Tue Oct 2, 2:27 pm)
Re: [PATCH] mark read_crX() asm code as volatile, Nick Piggin, (Tue Oct 2, 8:14 am)
Re: [PATCH] mark read_crX() asm code as volatile, H. Peter Anvin, (Wed Oct 3, 2:18 am)
Re: [PATCH] mark read_crX() asm code as volatile, Nick Piggin, (Tue Oct 2, 11:49 am)
Re: [PATCH] mark read_crX() asm code as volatile, Andi Kleen, (Wed Oct 3, 4:45 am)
Re: [PATCH] mark read_crX() asm code as volatile, Andi Kleen, (Tue Oct 2, 10:17 am)
speck-geostationary