Frediano Ziglio
2013-Feb-18 10:10 UTC
[PATCH 0/2] genid: ACPI Windows generation ID updates
These patch update Windows generation ID support on ACPI. First patch mainly update to new specifications while second one introduce again the device in ACPI table. Frediano Ziglio (2): genid: Update Windows generation ID genid: Introduce again Windows generation ID device docs/misc/xenstore-paths.markdown | 6 ++++ tools/firmware/hvmloader/acpi/build.c | 49 ++++++++++++++++++++++---------- tools/firmware/hvmloader/acpi/dsdt.asl | 25 ++++++++++++++++ 3 files changed, 65 insertions(+), 15 deletions(-) -- 1.7.9.5
First draft specification document it as a 64bit counter, now are a 128bit value handled as a couple of 64bit values. Allow to disable the device is values are all zeroes. Add documentation for platform/generation-id key. Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> --- docs/misc/xenstore-paths.markdown | 6 ++++ tools/firmware/hvmloader/acpi/build.c | 49 +++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/docs/misc/xenstore-paths.markdown b/docs/misc/xenstore-paths.markdown index 09e551b..535830e 100644 --- a/docs/misc/xenstore-paths.markdown +++ b/docs/misc/xenstore-paths.markdown @@ -164,6 +164,12 @@ Various platform properties. * acpi_s3 -- is ACPI S3 support enabled for this domain * acpi_s4 -- is ACPI S4 support enabled for this domain +#### ~/platform/generation-id = INTEGER ":" INTEGER [HVM,INTERNAL] + +Two 64 bit values that represent the Windows Generation ID. +Is used by the BIOS initializer to get this value. +If not present or "0:0" (all zeroes) device will not be present to the machine. + ### Frontend device paths Paravirtual device frontends are generally specified by their own diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c index 9026e09..ad9fbb7 100644 --- a/tools/firmware/hvmloader/acpi/build.c +++ b/tools/firmware/hvmloader/acpi/build.c @@ -349,24 +349,45 @@ static int construct_secondary_tables(unsigned long *table_ptrs, return nr_tables; } -unsigned long new_vm_gid(void) +/** + * Allocate and initialize Windows Generation ID + * If value is not present in the XenStore or if all zeroes + * the device will be not active + * + * Return 0 if memory failure, != 0 if success + */ +static int new_vm_gid(struct acpi_info *acpi_info) { - uint64_t gid; - unsigned char *buf; - char addr[11]; - - buf = mem_alloc(8, 8); - if (!buf) return 0; + uint64_t vm_gid[2], *buf; + char addr[12]; + const char * s; + char *end; + + acpi_info->vm_gid_addr = 0; + + /* read ID and check for 0 */ + s = xenstore_read("platform/generation-id", "0:0"); + vm_gid[0] = strtoll(s, &end, 0); + vm_gid[1] = 0; + if ( end && end[0] == '':'' ) + vm_gid[1] = strtoll(end+1, NULL, 0); + if ( !vm_gid[0] && !vm_gid[1] ) + return 1; + + /* copy to allocate BIOS memory */ + buf = (uint64_t *) mem_alloc(sizeof(vm_gid), 8); + if ( !buf ) + return 0; + memcpy(buf, vm_gid, sizeof(vm_gid)); + /* set into ACPI table and XenStore the address */ + acpi_info->vm_gid_addr = virt_to_phys(buf); if ( snprintf(addr, sizeof(addr), "0x%lx", virt_to_phys(buf)) >= sizeof(addr) ) return 0; xenstore_write("hvmloader/generation-id-address", addr); - gid = strtoll(xenstore_read("platform/generation-id", "0"), NULL, 0); - *(uint64_t *)buf = gid; - - return virt_to_phys(buf); + return 1; } void acpi_build_tables(struct acpi_config *config, unsigned int physical) @@ -381,7 +402,6 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical) unsigned char *dsdt; unsigned long secondary_tables[ACPI_MAX_SECONDARY_TABLES]; int nr_secondaries, i; - unsigned long vm_gid_addr; /* Allocate and initialise the acpi info area. */ mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1); @@ -494,8 +514,8 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical) offsetof(struct acpi_20_rsdp, extended_checksum), sizeof(struct acpi_20_rsdp)); - vm_gid_addr = new_vm_gid(); - if (!vm_gid_addr) goto oom; + if ( !new_vm_gid(acpi_info) ) + goto oom; acpi_info->com1_present = uart_exists(0x3f8); acpi_info->com2_present = uart_exists(0x2f8); @@ -503,7 +523,6 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical) acpi_info->hpet_present = hpet_exists(ACPI_HPET_ADDRESS); acpi_info->pci_min = pci_mem_start; acpi_info->pci_len = pci_mem_end - pci_mem_start; - acpi_info->vm_gid_addr = vm_gid_addr; return; -- 1.7.9.5
Frediano Ziglio
2013-Feb-18 10:10 UTC
[PATCH 2/2] genid: Introduce again Windows generation ID device
This device was removed due to change in specifications. Original patch written by Paul Durrant Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> --- tools/firmware/hvmloader/acpi/dsdt.asl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/firmware/hvmloader/acpi/dsdt.asl b/tools/firmware/hvmloader/acpi/dsdt.asl index 64896ce..247a8ad 100644 --- a/tools/firmware/hvmloader/acpi/dsdt.asl +++ b/tools/firmware/hvmloader/acpi/dsdt.asl @@ -397,6 +397,31 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0) IRQNoFlags () {7} }) } + + Device(VGID) { + Name(_HID, EisaId ("XEN0000")) + Name(_UID, 0x00) + Name(_CID, "VM_Gen_Counter") + Name(_DDN, "VM_Gen_Counter") + Method(_STA, 0, NotSerialized) + { + If(LEqual(\_SB.VGIA, 0x00000000)) { + Return(0x00) + } Else { + Return(0x0F) + } + } + Name(PKG, Package () + { + 0x00000000, + 0x00000000 + }) + Method(ADDR, 0, NotSerialized) + { + Store(\_SB.VGIA, Index(PKG, 0)) + Return(PKG) + } + } } } } -- 1.7.9.5
Frediano Ziglio
2013-Feb-19 08:54 UTC
[PATCH 0/2] genid: ACPI Windows generation ID updates
These patch update Windows generation ID support on ACPI. First patch mainly update to new specifications while second one introduce again the device in ACPI table. Frediano Ziglio (2): genid: Update Windows generation ID genid: Introduce again Windows generation ID device docs/misc/xenstore-paths.markdown | 6 ++++ tools/firmware/hvmloader/acpi/build.c | 49 ++++++++++++++++++++++---------- tools/firmware/hvmloader/acpi/dsdt.asl | 25 ++++++++++++++++ 3 files changed, 65 insertions(+), 15 deletions(-) -- 1.7.9.5
First draft specification document it as a 64bit counter, now are a 128bit value handled as a couple of 64bit values. Allow to disable the device is values are all zeroes. Add documentation for platform/generation-id key. Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> --- docs/misc/xenstore-paths.markdown | 6 ++++ tools/firmware/hvmloader/acpi/build.c | 49 +++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/docs/misc/xenstore-paths.markdown b/docs/misc/xenstore-paths.markdown index 09e551b..535830e 100644 --- a/docs/misc/xenstore-paths.markdown +++ b/docs/misc/xenstore-paths.markdown @@ -164,6 +164,12 @@ Various platform properties. * acpi_s3 -- is ACPI S3 support enabled for this domain * acpi_s4 -- is ACPI S4 support enabled for this domain +#### ~/platform/generation-id = INTEGER ":" INTEGER [HVM,INTERNAL] + +Two 64 bit values that represent the Windows Generation ID. +Is used by the BIOS initializer to get this value. +If not present or "0:0" (all zeroes) device will not be present to the machine. + ### Frontend device paths Paravirtual device frontends are generally specified by their own diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c index 9026e09..ad9fbb7 100644 --- a/tools/firmware/hvmloader/acpi/build.c +++ b/tools/firmware/hvmloader/acpi/build.c @@ -349,24 +349,45 @@ static int construct_secondary_tables(unsigned long *table_ptrs, return nr_tables; } -unsigned long new_vm_gid(void) +/** + * Allocate and initialize Windows Generation ID + * If value is not present in the XenStore or if all zeroes + * the device will be not active + * + * Return 0 if memory failure, != 0 if success + */ +static int new_vm_gid(struct acpi_info *acpi_info) { - uint64_t gid; - unsigned char *buf; - char addr[11]; - - buf = mem_alloc(8, 8); - if (!buf) return 0; + uint64_t vm_gid[2], *buf; + char addr[12]; + const char * s; + char *end; + + acpi_info->vm_gid_addr = 0; + + /* read ID and check for 0 */ + s = xenstore_read("platform/generation-id", "0:0"); + vm_gid[0] = strtoll(s, &end, 0); + vm_gid[1] = 0; + if ( end && end[0] == '':'' ) + vm_gid[1] = strtoll(end+1, NULL, 0); + if ( !vm_gid[0] && !vm_gid[1] ) + return 1; + + /* copy to allocate BIOS memory */ + buf = (uint64_t *) mem_alloc(sizeof(vm_gid), 8); + if ( !buf ) + return 0; + memcpy(buf, vm_gid, sizeof(vm_gid)); + /* set into ACPI table and XenStore the address */ + acpi_info->vm_gid_addr = virt_to_phys(buf); if ( snprintf(addr, sizeof(addr), "0x%lx", virt_to_phys(buf)) >= sizeof(addr) ) return 0; xenstore_write("hvmloader/generation-id-address", addr); - gid = strtoll(xenstore_read("platform/generation-id", "0"), NULL, 0); - *(uint64_t *)buf = gid; - - return virt_to_phys(buf); + return 1; } void acpi_build_tables(struct acpi_config *config, unsigned int physical) @@ -381,7 +402,6 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical) unsigned char *dsdt; unsigned long secondary_tables[ACPI_MAX_SECONDARY_TABLES]; int nr_secondaries, i; - unsigned long vm_gid_addr; /* Allocate and initialise the acpi info area. */ mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1); @@ -494,8 +514,8 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical) offsetof(struct acpi_20_rsdp, extended_checksum), sizeof(struct acpi_20_rsdp)); - vm_gid_addr = new_vm_gid(); - if (!vm_gid_addr) goto oom; + if ( !new_vm_gid(acpi_info) ) + goto oom; acpi_info->com1_present = uart_exists(0x3f8); acpi_info->com2_present = uart_exists(0x2f8); @@ -503,7 +523,6 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical) acpi_info->hpet_present = hpet_exists(ACPI_HPET_ADDRESS); acpi_info->pci_min = pci_mem_start; acpi_info->pci_len = pci_mem_end - pci_mem_start; - acpi_info->vm_gid_addr = vm_gid_addr; return; -- 1.7.9.5
Frediano Ziglio
2013-Feb-19 08:54 UTC
[PATCH 2/2] genid: Introduce again Windows generation ID device
This device was removed due to change in specifications. Original patch written by Paul Durrant Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> --- tools/firmware/hvmloader/acpi/dsdt.asl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/firmware/hvmloader/acpi/dsdt.asl b/tools/firmware/hvmloader/acpi/dsdt.asl index 64896ce..247a8ad 100644 --- a/tools/firmware/hvmloader/acpi/dsdt.asl +++ b/tools/firmware/hvmloader/acpi/dsdt.asl @@ -397,6 +397,31 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0) IRQNoFlags () {7} }) } + + Device(VGID) { + Name(_HID, EisaId ("XEN0000")) + Name(_UID, 0x00) + Name(_CID, "VM_Gen_Counter") + Name(_DDN, "VM_Gen_Counter") + Method(_STA, 0, NotSerialized) + { + If(LEqual(\_SB.VGIA, 0x00000000)) { + Return(0x00) + } Else { + Return(0x0F) + } + } + Name(PKG, Package () + { + 0x00000000, + 0x00000000 + }) + Method(ADDR, 0, NotSerialized) + { + Store(\_SB.VGIA, Index(PKG, 0)) + Return(PKG) + } + } } } } -- 1.7.9.5
Possibly Parallel Threads
- [PATCH 0 of 6] Add support for a VM generation ID virtual device (v2)
- [PATCH 0 of 2] Add configuration options to selectively disable S3 and S4 (V3)
- Re: [Qemu-devel] Hvmloader: Modify ACPI to only supply _EJ0 methods for PCIslots that support hotplug by runtime patching
- [PATCH 0 of 2] Support for VM generation ID save/restore and migrate
- [PATCH] v2v: Preserve VM Generation ID (RHBZ#1598350).