Is there a standard way to detect that one is running in a MS hypervisor
(for Visa and later guests)?
Regards,
Is there a standard way to detect that one is running in a MS hypervisor
(for Visa and later guests)?
Regards,
Google for “Hyper-V Functional Specification”. The short answer is
there are MSRs you can read that are not architectural to the processor.
t.
On Thu, 17 Nov 2011, George M. Garner Jr. wrote:
Is there a standard way to detect that one is running in a MS hypervisor (for
Visa and later guests)?Regards,
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminarsTo unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Here’s what I’ve used:
#include <intrin.h>
bool IsOnVirtualMachine()
{
int reg[4];
__cpuid(reg,1);
return !!(reg[2]&0x80000000);
}
I leave it to you to re-assign friendly names to the magic integers.</intrin.h>
Indeed.
I think that it’s described in this app note:
http://www.intel.com/content/www/us/en/processors/processor-identification-c
puid-instruction-note.html
Good luck,
mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jeffrey Tippet
Sent: Thursday, November 17, 2011 2:27 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Detecting a hypervisor
Here’s what I’ve used:
#include <intrin.h>
bool IsOnVirtualMachine()
{
int reg[4];
__cpuid(reg,1);
return !!(reg[2]&0x80000000);
}
I leave it to you to re-assign friendly names to the magic integers.
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer</intrin.h>
And Hyper-V specifically here: http://msdn.microsoft.com/en-us/library/ff538624(v=VS.85).aspx
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Martin O’Brien
Sent: Thursday, November 17, 2011 2:34 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Detecting a hypervisor
Indeed.
I think that it’s described in this app note:
http://www.intel.com/content/www/us/en/processors/processor-identification-c
puid-instruction-note.html
Good luck,
mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jeffrey Tippet
Sent: Thursday, November 17, 2011 2:27 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Detecting a hypervisor
Here’s what I’ve used:
#include <intrin.h>
bool IsOnVirtualMachine()
{
int reg[4];
__cpuid(reg,1);
return !!(reg[2]&0x80000000);
}
I leave it to you to re-assign friendly names to the magic integers.
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</intrin.h>
Thanks for the two links and code sample (which works as far as it
goes). The problem is that the code sample which detects the presence
pf a hypervizor does not distinguish between the root and guest
partitions. If I run it on Hyper-v server host it shows a hypervizor
present. This is logical, since the root partition is just another
partition. However, I need to know whether or not I am running as a
guest (on synthetic hardware). How do I distinguish root from guest
partitions?
Regards,
George.
In a VM technology agnostic way? I don’t think you can do that. If you
know which VM tech is running then you can use the appropriate vendor
apis to find out which domain you are in, assuming the vendor makes
this information available.
Mark Roddy
On Fri, Nov 18, 2011 at 11:05 AM, George M. Garner Jr.
wrote:
> Thanks for the two links and code sample (which works as far as it goes).
> ?The problem is that the code sample which detects the presence pf a
> hypervizor does not distinguish between the root and guest partitions. ?If I
> run it on Hyper-v server host it shows a hypervizor present. ?This is
> logical, since the root partition is just another partition. ?However, I
> need to know whether or not I am running as a guest (on synthetic hardware).
> ?How do I distinguish root from guest partitions?
>
> Regards,
>
> George.
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
Asking the hypervisor which partition your code is running in is usually
asking the wrong question. You think you know something, for example that
the NIC hardware in a VM is “synthetic” and that has some property you’re
expecting. So you ask which partition you’re running in to infer some
property of the NIC.
Tell me what you’re actually trying to infer and I’ll try to tell you how to
get that information.
(And, even though I think it’s the wrong question to ask, I’ll answer it
here. The same documents that others pointed you toward document the entire
hypercall interface. You can tell the difference between a root (or parent)
partition and a child partition by looking at the various rights granted to
them, again through CPUID.)
Jake Oshins
Hyper-V I/O Architect
Windows Kernel Group
This post implies no warranties and confers no rights.
“George M. Garner Jr.” wrote in message news:xxxxx@ntdev…
Thanks for the two links and code sample (which works as far as it
goes). The problem is that the code sample which detects the presence
pf a hypervizor does not distinguish between the root and guest
partitions. If I run it on Hyper-v server host it shows a hypervizor
present. This is logical, since the root partition is just another
partition. However, I need to know whether or not I am running as a
guest (on synthetic hardware). How do I distinguish root from guest
partitions?
Regards,
George.