ACPI related fixes to comform the spec better
v3 cover ACPI related fixes to comform the spec better
Miscellaneous bug fixes related to ACPI to play nice with guest BIOSes/OSes by conforming to ACPI spec better.
Changes from v2:
- improved commit message
- introduced compat property x-smm-compat-5
- _CRS for MMCONFIG resource, read MMCONFIG info from qemu, generate resource instead of dynamically reading chipset configuration.
Changes from v1:
- fixed style issue with fixes to checkpatch.pl
- fixed make check breakage
- added ACPI table tests
- update comment message to include acpi table diff
Isaku Yamahata (9):
checkpatch: don't emit warning on newly created acpi data files
qtest: update tests/qtest/bios-tables-test-allowed-diff.h
i386: add properoty, x-smm-compat-5, to keep compatibility of SMM acpi/core: always set SCI_EN when SMM isn't supported
acpi: set fadt.smi_cmd to zero when SMM is not supported
acpi: add test case for smm unsupported -machine smm=off hw/i386: declare ACPI mother board resource for MMCONFIG region
acpi: add test case for -no-hpet qtest/acpi/bios-tables-test: update acpi tables
Sean Christopherson (1):
i386: acpi: Don't build HPET ACPI entry if HPET is disabled
hw/acpi/core.c | 20 ++++++++- hw/acpi/ich9.c | 2 +- hw/acpi/piix4.c | 3 +- hw/i386/acpi-build.c | 72 +++++++++++++++++++++++++++--- hw/i386/pc_piix.c | 10 +++-- hw/i386/pc_q35.c | 1 + hw/i386/x86.c | 18 ++++++++ hw/isa/vt82c686.c | 2 +- include/hw/acpi/acpi.h | 4 +- include/hw/i386/x86.h | 2 + scripts/checkpatch.pl | 4 +- tests/data/acpi/q35/DSDT | Bin 7801 -> 7892 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9126 -> 9217 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7819 -> 7910 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8265 -> 8356 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9455 -> 9546 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7876 -> 7967 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9160 -> 9251 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8932 -> 9023 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 0 -> 7750 bytes tests/data/acpi/q35/DSDT.nosmm | Bin 0 -> 7892 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7807 -> 7898 bytes tests/data/acpi/q35/DSDT.tis | Bin 8407 -> 8498 bytes tests/data/acpi/q35/FACP.nosmm | Bin 0 -> 244 bytes tests/qtest/bios-tables-test.c | 24 ++++++++++ 25 files changed, 146 insertions(+), 16 deletions(-) create mode 100644 tests/data/acpi/q35/DSDT.nohpet create mode 100644 tests/data/acpi/q35/DSDT.nosmm create mode 100644 tests/data/acpi/q35/FACP.nosmm
Signature · 1 line
2.17.1
PATCH v3 1/10 checkpatch: don't emit warning on newly created acpi data files
Newly created acpi data files(tests/data/acpi/) cause false positive warning.
If file names are acpi expected file, don't emit warning.
--- scripts/checkpatch.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +3 -1
@@ -1530,7 +1530,9 @@ sub process { ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ || $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ || ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && - (defined($1) || defined($2))))) { + (defined($1) || defined($2)))) && + !(($realfile ne '') && + ($realfile eq $acpi_testexpected))) { $reported_maintainer_file = 1; WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr); }
Signature · 1 line
2.17.1
PATCH v3 5/10 acpi: set fadt.smi_cmd to zero when SMM is not supported
In reply to Isaku YamahataFrom table 5.9 SMI_CMD of ACPI spec
Quoted 2 lines
This field is reserved and must be zero on system
that does not support System Management mode.
When smm is not enabled, set it to zero to comform to the spec. When -machine smm=off is passed, the change to FACP is as follows.
@@ -1,46 +1,46 @@
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20180105 (64-bit version)
* Copyright (c) 2000 - 2018 Intel Corporation
*
- * Disassembly of tests/data/acpi/q35/FACP, Fri Feb 5 16:57:04 2021
+ * Disassembly of /tmp/aml-1OQYX0, Fri Feb 5 16:57:04 2021 *
* ACPI Data Table [FACP]
*
* Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue */
[000h 0000 4] Signature : "FACP" [Fixed ACPI Description Table (FADT)] [004h 0004 4] Table Length : 000000F4 [008h 0008 1] Revision : 03 -[009h 0009 1] Checksum : 1F +[009h 0009 1] Checksum : D6 [00Ah 0010 6] Oem ID : "BOCHS " [010h 0016 8] Oem Table ID : "BXPCFACP" [018h 0024 4] Oem Revision : 00000001 [01Ch 0028 4] Asl Compiler ID : "BXPC" [020h 0032 4] Asl Compiler Revision : 00000001
[024h 0036 4] FACS Address : 00000000 [028h 0040 4] DSDT Address : 00000000 [02Ch 0044 1] Model : 01 [02Dh 0045 1] PM Profile : 00 [Unspecified] [02Eh 0046 2] SCI Interrupt : 0009 -[030h 0048 4] SMI Command Port : 000000B2 -[034h 0052 1] ACPI Enable Value : 02 -[035h 0053 1] ACPI Disable Value : 03 +[030h 0048 4] SMI Command Port : 00000000 +[034h 0052 1] ACPI Enable Value : 00 +[035h 0053 1] ACPI Disable Value : 00 [036h 0054 1] S4BIOS Command : 00 [037h 0055 1] P-State Control : 00 [038h 0056 4] PM1A Event Block Address : 00000600 [03Ch 0060 4] PM1B Event Block Address : 00000000 [040h 0064 4] PM1A Control Block Address : 00000604 [044h 0068 4] PM1B Control Block Address : 00000000 [048h 0072 4] PM2 Control Block Address : 00000000 [04Ch 0076 4] PM Timer Block Address : 00000608 [050h 0080 4] GPE0 Block Address : 00000620 [054h 0084 4] GPE1 Block Address : 00000000 [058h 0088 1] PM1 Event Block Length : 04 [059h 0089 1] PM1 Control Block Length : 02 [05Ah 0090 1] PM2 Control Block Length : 00 [05Bh 0091 1] PM Timer Block Length : 04 [05Ch 0092 1] GPE0 Block Length : 10 [05Dh 0093 1] GPE1 Block Length : 00
--- hw/i386/acpi-build.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
hw/i386/acpi-build.c +15 -3
@@ -139,6 +139,14 @@ const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio = {static void init_common_fadt_data (MachineState *ms,Object *o,AcpiFadtData *data) { +X86MachineState *x86ms =X86_MACHINE (ms); +/* +* Until v5, smi_cmd/acpi_enable_cmd/acpi_disable_cmd were always set +* irrelevant to smm_enabled, which doesn't comforms to ACPI spec. +* Keep guest ABI compatibility when smm_compat_5 is true. +*/ +bool smm_enabled = x86ms->smm_compat_5 ? + true :x86_machine_is_smm_enabled (x86ms);uint32_t io =object_property_get_uint (o,ACPI_PM_PROP_PM_IO_BASE ,NULL );AmlAddressSpace as =AML_AS_SYSTEM_IO ;AcpiFadtData fadt = {
@@ -159,12 +167,16 @@ static void init_common_fadt_data(MachineState *ms, Object *o, .rtc_century = RTC_CENTURY, .plvl2_lat = 0xfff /* C2 state not supported */, .plvl3_lat = 0xfff /* C3 state not supported */, - .smi_cmd = ACPI_PORT_SMI_CMD, + .smi_cmd = smm_enabled ? ACPI_PORT_SMI_CMD : 0, .sci_int = object_property_get_uint(o, ACPI_PM_PROP_SCI_INT, NULL), .acpi_enable_cmd = - object_property_get_uint(o, ACPI_PM_PROP_ACPI_ENABLE_CMD, NULL), + smm_enabled ? +object_property_get_uint (o,ACPI_PM_PROP_ACPI_ENABLE_CMD ,NULL ) : + 0, .acpi_disable_cmd = - object_property_get_uint(o, ACPI_PM_PROP_ACPI_DISABLE_CMD, NULL), + smm_enabled ? +object_property_get_uint (o,ACPI_PM_PROP_ACPI_DISABLE_CMD ,NULL ) : + 0, .pm1a_evt = { .space_id = as, .bit_width = 4 * 8, .address = io }, .pm1a_cnt = { .space_id = as, .bit_width = 2 * 8, .address = io + 0x04 },
Signature · 1 line
2.17.1
PATCH v3 2/10 qtest: update tests/qtest/bios-tables-test-allowed-diff.h
In reply to Isaku YamahataThe following tests will modify acpi tables.
prepare qtests to allow acpi table change.
add new tables for new tests.
- tests/data/acpi/q35/DSDT.nosmm
- tests/data/acpi/q35/FACP.nosmm
- tests/data/acpi/q35/DSDT.nohpet
--- tests/data/acpi/q35/DSDT.nohpet | 0 tests/data/acpi/q35/DSDT.nosmm | 0 tests/data/acpi/q35/FACP.nosmm | 0 tests/qtest/bios-tables-test-allowed-diff.h | 13 +++++++++++++ 4 files changed, 13 insertions(+) create mode 100644 tests/data/acpi/q35/DSDT.nohpet create mode 100644 tests/data/acpi/q35/DSDT.nosmm create mode 100644 tests/data/acpi/q35/FACP.nosmm
tests/data/acpi/q35/DSDT.nohpet new file +0 -0
tests/data/acpi/q35/DSDT.nosmm new file +0 -0
tests/data/acpi/q35/FACP.nosmm new file +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +13 -0
@@ -1 +1,14 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT" , +"tests/data/acpi/q35/DSDT.tis" , +"tests/data/acpi/q35/DSDT.bridge" , +"tests/data/acpi/q35/DSDT.ipmibt" , +"tests/data/acpi/q35/DSDT.cphp" , +"tests/data/acpi/q35/DSDT.memhp" , +"tests/data/acpi/q35/DSDT.numamem" , +"tests/data/acpi/q35/DSDT.dimmpxm" , +"tests/data/acpi/q35/DSDT.acpihmat" , +"tests/data/acpi/q35/DSDT.mmio64" , +"tests/data/acpi/q35/DSDT.nosmm" , +"tests/data/acpi/q35/FACP.nosmm" , +"tests/data/acpi/q35/DSDT.nohpet",
Signature · 1 line
2.17.1
PATCH v3 6/10 acpi: add test case for smm unsupported -machine smm=off
In reply to Isaku Yamahata--- tests/qtest/bios-tables-test.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tests/qtest/bios-tables-test.c +12 -0
@@ -969,6 +969,17 @@ static void test_acpi_q35_tcg_numamem(void)free_test_data (&data); } +static void test_acpi_q35_tcg_nosmm (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_Q35 ; + data.variant =".nosmm" ; +test_acpi_one ("-machine smm=off" , &data); +free_test_data (&data); +} +static void test_acpi_piix4_tcg_numamem (void ) {test_data data;
@@ -1325,6 +1336,7 @@ int main(int argc, char *argv[])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/q35/nosmm" , test_acpi_q35_tcg_nosmm);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.17.1
PATCH v3 3/10 i386: add properoty, x-smm-compat-5, to keep compatibility of SMM
In reply to Isaku YamahataThe following patch will introduce incompatible behavior of SMM. Introduce a property to keep the old behavior for compatibility. To enable smm compat, use "-machine x-smm-compat-5=on"
--- hw/i386/pc_piix.c | 10 ++++++---- hw/i386/pc_q35.c | 1 + hw/i386/x86.c | 18 ++++++++++++++++++ include/hw/i386/x86.h | 2 ++ 4 files changed, 27 insertions(+), 4 deletions(-)
hw/i386/pc_piix.c +6 -4
@@ -441,6 +441,7 @@ DEFINE_I440FX_MACHINE(v6_0, "pc-i440fx-6.0", NULL,static void pc_i440fx_5_2_machine_options (MachineClass *m) {pc_i440fx_6_0_machine_options (m); + m->default_machine_opts ="firmware=bios-256k.bin,x-smm-compat-5=on" ; m->alias =NULL ; m->is_default = false;compat_props_add (m->compat_props, hw_compat_5_2, hw_compat_5_2_len);
@@ -664,7 +665,8 @@ static void pc_i440fx_2_2_machine_options(MachineClass *m)pc_i440fx_2_3_machine_options (m); m->hw_version ="2.2.0" ; - m->default_machine_opts ="firmware=bios-256k.bin,suppress-vmdesc=on" ; + m->default_machine_opts ="firmware=bios-256k.bin,suppress-vmdesc=on" +",x-smm-compat-5=on" ;compat_props_add (m->compat_props, hw_compat_2_2, hw_compat_2_2_len);compat_props_add (m->compat_props, pc_compat_2_2, pc_compat_2_2_len); pcmc->rsdp_in_ram = false;
@@ -727,7 +729,7 @@ static void pc_i440fx_1_7_machine_options(MachineClass *m)pc_i440fx_2_0_machine_options (m); m->hw_version ="1.7.0" ; - m->default_machine_opts =NULL ; + m->default_machine_opts ="x-smm-compat-5=on" ; m->option_rom_has_mr = true;compat_props_add (m->compat_props, pc_compat_1_7, pc_compat_1_7_len); pcmc->smbios_defaults = false;
@@ -999,7 +1001,7 @@ static void xenfv_4_2_machine_options(MachineClass *m)pc_i440fx_4_2_machine_options (m); m->desc ="Xen Fully-virtualized PC" ; m->max_cpus =HVM_MAX_VCPUS ; - m->default_machine_opts ="accel=xen,suppress-vmdesc=on" ; + m->default_machine_opts ="accel=xen,suppress-vmdesc=on,x-smm-compat-5=on" ; } DEFINE_PC_MACHINE(xenfv_4_2, "xenfv-4.2", pc_xen_hvm_init,
@@ -1011,7 +1013,7 @@ static void xenfv_3_1_machine_options(MachineClass *m) m->desc ="Xen Fully-virtualized PC" ; m->alias ="xenfv" ; m->max_cpus =HVM_MAX_VCPUS ; - m->default_machine_opts ="accel=xen,suppress-vmdesc=on" ; + m->default_machine_opts ="accel=xen,suppress-vmdesc=on,x-smm-compat-5=on" ; } DEFINE_PC_MACHINE(xenfv, "xenfv-3.1", pc_xen_hvm_init,
hw/i386/pc_q35.c +1 -0
@@ -358,6 +358,7 @@ DEFINE_Q35_MACHINE(v6_0, "pc-q35-6.0", NULL,static void pc_q35_5_2_machine_options (MachineClass *m) {pc_q35_6_0_machine_options (m); + m->default_machine_opts ="firmware=bios-256k.bin,x-smm-compat-5=on" ; m->alias =NULL ;compat_props_add (m->compat_props, hw_compat_5_2, hw_compat_5_2_len);compat_props_add (m->compat_props, pc_compat_5_2, pc_compat_5_2_len);
hw/i386/x86.c +18 -0
@@ -1174,6 +1174,18 @@ static void x86_machine_set_smm(Object *obj, Visitor *v, const char *name,visit_type_OnOffAuto (v, name, &x86ms->smm, errp); } +static bool x86_machine_get_smm_compat_5 (Object *obj,Error **errp) +{ +X86MachineState *x86ms =X86_MACHINE (obj); +return x86ms->smm_compat_5; +} + +static void x86_machine_set_smm_compat_5 (Object *obj,bool value,Error **errp) +{ +X86MachineState *x86ms =X86_MACHINE (obj); + x86ms->smm_compat_5 = value; +} +bool x86_machine_is_acpi_enabled (const X86MachineState *x86ms) {if (x86ms->acpi ==ON_OFF_AUTO_OFF ) {
@@ -1204,6 +1216,7 @@ static void x86_machine_initfn(Object *obj)X86MachineState *x86ms =X86_MACHINE (obj); x86ms->smm =ON_OFF_AUTO_AUTO ; + x86ms->smm_compat_5 = false; x86ms->acpi =ON_OFF_AUTO_AUTO ; x86ms->smp_dies =1 ; x86ms->pci_irq_mask =ACPI_BUILD_PCI_IRQS ;
@@ -1228,6 +1241,11 @@ static void x86_machine_class_init(ObjectClass *oc, void *data)object_class_property_set_description (oc,X86_MACHINE_SMM ,"Enable SMM" ); +object_class_property_add_bool (oc,X86_MACHINE_SMM_COMPAT_5 , + x86_machine_get_smm_compat_5, x86_machine_set_smm_compat_5); +object_class_property_set_description (oc,X86_MACHINE_SMM_COMPAT_5 , +"Enable SMM compatible behavior" ); +object_class_property_add (oc,X86_MACHINE_ACPI ,"OnOffAuto" , x86_machine_get_acpi, x86_machine_set_acpi,NULL ,NULL );
include/hw/i386/x86.h +2 -0
@@ -65,6 +65,7 @@ struct X86MachineState {unsigned smp_dies;OnOffAuto smm; +bool smm_compat_5;OnOffAuto acpi;/*
@@ -75,6 +76,7 @@ struct X86MachineState { };#define X86_MACHINE_SMM "smm" +#define X86_MACHINE_SMM_COMPAT_5 "x-smm-compat-5"#define X86_MACHINE_ACPI "acpi"#define TYPE_X86_MACHINE MACHINE_TYPE_NAME("x86")
Signature · 1 line
2.17.1
PATCH v3 7/10 hw/i386: declare ACPI mother board resource for MMCONFIG region
In reply to Isaku YamahataDeclare PNP0C01 device to reserve MMCONFIG region to conform to the spec better and play nice with guest BIOSes/OSes.
According to PCI Firmware Specification[0], MMCONFIG region must be reserved by declaring a motherboard resource. It's optional to reserve the region in memory map by Int 15 E820h or EFIGetMemoryMap. Guest Linux checks if the MMCFG region is reserved by bios memory map or ACPI resource. If it's not reserved, Linux falls back to legacy PCI configuration access.
TDVF [1] [2] doesn't reserve MMCONFIG the region in memory map. On the other hand OVMF reserves it in memory map without declaring a motherboard resource. With memory map reservation, linux guest uses MMCONFIG region. However it doesn't comply to PCI Firmware specification.
[0] PCI Firmware specification Revision 3.2
4.1.2 MCFG Table Description table 4-2 NOTE 2
If the operating system does not natively comprehend reserving the MMCFG region, The MMCFG region must e reserved by firmware. ... For most systems, the mortheroard resource would appear at the root of the ACPI namespace (under \_SB)...
The resource can optionally be returned in Int15 E820h or EFIGetMemoryMap as reserved memory but must always be reported through ACPI as a motherboard resource
[1] TDX: Intel Trust Domain Extension
https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html
[2] TDX Virtual Firmware
https://github.com/tianocore/edk2-staging/tree/TDVF
The change to DSDT is as follows.
@@ -68,32 +68,51 @@
If ((CDW3 != Local0))
{
CDW1 |= 0x10
}
CDW3 = Local0
}
Else
{
CDW1 |= 0x04
}
Return (Arg3)
}
}
+
+ Device (DRAC)
+ {
+ Name (_HID, "PNP0C01" /* System Board */) // _HID: Hardware ID
+ Name (RBUF, ResourceTemplate ()
+ {
+ QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
+ 0x0000000000000000, // Granularity
+ 0x00000000B0000000, // Range Minimum
+ 0x00000000BFFFFFFF, // Range Maximum
+ 0x0000000000000000, // Translation Offset
+ 0x0000000010000000, // Length
+ ,, , AddressRangeMemory, TypeStatic)
+ })
+ Method (_CRS, 0, Serialized) // _CRS: Current Resource Settings
+ {
+ Return (RBUF) /* \_SB_.DRAC.RBUF */
+ }
+ }
}
Scope (_SB)
{
Device (HPET)
{
Name (_HID, EisaId ("PNP0103") /* HPET System Timer */) // _HID: Hardware ID
Name (_UID, Zero) // _UID: Unique ID
OperationRegion (HPTM, SystemMemory, 0xFED00000, 0x0400)
Field (HPTM, DWordAcc, Lock, Preserve)
{
VEND, 32,
PRD, 32
}
Method (_STA, 0, NotSerialized) // _STA: Status--- hw/i386/acpi-build.c | 46 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-)
hw/i386/acpi-build.c +45 -1
@@ -1072,6 +1072,46 @@ static void build_q35_pci0_int(Aml *table)aml_append (table, sb_scope); } +static Aml *build_q35_dram_controller (void ) +{ +AcpiMcfgInfo mcfg; +Aml *dev; +Aml *rbuf; +Aml *resource_template; +Aml *rbuf_name; +Aml *crs; + +if (!acpi_get_mcfg (&mcfg)) { +return NULL ; + } + +/* DRAM controller */ + dev =aml_device ("DRAC" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("PNP0C01" ))); + + resource_template =aml_resource_template (); +aml_append (resource_template, +aml_qword_memory (AML_POS_DECODE , +AML_MIN_FIXED , +AML_MAX_FIXED , +AML_NON_CACHEABLE , +AML_READ_WRITE , +0x0000000000000000 , + mcfg.base, + mcfg.base + mcfg.size -1 , +0x0000000000000000 , + mcfg.size)); + rbuf =aml_name_decl ("RBUF" , resource_template); +aml_append (dev, rbuf); + + crs =aml_method ("_CRS" ,0 ,AML_SERIALIZED ); + rbuf_name =aml_name ("RBUF" ); +aml_append (crs,aml_return (rbuf_name)); +aml_append (dev, crs); + +return dev; +} +static void build_q35_isa_bridge (Aml *table) {Aml *dev;
@@ -1212,7 +1252,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Range *pci_hole, Range *pci_hole64, MachineState *machine) {CrsRangeEntry *entry; -Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs; +Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs, *drac;CrsRangeSet crs_range_set;PCMachineState *pcms =PC_MACHINE (machine);PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (machine);
@@ -1256,6 +1296,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 )));aml_append (dev,build_q35_osc_method ());aml_append (sb_scope, dev); + drac =build_q35_dram_controller (); +if (drac) { +aml_append (sb_scope, drac); + }if (pm->smi_on_cpuhp) {/* reserve SMI block resources, IO ports 0xB2, 0xB3 */
Signature · 1 line
2.17.1
PATCH v3 8/10 i386: acpi: Don't build HPET ACPI entry if HPET is disabled
In reply to Isaku YamahataFrom: Sean Christopherson <[email protected]>
Omit HPET AML if the HPET is disabled, QEMU is not emulating it and the guest may get confused by seeing HPET in the ACPI tables without a "physical" device present.
The change of DSDT when -no-hpet is as follows.
@@ -141,47 +141,6 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS "
}
}- Scope (_SB)
- {
- Device (HPET)
- {
- Name (_HID, EisaId ("PNP0103") /* HPET System Timer */) // _HID: Hardware ID
- Name (_UID, Zero) // _UID: Unique ID
- OperationRegion (HPTM, SystemMemory, 0xFED00000, 0x0400)
- Field (HPTM, DWordAcc, Lock, Preserve)
- {
- VEND, 32,
- PRD, 32- }
-
- Method (_STA, 0, NotSerialized) // _STA: Status
- {
- Local0 = VEND /* \_SB_.HPET.VEND */
- Local1 = PRD /* \_SB_.HPET.PRD_ */
- Local0 >>= 0x10
- If (((Local0 == Zero) || (Local0 == 0xFFFF)))
- {- Return (Zero)
- }
-
- If (((Local1 == Zero) || (Local1 > 0x05F5E100)))
- {
- Return (Zero)
- }
-
- Return (0x0F)
- }
-
- Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
- {
- Memory32Fixed (ReadOnly,
- 0xFED00000, // Address Base - 0x00000400, // Address Length - )
- })
- }
- }
-
Scope (_SB.PCI0)
{
Device (ISA)--- hw/i386/acpi-build.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
hw/i386/acpi-build.c +6 -2
@@ -1280,7 +1280,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (sb_scope, dev);aml_append (dsdt, sb_scope); -build_hpet_aml (dsdt); +if (misc->has_hpet) { +build_hpet_aml (dsdt); + }build_piix4_isa_bridge (dsdt);build_isa_devices_aml (dsdt);if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
@@ -1328,7 +1330,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dsdt, sb_scope); -build_hpet_aml (dsdt); +if (misc->has_hpet) { +build_hpet_aml (dsdt); + }build_q35_isa_bridge (dsdt);build_isa_devices_aml (dsdt);build_q35_pci0_int (dsdt);
Signature · 1 line
2.17.1
PATCH v3 4/10 acpi/core: always set SCI_EN when SMM isn't supported
In reply to Isaku YamahataIf SMM is not supported, ACPI fixed hardware doesn't support legacy-mode. ACPI-only platform. Where SCI_EN in PM1_CNT register is always set.
The bit tells OS legacy mode(SCI_EN cleared) or ACPI mode(SCI_EN set).
With the next patch (setting fadt.smi_cmd = 0 when smm isn't enabled), guest Linux tries to switch to ACPI mode, finds smi_cmd = 0, and then fails to initialize acpi subsystem. This patch proactively fixes it.
This patch changes guest ABI. To keep compatibility, use "x-smm-compat-5" introduced by earlier patch. If the property is true, disable new behavior.
ACPI spec 4.8.10.1 PM1 Event Grouping
PM1 Eanble Registers
Quoted 1 line
For ACPI-only platforms (where
SCI_ENis always set)
--- hw/acpi/core.c | 20 +++++++++++++++++++- hw/acpi/ich9.c | 2 +- hw/acpi/piix4.c | 3 ++- hw/isa/vt82c686.c | 2 +- include/hw/acpi/acpi.h | 4 +++- 5 files changed, 26 insertions(+), 5 deletions(-)
hw/acpi/core.c +19 -1
@@ -579,6 +579,10 @@ void acpi_pm1_cnt_update(ACPIREGS *ar, bool sci_enable, bool sci_disable) {/* ACPI specs 3.0, 4.7.2.5 */ +if (ar->pm1.cnt.acpi_only) { +return ; + } +if (sci_enable) { ar->pm1.cnt.cnt |=ACPI_BITMASK_SCI_ENABLE ; }else if (sci_disable) {
@@ -608,11 +612,22 @@ static const MemoryRegionOps acpi_pm_cnt_ops = { };void acpi_pm1_cnt_init (ACPIREGS *ar,MemoryRegion *parent, -bool disable_s3,bool disable_s4,uint8_t s4_val) +bool disable_s3,bool disable_s4,uint8_t s4_val, +bool acpi_only) {FWCfgState *fw_cfg; +/* +* Until v5, pm1 cnt allows to change mode (legacy vs acpi) +* even SMM isn't enabled. +* Keep the old behavior for compatibility. +*/ +if (object_property_get_bool (qdev_get_machine (),"x-smm-compat-5" ,NULL )) { + acpi_only = false; + } + ar->pm1.cnt.s4_val = s4_val; + ar->pm1.cnt.acpi_only = acpi_only; ar->wakeup.notify = acpi_notify_wakeup;qemu_register_wakeup_notifier (&ar->wakeup);
@@ -638,6 +653,9 @@ void acpi_pm1_cnt_init(ACPIREGS *ar, MemoryRegion *parent,void acpi_pm1_cnt_reset (ACPIREGS *ar) { ar->pm1.cnt.cnt =0 ; +if (ar->pm1.cnt.acpi_only) { + ar->pm1.cnt.cnt |=ACPI_BITMASK_SCI_ENABLE ; + } }/* ACPI GPE */
hw/acpi/ich9.c +1 -1
@@ -282,7 +282,7 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,acpi_pm_tmr_init (&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);acpi_pm1_evt_init (&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);acpi_pm1_cnt_init (&pm->acpi_regs, &pm->io, pm->disable_s3, pm->disable_s4, - pm->s4_val); + pm->s4_val, !smm_enabled);acpi_gpe_init (&pm->acpi_regs,ICH9_PMIO_GPE0_LEN ); memory_region_init_io(&pm->io_gpe, OBJECT(lpc_pci), &ich9_gpe_ops, pm,
hw/acpi/piix4.c +2 -1
@@ -496,7 +496,8 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)acpi_pm_tmr_init (&s->ar, pm_tmr_timer, &s->io);acpi_pm1_evt_init (&s->ar, pm_tmr_timer, &s->io); -acpi_pm1_cnt_init (&s->ar, &s->io, s->disable_s3, s->disable_s4, s->s4_val); +acpi_pm1_cnt_init (&s->ar, &s->io, s->disable_s3, s->disable_s4, s->s4_val, + !s->smm_enabled);acpi_gpe_init (&s->ar,GPE_LEN ); s->powerdown_notifier.notify = piix4_pm_powerdown_req;
hw/isa/vt82c686.c +1 -1
@@ -240,7 +240,7 @@ static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp)acpi_pm_tmr_init (&s->ar, pm_tmr_timer, &s->io);acpi_pm1_evt_init (&s->ar, pm_tmr_timer, &s->io); -acpi_pm1_cnt_init (&s->ar, &s->io, false, false,2 ); +acpi_pm1_cnt_init (&s->ar, &s->io, false, false,2 , false); }static Property via_pm_properties[] = {
include/hw/acpi/acpi.h +3 -1
@@ -128,6 +128,7 @@ struct ACPIPM1CNT {MemoryRegion io;uint16_t cnt;uint8_t s4_val; +bool acpi_only; };struct ACPIGPE {
@@ -163,7 +164,8 @@ void acpi_pm1_evt_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,/* PM1a_CNT: piix and ich9 don't implement PM1b CNT. */ void acpi_pm1_cnt_init (ACPIREGS *ar,MemoryRegion *parent, -bool disable_s3,bool disable_s4,uint8_t s4_val); +bool disable_s3,bool disable_s4,uint8_t s4_val, +bool acpi_only);void acpi_pm1_cnt_update (ACPIREGS *ar,bool sci_enable,bool sci_disable);void acpi_pm1_cnt_reset (ACPIREGS *ar);
Signature · 1 line
2.17.1
PATCH v3 9/10 acpi: add test case for -no-hpet
In reply to Isaku Yamahata--- tests/qtest/bios-tables-test.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tests/qtest/bios-tables-test.c +12 -0
@@ -980,6 +980,17 @@ static void test_acpi_q35_tcg_nosmm(void)free_test_data (&data); } +static void test_acpi_q35_tcg_nohpet (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_Q35 ; + data.variant =".nohpet" ; +test_acpi_one (" -no-hpet" , &data); +free_test_data (&data); +} +static void test_acpi_piix4_tcg_numamem (void ) {test_data data;
@@ -1337,6 +1348,7 @@ int main(int argc, char *argv[])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/q35/nosmm" , test_acpi_q35_tcg_nosmm); +qtest_add_func ("acpi/q35/nohpet" , test_acpi_q35_tcg_nohpet);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.17.1
PATCH v3 10/10 qtest/acpi/bios-tables-test: update acpi tables
In reply to Isaku Yamahataupdate golden master acpi tables and emptybios-tables-test-allowed-diff.h.
--- tests/data/acpi/q35/DSDT | Bin 7801 -> 7892 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9126 -> 9217 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7819 -> 7910 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8265 -> 8356 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9455 -> 9546 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7876 -> 7967 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9160 -> 9251 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8932 -> 9023 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 0 -> 7750 bytes tests/data/acpi/q35/DSDT.nosmm | Bin 0 -> 7892 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7807 -> 7898 bytes tests/data/acpi/q35/DSDT.tis | Bin 8407 -> 8498 bytes tests/data/acpi/q35/FACP.nosmm | Bin 0 -> 244 bytes tests/qtest/bios-tables-test-allowed-diff.h | 13 ------------- 14 files changed, 13 deletions(-)
tests/data/acpi/q35/DSDT binary +0 -0
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.cphp binary +0 -0
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
tests/data/acpi/q35/DSDT.memhp binary +0 -0
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
tests/data/acpi/q35/DSDT.nohpet binary +0 -0
tests/data/acpi/q35/DSDT.nosmm binary +0 -0
tests/data/acpi/q35/DSDT.numamem binary +0 -0
tests/data/acpi/q35/DSDT.tis binary +0 -0
tests/data/acpi/q35/FACP.nosmm binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -13
@@ -1,14 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DSDT" , -"tests/data/acpi/q35/DSDT.tis" , -"tests/data/acpi/q35/DSDT.bridge" , -"tests/data/acpi/q35/DSDT.ipmibt" , -"tests/data/acpi/q35/DSDT.cphp" , -"tests/data/acpi/q35/DSDT.memhp" , -"tests/data/acpi/q35/DSDT.numamem" , -"tests/data/acpi/q35/DSDT.dimmpxm" , -"tests/data/acpi/q35/DSDT.acpihmat" , -"tests/data/acpi/q35/DSDT.mmio64" , -"tests/data/acpi/q35/DSDT.nosmm" , -"tests/data/acpi/q35/FACP.nosmm" , -"tests/data/acpi/q35/DSDT.nohpet",
Signature · 1 line
2.17.1
Re: [PATCH v3 03/10] i386: add properoty, x-smm-compat-5, to keep compatibility of SMM
In reply to Isaku YamahataQuoted 3 lines · On Wed, 10 Feb 2021 22:46:39 -0800 Isaku Yamahata <[email protected]>…
The following patch will introduce incompatible behavior of SMM. Introduce a property to keep the old behavior for compatibility. To enable smm compat, use "-machine x-smm-compat-5=on"
just curious, why it has "-5" suffix
also I'd drop x- prefix.
Quoted 13 lines
Signed-off-by Isaku Yamahata <[email protected]>--- hw/i386/pc_piix.c | 10 ++++++---- hw/i386/pc_q35.c | 1 + hw/i386/x86.c | 18 ++++++++++++++++++ include/hw/i386/x86.h | 2 ++ 4 files changed, 27 insertions(+), 4 deletions(-)hw/i386/pc_piix.c +0
-0
hw/i386/pc_piix.c DEFINE_I440FX_MACHINE(v6_0, "pc-i440fx-6.0", NULL, · line 444
Quoted 4 lines
hw/i386/pc_piix.c +1
-0@@ -441,6 +441,7 @@ DEFINE_I440FX_MACHINE(v6_0, "pc-i440fx-6.0", NULL,static void pc_i440fx_5_2_machine_options (MachineClass *m) {pc_i440fx_6_0_machine_options (m); + m->default_machine_opts ="firmware=bios-256k.bin,x-smm-compat-5=on" ;
did I point to a wrong example :/
smm machinery is part of ich9/piix4 devices, so it would be simpler by adding 'smm-compat' property to them
hw/core/machine.c +1 -1
@@ -36,7 +36,9 @@#include "hw/virtio/virtio.h" #include "hw/virtio/virtio-pci.h" -GlobalProperty hw_compat_5_2[] = {}; +GlobalProperty hw_compat_5_2[] = {
it turns on compat mode on 5.2 and older machines types
+ { "ICH9-LPC", "smm-compat", "on"},
+};
const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
GlobalProperty hw_compat_5_1[] = {
hw/isa/lpc_ich9.c +0 -0
@@ -774,6 +774,7 @@ static const VMStateDescription vmstate_ich9_lpc = { };static Property ich9_lpc_properties[] = {
default would be used on new and later machine types
+ DEFINE_PROP_BOOL("smm-compat", ICH9LPCState, pm.smm_compat , false),
DEFINE_PROP_BOOL("noreboot", ICH9LPCState, pin_strap.spkr_hi, true), DEFINE_PROP_BIT64("x-smi-broadcast", ICH9LPCState, smi_host_features,
ICH9_LPC_SMI_F_BROADCAST_BIT, true),
then do the same for piix4 pm device
Quoted 115 lines
hw/i386/pc_piix.c +5
-4m->alias =NULL ; m->is_default = false;compat_props_add (m->compat_props, hw_compat_5_2, hw_compat_5_2_len);@@ -664,7 +665,8 @@ static void pc_i440fx_2_2_machine_options(MachineClass *m)pc_i440fx_2_3_machine_options (m); m->hw_version ="2.2.0" ; - m->default_machine_opts ="firmware=bios-256k.bin,suppress-vmdesc=on" ; + m->default_machine_opts ="firmware=bios-256k.bin,suppress-vmdesc=on" +",x-smm-compat-5=on" ;compat_props_add (m->compat_props, hw_compat_2_2, hw_compat_2_2_len);compat_props_add (m->compat_props, pc_compat_2_2, pc_compat_2_2_len); pcmc->rsdp_in_ram = false;@@ -727,7 +729,7 @@ static void pc_i440fx_1_7_machine_options(MachineClass *m)pc_i440fx_2_0_machine_options (m); m->hw_version ="1.7.0" ; - m->default_machine_opts =NULL ; + m->default_machine_opts ="x-smm-compat-5=on" ; m->option_rom_has_mr = true;compat_props_add (m->compat_props, pc_compat_1_7, pc_compat_1_7_len); pcmc->smbios_defaults = false;@@ -999,7 +1001,7 @@ static void xenfv_4_2_machine_options(MachineClass *m)pc_i440fx_4_2_machine_options (m); m->desc ="Xen Fully-virtualized PC" ; m->max_cpus =HVM_MAX_VCPUS ; - m->default_machine_opts ="accel=xen,suppress-vmdesc=on" ; + m->default_machine_opts ="accel=xen,suppress-vmdesc=on,x-smm-compat-5=on" ; } DEFINE_PC_MACHINE(xenfv_4_2, "xenfv-4.2", pc_xen_hvm_init,@@ -1011,7 +1013,7 @@ static void xenfv_3_1_machine_options(MachineClass *m) m->desc ="Xen Fully-virtualized PC" ; m->alias ="xenfv" ; m->max_cpus =HVM_MAX_VCPUS ; - m->default_machine_opts ="accel=xen,suppress-vmdesc=on" ; + m->default_machine_opts ="accel=xen,suppress-vmdesc=on,x-smm-compat-5=on" ; } DEFINE_PC_MACHINE(xenfv, "xenfv-3.1", pc_xen_hvm_init,hw/i386/pc_q35.c +1
-0@@ -358,6 +358,7 @@ DEFINE_Q35_MACHINE(v6_0, "pc-q35-6.0", NULL,static void pc_q35_5_2_machine_options (MachineClass *m) {pc_q35_6_0_machine_options (m); + m->default_machine_opts ="firmware=bios-256k.bin,x-smm-compat-5=on" ; m->alias =NULL ;compat_props_add (m->compat_props, hw_compat_5_2, hw_compat_5_2_len);compat_props_add (m->compat_props, pc_compat_5_2, pc_compat_5_2_len);hw/i386/x86.c +18
-0@@ -1174,6 +1174,18 @@ static void x86_machine_set_smm(Object *obj, Visitor *v, const char *name,visit_type_OnOffAuto (v, name, &x86ms->smm, errp); } +static bool x86_machine_get_smm_compat_5 (Object *obj,Error **errp) +{ +X86MachineState *x86ms =X86_MACHINE (obj); +return x86ms->smm_compat_5; +} + +static void x86_machine_set_smm_compat_5 (Object *obj,bool value,Error **errp) +{ +X86MachineState *x86ms =X86_MACHINE (obj); + x86ms->smm_compat_5 = value; +} +bool x86_machine_is_acpi_enabled (const X86MachineState *x86ms) {if (x86ms->acpi ==ON_OFF_AUTO_OFF ) {@@ -1204,6 +1216,7 @@ static void x86_machine_initfn(Object *obj)X86MachineState *x86ms =X86_MACHINE (obj); x86ms->smm =ON_OFF_AUTO_AUTO ; + x86ms->smm_compat_5 = false; x86ms->acpi =ON_OFF_AUTO_AUTO ; x86ms->smp_dies =1 ; x86ms->pci_irq_mask =ACPI_BUILD_PCI_IRQS ;@@ -1228,6 +1241,11 @@ static void x86_machine_class_init(ObjectClass *oc, void *data)object_class_property_set_description (oc,X86_MACHINE_SMM ,"Enable SMM" ); +object_class_property_add_bool (oc,X86_MACHINE_SMM_COMPAT_5 , + x86_machine_get_smm_compat_5, x86_machine_set_smm_compat_5); +object_class_property_set_description (oc,X86_MACHINE_SMM_COMPAT_5 , +"Enable SMM compatible behavior" ); +object_class_property_add (oc,X86_MACHINE_ACPI ,"OnOffAuto" , x86_machine_get_acpi, x86_machine_set_acpi,NULL ,NULL );include/hw/i386/x86.h +2
-0@@ -65,6 +65,7 @@ struct X86MachineState {unsigned smp_dies;OnOffAuto smm; +bool smm_compat_5;OnOffAuto acpi;/* @@ -75,6 +76,7 @@ struct X86MachineState { };#define X86_MACHINE_SMM "smm" +#define X86_MACHINE_SMM_COMPAT_5 "x-smm-compat-5"#define X86_MACHINE_ACPI "acpi"#define TYPE_X86_MACHINE MACHINE_TYPE_NAME("x86")
Re: [PATCH v3 04/10] acpi/core: always set SCI_EN when SMM isn't supported
In reply to Isaku YamahataQuoted 80 lines · On Wed, 10 Feb 2021 22:46:40 -0800 Isaku Yamahata <[email protected]>…
If SMM is not supported, ACPI fixed hardware doesn't support legacy-mode. ACPI-only platform. Where
SCI_ENinPM1_CNTregister is always set.
The bit tells OS legacymode(SCI_EN cleared)or ACPImode(SCI_EN set).With the next patch (setting fadt.smi_cmd = 0 when smm isn't enabled), guest Linux tries to switch to ACPI mode, finds
smi_cmd= 0, and then fails to initialize acpi subsystem. This patch proactively fixes it.This patch changes guest ABI. To keep compatibility, use "x-smm-compat-5" introduced by earlier patch. If the property is true, disable new behavior.
ACPI spec 4.8.10.1 PM1 Event Grouping
PM1 Eanble RegistersQuoted 1 line
For ACPI-only platforms (where
SCI_ENis always set)Signed-off-by Isaku Yamahata <[email protected]>--- hw/acpi/core.c | 20 +++++++++++++++++++- hw/acpi/ich9.c | 2 +- hw/acpi/piix4.c | 3 ++- hw/isa/vt82c686.c | 2 +- include/hw/acpi/acpi.h | 4 +++- 5 files changed, 26 insertions(+), 5 deletions(-)hw/acpi/core.c +19
-1@@ -579,6 +579,10 @@ void acpi_pm1_cnt_update(ACPIREGS *ar, bool sci_enable, bool sci_disable) {/* ACPI specs 3.0, 4.7.2.5 */ +if (ar->pm1.cnt.acpi_only) { +return ; + } +if (sci_enable) { ar->pm1.cnt.cnt |=ACPI_BITMASK_SCI_ENABLE ; }else if (sci_disable) {@@ -608,11 +612,22 @@ static const MemoryRegionOps acpi_pm_cnt_ops = { };void acpi_pm1_cnt_init (ACPIREGS *ar,MemoryRegion *parent, -bool disable_s3,bool disable_s4,uint8_t s4_val) +bool disable_s3,bool disable_s4,uint8_t s4_val, +bool acpi_only) {FWCfgState *fw_cfg; +/* +* Until v5, pm1 cnt allows to change mode (legacy vs acpi) +* even SMM isn't enabled. +* Keep the old behavior for compatibility. +*/ +if (object_property_get_bool (qdev_get_machine (),"x-smm-compat-5" ,NULL )) { + acpi_only = false; + } + ar->pm1.cnt.s4_val = s4_val; + ar->pm1.cnt.acpi_only = acpi_only; ar->wakeup.notify = acpi_notify_wakeup;qemu_register_wakeup_notifier (&ar->wakeup);@@ -638,6 +653,9 @@ void acpi_pm1_cnt_init(ACPIREGS *ar, MemoryRegion *parent,void acpi_pm1_cnt_reset (ACPIREGS *ar) { ar->pm1.cnt.cnt =0 ; +if (ar->pm1.cnt.acpi_only) { + ar->pm1.cnt.cnt |=ACPI_BITMASK_SCI_ENABLE ; + } }/* ACPI GPE */ hw/acpi/ich9.c +0
-0
hw/acpi/ich9.c void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, · line 285
Quoted 5 lines
hw/acpi/ich9.c +1
-1@@ -282,7 +282,7 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,acpi_pm_tmr_init (&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);acpi_pm1_evt_init (&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);acpi_pm1_cnt_init (&pm->acpi_regs, &pm->io, pm->disable_s3, pm->disable_s4, - pm->s4_val); + pm->s4_val, !smm_enabled);
with device compat prop as suggested on 3/10 it will look like s/!smm_enabled/!pm->smm_compat && !smm_enabled/
Quoted 52 lines
hw/acpi/ich9.c +0
-0acpi_gpe_init (&pm->acpi_regs,ICH9_PMIO_GPE0_LEN ); memory_region_init_io(&pm->io_gpe, OBJECT(lpc_pci), &ich9_gpe_ops, pm,hw/acpi/piix4.c +2
-1@@ -496,7 +496,8 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)acpi_pm_tmr_init (&s->ar, pm_tmr_timer, &s->io);acpi_pm1_evt_init (&s->ar, pm_tmr_timer, &s->io); -acpi_pm1_cnt_init (&s->ar, &s->io, s->disable_s3, s->disable_s4, s->s4_val); +acpi_pm1_cnt_init (&s->ar, &s->io, s->disable_s3, s->disable_s4, s->s4_val, + !s->smm_enabled);acpi_gpe_init (&s->ar,GPE_LEN ); s->powerdown_notifier.notify = piix4_pm_powerdown_req;hw/isa/vt82c686.c +1
-1@@ -240,7 +240,7 @@ static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp)acpi_pm_tmr_init (&s->ar, pm_tmr_timer, &s->io);acpi_pm1_evt_init (&s->ar, pm_tmr_timer, &s->io); -acpi_pm1_cnt_init (&s->ar, &s->io, false, false,2 ); +acpi_pm1_cnt_init (&s->ar, &s->io, false, false,2 , false); }static Property via_pm_properties[] = {include/hw/acpi/acpi.h +3
-1@@ -128,6 +128,7 @@ struct ACPIPM1CNT {MemoryRegion io;uint16_t cnt;uint8_t s4_val; +bool acpi_only; };struct ACPIGPE {@@ -163,7 +164,8 @@ void acpi_pm1_evt_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,/* PM1a_CNT: piix and ich9 don't implement PM1b CNT. */ void acpi_pm1_cnt_init (ACPIREGS *ar,MemoryRegion *parent, -bool disable_s3,bool disable_s4,uint8_t s4_val); +bool disable_s3,bool disable_s4,uint8_t s4_val, +bool acpi_only);void acpi_pm1_cnt_update (ACPIREGS *ar,bool sci_enable,bool sci_disable);void acpi_pm1_cnt_reset (ACPIREGS *ar);
Re: [PATCH v3 05/10] acpi: set fadt.smi_cmd to zero when SMM is not supported
In reply to Isaku YamahataQuoted 86 lines · On Wed, 10 Feb 2021 22:46:41 -0800 Isaku Yamahata <[email protected]>…
From table 5.9
SMI_CMDof ACPI specQuoted 2 lines
This field is reserved and must be zero on system
that does not support System Management mode.When smm is not enabled, set it to zero to comform to the spec. When -machine smm=off is passed, the change to FACP is as follows.
(quoted diff) +5
-5@@ -1,46 +1,46 @@ /* * Intel ACPI Component Architecture * AML/ASL+ Disassembler version 20180105 (64-bit version) * Copyright (c) 2000 - 2018 Intel Corporation * - * Disassembly of tests/data/acpi/q35/FACP, Fri Feb 5 16:57:04 2021 + * Disassembly of /tmp/aml-1OQYX0, Fri Feb 5 16:57:04 2021 * * ACPI Data Table [FACP] * * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue */ [000h 0000 4] Signature : "FACP" [Fixed ACPI Description Table (FADT)] [004h 0004 4] Table Length : 000000F4 [008h 0008 1] Revision : 03 -[009h 0009 1] Checksum : 1F +[009h 0009 1] Checksum : D6 [00Ah 0010 6] Oem ID : "BOCHS " [010h 0016 8] Oem Table ID : "BXPCFACP" [018h 0024 4] Oem Revision : 00000001 [01Ch 0028 4] Asl Compiler ID : "BXPC" [020h 0032 4] Asl Compiler Revision : 00000001 [024h 0036 4] FACS Address : 00000000 [028h 0040 4] DSDT Address : 00000000 [02Ch 0044 1] Model : 01 [02Dh 0045 1] PM Profile : 00 [Unspecified] [02Eh 0046 2] SCI Interrupt : 0009 -[030h 0048 4] SMI Command Port : 000000B2 -[034h 0052 1] ACPI Enable Value : 02 -[035h 0053 1] ACPI Disable Value : 03 +[030h 0048 4] SMI Command Port : 00000000 +[034h 0052 1] ACPI Enable Value : 00 +[035h 0053 1] ACPI Disable Value : 00 [036h 0054 1] S4BIOS Command : 00 [037h 0055 1] P-State Control : 00 [038h 0056 4] PM1A Event Block Address : 00000600 [03Ch 0060 4] PM1B Event Block Address : 00000000 [040h 0064 4] PM1A Control Block Address : 00000604 [044h 0068 4] PM1B Control Block Address : 00000000 [048h 0072 4] PM2 Control Block Address : 00000000 [04Ch 0076 4] PM Timer Block Address : 00000608 [050h 0080 4] GPE0 Block Address : 00000620 [054h 0084 4] GPE1 Block Address : 00000000 [058h 0088 1] PM1 Event Block Length : 04 [059h 0089 1] PM1 Control Block Length : 02 [05Ah 0090 1] PM2 Control Block Length : 00 [05Bh 0091 1] PM Timer Block Length : 04 [05Ch 0092 1] GPE0 Block Length : 10 [05Dh 0093 1] GPE1 Block Length : 00Reviewed-by Igor Mammedov <[email protected]>Signed-off-by Isaku Yamahata <[email protected]>--- hw/i386/acpi-build.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)hw/i386/acpi-build.c +8
-0@@ -139,6 +139,14 @@ const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio = {static void init_common_fadt_data (MachineState *ms,Object *o,AcpiFadtData *data) { +X86MachineState *x86ms =X86_MACHINE (ms); +/* +* Until v5, smi_cmd/acpi_enable_cmd/acpi_disable_cmd were always set +* irrelevant to smm_enabled, which doesn't comforms to ACPI spec. +* Keep guest ABI compatibility when smm_compat_5 is true. +*/ +bool smm_enabled = x86ms->smm_compat_5 ? + true :x86_machine_is_smm_enabled (x86ms);uint32_t io =object_property_get_uint (o,ACPI_PM_PROP_PM_IO_BASE ,NULL );AmlAddressSpace as =AML_AS_SYSTEM_IO ;AcpiFadtData fadt = {
hw/i386/acpi-build.c static void init_common_fadt_data(MachineState *ms, Object *o, · line 170
Quoted 5 lines
hw/i386/acpi-build.c +1
-1@@ -159,12 +167,16 @@ static void init_common_fadt_data(MachineState *ms, Object *o, .rtc_century = RTC_CENTURY, .plvl2_lat = 0xfff /* C2 state not supported */, .plvl3_lat = 0xfff /* C3 state not supported */, - .smi_cmd = ACPI_PORT_SMI_CMD, + .smi_cmd = smm_enabled ? ACPI_PORT_SMI_CMD : 0,
I'd fetch smm-compat property from 'o' object (assuming per device compat property)
hw/i386/acpi-build.c static void init_common_fadt_data(MachineState *ms, Object *o, · line 179
Quoted 11 lines
hw/i386/acpi-build.c +6
-2.sci_int = object_property_get_uint(o, ACPI_PM_PROP_SCI_INT, NULL), .acpi_enable_cmd = - object_property_get_uint(o, ACPI_PM_PROP_ACPI_ENABLE_CMD, NULL), + smm_enabled ? +object_property_get_uint (o,ACPI_PM_PROP_ACPI_ENABLE_CMD ,NULL ) : + 0, .acpi_disable_cmd = - object_property_get_uint(o, ACPI_PM_PROP_ACPI_DISABLE_CMD, NULL), + smm_enabled ? +object_property_get_uint (o,ACPI_PM_PROP_ACPI_DISABLE_CMD ,NULL ) : + 0,
for both ACPI_PM_PROP_ACPI_[EN|DIS]ABLE_CMD can return 0 when ich9/piix4 in acpi_only mode
Quoted 3 lines
hw/i386/acpi-build.c +0
-0.pm1a_evt = { .space_id = as, .bit_width = 4 * 8, .address = io }, .pm1a_cnt = { .space_id = as, .bit_width = 2 * 8, .address = io + 0x04 },
Re: [PATCH v3 07/10] hw/i386: declare ACPI mother board resource for MMCONFIG region
In reply to Isaku YamahataQuoted 95 lines · On Wed, 10 Feb 2021 22:46:43 -0800 Isaku Yamahata <[email protected]>…
Declare PNP0C01 device to reserve MMCONFIG region to conform to the spec better and play nice with guest BIOSes/OSes.
According to PCI Firmware Specification[0], MMCONFIG region must be reserved by declaring a motherboard resource. It's optional to reserve the region in memory map by Int 15 E820h or EFIGetMemoryMap. Guest Linux checks if the MMCFG region is reserved by bios memory map or ACPI resource. If it's not reserved, Linux falls back to legacy PCI configuration access.
TDVF [1] [2] doesn't reserve MMCONFIG the region in memory map. On the other hand OVMF reserves it in memory map without declaring a motherboard resource. With memory map reservation, linux guest uses MMCONFIG region. However it doesn't comply to PCI Firmware specification.
[0] PCI Firmware specification Revision 3.2
4.1.2 MCFG Table Description table 4-2 NOTE 2
If the operating system does not natively comprehend reserving the MMCFG region, The MMCFG region must e reserved by firmware. ... For most systems, the mortheroard resource would appear at the root of the ACPI namespace (under \_SB)...
The resource can optionally be returned in Int15 E820h or EFIGetMemoryMap as reserved memory but must always be reported through ACPI as a motherboard resource[1] TDX: Intel Trust Domain Extension
https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html
[2] TDX Virtual Firmware
https://github.com/tianocore/edk2-staging/tree/TDVFThe change to DSDT is as follows.
(quoted diff) +19
-0@@ -68,32 +68,51 @@ If ((CDW3 != Local0)) { CDW1 |= 0x10 } CDW3 = Local0 } Else { CDW1 |= 0x04 } Return (Arg3) } } + + Device (DRAC) + { + Name (_HID, "PNP0C01" /* System Board */) // _HID: Hardware ID + Name (RBUF, ResourceTemplate () + { + QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite, + 0x0000000000000000, // Granularity + 0x00000000B0000000, // Range Minimum + 0x00000000BFFFFFFF, // Range Maximum + 0x0000000000000000, // Translation Offset + 0x0000000010000000, // Length + ,, , AddressRangeMemory, TypeStatic) + }) + Method (_CRS, 0, Serialized) // _CRS: Current Resource Settings + { + Return (RBUF) /* \_SB_.DRAC.RBUF */ + } + } } Scope (_SB) { Device (HPET) { Name (_HID, EisaId ("PNP0103") /* HPET System Timer */) // _HID: Hardware ID Name (_UID, Zero) // _UID: Unique ID OperationRegion (HPTM, SystemMemory, 0xFED00000, 0x0400) Field (HPTM, DWordAcc, Lock, Preserve) { VEND, 32, PRD, 32 } Method (_STA, 0, NotSerialized) // _STA: StatusSigned-off-by Isaku Yamahata <[email protected]>--- hw/i386/acpi-build.c | 46 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-)hw/i386/acpi-build.c +0
-0
hw/i386/acpi-build.c static void build_q35_pci0_int(Aml *table) · line 1077
Quoted 6 lines
hw/i386/acpi-build.c +3
-0@@ -1072,6 +1072,46 @@ static void build_q35_pci0_int(Aml *table)aml_append (table, sb_scope); } +static Aml *build_q35_dram_controller (void ) +{ +AcpiMcfgInfo mcfg;
build_dsdt() already calls acpi_get_mcfg(),
I suggest to cache it there and pass to build_q35_dram_controller as an argument.
Quoted 14 lines
hw/i386/acpi-build.c +14
-0+Aml *dev; +Aml *rbuf; +Aml *resource_template; +Aml *rbuf_name; +Aml *crs; + +if (!acpi_get_mcfg (&mcfg)) { +return NULL ; + } + +/* DRAM controller */ + dev =aml_device ("DRAC" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("PNP0C01" ))); +
hw/i386/acpi-build.c static void build_q35_pci0_int(Aml *table) · line 1101
Quoted 10 lines
hw/i386/acpi-build.c +10
-0+ resource_template =aml_resource_template (); + aml_append(resource_template, + aml_qword_memory(AML_POS_DECODE, + AML_MIN_FIXED, + AML_MAX_FIXED, + AML_NON_CACHEABLE, + AML_READ_WRITE, + 0x0000000000000000, + mcfg.base, + mcfg.base + mcfg.size - 1,
s/mcfg.base + mcfg.size - 1/mcfg.base/
Quoted 17 lines
hw/i386/acpi-build.c +13
-0+0x0000000000000000 , + mcfg.size)); + rbuf =aml_name_decl ("RBUF" , resource_template); +aml_append (dev, rbuf); + + crs =aml_method ("_CRS" ,0 ,AML_SERIALIZED ); + rbuf_name =aml_name ("RBUF" ); +aml_append (crs,aml_return (rbuf_name)); +aml_append (dev, crs); + +return dev; +} +static void build_q35_isa_bridge (Aml *table) {Aml *dev;
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1255
Quoted 5 lines
hw/i386/acpi-build.c +1
-1@@ -1212,7 +1252,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Range *pci_hole, Range *pci_hole64, MachineState *machine) {CrsRangeEntry *entry; -Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs; +Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs, *drac;
maybe limit drac to
if (misc->is_piix4) {
... } else {
Aml *drac
scope
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1302
Quoted 11 lines
hw/i386/acpi-build.c +4
-0CrsRangeSet crs_range_set;PCMachineState *pcms =PC_MACHINE (machine);PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (machine);@@ -1256,6 +1296,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 )));aml_append (dev,build_q35_osc_method ());aml_append (sb_scope, dev); + drac =build_q35_dram_controller (); +if (drac) { +aml_append (sb_scope, drac); + }
mmcfg isn't optional for q35, is it?
I'd simplify to:
aml_append(sb_scope, build_q35_dram_controller(mmcfg_info));
or put all of it under condition if it's optional
if(foo) aml_append(sb_scope, build_q35_dram_controller(mmcfg_info))
Quoted 2 lines
hw/i386/acpi-build.c +0
-0if (pm->smi_on_cpuhp) {/* reserve SMI block resources, IO ports 0xB2, 0xB3 */
Re: [PATCH v3 07/10] hw/i386: declare ACPI mother board resource for MMCONFIG region
Quoted 101 lines · Igor Mammedov
Quoted 98 lines · On Wed, 10 Feb 2021 22:46:43 -0800 Isaku Yamahata <[email protected]>…
Declare PNP0C01 device to reserve MMCONFIG region to conform to the spec better and play nice with guest BIOSes/OSes.
According to PCI Firmware Specification[0], MMCONFIG region must be reserved by declaring a motherboard resource. It's optional to reserve the region in memory map by Int 15 E820h or EFIGetMemoryMap. Guest Linux checks if the MMCFG region is reserved by bios memory map or ACPI resource. If it's not reserved, Linux falls back to legacy PCI configuration access.
TDVF [1] [2] doesn't reserve MMCONFIG the region in memory map. On the other hand OVMF reserves it in memory map without declaring a motherboard resource. With memory map reservation, linux guest uses MMCONFIG region. However it doesn't comply to PCI Firmware specification.
[0] PCI Firmware specification Revision 3.2
4.1.2 MCFG Table Description table 4-2 NOTE 2
If the operating system does not natively comprehend reserving the MMCFG region, The MMCFG region must e reserved by firmware. ... For most systems, the mortheroard resource would appear at the root of the ACPI namespace (under \_SB)...
The resource can optionally be returned in Int15 E820h or EFIGetMemoryMap as reserved memory but must always be reported through ACPI as a motherboard resource[1] TDX: Intel Trust Domain Extension
https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html
[2] TDX Virtual Firmware
https://github.com/tianocore/edk2-staging/tree/TDVFThe change to DSDT is as follows.
(quoted diff) +19
-0@@ -68,32 +68,51 @@ If ((CDW3 != Local0)) { CDW1 |= 0x10 } CDW3 = Local0 } Else { CDW1 |= 0x04 } Return (Arg3) } } + + Device (DRAC) + { + Name (_HID, "PNP0C01" /* System Board */) // _HID: Hardware ID + Name (RBUF, ResourceTemplate () + { + QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite, + 0x0000000000000000, // Granularity + 0x00000000B0000000, // Range Minimum + 0x00000000BFFFFFFF, // Range Maximum + 0x0000000000000000, // Translation Offset + 0x0000000010000000, // Length + ,, , AddressRangeMemory, TypeStatic) + }) + Method (_CRS, 0, Serialized) // _CRS: Current Resource Settings + { + Return (RBUF) /* \_SB_.DRAC.RBUF */ + } + } } Scope (_SB) { Device (HPET) { Name (_HID, EisaId ("PNP0103") /* HPET System Timer */) // _HID: Hardware ID Name (_UID, Zero) // _UID: Unique ID OperationRegion (HPTM, SystemMemory, 0xFED00000, 0x0400) Field (HPTM, DWordAcc, Lock, Preserve) { VEND, 32, PRD, 32 } Method (_STA, 0, NotSerialized) // _STA: StatusSigned-off-by Isaku Yamahata <[email protected]>--- hw/i386/acpi-build.c | 46 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-)hw/i386/acpi-build.c +0
-0@@ -1072,6 +1072,46 @@ static void build_q35_pci0_int(Aml *table)aml_append (table, sb_scope); }
Quoted 6 lines
hw/i386/acpi-build.c static void build_q35_pci0_int(Aml *table) · line 1077
Quoted 3 lines
hw/i386/acpi-build.c +3
-0+static Aml *build_q35_dram_controller (void ) +{ +AcpiMcfgInfo mcfg;
build_dsdt()already callsacpi_get_mcfg(),
I suggest to cache it there and pass tobuild_q35_dram_controlleras an argument.
Sure.
Quoted 17 lines
Quoted 17 lines
hw/i386/acpi-build.c +17
-0+Aml *dev; +Aml *rbuf; +Aml *resource_template; +Aml *rbuf_name; +Aml *crs; + +if (!acpi_get_mcfg (&mcfg)) { +return NULL ; + } + +/* DRAM controller */ + dev =aml_device ("DRAC" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("PNP0C01" ))); + + resource_template =aml_resource_template (); + aml_append(resource_template, + aml_qword_memory(AML_POS_DECODE,
Quoted 8 lines
hw/i386/acpi-build.c static void build_q35_pci0_int(Aml *table) · line 1101
Quoted 7 lines
hw/i386/acpi-build.c +7
-0+AML_MIN_FIXED , +AML_MAX_FIXED , +AML_NON_CACHEABLE , +AML_READ_WRITE , +0x0000000000000000 , + mcfg.base, + mcfg.base + mcfg.size - 1,s/mcfg.base + mcfg.size - 1/mcfg.base/
AddressMaximum needs to be the highest address of the region. Not base address. By disassemble/assembl it, iasl complains as follows. Also there are similar examples in acpi-build.c.
iasl drm-1.dsl
Intel ACPI Component Architecture
ASL+ Optimizing Compiler/Disassembler version 20190509 Copyright (c) 2000 - 2019 Intel Corporation
drm-1.dsl 23: 0x10000000, // Length = 256M
Error 6049 - ^ Length is larger than Min/Max window
ASL Input: drm-1.dsl - 1000 bytes 6 keywords 37 source lines
Compilation failed. 1 Errors, 0 Warnings, 0 Remarks No AML files were generated due to compiler error(s)
Quoted 19 lines
Quoted 19 lines
hw/i386/acpi-build.c +13
-0+0x0000000000000000 , + mcfg.size)); + rbuf =aml_name_decl ("RBUF" , resource_template); +aml_append (dev, rbuf); + + crs =aml_method ("_CRS" ,0 ,AML_SERIALIZED ); + rbuf_name =aml_name ("RBUF" ); +aml_append (crs,aml_return (rbuf_name)); +aml_append (dev, crs); + +return dev; +} +static void build_q35_isa_bridge (Aml *table) {Aml *dev;@@ -1212,7 +1252,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Range *pci_hole, Range *pci_hole64, MachineState *machine) {
Quoted 8 lines
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1255
Quoted 3 lines
hw/i386/acpi-build.c +1
-1CrsRangeEntry *entry; -Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs; +Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs, *drac;maybe limit drac to
if (misc->is_piix4) {
... } else {
Aml *drac
scope
ok.
Quoted 13 lines
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1302
Quoted 11 lines
hw/i386/acpi-build.c +4
-0CrsRangeSet crs_range_set;PCMachineState *pcms =PC_MACHINE (machine);PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (machine);@@ -1256,6 +1296,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 )));aml_append (dev,build_q35_osc_method ());aml_append (sb_scope, dev); + drac =build_q35_dram_controller (); +if (drac) { +aml_append (sb_scope, drac); + }mmcfg isn't optional for q35, is it?
I'd simplify to:
Quoted 3 lines
aml_append(sb_scope, build_q35_dram_controller(mmcfg_info));or put all of it under condition if it's optional
if(foo)aml_append(sb_scope, build_q35_dram_controller(mmcfg_info))
It's optional. If MCFG isn't setup after reset, PCIE_BASE_ADDR_UNMAPPED is returned.
Signature · 1 line
Isaku Yamahata <[email protected]>
Re: [PATCH v3 07/10] hw/i386: declare ACPI mother board resource for MMCONFIG region
Quoted 140 lines · On Fri, 12 Feb 2021 12:51:57 -0800 Isaku Yamahata <[email protected]>…
Quoted 101 lines · Igor Mammedov
Quoted 98 lines · On Wed, 10 Feb 2021 22:46:43 -0800 Isaku Yamahata <[email protected]>…
Declare PNP0C01 device to reserve MMCONFIG region to conform to the spec better and play nice with guest BIOSes/OSes.
According to PCI Firmware Specification[0], MMCONFIG region must be reserved by declaring a motherboard resource. It's optional to reserve the region in memory map by Int 15 E820h or EFIGetMemoryMap. Guest Linux checks if the MMCFG region is reserved by bios memory map or ACPI resource. If it's not reserved, Linux falls back to legacy PCI configuration access.
TDVF [1] [2] doesn't reserve MMCONFIG the region in memory map. On the other hand OVMF reserves it in memory map without declaring a motherboard resource. With memory map reservation, linux guest uses MMCONFIG region. However it doesn't comply to PCI Firmware specification.
[0] PCI Firmware specification Revision 3.2
4.1.2 MCFG Table Description table 4-2 NOTE 2
If the operating system does not natively comprehend reserving the MMCFG region, The MMCFG region must e reserved by firmware. ... For most systems, the mortheroard resource would appear at the root of the ACPI namespace (under \_SB)...
The resource can optionally be returned in Int15 E820h or EFIGetMemoryMap as reserved memory but must always be reported through ACPI as a motherboard resource[1] TDX: Intel Trust Domain Extension
https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html
[2] TDX Virtual Firmware
https://github.com/tianocore/edk2-staging/tree/TDVFThe change to DSDT is as follows.
(quoted diff) +19
-0@@ -68,32 +68,51 @@ If ((CDW3 != Local0)) { CDW1 |= 0x10 } CDW3 = Local0 } Else { CDW1 |= 0x04 } Return (Arg3) } } + + Device (DRAC) + { + Name (_HID, "PNP0C01" /* System Board */) // _HID: Hardware ID + Name (RBUF, ResourceTemplate () + { + QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite, + 0x0000000000000000, // Granularity + 0x00000000B0000000, // Range Minimum + 0x00000000BFFFFFFF, // Range Maximum + 0x0000000000000000, // Translation Offset + 0x0000000010000000, // Length + ,, , AddressRangeMemory, TypeStatic) + }) + Method (_CRS, 0, Serialized) // _CRS: Current Resource Settings + { + Return (RBUF) /* \_SB_.DRAC.RBUF */ + } + } } Scope (_SB) { Device (HPET) { Name (_HID, EisaId ("PNP0103") /* HPET System Timer */) // _HID: Hardware ID Name (_UID, Zero) // _UID: Unique ID OperationRegion (HPTM, SystemMemory, 0xFED00000, 0x0400) Field (HPTM, DWordAcc, Lock, Preserve) { VEND, 32, PRD, 32 } Method (_STA, 0, NotSerialized) // _STA: StatusSigned-off-by Isaku Yamahata <[email protected]>--- hw/i386/acpi-build.c | 46 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-)hw/i386/acpi-build.c +0
-0@@ -1072,6 +1072,46 @@ static void build_q35_pci0_int(Aml *table)aml_append (table, sb_scope); }Quoted 6 lines
hw/i386/acpi-build.c static void build_q35_pci0_int(Aml *table) · line 1077
Quoted 3 lines
hw/i386/acpi-build.c +3
-0+static Aml *build_q35_dram_controller (void ) +{ +AcpiMcfgInfo mcfg;
build_dsdt()already callsacpi_get_mcfg(),
I suggest to cache it there and pass tobuild_q35_dram_controlleras an argument.Sure.
Quoted 17 lines
Quoted 17 lines
hw/i386/acpi-build.c +17
-0+Aml *dev; +Aml *rbuf; +Aml *resource_template; +Aml *rbuf_name; +Aml *crs; + +if (!acpi_get_mcfg (&mcfg)) { +return NULL ; + } + +/* DRAM controller */ + dev =aml_device ("DRAC" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("PNP0C01" ))); + + resource_template =aml_resource_template (); + aml_append(resource_template, + aml_qword_memory(AML_POS_DECODE,Quoted 8 lines
hw/i386/acpi-build.c static void build_q35_pci0_int(Aml *table) · line 1101
Quoted 7 lines
hw/i386/acpi-build.c +7
-0+AML_MIN_FIXED , +AML_MAX_FIXED , +AML_NON_CACHEABLE , +AML_READ_WRITE , +0x0000000000000000 , + mcfg.base, + mcfg.base + mcfg.size - 1,s/mcfg.base + mcfg.size - 1/mcfg.base/
Quoted 3 lines
AddressMaximum needs to be the highest address of the region. Not base address. By disassemble/assembl it, iasl complains as follows. Also there are similar examples in
acpi-build.c.
I mostly clean up all places to use the same base address for min/max, but probably something were left behind.
spec says:
acpi 6.3: 19.6.110 QWordMemory
AddressMaximum evaluates to a 64-bit integer that specifies the highest possible base address of the Memory range. The value must have ‘0’ in all bits where the corresponding bit in AddressGranularity is ‘1’. For bridge devices which translate addresses, this is the address on the secondary bus. The 64-bit field DescriptorName ._MAX is automatically created to refer to this portion of the resource descriptor.
Quoted 63 lines
iasl drm-1.dsl
Intel ACPI Component Architecture
ASL+ Optimizing Compiler/Disassembler version 20190509 Copyright (c) 2000 - 2019 Intel Corporationdrm-1.dsl 23:
0x10000000, // Length = 256M
Error 6049 - ^ Length is larger than Min/Max windowASL Input: drm-1.dsl - 1000 bytes 6 keywords 37 source lines
Compilation failed. 1 Errors, 0 Warnings, 0 Remarks No AML files were generated due to compiler error(s)
Quoted 19 lines
Quoted 19 lines
hw/i386/acpi-build.c +13
-0+0x0000000000000000 , + mcfg.size)); + rbuf =aml_name_decl ("RBUF" , resource_template); +aml_append (dev, rbuf); + + crs =aml_method ("_CRS" ,0 ,AML_SERIALIZED ); + rbuf_name =aml_name ("RBUF" ); +aml_append (crs,aml_return (rbuf_name)); +aml_append (dev, crs); + +return dev; +} +static void build_q35_isa_bridge (Aml *table) {Aml *dev;@@ -1212,7 +1252,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Range *pci_hole, Range *pci_hole64, MachineState *machine) {Quoted 8 lines
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1255
Quoted 3 lines
hw/i386/acpi-build.c +1
-1CrsRangeEntry *entry; -Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs; +Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs, *drac;maybe limit drac to
if (misc->is_piix4) {
... } else {
Aml *drac
scopeok.
Quoted 13 lines
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1302
Quoted 11 lines
hw/i386/acpi-build.c +4
-0CrsRangeSet crs_range_set;PCMachineState *pcms =PC_MACHINE (machine);PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (machine);@@ -1256,6 +1296,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 )));aml_append (dev,build_q35_osc_method ());aml_append (sb_scope, dev); + drac =build_q35_dram_controller (); +if (drac) { +aml_append (sb_scope, drac); + }mmcfg isn't optional for q35, is it?
I'd simplify to:Quoted 3 lines
aml_append(sb_scope, build_q35_dram_controller(mmcfg_info));or put all of it under condition if it's optional
if(foo)aml_append(sb_scope, build_q35_dram_controller(mmcfg_info))
Quoted 2 lines
It's optional. If MCFG isn't setup after reset,
PCIE_BASE_ADDR_UNMAPPEDis returned.
ok
Re: [PATCH v3 07/10] hw/i386: declare ACPI mother board resource for MMCONFIG region
Quoted 41 lines · Igor Mammedov
Quoted 32 lines · On Fri, 12 Feb 2021 12:51:57 -0800 Isaku Yamahata <[email protected]>…
Quoted 20 lines · Igor Mammedov
Quoted 17 lines · On Wed, 10 Feb 2021 22:46:43 -0800 Isaku Yamahata <[email protected]>…
hw/i386/acpi-build.c +17
-0+Aml *dev; +Aml *rbuf; +Aml *resource_template; +Aml *rbuf_name; +Aml *crs; + +if (!acpi_get_mcfg (&mcfg)) { +return NULL ; + } + +/* DRAM controller */ + dev =aml_device ("DRAC" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("PNP0C01" ))); + + resource_template =aml_resource_template (); + aml_append(resource_template, + aml_qword_memory(AML_POS_DECODE,Quoted 8 lines
hw/i386/acpi-build.c static void build_q35_pci0_int(Aml *table) · line 1101
Quoted 7 lines
hw/i386/acpi-build.c +7
-0+AML_MIN_FIXED , +AML_MAX_FIXED , +AML_NON_CACHEABLE , +AML_READ_WRITE , +0x0000000000000000 , + mcfg.base, + mcfg.base + mcfg.size - 1,s/mcfg.base + mcfg.size - 1/mcfg.base/
Quoted 3 lines
AddressMaximum needs to be the highest address of the region. Not base address. By disassemble/assembl it, iasl complains as follows. Also there are similar examples in
acpi-build.c.I mostly clean up all places to use the same base address for min/max, but probably something were left behind.
Quoted 8 lines
spec says:
acpi 6.3: 19.6.110 QWordMemory
AddressMaximum evaluates to a 64-bit integer that specifies the highest possible base address of the Memory range. The value must have ‘0’ in all bits where the corresponding bit in AddressGranularity is ‘1’. For bridge devices which translate addresses, this is the address on the secondary bus. The 64-bit field DescriptorName ._MAX is automatically created to refer to this portion of the resource descriptor.
Ok, Linux guest is happy with min=max.
I conlude that it's iasl issue.
Thanks,
Signature · 1 line
Isaku Yamahata <[email protected]>
Re: [PATCH v3 07/10] hw/i386: declare ACPI mother board resource for MMCONFIG region
Quoted 53 lines · Isaku Yamahata
Quoted 41 lines · Igor Mammedov
Quoted 32 lines · On Fri, 12 Feb 2021 12:51:57 -0800 Isaku Yamahata <[email protected]>…
Quoted 20 lines · Igor Mammedov
Quoted 17 lines · On Wed, 10 Feb 2021 22:46:43 -0800 Isaku Yamahata <[email protected]>…
hw/i386/acpi-build.c +17
-0+Aml *dev; +Aml *rbuf; +Aml *resource_template; +Aml *rbuf_name; +Aml *crs; + +if (!acpi_get_mcfg (&mcfg)) { +return NULL ; + } + +/* DRAM controller */ + dev =aml_device ("DRAC" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("PNP0C01" ))); + + resource_template =aml_resource_template (); + aml_append(resource_template, + aml_qword_memory(AML_POS_DECODE,Quoted 8 lines
hw/i386/acpi-build.c static void build_q35_pci0_int(Aml *table) · line 1101
Quoted 7 lines
hw/i386/acpi-build.c +7
-0+AML_MIN_FIXED , +AML_MAX_FIXED , +AML_NON_CACHEABLE , +AML_READ_WRITE , +0x0000000000000000 , + mcfg.base, + mcfg.base + mcfg.size - 1,s/mcfg.base + mcfg.size - 1/mcfg.base/
Quoted 3 lines
AddressMaximum needs to be the highest address of the region. Not base address. By disassemble/assembl it, iasl complains as follows. Also there are similar examples in
acpi-build.c.I mostly clean up all places to use the same base address for min/max, but probably something were left behind.
Quoted 8 lines
spec says:
acpi 6.3: 19.6.110 QWordMemory
AddressMaximum evaluates to a 64-bit integer that specifies the highest possible base address of the Memory range. The value must have ‘0’ in all bits where the corresponding bit in AddressGranularity is ‘1’. For bridge devices which translate addresses, this is the address on the secondary bus. The 64-bit field DescriptorName ._MAX is automatically created to refer to this portion of the resource descriptor.
Quoted 4 lines
Ok, Linux guest is happy with min=max.
I conlude that it's iasl issue.Thanks,
OK but what about all the other places in the code that seem to use this field differently?
Signature · 1 line
MST
Re: [PATCH v3 07/10] hw/i386: declare ACPI mother board resource for MMCONFIG region
Quoted 54 lines · Michael S. Tsirkin
Quoted 53 lines · Isaku Yamahata
Quoted 49 lines · Igor Mammedov
Quoted 32 lines · On Fri, 12 Feb 2021 12:51:57 -0800 Isaku Yamahata <[email protected]>…
Quoted 20 lines · Igor Mammedov
Quoted 17 lines · On Wed, 10 Feb 2021 22:46:43 -0800 Isaku Yamahata <[email protected]>…
hw/i386/acpi-build.c +17
-0+Aml *dev; +Aml *rbuf; +Aml *resource_template; +Aml *rbuf_name; +Aml *crs; + +if (!acpi_get_mcfg (&mcfg)) { +return NULL ; + } + +/* DRAM controller */ + dev =aml_device ("DRAC" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("PNP0C01" ))); + + resource_template =aml_resource_template (); + aml_append(resource_template, + aml_qword_memory(AML_POS_DECODE,Quoted 8 lines
hw/i386/acpi-build.c static void build_q35_pci0_int(Aml *table) · line 1101
Quoted 7 lines
hw/i386/acpi-build.c +7
-0+AML_MIN_FIXED , +AML_MAX_FIXED , +AML_NON_CACHEABLE , +AML_READ_WRITE , +0x0000000000000000 , + mcfg.base, + mcfg.base + mcfg.size - 1,s/mcfg.base + mcfg.size - 1/mcfg.base/
Quoted 3 lines
AddressMaximum needs to be the highest address of the region. Not base address. By disassemble/assembl it, iasl complains as follows. Also there are similar examples in
acpi-build.c.I mostly clean up all places to use the same base address for min/max, but probably something were left behind.
spec says:
acpi 6.3: 19.6.110 QWordMemory
AddressMaximum evaluates to a 64-bit integer that specifies the highest possible base address of the Memory range. The value must have ‘0’ in all bits where the corresponding bit in AddressGranularity is ‘1’. For bridge devices which translate addresses, this is the address on the secondary bus. The 64-bit field DescriptorName ._MAX is automatically created to refer to this portion of the resource descriptor.
Quoted 7 lines
Quoted 4 lines
Ok, Linux guest is happy with min=max.
I conlude that it's iasl issue.Thanks,
OK but what about all the other places in the code that seem to use this field differently?
Igor, what do you think?
The followings are the summary of the situation.
- acpi 6.4: 19.6.110 QWordMemory
_MAX: maximum of base address.
- acpi 6.4: 6.4.3.5 Address Space Resource Descriptors table 6.44
If _LEN > 0 and _MIF = 1 and _MAF = 1, then _LEN = _MAX - _MIN + 1 This doesn't match with the above description
- iasl
If _LEN > 0 and _MIF = 1 and _MAF = 1,
it emits warning on _LEN != _MAX - _MIN + 1
- Linux Guest MMCONFIG check check_mcfg_resoure() uses only _MIN. doesn't use _MAX. _MAX value doesn't matter
- Linux acpi code
acpi_decode_space() uses _MAX to calulate range [start, end], not use _LEN. i.e. It assumes _LEN = _MAX - _MIN + 1 if _LEN > 0, _MIF = 1, _MAF = 1
- qemu code sets for [qd]word_memory_resource (except this patch) If _LEN > 0 and _MIF = 1 and _MAF = 1, then set _LEN = _MAX - _MIN + 1
Signature · 1 line
Isaku Yamahata <[email protected]>
Re: [PATCH v3 07/10] hw/i386: declare ACPI mother board resource for MMCONFIG region
Quoted 68 lines · On Tue, 16 Feb 2021 10:13:25 -0800 Isaku Yamahata <[email protected]>…
Quoted 54 lines · Michael S. Tsirkin
Quoted 53 lines · Isaku Yamahata
Quoted 49 lines · Igor Mammedov
Quoted 32 lines · On Fri, 12 Feb 2021 12:51:57 -0800 Isaku Yamahata <[email protected]>…
Quoted 20 lines · Igor Mammedov
Quoted 17 lines · On Wed, 10 Feb 2021 22:46:43 -0800 Isaku Yamahata <[email protected]>…
(quoted diff) +17
-0+ Aml *dev; + Aml *rbuf; + Aml *resource_template; + Aml *rbuf_name; + Aml *crs; + + if (!acpi_get_mcfg(&mcfg)) { + return NULL; + } + + /* DRAM controller */ + dev = aml_device("DRAC"); + aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C01"))); + + resource_template = aml_resource_template(); + aml_append(resource_template, + aml_qword_memory(AML_POS_DECODE,Quoted 8 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+ AML_MIN_FIXED, + AML_MAX_FIXED, + AML_NON_CACHEABLE, + AML_READ_WRITE, + 0x0000000000000000, + mcfg.base, + mcfg.base + mcfg.size - 1,s/mcfg.base + mcfg.size - 1/mcfg.base/
Quoted 3 lines
AddressMaximum needs to be the highest address of the region. Not base address. By disassemble/assembl it, iasl complains as follows. Also there are similar examples in
acpi-build.c.I mostly clean up all places to use the same base address for min/max, but probably something were left behind.
spec says:
acpi 6.3: 19.6.110 QWordMemory
AddressMaximum evaluates to a 64-bit integer that specifies the highest possible base address of the Memory range. The value must have ‘0’ in all bits where the corresponding bit in AddressGranularity is ‘1’. For bridge devices which translate addresses, this is the address on the secondary bus. The 64-bit field DescriptorName ._MAX is automatically created to refer to this portion of the resource descriptor.
Quoted 7 lines
Quoted 4 lines
Ok, Linux guest is happy with min=max.
I conlude that it's iasl issue.Thanks,
OK but what about all the other places in the code that seem to use this field differently?
Igor, what do you think?
The followings are the summary of the situation.
Quoted 7 lines
- acpi 6.4: 19.6.110 QWordMemory
_MAX: maximum of base address.- acpi 6.4: 6.4.3.5 Address Space Resource Descriptors table 6.44
If_LEN> 0 and_MIF= 1 and_MAF= 1, then_LEN=_MAX-_MIN+ 1 This doesn't match with the above description
I'd say it 19.6.110 doesn't describes whole possibilities of resource, but only subset in its current phrasing.
Quoted 3 lines
- iasl
If_LEN> 0 and_MIF= 1 and_MAF= 1,
it emits warning on_LEN!=_MAX-_MIN+ 1
so IASL is right and follows spec.
Anyways, My apologies for misleading and your patch is correct.
I need to add similar checks to QEMU code plus comments to avoid confusion in future.
Quoted 10 lines
- Linux Guest MMCONFIG check
check_mcfg_resoure()uses only_MIN. doesn't use_MAX._MAXvalue doesn't matter- Linux acpi code
acpi_decode_space()uses_MAXto calulate range [start, end], not use_LEN. i.e. It assumes_LEN=_MAX-_MIN+ 1 if_LEN> 0,_MIF= 1,_MAF= 1- qemu code sets for [qd]word_memory_resource (except this patch) If
_LEN> 0 and_MIF= 1 and_MAF= 1, then set_LEN=_MAX-_MIN+ 1