Native hypercall basics using int 82
Hi,
I'm trying to detect if I'm running as a guest in XEN hypervisor using a simple hypercall like __HYPERVISOR_xen_version with the XENVER_extraversion option.
I cannot use any of the API functions for this so I'm trying to setup the required registers and call int 82 myself.
This is what I do and unfortunately, it generates an exception 0xd when executing INT 82.
Reading the source, I think I've figured out that I should put my arguments in a hypercall struct shown below. I might be wrong then.
Thanks in advance
David
---
char buffer[256];
HYPERCALL hypercall;
PHYPERCALL phypercall = &hypercall;
hypercall.op = 17; // xen_version
hypercall.arg[0] = (unsigned long) 1; // xen_extra_version hypercall.arg[1] = (unsigned long) Buffer;
memset(Buffer, 0, sizeof(Buffer));
_asm
{
PUSH EDI;
PUSH ESI;
PUSH EDX;
PUSH ECX;
PUSH EBX;
PUSH EAX;
MOV EAX, phypercall;
INT 82;
POP EAX;
POP EBX;
POP ECX
POP EDX;
POP ESI;
POP EDI;}
BufferA[255] = '\0';
Cprintf("Buf: %s\r\n", Buffer);_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 10 lines · hnrkssn hnrkssn
I'm trying to detect if I'm running as a guest in XEN hypervisor using a simple hypercall like
__HYPERVISOR_xen_versionwith theXENVER_extraversionoption.
I cannot use any of the API functions for this so I'm trying to setup the required registers and call int 82 myself.
This is what I do and unfortunately, it generates an exception0xdwhen executing INT 82.Reading the source, I think I've figured out that I should put my arguments in a hypercall struct shown below. I might be wrong then.
See tools/misc/xen-detect.c for a nice approach that even works from user space.
-- Keir
I have already tried the CPUID approach used in xen-detect.c When I read the info from leaf 0x40000001, it says "Microsoft Hv" when I run it on Citrix XenServer Express Edition.
I thought "Microsoft Hv" was supposed to identify Hyper-V?
So I have to try another method.
Can anybody give me some hints on my assembler example in the initial post for making a hypercall?
---
char buffer[256];
HYPERCALL hypercall;
PHYPERCALL phypercall = &hypercall;
hypercall.op = 17; // xen_version
hypercall.arg[0] = (unsigned long) 1; // xen_extra_version hypercall.arg[1] = (unsigned long) Buffer;
memset(Buffer, 0, sizeof(Buffer));
_asm
{
MOV EAX, phypercall;
INT 82;}
Buffer[255] = '\0';
Cprintf("Buf: %s\r\n", Buffer);Best Regards,
David
Quoted 11 lines · Keir Fraser
Quoted 2 lines · hnrkssn hnrkssn
I'm trying to detect if I'm running as a guest in XEN hypervisor using a simple hypercall like
__HYPERVISOR_xen_versionwith the
XENVER_extraversionQuoted 6 lines
option.
I cannot use any of the API functions for this so I'm trying to setup the required registers and call int 82 myself.
This is what I do and unfortunately, it generates an exception0xdwhen executing INT 82.
Quoted 11 lines
Quoted 1 line
Reading the source, I think I've figured out that I should put my
arguments in
Quoted 1 line
a hypercall struct shown below. I might be wrong then.
See
tools/misc/xen-detect.cfor a nice approach that even works from user space.-- Keir
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
We relocate the Xen CPUID info when we emulate Hyper-V. You need to scan for the Xen signature ‹ starting at 0x40000000 and then every 0x100 up to 0x40001000. If you find the signature then you have found the contiguous range of Xen CPUID leaves. I should fix xen-detect.c to do this scan.
-- Keir
Quoted 32 lines · hnrkssn hnrkssn
I have already tried the CPUID approach used in
xen-detect.cWhen I read the info from leaf0x40000001, it says "Microsoft Hv" when I run it on Citrix XenServer Express Edition.
I thought "Microsoft Hv" was supposed to identify Hyper-V?So I have to try another method.
Can anybody give me some hints on my assembler example in the initial post for making a hypercall?---
char buffer[256];
HYPERCALL hypercall;
PHYPERCALL phypercall = &hypercall;hypercall.op = 17; //
xen_version
hypercall.arg[0] = (unsigned long) 1; //xen_extra_versionhypercall.arg[1] = (unsigned long) Buffer;
memset(Buffer, 0, sizeof(Buffer));
_asm{ MOV EAX, phypercall; INT 82;}
Buffer[255] = '\0'; Cprintf("Buf: %s\r\n", Buffer);
Quoted 28 lines
Best Regards,
DavidQuoted 21 lines · Keir Fraser
Quoted 12 lines · hnrkssn hnrkssn
Quoted 2 lines
I'm trying to detect if I'm running as a guest in XEN hypervisor using a simple hypercall like
__HYPERVISOR_xen_versionwith the
XENVER_extraversionQuoted 7 lines
option.
I cannot use any of the API functions for this so I'm trying to setup the required registers and call int 82 myself.
This is what I do and unfortunately, it generates an exception0xdwhen executing INT 82.Reading the source, I think I've figured out that I should put my
arguments in
Quoted 1 line
a hypercall struct shown below. I might be wrong then.
See
tools/misc/xen-detect.cfor a nice approach that even works from user space.-- Keir
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Thanks,
It's working like a charm.
A background question, why does it "emulate Hyper-V"? Is it configurable?
Regards
David
Quoted 59 lines · Keir Fraser
We relocate the Xen CPUID info when we emulate Hyper-V. You need to scan
for the Xen signature — starting at0x40000000and then every0x100up to0x40001000. If you find the signature then you have found the contiguous range of Xen CPUID leaves. I should fixxen-detect.cto do this scan.-- Keir
On 16/12/2008 10:33, "hnrkssn hnrkssn" <[email protected]> wrote:
I have already tried the CPUID approach used in
xen-detect.cWhen I read the info from leaf0x40000001, it says "Microsoft Hv" when I run it on Citrix XenServer Express Edition.
I thought "Microsoft Hv" was supposed to identify Hyper-V?So I have to try another method.
Can anybody give me some hints on my assembler example in the initial post for making a hypercall?---
char buffer[256];
HYPERCALL hypercall;
PHYPERCALL phypercall = &hypercall;hypercall.op = 17; //
xen_version
hypercall.arg[0] = (unsigned long) 1; //xen_extra_versionhypercall.arg[1] = (unsigned long) Buffer;
memset(Buffer, 0, sizeof(Buffer));
_asm{ MOV EAX, phypercall; INT 82;}
Buffer[255] = '\0'; Cprintf("Buf: %s\r\n", Buffer);Best Regards,
DavidOn Tue, Dec 16, 2008 at 9:47 AM, Keir Fraser <[email protected]> wrote:
Quoted 2 lines · hnrkssn hnrkssn
I'm trying to detect if I'm running as a guest in XEN hypervisor using a simple hypercall like
__HYPERVISOR_xen_versionwith the
XENVER_extraversionQuoted 6 lines
option.
I cannot use any of the API functions for this so I'm trying to setup the required registers and call int 82 myself.
This is what I do and unfortunately, it generates an exception0xdwhen executing INT 82.
Quoted 13 lines
Quoted 1 line
Reading the source, I think I've figured out that I should put my
arguments in
Quoted 1 line
a hypercall struct shown below. I might be wrong then.
See
tools/misc/xen-detect.cfor a nice approach that even works from user space.-- Keir
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
I don¹t know whether it¹s configurable in Citrix product. It is configurable in the open source tree (and disabled by default). It¹s probably always on since it¹s harmless and will improve performance of certain Windows guests a tiny bit.
-- Keir
Quoted 4 lines · hnrkssn hnrkssn
Thanks,
It's working like a charm.A background question, why does it "emulate Hyper-V"? Is it configurable?
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 6 lines · Keir Fraser
I don't know whether it's configurable in Citrix product. It is configurable in the open source tree (and disabled by default). It's probably always on since it's harmless and will improve performance of certain Windows guests a tiny bit.
-- Keir
How is it enabled in the open source edition? I cannot find any documentation.
And how does it improve performance?
Quoted 14 lines · hnrkssn hnrkssn
Thanks,
It's working like a charm.A background question, why does it "emulate Hyper-V"? Is it configurable?
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 1 line · Andrew Lyon
How is it enabled in the open source edition? I cannot find any documentation.
Add 'viridian=1' to your domain config file.
Quoted 1 line
And how does it improve performance?
APIC accesses are done via emulated MSRs rather than emulated mmio cycles, which is a teeny bit faster. Also we implement spin-wait notofications, so a vcpu can be descheduled rather than spin. There's others also we could implement but it's not clear it would be a win for us.
-- Keir
Quoted 2 lines · hnrkssn hnrkssn
MOV EAX, phypercall;
INT 82;You should have used "INT 0x82" ??
-- Paul S.