acpi: refactor error prone build_header() and packed structures usage in ACPI tables
cover acpi: refactor error prone build_header() and packed structures usage in ACPI tables
Highlights:
* drop pointer arithmetic in ACPI tables code
* use endian agnostic API
* simplifies review of tables. /in most cases just line by line comparision with spec/
Series replaces build_header() with acpi_init_table()/acpi_table_composed() API that hides pointer/offset arithmetic from user, to prevent errors caused by it [1].
While doing above, it was necessary to split table header from packed structure that was describing the table, which is counter-productive since it still leaves packed structure drawbacks. So that sort of forced me to rewrite tables that were composed with help of packed structures to preferred build_append_int_noprefix() API. In cases where switch to build_append_int_noprefix() was small, it was combined with acpi_init_table()/acpi_table_composed() patch. Conversion reduced code size quite a bit despite me adding doc comments for every table row.
Series also includes optional qtest patches that add missing acpi tests for tables that I'm touching to verify conversion changes. That includes an alternative build time based impl. of qtest_has_accel() API. So if we start bike-shedding this qtest_has_accel() we can safely drop all tests included, till the time discussion settles and some form of a qtest_has_accel() is merged, at which point I'd respin depended tests.
1) commits
bb9feea43179 x86: acpi: use offset instead of pointer when using build_header() 4d027afeb3a9 Virt: ACPI: fix qemu assert due to re-assigned table data address
Link to repo:
https://gitlab.com/imammedo/qemu/-/commits/acpi_build_header_refactoring
Igor Mammedov (53):
tests: acpi: dump table with failed checksum
tests: qtest: add qtest_has_accel() to check if tested binary supports
accelerator
tests: acpi: whitelist expected tables for acpi/q35/numamem testcase
tests: acpi: q35: test for x2APIC entries in SRAT
tests: acpi: update expected tables blobs
tests: acpi: whitelist new expected table
tests/data/acpi/q35/DMAR.dmar
tests: acpi: add testcase for intel_iommu (DMAR table)
tests: acpi: add expected blob for DMAR table
tests: acpi: whitelist expected blobs for new acpi/q35/ivrs testcase
tests: acpi: add testcase for amd-iommu (IVRS table)
tests: acpi: update expected blobs
tests: acpi: arm/virt: drop redundant test_acpi_one() in
test_acpi_virt_tcg()
tests: acpi: whitelist expected tables for acpi/virt/iort testcase
tests: acpi: arm/virt: use kvm to test IORT table
tests: acpi: add expected IORT table blob
tests: arm-cpu-features: use qtest_has_kvm() API
tests: migration-test: use qtest_has_accel() API
tests: bios-tables-test: use qtest_has_accel() API to register TCG
only tests
acpi: add helper routines to initialize ACPI tables
acpi: build_rsdt: use acpi_init_table()/acpi_table_composed() instead
of build_header()
acpi: build_xsdt: use acpi_init_table()/acpi_table_composed() instead
of build_header()
acpi: build_slit: use acpi_init_table()/acpi_table_composed() instead
of build_header()
acpi: build_fadt: use acpi_init_table()/acpi_table_composed() instead
of build_header()
acpi: build_tpm2: use acpi_init_table()/acpi_table_composed() instead
of build_header()
acpi: acpi_build_hest: use acpi_init_table()/acpi_table_composed()
instead of build_header()
acpi: build_mcfg: use acpi_init_table()/acpi_table_composed() instead
of build_header()
acpi: build_hmat: use acpi_init_table()/acpi_table_composed() instead
of build_header()
acpi: nvdimm_build_nfit: use acpi_init_table()/acpi_table_composed()
instead of build_header()
acpi: nvdimm_build_ssdt: use acpi_init_table()/acpi_table_composed()
instead of build_header()
acpi: vmgenid_build_acpi: use acpi_init_table()/acpi_table_composed()
instead of build_header()
acpi: x86: build_dsdt: use acpi_init_table()/acpi_table_composed()
instead of build_header()
acpi: build_hpet: use acpi_init_table()/acpi_table_composed() instead
of build_header()
acpi: build_tpm_tcpa: use acpi_init_table()/acpi_table_composed()
instead of build_header()
acpi: arm/x86: build_srat: use acpi_init_table()/acpi_table_composed()
instead of build_header()
acpi: use build_append_int_noprefix() API to compose SRAT table
acpi: build_dmar_q35: use acpi_init_table()/acpi_table_composed()
instead of build_header()
acpi: build_waet: use acpi_init_table()/acpi_table_composed() instead
of build_header()
acpi: build_amd_iommu: use acpi_init_table()/acpi_table_composed()
instead of build_header()
acpi: madt: arm/x86: use acpi_init_table()/acpi_table_composed()
instead of build_header()
acpi: x86: remove dead code
acpi: x86: set enabled when composing _MAT entries
acpi: x86: madt: use build_append_int_noprefix() API to compose MADT
table
acpi: arm/virt: madt: use build_append_int_noprefix() API to compose
MADT table
acpi: build_dsdt_microvm: use acpi_init_table()/acpi_table_composed()
instead of build_header()
acpi: arm: virt: build_dsdt: use
acpi_init_table()/acpi_table_composed() instead of build_header()
acpi: arm: virt: build_iort: use
acpi_init_table()/acpi_table_composed() instead of build_header()
acpi: arm/virt: convert build_iort() to endian agnostic
build_append_FOO() API
acpi: arm/virt: build_spcr: fix invalid cast
acpi: arm/virt: build_spcr: use
acpi_init_table()/acpi_table_composed() instead of build_header()
acpi: arm/virt: build_gtdt: use
acpi_init_table()/acpi_table_composed() instead of build_header()
acpi: build_facs: use build_append_int_noprefix() API to compose table
acpi: remove no longer used build_header()
acpi: AcpiGenericAddress no longer used to map/access fields of MMIO,
drop packed attribute
include/hw/acpi/acpi-defs.h | 528 +------------------------ include/hw/acpi/acpi_dev_interface.h | 3 +- include/hw/acpi/aml-build.h | 21 +- include/hw/i386/pc.h | 7 +- tests/qtest/libqos/libqtest.h | 8 + hw/acpi/acpi-x86-stub.c | 3 +- hw/acpi/aml-build.c | 188 +++++---- hw/acpi/cpu.c | 17 +- hw/acpi/ghes.c | 10 +- hw/acpi/hmat.c | 14 +- hw/acpi/nvdimm.c | 64 ++-- hw/acpi/pci.c | 18 +- hw/acpi/vmgenid.c | 16 +- hw/arm/virt-acpi-build.c | 550 +++++++++++++++------------ hw/i386/acpi-build.c | 285 +++++++------- hw/i386/acpi-common.c | 158 ++++---- hw/i386/acpi-microvm.c | 13 +- meson.build | 6 + tests/data/acpi/q35/APIC.numamem | Bin 0 -> 2686 bytes tests/data/acpi/q35/DMAR.dmar | Bin 0 -> 80 bytes tests/data/acpi/q35/DSDT.ivrs | Bin 0 -> 7877 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7865 -> 35222 bytes tests/data/acpi/q35/FACP.numamem | Bin 0 -> 244 bytes tests/data/acpi/q35/IVRS.ivrs | Bin 0 -> 104 bytes tests/data/acpi/q35/SRAT.numamem | Bin 224 -> 5080 bytes tests/data/acpi/virt/IORT.iort | Bin 0 -> 124 bytes tests/qtest/acpi-utils.c | 14 + tests/qtest/arm-cpu-features.c | 29 +- tests/qtest/bios-tables-test.c | 85 ++++- tests/qtest/libqtest.c | 27 ++ tests/qtest/migration-test.c | 15 +- 31 files changed, 873 insertions(+), 1206 deletions(-) create mode 100644 tests/data/acpi/q35/APIC.numamem create mode 100644 tests/data/acpi/q35/DMAR.dmar create mode 100644 tests/data/acpi/q35/DSDT.ivrs create mode 100644 tests/data/acpi/q35/FACP.numamem create mode 100644 tests/data/acpi/q35/IVRS.ivrs create mode 100644 tests/data/acpi/virt/IORT.iort
--
2.27.0
PATCH 1/53 tests: acpi: dump table with failed checksum
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- tests/qtest/acpi-utils.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
tests/qtest/acpi-utils.c +14 -0
@@ -98,6 +98,20 @@ void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,ACPI_ASSERT_CMP (**aml, sig); }if (verify_checksum) { +if (acpi_calc_checksum (*aml, *aml_len)) { +gint fd, ret; +char *fname =NULL ; +GError *error =NULL ; + +fprintf (stderr,"Invalid '%.4s'(%d)\n" , *aml, *aml_len); + fd =g_file_open_tmp ("malformed-XXXXXX.dat" , &fname, &error); +g_assert_no_error (error); +fprintf (stderr,"Dumping invalid table into '%s'\n" , fname); + ret =qemu_write_full (fd, *aml, *aml_len); +g_assert (ret == *aml_len); +close (fd); +g_free (fname); + }g_assert (!acpi_calc_checksum (*aml, *aml_len)); } }
Signature · 1 line
2.27.0
PATCH 2/53 tests: qtest: add qtest_has_accel() to check if tested binary supports accelerator
In reply to Igor MammedovCurrently it is not possible to create tests that have KVM as a hard requirement on a host that doesn't support KVM for tested target binary (modulo going through the trouble of compiling out the offending test case).
Following scenario makes test fail when it's run on non x86 host:
qemu-system-x86_64 -enable-kvm -M q35,kernel-irqchip=on -smp 1,maxcpus=288
This patch introduces qtest_has_accel() to let users check if accel is available in advance and avoid executing non run-able test-cases.
It implements detection of TCG and KVM only, the rest could be added later on, when we actually start testing them in qtest.
---
PS:
There is an alternative 'runtime' approach on list:
'query-accels' series.
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/
on upside this impl. much cheaper to execute than the 'query-accels' as it doesn't need to run QEMU for probing.
v4:
- s/qtest_has_kvm/qtest_has_accel/
- add TCG detection (based on --disable-tcg)
v3:
- make it work with --disable-kvm
(Claudio Fontana <[email protected]>)
v2:
- fix access() check.
s/access()/!access()/
- format C array items at meson.build time
--- tests/qtest/libqos/libqtest.h | 8 ++++++++ meson.build | 6 ++++++ tests/qtest/libqtest.c | 27 +++++++++++++++++++++++++++ 3 files changed, 41 insertions(+)
tests/qtest/libqos/libqtest.h +8 -0
@@ -588,6 +588,14 @@ bool qtest_big_endian(QTestState *s);*/ const char *qtest_get_arch (void ); +/** +* qtest_has_accel: +* @accel_name: Accelerator name to check for. +* +* Returns: true if the accelerator is built in. +*/ +bool qtest_has_accel (const char *accel_name); +/** * qtest_add_func: * @str: Test case path.
meson.build +6 -0
@@ -76,6 +76,12 @@ else kvm_targets = [] endif +kvm_targets_c = '' +if not get_option('kvm').disabled() and targetos == 'linux' + kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"' +endif +config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c) + accelerator_targets = { 'CONFIG_KVM': kvm_targets } if cpu in ['x86', 'x86_64', 'arm', 'aarch64'] # i368 emulator provides xenpv machine type for multiple architectures
tests/qtest/libqtest.c +27 -0
@@ -920,6 +920,33 @@ const char *qtest_get_arch(void)return end +1 ; } +bool qtest_has_accel (const char *accel_name) +{ +if (g_str_equal (accel_name,"tcg" )) { +#if defined(CONFIG_TCG ) +return true; +#else +return false; +#endif + }else if (g_str_equal (accel_name,"kvm" )) { +int i; +const char *arch =qtest_get_arch (); +const char *targets[] = {CONFIG_KVM_TARGETS }; + +for (i =0 ; i <ARRAY_SIZE (targets); i++) { +if (!strncmp (targets[i], arch,strlen (arch))) { +if (!access ("/dev/kvm" ,R_OK |W_OK )) { +return true; + } + } + } + }else { +/* not implemented */ +g_assert_not_reached (); + } +return false; +} +bool qtest_get_irq (QTestState *s,int num) {/* dummy operation in order to make sure irq is up to date */
Signature · 1 line
2.27.0
Re: [PATCH 02/53] tests: qtest: add qtest_has_accel() to check if tested binary supports accelerator
Quoted 85 lines · Igor Mammedov
Currently it is not possible to create tests that have KVM as a hard requirement on a host that doesn't support KVM for tested target binary (modulo going through the trouble of compiling out the offending test case).
Following scenario makes test fail when it's run on non x86 host:
qemu-system-x86_64 -enable-kvm -M q35,kernel-irqchip=on -smp 1,maxcpus=288This patch introduces
qtest_has_accel()to let users check if accel is available in advance and avoid executing non run-able test-cases.It implements detection of TCG and KVM only, the rest could be added later on, when we actually start testing them in qtest.
Signed-off-by Igor Mammedov <[email protected]>---
PS:
There is an alternative 'runtime' approach on list:
'query-accels' series.
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/on upside this impl. much cheaper to execute than the 'query-accels' as it doesn't need to run QEMU for probing.
v4:
- s/qtest_has_kvm/qtest_has_accel/
- add TCG detection (based on --disable-tcg)
v3:
- make it work with --disable-kvm
(Claudio Fontana <[email protected]>)
v2:
- fixaccess()check.s/access()/!access()/- format C array items at meson.build time
--- tests/qtest/libqos/libqtest.h | 8 ++++++++ meson.build | 6 ++++++ tests/qtest/libqtest.c | 27 +++++++++++++++++++++++++++ 3 files changed, 41 insertions(+)tests/qtest/libqos/libqtest.h +8
-0@@ -588,6 +588,14 @@ bool qtest_big_endian(QTestState *s);*/ const char *qtest_get_arch (void ); +/** +* qtest_has_accel: +* @accel_name: Accelerator name to check for. +* +* Returns: true if the accelerator is built in. +*/ +bool qtest_has_accel (const char *accel_name); +/** * qtest_add_func: * @str: Test case path. meson.build +6
-0@@ -76,6 +76,12 @@ else kvm_targets = [] endif +kvm_targets_c = '' +if not get_option('kvm').disabled() and targetos == 'linux' + kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"' +endif +config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c) + accelerator_targets = { 'CONFIG_KVM': kvm_targets } if cpu in ['x86', 'x86_64', 'arm', 'aarch64'] # i368 emulator provides xenpv machine type for multiple architecturestests/qtest/libqtest.c +0
-0
tests/qtest/libqtest.c const char *qtest_get_arch(void) · line 926
Quoted 7 lines
tests/qtest/libqtest.c +4
-0@@ -920,6 +920,33 @@ const char *qtest_get_arch(void)return end +1 ; } +bool qtest_has_accel (const char *accel_name) +{ +if (g_str_equal (accel_name,"tcg" )) { +#if defined(CONFIG_TCG )
The point of the "alternative 'runtime' approach" was to remove access to accel-specific definitions in tests/ and you are adding yet another one :( Maybe now it is acceptable, I am not sure since I haven't followed the latest accelerator modularization effort series. So I'll defer that to the active developers doing it.
Quoted 27 lines
tests/qtest/libqtest.c +23
-0+return true; +#else +return false; +#endif + }else if (g_str_equal (accel_name,"kvm" )) { +int i; +const char *arch =qtest_get_arch (); +const char *targets[] = {CONFIG_KVM_TARGETS }; + +for (i =0 ; i <ARRAY_SIZE (targets); i++) { +if (!strncmp (targets[i], arch,strlen (arch))) { +if (!access ("/dev/kvm" ,R_OK |W_OK )) { +return true; + } + } + } + }else { +/* not implemented */ +g_assert_not_reached (); + } +return false; +} +bool qtest_get_irq (QTestState *s,int num) {/* dummy operation in order to make sure irq is up to date */
PATCH 3/53 tests: acpi: whitelist expected tables for acpi/q35/numamem testcase
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++ 1 file changed, 4 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +4 -0
@@ -1 +1,5 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT.numamem" , +"tests/data/acpi/q35/SRAT.numamem" , +"tests/data/acpi/q35/FACP" , +"tests/data/acpi/q35/APIC",
Signature · 1 line
2.27.0
PATCH 4/53 tests: acpi: q35: test for x2APIC entries in SRAT
In reply to Igor MammedovSet -smp 1,maxcpus=288 to test for ACPI code that
deal with CPUs with large APIC ID (>255).
PS:
Test requires KVM and in-kernel irqchip support,
so skip test if KVM is not available.
---
v2:
- switch to qtest_has_accel() API
--- tests/qtest/bios-tables-test.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tests/qtest/bios-tables-test.c +8 -3
@@ -1021,7 +1021,7 @@ static void test_acpi_piix4_tcg_nohpet(void)free_test_data (&data); } -static void test_acpi_q35_tcg_numamem (void ) +static void test_acpi_q35_kvm_numamem (void ) {test_data data;
@@ -1029,7 +1029,9 @@ static void test_acpi_q35_tcg_numamem(void) data.machine =MACHINE_Q35 ; data.variant =".numamem" ;test_acpi_one (" -object memory-backend-ram,id=ram0,size=128M" -" -numa node -numa node,memdev=ram0" , &data); +" -numa node -numa node,memdev=ram0" +" -machine kernel-irqchip=on -smp 1,maxcpus=288" + , &data);free_test_data (&data); }
@@ -1506,6 +1508,7 @@ static void test_acpi_oem_fields_virt(void)int main (int argc,char *argv[]) {const char *arch =qtest_get_arch (); +const bool has_kvm =qtest_has_accel ("kvm" );int ret;g_test_init (&argc, &argv,NULL );
@@ -1536,7 +1539,6 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/piix4/memhp" , test_acpi_piix4_tcg_memhp);qtest_add_func ("acpi/q35/memhp" , test_acpi_q35_tcg_memhp);qtest_add_func ("acpi/piix4/numamem" , test_acpi_piix4_tcg_numamem); -qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_tcg_numamem);qtest_add_func ("acpi/piix4/nosmm" , test_acpi_piix4_tcg_nosmm);qtest_add_func ("acpi/piix4/smm-compat" , test_acpi_piix4_tcg_smm_compat);
@@ -1561,6 +1563,9 @@ int main(int argc, char *argv[])if (strcmp (arch,"x86_64" ) ==0 ) {qtest_add_func ("acpi/microvm/pcie" , test_acpi_microvm_pcie_tcg); } +if (has_kvm) { +qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_kvm_numamem); + } }else if (strcmp (arch,"aarch64" ) ==0 ) {qtest_add_func ("acpi/virt" , test_acpi_virt_tcg);qtest_add_func ("acpi/virt/numamem" , test_acpi_virt_tcg_numamem);
Signature · 1 line
2.27.0
Re: [PATCH 04/53] tests: acpi: q35: test for x2APIC entries in SRAT
Quoted 8 lines · Igor Mammedov
Set -smp 1,maxcpus=288 to test for ACPI code that
deal with CPUs with large APIC ID (>255).PS:
Test requires KVM and in-kernel irqchip support,
so skip test if KVM is not available.Signed-off-by Igor Mammedov <[email protected]>
Why don't we add a new test? Why change an existing one? And I'd prefer kvm in the name since it's kvm specific. E.g. kvmnumamem.
Quoted 62 lines
---
v2:
- switch toqtest_has_accel()API--- tests/qtest/bios-tables-test.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)tests/qtest/bios-tables-test.c +8
-3@@ -1021,7 +1021,7 @@ static void test_acpi_piix4_tcg_nohpet(void)free_test_data (&data); } -static void test_acpi_q35_tcg_numamem (void ) +static void test_acpi_q35_kvm_numamem (void ) {test_data data;@@ -1029,7 +1029,9 @@ static void test_acpi_q35_tcg_numamem(void) data.machine =MACHINE_Q35 ; data.variant =".numamem" ;test_acpi_one (" -object memory-backend-ram,id=ram0,size=128M" -" -numa node -numa node,memdev=ram0" , &data); +" -numa node -numa node,memdev=ram0" +" -machine kernel-irqchip=on -smp 1,maxcpus=288" + , &data);free_test_data (&data); }@@ -1506,6 +1508,7 @@ static void test_acpi_oem_fields_virt(void)int main (int argc,char *argv[]) {const char *arch =qtest_get_arch (); +const bool has_kvm =qtest_has_accel ("kvm" );int ret;g_test_init (&argc, &argv,NULL );@@ -1536,7 +1539,6 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/piix4/memhp" , test_acpi_piix4_tcg_memhp);qtest_add_func ("acpi/q35/memhp" , test_acpi_q35_tcg_memhp);qtest_add_func ("acpi/piix4/numamem" , test_acpi_piix4_tcg_numamem); -qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_tcg_numamem);qtest_add_func ("acpi/piix4/nosmm" , test_acpi_piix4_tcg_nosmm);qtest_add_func ("acpi/piix4/smm-compat" , test_acpi_piix4_tcg_smm_compat);@@ -1561,6 +1563,9 @@ int main(int argc, char *argv[])if (strcmp (arch,"x86_64" ) ==0 ) {qtest_add_func ("acpi/microvm/pcie" , test_acpi_microvm_pcie_tcg); } +if (has_kvm) { +qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_kvm_numamem); + } }else if (strcmp (arch,"aarch64" ) ==0 ) {qtest_add_func ("acpi/virt" , test_acpi_virt_tcg);qtest_add_func ("acpi/virt/numamem" , test_acpi_virt_tcg_numamem);Signature · 1 line
2.27.0
Re: [PATCH 04/53] tests: acpi: q35: test for x2APIC entries in SRAT
Quoted 8 lines · On Fri, 2 Jul 2021 10:45:37 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
Set -smp 1,maxcpus=288 to test for ACPI code that
deal with CPUs with large APIC ID (>255).PS:
Test requires KVM and in-kernel irqchip support,
so skip test if KVM is not available.
Quoted 5 lines
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>Why don't we add a new test? Why change an existing one? And I'd prefer kvm in the name since it's kvm specific. E.g. kvmnumamem.
I've opted for changing existing one as it practically tests the same ACPI code in 'pc' variant, so changing q35 'duplicate' variant to handle more than 255 cpus seemed reasonable to me.
Anyways, I don't have any preferences here so I can easily change that to a new testcase if you still prefer it.
as for name, I'll amend it on test respin.
Quoted 64 lines
Quoted 63 lines
---
v2:
- switch toqtest_has_accel()API--- tests/qtest/bios-tables-test.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)tests/qtest/bios-tables-test.c +8
-3@@ -1021,7 +1021,7 @@ static void test_acpi_piix4_tcg_nohpet(void)free_test_data (&data); } -static void test_acpi_q35_tcg_numamem (void ) +static void test_acpi_q35_kvm_numamem (void ) {test_data data;@@ -1029,7 +1029,9 @@ static void test_acpi_q35_tcg_numamem(void) data.machine =MACHINE_Q35 ; data.variant =".numamem" ;test_acpi_one (" -object memory-backend-ram,id=ram0,size=128M" -" -numa node -numa node,memdev=ram0" , &data); +" -numa node -numa node,memdev=ram0" +" -machine kernel-irqchip=on -smp 1,maxcpus=288" + , &data);free_test_data (&data); }@@ -1506,6 +1508,7 @@ static void test_acpi_oem_fields_virt(void)int main (int argc,char *argv[]) {const char *arch =qtest_get_arch (); +const bool has_kvm =qtest_has_accel ("kvm" );int ret;g_test_init (&argc, &argv,NULL );@@ -1536,7 +1539,6 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/piix4/memhp" , test_acpi_piix4_tcg_memhp);qtest_add_func ("acpi/q35/memhp" , test_acpi_q35_tcg_memhp);qtest_add_func ("acpi/piix4/numamem" , test_acpi_piix4_tcg_numamem); -qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_tcg_numamem);qtest_add_func ("acpi/piix4/nosmm" , test_acpi_piix4_tcg_nosmm);qtest_add_func ("acpi/piix4/smm-compat" , test_acpi_piix4_tcg_smm_compat);@@ -1561,6 +1563,9 @@ int main(int argc, char *argv[])if (strcmp (arch,"x86_64" ) ==0 ) {qtest_add_func ("acpi/microvm/pcie" , test_acpi_microvm_pcie_tcg); } +if (has_kvm) { +qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_kvm_numamem); + } }else if (strcmp (arch,"aarch64" ) ==0 ) {qtest_add_func ("acpi/virt" , test_acpi_virt_tcg);qtest_add_func ("acpi/virt/numamem" , test_acpi_virt_tcg_numamem);Signature · 1 line
2.27.0
Re: [PATCH 04/53] tests: acpi: q35: test for x2APIC entries in SRAT
Quoted 17 lines · Igor Mammedov
Quoted 8 lines · On Fri, 2 Jul 2021 10:45:37 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
Set -smp 1,maxcpus=288 to test for ACPI code that
deal with CPUs with large APIC ID (>255).PS:
Test requires KVM and in-kernel irqchip support,
so skip test if KVM is not available.Quoted 5 lines
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>Why don't we add a new test? Why change an existing one? And I'd prefer kvm in the name since it's kvm specific. E.g. kvmnumamem.
Quoted 8 lines
I've opted for changing existing one as it practically tests the same ACPI code in 'pc' variant, so changing q35 'duplicate' variant to handle more than 255 cpus seemed reasonable to me.
Anyways, I don't have any preferences here so I can easily change that to a new testcase if you still prefer it.
the reason I do is because this way we don't drop the test on non kvm hosts.
Quoted 66 lines
as for name, I'll amend it on test respin.
Quoted 64 lines
Quoted 63 lines
---
v2:
- switch toqtest_has_accel()API--- tests/qtest/bios-tables-test.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)tests/qtest/bios-tables-test.c +8
-3@@ -1021,7 +1021,7 @@ static void test_acpi_piix4_tcg_nohpet(void)free_test_data (&data); } -static void test_acpi_q35_tcg_numamem (void ) +static void test_acpi_q35_kvm_numamem (void ) {test_data data;@@ -1029,7 +1029,9 @@ static void test_acpi_q35_tcg_numamem(void) data.machine =MACHINE_Q35 ; data.variant =".numamem" ;test_acpi_one (" -object memory-backend-ram,id=ram0,size=128M" -" -numa node -numa node,memdev=ram0" , &data); +" -numa node -numa node,memdev=ram0" +" -machine kernel-irqchip=on -smp 1,maxcpus=288" + , &data);free_test_data (&data); }@@ -1506,6 +1508,7 @@ static void test_acpi_oem_fields_virt(void)int main (int argc,char *argv[]) {const char *arch =qtest_get_arch (); +const bool has_kvm =qtest_has_accel ("kvm" );int ret;g_test_init (&argc, &argv,NULL );@@ -1536,7 +1539,6 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/piix4/memhp" , test_acpi_piix4_tcg_memhp);qtest_add_func ("acpi/q35/memhp" , test_acpi_q35_tcg_memhp);qtest_add_func ("acpi/piix4/numamem" , test_acpi_piix4_tcg_numamem); -qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_tcg_numamem);qtest_add_func ("acpi/piix4/nosmm" , test_acpi_piix4_tcg_nosmm);qtest_add_func ("acpi/piix4/smm-compat" , test_acpi_piix4_tcg_smm_compat);@@ -1561,6 +1563,9 @@ int main(int argc, char *argv[])if (strcmp (arch,"x86_64" ) ==0 ) {qtest_add_func ("acpi/microvm/pcie" , test_acpi_microvm_pcie_tcg); } +if (has_kvm) { +qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_kvm_numamem); + } }else if (strcmp (arch,"aarch64" ) ==0 ) {qtest_add_func ("acpi/virt" , test_acpi_virt_tcg);qtest_add_func ("acpi/virt/numamem" , test_acpi_virt_tcg_numamem);Signature · 1 line
2.27.0
PATCH 5/53 tests: acpi: update expected tables blobs
In reply to Igor MammedovUpdate adds CPU entries to MADT/SRAT/FACP and DSDT to cover 288 CPUs. Notable changes are that CPUs with APIC ID 255 and higher use 'Processor Local x2APIC Affinity' structure in SRAT and "Device" element in DSDT.
FACP:
- Use APIC Cluster Model (V4) : 0
+ Use APIC Cluster Model (V4) : 1
SRAT:
...
+[1010h 4112 1] Subtable Type : 00 [Processor Local APIC/SAPIC Affinity]
+[1011h 4113 1] Length : 10
+
+[1012h 4114 1] Proximity Domain Low(8) : 00 +[1013h 4115 1] Apic ID : FE +[1014h 4116 4] Flags (decoded below) : 00000001 + Enabled : 1 +[1018h 4120 1] Local Sapic EID : 00 +[1019h 4121 3] Proximity Domain High(24) : 000000 +[101Ch 4124 4] Clock Domain : 00000000
+
+[1020h 4128 1] Subtable Type : 02 [Processor Local x2APIC Affinity]
+[1021h 4129 1] Length : 18
+
+[1022h 4130 2] Reserved1 : 0000 +[1024h 4132 4] Proximity Domain : 00000001 +[1028h 4136 4] Apic ID : 000000FF +[102Ch 4140 4] Flags (decoded below) : 00000001
+ Enabled : 1
+[1030h 4144 4] Clock Domain : 00000000
+[1034h 4148 4] Reserved2 : 00000000
...
+[1320h 4896 1] Subtable Type : 02 [Processor Local x2APIC Affinity]
+[1321h 4897 1] Length : 18
+
+[1322h 4898 2] Reserved1 : 0000 +[1324h 4900 4] Proximity Domain : 00000001 +[1328h 4904 4] Apic ID : 0000011F +[132Ch 4908 4] Flags (decoded below) : 00000001
+ Enabled : 1
+[1330h 4912 4] Clock Domain : 00000000
+[1334h 4916 4] Reserved2 : 00000000
DSDT:
...
+ Processor (C0FE, 0xFE, 0x00000000, 0x00)
+ {
...
+ }
+
+ Device (C0FF)
+ {
+ Name (_HID, "ACPI0007" /* Processor Device */) // _HID: Hardware ID
+ Name (_UID, 0xFF) // _UID: Unique ID
...
+ }
+ Device (C11F)
+ {
+ Name (_HID, "ACPI0007" /* Processor Device */) // _HID: Hardware ID
+ Name (_UID, 0x011F) // _UID: Unique ID
...
+ }
APIC:
+[034h 0052 1] Subtable Type : 00 [Processor Local APIC] +[035h 0053 1] Length : 08 +[036h 0054 1] Processor ID : 01 +[037h 0055 1] Local Apic ID : 01 +[038h 0056 4] Flags (decoded below) : 00000000
+ Processor Enabled : 0
...
+[81Ch 2076 1] Subtable Type : 00 [Processor Local APIC] +[81Dh 2077 1] Length : 08 +[81Eh 2078 1] Processor ID : FE +[81Fh 2079 1] Local Apic ID : FE +[820h 2080 4] Flags (decoded below) : 00000000 + Processor Enabled : 0 + +[824h 2084 1] Subtable Type : 09 [Processor Local x2APIC] +[825h 2085 1] Length : 10 +[826h 2086 2] Reserved : 0000 +[828h 2088 4] Processor x2Apic ID : 000000FF +[82Ch 2092 4] Flags (decoded below) : 00000000
+ Processor Enabled : 0
+[830h 2096 4] Processor UID : 000000FF
...
+[A24h 2596 1] Subtable Type : 09 [Processor Local x2APIC] +[A25h 2597 1] Length : 10 +[A26h 2598 2] Reserved : 0000 +[A28h 2600 4] Processor x2Apic ID : 0000011F +[A2Ch 2604 4] Flags (decoded below) : 00000000 + Processor Enabled : 0 +[A30h 2608 4] Processor UID : 0000011F + +[A34h 2612 1] Subtable Type : 01 [I/O APIC] +[A35h 2613 1] Length : 0C +[A36h 2614 1] I/O Apic ID : 00 +[A37h 2615 1] Reserved : 00 +[A38h 2616 4] Address : FEC00000 +[A3Ch 2620 4] Interrupt : 00000000 + +[A40h 2624 1] Subtable Type : 02 [Interrupt Source Override] +[A41h 2625 1] Length : 0A +[A42h 2626 1] Bus : 00 +[A43h 2627 1] Source : 00 +[A44h 2628 4] Interrupt : 00000002 +[A48h 2632 2] Flags (decoded below) : 0000
Polarity : 0
Trigger Mode : 0
-[04Ah 0074 1] Subtable Type : 02 [Interrupt Source Override] -[04Bh 0075 1] Length : 0A -[04Ch 0076 1] Bus : 00 -[04Dh 0077 1] Source : 05 -[04Eh 0078 4] Interrupt : 00000005 -[052h 0082 2] Flags (decoded below) : 000D +[A4Ah 2634 1] Subtable Type : 02 [Interrupt Source Override] +[A4Bh 2635 1] Length : 0A +[A4Ch 2636 1] Bus : 00 +[A4Dh 2637 1] Source : 05 +[A4Eh 2638 4] Interrupt : 00000005 +[A52h 2642 2] Flags (decoded below) : 000D
Polarity : 1
Trigger Mode : 3
-[054h 0084 1] Subtable Type : 02 [Interrupt Source Override] -[055h 0085 1] Length : 0A -[056h 0086 1] Bus : 00 -[057h 0087 1] Source : 09 -[058h 0088 4] Interrupt : 00000009 -[05Ch 0092 2] Flags (decoded below) : 000D +[A54h 2644 1] Subtable Type : 02 [Interrupt Source Override] +[A55h 2645 1] Length : 0A +[A56h 2646 1] Bus : 00 +[A57h 2647 1] Source : 09 +[A58h 2648 4] Interrupt : 00000009 +[A5Ch 2652 2] Flags (decoded below) : 000D
Polarity : 1
Trigger Mode : 3
-[05Eh 0094 1] Subtable Type : 02 [Interrupt Source Override] -[05Fh 0095 1] Length : 0A -[060h 0096 1] Bus : 00 -[061h 0097 1] Source : 0A -[062h 0098 4] Interrupt : 0000000A -[066h 0102 2] Flags (decoded below) : 000D +[A5Eh 2654 1] Subtable Type : 02 [Interrupt Source Override] +[A5Fh 2655 1] Length : 0A +[A60h 2656 1] Bus : 00 +[A61h 2657 1] Source : 0A +[A62h 2658 4] Interrupt : 0000000A +[A66h 2662 2] Flags (decoded below) : 000D
Polarity : 1
Trigger Mode : 3
-[068h 0104 1] Subtable Type : 02 [Interrupt Source Override] -[069h 0105 1] Length : 0A -[06Ah 0106 1] Bus : 00 -[06Bh 0107 1] Source : 0B -[06Ch 0108 4] Interrupt : 0000000B -[070h 0112 2] Flags (decoded below) : 000D +[A68h 2664 1] Subtable Type : 02 [Interrupt Source Override] +[A69h 2665 1] Length : 0A +[A6Ah 2666 1] Bus : 00 +[A6Bh 2667 1] Source : 0B +[A6Ch 2668 4] Interrupt : 0000000B +[A70h 2672 2] Flags (decoded below) : 000D
Polarity : 1
Trigger Mode : 3
-[072h 0114 1] Subtable Type : 04 [Local APIC NMI]
-[073h 0115 1] Length : 06
-[074h 0116 1] Processor ID : FF
-[075h 0117 2] Flags (decoded below) : 0000
+[A72h 2674 1] Subtable Type : 0A [Local x2APIC NMI]
+[A73h 2675 1] Length : 0C
+[A74h 2676 2] Flags (decoded below) : 0000
Polarity : 0
Trigger Mode : 0
-[077h 0119 1] Interrupt Input LINT : 01
+[A76h 2678 4] Processor UID : FFFFFFFF
+[A7Ah 2682 1] Interrupt Input LINT : 01
+[A7Bh 2683 3] Reserved : 000000--- tests/qtest/bios-tables-test-allowed-diff.h | 4 ---- tests/data/acpi/q35/APIC.numamem | Bin 0 -> 2686 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7865 -> 35222 bytes tests/data/acpi/q35/FACP.numamem | Bin 0 -> 244 bytes tests/data/acpi/q35/SRAT.numamem | Bin 224 -> 5080 bytes 5 files changed, 4 deletions(-) create mode 100644 tests/data/acpi/q35/APIC.numamem create mode 100644 tests/data/acpi/q35/FACP.numamem
tests/qtest/bios-tables-test-allowed-diff.h +0 -4
@@ -1,5 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DSDT.numamem" , -"tests/data/acpi/q35/SRAT.numamem" , -"tests/data/acpi/q35/FACP" , -"tests/data/acpi/q35/APIC",
tests/data/acpi/q35/APIC.numamem new file binary +0 -0
tests/data/acpi/q35/DSDT.numamem binary +0 -0
tests/data/acpi/q35/FACP.numamem new file binary +0 -0
tests/data/acpi/q35/SRAT.numamem binary +0 -0
Signature · 1 line
2.27.0
PATCH 6/53 tests: acpi: whitelist new expected table tests/data/acpi/q35/DMAR.dmar
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 1 + tests/data/acpi/q35/DMAR.dmar | 0 2 files changed, 1 insertion(+) create mode 100644 tests/data/acpi/q35/DMAR.dmar
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
@@ -1 +1,2 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DMAR.dmar",
tests/data/acpi/q35/DMAR.dmar new file +0 -0
Signature · 1 line
2.27.0
PATCH 7/53 tests: acpi: add testcase for intel_iommu (DMAR table)
In reply to Igor Mammedov---
CC: [email protected]
CC: [email protected]
--- tests/qtest/bios-tables-test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
tests/qtest/bios-tables-test.c +13 -0
@@ -1079,6 +1079,18 @@ static void test_acpi_q35_tcg_nohpet(void)free_test_data (&data); } +static void test_acpi_q35_tcg_dmar (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_Q35 ; + data.variant =".dmar" ; +test_acpi_one ("-machine kernel-irqchip=split -accel kvm" +" -device intel-iommu,intremap=on,device-iotlb=on" , &data); +free_test_data (&data); +} +static void test_acpi_piix4_tcg_numamem (void ) {test_data data;
@@ -1565,6 +1577,7 @@ int main(int argc, char *argv[]) }if (has_kvm) {qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_kvm_numamem); +qtest_add_func ("acpi/q35/dmar" , test_acpi_q35_tcg_dmar); } }else if (strcmp (arch,"aarch64" ) ==0 ) {qtest_add_func ("acpi/virt" , test_acpi_virt_tcg);
Signature · 1 line
2.27.0
PATCH 8/53 tests: acpi: add expected blob for DMAR table
In reply to Igor Mammedov [000h 0000 4] Signature : "DMAR" [DMA Remapping table]
[004h 0004 4] Table Length : 00000050
[008h 0008 1] Revision : 01
[009h 0009 1] Checksum : F4
[00Ah 0010 6] Oem ID : "BOCHS "
[010h 0016 8] Oem Table ID : "BXPC "
[018h 0024 4] Oem Revision : 00000001
[01Ch 0028 4] Asl Compiler ID : "BXPC"
[020h 0032 4] Asl Compiler Revision : 00000001 [024h 0036 1] Host Address Width : 26
[025h 0037 1] Flags : 01
[026h 0038 10] Reserved : 00 00 00 00 00 00 00 00 00 00
[030h 0048 2] Subtable Type : 0000 [Hardware Unit Definition]
[032h 0050 2] Length : 0018
[034h 0052 1] Flags : 01
[035h 0053 1] Reserved : 00
[036h 0054 2] PCI Segment Number : 0000
[038h 0056 8] Register Base Address : 00000000FED90000
[040h 0064 1] Device Scope Type : 03 [IOAPIC Device]
[041h 0065 1] Entry Length : 08
[042h 0066 2] Reserved : 0000
[044h 0068 1] Enumeration ID : 00
[045h 0069 1] PCI Bus Number : FF
[046h 0070 2] PCI Path : 00,00
[048h 0072 2] Subtable Type : 0002 [Root Port ATS Capability]
[04Ah 0074 2] Length : 0008
[04Ch 0076 1] Flags : 01
[04Dh 0077 1] Reserved : 00
[04Eh 0078 2] PCI Segment Number : 0000--- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/q35/DMAR.dmar | Bin 0 -> 80 bytes 2 files changed, 1 deletion(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
@@ -1,2 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DMAR.dmar",
tests/data/acpi/q35/DMAR.dmar binary +0 -0
Signature · 1 line
2.27.0
PATCH 9/53 tests: acpi: whitelist expected blobs for new acpi/q35/ivrs testcase
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 2 ++ tests/data/acpi/q35/IVRS.ivrs | 0 2 files changed, 2 insertions(+) create mode 100644 tests/data/acpi/q35/IVRS.ivrs
tests/qtest/bios-tables-test-allowed-diff.h +2 -0
@@ -1 +1,3 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT" , +"tests/data/acpi/q35/IVRS.ivrs",
tests/data/acpi/q35/IVRS.ivrs new file +0 -0
Signature · 1 line
2.27.0
PATCH 10/53 tests: acpi: add testcase for amd-iommu (IVRS table)
In reply to Igor Mammedov---
CC: [email protected]
CC: [email protected]
--- tests/qtest/bios-tables-test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
tests/qtest/bios-tables-test.c +13 -0
@@ -1091,6 +1091,18 @@ static void test_acpi_q35_tcg_dmar(void)free_test_data (&data); } +static void test_acpi_q35_tcg_ivrs (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_Q35 ; + data.variant =".ivrs" ; + data.tcg_only = true, +test_acpi_one (" -device amd-iommu" , &data); +free_test_data (&data); +} +static void test_acpi_piix4_tcg_numamem (void ) {test_data data;
@@ -1563,6 +1575,7 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/q35/smm-compat-nosmm" , test_acpi_q35_tcg_smm_compat_nosmm);qtest_add_func ("acpi/q35/nohpet" , test_acpi_q35_tcg_nohpet); +qtest_add_func ("acpi/q35/ivrs" , test_acpi_q35_tcg_ivrs);qtest_add_func ("acpi/piix4/dimmpxm" , test_acpi_piix4_tcg_dimm_pxm);qtest_add_func ("acpi/q35/dimmpxm" , test_acpi_q35_tcg_dimm_pxm);qtest_add_func ("acpi/piix4/acpihmat" , test_acpi_piix4_tcg_acpi_hmat);
Signature · 1 line
2.27.0
PATCH 11/53 tests: acpi: update expected blobs
In reply to Igor MammedovDSDT:
+ Device (S10)
+ {
+ Name (_ADR, 0x00020000) // _ADR: Address
+ }
New IVRS table:
[000h 0000 4] Signature : "IVRS" [I/O Virtualization Reporting Structure] [004h 0004 4] Table Length : 00000068 [008h 0008 1] Revision : 01 [009h 0009 1] Checksum : 43 [00Ah 0010 6] Oem ID : "BOCHS " [010h 0016 8] Oem Table ID : "BXPC " [018h 0024 4] Oem Revision : 00000001 [01Ch 0028 4] Asl Compiler ID : "BXPC" [020h 0032 4] Asl Compiler Revision : 00000001
[024h 0036 4] Virtualization Info : 00002800
[028h 0040 8] Reserved : 0000000000000000
[030h 0048 1] Subtable Type : 10 [Hardware Definition Block] [031h 0049 1] Flags : D1 [032h 0050 2] Length : 0038 [034h 0052 2] DeviceId : 0010
[036h 0054 2] Capability Offset : 0040 [038h 0056 8] Base Address : 00000000FED80000 [040h 0064 2] PCI Segment Group : 0000 [042h 0066 2] Virtualization Info : 0000 [044h 0068 4] Reserved : 00000044
[048h 0072 1] Entry Type : 02 [049h 0073 2] Device ID : 0000 [04Bh 0075 1] Data Setting : 00
[04Ch 0076 1] Entry Type : 02 [04Dh 0077 2] Device ID : 0008 [04Fh 0079 1] Data Setting : 00
[050h 0080 1] Entry Type : 02 [051h 0081 2] Device ID : 0010 [053h 0083 1] Data Setting : 00
[054h 0084 1] Entry Type : 02 [055h 0085 2] Device ID : 00F8 [057h 0087 1] Data Setting : 00
[058h 0088 1] Entry Type : 02 [059h 0089 2] Device ID : 00FA [05Bh 0091 1] Data Setting : 00
[05Ch 0092 1] Entry Type : 02 [05Dh 0093 2] Device ID : 00FB [05Fh 0095 1] Data Setting : 00
[060h 0096 1] Entry Type : 48 [061h 0097 2] Device ID : 0000 [063h 0099 1] Data Setting : 00 [064h 0100 1] Handle : 00 [065h 0101 2] Source Used Device ID : 00A0 [067h 0103 1] Variety : 01
--- tests/qtest/bios-tables-test-allowed-diff.h | 2 -- tests/data/acpi/q35/DSDT.ivrs | Bin 0 -> 7877 bytes tests/data/acpi/q35/IVRS.ivrs | Bin 0 -> 104 bytes 3 files changed, 2 deletions(-) create mode 100644 tests/data/acpi/q35/DSDT.ivrs
tests/qtest/bios-tables-test-allowed-diff.h +0 -2
@@ -1,3 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DSDT" , -"tests/data/acpi/q35/IVRS.ivrs",
tests/data/acpi/q35/DSDT.ivrs new file binary +0 -0
tests/data/acpi/q35/IVRS.ivrs binary +0 -0
Signature · 1 line
2.27.0
PATCH 12/53 tests: acpi: arm/virt: drop redundant test_acpi_one() in test_acpi_virt_tcg()
In reply to Igor Mammedovfollow up call with smbios options generates the same ACPI tables, so there is no need to run smbios-less variant at all.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- tests/qtest/bios-tables-test.c | 3 --- 1 file changed, 3 deletions(-)
tests/qtest/bios-tables-test.c +0 -3
@@ -1416,9 +1416,6 @@ static void test_acpi_virt_tcg(void) .scan_len = 128ULL * 1024 * 1024, }; -test_acpi_one ("-cpu cortex-a57" , &data); -free_test_data (&data); - data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ; test_acpi_one("-cpu cortex-a57 "
Signature · 1 line
2.27.0
PATCH 12/53 tests: acpi: arm/virt: drop redudant test_acpi_one() in test_acpi_virt_tcg()
In reply to Igor Mammedovfollow up call test_acpi_one() with smbios options generates the same ACPI tables, so there is no need to run smbios-less variant at all.
--- tests/qtest/bios-tables-test.c | 3 --- 1 file changed, 3 deletions(-)
tests/qtest/bios-tables-test.c +0 -3
@@ -1416,9 +1416,6 @@ static void test_acpi_virt_tcg(void) .scan_len = 128ULL * 1024 * 1024, }; -test_acpi_one ("-cpu cortex-a57" , &data); -free_test_data (&data); - data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ; test_acpi_one("-cpu cortex-a57 "
Signature · 1 line
2.27.0
PATCH 13/53 tests: acpi: whitelist expected tables for acpi/virt/iort testcase
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 1 + tests/data/acpi/virt/IORT.iort | 0 2 files changed, 1 insertion(+) create mode 100644 tests/data/acpi/virt/IORT.iort
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
@@ -1 +1,2 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/virt/IORT.iort",
tests/data/acpi/virt/IORT.iort new file +0 -0
Signature · 1 line
2.27.0
PATCH 14/53 tests: acpi: arm/virt: use kvm to test IORT table
In reply to Igor Mammedov---
- v2: switch to qtest_has_accel() API
--- tests/qtest/bios-tables-test.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
tests/qtest/bios-tables-test.c +19 -0
@@ -1423,6 +1423,22 @@ static void test_acpi_virt_tcg(void)free_test_data (&data); } +static void test_acpi_virt_iort (void ) +{ +test_data data = { + .machine ="virt" , + .uefi_fl1 ="pc-bios/edk2-aarch64-code.fd" , + .uefi_fl2 ="pc-bios/edk2-arm-vars.fd" , + .cd ="tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2" , + .ram_start =0x40000000ULL , + .scan_len =128ULL *1024 *1024 , + }; + + data.variant =".iort" ; +test_acpi_one ("-cpu host" , &data); +free_test_data (&data); +} +static void test_oem_fields (test_data *data) {int i;
@@ -1595,6 +1611,9 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/virt/memhp" , test_acpi_virt_tcg_memhp);qtest_add_func ("acpi/virt/pxb" , test_acpi_virt_tcg_pxb);qtest_add_func ("acpi/virt/oem-fields" , test_acpi_oem_fields_virt); +if (has_kvm) { +qtest_add_func ("acpi/virt/iort" , test_acpi_virt_iort); + } } ret =g_test_run ();boot_sector_cleanup (disk);
Signature · 1 line
2.27.0
PATCH 15/53 tests: acpi: add expected IORT table blob
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/virt/IORT.iort | Bin 0 -> 124 bytes 2 files changed, 1 deletion(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
@@ -1,2 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/virt/IORT.iort",
tests/data/acpi/virt/IORT.iort binary +0 -0
Signature · 1 line
2.27.0
PATCH 16/53 tests: arm-cpu-features: use qtest_has_kvm() API
In reply to Igor Mammedovand drop custom function that were doing the job
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- tests/qtest/arm-cpu-features.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-)
tests/qtest/arm-cpu-features.c +5 -24
@@ -26,21 +26,6 @@ " 'arguments': { 'type': 'full', "#define QUERY_TAIL "}}" -static bool kvm_enabled (QTestState *qts) -{ -QDict *resp, *qdict; -bool enabled; - - resp =qtest_qmp (qts,"{ 'execute': 'query-kvm' }" ); -g_assert (qdict_haskey (resp,"return" )); - qdict =qdict_get_qdict (resp,"return" ); -g_assert (qdict_haskey (qdict,"enabled" )); - enabled =qdict_get_bool (qdict,"enabled" ); -qobject_unref (resp); - -return enabled; -} -static QDict *do_query_no_props (QTestState *qts,const char *cpu_type) { return qtest_qmp(qts, QUERY_HEAD "'model': { 'name': %s }"
@@ -493,14 +478,6 @@ static void test_query_cpu_model_expansion_kvm(const void *data) qts =qtest_init (MACHINE_KVM "-cpu max" ); -/* -* These tests target the 'host' CPU type, so KVM must be enabled. -*/ -if (!kvm_enabled (qts)) { -qtest_quit (qts); -return ; - } -/* Enabling and disabling kvm-no-adjvtime should always work. */ assert_has_feature_disabled (qts,"host" ,"kvm-no-adjvtime" );assert_set_feature (qts,"host" ,"kvm-no-adjvtime" , true);
@@ -624,7 +601,11 @@ int main(int argc, char **argv)* order avoid attempting to run an AArch32 QEMU with KVM on * AArch64 hosts. That won't work and isn't easy to detect. */ -if (g_str_equal (qtest_get_arch (),"aarch64" )) { +if (g_str_equal (qtest_get_arch (),"aarch64" ) &&qtest_has_accel ("kvm" )) { +/* +* This tests target the 'host' CPU type, so register it only if +* KVM is available. +*/ qtest_add_data_func ("/arm/kvm/query-cpu-model-expansion" ,NULL , test_query_cpu_model_expansion_kvm); }
Signature · 1 line
2.27.0
PATCH 17/53 tests: migration-test: use qtest_has_accel() API
In reply to Igor Mammedov---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- tests/qtest/migration-test.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
tests/qtest/migration-test.c +4 -11
@@ -1372,6 +1372,7 @@ static void test_multifd_tcp_cancel(void)int main (int argc,char **argv) {char template[] ="/tmp/migration-test-XXXXXX" ; +const bool has_kvm =qtest_has_accel ("kvm" );int ret;g_test_init (&argc, &argv,NULL );
@@ -1386,8 +1387,7 @@ int main(int argc, char **argv)* some reason) */ if (g_str_equal (qtest_get_arch (),"ppc64" ) && - (access ("/sys/module/kvm_hv" ,F_OK ) || -access ("/dev/kvm" ,R_OK |W_OK ))) { + (!has_kvm ||access ("/sys/module/kvm_hv" ,F_OK ))) {g_test_message ("Skipping test: kvm_hv not available" );return g_test_run (); }
@@ -1396,16 +1396,9 @@ int main(int argc, char **argv)* Similar to ppc64, s390x seems to be touchy with TCG, so disable it * there until the problems are resolved */ -if (g_str_equal (qtest_get_arch (),"s390x" )) { -#if defined(HOST_S390X ) -if (access ("/dev/kvm" ,R_OK |W_OK )) { -g_test_message ("Skipping test: kvm not available" ); -return g_test_run (); - } -#else -g_test_message ("Skipping test: Need s390x host to work properly" ); +if (g_str_equal (qtest_get_arch (),"s390x" ) && !has_kvm) { +g_test_message ("Skipping test: s390x host with KVM is required" );return g_test_run (); -#endif } tmpfs =mkdtemp (template);
Signature · 1 line
2.27.0
PATCH 18/53 tests: bios-tables-test: use qtest_has_accel() API to register TCG only tests
In reply to Igor Mammedov.. only if TCG is available
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- tests/qtest/bios-tables-test.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
tests/qtest/bios-tables-test.c +13 -15
@@ -722,13 +722,6 @@ static void test_acpi_one(const char *params, test_data *data)char *args;bool use_uefi = data->uefi_fl1 && data->uefi_fl2; -#ifndef CONFIG_TCG -if (data->tcg_only) { -g_test_skip ("TCG disabled, skipping ACPI tcg_only test" ); -return ; - } -#endif /* CONFIG_TCG */ - args =test_acpi_create_args (data, params, use_uefi); data->qts =qtest_init (args);test_acpi_load_tables (data, use_uefi);
@@ -1546,6 +1539,7 @@ int main(int argc, char *argv[]) {const char *arch =qtest_get_arch ();const bool has_kvm =qtest_has_accel ("kvm" ); +const bool has_tcg =qtest_has_accel ("tcg" );int ret;g_test_init (&argc, &argv,NULL );
@@ -1588,7 +1582,6 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/q35/smm-compat-nosmm" , test_acpi_q35_tcg_smm_compat_nosmm);qtest_add_func ("acpi/q35/nohpet" , test_acpi_q35_tcg_nohpet); -qtest_add_func ("acpi/q35/ivrs" , test_acpi_q35_tcg_ivrs);qtest_add_func ("acpi/piix4/dimmpxm" , test_acpi_piix4_tcg_dimm_pxm);qtest_add_func ("acpi/q35/dimmpxm" , test_acpi_q35_tcg_dimm_pxm);qtest_add_func ("acpi/piix4/acpihmat" , test_acpi_piix4_tcg_acpi_hmat);
@@ -1598,19 +1591,24 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/microvm/rtc" , test_acpi_microvm_rtc_tcg);qtest_add_func ("acpi/microvm/ioapic2" , test_acpi_microvm_ioapic2_tcg);qtest_add_func ("acpi/microvm/oem-fields" , test_acpi_oem_fields_microvm); -if (strcmp (arch,"x86_64" ) ==0 ) { -qtest_add_func ("acpi/microvm/pcie" , test_acpi_microvm_pcie_tcg); +if (has_tcg) { +qtest_add_func ("acpi/q35/ivrs" , test_acpi_q35_tcg_ivrs); +if (strcmp (arch,"x86_64" ) ==0 ) { +qtest_add_func ("acpi/microvm/pcie" , test_acpi_microvm_pcie_tcg); + } }if (has_kvm) {qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_kvm_numamem);qtest_add_func ("acpi/q35/dmar" , test_acpi_q35_tcg_dmar); } }else if (strcmp (arch,"aarch64" ) ==0 ) { -qtest_add_func ("acpi/virt" , test_acpi_virt_tcg); -qtest_add_func ("acpi/virt/numamem" , test_acpi_virt_tcg_numamem); -qtest_add_func ("acpi/virt/memhp" , test_acpi_virt_tcg_memhp); -qtest_add_func ("acpi/virt/pxb" , test_acpi_virt_tcg_pxb); -qtest_add_func ("acpi/virt/oem-fields" , test_acpi_oem_fields_virt); +if (has_tcg) { +qtest_add_func ("acpi/virt" , test_acpi_virt_tcg); +qtest_add_func ("acpi/virt/numamem" , test_acpi_virt_tcg_numamem); +qtest_add_func ("acpi/virt/memhp" , test_acpi_virt_tcg_memhp); +qtest_add_func ("acpi/virt/pxb" , test_acpi_virt_tcg_pxb); +qtest_add_func ("acpi/virt/oem-fields" , test_acpi_oem_fields_virt); + }if (has_kvm) {qtest_add_func ("acpi/virt/iort" , test_acpi_virt_iort); }
Signature · 1 line
2.27.0
PATCH 19/53 acpi: add helper routines to initialize ACPI tables
In reply to Igor Mammedov acpi_init_table():
initializes table header and keeps track of table data/offsets
acpi_table_composed():
sets actual table length and tells bios loader where it's for later initialization on guest side.
--- include/hw/acpi/aml-build.h | 14 ++++++++++ hw/acpi/aml-build.c | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)
include/hw/acpi/aml-build.h +14 -0
@@ -413,6 +413,20 @@ Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target);Aml *aml_object_type (Aml *object);void build_append_int_noprefix (GArray *table,uint64_t value,int size); + +typedef struct AcpiTable { +const char *sig; +const uint8_t rev; +const char *oem_id; +const char *oem_table_id; +/* private vars tracking table state */ +GArray *array; +unsigned table_offset; +}AcpiTable ; + +void acpi_init_table (AcpiTable *desc,GArray *array); +void acpi_table_composed (BIOSLinker *linker,AcpiTable *table); + void build_header(BIOSLinker *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev,
hw/acpi/aml-build.c +53 -0
65 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH 19/53] acpi: add helper routines to initialize ACPI tables
Quoted 92 lines · Igor Mammedov
acpi_init_table():
initializes table header and keeps track of table data/offsets
acpi_table_composed():
sets actual table length and tells bios loader where it's for later initialization on guest side.Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/aml-build.h | 14 ++++++++++ hw/acpi/aml-build.c | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)include/hw/acpi/aml-build.h +14
-0@@ -413,6 +413,20 @@ Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target);Aml *aml_object_type (Aml *object);void build_append_int_noprefix (GArray *table,uint64_t value,int size); + +typedef struct AcpiTable { +const char *sig; +const uint8_t rev; +const char *oem_id; +const char *oem_table_id; +/* private vars tracking table state */ +GArray *array; +unsigned table_offset; +}AcpiTable ; + +void acpi_init_table (AcpiTable *desc,GArray *array); +void acpi_table_composed (BIOSLinker *linker,AcpiTable *table); + void build_header(BIOSLinker *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev,hw/acpi/aml-build.c +39
-0@@ -52,6 +52,19 @@ static void build_append_byte(GArray *array, uint8_t val)g_array_append_val (array, val); } +static void build_append_padded_str (GArray *array,const char *str, +size_t maxlen,char pad) +{ +size_t i; +size_t len =strlen (str); + +g_assert (len <= maxlen); +g_array_append_vals (array, str, len); +for (i = maxlen - len; i >0 ; i--) { +g_array_append_val (array, pad); + } +} +static void build_append_array (GArray *array,GArray *val) {g_array_append_vals (array, val->data, val->len);@@ -1692,6 +1705,46 @@ Aml *aml_object_type(Aml *object)return var; } +void acpi_init_table (AcpiTable *desc,GArray *array) +{ + + desc->array = array; + desc->table_offset = array->len; + +/* +* ACPI spec 1.0b +* 5.2.3 System Description Table Header +*/ +g_assert (strlen (desc->sig) ==4 ); +g_array_append_vals (array, desc->sig,4 );/* Signature */ +build_append_int_noprefix (array,0 ,4 );/* Length */ +build_append_int_noprefix (array, desc->rev,1 );/* Revision */ +build_append_int_noprefix (array,0 ,1 );/* Checksum */ +build_append_padded_str (array, desc->oem_id,6 ,' ' );/* OEMID */ +/* OEM Table ID */ +build_append_padded_str (array, desc->oem_table_id,8 ,' ' ); +build_append_int_noprefix (array,1 ,4 );/* OEM Revision */ +g_array_append_vals (array,ACPI_BUILD_APPNAME8 ,4 );/* Creator ID */ +build_append_int_noprefix (array,1 ,4 );/* Creator Revision */ +} + +void acpi_table_composed (BIOSLinker *linker,AcpiTable *desc) +{ +/*
hw/acpi/aml-build.c Aml *aml_object_type(Aml *object) · line 1743
Quoted 10 lines
hw/acpi/aml-build.c +10
-0+* ACPI spec 1.0b +* 5.2.3 System Description Table Header +* Table 5-2 DESCRIPTION_HEADER Fields +*/ +const unsigned checksum_offset =9 ; +uint32_t table_len = desc->array->len - desc->table_offset; +uint32_t table_len_le =cpu_to_le32 (table_len); +gchar *len_ptr = &desc->array->data[desc->table_offset +4 ]; + +memcpy (len_ptr, &table_len_le,sizeof table_len_le);
ok so this patches in the correct length. Not sure how to make it prettier ... at least please add comments explaining what's going on here.
Quoted 9 lines
hw/acpi/aml-build.c +4
-0+bios_linker_loader_add_checksum (linker,ACPI_BUILD_TABLE_FILE , + desc->table_offset, table_len, desc->table_offset + checksum_offset); +} + void build_header(BIOSLinker *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev,Signature · 1 line
2.27.0
Re: [PATCH 19/53] acpi: add helper routines to initialize ACPI tables
Quoted 7 lines · On Tue, 29 Jun 2021 15:16:42 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 6 lines · Igor Mammedov
acpi_init_table():
initializes table header and keeps track of table data/offsets
acpi_table_composed():
sets actual table length and tells bios loader where it's for later initialization on guest side.
Patch introduces acpi_init_table()/acpi_table_composed() API that hides pointer/offset arithmetic from user as opposed to build_header(), to prevent errors caused by it [1].
acpi_init_table():
initializes table header and keeps track of table data/offsets
acpi_table_composed():
sets actual table length and tells bios loader where table is for the later initialization on guest side.
1) commits
bb9feea43179 x86: acpi: use offset instead of pointer when using build_header() 4d027afeb3a9 Virt: ACPI: fix qemu assert due to re-assigned table data address
Quoted 91 lines
Quoted 91 lines
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/aml-build.h | 14 ++++++++++ hw/acpi/aml-build.c | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)include/hw/acpi/aml-build.h +14
-0@@ -413,6 +413,20 @@ Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target);Aml *aml_object_type (Aml *object);void build_append_int_noprefix (GArray *table,uint64_t value,int size); + +typedef struct AcpiTable { +const char *sig; +const uint8_t rev; +const char *oem_id; +const char *oem_table_id; +/* private vars tracking table state */ +GArray *array; +unsigned table_offset; +}AcpiTable ; + +void acpi_init_table (AcpiTable *desc,GArray *array); +void acpi_table_composed (BIOSLinker *linker,AcpiTable *table); + void build_header(BIOSLinker *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev,hw/acpi/aml-build.c +45
-0@@ -52,6 +52,19 @@ static void build_append_byte(GArray *array, uint8_t val)g_array_append_val (array, val); } +static void build_append_padded_str (GArray *array,const char *str, +size_t maxlen,char pad) +{ +size_t i; +size_t len =strlen (str); + +g_assert (len <= maxlen); +g_array_append_vals (array, str, len); +for (i = maxlen - len; i >0 ; i--) { +g_array_append_val (array, pad); + } +} +static void build_append_array (GArray *array,GArray *val) {g_array_append_vals (array, val->data, val->len);@@ -1692,6 +1705,46 @@ Aml *aml_object_type(Aml *object)return var; } +void acpi_init_table (AcpiTable *desc,GArray *array) +{ + + desc->array = array; + desc->table_offset = array->len; + +/* +* ACPI spec 1.0b +* 5.2.3 System Description Table Header +*/ +g_assert (strlen (desc->sig) ==4 ); +g_array_append_vals (array, desc->sig,4 );/* Signature */ +build_append_int_noprefix (array,0 ,4 );/* Length */ +build_append_int_noprefix (array, desc->rev,1 );/* Revision */ +build_append_int_noprefix (array,0 ,1 );/* Checksum */ +build_append_padded_str (array, desc->oem_id,6 ,' ' );/* OEMID */ +/* OEM Table ID */ +build_append_padded_str (array, desc->oem_table_id,8 ,' ' ); +build_append_int_noprefix (array,1 ,4 );/* OEM Revision */ +g_array_append_vals (array,ACPI_BUILD_APPNAME8 ,4 );/* Creator ID */ +build_append_int_noprefix (array,1 ,4 );/* Creator Revision */ +} + +void acpi_table_composed (BIOSLinker *linker,AcpiTable *desc) +{ +/* +* ACPI spec 1.0b +* 5.2.3 System Description Table Header +* Table 5-2 DESCRIPTION_HEADER Fields +*/ +const unsigned checksum_offset =9 ; +uint32_t table_len = desc->array->len - desc->table_offset;
Quoted 8 lines
hw/acpi/aml-build.c Aml *aml_object_type(Aml *object) · line 1743
Quoted 4 lines
hw/acpi/aml-build.c +4
-0+uint32_t table_len_le =cpu_to_le32 (table_len); +gchar *len_ptr = &desc->array->data[desc->table_offset +4 ]; + +memcpy (len_ptr, &table_len_le,sizeof table_len_le);ok so this patches in the correct length. Not sure how to make it prettier ... at least please add comments explaining what's going on here.
it's not prettier, combo of acpi_init_table()/acpi_table_composed() intention is to hide offsets manipulation from callers in the most usecases. (that's where we used to have bugs). I have this explained in cover letter, but I lost it when writing down this commit message (see updated commit message above)
how about:
/* patch table length reserved by acpi_init_table()
* to the actual length, i.e. accumulated table length from
* acpi_init_table() till acpi_table_composed() */
Quoted 11 lines
Quoted 10 lines
hw/acpi/aml-build.c +4
-0+bios_linker_loader_add_checksum (linker,ACPI_BUILD_TABLE_FILE , + desc->table_offset, table_len, desc->table_offset + checksum_offset); +} + void build_header(BIOSLinker *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev,Signature · 1 line
2.27.0
PATCH 20/53 acpi: build_rsdt: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offests magic from API user.
While at it switch to build_append_int_noprefix() to build entries to other tables (which also removes some manual offset calculations).
--- include/hw/acpi/acpi-defs.h | 10 ---------- hw/acpi/aml-build.c | 27 ++++++++++++--------------- 2 files changed, 12 insertions(+), 25 deletions(-)
include/hw/acpi/acpi-defs.h +0 -10
@@ -149,16 +149,6 @@ struct AcpiSerialPortConsoleRedirection {typedef struct AcpiSerialPortConsoleRedirection AcpiSerialPortConsoleRedirection ; -/* -* ACPI 1.0 Root System Description Table (RSDT) -*/ -struct AcpiRsdtDescriptorRev1 { -ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint32_t table_offset_entry[]; /* Array of pointers to other */ -/* ACPI tables */ -}QEMU_PACKED ; -typedef struct AcpiRsdtDescriptorRev1 AcpiRsdtDescriptorRev1 ; -/* * ACPI 2.0 eXtended System Description Table (XSDT) */
hw/acpi/aml-build.c +12 -15
@@ -1881,27 +1881,24 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, const char *oem_id, const char *oem_table_id) { int i; -unsigned rsdt_entries_offset; -AcpiRsdtDescriptorRev1 *rsdt; -int rsdt_start = table_data->len; -const unsigned table_data_len = (sizeof (uint32_t ) * table_offsets->len); -const unsigned rsdt_entry_size =sizeof (rsdt->table_offset_entry[0 ]); -const size_t rsdt_len =sizeof (*rsdt) + table_data_len; - - rsdt =acpi_data_push (table_data, rsdt_len); - rsdt_entries_offset = (char *)rsdt->table_offset_entry - table_data->data; +AcpiTable table = { .sig ="RSDT" , .rev =1 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; + +acpi_init_table (&table, table_data);for (i =0 ; i < table_offsets->len; ++i) {uint32_t ref_tbl_offset =g_array_index (table_offsets, uint32_t, i); -uint32_t rsdt_entry_offset = rsdt_entries_offset + rsdt_entry_size * i; +uint32_t rsdt_entry_offset = table.array->len; + +/* reserve space for entry */ +build_append_int_noprefix (table.array,0 ,4 ); -/* rsdt->table_offset_entry to be filled by Guest linker */ +/* mark position of RSDT entry to be filled by Guest linker */ bios_linker_loader_add_pointer (linker, -ACPI_BUILD_TABLE_FILE , rsdt_entry_offset, rsdt_entry_size, +ACPI_BUILD_TABLE_FILE , rsdt_entry_offset,4 ,ACPI_BUILD_TABLE_FILE , ref_tbl_offset); + } -build_header (linker, table_data, - (void *)(table_data->data + rsdt_start), -"RSDT" , rsdt_len,1 , oem_id, oem_table_id); +acpi_table_composed (linker, &table); }/* Build xsdt table */
Signature · 1 line
2.27.0
PATCH 21/53 acpi: build_xsdt: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
While at it switch to build_append_int_noprefix() to build entries to other tables (which also removes some manual offset calculations).
--- include/hw/acpi/acpi-defs.h | 10 ---------- hw/acpi/aml-build.c | 27 ++++++++++++--------------- 2 files changed, 12 insertions(+), 25 deletions(-)
include/hw/acpi/acpi-defs.h +0 -10
@@ -149,16 +149,6 @@ struct AcpiSerialPortConsoleRedirection {typedef struct AcpiSerialPortConsoleRedirection AcpiSerialPortConsoleRedirection ; -/* -* ACPI 2.0 eXtended System Description Table (XSDT) -*/ -struct AcpiXsdtDescriptorRev2 { -ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint64_t table_offset_entry[]; /* Array of pointers to other */ -/* ACPI tables */ -}QEMU_PACKED ; -typedef struct AcpiXsdtDescriptorRev2 AcpiXsdtDescriptorRev2 ; -/* * ACPI 1.0 Firmware ACPI Control Structure (FACS) */
hw/acpi/aml-build.c +12 -15
@@ -1907,27 +1907,24 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, const char *oem_id, const char *oem_table_id) { int i; -unsigned xsdt_entries_offset; -AcpiXsdtDescriptorRev2 *xsdt; -int xsdt_start = table_data->len; -const unsigned table_data_len = (sizeof (uint64_t ) * table_offsets->len); -const unsigned xsdt_entry_size =sizeof (xsdt->table_offset_entry[0 ]); -const size_t xsdt_len =sizeof (*xsdt) + table_data_len; - - xsdt =acpi_data_push (table_data, xsdt_len); - xsdt_entries_offset = (char *)xsdt->table_offset_entry - table_data->data; +AcpiTable table = { .sig ="XSDT" , .rev =1 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; + +acpi_init_table (&table, table_data); +for (i =0 ; i < table_offsets->len; ++i) {uint64_t ref_tbl_offset =g_array_index (table_offsets, uint32_t, i); -uint64_t xsdt_entry_offset = xsdt_entries_offset + xsdt_entry_size * i; +uint64_t xsdt_entry_offset = table.array->len; -/* xsdt->table_offset_entry to be filled by Guest linker */ +/* reserve space for entry */ +build_append_int_noprefix (table.array,0 ,8 ); + +/* mark position of RSDT entry to be filled by Guest linker */ bios_linker_loader_add_pointer (linker, -ACPI_BUILD_TABLE_FILE , xsdt_entry_offset, xsdt_entry_size, +ACPI_BUILD_TABLE_FILE , xsdt_entry_offset,8 ,ACPI_BUILD_TABLE_FILE , ref_tbl_offset); } -build_header (linker, table_data, - (void *)(table_data->data + xsdt_start), -"XSDT" , xsdt_len,1 , oem_id, oem_table_id); +acpi_table_composed (linker, &table); } void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
Signature · 1 line
2.27.0
PATCH 22/53 acpi: build_slit: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
--- hw/acpi/aml-build.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
hw/acpi/aml-build.c +5 -8
@@ -1945,11 +1945,12 @@ void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,void build_slit (GArray *table_data,BIOSLinker *linker,MachineState *ms,const char *oem_id,const char *oem_table_id) { -int slit_start, i, j; - slit_start = table_data->len; +int i, j;int nb_numa_nodes = ms->numa_state->num_nodes; +AcpiTable table = { .sig ="SLIT" , .rev =1 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; -acpi_data_push (table_data,sizeof (AcpiTableHeader)); +acpi_init_table (&table, table_data);build_append_int_noprefix (table_data, nb_numa_nodes,8 );for (i =0 ; i < nb_numa_nodes; i++) {
@@ -1960,11 +1961,7 @@ void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms, 1); } } - -build_header (linker, table_data, - (void *)(table_data->data + slit_start), -"SLIT" , - table_data->len - slit_start,1 , oem_id, oem_table_id); +acpi_table_composed (linker, &table); }/* build rev1/rev3/rev5.1 FADT */
Signature · 1 line
2.27.0
PATCH 23/53 acpi: build_fadt: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
--- hw/acpi/aml-build.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
hw/acpi/aml-build.c +7 -7
@@ -1969,9 +1969,10 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f, const char *oem_id, const char *oem_table_id) { int off; -int fadt_start = tbl->len; +AcpiTable table = { .sig ="FACP" , .rev = f->rev, + .oem_id = oem_id, .oem_table_id = oem_table_id }; -acpi_data_push (tbl,sizeof (AcpiTableHeader)); +acpi_init_table (&table, tbl);/* FACS address to be filled by Guest linker at runtime */ off = tbl->len;
@@ -2035,7 +2036,7 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,build_append_int_noprefix (tbl, f->flags,4 );/* Flags */ if (f->rev ==1 ) { - goto build_hdr; + goto done; }build_append_gas_from_struct (tbl, &f->reset_reg);/* RESET_REG */
@@ -2072,7 +2073,7 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,build_append_gas (tbl,AML_AS_SYSTEM_MEMORY ,0 ,0 ,0 ,0 );/* X_GPE1_BLK */ if (f->rev <=4 ) { - goto build_hdr; + goto done; }/* SLEEP_CONTROL_REG */
@@ -2083,9 +2084,8 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,/* TODO: extra fields need to be added to support revisions above rev5 */ assert (f->rev ==5 ); -build_hdr: -build_header (linker, tbl, (void *)(tbl->data + fadt_start), -"FACP" , tbl->len - fadt_start, f->rev, oem_id, oem_table_id); +done: +acpi_table_composed (linker, &table); }#ifdef CONFIG_TPM
Signature · 1 line
2.27.0
PATCH 24/53 acpi: build_tpm2: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
---
CC: [email protected]
--- hw/acpi/aml-build.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
hw/acpi/aml-build.c +5 -6
@@ -2098,13 +2098,14 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog, const char *oem_id, const char *oem_table_id) { uint8_t start_method_params[12] = {}; -unsigned log_addr_offset, tpm2_start; +unsigned log_addr_offset;uint64_t control_area_start_address;TPMIf *tpmif =tpm_find ();uint32_t start_method; +AcpiTable table = { .sig ="TPM2" , .rev =4 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; - tpm2_start = table_data->len; -acpi_data_push (table_data,sizeof (AcpiTableHeader)); +acpi_init_table (&table, table_data);/* Platform Class */ build_append_int_noprefix (table_data,TPM2_ACPI_CLASS_CLIENT ,2 );
@@ -2142,9 +2143,7 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,bios_linker_loader_add_pointer (linker,ACPI_BUILD_TABLE_FILE , log_addr_offset,8 ,ACPI_BUILD_TPMLOG_FILE ,0 ); -build_header (linker, table_data, - (void *)(table_data->data + tpm2_start), - "TPM2", table_data->len - tpm2_start, 4, oem_id, oem_table_id); + acpi_table_composed(linker, &table); }#endif
Signature · 1 line
2.27.0
Re: [PATCH 24/53] acpi: build_tpm2: use acpi_init_table()/acpi_table_composed() instead of build_header()
Quoted 5 lines · Igor Mammedov
it replaces error-prone pointer arithmetic for
build_header()API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.Signed-off-by Igor Mammedov <[email protected]>
I applied patch 19 of this series along with this one and this one works (TPM 1.2 not so much with TCPA modifications):
Quoted 39 lines
---
CC: [email protected]--- hw/acpi/aml-build.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)hw/acpi/aml-build.c +5
-6@@ -2098,13 +2098,14 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog, const char *oem_id, const char *oem_table_id) { uint8_t start_method_params[12] = {}; -unsigned log_addr_offset, tpm2_start; +unsigned log_addr_offset;uint64_t control_area_start_address;TPMIf *tpmif =tpm_find ();uint32_t start_method; +AcpiTable table = { .sig ="TPM2" , .rev =4 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; - tpm2_start = table_data->len; -acpi_data_push (table_data,sizeof (AcpiTableHeader)); +acpi_init_table (&table, table_data);/* Platform Class */ build_append_int_noprefix (table_data,TPM2_ACPI_CLASS_CLIENT ,2 );@@ -2142,9 +2143,7 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,bios_linker_loader_add_pointer (linker,ACPI_BUILD_TABLE_FILE , log_addr_offset,8 ,ACPI_BUILD_TPMLOG_FILE ,0 ); -build_header (linker, table_data, - (void *)(table_data->data + tpm2_start), - "TPM2", table_data->len - tpm2_start, 4, oem_id, oem_table_id); + acpi_table_composed(linker, &table); }#endif
PATCH 25/53 acpi: acpi_build_hest: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- hw/acpi/ghes.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
hw/acpi/ghes.c +4 -6
@@ -362,18 +362,16 @@ static void build_ghes_v2(GArray *table_data, int source_id, BIOSLinker *linker)void acpi_build_hest (GArray *table_data,BIOSLinker *linker,const char *oem_id,const char *oem_table_id) { -uint64_t hest_start = table_data->len; +AcpiTable table = { .sig ="HEST" , .rev =1 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; -/* Hardware Error Source Table header*/ -acpi_data_push (table_data,sizeof (AcpiTableHeader)); +acpi_init_table (&table, table_data);/* Error Source Count */ build_append_int_noprefix (table_data,ACPI_GHES_ERROR_SOURCE_COUNT ,4 ); -build_ghes_v2 (table_data,ACPI_HEST_SRC_ID_SEA , linker); -build_header (linker, table_data, (void *)(table_data->data + hest_start), -"HEST" , table_data->len - hest_start,1 , oem_id, oem_table_id); +acpi_table_composed (linker, &table); } void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgState *s,
Signature · 1 line
2.27.0
Re: [PATCH 25/53] acpi: acpi_build_hest: use acpi_init_table()/acpi_table_composed() instead of build_header()
Quoted 28 lines · Igor Mammedov <[email protected]> 于2021年6月25日周五 下午5:19写道:
it replaces error-prone pointer arithmetic for
build_header()API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.Signed-off-by Igor Mammedov <[email protected]>---
CC: [email protected]
CC: [email protected]
CC: [email protected]--- hw/acpi/ghes.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)hw/acpi/ghes.c +2
-3@@ -362,18 +362,16 @@ static void build_ghes_v2(GArray *table_data, int source_id, BIOSLinker *linker)void acpi_build_hest (GArray *table_data,BIOSLinker *linker,const char *oem_id,const char *oem_table_id) { -uint64_t hest_start = table_data->len; +AcpiTable table = { .sig ="HEST" , .rev =1 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; -/* Hardware Error Source Table header*/ -acpi_data_push (table_data,sizeof (AcpiTableHeader));
hw/acpi/ghes.c static void build_ghes_v2(GArray *table_data, int source_id, BIOSLinker *linker) · line 374
Quoted 10 lines
hw/acpi/ghes.c +2
-3+acpi_init_table (&table, table_data);/* Error Source Count */ build_append_int_noprefix (table_data,ACPI_GHES_ERROR_SOURCE_COUNT ,4 ); -build_ghes_v2 (table_data,ACPI_HEST_SRC_ID_SEA , linker); -build_header (linker, table_data, (void *)(table_data->data + hest_start), -"HEST" , table_data->len - hest_start,1 , oem_id, oem_table_id); +acpi_table_composed (linker, &table);
Thanks for the change, I think this change is reasonable to use
common API acpi_init_table() to replace build_header()
Quoted 6 lines
hw/acpi/ghes.c +0
-1} void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgState *s, --2.27.0
PATCH 26/53 acpi: build_mcfg: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
--- hw/acpi/pci.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
hw/acpi/pci.c +9 -9
@@ -28,19 +28,20 @@#include "hw/acpi/pci.h" #include "hw/pci/pcie_host.h" +/* +* PCI Firmware Specification, Revision 3.0 +* 4.1.2 MCFG Table Description. +*/ void build_mcfg (GArray *table_data,BIOSLinker *linker,AcpiMcfgInfo *info,const char *oem_id,const char *oem_table_id) { -int mcfg_start = table_data->len; +AcpiTable table = { .sig ="MCFG" , .rev =1 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; + +acpi_init_table (&table, table_data); -/* -* PCI Firmware Specification, Revision 3.0 -* 4.1.2 MCFG Table Description. -*/ -acpi_data_push (table_data,sizeof (AcpiTableHeader));/* Reserved */ build_append_int_noprefix (table_data,0 ,8 ); -/* * Memory Mapped Enhanced Configuration Space Base Address Allocation * Structure
@@ -56,6 +57,5 @@ void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info,/* Reserved */ build_append_int_noprefix (table_data,0 ,4 ); -build_header (linker, table_data, (void *)(table_data->data + mcfg_start), -"MCFG" , table_data->len - mcfg_start,1 , oem_id, oem_table_id); +acpi_table_composed (linker, &table); }
Signature · 1 line
2.27.0
PATCH 27/53 acpi: build_hmat: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
Also since acpi_init_table() reserves space only for standard header while previous acpi_data_push() reserved the header + 4 bytes field, add 4 bytes 'Reserved' field into hmat_build_table_structs() which didn have it.
--- hw/acpi/hmat.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
hw/acpi/hmat.c +6 -8
@@ -200,6 +200,8 @@ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_state)HMAT_LB_Info *hmat_lb;NumaHmatCacheOptions *hmat_cache; +build_append_int_noprefix (table_data,0 ,4 );/* Reserved */ +for (i =0 ; i < numa_state->num_nodes; i++) { flags =0 ;
@@ -256,14 +258,10 @@ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_state)void build_hmat (GArray *table_data,BIOSLinker *linker,NumaState *numa_state,const char *oem_id,const char *oem_table_id) { -int hmat_start = table_data->len; - -/* reserve space for HMAT header */ -acpi_data_push (table_data,40 ); +AcpiTable table = { .sig ="HMAT" , .rev =2 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; +acpi_init_table (&table, table_data);hmat_build_table_structs (table_data, numa_state); - -build_header (linker, table_data, - (void *)(table_data->data + hmat_start), -"HMAT" , table_data->len - hmat_start,2 , oem_id, oem_table_id); +acpi_table_composed (linker, &table); }
Signature · 1 line
2.27.0
PATCH 28/53 acpi: nvdimm_build_nfit: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
Also since acpi_init_table() reserves space only for standard header while previous acpi_data_push() reserved the header + 4 bytes field, add 4 bytes 'Reserved' field into nvdimm_build_nfit() which didn't have it.
---
CC: [email protected]
--- hw/acpi/nvdimm.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-)
hw/acpi/nvdimm.c +17 -25
@@ -44,22 +44,6 @@ static const uint8_t nvdimm_nfit_spa_uuid[] =UUID_LE (0x66f0d379 ,0xb4f3 ,0x4074 ,0xac ,0x43 ,0x0d ,0x33 ,0x18 ,0xb7 ,0x8c ,0xdb ); -/* -* NVDIMM Firmware Interface Table -* @signature: "NFIT" -* -* It provides information that allows OSPM to enumerate NVDIMM present in -* the platform and associate system physical address ranges created by the -* NVDIMMs. -* -* It is defined in ACPI 6.0: 5.2.25 NVDIMM Firmware Interface Table (NFIT) -*/ -struct NvdimmNfitHeader { -ACPI_TABLE_HEADER_DEF - uint32_t reserved; -}QEMU_PACKED ; -typedef struct NvdimmNfitHeader NvdimmNfitHeader ; -/* * define NFIT structures according to ACPI 6.0: 5.2.25 NVDIMM Firmware * Interface Table (NFIT).
@@ -401,25 +385,33 @@ void nvdimm_plug(NVDIMMState *state)nvdimm_build_fit_buffer (state); } +/* +* NVDIMM Firmware Interface Table +* @signature: "NFIT" +* +* It provides information that allows OSPM to enumerate NVDIMM present in +* the platform and associate system physical address ranges created by the +* NVDIMMs. +* +* It is defined in ACPI 6.0: 5.2.25 NVDIMM Firmware Interface Table (NFIT) +*/ +static void nvdimm_build_nfit (NVDIMMState *state,GArray *table_offsets,GArray *table_data,BIOSLinker *linker,const char *oem_id,const char *oem_table_id) {NvdimmFitBuffer *fit_buf = &state->fit_buf; -unsigned int header; +AcpiTable table = { .sig ="NFIT" , .rev =1 , + .oem_id = oem_id, .oem_table_id = oem_table_id };acpi_add_table (table_offsets, table_data); -/* NFIT header. */ - header = table_data->len; -acpi_data_push (table_data,sizeof (NvdimmNfitHeader)); +acpi_init_table (&table, table_data); +/* Reserved */ +build_append_int_noprefix (table_data,0 ,4 );/* NVDIMM device structures. */ g_array_append_vals (table_data, fit_buf->fit->data, fit_buf->fit->len); - -build_header (linker, table_data, - (void *)(table_data->data + header),"NFIT" , -sizeof (NvdimmNfitHeader) + fit_buf->fit->len,1 , oem_id, - oem_table_id); +acpi_table_composed (linker, &table); }#define NVDIMM_DSM_MEMORY_SIZE 4096
Signature · 1 line
2.27.0
PATCH 29/53 acpi: nvdimm_build_ssdt: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
---
CC: [email protected]
--- hw/acpi/nvdimm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
hw/acpi/nvdimm.c +10 -8
@@ -1274,14 +1274,15 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data,NVDIMMState *nvdimm_state, uint32_t ram_slots, const char *oem_id) { + int mem_addr_offset;Aml *ssdt, *sb_scope, *dev; -int mem_addr_offset, nvdimm_ssdt; +AcpiTable table = { .sig ="SSDT" , .rev =1 , + .oem_id = oem_id, .oem_table_id ="NVDIMM" };acpi_add_table (table_offsets, table_data); +acpi_init_table (&table, table_data); ssdt =init_aml_allocator (); -acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); - sb_scope =aml_scope ("\\_SB" ); dev =aml_device ("NVDR" );
@@ -1310,8 +1311,6 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data,aml_append (sb_scope, dev);aml_append (ssdt, sb_scope); - nvdimm_ssdt = table_data->len; -/* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals (table_data, ssdt->buf->data, ssdt->buf->len); mem_addr_offset = build_append_named_dword(table_data,
@@ -1323,10 +1322,13 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data,bios_linker_loader_add_pointer (linker,ACPI_BUILD_TABLE_FILE , mem_addr_offset,sizeof (uint32_t ),NVDIMM_DSM_MEM_FILE ,0 ); -build_header (linker, table_data, - (void *)(table_data->data + nvdimm_ssdt), -"SSDT" , table_data->len - nvdimm_ssdt,1 , oem_id,"NVDIMM" );free_aml_allocator (); +/* +* must be executed as the last so that pointer patching command above +* would be executed by guest before it recalculates checksum which were +* scheduled by acpi_table_composed() +*/ +acpi_table_composed (linker, &table); }void nvdimm_build_srat (GArray *table_data)
Signature · 1 line
2.27.0
PATCH 30/53 acpi: vmgenid_build_acpi: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
--- hw/acpi/vmgenid.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
hw/acpi/vmgenid.c +7 -9
@@ -29,6 +29,8 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *table_data, GArray *guid,Aml *ssdt, *dev, *scope, *method, *addr, *if_ctx;uint32_t vgia_offset;QemuUUID guid_le; +AcpiTable table = { .sig ="SSDT" , .rev =1 , + .oem_id = oem_id, .oem_table_id ="VMGENID" };/* Fill in the GUID values. These need to be converted to little-endian * first, since that's what the guest expects
@@ -42,15 +44,12 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *table_data, GArray *guid,g_array_insert_vals (guid,VMGENID_GUID_OFFSET , guid_le.data,ARRAY_SIZE (guid_le.data)); -/* Put this in a separate SSDT table */ +/* Put VMGNEID into a separate SSDT table */ +acpi_init_table (&table, table_data); ssdt =init_aml_allocator (); -/* Reserve space for header */ -acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); -/* Storage for the GUID address */ - vgia_offset = table_data->len + -build_append_named_dword (ssdt->buf,"VGIA" ); + vgia_offset = table_data->len +build_append_named_dword (ssdt->buf,"VGIA" ); scope =aml_scope ("\\_SB" ); dev =aml_device ("VGEN" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("QEMUVGID" )));
@@ -116,9 +115,8 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *table_data, GArray *guid,ACPI_BUILD_TABLE_FILE , vgia_offset,sizeof (uint32_t ), VMGENID_GUID_FW_CFG_FILE, 0); -build_header (linker, table_data, - (void *)(table_data->data + table_data->len - ssdt->buf->len), -"SSDT" , ssdt->buf->len,1 , oem_id,"VMGENID" ); +/* must be called after above command to ensure correct table checksum */ +acpi_table_composed (linker, &table);free_aml_allocator (); }
Signature · 1 line
2.27.0
PATCH 31/53 acpi: x86: build_dsdt: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
---
CC: [email protected]
--- hw/i386/acpi-build.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
hw/i386/acpi-build.c +4 -6
@@ -1380,12 +1380,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,#endif int i;VMBusBridge *vmbus_bridge =vmbus_bridge_find (); +AcpiTable table = { .sig ="DSDT" , .rev =1 , .oem_id = x86ms->oem_id, + .oem_table_id = x86ms->oem_table_id }; +acpi_init_table (&table, table_data); dsdt =init_aml_allocator (); -/* Reserve space for header */ -acpi_data_push (dsdt->buf,sizeof (AcpiTableHeader)); -build_dbg_aml (dsdt);if (misc->is_piix4) { sb_scope =aml_scope ("_SB" );
@@ -1816,9 +1816,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,/* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals (table_data, dsdt->buf->data, dsdt->buf->len); -build_header (linker, table_data, - (void *)(table_data->data + table_data->len - dsdt->buf->len), -"DSDT" , dsdt->buf->len,1 , x86ms->oem_id, x86ms->oem_table_id); +acpi_table_composed (linker, &table);free_aml_allocator (); }
Signature · 1 line
2.27.0
PATCH 32/53 acpi: build_hpet: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
while at it convert build_hpet() to endian agnostic build_append_FOO() API
---
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 13 ------------- hw/i386/acpi-build.c | 26 ++++++++++++++++++-------- 2 files changed, 18 insertions(+), 21 deletions(-)
include/hw/acpi/acpi-defs.h +0 -13
@@ -358,19 +358,6 @@ struct AcpiGenericTimerTable { }QEMU_PACKED ;typedef struct AcpiGenericTimerTable AcpiGenericTimerTable ; -/* -* HPET Description Table -*/ -struct Acpi20Hpet { -ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint32_t timer_block_id; -struct AcpiGenericAddress addr; -uint8_t hpet_number; -uint16_t min_tick; -uint8_t page_protect; -}QEMU_PACKED ; -typedef struct Acpi20Hpet Acpi20Hpet ; -/* * SRAT (NUMA topology description) table */
hw/i386/acpi-build.c +18 -8
@@ -1820,22 +1820,32 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,free_aml_allocator (); } +/* +* IA-PC HPET (High Precision Event Timers) Specification (Revision: 1.0a) +* 3.2.4The ACPI 2.0 HPET Description Table (HPET) +*/ static void build_hpet (GArray *table_data,BIOSLinker *linker,const char *oem_id,const char *oem_table_id) { -Acpi20Hpet *hpet; -int hpet_start = table_data->len; +AcpiTable table = { .sig ="HPET" , .rev =1 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; - hpet =acpi_data_push (table_data,sizeof (*hpet)); +acpi_init_table (&table, table_data);/* Note timer_block_id value must be kept in sync with value advertised by * emulated hpet */ - hpet->timer_block_id =cpu_to_le32 (0x8086a201 ); - hpet->addr.address =cpu_to_le64 (HPET_BASE ); -build_header (linker, table_data, - (void *)(table_data->data + hpet_start), -"HPET" ,sizeof (*hpet),1 , oem_id, oem_table_id); +/* Event Timer Block ID */ +build_append_int_noprefix (table_data,0x8086a201 ,4 ); +/* BASE_ADDRESS */ +build_append_gas (table_data,AML_AS_SYSTEM_MEMORY ,0 ,0 ,0 ,HPET_BASE ); +/* HPET Number */ +build_append_int_noprefix (table_data,0 ,1 ); +/* Main Counter Minimum Clock_tick in Periodic Mode */ +build_append_int_noprefix (table_data,0 ,2 ); +/* Page Protection And OEM Attribute */ +build_append_int_noprefix (table_data,0 ,1 ); +acpi_table_composed (linker, &table); }#ifdef CONFIG_TPM
Signature · 1 line
2.27.0
PATCH 33/53 acpi: build_tpm_tcpa: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
While at it switch to build_append_int_noprefix() to build table entries (which also removes some manual offset calculations).
---
CC: [email protected]
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 14 ------------- hw/i386/acpi-build.c | 39 +++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 31 deletions(-)
include/hw/acpi/acpi-defs.h +0 -14
@@ -418,20 +418,6 @@ struct AcpiSratProcessorGiccAffinity {typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity ; -/* -* TCPA Description Table -* -* Following Level 00, Rev 00.37 of specs: -* http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification -*/ -struct Acpi20Tcpa { -ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint16_t platform_class; -uint32_t log_area_minimum_length; -uint64_t log_area_start_address; -}QEMU_PACKED ; -typedef struct Acpi20Tcpa Acpi20Tcpa ; -/* DMAR - DMA Remapping table r2.2 */ struct AcpiTableDmar {ACPI_TABLE_HEADER_DEF
hw/i386/acpi-build.c +22 -17
@@ -1849,31 +1849,36 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id, }#ifdef CONFIG_TPM +/* +* TCPA Description Table +* +* Following Level 00, Rev 00.37 of specs: +* http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification +* 7.1.2 ACPI Table Layout +*/ static void build_tpm_tcpa (GArray *table_data,BIOSLinker *linker,GArray *tcpalog,const char *oem_id,const char *oem_table_id) { -int tcpa_start = table_data->len; -Acpi20Tcpa *tcpa =acpi_data_push (table_data,sizeof *tcpa); -unsigned log_addr_size =sizeof (tcpa->log_area_start_address); -unsigned log_addr_offset = - (char *)&tcpa->log_area_start_address - table_data->data; +AcpiTable table = { .sig ="TCPA" , .rev =2 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; - tcpa->platform_class =cpu_to_le16 (TPM_TCPA_ACPI_CLASS_CLIENT ); - tcpa->log_area_minimum_length =cpu_to_le32 (TPM_LOG_AREA_MINIMUM_SIZE ); -acpi_data_push (tcpalog,le32_to_cpu (tcpa->log_area_minimum_length)); +acpi_init_table (&table, table_data); +/* Platform Class */ +build_append_int_noprefix (table_data,TPM_TCPA_ACPI_CLASS_CLIENT ,2 ); +/* Log Area Minimum Length (LAML) */ +build_append_int_noprefix (table_data,TPM_LOG_AREA_MINIMUM_SIZE ,4 ); +/* Log Area Start Address (LASA) */ +/* log area start address to be filled by Guest linker */ +bios_linker_loader_add_pointer (linker,ACPI_BUILD_TABLE_FILE , + table_data->len,8 ,ACPI_BUILD_TPMLOG_FILE ,0 ); +build_append_int_noprefix (table_data,0 ,8 ); +acpi_table_composed (linker, &table); +/* allocate/reserve space for TPM log area */ +acpi_data_push (tcpalog,TPM_LOG_AREA_MINIMUM_SIZE );bios_linker_loader_alloc (linker,ACPI_BUILD_TPMLOG_FILE , tcpalog,1 , false/* high memory */ ); - -/* log area start address to be filled by Guest linker */ -bios_linker_loader_add_pointer (linker, -ACPI_BUILD_TABLE_FILE , log_addr_offset, log_addr_size, -ACPI_BUILD_TPMLOG_FILE ,0 ); - -build_header (linker, table_data, - (void *)(table_data->data + tcpa_start), -"TCPA" ,sizeof (*tcpa),2 , oem_id, oem_table_id); }#endif
Signature · 1 line
2.27.0
Re: [PATCH 33/53] acpi: build_tpm_tcpa: use acpi_init_table()/acpi_table_composed() instead of build_header()
Quoted 9 lines · Igor Mammedov
it replaces error-prone pointer arithmetic for
build_header()API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.While at it switch to
build_append_int_noprefix()to build table entries (which also removes some manual offset calculations).Signed-off-by Igor Mammedov <[email protected]>
Patch 19, 24 and this one applied causes this error here when using a TPM 1.2:
qemu-system-x86_64: ../hw/acpi/bios-linker-loader.c:286: bios_linker_loader_add_pointer: Assertion `source_file' failed.
Stefan
Quoted 91 lines
---
CC: [email protected]
CC: [email protected]--- include/hw/acpi/acpi-defs.h | 14 ------------- hw/i386/acpi-build.c | 39 +++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 31 deletions(-)include/hw/acpi/acpi-defs.h +0
-14@@ -418,20 +418,6 @@ struct AcpiSratProcessorGiccAffinity {typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity ; -/* -* TCPA Description Table -* -* Following Level 00, Rev 00.37 of specs: -* http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification -*/ -struct Acpi20Tcpa { -ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint16_t platform_class; -uint32_t log_area_minimum_length; -uint64_t log_area_start_address; -}QEMU_PACKED ; -typedef struct Acpi20Tcpa Acpi20Tcpa ; -/* DMAR - DMA Remapping table r2.2 */ struct AcpiTableDmar {ACPI_TABLE_HEADER_DEF hw/i386/acpi-build.c +22
-17@@ -1849,31 +1849,36 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id, }#ifdef CONFIG_TPM +/* +* TCPA Description Table +* +* Following Level 00, Rev 00.37 of specs: +* http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification +* 7.1.2 ACPI Table Layout +*/ static void build_tpm_tcpa (GArray *table_data,BIOSLinker *linker,GArray *tcpalog,const char *oem_id,const char *oem_table_id) { -int tcpa_start = table_data->len; -Acpi20Tcpa *tcpa =acpi_data_push (table_data,sizeof *tcpa); -unsigned log_addr_size =sizeof (tcpa->log_area_start_address); -unsigned log_addr_offset = - (char *)&tcpa->log_area_start_address - table_data->data; +AcpiTable table = { .sig ="TCPA" , .rev =2 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; - tcpa->platform_class =cpu_to_le16 (TPM_TCPA_ACPI_CLASS_CLIENT ); - tcpa->log_area_minimum_length =cpu_to_le32 (TPM_LOG_AREA_MINIMUM_SIZE ); -acpi_data_push (tcpalog,le32_to_cpu (tcpa->log_area_minimum_length)); +acpi_init_table (&table, table_data); +/* Platform Class */ +build_append_int_noprefix (table_data,TPM_TCPA_ACPI_CLASS_CLIENT ,2 ); +/* Log Area Minimum Length (LAML) */ +build_append_int_noprefix (table_data,TPM_LOG_AREA_MINIMUM_SIZE ,4 ); +/* Log Area Start Address (LASA) */ +/* log area start address to be filled by Guest linker */ +bios_linker_loader_add_pointer (linker,ACPI_BUILD_TABLE_FILE , + table_data->len,8 ,ACPI_BUILD_TPMLOG_FILE ,0 ); +build_append_int_noprefix (table_data,0 ,8 ); +acpi_table_composed (linker, &table); +/* allocate/reserve space for TPM log area */ +acpi_data_push (tcpalog,TPM_LOG_AREA_MINIMUM_SIZE );bios_linker_loader_alloc (linker,ACPI_BUILD_TPMLOG_FILE , tcpalog,1 , false/* high memory */ ); - -/* log area start address to be filled by Guest linker */ -bios_linker_loader_add_pointer (linker, -ACPI_BUILD_TABLE_FILE , log_addr_offset, log_addr_size, -ACPI_BUILD_TPMLOG_FILE ,0 ); - -build_header (linker, table_data, - (void *)(table_data->data + tcpa_start), -"TCPA" ,sizeof (*tcpa),2 , oem_id, oem_table_id); }#endif
Re: [PATCH 33/53] acpi: build_tpm_tcpa: use acpi_init_table()/acpi_table_composed() instead of build_header()
Quoted 10 lines · On Tue, 29 Jun 2021 11:19:17 -0400 Stefan Berger <[email protected]> wrote:
Quoted 8 lines · Igor Mammedov
it replaces error-prone pointer arithmetic for
build_header()API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.While at it switch to
build_append_int_noprefix()to build table entries (which also removes some manual offset calculations).
Quoted 8 lines
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>Patch 19, 24 and this one applied causes this error here when using a TPM 1.2:
qemu-system-x86_64:
../hw/acpi/bios-linker-loader.c:286:bios_linker_loader_add_pointer: Assertion `source_file' failed.
I missed this one since it's not covered by qtest, it seems that test_acpi_tcg_tpm() tests only TPM2.0, can you look into adding a test-case for TPM1.2 so it won't get missed/broken in the future?
I'll post fixed patch shortly as a reply this this thread.
Quoted 97 lines
Stefan
Quoted 91 lines
---
CC: [email protected]
CC: [email protected]--- include/hw/acpi/acpi-defs.h | 14 ------------- hw/i386/acpi-build.c | 39 +++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 31 deletions(-)include/hw/acpi/acpi-defs.h +0
-14@@ -418,20 +418,6 @@ struct AcpiSratProcessorGiccAffinity {typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity ; -/* -* TCPA Description Table -* -* Following Level 00, Rev 00.37 of specs: -* http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification -*/ -struct Acpi20Tcpa { -ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint16_t platform_class; -uint32_t log_area_minimum_length; -uint64_t log_area_start_address; -}QEMU_PACKED ; -typedef struct Acpi20Tcpa Acpi20Tcpa ; -/* DMAR - DMA Remapping table r2.2 */ struct AcpiTableDmar {ACPI_TABLE_HEADER_DEF hw/i386/acpi-build.c +22
-17@@ -1849,31 +1849,36 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id, }#ifdef CONFIG_TPM +/* +* TCPA Description Table +* +* Following Level 00, Rev 00.37 of specs: +* http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification +* 7.1.2 ACPI Table Layout +*/ static void build_tpm_tcpa (GArray *table_data,BIOSLinker *linker,GArray *tcpalog,const char *oem_id,const char *oem_table_id) { -int tcpa_start = table_data->len; -Acpi20Tcpa *tcpa =acpi_data_push (table_data,sizeof *tcpa); -unsigned log_addr_size =sizeof (tcpa->log_area_start_address); -unsigned log_addr_offset = - (char *)&tcpa->log_area_start_address - table_data->data; +AcpiTable table = { .sig ="TCPA" , .rev =2 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; - tcpa->platform_class =cpu_to_le16 (TPM_TCPA_ACPI_CLASS_CLIENT ); - tcpa->log_area_minimum_length =cpu_to_le32 (TPM_LOG_AREA_MINIMUM_SIZE ); -acpi_data_push (tcpalog,le32_to_cpu (tcpa->log_area_minimum_length)); +acpi_init_table (&table, table_data); +/* Platform Class */ +build_append_int_noprefix (table_data,TPM_TCPA_ACPI_CLASS_CLIENT ,2 ); +/* Log Area Minimum Length (LAML) */ +build_append_int_noprefix (table_data,TPM_LOG_AREA_MINIMUM_SIZE ,4 ); +/* Log Area Start Address (LASA) */ +/* log area start address to be filled by Guest linker */ +bios_linker_loader_add_pointer (linker,ACPI_BUILD_TABLE_FILE , + table_data->len,8 ,ACPI_BUILD_TPMLOG_FILE ,0 ); +build_append_int_noprefix (table_data,0 ,8 ); +acpi_table_composed (linker, &table); +/* allocate/reserve space for TPM log area */ +acpi_data_push (tcpalog,TPM_LOG_AREA_MINIMUM_SIZE );bios_linker_loader_alloc (linker,ACPI_BUILD_TPMLOG_FILE , tcpalog,1 , false/* high memory */ ); - -/* log area start address to be filled by Guest linker */ -bios_linker_loader_add_pointer (linker, -ACPI_BUILD_TABLE_FILE , log_addr_offset, log_addr_size, -ACPI_BUILD_TPMLOG_FILE ,0 ); - -build_header (linker, table_data, - (void *)(table_data->data + tcpa_start), -"TCPA" ,sizeof (*tcpa),2 , oem_id, oem_table_id); }#endif
PATCH v2 33/53 acpi: build_tpm_tcpa: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
While at it switch to build_append_int_noprefix() to build table entries (which also removes some manual offset calculations).
---
v2:
* fix assert when starting QEMU with TPM 1.2
Stefan Berger <[email protected]>
--- include/hw/acpi/acpi-defs.h | 14 ------------- hw/i386/acpi-build.c | 40 ++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 30 deletions(-)
include/hw/acpi/acpi-defs.h +0 -14
@@ -418,20 +418,6 @@ struct AcpiSratProcessorGiccAffinity {typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity ; -/* -* TCPA Description Table -* -* Following Level 00, Rev 00.37 of specs: -* http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification -*/ -struct Acpi20Tcpa { -ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint16_t platform_class; -uint32_t log_area_minimum_length; -uint64_t log_area_start_address; -}QEMU_PACKED ; -typedef struct Acpi20Tcpa Acpi20Tcpa ; -/* DMAR - DMA Remapping table r2.2 */ struct AcpiTableDmar {ACPI_TABLE_HEADER_DEF
hw/i386/acpi-build.c +24 -16
@@ -1849,31 +1849,39 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id, }#ifdef CONFIG_TPM +/* +* TCPA Description Table +* +* Following Level 00, Rev 00.37 of specs: +* http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification +* 7.1.2 ACPI Table Layout +*/ static void build_tpm_tcpa (GArray *table_data,BIOSLinker *linker,GArray *tcpalog,const char *oem_id,const char *oem_table_id) { -int tcpa_start = table_data->len; -Acpi20Tcpa *tcpa =acpi_data_push (table_data,sizeof *tcpa); -unsigned log_addr_size =sizeof (tcpa->log_area_start_address); -unsigned log_addr_offset = - (char *)&tcpa->log_area_start_address - table_data->data; +unsigned log_addr_offset; +AcpiTable table = { .sig ="TCPA" , .rev =2 , + .oem_id = oem_id, .oem_table_id = oem_table_id }; - tcpa->platform_class =cpu_to_le16 (TPM_TCPA_ACPI_CLASS_CLIENT ); - tcpa->log_area_minimum_length =cpu_to_le32 (TPM_LOG_AREA_MINIMUM_SIZE ); -acpi_data_push (tcpalog,le32_to_cpu (tcpa->log_area_minimum_length)); +acpi_init_table (&table, table_data); +/* Platform Class */ +build_append_int_noprefix (table_data,TPM_TCPA_ACPI_CLASS_CLIENT ,2 ); +/* Log Area Minimum Length (LAML) */ +build_append_int_noprefix (table_data,TPM_LOG_AREA_MINIMUM_SIZE ,4 ); +/* Log Area Start Address (LASA) */ + log_addr_offset = table_data->len; +build_append_int_noprefix (table_data,0 ,8 ); +acpi_table_composed (linker, &table); + +/* allocate/reserve space for TPM log area */ +acpi_data_push (tcpalog,TPM_LOG_AREA_MINIMUM_SIZE );bios_linker_loader_alloc (linker,ACPI_BUILD_TPMLOG_FILE , tcpalog,1 , false/* high memory */ ); -/* log area start address to be filled by Guest linker */ -bios_linker_loader_add_pointer (linker, -ACPI_BUILD_TABLE_FILE , log_addr_offset, log_addr_size, -ACPI_BUILD_TPMLOG_FILE ,0 ); - -build_header (linker, table_data, - (void *)(table_data->data + tcpa_start), -"TCPA" ,sizeof (*tcpa),2 , oem_id, oem_table_id); +bios_linker_loader_add_pointer (linker,ACPI_BUILD_TABLE_FILE , + log_addr_offset,8 ,ACPI_BUILD_TPMLOG_FILE ,0 ); }#endif
Signature · 1 line
2.27.0
Re: [PATCH v2 33/53] acpi: build_tpm_tcpa: use acpi_init_table()/acpi_table_composed() instead of build_header()
Quoted 9 lines · Igor Mammedov
it replaces error-prone pointer arithmetic for
build_header()API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.While at it switch to
build_append_int_noprefix()to build table entries (which also removes some manual offset calculations).Signed-off-by Igor Mammedov <[email protected]>
PATCH 34/53 acpi: arm/x86: build_srat: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 11 ----------- hw/arm/virt-acpi-build.c | 15 +++++++-------- hw/i386/acpi-build.c | 18 +++++++----------- 3 files changed, 14 insertions(+), 30 deletions(-)
include/hw/acpi/acpi-defs.h +0 -11
@@ -358,17 +358,6 @@ struct AcpiGenericTimerTable { }QEMU_PACKED ;typedef struct AcpiGenericTimerTable AcpiGenericTimerTable ; -/* -* SRAT (NUMA topology description) table -*/ - -struct AcpiSystemResourceAffinityTable { -ACPI_TABLE_HEADER_DEF - uint32_t reserved1; -uint32_t reserved2[2 ]; -}QEMU_PACKED ; -typedef struct AcpiSystemResourceAffinityTable AcpiSystemResourceAffinityTable ; -#define ACPI_SRAT_PROCESSOR_APIC 0#define ACPI_SRAT_MEMORY 1#define ACPI_SRAT_PROCESSOR_x2APIC 2
hw/arm/virt-acpi-build.c +7 -8
@@ -385,18 +385,19 @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)static void build_srat (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) { -AcpiSystemResourceAffinityTable *srat;AcpiSratProcessorGiccAffinity *core;AcpiSratMemoryAffinity *numamem; -int i, srat_start; +int i;uint64_t mem_base;MachineClass *mc =MACHINE_GET_CLASS (vms);MachineState *ms =MACHINE (vms);const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids (ms); +AcpiTable table = { .sig ="SRAT" , .rev =3 , .oem_id = vms->oem_id, + .oem_table_id = vms->oem_table_id }; - srat_start = table_data->len; - srat =acpi_data_push (table_data,sizeof (*srat)); - srat->reserved1 =cpu_to_le32 (1 ); +acpi_init_table (&table, table_data); +build_append_int_noprefix (table_data,1 ,4 );/* Reserved */ +build_append_int_noprefix (table_data,0 ,8 );/* Reserved */ for (i =0 ; i < cpu_list->len; ++i) { core =acpi_data_push (table_data,sizeof (*core));
@@ -430,9 +431,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); } -build_header (linker, table_data, (void *)(table_data->data + srat_start), -"SRAT" , table_data->len - srat_start,3 , vms->oem_id, - vms->oem_table_id); +acpi_table_composed (linker, &table); }/* GTDT */
hw/i386/acpi-build.c +7 -11
@@ -1888,11 +1888,10 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,static void build_srat (GArray *table_data,BIOSLinker *linker,MachineState *machine) { -AcpiSystemResourceAffinityTable *srat;AcpiSratMemoryAffinity *numamem;int i; -int srat_start, numa_start, slots; +int numa_start, slots;uint64_t mem_len, mem_base, next_base;MachineClass *mc =MACHINE_GET_CLASS (machine);X86MachineState *x86ms =X86_MACHINE (machine);
@@ -1901,11 +1900,12 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)ram_addr_t hotplugabble_address_space_size =object_property_get_int (OBJECT (pcms),PC_MACHINE_DEVMEM_REGION_SIZE ,NULL ); +AcpiTable table = { .sig ="SRAT" , .rev =1 , .oem_id = x86ms->oem_id, + .oem_table_id = x86ms->oem_table_id }; - srat_start = table_data->len; - - srat =acpi_data_push (table_data,sizeof *srat); - srat->reserved1 =cpu_to_le32 (1 ); +acpi_init_table (&table, table_data); +build_append_int_noprefix (table_data,1 ,4 );/* Reserved */ +build_append_int_noprefix (table_data,0 ,8 );/* Reserved */ for (i =0 ; i < apic_ids->len; i++) {int node_id = apic_ids->cpus[i].props.node_id;
@@ -2011,11 +2011,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); } -build_header (linker, table_data, - (void *)(table_data->data + srat_start), -"SRAT" , - table_data->len - srat_start,1 , x86ms->oem_id, - x86ms->oem_table_id); +acpi_table_composed (linker, &table); }/*
Signature · 1 line
2.27.0
PATCH 35/53 acpi: use build_append_int_noprefix() API to compose SRAT table
In reply to Igor MammedovDrop usage of packed structures and explicit endian conversions when building SRAT tables for arm/x86 and use endian agnostic build_append_int_noprefix() API to build it.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 49 ----------------------- include/hw/acpi/aml-build.h | 2 +- hw/acpi/aml-build.c | 24 ++++++++---- hw/acpi/nvdimm.c | 4 +- hw/arm/virt-acpi-build.c | 29 ++++++++------ hw/i386/acpi-build.c | 78 +++++++++++++++++++++---------------- 6 files changed, 80 insertions(+), 106 deletions(-)
include/hw/acpi/acpi-defs.h +0 -49
@@ -358,55 +358,6 @@ struct AcpiGenericTimerTable { }QEMU_PACKED ;typedef struct AcpiGenericTimerTable AcpiGenericTimerTable ; -#define ACPI_SRAT_PROCESSOR_APIC 0 -#define ACPI_SRAT_MEMORY 1 -#define ACPI_SRAT_PROCESSOR_x2APIC 2 -#define ACPI_SRAT_PROCESSOR_GICC 3 - -struct AcpiSratProcessorAffinity { -ACPI_SUB_HEADER_DEF - uint8_t proximity_lo; -uint8_t local_apic_id; -uint32_t flags; -uint8_t local_sapic_eid; -uint8_t proximity_hi[3 ]; -uint32_t reserved; -}QEMU_PACKED ; -typedef struct AcpiSratProcessorAffinity AcpiSratProcessorAffinity ; - -struct AcpiSratProcessorX2ApicAffinity { -ACPI_SUB_HEADER_DEF - uint16_t reserved; -uint32_t proximity_domain; -uint32_t x2apic_id; -uint32_t flags; -uint32_t clk_domain; -uint32_t reserved2; -}QEMU_PACKED ; -typedef struct AcpiSratProcessorX2ApicAffinity AcpiSratProcessorX2ApicAffinity ; - -struct AcpiSratMemoryAffinity { -ACPI_SUB_HEADER_DEF - uint32_t proximity; -uint16_t reserved1; -uint64_t base_addr; -uint64_t range_length; -uint32_t reserved2; -uint32_t flags; -uint32_t reserved3[2 ]; -}QEMU_PACKED ; -typedef struct AcpiSratMemoryAffinity AcpiSratMemoryAffinity ; - -struct AcpiSratProcessorGiccAffinity { -ACPI_SUB_HEADER_DEF - uint32_t proximity; -uint32_t acpi_processor_uid; -uint32_t flags; -uint32_t clock_domain; -}QEMU_PACKED ; - -typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity ; -/* DMAR - DMA Remapping table r2.2 */ struct AcpiTableDmar {ACPI_TABLE_HEADER_DEF
include/hw/acpi/aml-build.h +1 -1
@@ -470,7 +470,7 @@ Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_offset, uint32_t mmio32_offset, uint64_t mmio64_offset, uint16_t bus_nr_offset); -void build_srat_memory (AcpiSratMemoryAffinity *numamem,uint64_t base, +void build_srat_memory (GArray *table_data,uint64_t base,uint64_t len,int node,MemoryAffinityFlags flags); void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms,
hw/acpi/aml-build.c +17 -7
@@ -1927,15 +1927,25 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,acpi_table_composed (linker, &table); } -void build_srat_memory (AcpiSratMemoryAffinity *numamem,uint64_t base, +/* +* ACPI spec, Revision 4.0 +* 5.2.16.2 Memory Affinity Structure +*/ +void build_srat_memory (GArray *table_data,uint64_t base,uint64_t len,int node,MemoryAffinityFlags flags) { - numamem->type =ACPI_SRAT_MEMORY ; - numamem->length =sizeof (*numamem); - numamem->proximity =cpu_to_le32 (node); - numamem->flags =cpu_to_le32 (flags); - numamem->base_addr =cpu_to_le64 (base); - numamem->range_length =cpu_to_le64 (len); +build_append_int_noprefix (table_data,1 ,1 );/* Type */ +build_append_int_noprefix (table_data,40 ,1 );/* Length */ +build_append_int_noprefix (table_data, node,4 );/* Proximity Domain */ +build_append_int_noprefix (table_data,0 ,2 );/* Reserved */ +build_append_int_noprefix (table_data, base,4 );/* Base Address Low */ +/* Base Address High */ +build_append_int_noprefix (table_data, base >>32 ,4 ); +build_append_int_noprefix (table_data, len,4 );/* Length Low */ +build_append_int_noprefix (table_data, len >>32 ,4 );/* Length High */ +build_append_int_noprefix (table_data,0 ,4 );/* Reserved */ +build_append_int_noprefix (table_data, flags,4 );/* Flags */ +build_append_int_noprefix (table_data,0 ,8 );/* Reserved */ }/*
hw/acpi/nvdimm.c +1 -3
@@ -1336,7 +1336,6 @@ void nvdimm_build_srat(GArray *table_data)GSList *device_list =nvdimm_get_device_list ();for (; device_list; device_list = device_list->next) { -AcpiSratMemoryAffinity *numamem =NULL ;DeviceState *dev = device_list->data;Object *obj =OBJECT (dev);uint64_t addr, size;
@@ -1346,8 +1345,7 @@ void nvdimm_build_srat(GArray *table_data) addr =object_property_get_uint (obj,PC_DIMM_ADDR_PROP , &error_abort); size =object_property_get_uint (obj,PC_DIMM_SIZE_PROP , &error_abort); - numamem =acpi_data_push (table_data,sizeof *numamem); -build_srat_memory (numamem, addr, size, node, +build_srat_memory (table_data, addr, size, node,MEM_AFFINITY_ENABLED |MEM_AFFINITY_NON_VOLATILE ); }g_slist_free (device_list);
hw/arm/virt-acpi-build.c +17 -12
@@ -382,11 +382,13 @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) vms->oem_table_id); } +/* +* ACPI spec, Revision 5.1 +* 5.2.16 System Resource Affinity Table (SRAT) +*/ static void build_srat (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) { -AcpiSratProcessorGiccAffinity *core; -AcpiSratMemoryAffinity *numamem;int i;uint64_t mem_base;MachineClass *mc =MACHINE_GET_CLASS (vms);
@@ -400,19 +402,23 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)build_append_int_noprefix (table_data,0 ,8 );/* Reserved */ for (i =0 ; i < cpu_list->len; ++i) { - core =acpi_data_push (table_data,sizeof (*core)); - core->type =ACPI_SRAT_PROCESSOR_GICC ; - core->length =sizeof (*core); - core->proximity =cpu_to_le32 (cpu_list->cpus[i].props.node_id); - core->acpi_processor_uid =cpu_to_le32 (i); - core->flags =cpu_to_le32 (1 ); +uint32_t nodeid = cpu_list->cpus[i].props.node_id; +/* +* 5.2.16.4 GICC Affinity Structure +*/ +build_append_int_noprefix (table_data,3 ,1 );/* Type */ +build_append_int_noprefix (table_data,18 ,1 );/* Length */ +build_append_int_noprefix (table_data, nodeid,4 );/* Proximity Domain */ +build_append_int_noprefix (table_data, i,4 );/* ACPI Processor UID */ +/* Flags, Table 5-76 */ +build_append_int_noprefix (table_data,1 /* Enabled */ ,4 ); +build_append_int_noprefix (table_data,0 ,4 );/* Clock Domain */ } mem_base = vms->memmap[VIRT_MEM ].base;for (i =0 ; i < ms->numa_state->num_nodes; ++i) {if (ms->numa_state->nodes[i].node_mem >0 ) { - numamem =acpi_data_push (table_data,sizeof (*numamem)); -build_srat_memory (numamem, mem_base, +build_srat_memory (table_data, mem_base, ms->numa_state->nodes[i].node_mem, i,MEM_AFFINITY_ENABLED ); mem_base += ms->numa_state->nodes[i].node_mem;
@@ -424,8 +430,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) }if (ms->device_memory) { - numamem =acpi_data_push (table_data,sizeof *numamem); -build_srat_memory (numamem, ms->device_memory->base, +build_srat_memory (table_data, ms->device_memory->base,memory_region_size (&ms->device_memory->mr), ms->numa_state->num_nodes -1 ,MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED );
hw/i386/acpi-build.c +44 -34
133 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 36/53 acpi: build_dmar_q35: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
While at it switch to build_append_int_noprefix() to build table entries tables.
---
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 68 -------------------------------- hw/i386/acpi-build.c | 77 ++++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 103 deletions(-)
include/hw/acpi/acpi-defs.h +0 -68
@@ -358,74 +358,6 @@ struct AcpiGenericTimerTable { }QEMU_PACKED ;typedef struct AcpiGenericTimerTable AcpiGenericTimerTable ; -/* DMAR - DMA Remapping table r2.2 */ -struct AcpiTableDmar { -ACPI_TABLE_HEADER_DEF - uint8_t host_address_width; /* Maximum DMA physical addressability */ -uint8_t flags; -uint8_t reserved[10 ]; -}QEMU_PACKED ; -typedef struct AcpiTableDmar AcpiTableDmar ; - -/* Masks for Flags field above */ -#define ACPI_DMAR_INTR_REMAP 1 -#define ACPI_DMAR_X2APIC_OPT_OUT (1 << 1) - -/* Values for sub-structure type for DMAR */ -enum { -ACPI_DMAR_TYPE_HARDWARE_UNIT =0 ,/* DRHD */ -ACPI_DMAR_TYPE_RESERVED_MEMORY =1 ,/* RMRR */ -ACPI_DMAR_TYPE_ATSR =2 ,/* ATSR */ -ACPI_DMAR_TYPE_HARDWARE_AFFINITY =3 ,/* RHSR */ -ACPI_DMAR_TYPE_ANDD =4 ,/* ANDD */ -ACPI_DMAR_TYPE_RESERVED =5 /* Reserved for furture use */ -}; - -/* -* Sub-structures for DMAR -*/ - -/* Device scope structure for DRHD. */ -struct AcpiDmarDeviceScope { -uint8_t entry_type; -uint8_t length; -uint16_t reserved; -uint8_t enumeration_id; -uint8_t bus; -struct { -uint8_t device; -uint8_t function; - } path[]; -}QEMU_PACKED ; -typedef struct AcpiDmarDeviceScope AcpiDmarDeviceScope ; - -/* Type 0: Hardware Unit Definition */ -struct AcpiDmarHardwareUnit { -uint16_t type; -uint16_t length; -uint8_t flags; -uint8_t reserved; -uint16_t pci_segment;/* The PCI Segment associated with this unit */ -uint64_t address;/* Base address of remapping hardware register-set */ -AcpiDmarDeviceScope scope[]; -}QEMU_PACKED ; -typedef struct AcpiDmarHardwareUnit AcpiDmarHardwareUnit ; - -/* Type 2: Root Port ATS Capability Reporting Structure */ -struct AcpiDmarRootPortATS { -uint16_t type; -uint16_t length; -uint8_t flags; -uint8_t reserved; -uint16_t pci_segment; -AcpiDmarDeviceScope scope[]; -}QEMU_PACKED ; -typedef struct AcpiDmarRootPortATS AcpiDmarRootPortATS ; - -/* Masks for Flags field above */ -#define ACPI_DMAR_INCLUDE_PCI_ALL 1 -#define ACPI_DMAR_ATSR_ALL_PORTS 1 -/* * Input Output Remapping Table (IORT) * Conforms to "IO Remapping Table System Software on ARM Platforms",
hw/i386/acpi-build.c +42 -35
104 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 37/53 acpi: build_waet: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
---
CC: [email protected]
--- hw/i386/acpi-build.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
hw/i386/acpi-build.c +4 -6
@@ -2101,10 +2101,10 @@ static void build_waet(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { -int waet_start = table_data->len; +AcpiTable table = { .sig ="WAET" , .rev =1 , .oem_id = oem_id, + .oem_table_id = oem_table_id }; -/* WAET header */ -acpi_data_push (table_data,sizeof (AcpiTableHeader)); +acpi_init_table (&table, table_data);/* * Set "ACPI PM timer good" flag. *
@@ -2113,9 +2113,7 @@ build_waet(GArray *table_data, BIOSLinker *linker, const char *oem_id,* Which avoids costly VMExits caused by guest re-reading it unnecessarily. */ build_append_int_noprefix (table_data,1 <<1 /* ACPI PM timer good */ ,4 ); - -build_header (linker, table_data, (void *)(table_data->data + waet_start), -"WAET" , table_data->len - waet_start,1 , oem_id, oem_table_id); +acpi_table_composed (linker, &table); }/*
Signature · 1 line
2.27.0
PATCH 38/53 acpi: build_amd_iommu: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
---
CC: [email protected]
--- hw/i386/acpi-build.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
hw/i386/acpi-build.c +4 -7
@@ -2219,12 +2219,12 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) {int ivhd_table_len =24 ; -int iommu_start = table_data->len;AMDVIState *s =AMD_IOMMU_DEVICE (x86_iommu_get_default ());GArray *ivhd_blob =g_array_new (false, true,1 ); +AcpiTable table = { .sig ="IVRS" , .rev =1 , .oem_id = oem_id, + .oem_table_id = oem_table_id }; -/* IVRS header */ -acpi_data_push (table_data,sizeof (AcpiTableHeader)); +acpi_init_table (&table, table_data);/* IVinfo - IO virtualization information common to all * IOMMU units in a system */
@@ -2309,10 +2309,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id,0x48 ,/* special device */ 8); } - -build_header (linker, table_data, (void *)(table_data->data + iommu_start), -"IVRS" , table_data->len - iommu_start,1 , oem_id, - oem_table_id); +acpi_table_composed (linker, &table); } typedef
Signature · 1 line
2.27.0
PATCH 39/53 acpi: madt: arm/x86: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 9 --------- hw/arm/virt-acpi-build.c | 19 +++++++++++-------- hw/i386/acpi-common.c | 19 +++++++++++-------- 3 files changed, 22 insertions(+), 25 deletions(-)
include/hw/acpi/acpi-defs.h +0 -9
@@ -176,15 +176,6 @@ typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1;#define ACPI_DUAL_PIC 0#define ACPI_MULTIPLE_APIC 1 -/* Master MADT */ - -struct AcpiMultipleApicTable { -ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint32_t local_apic_address; /* Physical address of local APIC */ -uint32_t flags; -}QEMU_PACKED ; -typedef struct AcpiMultipleApicTable AcpiMultipleApicTable ; -/* Values for Type in APIC sub-headers */ #define ACPI_APIC_PROCESSOR 0
hw/arm/virt-acpi-build.c +11 -8
@@ -475,19 +475,26 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) vms->oem_table_id); } -/* MADT */ +/* +* ACPI spec, Revision 5.0 +* 5.2.12 Multiple APIC Description Table (MADT) +*/ static void build_madt (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) {VirtMachineClass *vmc =VIRT_MACHINE_GET_CLASS (vms); -int madt_start = table_data->len;const MemMapEntry *memmap = vms->memmap;const int *irqmap = vms->irqmap;AcpiMadtGenericDistributor *gicd;AcpiMadtGenericMsiFrame *gic_msi;int i; +AcpiTable table = { .sig ="APIC" , .rev =3 , .oem_id = vms->oem_id, + .oem_table_id = vms->oem_table_id }; -acpi_data_push (table_data,sizeof (AcpiMultipleApicTable)); +acpi_init_table (&table, table_data); +/* Local Interrupt Controller Address */ +build_append_int_noprefix (table_data,0 ,4 ); +build_append_int_noprefix (table_data,0 ,4 );/* Flags */ gicd =acpi_data_push (table_data,sizeof *gicd); gicd->type =ACPI_APIC_GENERIC_DISTRIBUTOR ;
@@ -558,11 +565,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) gic_msi->spi_count =cpu_to_le16 (NUM_GICV2M_SPIS ); gic_msi->spi_base =cpu_to_le16 (irqmap[VIRT_GIC_V2M ] +ARM_SPI_BASE ); } - -build_header (linker, table_data, - (void *)(table_data->data + madt_start),"APIC" , - table_data->len - madt_start,3 , vms->oem_id, - vms->oem_table_id); +acpi_table_composed (linker, &table); }/* FADT */
hw/i386/acpi-common.c +11 -8
@@ -71,24 +71,29 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, } } +/* +* ACPI spec, Revision 1.0b +* 5.2.8 Multiple APIC Description Table +*/ void acpi_build_madt (GArray *table_data,BIOSLinker *linker,X86MachineState *x86ms,AcpiDeviceIf *adev,const char *oem_id,const char *oem_table_id) {MachineClass *mc =MACHINE_GET_CLASS (x86ms);const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids (MACHINE (x86ms)); -int madt_start = table_data->len;AcpiDeviceIfClass *adevc =ACPI_DEVICE_IF_GET_CLASS (adev);bool x2apic_mode = false; -AcpiMultipleApicTable *madt;AcpiMadtIoApic *io_apic;AcpiMadtIntsrcovr *intsrcovr;int i; +AcpiTable table = { .sig ="APIC" , .rev =1 , .oem_id = oem_id, + .oem_table_id = oem_table_id }; - madt =acpi_data_push (table_data,sizeof *madt); - madt->local_apic_address =cpu_to_le32 (APIC_DEFAULT_ADDRESS ); - madt->flags =cpu_to_le32 (1 ); +acpi_init_table (&table, table_data); +/* Local APIC Address */ +build_append_int_noprefix (table_data,APIC_DEFAULT_ADDRESS ,4 ); +build_append_int_noprefix (table_data,1 /* PCAT_COMPAT */ ,4 );/* Flags */ for (i =0 ; i < apic_ids->len; i++) { adevc->madt_cpu (adev, i, apic_ids, table_data);
@@ -156,8 +161,6 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *linker, local_nmi->lint =1 ;/* ACPI_LINT1 */ } -build_header (linker, table_data, - (void *)(table_data->data + madt_start),"APIC" , - table_data->len - madt_start,1 , oem_id, oem_table_id); +acpi_table_composed (linker, &table); }
Signature · 1 line
2.27.0
PATCH 40/53 acpi: x86: remove dead code
In reply to Igor Mammedov--- include/hw/acpi/acpi-defs.h | 13 ------------- 1 file changed, 13 deletions(-)
include/hw/acpi/acpi-defs.h +0 -13
@@ -163,19 +163,6 @@ struct AcpiFacsDescriptorRev1 { }QEMU_PACKED ;typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1 ; -/* -* Differentiated System Description Table (DSDT) -*/ - -/* -* MADT values and structures -*/ - -/* Values for MADT PCATCompat */ - -#define ACPI_DUAL_PIC 0 -#define ACPI_MULTIPLE_APIC 1 -/* Values for Type in APIC sub-headers */ #define ACPI_APIC_PROCESSOR 0
Signature · 1 line
2.27.0
PATCH 41/53 acpi: x86: set enabled when composing _MAT entries
In reply to Igor MammedovInstead of composing disabled _MAT entry and then later on patching it to enabled for hotpluggbale CPUs in DSDT, set it to enabled at the time _MAT entry is built.
It will allow to drop usage of packed structures in following patches when build_madt() is switched to use build_append_int_noprefix() API.
---
CC: [email protected]
--- include/hw/acpi/acpi_dev_interface.h | 3 ++- include/hw/i386/pc.h | 7 ++++--- hw/acpi/acpi-x86-stub.c | 3 ++- hw/acpi/cpu.c | 17 ++--------------- hw/i386/acpi-common.c | 18 ++++++------------ 5 files changed, 16 insertions(+), 32 deletions(-)
include/hw/acpi/acpi_dev_interface.h +2 -1
@@ -53,6 +53,7 @@ struct AcpiDeviceIfClass {void (*ospm_status)(AcpiDeviceIf *adev,ACPIOSTInfoList ***list);void (*send_event)(AcpiDeviceIf *adev,AcpiEventStatusBits ev);void (*madt_cpu)(AcpiDeviceIf *adev,int uid, - const CPUArchIdList *apic_ids, GArray *entry); +const CPUArchIdList *apic_ids,GArray *entry, + bool force_enabled); };#endif
include/hw/i386/pc.h +4 -3
@@ -192,11 +192,12 @@ void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memory);bool pc_system_ovmf_table_find (const char *entry,uint8_t **data,int *data_len); - -/* acpi-build.c */ +/* hw/i386/acpi-common.c */ void pc_madt_cpu_entry (AcpiDeviceIf *adev,int uid, -const CPUArchIdList *apic_ids,GArray *entry); +const CPUArchIdList *apic_ids,GArray *entry, +bool force_enabled); +/* acpi-build.c */ extern GlobalProperty pc_compat_6_0[];extern const size_t pc_compat_6_0_len;
hw/acpi/acpi-x86-stub.c +2 -1
@@ -2,6 +2,7 @@#include "hw/i386/pc.h" void pc_madt_cpu_entry (AcpiDeviceIf *adev,int uid, -const CPUArchIdList *apic_ids,GArray *entry) +const CPUArchIdList *apic_ids,GArray *entry, +bool force_enabled) { }
hw/acpi/cpu.c +2 -15
@@ -669,21 +669,8 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,/* build _MAT object */ assert (adevc && adevc->madt_cpu); - adevc->madt_cpu (adev, i, arch_ids, madt_buf); -switch (madt_buf->data[0 ]) { -case ACPI_APIC_PROCESSOR : { -AcpiMadtProcessorApic *apic = (void *)madt_buf->data; - apic->flags =cpu_to_le32 (1 ); -break ; - } -case ACPI_APIC_LOCAL_X2APIC : { -AcpiMadtProcessorX2Apic *apic = (void *)madt_buf->data; - apic->flags =cpu_to_le32 (1 ); -break ; - } -default : -assert (0 ); - } + adevc->madt_cpu (adev, i, arch_ids, madt_buf, + true);/* set enabled flag */ aml_append (dev,aml_name_decl ("_MAT" ,aml_buffer (madt_buf->len, (uint8_t *)madt_buf->data)));g_array_free (madt_buf, true);
hw/i386/acpi-common.c +6 -12
@@ -34,9 +34,11 @@#include "acpi-common.h" void pc_madt_cpu_entry (AcpiDeviceIf *adev,int uid, -const CPUArchIdList *apic_ids,GArray *entry) +const CPUArchIdList *apic_ids,GArray *entry, +bool force_enabled) {uint32_t apic_id = apic_ids->cpus[uid].arch_id; +uint32_t flags = apic_ids->cpus[uid].cpu !=NULL || force_enabled ?1 :0 ;/* ACPI spec says that LAPIC entry for non present * CPU may be omitted from MADT or it must be marked
@@ -51,11 +53,7 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, apic->length =sizeof (*apic); apic->processor_id = uid; apic->local_apic_id = apic_id; -if (apic_ids->cpus[uid].cpu !=NULL ) { - apic->flags =cpu_to_le32 (1 ); - }else { - apic->flags =cpu_to_le32 (0 ); - } + apic->flags =cpu_to_le32 (flags); }else {AcpiMadtProcessorX2Apic *apic =acpi_data_push (entry,sizeof *apic);
@@ -63,11 +61,7 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, apic->length =sizeof (*apic); apic->uid =cpu_to_le32 (uid); apic->x2apic_id =cpu_to_le32 (apic_id); -if (apic_ids->cpus[uid].cpu !=NULL ) { - apic->flags =cpu_to_le32 (1 ); - }else { - apic->flags =cpu_to_le32 (0 ); - } + apic->flags =cpu_to_le32 (flags); } }
@@ -96,7 +90,7 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *linker,build_append_int_noprefix (table_data,1 /* PCAT_COMPAT */ ,4 );/* Flags */ for (i =0 ; i < apic_ids->len; i++) { - adevc->madt_cpu (adev, i, apic_ids, table_data); + adevc->madt_cpu (adev, i, apic_ids, table_data, false);if (apic_ids->cpus[i].arch_id >254 ) { x2apic_mode = true; }
Signature · 1 line
2.27.0
PATCH 42/53 acpi: x86: madt: use build_append_int_noprefix() API to compose MADT table
In reply to Igor MammedovDrop usage of packed structures and explicit endian conversions when building MADT table for arm/x86 and use endian agnostic build_append_int_noprefix() API to build it.
---
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 64 ------------------ hw/i386/acpi-common.c | 127 ++++++++++++++++++------------------ 2 files changed, 65 insertions(+), 126 deletions(-)
include/hw/acpi/acpi-defs.h +0 -64
@@ -165,17 +165,6 @@ typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1;/* Values for Type in APIC sub-headers */ -#define ACPI_APIC_PROCESSOR 0 -#define ACPI_APIC_IO 1 -#define ACPI_APIC_XRUPT_OVERRIDE 2 -#define ACPI_APIC_NMI 3 -#define ACPI_APIC_LOCAL_NMI 4 -#define ACPI_APIC_ADDRESS_OVERRIDE 5 -#define ACPI_APIC_IO_SAPIC 6 -#define ACPI_APIC_LOCAL_SAPIC 7 -#define ACPI_APIC_XRUPT_SOURCE 8 -#define ACPI_APIC_LOCAL_X2APIC 9 -#define ACPI_APIC_LOCAL_X2APIC_NMI 10#define ACPI_APIC_GENERIC_CPU_INTERFACE 11#define ACPI_APIC_GENERIC_DISTRIBUTOR 12#define ACPI_APIC_GENERIC_MSI_FRAME 13
@@ -192,59 +181,6 @@ typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1;/* Sub-structures for MADT */ -struct AcpiMadtProcessorApic { -ACPI_SUB_HEADER_DEF - uint8_t processor_id; /* ACPI processor id */ -uint8_t local_apic_id;/* Processor's local APIC id */ -uint32_t flags; -}QEMU_PACKED ; -typedef struct AcpiMadtProcessorApic AcpiMadtProcessorApic ; - -struct AcpiMadtIoApic { -ACPI_SUB_HEADER_DEF - uint8_t io_apic_id; /* I/O APIC ID */ -uint8_t reserved;/* Reserved - must be zero */ -uint32_t address;/* APIC physical address */ -uint32_t interrupt;/* Global system interrupt where INTI -* lines start */ -}QEMU_PACKED ; -typedef struct AcpiMadtIoApic AcpiMadtIoApic ; - -struct AcpiMadtIntsrcovr { -ACPI_SUB_HEADER_DEF - uint8_t bus; -uint8_t source; -uint32_t gsi; -uint16_t flags; -}QEMU_PACKED ; -typedef struct AcpiMadtIntsrcovr AcpiMadtIntsrcovr ; - -struct AcpiMadtLocalNmi { -ACPI_SUB_HEADER_DEF - uint8_t processor_id; /* ACPI processor id */ -uint16_t flags;/* MPS INTI flags */ -uint8_t lint;/* Local APIC LINT# */ -}QEMU_PACKED ; -typedef struct AcpiMadtLocalNmi AcpiMadtLocalNmi ; - -struct AcpiMadtProcessorX2Apic { -ACPI_SUB_HEADER_DEF - uint16_t reserved; -uint32_t x2apic_id;/* Processor's local x2APIC ID */ -uint32_t flags; -uint32_t uid;/* Processor object _UID */ -}QEMU_PACKED ; -typedef struct AcpiMadtProcessorX2Apic AcpiMadtProcessorX2Apic ; - -struct AcpiMadtLocalX2ApicNmi { -ACPI_SUB_HEADER_DEF - uint16_t flags; /* MPS INTI flags */ -uint32_t uid;/* Processor object _UID */ -uint8_t lint;/* Local APIC LINT# */ -uint8_t reserved[3 ];/* Local APIC LINT# */ -}QEMU_PACKED ; -typedef struct AcpiMadtLocalX2ApicNmi AcpiMadtLocalX2ApicNmi ; -struct AcpiMadtGenericCpuInterface {ACPI_SUB_HEADER_DEF uint16_t reserved;
hw/i386/acpi-common.c +65 -62
172 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 43/53 acpi: arm/virt: madt: use build_append_int_noprefix() API to compose MADT table
In reply to Igor MammedovDrop usage of packed structures and explicit endian conversions when building MADT table for arm/x86 and use endian agnostic build_append_int_noprefix() API to build it.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 84 -------------------- hw/arm/virt-acpi-build.c | 149 +++++++++++++++++++++--------------- 2 files changed, 89 insertions(+), 144 deletions(-)
include/hw/acpi/acpi-defs.h +0 -84
@@ -163,90 +163,6 @@ struct AcpiFacsDescriptorRev1 { }QEMU_PACKED ;typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1 ; -/* Values for Type in APIC sub-headers */ - -#define ACPI_APIC_GENERIC_CPU_INTERFACE 11 -#define ACPI_APIC_GENERIC_DISTRIBUTOR 12 -#define ACPI_APIC_GENERIC_MSI_FRAME 13 -#define ACPI_APIC_GENERIC_REDISTRIBUTOR 14 -#define ACPI_APIC_GENERIC_TRANSLATOR 15 -#define ACPI_APIC_RESERVED 16/* 16 and greater are reserved */ - -/* -* MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE) -*/ -#define ACPI_SUB_HEADER_DEF /* Common ACPI sub-structure header */ \ - uint8_t type; \ - uint8_t length; - -/* Sub-structures for MADT */ - -struct AcpiMadtGenericCpuInterface { -ACPI_SUB_HEADER_DEF - uint16_t reserved; -uint32_t cpu_interface_number; -uint32_t uid; -uint32_t flags; -uint32_t parking_version; -uint32_t performance_interrupt; -uint64_t parked_address; -uint64_t base_address; -uint64_t gicv_base_address; -uint64_t gich_base_address; -uint32_t vgic_interrupt; -uint64_t gicr_base_address; -uint64_t arm_mpidr; -}QEMU_PACKED ; - -typedef struct AcpiMadtGenericCpuInterface AcpiMadtGenericCpuInterface ; - -/* GICC CPU Interface Flags */ -#define ACPI_MADT_GICC_ENABLED 1 - -struct AcpiMadtGenericDistributor { -ACPI_SUB_HEADER_DEF - uint16_t reserved; -uint32_t gic_id; -uint64_t base_address; -uint32_t global_irq_base; -/* ACPI 5.1 Errata 1228 Present GIC version in MADT table */ -uint8_t version; -uint8_t reserved2[3 ]; -}QEMU_PACKED ; - -typedef struct AcpiMadtGenericDistributor AcpiMadtGenericDistributor ; - -struct AcpiMadtGenericMsiFrame { -ACPI_SUB_HEADER_DEF - uint16_t reserved; -uint32_t gic_msi_frame_id; -uint64_t base_address; -uint32_t flags; -uint16_t spi_count; -uint16_t spi_base; -}QEMU_PACKED ; - -typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame ; - -struct AcpiMadtGenericRedistributor { -ACPI_SUB_HEADER_DEF - uint16_t reserved; -uint64_t base_address; -uint32_t range_length; -}QEMU_PACKED ; - -typedef struct AcpiMadtGenericRedistributor AcpiMadtGenericRedistributor ; - -struct AcpiMadtGenericTranslator { -ACPI_SUB_HEADER_DEF - uint16_t reserved; -uint32_t translation_id; -uint64_t base_address; -uint32_t reserved2; -}QEMU_PACKED ; - -typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator ; -/* * Generic Timer Description Table (GTDT) */
hw/arm/virt-acpi-build.c +89 -60
183 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 44/53 acpi: build_dsdt_microvm: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
---
CC: [email protected]
--- hw/i386/acpi-microvm.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
hw/i386/acpi-microvm.c +6 -7
@@ -113,16 +113,16 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linker,Aml *dsdt, *sb_scope, *scope, *pkg;bool ambiguous;Object *isabus; +AcpiTable table = { .sig ="DSDT" , .rev =2 , .oem_id = x86ms->oem_id, + .oem_table_id = x86ms->oem_table_id }; isabus =object_resolve_path_type ("" ,TYPE_ISA_BUS , &ambiguous);assert (isabus);assert (!ambiguous); +acpi_init_table (&table, table_data); dsdt =init_aml_allocator (); -/* Reserve space for header */ -acpi_data_push (dsdt->buf,sizeof (AcpiTableHeader)); - sb_scope =aml_scope ("_SB" );fw_cfg_add_acpi_dsdt (sb_scope, x86ms->fw_cfg);isa_build_aml (ISA_BUS (isabus), sb_scope);
@@ -144,11 +144,10 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linker,aml_append (scope,aml_name_decl ("_S5" , pkg));aml_append (dsdt, scope); -/* copy AML table into ACPI tables blob and patch header there */ +/* copy AML bytecode into ACPI tables blob */ g_array_append_vals (table_data, dsdt->buf->data, dsdt->buf->len); -build_header (linker, table_data, - (void *)(table_data->data + table_data->len - dsdt->buf->len), -"DSDT" , dsdt->buf->len,2 , x86ms->oem_id, x86ms->oem_table_id); + +acpi_table_composed (linker, &table);free_aml_allocator (); }
Signature · 1 line
2.27.0
PATCH 45/53 acpi: arm: virt: build_dsdt: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- hw/arm/virt-acpi-build.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
hw/arm/virt-acpi-build.c +6 -7
@@ -636,10 +636,11 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)MachineState *ms =MACHINE (vms);const MemMapEntry *memmap = vms->memmap;const int *irqmap = vms->irqmap; +AcpiTable table = { .sig ="DSDT" , .rev =2 , .oem_id = vms->oem_id, + .oem_table_id = vms->oem_table_id }; +acpi_init_table (&table, table_data); dsdt =init_aml_allocator (); -/* Reserve space for header */ -acpi_data_push (dsdt->buf,sizeof (AcpiTableHeader));/* When booting the VM with UEFI, UEFI takes ownership of the RTC hardware. * While UEFI can use libfdt to disable the RTC device node in the DTB that
@@ -686,12 +687,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)aml_append (dsdt, scope); -/* copy AML table into ACPI tables blob and patch header there */ +/* copy AML table into ACPI tables blob */ g_array_append_vals (table_data, dsdt->buf->data, dsdt->buf->len); -build_header (linker, table_data, - (void *)(table_data->data + table_data->len - dsdt->buf->len), -"DSDT" , dsdt->buf->len,2 , vms->oem_id, - vms->oem_table_id); + +acpi_table_composed (linker, &table);free_aml_allocator (); }
Signature · 1 line
2.27.0
PATCH 46/53 acpi: arm: virt: build_iort: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 14 ------------ hw/arm/virt-acpi-build.c | 43 +++++++++++++++---------------------- 2 files changed, 17 insertions(+), 40 deletions(-)
include/hw/acpi/acpi-defs.h +0 -14
@@ -188,20 +188,6 @@ struct AcpiGenericTimerTable { }QEMU_PACKED ;typedef struct AcpiGenericTimerTable AcpiGenericTimerTable ; -/* -* Input Output Remapping Table (IORT) -* Conforms to "IO Remapping Table System Software on ARM Platforms", -* Document number: ARM DEN 0049B, October 2015 -*/ - -struct AcpiIortTable { -ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint32_t node_count; -uint32_t node_offset; -uint32_t reserved; -}QEMU_PACKED ; -typedef struct AcpiIortTable AcpiIortTable ; -/* * IORT node types */
hw/arm/virt-acpi-build.c +17 -26
83 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 47/53 acpi: arm/virt: convert build_iort() to endian agnostic build_append_FOO() API
In reply to Igor Mammedov---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 71 ------------------ hw/arm/virt-acpi-build.c | 143 +++++++++++++++++++----------------- 2 files changed, 77 insertions(+), 137 deletions(-)
include/hw/acpi/acpi-defs.h +0 -71
@@ -188,75 +188,4 @@ struct AcpiGenericTimerTable { } QEMU_PACKED;typedef struct AcpiGenericTimerTable AcpiGenericTimerTable ; -/* -* IORT node types -*/ - -#define ACPI_IORT_NODE_HEADER_DEF /* Node format common fields */ \ - uint8_t type; \ - uint16_t length; \ - uint8_t revision; \ - uint32_t reserved; \ - uint32_t mapping_count; \ - uint32_t mapping_offset; - -/* Values for node Type above */ -enum { -ACPI_IORT_NODE_ITS_GROUP =0x00 , -ACPI_IORT_NODE_NAMED_COMPONENT =0x01 , -ACPI_IORT_NODE_PCI_ROOT_COMPLEX =0x02 , -ACPI_IORT_NODE_SMMU =0x03 , -ACPI_IORT_NODE_SMMU_V3 =0x04 -}; - -struct AcpiIortIdMapping { -uint32_t input_base; -uint32_t id_count; -uint32_t output_base; -uint32_t output_reference; -uint32_t flags; -}QEMU_PACKED ; -typedef struct AcpiIortIdMapping AcpiIortIdMapping ; - -struct AcpiIortMemoryAccess { -uint32_t cache_coherency; -uint8_t hints; -uint16_t reserved; -uint8_t memory_flags; -}QEMU_PACKED ; -typedef struct AcpiIortMemoryAccess AcpiIortMemoryAccess ; - -struct AcpiIortItsGroup { -ACPI_IORT_NODE_HEADER_DEF - uint32_t its_count; -uint32_t identifiers[]; -}QEMU_PACKED ; -typedef struct AcpiIortItsGroup AcpiIortItsGroup ; - -#define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE 1 - -struct AcpiIortSmmu3 { -ACPI_IORT_NODE_HEADER_DEF - uint64_t base_address; -uint32_t flags; -uint32_t reserved2; -uint64_t vatos_address; -uint32_t model; -uint32_t event_gsiv; -uint32_t pri_gsiv; -uint32_t gerr_gsiv; -uint32_t sync_gsiv; -AcpiIortIdMapping id_mapping_array[]; -}QEMU_PACKED ; -typedef struct AcpiIortSmmu3 AcpiIortSmmu3 ; - -struct AcpiIortRC { -ACPI_IORT_NODE_HEADER_DEF - AcpiIortMemoryAccess memory_properties; -uint32_t ats_attribute; -uint32_t pci_segment_number; -AcpiIortIdMapping id_mapping_array[]; -}QEMU_PACKED ; -typedef struct AcpiIortRC AcpiIortRC ; -#endif
hw/arm/virt-acpi-build.c +77 -66
175 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 48/53 acpi: arm/virt: build_spcr: fix invalid cast
In reply to Igor Mammedovimplicit cast to structure uint8_t member didn't raise error when assigning value from incorrect enum, but when using build_append_gas() (next patch) it will error out with (clang):
implicit conversion from enumeration type 'AmlRegionSpace' to different enumeration type 'AmlAddressSpace'
fix cast error by using correct AML_AS_SYSTEM_MEMORY enum
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- hw/arm/virt-acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +1 -1
@@ -361,7 +361,7 @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) spcr->interface_type =0x3 ;/* ARM PL011 UART */ - spcr->base_address.space_id =AML_SYSTEM_MEMORY ; + spcr->base_address.space_id =AML_AS_SYSTEM_MEMORY ; spcr->base_address.bit_width =8 ; spcr->base_address.bit_offset =0 ; spcr->base_address.access_width =1 ;
Signature · 1 line
2.27.0
PATCH 49/53 acpi: arm/virt: build_spcr: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
while at it, replace packed structure with endian agnostic build_append_FOO() API.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 32 ----------------- hw/arm/virt-acpi-build.c | 68 ++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 59 deletions(-)
include/hw/acpi/acpi-defs.h +0 -32
@@ -117,38 +117,6 @@ typedef struct AcpiFadtData {#define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0)#define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1) -/* -* Serial Port Console Redirection Table (SPCR), Rev. 1.02 -* -* For .interface_type see Debug Port Table 2 (DBG2) serial port -* subtypes in Table 3, Rev. May 22, 2012 -*/ -struct AcpiSerialPortConsoleRedirection { -ACPI_TABLE_HEADER_DEF - uint8_t interface_type; -uint8_t reserved1[3 ]; -struct AcpiGenericAddress base_address; -uint8_t interrupt_types; -uint8_t irq; -uint32_t gsi; -uint8_t baud; -uint8_t parity; -uint8_t stopbits; -uint8_t flowctrl; -uint8_t term_type; -uint8_t reserved2; -uint16_t pci_device_id; -uint16_t pci_vendor_id; -uint8_t pci_bus; -uint8_t pci_slot; -uint8_t pci_func; -uint32_t pci_flags; -uint8_t pci_seg; -uint32_t reserved3; -}QEMU_PACKED ; -typedef struct AcpiSerialPortConsoleRedirection -AcpiSerialPortConsoleRedirection ; -/* * ACPI 1.0 Firmware ACPI Control Structure (FACS) */
hw/arm/virt-acpi-build.c +41 -27
80 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 50/53 acpi: arm/virt: build_gtdt: use acpi_init_table()/acpi_table_composed() instead of build_header()
In reply to Igor Mammedovit replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation,
which hides offsets magic from API user.
while at it, replace packed structure with endian agnostic build_append_FOO() API.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 25 ------------- hw/arm/virt-acpi-build.c | 75 ++++++++++++++++++++++++------------- 2 files changed, 48 insertions(+), 52 deletions(-)
include/hw/acpi/acpi-defs.h +0 -25
@@ -131,29 +131,4 @@ struct AcpiFacsDescriptorRev1 { } QEMU_PACKED;typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1 ; -/* -* Generic Timer Description Table (GTDT) -*/ -#define ACPI_GTDT_INTERRUPT_MODE_LEVEL (0 << 0) -#define ACPI_GTDT_INTERRUPT_MODE_EDGE (1 << 0) -#define ACPI_GTDT_CAP_ALWAYS_ON (1 << 2) - -struct AcpiGenericTimerTable { -ACPI_TABLE_HEADER_DEF - uint64_t counter_block_addresss; -uint32_t reserved; -uint32_t secure_el1_interrupt; -uint32_t secure_el1_flags; -uint32_t non_secure_el1_interrupt; -uint32_t non_secure_el1_flags; -uint32_t virtual_timer_interrupt; -uint32_t virtual_timer_flags; -uint32_t non_secure_el2_interrupt; -uint32_t non_secure_el2_flags; -uint64_t counter_read_block_address; -uint32_t platform_timer_count; -uint32_t platform_timer_offset; -}QEMU_PACKED ; -typedef struct AcpiGenericTimerTable AcpiGenericTimerTable ; -#endif
hw/arm/virt-acpi-build.c +48 -27
88 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 51/53 acpi: build_facs: use build_append_int_noprefix() API to compose table
In reply to Igor MammedovDrop usage of packed structures and explicit endian conversions when building table and use endian agnostic build_append_int_noprefix() API to build it.
---
CC: [email protected]
--- include/hw/acpi/acpi-defs.h | 14 -------------- include/hw/acpi/aml-build.h | 1 + hw/acpi/aml-build.c | 2 +- hw/i386/acpi-build.c | 18 ++++++++++++++---- 4 files changed, 16 insertions(+), 19 deletions(-)
include/hw/acpi/acpi-defs.h +0 -14
@@ -117,18 +117,4 @@ typedef struct AcpiFadtData {#define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0)#define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1) -/* -* ACPI 1.0 Firmware ACPI Control Structure (FACS) -*/ -struct AcpiFacsDescriptorRev1 { -uint32_t signature;/* ACPI Signature */ -uint32_t length;/* Length of structure, in bytes */ -uint32_t hardware_signature;/* Hardware configuration signature */ -uint32_t firmware_waking_vector;/* ACPI OS waking vector */ -uint32_t global_lock;/* Global Lock */ -uint32_t flags; -uint8_t resverved3 [40 ];/* Reserved - must be zero */ -}QEMU_PACKED ; -typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1 ; -#endif
include/hw/acpi/aml-build.h +1 -0
@@ -413,6 +413,7 @@ Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target);Aml *aml_object_type (Aml *object);void build_append_int_noprefix (GArray *table,uint64_t value,int size); +void build_append_byte (GArray *array,uint8_t val); typedef struct AcpiTable { const char *sig;
hw/acpi/aml-build.c +1 -1
@@ -47,7 +47,7 @@ static void build_prepend_byte(GArray *array, uint8_t val)g_array_prepend_val (array, val); } -static void build_append_byte (GArray *array,uint8_t val) +void build_append_byte (GArray *array,uint8_t val) {g_array_append_val (array, val); }
hw/i386/acpi-build.c +14 -4
@@ -346,13 +346,23 @@ static void acpi_align_size(GArray *blob, unsigned align)g_array_set_size (blob,ROUND_UP (acpi_data_len (blob), align)); } -/* FACS */ +/* +* ACPI spec 1.0b, +* 5.2.6 Firmware ACPI Control Structure +*/ static void build_facs (GArray *table_data) { -AcpiFacsDescriptorRev1 *facs =acpi_data_push (table_data,sizeof *facs); -memcpy (&facs->signature,"FACS" ,4 ); - facs->length =cpu_to_le32 (sizeof (*facs)); +const char *sig ="FACS" ; +const uint8_t reserved[40 ] = {}; + +g_array_append_vals (table_data, sig,4 );/* Signature */ +build_append_int_noprefix (table_data,64 ,4 );/* Length */ +build_append_int_noprefix (table_data,0 ,4 );/* Hardware Signature */ +build_append_int_noprefix (table_data,0 ,4 );/* Firmware Waking Vector */ +build_append_int_noprefix (table_data,0 ,4 );/* Global Lock */ +build_append_int_noprefix (table_data,0 ,4 );/* Flags */ +g_array_append_vals (table_data, reserved,40 );/* Reserved */ }static void build_append_pcihp_notify_entry (Aml *method,int slot)
Signature · 1 line
2.27.0
PATCH 52/53 acpi: remove no longer used build_header()
In reply to Igor Mammedov--- include/hw/acpi/acpi-defs.h | 25 ------------------------- include/hw/acpi/aml-build.h | 4 ---- hw/acpi/aml-build.c | 23 ----------------------- 3 files changed, 52 deletions(-)
include/hw/acpi/acpi-defs.h +0 -25
@@ -48,31 +48,6 @@ typedef struct AcpiRsdpData {unsigned *xsdt_tbl_offset; } AcpiRsdpData; -/* Table structure from Linux kernel (the ACPI tables are under the -BSD license) */ - - -#define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \ - uint32_t signature;/* ACPI signature (4 ASCII characters) */ \ -uint32_t length;/* Length of table, in bytes, including header */ \ -uint8_t revision;/* ACPI Specification minor version # */ \ -uint8_t checksum;/* To make sum of entire table == 0 */ \ - uint8_t oem_id[6] \ -QEMU_NONSTRING ;/* OEM identification */ \ - uint8_t oem_table_id[8] \ -QEMU_NONSTRING ;/* OEM table identification */ \ -uint32_t oem_revision;/* OEM revision number */ \ - uint8_t asl_compiler_id[4] \ -QEMU_NONSTRING ;/* ASL compiler vendor ID */ \ -uint32_t asl_compiler_revision;/* ASL compiler revision number */ - - -/* ACPI common table header */ -struct AcpiTableHeader { - ACPI_TABLE_HEADER_DEF -}QEMU_PACKED ; -typedef struct AcpiTableHeader AcpiTableHeader ; -struct AcpiGenericAddress {uint8_t space_id;/* Address space where struct or register exists */ uint8_t bit_width;/* Size in bits of given register */
include/hw/acpi/aml-build.h +0 -4
@@ -428,10 +428,6 @@ typedef struct AcpiTable {void acpi_init_table (AcpiTable *desc,GArray *array);void acpi_table_composed (BIOSLinker *linker,AcpiTable *table); -void -build_header (BIOSLinker *linker,GArray *table_data, -AcpiTableHeader *h,const char *sig,int len,uint8_t rev, -const char *oem_id,const char *oem_table_id);void *acpi_data_push (GArray *table_data,unsigned size);unsigned acpi_data_len (GArray *table);void acpi_add_table (GArray *table_offsets,GArray *table_data);
hw/acpi/aml-build.c +0 -23
@@ -1745,29 +1745,6 @@ void acpi_table_composed(BIOSLinker *linker, AcpiTable *desc) desc->table_offset, table_len, desc->table_offset + checksum_offset); } -void -build_header (BIOSLinker *linker,GArray *table_data, -AcpiTableHeader *h,const char *sig,int len,uint8_t rev, -const char *oem_id,const char *oem_table_id) -{ -unsigned tbl_offset = (char *)h - table_data->data; -unsigned checksum_offset = (char *)&h->checksum - table_data->data; -memcpy (&h->signature, sig,4 ); - h->length =cpu_to_le32 (len); - h->revision = rev; - -strpadcpy ((char *)h->oem_id,sizeof h->oem_id, oem_id,' ' ); -strpadcpy ((char *)h->oem_table_id,sizeof h->oem_table_id, - oem_table_id,' ' ); - - h->oem_revision =cpu_to_le32 (1 ); -memcpy (h->asl_compiler_id,ACPI_BUILD_APPNAME8 ,4 ); - h->asl_compiler_revision =cpu_to_le32 (1 ); -/* Checksum to be filled in by Guest linker */ -bios_linker_loader_add_checksum (linker,ACPI_BUILD_TABLE_FILE , - tbl_offset, len, checksum_offset); -} -void *acpi_data_push (GArray *table_data,unsigned size) {unsigned off = table_data->len;
Signature · 1 line
2.27.0
PATCH 53/53 acpi: AcpiGenericAddress no longer used to map/access fields of MMIO, drop packed attribute
In reply to Igor Mammedov--- include/hw/acpi/acpi-defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/acpi/acpi-defs.h +1 -1
@@ -55,7 +55,7 @@ struct AcpiGenericAddress {uint8_t access_width;/* ACPI 3.0: Minimum Access size (ACPI 3.0), ACPI 2.0: Reserved, Table 5-1 */ uint64_t address;/* 64-bit address of struct or register */ -}QEMU_PACKED ; +}; typedef struct AcpiFadtData { struct AcpiGenericAddress pm1a_cnt; /* PM1a_CNT_BLK */
Signature · 1 line
2.27.0
Quoted 4 lines · Igor Mammedov
Highlights:
* drop pointer arithmetic in ACPI tables code
* use endian agnostic API
* simplifies review of tables. /in most cases just line by line comparision with spec/
A hue amount of work, thank you!
To make it easier to merge, how about splitting it up a bit? E.g. I think first 10-11 patches make sense on their own, right?
Quoted 158 lines
Series replaces
build_header()with acpi_init_table()/acpi_table_composed() API that hides pointer/offset arithmetic from user, to prevent errors caused by it [1].
While doing above, it was necessary to split table header from packed structure that was describing the table, which is counter-productive since it still leaves packed structure drawbacks. So that sort of forced me to rewrite tables that were composed with help of packed structures to preferredbuild_append_int_noprefix()API. In cases where switch tobuild_append_int_noprefix()was small, it was combined with acpi_init_table()/acpi_table_composed() patch. Conversion reduced code size quite a bit despite me adding doc comments for every table row.Series also includes optional qtest patches that add missing acpi tests for tables that I'm touching to verify conversion changes. That includes an alternative build time based impl. of
qtest_has_accel()API. So if we start bike-shedding thisqtest_has_accel()we can safely drop all tests included, till the time discussion settles and some form of aqtest_has_accel()is merged, at which point I'd respin depended tests.1) commits
bb9feea43179x86: acpi: use offset instead of pointer when usingbuild_header()4d027afeb3a9Virt: ACPI: fix qemu assert due to re-assigned table data addressLink to repo:
https://gitlab.com/imammedo/qemu/-/commits/acpi_build_header_refactoringIgor Mammedov (53):
tests: acpi: dump table with failed checksum
tests: qtest: addqtest_has_accel()to check if tested binary supports
accelerator
tests: acpi: whitelist expected tables for acpi/q35/numamem testcase
tests: acpi: q35: test for x2APIC entries in SRAT
tests: acpi: update expected tables blobs
tests: acpi: whitelist new expected table
tests/data/acpi/q35/DMAR.dmar
tests: acpi: add testcase forintel_iommu(DMAR table)
tests: acpi: add expected blob for DMAR table
tests: acpi: whitelist expected blobs for new acpi/q35/ivrs testcase
tests: acpi: add testcase for amd-iommu (IVRS table)
tests: acpi: update expected blobs
tests: acpi: arm/virt: drop redundanttest_acpi_one()in
test_acpi_virt_tcg()
tests: acpi: whitelist expected tables for acpi/virt/iort testcase
tests: acpi: arm/virt: use kvm to test IORT table
tests: acpi: add expected IORT table blob
tests: arm-cpu-features: useqtest_has_kvm()API
tests: migration-test: useqtest_has_accel()API
tests: bios-tables-test: useqtest_has_accel()API to register TCG
only tests
acpi: add helper routines to initialize ACPI tables
acpi:build_rsdt: use acpi_init_table()/acpi_table_composed() instead
ofbuild_header()
acpi:build_xsdt: use acpi_init_table()/acpi_table_composed() instead
ofbuild_header()
acpi:build_slit: use acpi_init_table()/acpi_table_composed() instead
ofbuild_header()
acpi:build_fadt: use acpi_init_table()/acpi_table_composed() instead
ofbuild_header()
acpi:build_tpm2: use acpi_init_table()/acpi_table_composed() instead
ofbuild_header()
acpi:acpi_build_hest: use acpi_init_table()/acpi_table_composed()
instead ofbuild_header()
acpi:build_mcfg: use acpi_init_table()/acpi_table_composed() instead
ofbuild_header()
acpi:build_hmat: use acpi_init_table()/acpi_table_composed() instead
ofbuild_header()
acpi:nvdimm_build_nfit: use acpi_init_table()/acpi_table_composed()
instead ofbuild_header()
acpi:nvdimm_build_ssdt: use acpi_init_table()/acpi_table_composed()
instead ofbuild_header()
acpi:vmgenid_build_acpi: use acpi_init_table()/acpi_table_composed()
instead ofbuild_header()
acpi: x86:build_dsdt: use acpi_init_table()/acpi_table_composed()
instead ofbuild_header()
acpi:build_hpet: use acpi_init_table()/acpi_table_composed() instead
ofbuild_header()
acpi:build_tpm_tcpa: use acpi_init_table()/acpi_table_composed()
instead ofbuild_header()
acpi: arm/x86:build_srat: use acpi_init_table()/acpi_table_composed()
instead ofbuild_header()
acpi: usebuild_append_int_noprefix()API to compose SRAT table
acpi:build_dmar_q35: use acpi_init_table()/acpi_table_composed()
instead ofbuild_header()
acpi:build_waet: use acpi_init_table()/acpi_table_composed() instead
ofbuild_header()
acpi:build_amd_iommu: use acpi_init_table()/acpi_table_composed()
instead ofbuild_header()
acpi: madt: arm/x86: use acpi_init_table()/acpi_table_composed()
instead ofbuild_header()
acpi: x86: remove dead code
acpi: x86: set enabled when composing_MATentries
acpi: x86: madt: usebuild_append_int_noprefix()API to compose MADT
table
acpi: arm/virt: madt: usebuild_append_int_noprefix()API to compose
MADT table
acpi:build_dsdt_microvm: use acpi_init_table()/acpi_table_composed()
instead ofbuild_header()
acpi: arm: virt:build_dsdt: use
acpi_init_table()/acpi_table_composed() instead ofbuild_header()
acpi: arm: virt:build_iort: use
acpi_init_table()/acpi_table_composed() instead ofbuild_header()
acpi: arm/virt: convertbuild_iort()to endian agnostic
build_append_FOO()API
acpi: arm/virt:build_spcr: fix invalid cast
acpi: arm/virt:build_spcr: use
acpi_init_table()/acpi_table_composed() instead ofbuild_header()
acpi: arm/virt:build_gtdt: use
acpi_init_table()/acpi_table_composed() instead ofbuild_header()
acpi:build_facs: usebuild_append_int_noprefix()API to compose table
acpi: remove no longer usedbuild_header()
acpi: AcpiGenericAddress no longer used to map/access fields of MMIO,
drop packed attributeinclude/hw/acpi/acpi-defs.h | 528 +------------------------ include/hw/acpi/acpi_dev_interface.h | 3 +- include/hw/acpi/aml-build.h | 21 +- include/hw/i386/pc.h | 7 +- tests/qtest/libqos/libqtest.h | 8 + hw/acpi/acpi-x86-stub.c | 3 +- hw/acpi/aml-build.c | 188 +++++---- hw/acpi/cpu.c | 17 +- hw/acpi/ghes.c | 10 +- hw/acpi/hmat.c | 14 +- hw/acpi/nvdimm.c | 64 ++-- hw/acpi/pci.c | 18 +- hw/acpi/vmgenid.c | 16 +- hw/arm/virt-acpi-build.c | 550 +++++++++++++++------------ hw/i386/acpi-build.c | 285 +++++++------- hw/i386/acpi-common.c | 158 ++++---- hw/i386/acpi-microvm.c | 13 +- meson.build | 6 + tests/data/acpi/q35/APIC.numamem | Bin 0 -> 2686 bytes tests/data/acpi/q35/DMAR.dmar | Bin 0 -> 80 bytes tests/data/acpi/q35/DSDT.ivrs | Bin 0 -> 7877 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7865 -> 35222 bytes tests/data/acpi/q35/FACP.numamem | Bin 0 -> 244 bytes tests/data/acpi/q35/IVRS.ivrs | Bin 0 -> 104 bytes tests/data/acpi/q35/SRAT.numamem | Bin 224 -> 5080 bytes tests/data/acpi/virt/IORT.iort | Bin 0 -> 124 bytes tests/qtest/acpi-utils.c | 14 + tests/qtest/arm-cpu-features.c | 29 +- tests/qtest/bios-tables-test.c | 85 ++++- tests/qtest/libqtest.c | 27 ++ tests/qtest/migration-test.c | 15 +- 31 files changed, 873 insertions(+), 1206 deletions(-) create mode 100644 tests/data/acpi/q35/APIC.numamem create mode 100644 tests/data/acpi/q35/DMAR.dmar create mode 100644 tests/data/acpi/q35/DSDT.ivrs create mode 100644 tests/data/acpi/q35/FACP.numamem create mode 100644 tests/data/acpi/q35/IVRS.ivrs create mode 100644 tests/data/acpi/virt/IORT.iort--
2.27.0
Quoted 10 lines · On Fri, 2 Jul 2021 10:47:20 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 4 lines · Igor Mammedov
Highlights:
* drop pointer arithmetic in ACPI tables code
* use endian agnostic API
* simplifies review of tables. /in most cases just line by line comparision with spec/A hue amount of work, thank you!
To make it easier to merge, how about splitting it up a bit? E.g. I think first 10-11 patches make sense on their own, right?
I think you've meant 01-11 patches, and answer is yes, it's in-depended of actual ACPI refactoring as was mentioned is cover letter, see below.
[...]
Quoted 8 lines
Quoted 8 lines
Series also includes optional qtest patches that add missing acpi tests for tables that I'm touching to verify conversion changes. That includes an alternative build time based impl. of
qtest_has_accel()API. So if we start bike-shedding thisqtest_has_accel()we can safely drop all tests included, till the time discussion settles and some form of aqtest_has_accel()is merged, at which point I'd respin depended tests.
[...]
it's ok to split tests into a separate series if that's what you prefer.
Quoted 26 lines · Igor Mammedov
Quoted 10 lines · On Fri, 2 Jul 2021 10:47:20 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 4 lines · Igor Mammedov
Highlights:
* drop pointer arithmetic in ACPI tables code
* use endian agnostic API
* simplifies review of tables. /in most cases just line by line comparision with spec/A hue amount of work, thank you!
To make it easier to merge, how about splitting it up a bit? E.g. I think first 10-11 patches make sense on their own, right?I think you've meant 01-11 patches, and answer is yes, it's in-depended of actual ACPI refactoring as was mentioned is cover letter, see below.
[...]
Quoted 8 lines
Quoted 8 lines
Series also includes optional qtest patches that add missing acpi tests for tables that I'm touching to verify conversion changes. That includes an alternative build time based impl. of
qtest_has_accel()API. So if we start bike-shedding thisqtest_has_accel()we can safely drop all tests included, till the time discussion settles and some form of aqtest_has_accel()is merged, at which point I'd respin depended tests.
Quoted 3 lines
[...]
it's ok to split tests into a separate series if that's what you prefer.
Let's start with a smaller series that still makes sense. I'll merge that we'll look at the next chunk.
Signature · 1 line
MST
Quoted 27 lines · On Mon, 5 Jul 2021 14:00:51 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 26 lines · Igor Mammedov
Quoted 10 lines · On Fri, 2 Jul 2021 10:47:20 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 4 lines · Igor Mammedov
Highlights:
* drop pointer arithmetic in ACPI tables code
* use endian agnostic API
* simplifies review of tables. /in most cases just line by line comparision with spec/A hue amount of work, thank you!
To make it easier to merge, how about splitting it up a bit? E.g. I think first 10-11 patches make sense on their own, right?I think you've meant 01-11 patches, and answer is yes, it's in-depended of actual ACPI refactoring as was mentioned is cover letter, see below.
[...]
Quoted 8 lines
Quoted 8 lines
Series also includes optional qtest patches that add missing acpi tests for tables that I'm touching to verify conversion changes. That includes an alternative build time based impl. of
qtest_has_accel()API. So if we start bike-shedding thisqtest_has_accel()we can safely drop all tests included, till the time discussion settles and some form of aqtest_has_accel()is merged, at which point I'd respin depended tests.
Quoted 7 lines
Quoted 3 lines
[...]
it's ok to split tests into a separate series if that's what you prefer.
Let's start with a smaller series that still makes sense. I'll merge that we'll look at the next chunk.
Ok, I'll drop tests for now and respin as v2 with TPM fixes.