aboutsummaryrefslogtreecommitdiffstats
path: root/tools/misc/xen-detect.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-12-16 12:04:13 +0000
committerKeir Fraser <keir.fraser@citrix.com>2008-12-16 12:04:13 +0000
commitf771f7ffce74c0c032244edb0c0629711c7e6bd1 (patch)
tree1ae94f49d1deed56eb814ea363bf5284031c2cc0 /tools/misc/xen-detect.c
parentc32ea44041119db8f3b37b90260acb7b8200dc42 (diff)
downloadxen-f771f7ffce74c0c032244edb0c0629711c7e6bd1.tar.gz
xen-f771f7ffce74c0c032244edb0c0629711c7e6bd1.tar.bz2
xen-f771f7ffce74c0c032244edb0c0629711c7e6bd1.zip
x86: Update xen-detect utility to scan for Xen signature in CPUID space.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'tools/misc/xen-detect.c')
-rw-r--r--tools/misc/xen-detect.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/tools/misc/xen-detect.c b/tools/misc/xen-detect.c
index c918945f81..c50cf185ac 100644
--- a/tools/misc/xen-detect.c
+++ b/tools/misc/xen-detect.c
@@ -50,17 +50,25 @@ static int check_for_xen(void)
{
uint32_t eax, ebx, ecx, edx;
char signature[13];
+ uint32_t base;
- cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
- *(uint32_t *)(signature + 0) = ebx;
- *(uint32_t *)(signature + 4) = ecx;
- *(uint32_t *)(signature + 8) = edx;
- signature[12] = '\0';
+ for ( base = 0x40000000; base < 0x40001000; base += 0x100 )
+ {
+ cpuid(base, &eax, &ebx, &ecx, &edx);
- if ( strcmp("XenVMMXenVMM", signature) || (eax < 0x40000002) )
- return 0;
+ *(uint32_t *)(signature + 0) = ebx;
+ *(uint32_t *)(signature + 4) = ecx;
+ *(uint32_t *)(signature + 8) = edx;
+ signature[12] = '\0';
+
+ if ( !strcmp("XenVMMXenVMM", signature) && (eax >= (base + 2)) )
+ goto found;
+ }
+
+ return 0;
- cpuid(0x40000001, &eax, &ebx, &ecx, &edx);
+ found:
+ cpuid(base + 1, &eax, &ebx, &ecx, &edx);
printf("Running in %s context on Xen v%d.%d.\n",
pv_context ? "PV" : "HVM", (uint16_t)(eax >> 16), (uint16_t)eax);
return 1;