From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Subject: Re: [kvm-devel] [PATCH] KVM: Avoid using vmx instruction directly Date: Thu, 9 Nov 2006 17:37:48 +0100 Message-ID: <200611091737.48801.arnd@arndb.de> References: <20061109110852.A6B712500F7@cleopatra.q> <200611091542.31101.arnd@arndb.de> <455340B8.2080206@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm-devel@lists.sourceforge.net, akpm@osdl.org, linux-kernel@vger.kernel.org Return-path: To: Avi Kivity In-Reply-To: <455340B8.2080206@qumranet.com> Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Thursday 09 November 2006 15:52, Avi Kivity wrote: > Wouldn't that make inline assembly useless? =A0Suppose the contents i= s=20 > itself a pointer. =A0What about the pointed-to contents? >=20 > e.g. >=20 > =A0 =A0 int x =3D 3; > =A0 =A0 int *y =3D &x; > =A0 =A0 int z; >=20 > =A0 =A0 asm ("mov %1, %%rax; movl (%%rax), %0" : "=3Dr"(z) : "g"(y) := "rax"); > =A0 =A0 assert(z =3D=3D 3); Same here, you need to tell gcc what is really accessed, like=20 asm ("mov %1, %%rax; movl (%%rax), %0" : "=3Dr"(z) : "g"(y), "m"(*y) : = "rax"); I know that the s390 kernel developers have hit that problem frequently with inline assemblies. It may be that it's harder to hit on x86, because there are fewer registers available and data therefore tends to spill to the stack. > > Or gcc > > might move the assignment of phys_addr to after the inline assembly= =2E > > =A0=20 > "asm volatile" prevents that (and I'm not 100% sure it's necessary). Yes, I think that's right. The 'volatile' should not be necessary thoug= h, if you get the inputs right. Arnd <><