From: Steve Ofsthun <sofsthun@virtualiron.com>
To: xen-devel@lists.xensource.com
Subject: Re: [RFC][PATCH] Hypercalls from HVM guests (2/2) - Update
Date: Wed, 12 Apr 2006 17:20:59 -0400 [thread overview]
Message-ID: <443D6F3B.1090302@virtualiron.com> (raw)
In-Reply-To: <443D499B.3020504@virtualiron.com>
[-- Attachment #1: Type: text/plain, Size: 254 bytes --]
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@virtualiron.com>
Steve
--
Steve Ofsthun - Virtual Iron Software, Inc.
[-- Attachment #2: hypercall.h --]
[-- Type: text/x-chdr, Size: 2071 bytes --]
/******************************************************************************
* 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 */
}
}
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
prev parent reply other threads:[~2006-04-12 21:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-12 18:40 [RFC][PATCH] Hypercalls from HVM guests (2/2) Steve Ofsthun
2006-04-12 21:20 ` Steve Ofsthun [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=443D6F3B.1090302@virtualiron.com \
--to=sofsthun@virtualiron.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.