From: "H. Peter Anvin" <hpa@zytor.com>
To: Mike Frysinger <vapier@gentoo.org>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, ak@suse.de
Subject: Re: [patch] use __asm__ and __volatile__ in asm-x86_64/msr.h
Date: Mon, 18 Jun 2007 00:35:52 -0700 [thread overview]
Message-ID: <467635D8.5060202@zytor.com> (raw)
In-Reply-To: <200706180209.36762.vapier@gentoo.org>
Mike Frysinger wrote:
> Most of the macros in msr.h already use __asm__ and __volatile__, this patch
> brings the rest into line. This is needed since these get exported into
> userspace (need to use strict __asm__ vs asm when gcc compiles with GNU
> extensions turned off).
> ---
> diff --git a/include/asm-x86_64/msr.h b/include/asm-x86_64/msr.h
> index d5c55b8..ed15d2b 100644
> --- a/include/asm-x86_64/msr.h
> +++ b/include/asm-x86_64/msr.h
> @@ -33,7 +33,7 @@
>
> /* wrmsr with exception handling */
> #define wrmsr_safe(msr,a,b) ({ int ret__; \
> - asm volatile("2: wrmsr ; xorl %0,%0\n" \
> + __asm__ __volatile__("2: wrmsr ; xorl %0,%0\n" \
> "1:\n\t" \
> ".section .fixup,\"ax\"\n\t" \
> "3: movl %4,%0 ; jmp 1b\n\t" \
> @@ -50,7 +50,7 @@
>
> #define rdmsr_safe(msr,a,b) \
> ({ int ret__; \
> - asm volatile ("1: rdmsr\n" \
> + __asm__ __volatile__ ("1: rdmsr\n" \
> "2:\n" \
> ".section .fixup,\"ax\"\n" \
> "3: movl %4,%0\n" \
NAK.
This is wrong for two reasons:
- MSRs are not accessible in user space.
- .section .fixup is not applicable to user space.
Anything MSR-related should be protected by __KERNEL__ instead.
This NAK doesn't apply to rdtsc* and rdpmc* changes, however, as those
instructions are legitimate in userspace.
-hpa
next prev parent reply other threads:[~2007-06-18 7:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-18 6:09 Mike Frysinger
2007-06-18 7:35 ` H. Peter Anvin [this message]
2007-06-18 14:02 ` Mike Frysinger
2007-06-18 18:36 ` Christoph Hellwig
2007-06-18 18:53 ` Andi Kleen
2007-06-20 15:46 ` H. Peter Anvin
2007-07-23 0:45 ` Mike Frysinger
2007-07-23 1:18 ` H. Peter Anvin
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=467635D8.5060202@zytor.com \
--to=hpa@zytor.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vapier@gentoo.org \
/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
Powered by JetHome