From: Keir Fraser Subject: Re: Native hypercall basics using int 82 Date: Tue, 16 Dec 2008 10:59:24 +0000 Message-ID: References: <6a3ccf200812160233u7d435ccck6bf1b5490f97c276@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0861894628==" Return-path: In-Reply-To: <6a3ccf200812160233u7d435ccck6bf1b5490f97c276@mail.gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: hnrkssn hnrkssn Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --===============0861894628== Content-type: multipart/alternative; boundary="B_3312269973_35514051" > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3312269973_35514051 Content-type: text/plain; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable We relocate the Xen CPUID info when we emulate Hyper-V. You need to scan fo= r the Xen signature =8B 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 On 16/12/2008 10:33, "hnrkssn hnrkssn" wrote: > 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? >=20 > So I have to try another method. > Can anybody give me some hints on my assembler example in the initial pos= t for > making a hypercall? >=20 > --- > char buffer[256]; > HYPERCALL hypercall; > PHYPERCALL phypercall =3D &hypercall; >=20 > hypercall.op =3D 17; // xen_version > hypercall.arg[0] =3D (unsigned long) 1; // xen_extra_version > hypercall.arg[1] =3D (unsigned long) Buffer; >=20 > memset(Buffer, 0, sizeof(Buffer)); >=20 > _asm > { > MOV EAX, phypercall; > INT 82; > } >=20 > Buffer[255] =3D '\0'; > =20 > Cprintf("Buf: %s\r\n", Buffer); >=20 >=20 >=20 > Best Regards,=20 > David >=20 > On Tue, Dec 16, 2008 at 9:47 AM, Keir Fraser > wrote: >> On 16/12/2008 08:39, "hnrkssn hnrkssn" wrote: >>=20 >>> > I'm trying to detect if I'm running as a guest in XEN hypervisor usin= g 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 wh= en >>> > 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. >>=20 >> See tools/misc/xen-detect.c for a nice approach that even works from use= r >> space. >>=20 >> -- Keir >>=20 >>=20 >=20 >=20 --B_3312269973_35514051 Content-type: text/html; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable Re: [Xen-devel] Native hypercall basics using int 82 We relocate the Xen CPUID info when we emulate Hyper-V. You need to scan f= or 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

On 16/12/2008 10:33, "hnrkssn hnrkssn" <hnrkssn@gmail.com> wrote:

<= SPAN STYLE=3D'font-size:11pt'>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 =3D &hypercall;

hypercall.op     =3D 17;      &n= bsp;            =     // xen_version
hypercall.arg[0] =3D (unsigned long) 1; // xen_extra_version
hypercall.arg[1] =3D (unsigned long) Buffer;

memset(Buffer, 0, sizeof(Buffer));

_asm
  {
    MOV EAX, phypercall;
    INT 82;
  }

  Buffer[255] =3D '\0';
  
  Cprintf("Buf: %s\r\n", Buffer);



Best Regards,
David

On Tue, Dec 16, 2008 at 9:47 AM, Keir Fraser <keir.fraser@eu.citrix.com> wrote:
<= SPAN STYLE=3D'font-size:11pt'>On 16/12/2008 08:39, "hnrkssn hnrkssn"= <hnrkssn@gmail.com> wrote:

> 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_extrave= rsion
> 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 whe= n
> executing INT 82.
>
> Reading the source, I think I've figured out that I should put my argu= ments 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




--B_3312269973_35514051-- --===============0861894628== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============0861894628==--