ia64/xen-unstable

changeset 18935:fd720db48675

x86: Update xen-detect utility to scan for Xen signature in CPUID space.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Dec 16 12:04:13 2008 +0000 (2008-12-16)
parents 86db039882ea
children a76b4e00e186
files tools/misc/xen-detect.c
line diff
     1.1 --- a/tools/misc/xen-detect.c	Tue Dec 16 12:00:25 2008 +0000
     1.2 +++ b/tools/misc/xen-detect.c	Tue Dec 16 12:04:13 2008 +0000
     1.3 @@ -50,17 +50,25 @@ static int check_for_xen(void)
     1.4  {
     1.5      uint32_t eax, ebx, ecx, edx;
     1.6      char signature[13];
     1.7 +    uint32_t base;
     1.8  
     1.9 -    cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
    1.10 -    *(uint32_t *)(signature + 0) = ebx;
    1.11 -    *(uint32_t *)(signature + 4) = ecx;
    1.12 -    *(uint32_t *)(signature + 8) = edx;
    1.13 -    signature[12] = '\0';
    1.14 +    for ( base = 0x40000000; base < 0x40001000; base += 0x100 )
    1.15 +    {
    1.16 +        cpuid(base, &eax, &ebx, &ecx, &edx);
    1.17 +
    1.18 +        *(uint32_t *)(signature + 0) = ebx;
    1.19 +        *(uint32_t *)(signature + 4) = ecx;
    1.20 +        *(uint32_t *)(signature + 8) = edx;
    1.21 +        signature[12] = '\0';
    1.22  
    1.23 -    if ( strcmp("XenVMMXenVMM", signature) || (eax < 0x40000002) )
    1.24 -        return 0;
    1.25 +        if ( !strcmp("XenVMMXenVMM", signature) && (eax >= (base + 2)) )
    1.26 +            goto found;
    1.27 +    }
    1.28  
    1.29 -    cpuid(0x40000001, &eax, &ebx, &ecx, &edx);
    1.30 +    return 0;
    1.31 +
    1.32 + found:
    1.33 +    cpuid(base + 1, &eax, &ebx, &ecx, &edx);
    1.34      printf("Running in %s context on Xen v%d.%d.\n",
    1.35             pv_context ? "PV" : "HVM", (uint16_t)(eax >> 16), (uint16_t)eax);
    1.36      return 1;