WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [RFC][PATCH] Hypercalls from HVM guests (2/2) - Update

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] Re: [RFC][PATCH] Hypercalls from HVM guests (2/2) - Update
From: Steve Ofsthun <sofsthun@xxxxxxxxxxxxxxx>
Date: Wed, 12 Apr 2006 17:20:59 -0400
Delivery-date: Wed, 12 Apr 2006 14:21:21 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <443D499B.3020504@xxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <443D499B.3020504@xxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050715)
Here is an update to the previously posted test program for HVM hypercalls.
Just replace the previous version of this file with this version.

Signed-off-by: Steve Ofsthun <sofsthun@xxxxxxxxxxxxxxx>

Steve
--
Steve Ofsthun - Virtual Iron Software, Inc.
/******************************************************************************
 * hypercall.h
 *
 * Copyright (C) 2006, Virtual Iron Software, Inc.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307 USA.
 *
 */

#include <linux/version.h>
#include <asm/hypervisor.h>
#include <xen/interface/xen.h>

static inline int
check_amd(void)
{
        char id[12];

        __asm__ __volatile__(
                "cpuid"
                : "=b" (*(int *)(&id[0])),
                  "=c" (*(int *)(&id[8])),
                  "=d" (*(int *)(&id[4]))
                : "a" (0)
        );
        return __builtin_memcmp(id, "AuthenticAMD", 12) == 0;
}

#define VMCALL_INSTR    0x0f,0x01,0xc1
#define VMMCALL_INSTR   0x0f,0x01,0xd9

#define NR_hypercalls (PAGE_SIZE/32)

static inline void hypercall_page_init(void *hypercall_page)
{
    int i;
    char *p;
    char vmcall[3] = { VMCALL_INSTR };
    char vmmcall[3] = { VMMCALL_INSTR };
    int amd = check_amd();

    for ( i = 0; i < NR_hypercalls; i++ )
    {
        p = (char *)(hypercall_page + (i * 32));
        /*
         * This call sequence works for 32-bit and 64-bit guests.
         */
        memset(p, 0xcc, 32);
        *(u8  *)(p+ 0) = 0xb8;          /* mov $<i>,%eax */
        *(u32 *)(p+ 1) = i;
        if (amd) {
            *(u8  *)(p+ 5) = vmmcall[0];
            *(u8  *)(p+ 6) = vmmcall[1];
            *(u8  *)(p+ 7) = vmmcall[2];
        } else {
            *(u8  *)(p+ 5) = vmcall[0];
            *(u8  *)(p+ 6) = vmcall[1];
            *(u8  *)(p+ 7) = vmcall[2];
        }
        *(u8  *)(p+ 8) = 0xc3;          /* ret */
    }
}
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>