diff options
author | Keir Fraser <keir@xen.org> | 2011-12-02 06:31:14 -0800 |
---|---|---|
committer | Keir Fraser <keir@xen.org> | 2011-12-02 06:31:14 -0800 |
commit | 51b4edac5476726be451614b2ddbd645b4ce1de4 (patch) | |
tree | 7050c10ac0b781ca892b4e30faba8f419ca08868 /tools/libxc/xc_cpuid_x86.c | |
parent | b010d7f5b8b9ab1f95e59bc8d4f0a290a1f1a21b (diff) | |
download | xen-51b4edac5476726be451614b2ddbd645b4ce1de4.tar.gz xen-51b4edac5476726be451614b2ddbd645b4ce1de4.tar.bz2 xen-51b4edac5476726be451614b2ddbd645b4ce1de4.zip |
tools/x86_64: Fix cpuid() inline asm to not clobber stack's red zone
Pushing stuff onto the stack on x86-64 when we do not specify
-mno-red-zone is unsafe. Since the complicated asm is due to register
pressure on i386, we simply implement an all-new simpler alternative
for x86-64.
Signed-off-by: Keir Fraser <keir@xen.org>
Acked-by: Jan Beulich <jbeulich@novell.com>
Diffstat (limited to 'tools/libxc/xc_cpuid_x86.c')
-rw-r--r-- | tools/libxc/xc_cpuid_x86.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c index f7e1b61a02..939412edc5 100644 --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -43,23 +43,23 @@ static int hypervisor_is_64bit(xc_interface *xch) static void cpuid(const unsigned int *input, unsigned int *regs) { unsigned int count = (input[1] == XEN_CPUID_INPUT_UNUSED) ? 0 : input[1]; - asm ( #ifdef __i386__ + /* Use the stack to avoid reg constraint failures with some gcc flags */ + asm ( "push %%ebx; push %%edx\n\t" -#else - "push %%rbx; push %%rdx\n\t" -#endif "cpuid\n\t" "mov %%ebx,4(%4)\n\t" "mov %%edx,12(%4)\n\t" -#ifdef __i386__ "pop %%edx; pop %%ebx\n\t" -#else - "pop %%rdx; pop %%rbx\n\t" -#endif : "=a" (regs[0]), "=c" (regs[2]) - : "0" (input[0]), "1" (count), "S" (regs) + : "0" (input[0]), "1" (count), "S" (_regs) : "memory" ); +#else + asm ( + "cpuid" + : "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3]) + : "0" (input[0]), "2" (count) ); +#endif } /* Get the manufacturer brand name of the host processor. */ |