Problem with CPUID getting information in hvm guest
Hi,
I am using fellowing code get xen vmm string , but came out with "GenuntelineI", not "XenVMMXenVMM", i am using xen 3.41 on ubuntu 8.04 ,is some thing changed ? Thx.
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
typedef union
{
uint32_t r[3];
char string[12];
}cpuid_t;
#define CPUID(command,result) \
__asm __volatile(\
"CPUID"\
: "=b"(result.r[0]),"=c"(cpu.r[1]),"=d"(cpu.r[2])\
: "a"(command));
int main(void)
{
cpuid_t cpu;
CPUID(0,cpu);
printf("cpu.string=%s\n",cpu.string);
if(strncmp(cpu.string,"XenVMMXenVMM",12)==0)
{
printf("Running as a Xen HVM guest\n");
}
else
{
printf("Running on native hardware or a non Xen hypervisor\n");
}
return 0;
}
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Take a look at tools/misc/xen-detect.c in the Xen sources.
-- Keir
Quoted 35 lines · 胡少龙
Hi,
I am using fellowing code get xen vmm string , but came out with "GenuntelineI", not "XenVMMXenVMM", i am using xen 3.41 on ubuntu 8.04 ,is some thing changed ? Thx.#include <
stdio.h>
#include <inttypes.h>
#include <string.h>
typedef union
{
uint32_tr[3];
char string[12];
}cpuid_t;#define CPUID(command,result) \ __asm __volatile(\"CPUID"\
: "=b"(result.r[0]),"=c"(cpu.r[1]),"=d"(cpu.r[2])\
: "a"(command));
int main(void)
{
cpuid_tcpu;
CPUID(0,cpu);
printf("cpu.string=%s\n",cpu.string); if(strncmp(cpu.string,"XenVMMXenVMM",12)==0)
{
printf("Running as a Xen HVM guest\n");
}
else
{
printf("Running on native hardware or a non Xen hypervisor\n");
}
return 0;
}