Upgrade ACPI SPCR table to support SPCR table version 4 format
cover Upgrade ACPI SPCR table to support SPCR table version 4 format
Update the SPCR table to accommodate the SPCR Table version 4 [1]. The SPCR table has been modified to adhere to the version 4 format [2].
Meanwhile, the virt SPCR golden reference files have been updated to accommodate the SPCR Table version 4.
[1]: https://learn.microsoft.com/en-us/windows-hardware/drivers/serports/serial-port-console-redirection-table
[2]: https://github.com/acpica/acpica/pull/931
Sia Jee Heng (2):
tests/qtest/bios-tables-test: Update virt SPCR golden references hw/acpi: Upgrade ACPI SPCR table to support SPCR table version 4
format
hw/acpi/aml-build.c | 14 +++++++++++--- hw/arm/virt-acpi-build.c | 10 ++++++++-- hw/riscv/virt-acpi-build.c | 10 ++++++++-- include/hw/acpi/acpi-defs.h | 7 +++++-- include/hw/acpi/aml-build.h | 2 +- tests/data/acpi/virt/SPCR | Bin 80 -> 90 bytes 6 files changed, 33 insertions(+), 10 deletions(-)
base-commit: 4977ce198d2390bff8c71ad5cb1a5f6aa24b56fb
Signature · 1 line
2.34.1
PATCH 1/2 tests/qtest/bios-tables-test: Update virt SPCR golden references
Update the virt SPCR golden reference files to accommodate the SPCR Table version 4 [1], utilizing the iasl binary compiled from the latest ACPICA repository [2]. The SPCR table has been modified to adhere to the version 4 format [3].
[1]: https://learn.microsoft.com/en-us/windows-hardware/drivers/serports/serial-port-console-redirection-table
[2]: https://github.com/acpica/acpica
[3]: https://github.com/acpica/acpica/pull/931
Diffs from iasl:
@@ -1,32 +1,32 @@
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20240322 (64-bit version)
* Copyright (c) 2000 - 2023 Intel Corporation
*
- * Disassembly of tests/data/acpi/virt/SPCR
+ * Disassembly of /tmp/aml-HJ5IN2
*
* ACPI Data Table [SPCR]
*
* Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue (in hex) */
[000h 0000 004h] Signature : "SPCR" [Serial Port Console Redirection Table]
-[004h 0004 004h] Table Length : 00000050
-[008h 0008 001h] Revision : 02
-[009h 0009 001h] Checksum : B1
+[004h 0004 004h] Table Length : 0000005A
+[008h 0008 001h] Revision : 04
+[009h 0009 001h] Checksum : 1D
[00Ah 0010 006h] Oem ID : "BOCHS "
[010h 0016 008h] Oem Table ID : "BXPC "
[018h 0024 004h] Oem Revision : 00000001
[01Ch 0028 004h] Asl Compiler ID : "BXPC"
[020h 0032 004h] Asl Compiler Revision : 00000001
[024h 0036 001h] Interface Type : 03
[025h 0037 003h] Reserved : 000000
[028h 0040 00Ch] Serial Port Register : [Generic Address Structure]
[028h 0040 001h] Space ID : 00 [SystemMemory]
[029h 0041 001h] Bit Width : 20
[02Ah 0042 001h] Bit Offset : 00
[02Bh 0043 001h] Encoded Access Width : 03 [DWord Access:32]
[02Ch 0044 008h] Address : 0000000009000000
@@ -34,18 +34,29 @@
[035h 0053 001h] PCAT-compatible IRQ : 00
[036h 0054 004h] Interrupt : 00000021
[03Ah 0058 001h] Baud Rate : 03
[03Bh 0059 001h] Parity : 00
[03Ch 0060 001h] Stop Bits : 01
[03Dh 0061 001h] Flow Control : 02
[03Eh 0062 001h] Terminal Type : 00
[03Fh 0063 001h] Language : 00
[040h 0064 002h] PCI Device ID : FFFF
[042h 0066 002h] PCI Vendor ID : FFFF
[044h 0068 001h] PCI Bus : 00
[045h 0069 001h] PCI Device : 00
[046h 0070 001h] PCI Function : 00
[047h 0071 004h] PCI Flags : 00000000
[04Bh 0075 001h] PCI Segment : 00
[04Ch 0076 004h] Uart Clock Freq : 00000000
-/**** ACPI table terminates in the middle of a data structure! (dump table) -CurrentOffset: 50, TableLength: 50 ***/
\ No newline at end of file
+[050h 0080 004h] Precise Baud rate : 00000000
+[054h 0084 002h] NameSpaceStringLength : 0002
+[056h 0086 002h] NameSpaceStringOffset : 0058
+[058h 0088 002h] NamespaceString : "."
+
+Raw Table Data: Length 90 (0x5A)
+
+ 0000: 53 50 43 52 5A 00 00 00 04 1D 42 4F 43 48 53 20 // SPCRZ.....BOCHS + 0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC + 0020: 01 00 00 00 03 00 00 00 00 20 00 03 00 00 00 09 // ......... ...... + 0030: 00 00 00 00 08 00 21 00 00 00 03 00 01 02 00 00 // ......!......... + 0040: FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 // ................ + 0050: 00 00 00 00 02 00 58 00 2E 00 // ......X...
--- tests/data/acpi/virt/SPCR | Bin 80 -> 90 bytes 1 file changed, 0 insertions(+), 0 deletions(-)
tests/data/acpi/virt/SPCR binary +0 -0
Signature · 1 line
2.34.1
PATCH 2/2 hw/acpi: Upgrade ACPI SPCR table to support SPCR table version 4 format
In reply to Sia Jee HengUpdate the SPCR table to accommodate the SPCR Table version 4 [1]. The SPCR table has been modified to adhere to the version 4 format [2].
[1]: https://learn.microsoft.com/en-us/windows-hardware/drivers/serports/serial-port-console-redirection-table
[2]: https://github.com/acpica/acpica/pull/931
--- hw/acpi/aml-build.c | 14 +++++++++++--- hw/arm/virt-acpi-build.c | 10 ++++++++-- hw/riscv/virt-acpi-build.c | 10 ++++++++-- include/hw/acpi/acpi-defs.h | 7 +++++-- include/hw/acpi/aml-build.h | 2 +- 5 files changed, 33 insertions(+), 10 deletions(-)
hw/acpi/aml-build.c +11 -3
@@ -1996,7 +1996,7 @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags,void build_spcr (GArray *table_data,BIOSLinker *linker,const AcpiSpcrData *f,const uint8_t rev, -const char *oem_id,const char *oem_table_id) +const char *oem_id,const char *oem_table_id,const char *name) {AcpiTable table = { .sig ="SPCR" , .rev = rev, .oem_id = oem_id, .oem_table_id = oem_table_id };
@@ -2042,8 +2042,16 @@ void build_spcr(GArray *table_data, BIOSLinker *linker,build_append_int_noprefix (table_data, f->pci_flags,4 );/* PCI Segment */ build_append_int_noprefix (table_data, f->pci_segment,1 ); -/* Reserved */ -build_append_int_noprefix (table_data,0 ,4 ); +/* UartClkFreq */ +build_append_int_noprefix (table_data, f->uart_clk_freq,4 ); +/* PreciseBaudrate */ +build_append_int_noprefix (table_data, f->precise_baudrate,4 ); +/* NameSpaceStringLength */ +build_append_int_noprefix (table_data, f->namespace_string_length,2 ); +/* NameSpaceStringOffset */ +build_append_int_noprefix (table_data, f->namespace_string_offset,2 ); +/* NamespaceString[] */ +g_array_append_vals (table_data, name, f->namespace_string_length);acpi_table_end (linker, &table); }
hw/arm/virt-acpi-build.c +8 -2
@@ -429,11 +429,12 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)/* * Serial Port Console Redirection Table (SPCR) -* Rev: 1.07 +* Rev: 1.10 */ static void spcr_setup (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) { +const char name[] ="." ;AcpiSpcrData serial = { .interface_type =3 ,/* ARM PL011 UART */ .base_addr.id =AML_AS_SYSTEM_MEMORY ,
@@ -457,9 +458,14 @@ spcr_setup(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) .pci_function = 0, .pci_flags = 0, .pci_segment = 0, + .uart_clk_freq = 0, + .precise_baudrate = 0, + .namespace_string_length = sizeof(name), + .namespace_string_offset = 88, }; -build_spcr (table_data, linker, &serial,2 , vms->oem_id, vms->oem_table_id); +build_spcr (table_data, linker, &serial,4 , vms->oem_id, vms->oem_table_id, + name); }/*
hw/riscv/virt-acpi-build.c +8 -2
@@ -176,12 +176,13 @@ acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap,/* * Serial Port Console Redirection Table (SPCR) -* Rev: 1.07 +* Rev: 1.10 */ static void spcr_setup (GArray *table_data,BIOSLinker *linker,RISCVVirtState *s) { +const char name[] ="." ;AcpiSpcrData serial = { .interface_type =0 ,/* 16550 compatible */ .base_addr.id =AML_AS_SYSTEM_MEMORY ,
@@ -205,9 +206,14 @@ spcr_setup(GArray *table_data, BIOSLinker *linker, RISCVVirtState *s) .pci_function = 0, .pci_flags = 0, .pci_segment = 0, + .uart_clk_freq = 0, + .precise_baudrate = 0, + .namespace_string_length = sizeof(name), + .namespace_string_offset = 88, }; -build_spcr (table_data, linker, &serial,2 , s->oem_id, s->oem_table_id); +build_spcr (table_data, linker, &serial,4 , s->oem_id, s->oem_table_id, + name); }/* RHCT Node[N] starts at offset 56 */
include/hw/acpi/acpi-defs.h +5 -2
@@ -112,7 +112,6 @@ typedef struct AcpiSpcrData {uint8_t flow_control;uint8_t terminal_type;uint8_t language; -uint8_t reserved1;uint16_t pci_device_id;/* Must be 0xffff if not PCI device */ uint16_t pci_vendor_id;/* Must be 0xffff if not PCI device */ uint8_t pci_bus;
@@ -120,7 +119,11 @@ typedef struct AcpiSpcrData {uint8_t pci_function;uint32_t pci_flags;uint8_t pci_segment; -uint32_t reserved2; +uint32_t uart_clk_freq; +uint32_t precise_baudrate; +uint32_t namespace_string_length; +uint32_t namespace_string_offset; +char namespace_string[]; } AcpiSpcrData;#define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0)
include/hw/acpi/aml-build.h +1 -1
@@ -500,5 +500,5 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,void build_spcr (GArray *table_data,BIOSLinker *linker,const AcpiSpcrData *f,const uint8_t rev, -const char *oem_id,const char *oem_table_id); +const char *oem_id,const char *oem_table_id,const char *name);#endif
Signature · 1 line
2.34.1
Quoted 7 lines · Sia Jee Heng
Update the SPCR table to accommodate the SPCR Table version 4 [1]. The SPCR table has been modified to adhere to the version 4 format [2].
Meanwhile, the virt SPCR golden reference files have been updated to accommodate the SPCR Table version 4.
Quoted 7 lines
[1]: https://learn.microsoft.com/en-us/windows-hardware/drivers/serports/serial-port-console-redirection-table
[2]: https://github.com/acpica/acpica/pull/931Sia Jee Heng (2):
tests/qtest/bios-tables-test: Update virt SPCR golden references hw/acpi: Upgrade ACPI SPCR table to support SPCR table version 4
format
This isn't the right way to make a change that requires updates to the bios-tables-test reference files, because "make check" will fail after patch 1 but before patch 2.
You need a three-patch approach. How to do that is documented in the comment at the top of bios-tables-test.c. The resulting three patches should look like:
* patch 1 updates bios-tables-test-allowed-diff.h to mark the affected test or tests as "OK to fail"
* patch 2 makes the changes to QEMU that alter the required table output
* patch 3 updates the reference files and removes the tests from the allowed-diff file
See for instance commits 6c1c2e912fcf9, 1ec896fe7ca938, ea2fde5bccc514 as an example.
Side note: if riscv virt has APCI tables now, maybe we should add testing of them to the bios-tables-test ?
thanks
-- PMM
Quoted 41 lines
-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: Thursday, May 2, 2024 5:19 PM
To: JeeHeng Sia <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v1 0/2] Upgrade ACPI SPCR table to support SPCR table version 4 formatQuoted 7 lines · Sia Jee Heng
Update the SPCR table to accommodate the SPCR Table version 4 [1]. The SPCR table has been modified to adhere to the version 4 format [2].
Meanwhile, the virt SPCR golden reference files have been updated to accommodate the SPCR Table version 4.
Quoted 7 lines
[1]: https://learn.microsoft.com/en-us/windows-hardware/drivers/serports/serial-port-console-redirection-table
[2]: https://github.com/acpica/acpica/pull/931Sia Jee Heng (2):
tests/qtest/bios-tables-test: Update virt SPCR golden references hw/acpi: Upgrade ACPI SPCR table to support SPCR table version 4
formatThis isn't the right way to make a change that requires updates to the bios-tables-test reference files, because "make check" will fail after patch 1 but before patch 2.
You need a three-patch approach. How to do that is documented in the comment at the top of
bios-tables-test.c. The resulting three patches should look like:
* patch 1 updatesbios-tables-test-allowed-diff.hto mark the affected test or tests as "OK to fail"
* patch 2 makes the changes to QEMU that alter the required table output
* patch 3 updates the reference files and removes the tests from the allowed-diff file
Quoted 2 lines
See for instance commits
6c1c2e912fcf9,1ec896fe7ca938,ea2fde5bccc514as an example.
Thank you for the guidance. I will improve the patch by referring to the example provided.
Quoted 3 lines
Side note: if riscv virt has APCI tables now, maybe we should add testing of them to the bios-tables-test ?
Sure. I will make modifications based on the RISC-V test.
Quoted 3 lines
thanks
-- PMM