From: "hnrkssn hnrkssn" Subject: Native hypercall basics using int 82 Date: Tue, 16 Dec 2008 09:39:09 +0100 Message-ID: <6a3ccf200812160039g55343adn750be651e432d4a5@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1033477770==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --===============1033477770== Content-Type: multipart/alternative; boundary="----=_Part_116753_24484466.1229416749854" ------=_Part_116753_24484466.1229416749854 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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); ------=_Part_116753_24484466.1229416749854 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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);
------=_Part_116753_24484466.1229416749854-- --===============1033477770== 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 --===============1033477770==--