From: aball@linux.ibm.com Subject: [PATCH] HVM SMBIOS v2 2/5 Date: Wed, 12 Jul 2006 16:29:00 -0400 Message-ID: <20060712162900.u2j83xn5yosowoc8@imap.linux.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_180v7cbs305c" Content-Transfer-Encoding: 7bit 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 This message is in MIME format. --=_180v7cbs305c Content-Type: text/plain; charset=ISO-8859-1; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable [HVM] Add support for SMBIOS to HVM domain builder: make room for the tables in the e820 map and write data needed for the SMBIOS tables to the hvm_info_table struct. Signed-off-by: Andrew D. Ball diff -r a1c2cede77c7 tools/libxc/xc_hvm_build.c --- a/tools/libxc/xc_hvm_build.c=09Mon Jul 10 14:01:49 2006 +++ b/tools/libxc/xc_hvm_build.c=09Wed Jul 12 11:48:10 2006 @@ -60,12 +60,12 @@ /* XXX: Doesn't work for > 4GB yet */ e820entry[nr_map].addr =3D 0x0; - e820entry[nr_map].size =3D 0x9F800; + e820entry[nr_map].size =3D 0x9F000; e820entry[nr_map].type =3D E820_RAM; nr_map++; - e820entry[nr_map].addr =3D 0x9F800; - e820entry[nr_map].size =3D 0x800; + e820entry[nr_map].addr =3D 0x9F000; + e820entry[nr_map].size =3D 0x1000; e820entry[nr_map].type =3D E820_RESERVED; nr_map++; @@ -135,12 +135,15 @@ * Use E820 reserved memory 0x9F800 to pass HVM info to hvmloader * hvmloader will use this info to set BIOS accordingly */ -static int set_hvm_info(int xc_handle, uint32_t dom, +static int set_hvm_info(int xc_handle, uint32_t dom, uint64_t memsize, xen_pfn_t *pfn_list, unsigned int vcpus, - unsigned int pae, unsigned int acpi, unsigned =20 int apic) + unsigned int pae, unsigned int acpi, unsigned =20 int apic, + uint8_t *uuid) { char *va_map; struct hvm_info_table *va_hvm; + uint32_t xen_version; + char xen_extra_version[XEN_EXTRAVERSION_LEN]; va_map =3D xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE, @@ -158,6 +161,22 @@ va_hvm->apic_enabled =3D apic; va_hvm->pae_enabled =3D pae; va_hvm->nr_vcpus =3D vcpus; + va_hvm->memsize =3D memsize; + memcpy(va_hvm->uuid, uuid, 16); + + xen_version =3D xc_version(xc_handle, XENVER_version, NULL); + va_hvm->xen_major_version =3D (uint16_t) (xen_version >> 16); + va_hvm->xen_minor_version =3D (uint16_t) xen_version; + + if (xc_version(xc_handle, XENVER_extraversion, &xen_extra_version)) { + PERROR("Could not get Xen extra version for HVM info table!"); + return -1; + } + + snprintf(va_hvm->xen_version, sizeof(va_hvm->xen_version), + "%hd.%hd%s", va_hvm->xen_major_version, =20 va_hvm->xen_minor_version, + xen_extra_version); + va_hvm->xen_version[sizeof(va_hvm->xen_version)-1] =3D '\0'; set_hvm_info_checksum(va_hvm); @@ -177,7 +196,8 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn) + unsigned long *store_mfn, + uint8_t *uuid) { xen_pfn_t *page_array =3D NULL; unsigned long count, i; @@ -250,7 +270,8 @@ goto error_out; } - if ( set_hvm_info(xc_handle, dom, page_array, vcpus, pae, acpi, apic) ) + if ( set_hvm_info(xc_handle, dom, memsize, page_array, vcpus, pae, acpi= , + apic, uuid) ) { ERROR("Couldn't set hvm info for HVM guest.\n"); goto error_out; @@ -347,7 +368,8 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn) + unsigned long *store_mfn, + uint8_t *uuid) { dom0_op_t launch_op, op; int rc, i; @@ -400,7 +422,8 @@ ctxt->flags =3D VGCF_HVM_GUEST; if ( setup_guest(xc_handle, domid, memsize, image, image_size, nr_page= s, ctxt, op.u.getdomaininfo.shared_info_frame, - vcpus, pae, acpi, apic, store_evtchn, store_mfn) < 0) + vcpus, pae, acpi, apic, store_evtchn, store_mfn, + uuid) < 0) { ERROR("Error constructing guest OS"); goto error_out; @@ -593,7 +616,8 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn) + unsigned long *store_mfn, + uint8_t *uuid) { char *image; int sts; @@ -606,7 +630,7 @@ sts =3D xc_hvm_build_internal(xc_handle, domid, memsize, image, image_size, vcpus, pae, acpi, apic, - store_evtchn, store_mfn); + store_evtchn, store_mfn, uuid); free(image); @@ -629,7 +653,8 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn) + unsigned long *store_mfn, + uint8_t *uuid) { int sts; unsigned long img_len; @@ -653,7 +678,7 @@ sts =3D xc_hvm_build_internal(xc_handle, domid, memsize, img, img_len, vcpus, pae, acpi, apic, - store_evtchn, store_mfn); + store_evtchn, store_mfn, uuid); /* xc_inflate_buffer may return the original buffer pointer (for for already inflated buffers), so exercise some care in freeing */ diff -r a1c2cede77c7 tools/libxc/xenguest.h --- a/tools/libxc/xenguest.h=09Mon Jul 10 14:01:49 2006 +++ b/tools/libxc/xenguest.h=09Wed Jul 12 11:48:10 2006 @@ -111,7 +111,8 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn); + unsigned long *store_mfn, + uint8_t *uuid); int xc_hvm_build_mem(int xc_handle, uint32_t domid, @@ -123,6 +124,7 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn); + unsigned long *store_mfn, + uint8_t *uuid); #endif /* XENGUEST_H */ diff -r a1c2cede77c7 tools/libxc/xg_private.c --- a/tools/libxc/xg_private.c=09Mon Jul 10 14:01:49 2006 +++ b/tools/libxc/xg_private.c=09Wed Jul 12 11:48:10 2006 @@ -156,7 +156,8 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn) + unsigned long *store_mfn, + uint8_t *uuid) { return -ENOSYS; } --=_180v7cbs305c Content-Type: text/x-patch; charset=UTF-8; name="smbios_2-libxenguest.patch" Content-Disposition: attachment; filename="smbios_2-libxenguest.patch" Content-Transfer-Encoding: quoted-printable [HVM] Add support for SMBIOS to HVM domain builder: make room for the tables in the e820 map and write data needed for the SMBIOS tables to the hvm_info_table struct. Signed-off-by: Andrew D. Ball diff -r a1c2cede77c7 tools/libxc/xc_hvm_build.c --- a/tools/libxc/xc_hvm_build.c=09Mon Jul 10 14:01:49 2006 +++ b/tools/libxc/xc_hvm_build.c=09Wed Jul 12 11:48:10 2006 @@ -60,12 +60,12 @@ =20 /* XXX: Doesn't work for > 4GB yet */ e820entry[nr_map].addr =3D 0x0; - e820entry[nr_map].size =3D 0x9F800; + e820entry[nr_map].size =3D 0x9F000; e820entry[nr_map].type =3D E820_RAM; nr_map++; =20 - e820entry[nr_map].addr =3D 0x9F800; - e820entry[nr_map].size =3D 0x800; + e820entry[nr_map].addr =3D 0x9F000; + e820entry[nr_map].size =3D 0x1000; e820entry[nr_map].type =3D E820_RESERVED; nr_map++; =20 @@ -135,12 +135,15 @@ * Use E820 reserved memory 0x9F800 to pass HVM info to hvmloader * hvmloader will use this info to set BIOS accordingly */ -static int set_hvm_info(int xc_handle, uint32_t dom, +static int set_hvm_info(int xc_handle, uint32_t dom, uint64_t memsize, xen_pfn_t *pfn_list, unsigned int vcpus, - unsigned int pae, unsigned int acpi, unsigned int a= pic) + unsigned int pae, unsigned int acpi, unsigned int a= pic, + uint8_t *uuid) { char *va_map; struct hvm_info_table *va_hvm; + uint32_t xen_version; + char xen_extra_version[XEN_EXTRAVERSION_LEN]; =20 va_map =3D xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE, @@ -158,6 +161,22 @@ va_hvm->apic_enabled =3D apic; va_hvm->pae_enabled =3D pae; va_hvm->nr_vcpus =3D vcpus; + va_hvm->memsize =3D memsize; + memcpy(va_hvm->uuid, uuid, 16); + + xen_version =3D xc_version(xc_handle, XENVER_version, NULL); + va_hvm->xen_major_version =3D (uint16_t) (xen_version >> 16); + va_hvm->xen_minor_version =3D (uint16_t) xen_version; + + if (xc_version(xc_handle, XENVER_extraversion, &xen_extra_version)) { + PERROR("Could not get Xen extra version for HVM info table!"); + return -1; + } + + snprintf(va_hvm->xen_version, sizeof(va_hvm->xen_version), + "%hd.%hd%s", va_hvm->xen_major_version, va_hvm->xen_minor_vers= ion, + xen_extra_version); + va_hvm->xen_version[sizeof(va_hvm->xen_version)-1] =3D '\0'; =20 set_hvm_info_checksum(va_hvm); =20 @@ -177,7 +196,8 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn) + unsigned long *store_mfn, + uint8_t *uuid) { xen_pfn_t *page_array =3D NULL; unsigned long count, i; @@ -250,7 +270,8 @@ goto error_out; } =20 - if ( set_hvm_info(xc_handle, dom, page_array, vcpus, pae, acpi, apic) ) + if ( set_hvm_info(xc_handle, dom, memsize, page_array, vcpus, pae, acpi= , + apic, uuid) ) { ERROR("Couldn't set hvm info for HVM guest.\n"); goto error_out; @@ -347,7 +368,8 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn) + unsigned long *store_mfn, + uint8_t *uuid) { dom0_op_t launch_op, op; int rc, i; @@ -400,7 +422,8 @@ ctxt->flags =3D VGCF_HVM_GUEST; if ( setup_guest(xc_handle, domid, memsize, image, image_size, nr_pages= , ctxt, op.u.getdomaininfo.shared_info_frame, - vcpus, pae, acpi, apic, store_evtchn, store_mfn) < 0) + vcpus, pae, acpi, apic, store_evtchn, store_mfn, + uuid) < 0) { ERROR("Error constructing guest OS"); goto error_out; @@ -593,7 +616,8 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn) + unsigned long *store_mfn, + uint8_t *uuid) { char *image; int sts; @@ -606,7 +630,7 @@ sts =3D xc_hvm_build_internal(xc_handle, domid, memsize, image, image_size, vcpus, pae, acpi, apic, - store_evtchn, store_mfn); + store_evtchn, store_mfn, uuid); =20 free(image); =20 @@ -629,7 +653,8 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn) + unsigned long *store_mfn, + uint8_t *uuid) { int sts; unsigned long img_len; @@ -653,7 +678,7 @@ sts =3D xc_hvm_build_internal(xc_handle, domid, memsize, img, img_len, vcpus, pae, acpi, apic, - store_evtchn, store_mfn); + store_evtchn, store_mfn, uuid); =20 /* xc_inflate_buffer may return the original buffer pointer (for for already inflated buffers), so exercise some care in freeing */ diff -r a1c2cede77c7 tools/libxc/xenguest.h --- a/tools/libxc/xenguest.h=09Mon Jul 10 14:01:49 2006 +++ b/tools/libxc/xenguest.h=09Wed Jul 12 11:48:10 2006 @@ -111,7 +111,8 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn); + unsigned long *store_mfn, + uint8_t *uuid); =20 int xc_hvm_build_mem(int xc_handle, uint32_t domid, @@ -123,6 +124,7 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn); + unsigned long *store_mfn, + uint8_t *uuid); =20 #endif /* XENGUEST_H */ diff -r a1c2cede77c7 tools/libxc/xg_private.c --- a/tools/libxc/xg_private.c=09Mon Jul 10 14:01:49 2006 +++ b/tools/libxc/xg_private.c=09Wed Jul 12 11:48:10 2006 @@ -156,7 +156,8 @@ unsigned int acpi, unsigned int apic, unsigned int store_evtchn, - unsigned long *store_mfn) + unsigned long *store_mfn, + uint8_t *uuid) { return -ENOSYS; } --=_180v7cbs305c 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 --=_180v7cbs305c--