From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: "H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
akpm-3NddpPZAyC0@public.gmane.org,
Jeremy Fitzhardinge <jeremy-TSDbQ3PG+2Y@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] KVM: Avoid using vmx instruction directly
Date: Tue, 21 Nov 2006 21:41:53 +0200 [thread overview]
Message-ID: <45635681.2040504@qumranet.com> (raw)
In-Reply-To: <45634704.8020407-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
H. Peter Anvin wrote:
> Jeremy Fitzhardinge wrote:
>> Avi Kivity wrote:
>>>> Or gcc
>>>> might move the assignment of phys_addr to after the inline assembly.
>>>>
>>> "asm volatile" prevents that (and I'm not 100% sure it's necessary).
>>
>> No, it won't necessarily. "asm volatile" simply forces gcc to emit the
>> assembler, even if it thinks its output doesn't get used. It makes no
>> ordering guarantees with respect to other code (or even other "asm
>> volatiles"). The "memory" clobbers should fix the ordering of the asms
>> though.
>>
>
> I think you're wrong about that; in particular, I'm pretty sure "asm
> volatiles" are ordered among themselves. What the "volatile" means is
> "this has side effects you (the compiler) don't understand", and gcc
> can't assume that it can reorder such side effects.
The gcc manual has this to say:
Similarly, you can't expect a sequence of volatile `asm' instructions
to remain perfectly consecutive. If you want consecutive output, use a
single `asm'. Also, GCC will perform some optimizations across a
volatile `asm' instruction; GCC does not "forget everything" when it
encounters a volatile `asm' instruction the way some other compilers do.
I wonder how we are supposed to code the following sequence:
asm volatile ("blah") /* sets funky processor mode */
some_c_code();
asm volatile ("unblah");
Let's say "blah" disables floating point exceptions, and some_c_code()
must run without exceptions. Is is possible to code this in gcc without
putting functions in another translation unit? Is a memory clobber
sufficient? I'd certainly hate to use it.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
next prev parent reply other threads:[~2006-11-21 19:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-09 11:08 [PATCH] KVM: Avoid using vmx instruction directly Avi Kivity
2006-11-09 13:29 ` Arnd Bergmann
[not found] ` <200611091429.42040.arnd-r2nGTMty4D4@public.gmane.org>
2006-11-09 13:36 ` Avi Kivity
[not found] ` <45532EE3.4000104-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2006-11-09 14:42 ` Arnd Bergmann
2006-11-09 14:52 ` [kvm-devel] " Avi Kivity
2006-11-09 16:37 ` Arnd Bergmann
2006-11-09 16:51 ` Avi Kivity
2006-11-09 23:39 ` Jeremy Fitzhardinge
2006-11-10 12:46 ` Martin Schwidefsky
[not found] ` <6e0cfd1d0611100446j77a27b29jc23f76a515451377-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2006-11-10 19:38 ` Jeremy Fitzhardinge
[not found] ` <4553BC18.6090207-TSDbQ3PG+2Y@public.gmane.org>
2006-11-21 18:35 ` H. Peter Anvin
[not found] ` <45634704.8020407-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2006-11-21 19:41 ` Avi Kivity [this message]
2006-11-21 20:50 ` Jeremy Fitzhardinge
[not found] ` <4563667B.2060209-TSDbQ3PG+2Y@public.gmane.org>
2006-11-22 6:42 ` Avi Kivity
[not found] ` <4563F158.3060209-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2006-11-22 9:10 ` Jeremy Fitzhardinge
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=45635681.2040504@qumranet.com \
--to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
--cc=akpm-3NddpPZAyC0@public.gmane.org \
--cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
--cc=jeremy-TSDbQ3PG+2Y@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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