1 diff -r 23c068b10923 tools/misc/xen-detect.c
2 --- a/tools/misc/xen-detect.c Wed Jun 15 16:16:41 2011 +0100
3 +++ b/tools/misc/xen-detect.c Wed Jun 15 20:14:30 2011 +0100
8 -static void cpuid(uint32_t idx,
14 +static void cpuid(uint32_t idx, uint32_t *regs, int pv_context)
17 - "test %1,%1 ; jz 1f ; ud2a ; .ascii \"xen\" ; 1: cpuid"
18 - : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
19 - : "0" (idx), "1" (pv_context) );
21 +#define R(x) "%%e"#x"x"
23 +#define R(x) "%%r"#x"x"
25 + "push "R(a)"; push "R(b)"; push "R(c)"; push "R(d)"\n\t"
26 + "test %1,%1 ; jz 1f ; ud2a ; .ascii \"xen\" ; 1: cpuid\n\t"
27 + "mov %%eax,(%2); mov %%ebx,4(%2)\n\t"
28 + "mov %%ecx,8(%2); mov %%edx,12(%2)\n\t"
29 + "pop "R(d)"; pop "R(c)"; pop "R(b)"; pop "R(a)"\n\t"
30 + : : "a" (idx), "c" (pv_context), "S" (regs) : "memory" );
33 static int check_for_xen(int pv_context)
35 - uint32_t eax, ebx, ecx, edx;
40 for ( base = 0x40000000; base < 0x40010000; base += 0x100 )
42 - cpuid(base, &eax, &ebx, &ecx, &edx, pv_context);
43 + cpuid(base, regs, pv_context);
45 - *(uint32_t *)(signature + 0) = ebx;
46 - *(uint32_t *)(signature + 4) = ecx;
47 - *(uint32_t *)(signature + 8) = edx;
48 + *(uint32_t *)(signature + 0) = regs[1];
49 + *(uint32_t *)(signature + 4) = regs[2];
50 + *(uint32_t *)(signature + 8) = regs[3];
53 - if ( !strcmp("XenVMMXenVMM", signature) && (eax >= (base + 2)) )
54 + if ( !strcmp("XenVMMXenVMM", signature) && (regs[0] >= (base + 2)) )
61 - cpuid(base + 1, &eax, &ebx, &ecx, &edx, pv_context);
63 + cpuid(base + 1, regs, pv_context);
67 static jmp_buf sigill_jmp;