RISC-V: ACPI: Namespace updates
v3 cover RISC-V: ACPI: Namespace updates
This series adds few updates to RISC-V ACPI namespace for virt platform. Additionally, it has patches to enable ACPI table testing for RISC-V.
1) PCI Link devices need to be created outside the scope of the PCI root complex to ensure correct probe ordering by the OS. This matches the example given in ACPI spec as well.
2) Add PLIC and APLIC as platform devices as well to ensure probing order as per BRS spec [1] requirement.
3) BRS spec requires RISC-V to use new ACPI ID for the generic UART. So, update the HID of the UART.
4) Enabled ACPI tables tests for RISC-V which were originally part of
[2] but couldn't get merged due to updates required in the expected AML files. I think combining those patches with this series makes it easier to merge since expected AML files are updated.
[1] - https://github.com/riscv-non-isa/riscv-brs/blob/main/acpi.adoc
[2] - https://lists.gnu.org/archive/html/qemu-devel/2024-06/msg04734.html
Changes since v2:
1) Updated commit message with exact requirement in the BRS.
2) Addressed Igor's comments.
3) Rebased and updated tags.
Changes since v1:
1) Made changes in gpex-acpi.c generic as per feedback from Michael. This changes the DSDT for aarch64/virt and microvm machines. Hence, few patches are added to update the expected DSDT files for those machine so that CI tests don't fail.
2) Added patches to enable ACPI tables tests for RISC-V including a patch to remove the fallback path to search for expected AML files.
3) Rebased and added tags.
Sunil V L (9):
hw/riscv/virt-acpi-build.c: Add namespace devices for PLIC and APLIC hw/riscv/virt-acpi-build.c: Update the HID of RISC-V UART tests/acpi: Allow DSDT acpi table changes for aarch64 acpi/gpex: Create PCI link devices outside PCI root bridge tests/acpi: update expected DSDT blob for aarch64 and microvm tests/qtest/bios-tables-test.c: Remove the fall back path tests/acpi: Add empty ACPI data files for RISC-V tests/qtest/bios-tables-test.c: Enable basic testing for RISC-V tests/acpi: Add expected ACPI AML files for RISC-V
hw/pci-host/gpex-acpi.c | 13 +++--- hw/riscv/virt-acpi-build.c | 34 ++++++++++++++- tests/data/acpi/aarch64/virt/DSDT | Bin 5196 -> 5196 bytes .../data/acpi/aarch64/virt/DSDT.acpihmatvirt | Bin 5282 -> 5282 bytes tests/data/acpi/aarch64/virt/DSDT.memhp | Bin 6557 -> 6557 bytes tests/data/acpi/aarch64/virt/DSDT.pxb | Bin 7679 -> 7679 bytes tests/data/acpi/aarch64/virt/DSDT.topology | Bin 5398 -> 5398 bytes tests/data/acpi/riscv64/virt/APIC | Bin 0 -> 116 bytes tests/data/acpi/riscv64/virt/DSDT | Bin 0 -> 3576 bytes tests/data/acpi/riscv64/virt/FACP | Bin 0 -> 276 bytes tests/data/acpi/riscv64/virt/MCFG | Bin 0 -> 60 bytes tests/data/acpi/riscv64/virt/RHCT | Bin 0 -> 332 bytes tests/data/acpi/riscv64/virt/SPCR | Bin 0 -> 80 bytes tests/data/acpi/x86/microvm/DSDT.pcie | Bin 3023 -> 3023 bytes tests/qtest/bios-tables-test.c | 40 ++++++++++++------ 15 files changed, 66 insertions(+), 21 deletions(-) create mode 100644 tests/data/acpi/riscv64/virt/APIC create mode 100644 tests/data/acpi/riscv64/virt/DSDT create mode 100644 tests/data/acpi/riscv64/virt/FACP create mode 100644 tests/data/acpi/riscv64/virt/MCFG create mode 100644 tests/data/acpi/riscv64/virt/RHCT create mode 100644 tests/data/acpi/riscv64/virt/SPCR
Signature · 1 line
2.43.0
PATCH v3 1/9 hw/riscv/virt-acpi-build.c: Add namespace devices for PLIC and APLIC
As per the requirement ACPI_080 in the RISC-V Boot and Runtime Services (BRS) specification [1], PLIC and APLIC should be in namespace as well. So, add them using the defined HID.
[1] - https://github.com/riscv-non-isa/riscv-brs/blob/main/acpi.adoc
(commit : 241575b3189c5d9e60b5e55e78cf0443092713bf)
--- hw/riscv/virt-acpi-build.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
hw/riscv/virt-acpi-build.c +32 -0
@@ -141,6 +141,30 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtState *s) } } +static void acpi_dsdt_add_plic_aplic (Aml *scope,uint8_t socket_count, +uint64_t mmio_base,uint64_t mmio_size, +const char *hid) +{ +uint64_t plic_aplic_addr; +uint32_t gsi_base; +uint8_t socket; + +for (socket =0 ; socket < socket_count; socket++) { + plic_aplic_addr = mmio_base + mmio_size * socket; + gsi_base =VIRT_IRQCHIP_NUM_SOURCES * socket; +Aml *dev =aml_device ("IC%.02X" , socket); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("%s" , hid))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (socket))); +aml_append (dev,aml_name_decl ("_GSB" ,aml_int (gsi_base))); + +Aml *crs =aml_resource_template (); +aml_append (crs,aml_memory32_fixed (plic_aplic_addr, mmio_size, +AML_READ_WRITE )); +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (scope, dev); + } +} +static void acpi_dsdt_add_uart (Aml *scope,const MemMapEntry *uart_memmap,uint32_t uart_irq)
@@ -411,6 +435,14 @@ static void build_dsdt(GArray *table_data, socket_count =riscv_socket_count (ms); +if (s->aia_type ==VIRT_AIA_TYPE_NONE ) { +acpi_dsdt_add_plic_aplic (scope, socket_count, memmap[VIRT_PLIC ].base, + memmap[VIRT_PLIC ].size,"RSCV0001" ); + }else { +acpi_dsdt_add_plic_aplic (scope, socket_count, memmap[VIRT_APLIC_S ].base, + memmap[VIRT_APLIC_S ].size,"RSCV0002" ); + } +acpi_dsdt_add_uart (scope, &memmap[VIRT_UART0 ],UART0_IRQ );if (socket_count ==1 ) {
Signature · 1 line
2.43.0
Re: [PATCH v3 1/9] hw/riscv/virt-acpi-build.c: Add namespace devices for PLIC and APLIC
Quoted 6 lines · On Mon, 15 Jul 2024 22:41:21 +0530 Sunil V L <[email protected]> wrote:
As per the requirement
ACPI_080in the RISC-V Boot and Runtime Services (BRS) specification [1], PLIC and APLIC should be in namespace as well. So, add them using the defined HID.[1] - https://github.com/riscv-non-isa/riscv-brs/blob/main/acpi.adoc
(commit : 241575b3189c5d9e60b5e55e78cf0443092713bf)
in spec links 'See RVI ACPI IDs' and right below it 'additional guidance', do lead nowhere hence do not clarify anything.
Quoted 3 lines
Signed-off-by Sunil V L <[email protected]>Acked-by Alistair Francis <[email protected]>
Quoted 54 lines
--- hw/riscv/virt-acpi-build.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)hw/riscv/virt-acpi-build.c +32
-0@@ -141,6 +141,30 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtState *s) } } +static void acpi_dsdt_add_plic_aplic (Aml *scope,uint8_t socket_count, +uint64_t mmio_base,uint64_t mmio_size, +const char *hid) +{ +uint64_t plic_aplic_addr; +uint32_t gsi_base; +uint8_t socket; + +for (socket =0 ; socket < socket_count; socket++) { + plic_aplic_addr = mmio_base + mmio_size * socket; + gsi_base =VIRT_IRQCHIP_NUM_SOURCES * socket; +Aml *dev =aml_device ("IC%.02X" , socket); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("%s" , hid))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (socket))); +aml_append (dev,aml_name_decl ("_GSB" ,aml_int (gsi_base))); + +Aml *crs =aml_resource_template (); +aml_append (crs,aml_memory32_fixed (plic_aplic_addr, mmio_size, +AML_READ_WRITE )); +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (scope, dev); + } +} +static void acpi_dsdt_add_uart (Aml *scope,const MemMapEntry *uart_memmap,uint32_t uart_irq)@@ -411,6 +435,14 @@ static void build_dsdt(GArray *table_data, socket_count =riscv_socket_count (ms); +if (s->aia_type ==VIRT_AIA_TYPE_NONE ) { +acpi_dsdt_add_plic_aplic (scope, socket_count, memmap[VIRT_PLIC ].base, + memmap[VIRT_PLIC ].size,"RSCV0001" ); + }else { +acpi_dsdt_add_plic_aplic (scope, socket_count, memmap[VIRT_APLIC_S ].base, + memmap[VIRT_APLIC_S ].size,"RSCV0002" ); + } +acpi_dsdt_add_uart (scope, &memmap[VIRT_UART0 ],UART0_IRQ );if (socket_count ==1 ) {
Re: [PATCH v3 1/9] hw/riscv/virt-acpi-build.c: Add namespace devices for PLIC and APLIC
Quoted 7 lines · Igor Mammedov
Quoted 4 lines · On Mon, 15 Jul 2024 22:41:21 +0530 Sunil V L <[email protected]> wrote:
As per the requirement
ACPI_080in the RISC-V Boot and Runtime Services (BRS) specification [1], PLIC and APLIC should be in namespace as well. So, add them using the defined HID.
Quoted 6 lines
Quoted 2 lines
[1] - https://github.com/riscv-non-isa/riscv-brs/blob/main/acpi.adoc
(commit : 241575b3189c5d9e60b5e55e78cf0443092713bf)in spec links 'See RVI ACPI IDs' and right below it 'additional guidance', do lead nowhere hence do not clarify anything.
Thanks Igor. I didn't realize links work only in the final PDF generated from the sources. Let me point to the PDF itself where these requirements were documented first.
Thanks,
Sunil
Quoted 61 lines
Quoted 3 lines
Signed-off-by Sunil V L <[email protected]>Acked-by Alistair Francis <[email protected]>Acked-by Igor Mammedov <[email protected]>Quoted 54 lines
--- hw/riscv/virt-acpi-build.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)hw/riscv/virt-acpi-build.c +32
-0@@ -141,6 +141,30 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtState *s) } } +static void acpi_dsdt_add_plic_aplic (Aml *scope,uint8_t socket_count, +uint64_t mmio_base,uint64_t mmio_size, +const char *hid) +{ +uint64_t plic_aplic_addr; +uint32_t gsi_base; +uint8_t socket; + +for (socket =0 ; socket < socket_count; socket++) { + plic_aplic_addr = mmio_base + mmio_size * socket; + gsi_base =VIRT_IRQCHIP_NUM_SOURCES * socket; +Aml *dev =aml_device ("IC%.02X" , socket); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("%s" , hid))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (socket))); +aml_append (dev,aml_name_decl ("_GSB" ,aml_int (gsi_base))); + +Aml *crs =aml_resource_template (); +aml_append (crs,aml_memory32_fixed (plic_aplic_addr, mmio_size, +AML_READ_WRITE )); +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (scope, dev); + } +} +static void acpi_dsdt_add_uart (Aml *scope,const MemMapEntry *uart_memmap,uint32_t uart_irq)@@ -411,6 +435,14 @@ static void build_dsdt(GArray *table_data, socket_count =riscv_socket_count (ms); +if (s->aia_type ==VIRT_AIA_TYPE_NONE ) { +acpi_dsdt_add_plic_aplic (scope, socket_count, memmap[VIRT_PLIC ].base, + memmap[VIRT_PLIC ].size,"RSCV0001" ); + }else { +acpi_dsdt_add_plic_aplic (scope, socket_count, memmap[VIRT_APLIC_S ].base, + memmap[VIRT_APLIC_S ].size,"RSCV0002" ); + } +acpi_dsdt_add_uart (scope, &memmap[VIRT_UART0 ],UART0_IRQ );if (socket_count ==1 ) {
PATCH v3 2/9 hw/riscv/virt-acpi-build.c: Update the HID of RISC-V UART
In reply to Sunil V LThe requirement ACPI_060 in the RISC-V BRS specification [1], requires NS16550 compatible UART to have the HID RSCV0003. So, update the HID for the UART.
[1] - https://github.com/riscv-non-isa/riscv-brs/commits/main/acpi.adoc
(commit: 7bfa87e86ad5658283731207dbfc8ab3744d3265)
--- hw/riscv/virt-acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/virt-acpi-build.c +1 -1
@@ -170,7 +170,7 @@ acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uint32_t uart_irq) {Aml *dev =aml_device ("COM0" ); -aml_append (dev,aml_name_decl ("_HID" ,aml_string ("PNP0501" ))); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("RSCV0003" )));aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 )));Aml *crs =aml_resource_template ();
Signature · 1 line
2.43.0
Re: [PATCH v3 2/9] hw/riscv/virt-acpi-build.c: Update the HID of RISC-V UART
Quoted 5 lines · On Mon, 15 Jul 2024 22:41:22 +0530 Sunil V L <[email protected]> wrote:
The requirement
ACPI_060in the RISC-V BRS specification [1], requires NS16550 compatible UART to have the HID RSCV0003. So, update the HID for the UART.[1] - https://github.com/riscv-non-isa/riscv-brs/commits/main/acpi.adoc
this should point to text like in previous patch and not to commit
Quoted 4 lines
(commit: 7bfa87e86ad5658283731207dbfc8ab3744d3265)Signed-off-by Sunil V L <[email protected]>Acked-by Alistair Francis <[email protected]>
with above fixed:
Quoted 17 lines
--- hw/riscv/virt-acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/riscv/virt-acpi-build.c +1
-1@@ -170,7 +170,7 @@ acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uint32_t uart_irq) {Aml *dev =aml_device ("COM0" ); -aml_append (dev,aml_name_decl ("_HID" ,aml_string ("PNP0501" ))); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("RSCV0003" )));aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 )));Aml *crs =aml_resource_template ();
PATCH v3 3/9 tests/acpi: Allow DSDT acpi table changes for aarch64
In reply to Sunil V Lso that CI tests don't fail when those ACPI tables are updated in the next patch. This is as per the documentation in bios-tables-tests.c.
--- tests/qtest/bios-tables-test-allowed-diff.h | 6 ++++++ 1 file changed, 6 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +6 -0
@@ -1 +1,7 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/aarch64/virt/DSDT" , +"tests/data/acpi/aarch64/virt/DSDT.memhp" , +"tests/data/acpi/aarch64/virt/DSDT.topology" , +"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt" , +"tests/data/acpi/aarch64/virt/DSDT.pxb" , +"tests/data/acpi/x86/microvm/DSDT.pcie",
Signature · 1 line
2.43.0
PATCH v3 4/9 acpi/gpex: Create PCI link devices outside PCI root bridge
In reply to Sunil V LCurrently, PCI link devices (PNP0C0F) are always created within the scope of the PCI root bridge. However, RISC-V needs these link devices to be created outside to ensure the probing order in the OS. This matches the example given in the ACPI specification [1] as well. Hence, create these link devices directly under _SB instead of under the PCI root bridge.
To keep these link device names unique for multiple PCI bridges, change the device name from GSIx to LXXY format where XX is the PCI bus number and Y is the INTx.
GPEX is currently used by riscv, aarch64/virt and x86/microvm machines. So, this change will alter the DSDT for those systems.
[1] - ACPI 5.1: 6.2.13.1 Example: Using _PRT to Describe PCI IRQ Routing
--- hw/pci-host/gpex-acpi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
hw/pci-host/gpex-acpi.c +7 -6
@@ -7,7 +7,8 @@#include "hw/pci/pcie_host.h" #include "hw/acpi/cxl.h" -static void acpi_dsdt_add_pci_route_table (Aml *dev,uint32_t irq) +static void acpi_dsdt_add_pci_route_table (Aml *dev,uint32_t irq, +Aml *scope,uint8_t bus_num) {Aml *method, *crs;int i, slot_no;
@@ -20,7 +21,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq)Aml *pkg =aml_package (4 );aml_append (pkg,aml_int ((slot_no <<16 ) |0xFFFF ));aml_append (pkg,aml_int (i)); -aml_append (pkg,aml_name ("GSI%d" , gsi)); +aml_append (pkg,aml_name ("L%.02X%X" , bus_num, gsi));aml_append (pkg,aml_int (0 ));aml_append (rt_pkg, pkg); }
@@ -30,7 +31,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq)/* Create GSI link device */ for (i =0 ; i <PCI_NUM_PINS ; i++) {uint32_t irqs = irq + i; -Aml *dev_gsi =aml_device ("GSI%d" , i); +Aml *dev_gsi =aml_device ("L%.02X%X" , bus_num, i);aml_append (dev_gsi,aml_name_decl ("_HID" ,aml_string ("PNP0C0F" )));aml_append (dev_gsi,aml_name_decl ("_UID" ,aml_int (i))); crs =aml_resource_template ();
@@ -45,7 +46,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq)aml_append (dev_gsi,aml_name_decl ("_CRS" , crs)); method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED );aml_append (dev_gsi, method); -aml_append (dev, dev_gsi); +aml_append (scope, dev_gsi); } }
@@ -174,7 +175,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)aml_append (dev,aml_name_decl ("_PXM" ,aml_int (numa_node))); } -acpi_dsdt_add_pci_route_table (dev, cfg->irq); +acpi_dsdt_add_pci_route_table (dev, cfg->irq, scope, bus_num);/* * Resources defined for PXBs are composed of the following parts:
@@ -205,7 +206,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)aml_append (dev,aml_name_decl ("_STR" ,aml_unicode ("PCIe 0 Device" )));aml_append (dev,aml_name_decl ("_CCA" ,aml_int (1 ))); -acpi_dsdt_add_pci_route_table (dev, cfg->irq); +acpi_dsdt_add_pci_route_table (dev, cfg->irq, scope,0 ); method =aml_method ("_CBA" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (cfg->ecam.base)));
Signature · 1 line
2.43.0
Re: [PATCH v3 4/9] acpi/gpex: Create PCI link devices outside PCI root bridge
Quoted 11 lines · On Mon, 15 Jul 2024 22:41:24 +0530 Sunil V L <[email protected]> wrote:
Currently, PCI link devices (PNP0C0F) are always created within the scope of the PCI root bridge. However, RISC-V needs these link devices to be created outside to ensure the probing order in the OS. This matches the example given in the ACPI specification [1] as well. Hence, create these link devices directly under
_SBinstead of under the PCI root bridge.To keep these link device names unique for multiple PCI bridges, change the device name from GSIx to LXXY format where XX is the PCI bus number and Y is the INTx.
Quoted 6 lines
GPEX is currently used by riscv, aarch64/virt and x86/microvm machines. So, this change will alter the DSDT for those systems.
[1] - ACPI 5.1: 6.2.13.1 Example: Using
_PRTto Describe PCI IRQ RoutingSigned-off-by Sunil V L <[email protected]>
Quoted 63 lines
--- hw/pci-host/gpex-acpi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)hw/pci-host/gpex-acpi.c +7
-6@@ -7,7 +7,8 @@#include "hw/pci/pcie_host.h" #include "hw/acpi/cxl.h" -static void acpi_dsdt_add_pci_route_table (Aml *dev,uint32_t irq) +static void acpi_dsdt_add_pci_route_table (Aml *dev,uint32_t irq, +Aml *scope,uint8_t bus_num) {Aml *method, *crs;int i, slot_no;@@ -20,7 +21,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq)Aml *pkg =aml_package (4 );aml_append (pkg,aml_int ((slot_no <<16 ) |0xFFFF ));aml_append (pkg,aml_int (i)); -aml_append (pkg,aml_name ("GSI%d" , gsi)); +aml_append (pkg,aml_name ("L%.02X%X" , bus_num, gsi));aml_append (pkg,aml_int (0 ));aml_append (rt_pkg, pkg); }@@ -30,7 +31,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq)/* Create GSI link device */ for (i =0 ; i <PCI_NUM_PINS ; i++) {uint32_t irqs = irq + i; -Aml *dev_gsi =aml_device ("GSI%d" , i); +Aml *dev_gsi =aml_device ("L%.02X%X" , bus_num, i);aml_append (dev_gsi,aml_name_decl ("_HID" ,aml_string ("PNP0C0F" )));aml_append (dev_gsi,aml_name_decl ("_UID" ,aml_int (i))); crs =aml_resource_template ();@@ -45,7 +46,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq)aml_append (dev_gsi,aml_name_decl ("_CRS" , crs)); method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED );aml_append (dev_gsi, method); -aml_append (dev, dev_gsi); +aml_append (scope, dev_gsi); } }@@ -174,7 +175,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)aml_append (dev,aml_name_decl ("_PXM" ,aml_int (numa_node))); } -acpi_dsdt_add_pci_route_table (dev, cfg->irq); +acpi_dsdt_add_pci_route_table (dev, cfg->irq, scope, bus_num);/* * Resources defined for PXBs are composed of the following parts: @@ -205,7 +206,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)aml_append (dev,aml_name_decl ("_STR" ,aml_unicode ("PCIe 0 Device" )));aml_append (dev,aml_name_decl ("_CCA" ,aml_int (1 ))); -acpi_dsdt_add_pci_route_table (dev, cfg->irq); +acpi_dsdt_add_pci_route_table (dev, cfg->irq, scope,0 ); method =aml_method ("_CBA" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (cfg->ecam.base)));
PATCH v3 5/9 tests/acpi: update expected DSDT blob for aarch64 and microvm
In reply to Sunil V LAfter PCI link devices are moved out of the scope of PCI root complex, the DSDT files of machines which use GPEX, will change. So, update the expected AML files with these changes for these machines.
Mainly, there are 2 changes.
1) Since the link devices are created now directly under _SB for all PCI root bridges in the system, they should have unique names. So, instead of GSIx, named those devices as LXXY where L means link, XX will have PCI bus number and Y will have the INTx number (ex: L000 or L001). The _PRT entries will also be updated to reflect this name change.
2) PCI link devices are moved from the scope of each PCI root bridge to directly under _SB.
Below is the sample iASL difference for one such link device.
Scope (\_SB)
{
Name (_HID, "LNRO0005") // _HID: Hardware ID
Name (_UID, 0x1F) // _UID: Unique ID
Name (_CCA, One) // _CCA: Cache Coherency Attribute
Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
Memory32Fixed (ReadWrite,
0x0A003E00, // Address Base
0x00000200, // Address Length
)
Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
{
0x0000004F,
}
})+ Device (L000)
+ {
+ Name (_HID, "PNP0C0F" /* PCI Interrupt Link Device */)
+ Name (_UID, Zero) // _UID: Unique ID
+ Name (_PRS, ResourceTemplate ()
+ {+ Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
+ {
+ 0x00000023,
+ }
+ })
+ Name (_CRS, ResourceTemplate ()
+ {+ Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
+ {
+ 0x00000023,
+ }
+ })
+ Method (_SRS, 1, NotSerialized) // _SRS: Set Resource Settings
+ {
+ }
+ }
+
Device (PCI0)
{
Name (_HID, "PNP0A08" /* PCI Express Bus */) // _HID: Hardware ID
Name (_CID, "PNP0A03" /* PCI Bus */) // _CID: Compatible ID
Name (_SEG, Zero) // _SEG: PCI Segment
Name (_BBN, Zero) // _BBN: BIOS Bus Number
Name (_UID, Zero) // _UID: Unique ID
Name (_STR, Unicode ("PCIe 0 Device")) // _STR: Description String
Name (_CCA, One) // _CCA: Cache Coherency Attribute
Name (_PRT, Package (0x80) // _PRT: PCI Routing Table
{
Package (0x04)
{
0xFFFF,
Zero,
- GSI0,
+ L000,
Zero
},
.....
})
Device (GSI0)
{
Name (_HID, "PNP0C0F" /* PCI Interrupt Link Device */)
Name (_UID, Zero) // _UID: Unique ID
Name (_PRS, ResourceTemplate ()
{
Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
{
0x00000023,
}
})
Name (_CRS, ResourceTemplate ()
{
Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
{
0x00000023,
}
})
Method (_SRS, 1, NotSerialized) // _SRS: Set Resource Settings
{
}
}
}
}--- tests/data/acpi/aarch64/virt/DSDT | Bin 5196 -> 5196 bytes .../data/acpi/aarch64/virt/DSDT.acpihmatvirt | Bin 5282 -> 5282 bytes tests/data/acpi/aarch64/virt/DSDT.memhp | Bin 6557 -> 6557 bytes tests/data/acpi/aarch64/virt/DSDT.pxb | Bin 7679 -> 7679 bytes tests/data/acpi/aarch64/virt/DSDT.topology | Bin 5398 -> 5398 bytes tests/data/acpi/x86/microvm/DSDT.pcie | Bin 3023 -> 3023 bytes tests/qtest/bios-tables-test-allowed-diff.h | 6 ------ 7 files changed, 6 deletions(-)
tests/data/acpi/aarch64/virt/DSDT binary +0 -0
tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt binary +0 -0
tests/data/acpi/aarch64/virt/DSDT.memhp binary +0 -0
tests/data/acpi/aarch64/virt/DSDT.pxb binary +0 -0
tests/data/acpi/aarch64/virt/DSDT.topology binary +0 -0
tests/data/acpi/x86/microvm/DSDT.pcie binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -6
@@ -1,7 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/aarch64/virt/DSDT" , -"tests/data/acpi/aarch64/virt/DSDT.memhp" , -"tests/data/acpi/aarch64/virt/DSDT.topology" , -"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt" , -"tests/data/acpi/aarch64/virt/DSDT.pxb" , -"tests/data/acpi/x86/microvm/DSDT.pcie",
Signature · 1 line
2.43.0
PATCH v3 6/9 tests/qtest/bios-tables-test.c: Remove the fall back path
In reply to Sunil V LThe expected ACPI AML files are moved now under ${arch}/{machine} path. Hence, there is no need to search in old path which didn't have ${arch}. Remove the code which searches for the expected AML files under old path as well.
--- tests/qtest/bios-tables-test.c | 14 -------------- 1 file changed, 14 deletions(-)
tests/qtest/bios-tables-test.c +0 -14
@@ -267,15 +267,6 @@ static void dump_aml_files(test_data *data, bool rebuild) data->arch, data->machine, sdt->aml, ext); -/* -* To keep test cases not failing before the DATA files are moved to -* ${arch}/${machine} folder, add this check as well. -*/ -if (!g_file_test (aml_file,G_FILE_TEST_EXISTS )) { - aml_file =g_strdup_printf ("%s/%s/%.4s%s" , data_dir, - data->machine, sdt->aml, ext); - } -if (!g_file_test (aml_file,G_FILE_TEST_EXISTS ) && sdt->aml_len == exp_sdt->aml_len && !memcmp (sdt->aml, exp_sdt->aml, sdt->aml_len)) {
@@ -412,11 +403,6 @@ static GArray *load_expected_aml(test_data *data) try_again: aml_file =g_strdup_printf ("%s/%s/%s/%.4s%s" , data_dir, data->arch, data->machine, sdt->aml, ext); -if (!g_file_test (aml_file,G_FILE_TEST_EXISTS )) { - aml_file =g_strdup_printf ("%s/%s/%.4s%s" , data_dir, data->machine, - sdt->aml, ext); - } -if (verbosity_level >=2 ) {fprintf (stderr,"Looking for expected file '%s'\n" , aml_file); }
Signature · 1 line
2.43.0
PATCH v3 7/9 tests/acpi: Add empty ACPI data files for RISC-V
In reply to Sunil V LAs per process documented (steps 1-3) in bios-tables-test.c, add empty AML data files for RISC-V ACPI tables and add the entries in bios-tables-test-allowed-diff.h.
--- tests/data/acpi/riscv64/virt/APIC | 0 tests/data/acpi/riscv64/virt/DSDT | 0 tests/data/acpi/riscv64/virt/FACP | 0 tests/data/acpi/riscv64/virt/MCFG | 0 tests/data/acpi/riscv64/virt/RHCT | 0 tests/data/acpi/riscv64/virt/SPCR | 0 tests/qtest/bios-tables-test-allowed-diff.h | 6 ++++++ 7 files changed, 6 insertions(+) create mode 100644 tests/data/acpi/riscv64/virt/APIC create mode 100644 tests/data/acpi/riscv64/virt/DSDT create mode 100644 tests/data/acpi/riscv64/virt/FACP create mode 100644 tests/data/acpi/riscv64/virt/MCFG create mode 100644 tests/data/acpi/riscv64/virt/RHCT create mode 100644 tests/data/acpi/riscv64/virt/SPCR
tests/data/acpi/riscv64/virt/APIC new file +0 -0
tests/data/acpi/riscv64/virt/DSDT new file +0 -0
tests/data/acpi/riscv64/virt/FACP new file +0 -0
tests/data/acpi/riscv64/virt/MCFG new file +0 -0
tests/data/acpi/riscv64/virt/RHCT new file +0 -0
tests/data/acpi/riscv64/virt/SPCR new file +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +6 -0
@@ -1 +1,7 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/riscv64/virt/APIC" , +"tests/data/acpi/riscv64/virt/DSDT" , +"tests/data/acpi/riscv64/virt/FACP" , +"tests/data/acpi/riscv64/virt/MCFG" , +"tests/data/acpi/riscv64/virt/RHCT" , +"tests/data/acpi/riscv64/virt/SPCR",
Signature · 1 line
2.43.0
PATCH v3 8/9 tests/qtest/bios-tables-test.c: Enable basic testing for RISC-V
In reply to Sunil V LAdd basic ACPI table test case for RISC-V.
--- tests/qtest/bios-tables-test.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
tests/qtest/bios-tables-test.c +26 -0
@@ -1963,6 +1963,28 @@ static void test_acpi_microvm_acpi_erst(void) }#endif /* CONFIG_POSIX */ +static void test_acpi_riscv64_virt_tcg (void ) +{ +test_data data = { + .machine ="virt" , + .arch ="riscv64" , + .tcg_only = true, + .uefi_fl1 ="pc-bios/edk2-riscv-code.fd" , + .uefi_fl2 ="pc-bios/edk2-riscv-vars.fd" , + .cd ="tests/data/uefi-boot-images/bios-tables-test.riscv64.iso.qcow2" , + .ram_start =0x80000000ULL , + .scan_len =128ULL *1024 *1024 , + }; + +/* +* RHCT will have ISA string encoded. To reduce the effort +* of updating expected AML file for any new default ISA extension, +* use the profile rva22s64. +*/ +test_acpi_one ("-cpu rva22s64 " , &data); +free_test_data (&data); +} +static void test_acpi_aarch64_virt_tcg (void ) {test_data data = {
@@ -2441,6 +2463,10 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/virt/viot" , test_acpi_aarch64_virt_viot); } } + }else if (strcmp (arch,"riscv64" ) ==0 ) { +if (has_tcg &&qtest_has_device ("virtio-blk-pci" )) { +qtest_add_func ("acpi/virt" , test_acpi_riscv64_virt_tcg); + } } ret =g_test_run ();boot_sector_cleanup (disk);
Signature · 1 line
2.43.0
PATCH v3 9/9 tests/acpi: Add expected ACPI AML files for RISC-V
In reply to Sunil V LAs per the step 5 in the process documented in bios-tables-test.c, generate the expected ACPI AML data files for RISC-V using the rebuild-expected-aml.sh script and update the bios-tables-test-allowed-diff.h.
These are all new files being added for the first time. Hence, iASL diff output is not added.
--- tests/data/acpi/riscv64/virt/APIC | Bin 0 -> 116 bytes tests/data/acpi/riscv64/virt/DSDT | Bin 0 -> 3576 bytes tests/data/acpi/riscv64/virt/FACP | Bin 0 -> 276 bytes tests/data/acpi/riscv64/virt/MCFG | Bin 0 -> 60 bytes tests/data/acpi/riscv64/virt/RHCT | Bin 0 -> 332 bytes tests/data/acpi/riscv64/virt/SPCR | Bin 0 -> 80 bytes tests/qtest/bios-tables-test-allowed-diff.h | 6 ------ 7 files changed, 6 deletions(-)
tests/data/acpi/riscv64/virt/APIC binary +0 -0
tests/data/acpi/riscv64/virt/DSDT binary +0 -0
tests/data/acpi/riscv64/virt/FACP binary +0 -0
tests/data/acpi/riscv64/virt/MCFG binary +0 -0
tests/data/acpi/riscv64/virt/RHCT binary +0 -0
tests/data/acpi/riscv64/virt/SPCR binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -6
@@ -1,7 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/riscv64/virt/APIC" , -"tests/data/acpi/riscv64/virt/DSDT" , -"tests/data/acpi/riscv64/virt/FACP" , -"tests/data/acpi/riscv64/virt/MCFG" , -"tests/data/acpi/riscv64/virt/RHCT" , -"tests/data/acpi/riscv64/virt/SPCR",
Signature · 1 line
2.43.0