From: Zachary Amsden <zamsden@redhat.com>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Glauber Costa <glommer@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>, Avi Kivity <avi@redhat.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86: fix ordering constraints on crX read/writes
Date: Wed, 14 Jul 2010 15:00:36 -1000 [thread overview]
Message-ID: <4C3E5DB4.6020000@redhat.com> (raw)
In-Reply-To: <4C3E5C8C.8000800@goop.org>
On 07/14/2010 02:55 PM, Jeremy Fitzhardinge wrote:
> On 07/14/2010 05:28 PM, Zachary Amsden wrote:
>
>>
>>> static inline void native_write_cr2(unsigned long val)
>>> {
>>> - asm volatile("mov %0,%%cr2": : "r" (val), "m" (__force_order));
>>> + asm volatile("mov %1,%%cr2": "+m" (__force_order) : "r" (val) :
>>> "memory");
>>> }
>>>
>>>
>>
>> You don't need the memory clobber there. Technically, this should
>> never be used, however.
>>
> Yes. I just did it for consistency. Likewise, I didn't pore over the
> manuals to work out whether writes to any crX could really have memory
> side-effects.
>
0,3,4 all can.
>>> static inline unsigned long native_read_cr3(void)
>>> {
>>> unsigned long val;
>>> - asm volatile("mov %%cr3,%0\n\t" : "=r" (val), "=m"
>>> (__force_order));
>>> + asm volatile("mov %%cr3,%0\n\t" : "=r" (val) : "m"
>>> (__force_order));
>>> return val;
>>> }
>>>
>>> static inline void native_write_cr3(unsigned long val)
>>> {
>>> - asm volatile("mov %0,%%cr3": : "r" (val), "m" (__force_order));
>>> + asm volatile("mov %1,%%cr3": "+m" (__force_order) : "r" (val) :
>>> "memory");
>>> }
>>>
>>> static inline unsigned long native_read_cr4(void)
>>> {
>>> unsigned long val;
>>> - asm volatile("mov %%cr4,%0\n\t" : "=r" (val), "=m"
>>> (__force_order));
>>> + asm volatile("mov %%cr4,%0\n\t" : "=r" (val) : "m"
>>> (__force_order));
>>> return val;
>>> }
>>>
>>> @@ -271,7 +286,7 @@ static inline unsigned long
>>> native_read_cr4_safe(void)
>>> asm volatile("1: mov %%cr4, %0\n"
>>> "2:\n"
>>> _ASM_EXTABLE(1b, 2b)
>>> - : "=r" (val), "=m" (__force_order) : "0" (0));
>>> + : "=r" (val) : "m" (__force_order), "0" (0));
>>> #else
>>> val = native_read_cr4();
>>> #endif
>>> @@ -280,7 +295,7 @@ static inline unsigned long
>>> native_read_cr4_safe(void)
>>>
>>> static inline void native_write_cr4(unsigned long val)
>>> {
>>> - asm volatile("mov %0,%%cr4": : "r" (val), "m" (__force_order));
>>> + asm volatile("mov %1,%%cr4": "+m" (__force_order) : "r" (val) :
>>> "memory");
>>> }
>>>
>>> #ifdef CONFIG_X86_64
>>>
>>>
>>>
>>>
>> Looks good. I really hope __force_order gets pruned however. Does it
>> actually?
>>
> There's a couple of instances in my vmlinux. I didn't try to track them
> back to specific .o files. gcc tends to generate references by putting
> its address into a register and passing that into the asms.
>
Can you make it extern so at least there's only one in the final bss?
next prev parent reply other threads:[~2010-07-15 1:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-14 22:12 [PATCH] x86: fix ordering constraints on crX read/writes Jeremy Fitzhardinge
2010-07-15 0:28 ` Zachary Amsden
2010-07-15 0:55 ` Jeremy Fitzhardinge
2010-07-15 1:00 ` Zachary Amsden [this message]
2010-07-15 1:29 ` H. Peter Anvin
2010-07-15 14:34 ` Jeremy Fitzhardinge
2010-07-15 18:54 ` H. Peter Anvin
2010-07-15 19:28 ` Jeremy Fitzhardinge
2010-07-15 19:36 ` H. Peter Anvin
2010-07-15 19:57 ` Jeremy Fitzhardinge
2010-07-15 7:07 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C3E5DB4.6020000@redhat.com \
--to=zamsden@redhat.com \
--cc=avi@redhat.com \
--cc=glommer@redhat.com \
--cc=hpa@zytor.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).