summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-03-17 10:32:39 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-03-17 10:53:56 +0000
commit53cf9493343e34b09622a544c84957d60d50c038 (patch)
treebe4c3d3ea979e08f998c586b9644154e477ce871
parentd87e9cbae34b22c89e6094263ae44567f5b5bd90 (diff)
downloadvirt-what-53cf9493343e34b09622a544c84957d60d50c038.tar.gz
virt-what-53cf9493343e34b09622a544c84957d60d50c038.tar.xz
virt-what-53cf9493343e34b09622a544c84957d60d50c038.zip
Preserve %ebx across CPUID when using PIE (thanks Faustus, Anthony Basile from Gentoo).
PIE on i686 uses %ebx as a base register. Don't clobber it across the CPUID instruction. https://bugs.gentoo.org/show_bug.cgi?id=341271 https://bugzilla.redhat.com/show_bug.cgi?id=804282
-rw-r--r--virt-what-cpuid-helper.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/virt-what-cpuid-helper.c b/virt-what-cpuid-helper.c
index 8b81be3..7812545 100644
--- a/virt-what-cpuid-helper.c
+++ b/virt-what-cpuid-helper.c
@@ -31,8 +31,8 @@ cpuid (unsigned int eax, char *sig)
unsigned int *sig32 = (unsigned int *) sig;
asm volatile (
- "xor %%ebx, %%ebx; cpuid"
- : "=a" (eax), "=b" (sig32[0]), "=c" (sig32[1]), "=d" (sig32[2])
+ "xchgl %%ebx,%1; xor %%ebx,%%ebx; cpuid; xchgl %%ebx,%1"
+ : "=a" (eax), "+r" (sig32[0]), "=c" (sig32[1]), "=d" (sig32[2])
: "0" (eax));
sig[12] = 0;