mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
Rename VMX option name lapic to apic, and pass it to xen by
hvm_info_table. Previous we pass it to xen by guest vcpu context ECX register, now we unify to use hvm_info_table. Signed-off-by: Xin Li <xin.b.li@intel.com>
This commit is contained in:
1 parent
61cf7e808a
commit
29c3bf78b9
13 files changed
+145
-130
No files matched your search
@@ -28,11 +28,14 @@ name = "ExampleVMXDomain"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# the number of cpus guest platform has, default=1
|
||||
vcpus=1
|
||||
#vcpus=1
|
||||
|
||||
# enable/disalbe vmx guest ACPI, default=0 (disabled)
|
||||
#acpi=0
|
||||
|
||||
# enable/disalbe vmx guest APIC, default=0 (disabled)
|
||||
#apic=0
|
||||
|
||||
# List of which CPUS this domain is allowed to use, default Xen picks
|
||||
#cpus = "" # leave to Xen to pick
|
||||
#cpus = "0" # all vcpus run on CPU0
|
||||
|
||||
@@ -32,19 +32,29 @@ struct hvm_info_table {
|
||||
uint32_t length;
|
||||
uint8_t checksum;
|
||||
uint8_t acpi_enabled;
|
||||
uint8_t pad[2];
|
||||
uint8_t apic_enabled;
|
||||
uint8_t pad[1];
|
||||
uint32_t nr_vcpus;
|
||||
};
|
||||
|
||||
static struct hvm_info_table *table = NULL;
|
||||
|
||||
static int
|
||||
checksum_valid(uint8_t *ptr, int len)
|
||||
static int validate_hvm_info(struct hvm_info_table *t)
|
||||
{
|
||||
uint8_t sum=0;
|
||||
char signature[] = "HVM INFO";
|
||||
uint8_t *ptr = (uint8_t *)t;
|
||||
uint8_t sum = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
/* strncmp(t->signature, "HVM INFO", 8) */
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (signature[i] != t->signature[i]) {
|
||||
puts("Bad hvm info signature\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < t->length; i++)
|
||||
sum += ptr[i];
|
||||
|
||||
return (sum == 0);
|
||||
@@ -55,7 +65,6 @@ static struct hvm_info_table *
|
||||
get_hvm_info_table(void)
|
||||
{
|
||||
struct hvm_info_table *t;
|
||||
char signature[] = "HVM INFO";
|
||||
int i;
|
||||
|
||||
if (table != NULL)
|
||||
@@ -63,16 +72,8 @@ get_hvm_info_table(void)
|
||||
|
||||
t = (struct hvm_info_table *)(HVM_INFO_PAGE + HVM_INFO_OFFSET);
|
||||
|
||||
/* strncmp(t->signature, "HVM INFO", 8) */
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (signature[i] != t->signature[i]) {
|
||||
puts("Bad hvm info signature\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!checksum_valid((uint8_t *)t, t->length)) {
|
||||
puts("Bad hvm info checksum\n");
|
||||
if (!validate_hvm_info(t)) {
|
||||
puts("Bad hvm info table\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -126,10 +127,10 @@ acpi_madt_get_madt(unsigned char *acpi_start)
|
||||
return madt;
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
set_checksum(void *start, int checksum_offset, int len)
|
||||
{
|
||||
unsigned char sum = 0;
|
||||
unsigned char sum = 0;
|
||||
unsigned char *ptr;
|
||||
|
||||
ptr = start;
|
||||
@@ -141,9 +142,9 @@ set_checksum(void *start, int checksum_offset, int len)
|
||||
ptr[checksum_offset] = -sum;
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
acpi_madt_set_local_apics(
|
||||
int nr_vcpu,
|
||||
int nr_vcpu,
|
||||
ACPI_MULTIPLE_APIC_DESCRIPTION_TABLE *madt)
|
||||
{
|
||||
int i;
|
||||
@@ -156,14 +157,14 @@ acpi_madt_set_local_apics(
|
||||
madt->LocalApic[i].Length = sizeof (ACPI_LOCAL_APIC_STRUCTURE);
|
||||
madt->LocalApic[i].AcpiProcessorId = i;
|
||||
madt->LocalApic[i].ApicId = i;
|
||||
madt->LocalApic[i].Flags = 1;
|
||||
madt->LocalApic[i].Flags = 1;
|
||||
}
|
||||
|
||||
madt->Header.Header.Length =
|
||||
sizeof(ACPI_MULTIPLE_APIC_DESCRIPTION_TABLE) -
|
||||
sizeof(ACPI_MULTIPLE_APIC_DESCRIPTION_TABLE) -
|
||||
(MAX_VIRT_CPUS - nr_vcpu)* sizeof(ACPI_LOCAL_APIC_STRUCTURE);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FIELD_OFFSET(TYPE,Field) ((unsigned int)(&(((TYPE *) 0)->Field)))
|
||||
@@ -185,7 +186,7 @@ int acpi_madt_update(unsigned char *acpi_start)
|
||||
madt, FIELD_OFFSET(ACPI_TABLE_HEADER, Checksum),
|
||||
madt->Header.Header.Length);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+23
-36
@@ -33,18 +33,6 @@
|
||||
#define E820_MAP_NR_OFFSET 0x000001E8
|
||||
#define E820_MAP_OFFSET 0x000002D0
|
||||
|
||||
#define HVM_INFO_PAGE 0x0009F000
|
||||
#define HVM_INFO_OFFSET 0x00000800
|
||||
|
||||
struct hvm_info_table {
|
||||
char signature[8]; /* "HVM INFO" */
|
||||
uint32_t length;
|
||||
uint8_t checksum;
|
||||
uint8_t acpi_enabled;
|
||||
uint8_t pad[2];
|
||||
uint32_t nr_vcpus;
|
||||
};
|
||||
|
||||
struct e820entry {
|
||||
uint64_t addr;
|
||||
uint64_t size;
|
||||
@@ -128,7 +116,7 @@ static unsigned char build_e820map(void *e820_page, unsigned long mem_size)
|
||||
return (*(((unsigned char *)e820_page) + E820_MAP_NR_OFFSET) = nr_map);
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
set_hvm_info_checksum(struct hvm_info_table *t)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)t, sum = 0;
|
||||
@@ -148,7 +136,7 @@ set_hvm_info_checksum(struct hvm_info_table *t)
|
||||
*/
|
||||
static int set_hvm_info(int xc_handle, uint32_t dom,
|
||||
unsigned long *pfn_list, unsigned int vcpus,
|
||||
unsigned int acpi)
|
||||
unsigned int acpi, unsigned int apic)
|
||||
{
|
||||
char *va_map;
|
||||
struct hvm_info_table *va_hvm;
|
||||
@@ -164,8 +152,9 @@ static int set_hvm_info(int xc_handle, uint32_t dom,
|
||||
strncpy(va_hvm->signature, "HVM INFO", 8);
|
||||
va_hvm->length = sizeof(struct hvm_info_table);
|
||||
va_hvm->acpi_enabled = acpi;
|
||||
va_hvm->apic_enabled = apic;
|
||||
va_hvm->nr_vcpus = vcpus;
|
||||
|
||||
|
||||
set_hvm_info_checksum(va_hvm);
|
||||
|
||||
munmap(va_map, PAGE_SIZE);
|
||||
@@ -307,9 +296,9 @@ static int setup_guest(int xc_handle,
|
||||
vcpu_guest_context_t *ctxt,
|
||||
unsigned long shared_info_frame,
|
||||
unsigned int control_evtchn,
|
||||
unsigned int lapic,
|
||||
unsigned int vcpus,
|
||||
unsigned int acpi,
|
||||
unsigned int apic,
|
||||
unsigned int store_evtchn,
|
||||
unsigned long *store_mfn)
|
||||
{
|
||||
@@ -519,20 +508,14 @@ static int setup_guest(int xc_handle,
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
if (set_hvm_info(xc_handle, dom, page_array, vcpus, acpi)) {
|
||||
if ( set_hvm_info(xc_handle, dom, page_array, vcpus, acpi, apic) ) {
|
||||
fprintf(stderr, "Couldn't set hvm info for VMX guest.\n");
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
*store_mfn = page_array[(v_end-2) >> PAGE_SHIFT];
|
||||
if ( xc_clear_domain_page(xc_handle, dom, *store_mfn) )
|
||||
goto error_out;
|
||||
|
||||
shared_page_frame = (v_end - PAGE_SIZE) >> PAGE_SHIFT;
|
||||
|
||||
if ((e820_page = xc_map_foreign_range(
|
||||
xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
|
||||
page_array[E820_MAP_PAGE >> PAGE_SHIFT])) == 0)
|
||||
if ( (e820_page = xc_map_foreign_range(
|
||||
xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
|
||||
page_array[E820_MAP_PAGE >> PAGE_SHIFT])) == 0 )
|
||||
goto error_out;
|
||||
memset(e820_page, 0, PAGE_SIZE);
|
||||
e820_map_nr = build_e820map(e820_page, v_end);
|
||||
@@ -547,26 +530,30 @@ static int setup_guest(int xc_handle,
|
||||
munmap(e820_page, PAGE_SIZE);
|
||||
|
||||
/* shared_info page starts its life empty. */
|
||||
if ((shared_info = xc_map_foreign_range(
|
||||
xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
|
||||
shared_info_frame)) == 0)
|
||||
if ( (shared_info = xc_map_foreign_range(
|
||||
xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
|
||||
shared_info_frame)) == 0 )
|
||||
goto error_out;
|
||||
memset(shared_info, 0, sizeof(shared_info_t));
|
||||
/* Mask all upcalls... */
|
||||
for ( i = 0; i < MAX_VIRT_CPUS; i++ )
|
||||
shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
|
||||
|
||||
munmap(shared_info, PAGE_SIZE);
|
||||
|
||||
/* Populate the event channel port in the shared page */
|
||||
if ((sp = (shared_iopage_t *) xc_map_foreign_range(
|
||||
xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
|
||||
page_array[shared_page_frame])) == 0)
|
||||
shared_page_frame = page_array[(v_end >> PAGE_SHIFT) - 1];
|
||||
if ( (sp = (shared_iopage_t *) xc_map_foreign_range(
|
||||
xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
|
||||
shared_page_frame)) == 0 )
|
||||
goto error_out;
|
||||
memset(sp, 0, PAGE_SIZE);
|
||||
sp->sp_global.eport = control_evtchn;
|
||||
munmap(sp, PAGE_SIZE);
|
||||
|
||||
*store_mfn = page_array[(v_end >> PAGE_SHIFT) - 2];
|
||||
if ( xc_clear_domain_page(xc_handle, dom, *store_mfn) )
|
||||
goto error_out;
|
||||
|
||||
/* Send the page update requests down to the hypervisor. */
|
||||
if ( xc_finish_mmu_updates(xc_handle, mmu) )
|
||||
goto error_out;
|
||||
@@ -588,7 +575,7 @@ static int setup_guest(int xc_handle,
|
||||
ctxt->user_regs.eax = 0;
|
||||
ctxt->user_regs.esp = 0;
|
||||
ctxt->user_regs.ebx = 0; /* startup_32 expects this to be 0 to signal boot cpu */
|
||||
ctxt->user_regs.ecx = lapic;
|
||||
ctxt->user_regs.ecx = 0;
|
||||
ctxt->user_regs.esi = 0;
|
||||
ctxt->user_regs.edi = 0;
|
||||
ctxt->user_regs.ebp = 0;
|
||||
@@ -608,9 +595,9 @@ int xc_vmx_build(int xc_handle,
|
||||
int memsize,
|
||||
const char *image_name,
|
||||
unsigned int control_evtchn,
|
||||
unsigned int lapic,
|
||||
unsigned int vcpus,
|
||||
unsigned int acpi,
|
||||
unsigned int apic,
|
||||
unsigned int store_evtchn,
|
||||
unsigned long *store_mfn)
|
||||
{
|
||||
@@ -674,7 +661,7 @@ int xc_vmx_build(int xc_handle,
|
||||
|
||||
if ( setup_guest(xc_handle, domid, memsize, image, image_size, nr_pages,
|
||||
ctxt, op.u.getdomaininfo.shared_info_frame, control_evtchn,
|
||||
lapic, vcpus, acpi, store_evtchn, store_mfn) < 0)
|
||||
vcpus, acpi, apic, store_evtchn, store_mfn) < 0)
|
||||
{
|
||||
ERROR("Error constructing guest OS");
|
||||
goto error_out;
|
||||
|
||||
@@ -56,9 +56,9 @@ int xc_vmx_build(int xc_handle,
|
||||
int memsize,
|
||||
const char *image_name,
|
||||
unsigned int control_evtchn,
|
||||
unsigned int lapic,
|
||||
unsigned int vcpus,
|
||||
unsigned int acpi,
|
||||
unsigned int apic,
|
||||
unsigned int store_evtchn,
|
||||
unsigned long *store_mfn);
|
||||
|
||||
|
||||
@@ -362,22 +362,23 @@ static PyObject *pyxc_vmx_build(XcObject *self,
|
||||
uint32_t dom;
|
||||
char *image;
|
||||
int control_evtchn, store_evtchn;
|
||||
int vcpus = 1;
|
||||
int lapic = 0;
|
||||
int acpi = 0;
|
||||
int memsize;
|
||||
int vcpus = 1;
|
||||
int acpi = 0;
|
||||
int apic = 0;
|
||||
unsigned long store_mfn = 0;
|
||||
|
||||
static char *kwd_list[] = { "dom", "control_evtchn", "store_evtchn",
|
||||
"memsize", "image", "lapic", "vcpus", "acpi",NULL };
|
||||
"memsize", "image", "vcpus", "acpi", "apic",
|
||||
NULL };
|
||||
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiisiii", kwd_list,
|
||||
&dom, &control_evtchn, &store_evtchn,
|
||||
&memsize, &image, &lapic, &vcpus,&acpi) )
|
||||
&memsize, &image, &vcpus, &acpi, &apic) )
|
||||
return NULL;
|
||||
|
||||
if ( xc_vmx_build(self->xc_handle, dom, memsize, image, control_evtchn,
|
||||
lapic, vcpus, acpi, store_evtchn, &store_mfn) != 0 )
|
||||
vcpus, acpi, apic, store_evtchn, &store_mfn) != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
|
||||
|
||||
@@ -209,13 +209,9 @@ class VmxImageHandler(ImageHandler):
|
||||
|
||||
self.dmargs += self.configVNC(imageConfig)
|
||||
|
||||
self.lapic = 0
|
||||
lapic = sxp.child_value(imageConfig, 'lapic')
|
||||
if not lapic is None:
|
||||
self.lapic = int(lapic)
|
||||
|
||||
self.acpi = int(sxp.child_value(imageConfig, 'acpi', 0))
|
||||
|
||||
self.apic = int(sxp.child_value(imageConfig, 'apic', 0))
|
||||
|
||||
def buildDomain(self):
|
||||
# Create an event channel
|
||||
self.device_channel = xc.evtchn_alloc_unbound(dom=self.vm.getDomid(),
|
||||
@@ -229,18 +225,18 @@ class VmxImageHandler(ImageHandler):
|
||||
log.debug("control_evtchn = %d", self.device_channel)
|
||||
log.debug("store_evtchn = %d", store_evtchn)
|
||||
log.debug("memsize = %d", self.vm.getMemoryTarget() / 1024)
|
||||
log.debug("lapic = %d", self.lapic)
|
||||
log.debug("vcpus = %d", self.vm.getVCpuCount())
|
||||
log.debug("acpi = %d", self.acpi)
|
||||
log.debug("apic = %d", self.apic)
|
||||
|
||||
return xc.vmx_build(dom = self.vm.getDomid(),
|
||||
image = self.kernel,
|
||||
control_evtchn = self.device_channel,
|
||||
store_evtchn = store_evtchn,
|
||||
memsize = self.vm.getMemoryTarget() / 1024,
|
||||
lapic = self.lapic,
|
||||
vcpus = self.vm.getVCpuCount(),
|
||||
acpi = self.acpi,
|
||||
vcpus = self.vm.getVCpuCount())
|
||||
apic = self.apic)
|
||||
|
||||
# Return a list of cmd line args to the device models based on the
|
||||
# xm config file
|
||||
|
||||
@@ -160,14 +160,14 @@ gopts.var('cpus', val='CPUS',
|
||||
fn=set_int, default=None,
|
||||
use="CPUS to run the domain on.")
|
||||
|
||||
gopts.var('lapic', val='LAPIC',
|
||||
fn=set_int, default=0,
|
||||
use="Disable or enable local APIC of VMX domain.")
|
||||
|
||||
gopts.var('acpi', val='ACPI',
|
||||
fn=set_int, default=0,
|
||||
use="Disable or enable ACPI of VMX domain.")
|
||||
|
||||
gopts.var('apic', val='APIC',
|
||||
fn=set_int, default=0,
|
||||
use="Disable or enable APIC of VMX domain.")
|
||||
|
||||
gopts.var('vcpus', val='VCPUS',
|
||||
fn=set_int, default=1,
|
||||
use="# of Virtual CPUS in domain.")
|
||||
@@ -534,8 +534,8 @@ def configure_vmx(config_image, vals):
|
||||
"""
|
||||
args = [ 'device_model', 'vcpus', 'cdrom', 'boot', 'fda', 'fdb',
|
||||
'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'audio',
|
||||
'vnc', 'vncviewer', 'sdl', 'display', 'ne2000', 'lapic',
|
||||
'xauthority', 'acpi' ]
|
||||
'vnc', 'vncviewer', 'sdl', 'display', 'ne2000', 'acpi', 'apic',
|
||||
'xauthority' ]
|
||||
for a in args:
|
||||
if (vals.__dict__[a]):
|
||||
config_image.append([a, vals.__dict__[a]])
|
||||
|
||||
+1
-6
@@ -66,11 +66,6 @@ void vmx_final_setup_guest(struct vcpu *v)
|
||||
struct domain *d = v->domain;
|
||||
struct vcpu *vc;
|
||||
|
||||
d->arch.vmx_platform.lapic_enable = v->arch.guest_context.user_regs.ecx;
|
||||
v->arch.guest_context.user_regs.ecx = 0;
|
||||
VMX_DBG_LOG(DBG_LEVEL_VLAPIC, "lapic enable is %d.\n",
|
||||
d->arch.vmx_platform.lapic_enable);
|
||||
|
||||
/* Initialize monitor page table */
|
||||
for_each_vcpu(d, vc)
|
||||
vc->arch.monitor_table = mk_pagetable(0);
|
||||
@@ -95,7 +90,7 @@ void vmx_final_setup_guest(struct vcpu *v)
|
||||
void vmx_relinquish_resources(struct vcpu *v)
|
||||
{
|
||||
struct vmx_virpit *vpit;
|
||||
|
||||
|
||||
if ( !VMX_DOMAIN(v) )
|
||||
return;
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ int vlapic_find_highest_irr(struct vlapic *vlapic)
|
||||
|
||||
int vmx_apic_support(struct domain *d)
|
||||
{
|
||||
return d->arch.vmx_platform.lapic_enable;
|
||||
return d->arch.vmx_platform.apic_enabled;
|
||||
}
|
||||
|
||||
s_time_t get_apictime_scheduled(struct vcpu *v)
|
||||
|
||||
+38
-18
@@ -206,35 +206,55 @@ static void vmx_map_io_shared_page(struct domain *d)
|
||||
&d->shared_info->evtchn_mask[0]);
|
||||
}
|
||||
|
||||
#define VCPU_NR_PAGE 0x0009F000
|
||||
#define VCPU_NR_OFFSET 0x00000800
|
||||
#define VCPU_MAGIC 0x76637075 /* "vcpu" */
|
||||
static int validate_hvm_info(struct hvm_info_table *t)
|
||||
{
|
||||
char signature[] = "HVM INFO";
|
||||
uint8_t *ptr = (uint8_t *)t;
|
||||
uint8_t sum = 0;
|
||||
int i;
|
||||
|
||||
static void vmx_set_vcpu_nr(struct domain *d)
|
||||
/* strncmp(t->signature, "HVM INFO", 8) */
|
||||
for ( i = 0; i < 8; i++ ) {
|
||||
if ( signature[i] != t->signature[i] ) {
|
||||
printk("Bad hvm info signature\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
for ( i = 0; i < t->length; i++ )
|
||||
sum += ptr[i];
|
||||
|
||||
return (sum == 0);
|
||||
}
|
||||
|
||||
static void vmx_get_hvm_info(struct domain *d)
|
||||
{
|
||||
unsigned char *p;
|
||||
unsigned long mpfn;
|
||||
unsigned int *vcpus;
|
||||
struct hvm_info_table *t;
|
||||
|
||||
mpfn = get_mfn_from_pfn(VCPU_NR_PAGE >> PAGE_SHIFT);
|
||||
if (mpfn == INVALID_MFN) {
|
||||
printk("Can not get vcpu number page mfn for VMX domain.\n");
|
||||
mpfn = get_mfn_from_pfn(HVM_INFO_PAGE >> PAGE_SHIFT);
|
||||
if ( mpfn == INVALID_MFN ) {
|
||||
printk("Can not get hvm info page mfn for VMX domain.\n");
|
||||
domain_crash_synchronous();
|
||||
}
|
||||
|
||||
p = map_domain_page(mpfn);
|
||||
if (p == NULL) {
|
||||
printk("Can not map vcpu number page for VMX domain.\n");
|
||||
if ( p == NULL ) {
|
||||
printk("Can not map hvm info page for VMX domain.\n");
|
||||
domain_crash_synchronous();
|
||||
}
|
||||
|
||||
vcpus = (unsigned int *)(p + VCPU_NR_OFFSET);
|
||||
if (vcpus[0] != VCPU_MAGIC) {
|
||||
printk("Bad vcpus magic, set vcpu number to 1 by default.\n");
|
||||
d->arch.vmx_platform.nr_vcpu = 1;
|
||||
}
|
||||
t = (struct hvm_info_table *)(p + HVM_INFO_OFFSET);
|
||||
|
||||
d->arch.vmx_platform.nr_vcpu = vcpus[1];
|
||||
if ( validate_hvm_info(t) ) {
|
||||
d->arch.vmx_platform.nr_vcpus = t->nr_vcpus;
|
||||
d->arch.vmx_platform.apic_enabled = t->apic_enabled;
|
||||
} else {
|
||||
printk("Bad hvm info table\n");
|
||||
d->arch.vmx_platform.nr_vcpus = 1;
|
||||
d->arch.vmx_platform.apic_enabled = 0;
|
||||
}
|
||||
|
||||
unmap_domain_page(p);
|
||||
}
|
||||
@@ -244,10 +264,10 @@ static void vmx_setup_platform(struct domain* d)
|
||||
struct vmx_platform *platform;
|
||||
|
||||
vmx_map_io_shared_page(d);
|
||||
vmx_set_vcpu_nr(d);
|
||||
vmx_get_hvm_info(d);
|
||||
|
||||
platform = &d->arch.vmx_platform;
|
||||
pic_init(&platform->vmx_pic, pic_irq_request,
|
||||
pic_init(&platform->vmx_pic, pic_irq_request,
|
||||
&platform->interrupt_request);
|
||||
register_pic_io_hook();
|
||||
|
||||
|
||||
@@ -506,7 +506,7 @@ static inline int vmx_reflect_exception(struct vcpu *v)
|
||||
|
||||
static inline unsigned int vmx_get_vcpu_nr(struct domain *d)
|
||||
{
|
||||
return d->arch.vmx_platform.nr_vcpu;
|
||||
return d->arch.vmx_platform.nr_vcpus;
|
||||
}
|
||||
|
||||
static inline shared_iopage_t *get_sp(struct domain *d)
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
(((size_reg) << 24) | ((index) << 16) | ((seg) << 8) | (flag))
|
||||
|
||||
#define operand_size(operand) \
|
||||
((operand >> 24) & 0xFF)
|
||||
((operand >> 24) & 0xFF)
|
||||
|
||||
#define operand_index(operand) \
|
||||
((operand >> 16) & 0xFF)
|
||||
((operand >> 16) & 0xFF)
|
||||
|
||||
/* for instruction.operand[].size */
|
||||
#define BYTE 1
|
||||
@@ -81,13 +81,13 @@ struct instruction {
|
||||
|
||||
struct vmx_platform {
|
||||
unsigned long shared_page_va;
|
||||
unsigned int nr_vcpu;
|
||||
unsigned int lapic_enable;
|
||||
unsigned int nr_vcpus;
|
||||
unsigned int apic_enabled;
|
||||
|
||||
struct vmx_virpit vmx_pit;
|
||||
struct vmx_io_handler vmx_io_handler;
|
||||
struct vmx_virpic vmx_pic;
|
||||
struct vmx_vioapic vmx_vioapic;
|
||||
struct vmx_vioapic vmx_vioapic;
|
||||
unsigned char round_info[256];
|
||||
spinlock_t round_robin_lock;
|
||||
int interrupt_request;
|
||||
|
||||
@@ -38,21 +38,21 @@
|
||||
/*
|
||||
* VMExit dispatcher should cooperate with instruction decoder to
|
||||
* prepare this structure and notify service OS and DM by sending
|
||||
* virq
|
||||
* virq
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t addr; /* physical address */
|
||||
uint64_t size; /* size in bytes */
|
||||
uint64_t count; /* for rep prefixes */
|
||||
uint64_t addr; /* physical address */
|
||||
uint64_t size; /* size in bytes */
|
||||
uint64_t count; /* for rep prefixes */
|
||||
union {
|
||||
uint64_t data; /* data */
|
||||
void *pdata; /* pointer to data */
|
||||
uint64_t data; /* data */
|
||||
void *pdata; /* pointer to data */
|
||||
} u;
|
||||
uint8_t state:4;
|
||||
uint8_t pdata_valid:1; /* if 1, use pdata above */
|
||||
uint8_t dir:1; /* 1=read, 0=write */
|
||||
uint8_t pdata_valid:1; /* if 1, use pdata above */
|
||||
uint8_t dir:1; /* 1=read, 0=write */
|
||||
uint8_t df:1;
|
||||
uint8_t type; /* I/O type */
|
||||
uint8_t type; /* I/O type */
|
||||
} ioreq_t;
|
||||
|
||||
#define MAX_VECTOR 256
|
||||
@@ -61,16 +61,15 @@ typedef struct {
|
||||
#define INTR_LEN_32 (MAX_VECTOR/(BITS_PER_BYTE * sizeof(uint32_t)))
|
||||
|
||||
typedef struct {
|
||||
uint16_t pic_elcr;
|
||||
uint16_t pic_irr;
|
||||
uint16_t pic_last_irr;
|
||||
uint16_t pic_clear_irr;
|
||||
int eport; /* Event channel port */
|
||||
uint16_t pic_elcr;
|
||||
uint16_t pic_irr;
|
||||
uint16_t pic_last_irr;
|
||||
uint16_t pic_clear_irr;
|
||||
int eport; /* Event channel port */
|
||||
} global_iodata_t;
|
||||
|
||||
typedef struct {
|
||||
ioreq_t vp_ioreq;
|
||||
unsigned long vp_intr[INTR_LEN];
|
||||
ioreq_t vp_ioreq;
|
||||
} vcpu_iodata_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -78,6 +77,19 @@ typedef struct {
|
||||
vcpu_iodata_t vcpu_iodata[1];
|
||||
} shared_iopage_t;
|
||||
|
||||
#define HVM_INFO_PAGE 0x0009F000
|
||||
#define HVM_INFO_OFFSET 0x00000800
|
||||
|
||||
struct hvm_info_table {
|
||||
char signature[8]; /* "HVM INFO" */
|
||||
uint32_t length;
|
||||
uint8_t checksum;
|
||||
uint8_t acpi_enabled;
|
||||
uint8_t apic_enabled;
|
||||
uint8_t pad[1];
|
||||
uint32_t nr_vcpus;
|
||||
};
|
||||
|
||||
#endif /* _IOREQ_H_ */
|
||||
|
||||
/*
|
||||
|
||||