direct-io.hg

changeset 8472:412995d28a07

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>
author kaf24@firebug.cl.cam.ac.uk
date Tue Jan 03 14:35:45 2006 +0100 (2006-01-03)
parents 5b30599761b3
children 399c68937d59
files tools/examples/xmexample.vmx tools/firmware/vmxassist/acpi_madt.c tools/libxc/xc_vmx_build.c tools/libxc/xenguest.h tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/image.py tools/python/xen/xm/create.py xen/arch/x86/vmx.c xen/arch/x86/vmx_vlapic.c xen/arch/x86/vmx_vmcs.c xen/include/asm-x86/vmx.h xen/include/asm-x86/vmx_platform.h xen/include/public/io/ioreq.h
line diff
     1.1 --- a/tools/examples/xmexample.vmx	Mon Jan 02 11:35:29 2006 +0100
     1.2 +++ b/tools/examples/xmexample.vmx	Tue Jan 03 14:35:45 2006 +0100
     1.3 @@ -28,11 +28,14 @@ name = "ExampleVMXDomain"
     1.4  
     1.5  #-----------------------------------------------------------------------------
     1.6  # the number of cpus guest platform has, default=1
     1.7 -vcpus=1
     1.8 +#vcpus=1
     1.9  
    1.10  # enable/disalbe vmx guest ACPI, default=0 (disabled)
    1.11  #acpi=0
    1.12  
    1.13 +# enable/disalbe vmx guest APIC, default=0 (disabled)
    1.14 +#apic=0
    1.15 +
    1.16  # List of which CPUS this domain is allowed to use, default Xen picks
    1.17  #cpus = ""         # leave to Xen to pick
    1.18  #cpus = "0"        # all vcpus run on CPU0
     2.1 --- a/tools/firmware/vmxassist/acpi_madt.c	Mon Jan 02 11:35:29 2006 +0100
     2.2 +++ b/tools/firmware/vmxassist/acpi_madt.c	Tue Jan 03 14:35:45 2006 +0100
     2.3 @@ -32,19 +32,29 @@ struct hvm_info_table {
     2.4  	uint32_t length;
     2.5  	uint8_t  checksum;
     2.6  	uint8_t  acpi_enabled;
     2.7 -	uint8_t  pad[2];
     2.8 +	uint8_t  apic_enabled;
     2.9 +	uint8_t  pad[1];
    2.10  	uint32_t nr_vcpus;
    2.11  };
    2.12  
    2.13  static struct hvm_info_table *table = NULL;
    2.14  
    2.15 -static int
    2.16 -checksum_valid(uint8_t *ptr, int len)
    2.17 +static int validate_hvm_info(struct hvm_info_table *t)
    2.18  {
    2.19 -	uint8_t sum=0;
    2.20 +	char signature[] = "HVM INFO";
    2.21 +	uint8_t *ptr = (uint8_t *)t;
    2.22 +	uint8_t sum = 0;
    2.23  	int i;
    2.24  
    2.25 -	for (i = 0; i < len; i++)
    2.26 +	/* strncmp(t->signature, "HVM INFO", 8) */
    2.27 +	for (i = 0; i < 8; i++) {
    2.28 +		if (signature[i] != t->signature[i]) {
    2.29 +			puts("Bad hvm info signature\n");
    2.30 +			return 0;
    2.31 +		}
    2.32 +	}
    2.33 +
    2.34 +	for (i = 0; i < t->length; i++)
    2.35  		sum += ptr[i];
    2.36  
    2.37  	return (sum == 0);
    2.38 @@ -55,7 +65,6 @@ static struct hvm_info_table *
    2.39  get_hvm_info_table(void)
    2.40  {
    2.41  	struct hvm_info_table *t;
    2.42 -	char signature[] = "HVM INFO";
    2.43  	int i;
    2.44  
    2.45  	if (table != NULL)
    2.46 @@ -63,16 +72,8 @@ get_hvm_info_table(void)
    2.47  
    2.48  	t = (struct hvm_info_table *)(HVM_INFO_PAGE + HVM_INFO_OFFSET);
    2.49  
    2.50 -	/* strncmp(t->signature, "HVM INFO", 8) */
    2.51 -	for (i = 0; i < 8; i++) {
    2.52 -		if (signature[i] != t->signature[i]) {
    2.53 -			puts("Bad hvm info signature\n");
    2.54 -			return NULL;
    2.55 -		}
    2.56 -	}
    2.57 -
    2.58 -	if (!checksum_valid((uint8_t *)t, t->length)) {
    2.59 -		puts("Bad hvm info checksum\n");
    2.60 +	if (!validate_hvm_info(t)) {
    2.61 +		puts("Bad hvm info table\n");
    2.62  		return NULL;
    2.63  	}
    2.64  
    2.65 @@ -126,10 +127,10 @@ acpi_madt_get_madt(unsigned char *acpi_s
    2.66  	return madt;
    2.67  }
    2.68  
    2.69 -static void 
    2.70 +static void
    2.71  set_checksum(void *start, int checksum_offset, int len)
    2.72  {
    2.73 -	unsigned char sum = 0;  
    2.74 +	unsigned char sum = 0;
    2.75  	unsigned char *ptr;
    2.76  
    2.77  	ptr = start;
    2.78 @@ -141,9 +142,9 @@ set_checksum(void *start, int checksum_o
    2.79  	ptr[checksum_offset] = -sum;
    2.80  }
    2.81  
    2.82 -static int 
    2.83 +static int
    2.84  acpi_madt_set_local_apics(
    2.85 -	int nr_vcpu, 
    2.86 +	int nr_vcpu,
    2.87  	ACPI_MULTIPLE_APIC_DESCRIPTION_TABLE *madt)
    2.88  {
    2.89  	int i;
    2.90 @@ -156,14 +157,14 @@ acpi_madt_set_local_apics(
    2.91  		madt->LocalApic[i].Length          = sizeof (ACPI_LOCAL_APIC_STRUCTURE);
    2.92  		madt->LocalApic[i].AcpiProcessorId = i;
    2.93  		madt->LocalApic[i].ApicId          = i;
    2.94 -		madt->LocalApic[i].Flags           = 1; 
    2.95 +		madt->LocalApic[i].Flags           = 1;
    2.96  	}
    2.97  
    2.98  	madt->Header.Header.Length =
    2.99 -		sizeof(ACPI_MULTIPLE_APIC_DESCRIPTION_TABLE) - 
   2.100 +		sizeof(ACPI_MULTIPLE_APIC_DESCRIPTION_TABLE) -
   2.101  		(MAX_VIRT_CPUS - nr_vcpu)* sizeof(ACPI_LOCAL_APIC_STRUCTURE);
   2.102  
   2.103 -	return 0;                            
   2.104 +	return 0;
   2.105  }
   2.106  
   2.107  #define FIELD_OFFSET(TYPE,Field) ((unsigned int)(&(((TYPE *) 0)->Field)))
   2.108 @@ -185,7 +186,7 @@ int acpi_madt_update(unsigned char *acpi
   2.109  		madt, FIELD_OFFSET(ACPI_TABLE_HEADER, Checksum),
   2.110  		madt->Header.Header.Length);
   2.111  
   2.112 -	return 0;              
   2.113 +	return 0;
   2.114  }
   2.115  
   2.116  /*
     3.1 --- a/tools/libxc/xc_vmx_build.c	Mon Jan 02 11:35:29 2006 +0100
     3.2 +++ b/tools/libxc/xc_vmx_build.c	Tue Jan 03 14:35:45 2006 +0100
     3.3 @@ -33,18 +33,6 @@
     3.4  #define E820_MAP_NR_OFFSET  0x000001E8
     3.5  #define E820_MAP_OFFSET     0x000002D0
     3.6  
     3.7 -#define HVM_INFO_PAGE        0x0009F000
     3.8 -#define HVM_INFO_OFFSET      0x00000800
     3.9 -
    3.10 -struct hvm_info_table {
    3.11 -    char     signature[8]; /* "HVM INFO" */
    3.12 -    uint32_t length;
    3.13 -    uint8_t  checksum;
    3.14 -    uint8_t  acpi_enabled;
    3.15 -    uint8_t  pad[2];
    3.16 -    uint32_t nr_vcpus;
    3.17 -};
    3.18 -
    3.19  struct e820entry {
    3.20      uint64_t addr;
    3.21      uint64_t size;
    3.22 @@ -128,7 +116,7 @@ static unsigned char build_e820map(void 
    3.23      return (*(((unsigned char *)e820_page) + E820_MAP_NR_OFFSET) = nr_map);
    3.24  }
    3.25  
    3.26 -static void 
    3.27 +static void
    3.28  set_hvm_info_checksum(struct hvm_info_table *t)
    3.29  {
    3.30      uint8_t *ptr = (uint8_t *)t, sum = 0;
    3.31 @@ -148,7 +136,7 @@ set_hvm_info_checksum(struct hvm_info_ta
    3.32   */
    3.33  static int set_hvm_info(int xc_handle, uint32_t dom,
    3.34                          unsigned long *pfn_list, unsigned int vcpus,
    3.35 -                        unsigned int acpi)
    3.36 +                        unsigned int acpi, unsigned int apic)
    3.37  {
    3.38      char *va_map;
    3.39      struct hvm_info_table *va_hvm;
    3.40 @@ -164,8 +152,9 @@ static int set_hvm_info(int xc_handle, u
    3.41      strncpy(va_hvm->signature, "HVM INFO", 8);
    3.42      va_hvm->length       = sizeof(struct hvm_info_table);
    3.43      va_hvm->acpi_enabled = acpi;
    3.44 +    va_hvm->apic_enabled = apic;
    3.45      va_hvm->nr_vcpus     = vcpus;
    3.46 -    
    3.47 +
    3.48      set_hvm_info_checksum(va_hvm);
    3.49  
    3.50      munmap(va_map, PAGE_SIZE);
    3.51 @@ -307,9 +296,9 @@ static int setup_guest(int xc_handle,
    3.52                         vcpu_guest_context_t *ctxt,
    3.53                         unsigned long shared_info_frame,
    3.54                         unsigned int control_evtchn,
    3.55 -                       unsigned int lapic,
    3.56                         unsigned int vcpus,
    3.57                         unsigned int acpi,
    3.58 +                       unsigned int apic,
    3.59                         unsigned int store_evtchn,
    3.60                         unsigned long *store_mfn)
    3.61  {
    3.62 @@ -519,20 +508,14 @@ static int setup_guest(int xc_handle,
    3.63              goto error_out;
    3.64      }
    3.65  
    3.66 -    if (set_hvm_info(xc_handle, dom, page_array, vcpus, acpi)) {
    3.67 +    if ( set_hvm_info(xc_handle, dom, page_array, vcpus, acpi, apic) ) {
    3.68          fprintf(stderr, "Couldn't set hvm info for VMX guest.\n");
    3.69          goto error_out;
    3.70      }
    3.71  
    3.72 -    *store_mfn = page_array[(v_end-2) >> PAGE_SHIFT];
    3.73 -    if ( xc_clear_domain_page(xc_handle, dom, *store_mfn) )
    3.74 -        goto error_out;
    3.75 -
    3.76 -    shared_page_frame = (v_end - PAGE_SIZE) >> PAGE_SHIFT;
    3.77 -
    3.78 -    if ((e820_page = xc_map_foreign_range(
    3.79 -        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
    3.80 -        page_array[E820_MAP_PAGE >> PAGE_SHIFT])) == 0)
    3.81 +    if ( (e820_page = xc_map_foreign_range(
    3.82 +         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
    3.83 +         page_array[E820_MAP_PAGE >> PAGE_SHIFT])) == 0 )
    3.84          goto error_out;
    3.85      memset(e820_page, 0, PAGE_SIZE);
    3.86      e820_map_nr = build_e820map(e820_page, v_end);
    3.87 @@ -547,26 +530,30 @@ static int setup_guest(int xc_handle,
    3.88      munmap(e820_page, PAGE_SIZE);
    3.89  
    3.90      /* shared_info page starts its life empty. */
    3.91 -    if ((shared_info = xc_map_foreign_range(
    3.92 -        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
    3.93 -        shared_info_frame)) == 0)
    3.94 +    if ( (shared_info = xc_map_foreign_range(
    3.95 +         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
    3.96 +         shared_info_frame)) == 0 )
    3.97          goto error_out;
    3.98      memset(shared_info, 0, sizeof(shared_info_t));
    3.99      /* Mask all upcalls... */
   3.100      for ( i = 0; i < MAX_VIRT_CPUS; i++ )
   3.101          shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
   3.102 -
   3.103      munmap(shared_info, PAGE_SIZE);
   3.104  
   3.105      /* Populate the event channel port in the shared page */
   3.106 -    if ((sp = (shared_iopage_t *) xc_map_foreign_range(
   3.107 -        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   3.108 -        page_array[shared_page_frame])) == 0)
   3.109 +    shared_page_frame = page_array[(v_end >> PAGE_SHIFT) - 1];
   3.110 +    if ( (sp = (shared_iopage_t *) xc_map_foreign_range(
   3.111 +         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   3.112 +         shared_page_frame)) == 0 )
   3.113          goto error_out;
   3.114      memset(sp, 0, PAGE_SIZE);
   3.115      sp->sp_global.eport = control_evtchn;
   3.116      munmap(sp, PAGE_SIZE);
   3.117  
   3.118 +    *store_mfn = page_array[(v_end >> PAGE_SHIFT) - 2];
   3.119 +    if ( xc_clear_domain_page(xc_handle, dom, *store_mfn) )
   3.120 +        goto error_out;
   3.121 +
   3.122      /* Send the page update requests down to the hypervisor. */
   3.123      if ( xc_finish_mmu_updates(xc_handle, mmu) )
   3.124          goto error_out;
   3.125 @@ -588,7 +575,7 @@ static int setup_guest(int xc_handle,
   3.126      ctxt->user_regs.eax = 0;
   3.127      ctxt->user_regs.esp = 0;
   3.128      ctxt->user_regs.ebx = 0; /* startup_32 expects this to be 0 to signal boot cpu */
   3.129 -    ctxt->user_regs.ecx = lapic;
   3.130 +    ctxt->user_regs.ecx = 0;
   3.131      ctxt->user_regs.esi = 0;
   3.132      ctxt->user_regs.edi = 0;
   3.133      ctxt->user_regs.ebp = 0;
   3.134 @@ -608,9 +595,9 @@ int xc_vmx_build(int xc_handle,
   3.135                   int memsize,
   3.136                   const char *image_name,
   3.137                   unsigned int control_evtchn,
   3.138 -                 unsigned int lapic,
   3.139                   unsigned int vcpus,
   3.140                   unsigned int acpi,
   3.141 +                 unsigned int apic,
   3.142                   unsigned int store_evtchn,
   3.143                   unsigned long *store_mfn)
   3.144  {
   3.145 @@ -674,7 +661,7 @@ int xc_vmx_build(int xc_handle,
   3.146  
   3.147      if ( setup_guest(xc_handle, domid, memsize, image, image_size, nr_pages,
   3.148                       ctxt, op.u.getdomaininfo.shared_info_frame, control_evtchn,
   3.149 -                     lapic, vcpus, acpi, store_evtchn, store_mfn) < 0)
   3.150 +                     vcpus, acpi, apic, store_evtchn, store_mfn) < 0)
   3.151      {
   3.152          ERROR("Error constructing guest OS");
   3.153          goto error_out;
     4.1 --- a/tools/libxc/xenguest.h	Mon Jan 02 11:35:29 2006 +0100
     4.2 +++ b/tools/libxc/xenguest.h	Tue Jan 03 14:35:45 2006 +0100
     4.3 @@ -56,9 +56,9 @@ int xc_vmx_build(int xc_handle,
     4.4                   int memsize,
     4.5                   const char *image_name,
     4.6                   unsigned int control_evtchn,
     4.7 -                 unsigned int lapic,
     4.8                   unsigned int vcpus,
     4.9                   unsigned int acpi,
    4.10 +                 unsigned int apic,
    4.11                   unsigned int store_evtchn,
    4.12                   unsigned long *store_mfn);
    4.13  
     5.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Mon Jan 02 11:35:29 2006 +0100
     5.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Tue Jan 03 14:35:45 2006 +0100
     5.3 @@ -362,22 +362,23 @@ static PyObject *pyxc_vmx_build(XcObject
     5.4      uint32_t dom;
     5.5      char *image;
     5.6      int control_evtchn, store_evtchn;
     5.7 +    int memsize;
     5.8      int vcpus = 1;
     5.9 -    int lapic = 0;
    5.10      int acpi = 0;
    5.11 -    int memsize;
    5.12 +    int apic = 0;
    5.13      unsigned long store_mfn = 0;
    5.14  
    5.15      static char *kwd_list[] = { "dom", "control_evtchn", "store_evtchn",
    5.16 -                                "memsize", "image", "lapic", "vcpus", "acpi",NULL };
    5.17 +                                "memsize", "image", "vcpus", "acpi", "apic",
    5.18 +                                NULL };
    5.19  
    5.20      if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiisiii", kwd_list,
    5.21                                        &dom, &control_evtchn, &store_evtchn,
    5.22 -                                      &memsize, &image, &lapic, &vcpus,&acpi) )
    5.23 +                                      &memsize, &image, &vcpus, &acpi, &apic) )
    5.24          return NULL;
    5.25  
    5.26      if ( xc_vmx_build(self->xc_handle, dom, memsize, image, control_evtchn,
    5.27 -                      lapic, vcpus, acpi, store_evtchn, &store_mfn) != 0 )
    5.28 +                      vcpus, acpi, apic, store_evtchn, &store_mfn) != 0 )
    5.29          return PyErr_SetFromErrno(xc_error);
    5.30  
    5.31      return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
     6.1 --- a/tools/python/xen/xend/image.py	Mon Jan 02 11:35:29 2006 +0100
     6.2 +++ b/tools/python/xen/xend/image.py	Tue Jan 03 14:35:45 2006 +0100
     6.3 @@ -209,13 +209,9 @@ class VmxImageHandler(ImageHandler):
     6.4  
     6.5          self.dmargs += self.configVNC(imageConfig)
     6.6  
     6.7 -        self.lapic = 0
     6.8 -        lapic = sxp.child_value(imageConfig, 'lapic')
     6.9 -        if not lapic is None:
    6.10 -            self.lapic = int(lapic)
    6.11 +        self.acpi = int(sxp.child_value(imageConfig, 'acpi', 0))
    6.12 +        self.apic = int(sxp.child_value(imageConfig, 'apic', 0))
    6.13  
    6.14 -        self.acpi = int(sxp.child_value(imageConfig, 'acpi', 0))
    6.15 -        
    6.16      def buildDomain(self):
    6.17          # Create an event channel
    6.18          self.device_channel = xc.evtchn_alloc_unbound(dom=self.vm.getDomid(),
    6.19 @@ -229,18 +225,18 @@ class VmxImageHandler(ImageHandler):
    6.20          log.debug("control_evtchn = %d", self.device_channel)
    6.21          log.debug("store_evtchn   = %d", store_evtchn)
    6.22          log.debug("memsize        = %d", self.vm.getMemoryTarget() / 1024)
    6.23 -        log.debug("lapic          = %d", self.lapic)
    6.24          log.debug("vcpus          = %d", self.vm.getVCpuCount())
    6.25          log.debug("acpi           = %d", self.acpi)
    6.26 +        log.debug("apic           = %d", self.apic)
    6.27  
    6.28          return xc.vmx_build(dom            = self.vm.getDomid(),
    6.29                              image          = self.kernel,
    6.30                              control_evtchn = self.device_channel,
    6.31                              store_evtchn   = store_evtchn,
    6.32                              memsize        = self.vm.getMemoryTarget() / 1024,
    6.33 -                            lapic          = self.lapic,
    6.34 +                            vcpus          = self.vm.getVCpuCount(),
    6.35                              acpi           = self.acpi,
    6.36 -                            vcpus          = self.vm.getVCpuCount())
    6.37 +                            apic           = self.apic)
    6.38  
    6.39      # Return a list of cmd line args to the device models based on the
    6.40      # xm config file
     7.1 --- a/tools/python/xen/xm/create.py	Mon Jan 02 11:35:29 2006 +0100
     7.2 +++ b/tools/python/xen/xm/create.py	Tue Jan 03 14:35:45 2006 +0100
     7.3 @@ -160,14 +160,14 @@ gopts.var('cpus', val='CPUS',
     7.4            fn=set_int, default=None,
     7.5            use="CPUS to run the domain on.")
     7.6  
     7.7 -gopts.var('lapic', val='LAPIC',
     7.8 -          fn=set_int, default=0,
     7.9 -          use="Disable or enable local APIC of VMX domain.")
    7.10 -
    7.11  gopts.var('acpi', val='ACPI',
    7.12            fn=set_int, default=0,
    7.13            use="Disable or enable ACPI of VMX domain.")
    7.14  
    7.15 +gopts.var('apic', val='APIC',
    7.16 +          fn=set_int, default=0,
    7.17 +          use="Disable or enable APIC of VMX domain.")
    7.18 +
    7.19  gopts.var('vcpus', val='VCPUS',
    7.20            fn=set_int, default=1,
    7.21            use="# of Virtual CPUS in domain.")
    7.22 @@ -534,8 +534,8 @@ def configure_vmx(config_image, vals):
    7.23      """
    7.24      args = [ 'device_model', 'vcpus', 'cdrom', 'boot', 'fda', 'fdb',
    7.25               'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'audio',
    7.26 -             'vnc', 'vncviewer', 'sdl', 'display', 'ne2000', 'lapic',
    7.27 -             'xauthority', 'acpi' ]
    7.28 +             'vnc', 'vncviewer', 'sdl', 'display', 'ne2000', 'acpi', 'apic',
    7.29 +             'xauthority' ]
    7.30      for a in args:
    7.31          if (vals.__dict__[a]):
    7.32              config_image.append([a, vals.__dict__[a]])
     8.1 --- a/xen/arch/x86/vmx.c	Mon Jan 02 11:35:29 2006 +0100
     8.2 +++ b/xen/arch/x86/vmx.c	Tue Jan 03 14:35:45 2006 +0100
     8.3 @@ -66,11 +66,6 @@ void vmx_final_setup_guest(struct vcpu *
     8.4          struct domain *d = v->domain;
     8.5          struct vcpu *vc;
     8.6  
     8.7 -        d->arch.vmx_platform.lapic_enable = v->arch.guest_context.user_regs.ecx;
     8.8 -        v->arch.guest_context.user_regs.ecx = 0;
     8.9 -        VMX_DBG_LOG(DBG_LEVEL_VLAPIC, "lapic enable is %d.\n",
    8.10 -                    d->arch.vmx_platform.lapic_enable);
    8.11 -
    8.12          /* Initialize monitor page table */
    8.13          for_each_vcpu(d, vc)
    8.14              vc->arch.monitor_table = mk_pagetable(0);
    8.15 @@ -95,7 +90,7 @@ void vmx_final_setup_guest(struct vcpu *
    8.16  void vmx_relinquish_resources(struct vcpu *v)
    8.17  {
    8.18      struct vmx_virpit *vpit;
    8.19 -    
    8.20 +
    8.21      if ( !VMX_DOMAIN(v) )
    8.22          return;
    8.23  
     9.1 --- a/xen/arch/x86/vmx_vlapic.c	Mon Jan 02 11:35:29 2006 +0100
     9.2 +++ b/xen/arch/x86/vmx_vlapic.c	Tue Jan 03 14:35:45 2006 +0100
     9.3 @@ -62,7 +62,7 @@ int vlapic_find_highest_irr(struct vlapi
     9.4  
     9.5  int vmx_apic_support(struct domain *d)
     9.6  {
     9.7 -    return d->arch.vmx_platform.lapic_enable;
     9.8 +    return d->arch.vmx_platform.apic_enabled;
     9.9  }
    9.10  
    9.11  s_time_t get_apictime_scheduled(struct vcpu *v)
    10.1 --- a/xen/arch/x86/vmx_vmcs.c	Mon Jan 02 11:35:29 2006 +0100
    10.2 +++ b/xen/arch/x86/vmx_vmcs.c	Tue Jan 03 14:35:45 2006 +0100
    10.3 @@ -206,36 +206,56 @@ static void vmx_map_io_shared_page(struc
    10.4                &d->shared_info->evtchn_mask[0]);
    10.5  }
    10.6  
    10.7 -#define VCPU_NR_PAGE        0x0009F000
    10.8 -#define VCPU_NR_OFFSET      0x00000800
    10.9 -#define VCPU_MAGIC          0x76637075  /* "vcpu" */
   10.10 +static int validate_hvm_info(struct hvm_info_table *t)
   10.11 +{
   10.12 +    char signature[] = "HVM INFO";
   10.13 +    uint8_t *ptr = (uint8_t *)t;
   10.14 +    uint8_t sum = 0;
   10.15 +    int i;
   10.16  
   10.17 -static void vmx_set_vcpu_nr(struct domain *d)
   10.18 +    /* strncmp(t->signature, "HVM INFO", 8) */
   10.19 +    for ( i = 0; i < 8; i++ ) {
   10.20 +        if ( signature[i] != t->signature[i] ) {
   10.21 +            printk("Bad hvm info signature\n");
   10.22 +            return 0;
   10.23 +        }
   10.24 +    }
   10.25 +
   10.26 +    for ( i = 0; i < t->length; i++ )
   10.27 +        sum += ptr[i];
   10.28 +
   10.29 +    return (sum == 0);
   10.30 +}
   10.31 +
   10.32 +static void vmx_get_hvm_info(struct domain *d)
   10.33  {
   10.34      unsigned char *p;
   10.35      unsigned long mpfn;
   10.36 -    unsigned int *vcpus;
   10.37 +    struct hvm_info_table *t;
   10.38  
   10.39 -    mpfn = get_mfn_from_pfn(VCPU_NR_PAGE >> PAGE_SHIFT);
   10.40 -    if (mpfn == INVALID_MFN) {
   10.41 -        printk("Can not get vcpu number page mfn for VMX domain.\n");
   10.42 +    mpfn = get_mfn_from_pfn(HVM_INFO_PAGE >> PAGE_SHIFT);
   10.43 +    if ( mpfn == INVALID_MFN ) {
   10.44 +        printk("Can not get hvm info page mfn for VMX domain.\n");
   10.45          domain_crash_synchronous();
   10.46      }
   10.47  
   10.48      p = map_domain_page(mpfn);
   10.49 -    if (p == NULL) {
   10.50 -        printk("Can not map vcpu number page for VMX domain.\n");
   10.51 +    if ( p == NULL ) {
   10.52 +        printk("Can not map hvm info page for VMX domain.\n");
   10.53          domain_crash_synchronous();
   10.54      }
   10.55  
   10.56 -    vcpus = (unsigned int *)(p + VCPU_NR_OFFSET);
   10.57 -    if (vcpus[0] != VCPU_MAGIC) {
   10.58 -        printk("Bad vcpus magic, set vcpu number to 1 by default.\n");
   10.59 -        d->arch.vmx_platform.nr_vcpu = 1;
   10.60 +    t = (struct hvm_info_table *)(p + HVM_INFO_OFFSET);
   10.61 +
   10.62 +    if ( validate_hvm_info(t) ) {
   10.63 +        d->arch.vmx_platform.nr_vcpus = t->nr_vcpus;
   10.64 +        d->arch.vmx_platform.apic_enabled = t->apic_enabled;
   10.65 +    } else {
   10.66 +        printk("Bad hvm info table\n");
   10.67 +        d->arch.vmx_platform.nr_vcpus = 1;
   10.68 +        d->arch.vmx_platform.apic_enabled = 0;
   10.69      }
   10.70  
   10.71 -    d->arch.vmx_platform.nr_vcpu = vcpus[1];
   10.72 -
   10.73      unmap_domain_page(p);
   10.74  }
   10.75  
   10.76 @@ -244,10 +264,10 @@ static void vmx_setup_platform(struct do
   10.77      struct vmx_platform *platform;
   10.78  
   10.79      vmx_map_io_shared_page(d);
   10.80 -    vmx_set_vcpu_nr(d);
   10.81 +    vmx_get_hvm_info(d);
   10.82  
   10.83      platform = &d->arch.vmx_platform;
   10.84 -    pic_init(&platform->vmx_pic,  pic_irq_request, 
   10.85 +    pic_init(&platform->vmx_pic,  pic_irq_request,
   10.86               &platform->interrupt_request);
   10.87      register_pic_io_hook();
   10.88  
    11.1 --- a/xen/include/asm-x86/vmx.h	Mon Jan 02 11:35:29 2006 +0100
    11.2 +++ b/xen/include/asm-x86/vmx.h	Tue Jan 03 14:35:45 2006 +0100
    11.3 @@ -506,7 +506,7 @@ static inline int vmx_reflect_exception(
    11.4  
    11.5  static inline unsigned int vmx_get_vcpu_nr(struct domain *d)
    11.6  {
    11.7 -    return d->arch.vmx_platform.nr_vcpu;
    11.8 +    return d->arch.vmx_platform.nr_vcpus;
    11.9  }
   11.10  
   11.11  static inline shared_iopage_t *get_sp(struct domain *d)
    12.1 --- a/xen/include/asm-x86/vmx_platform.h	Mon Jan 02 11:35:29 2006 +0100
    12.2 +++ b/xen/include/asm-x86/vmx_platform.h	Tue Jan 03 14:35:45 2006 +0100
    12.3 @@ -33,10 +33,10 @@
    12.4      (((size_reg) << 24) | ((index) << 16) | ((seg) << 8) | (flag))
    12.5  
    12.6  #define operand_size(operand)   \
    12.7 -      ((operand >> 24) & 0xFF)
    12.8 +    ((operand >> 24) & 0xFF)
    12.9  
   12.10  #define operand_index(operand)  \
   12.11 -      ((operand >> 16) & 0xFF)
   12.12 +    ((operand >> 16) & 0xFF)
   12.13  
   12.14  /* for instruction.operand[].size */
   12.15  #define BYTE    1
   12.16 @@ -81,13 +81,13 @@ struct instruction {
   12.17  
   12.18  struct vmx_platform {
   12.19      unsigned long          shared_page_va;
   12.20 -    unsigned int           nr_vcpu;
   12.21 -    unsigned int           lapic_enable;
   12.22 +    unsigned int           nr_vcpus;
   12.23 +    unsigned int           apic_enabled;
   12.24  
   12.25      struct vmx_virpit      vmx_pit;
   12.26      struct vmx_io_handler  vmx_io_handler;
   12.27      struct vmx_virpic      vmx_pic;
   12.28 -    struct vmx_vioapic      vmx_vioapic;
   12.29 +    struct vmx_vioapic     vmx_vioapic;
   12.30      unsigned char          round_info[256];
   12.31      spinlock_t             round_robin_lock;
   12.32      int                    interrupt_request;
    13.1 --- a/xen/include/public/io/ioreq.h	Mon Jan 02 11:35:29 2006 +0100
    13.2 +++ b/xen/include/public/io/ioreq.h	Tue Jan 03 14:35:45 2006 +0100
    13.3 @@ -38,21 +38,21 @@
    13.4  /*
    13.5   * VMExit dispatcher should cooperate with instruction decoder to
    13.6   * prepare this structure and notify service OS and DM by sending
    13.7 - * virq 
    13.8 + * virq
    13.9   */
   13.10  typedef struct {
   13.11 -    uint64_t addr;   /*  physical address            */
   13.12 -    uint64_t size;   /*  size in bytes               */
   13.13 -    uint64_t count;  /*  for rep prefixes            */
   13.14 +    uint64_t addr;          /*  physical address            */
   13.15 +    uint64_t size;          /*  size in bytes               */
   13.16 +    uint64_t count;         /*  for rep prefixes            */
   13.17      union {
   13.18 -        uint64_t data;           /*  data                        */
   13.19 -        void    *pdata;          /*  pointer to data             */
   13.20 +        uint64_t data;      /*  data                        */
   13.21 +        void    *pdata;     /*  pointer to data             */
   13.22      } u;
   13.23      uint8_t state:4;
   13.24 -    uint8_t pdata_valid:1; /* if 1, use pdata above  */
   13.25 -    uint8_t dir:1;   /*  1=read, 0=write             */
   13.26 +    uint8_t pdata_valid:1;  /* if 1, use pdata above        */
   13.27 +    uint8_t dir:1;          /*  1=read, 0=write             */
   13.28      uint8_t df:1;
   13.29 -    uint8_t type;    /* I/O type                     */
   13.30 +    uint8_t type;           /* I/O type                     */
   13.31  } ioreq_t;
   13.32  
   13.33  #define MAX_VECTOR      256
   13.34 @@ -61,16 +61,15 @@ typedef struct {
   13.35  #define INTR_LEN_32     (MAX_VECTOR/(BITS_PER_BYTE * sizeof(uint32_t)))
   13.36  
   13.37  typedef struct {
   13.38 -    uint16_t  pic_elcr;
   13.39 -    uint16_t   pic_irr;
   13.40 -    uint16_t   pic_last_irr;
   13.41 -    uint16_t   pic_clear_irr;
   13.42 -    int      eport; /* Event channel port */
   13.43 +    uint16_t    pic_elcr;
   13.44 +    uint16_t    pic_irr;
   13.45 +    uint16_t    pic_last_irr;
   13.46 +    uint16_t    pic_clear_irr;
   13.47 +    int         eport; /* Event channel port */
   13.48  } global_iodata_t;
   13.49  
   13.50  typedef struct {
   13.51 -    ioreq_t       vp_ioreq;
   13.52 -    unsigned long vp_intr[INTR_LEN];
   13.53 +    ioreq_t     vp_ioreq;
   13.54  } vcpu_iodata_t;
   13.55  
   13.56  typedef struct {
   13.57 @@ -78,6 +77,19 @@ typedef struct {
   13.58      vcpu_iodata_t   vcpu_iodata[1];
   13.59  } shared_iopage_t;
   13.60  
   13.61 +#define HVM_INFO_PAGE        0x0009F000
   13.62 +#define HVM_INFO_OFFSET      0x00000800
   13.63 +
   13.64 +struct hvm_info_table {
   13.65 +    char        signature[8]; /* "HVM INFO" */
   13.66 +    uint32_t    length;
   13.67 +    uint8_t     checksum;
   13.68 +    uint8_t     acpi_enabled;
   13.69 +    uint8_t     apic_enabled;
   13.70 +    uint8_t     pad[1];
   13.71 +    uint32_t    nr_vcpus;
   13.72 +};
   13.73 +
   13.74  #endif /* _IOREQ_H_ */
   13.75  
   13.76  /*