]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blob - pkgs/xen/patches/00-xen-detect.patch
0b485f7beaaabdf78c08a51495c9966a52b13358
[people/arne_f/ipfire-3.x.git] / pkgs / xen / patches / 00-xen-detect.patch
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
4 @@ -33,43 +33,46 @@
5 #include <unistd.h>
6 #include <getopt.h>
7
8 -static void cpuid(uint32_t idx,
9 - uint32_t *eax,
10 - uint32_t *ebx,
11 - uint32_t *ecx,
12 - uint32_t *edx,
13 - int pv_context)
14 +static void cpuid(uint32_t idx, uint32_t *regs, int pv_context)
15 {
16 asm volatile (
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) );
20 +#ifdef __i386__
21 +#define R(x) "%%e"#x"x"
22 +#else
23 +#define R(x) "%%r"#x"x"
24 +#endif
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" );
31 }
32
33 static int check_for_xen(int pv_context)
34 {
35 - uint32_t eax, ebx, ecx, edx;
36 + uint32_t regs[4];
37 char signature[13];
38 uint32_t base;
39
40 for ( base = 0x40000000; base < 0x40010000; base += 0x100 )
41 {
42 - cpuid(base, &eax, &ebx, &ecx, &edx, pv_context);
43 + cpuid(base, regs, pv_context);
44
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];
51 signature[12] = '\0';
52
53 - if ( !strcmp("XenVMMXenVMM", signature) && (eax >= (base + 2)) )
54 + if ( !strcmp("XenVMMXenVMM", signature) && (regs[0] >= (base + 2)) )
55 goto found;
56 }
57
58 return 0;
59
60 found:
61 - cpuid(base + 1, &eax, &ebx, &ecx, &edx, pv_context);
62 - return eax;
63 + cpuid(base + 1, regs, pv_context);
64 + return regs[0];
65 }
66
67 static jmp_buf sigill_jmp;