Skip to content

Commit 51db2d7

Browse files
committed
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
pc,virtio,pci: fixes, tests Fixes all over the place, a new test. Signed-off-by: Michael S. Tsirkin <[email protected]> # gpg: Signature made Tue 23 Feb 2021 16:00:29 GMT # gpg: using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469 # gpg: issuer "[email protected]" # gpg: Good signature from "Michael S. Tsirkin <[email protected]>" [full] # gpg: aka "Michael S. Tsirkin <[email protected]>" [full] # Primary key fingerprint: 0270 606B 6F3C DF3D 0B17 0970 C350 3912 AFBE 8E67 # Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA 8A0D 281F 0DB8 D28D 5469 * remotes/mst/tags/for_upstream: qtest/acpi/bios-tables-test: update acpi tables acpi: add test case for -no-hpet i386: acpi: Don't build HPET ACPI entry if HPET is disabled hw/i386: declare ACPI mother board resource for MMCONFIG region acpi: add test case for smm unsupported -machine smm=off acpi: set fadt.smi_cmd to zero when SMM is not supported acpi/core: always set SCI_EN when SMM isn't supported ich9, piix4: add property, smm-compat, to keep compatibility of SMM qtest: update tests/qtest/bios-tables-test-allowed-diff.h checkpatch: don't emit warning on newly created acpi data files tests/data/acpi/virt/DSDT.pxb: update with _CCA acpi/gpex: Fix cca attribute check for pxb device acpi: Allow pxb DSDT acpi table changes pcie: don't set link state active if the slot is empty failover: really display a warning when the primary device is not found virtio-net: add missing object_unref() pci: cleanup failover sanity check Signed-off-by: Peter Maydell <[email protected]>
2 parents 7ef8134 + 7b630d9 commit 51db2d7

30 files changed

+215
-36
lines changed

hw/acpi/core.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,10 @@ void acpi_pm1_cnt_update(ACPIREGS *ar,
579579
bool sci_enable, bool sci_disable)
580580
{
581581
/* ACPI specs 3.0, 4.7.2.5 */
582+
if (ar->pm1.cnt.acpi_only) {
583+
return;
584+
}
585+
582586
if (sci_enable) {
583587
ar->pm1.cnt.cnt |= ACPI_BITMASK_SCI_ENABLE;
584588
} else if (sci_disable) {
@@ -608,11 +612,13 @@ static const MemoryRegionOps acpi_pm_cnt_ops = {
608612
};
609613

610614
void acpi_pm1_cnt_init(ACPIREGS *ar, MemoryRegion *parent,
611-
bool disable_s3, bool disable_s4, uint8_t s4_val)
615+
bool disable_s3, bool disable_s4, uint8_t s4_val,
616+
bool acpi_only)
612617
{
613618
FWCfgState *fw_cfg;
614619

615620
ar->pm1.cnt.s4_val = s4_val;
621+
ar->pm1.cnt.acpi_only = acpi_only;
616622
ar->wakeup.notify = acpi_notify_wakeup;
617623
qemu_register_wakeup_notifier(&ar->wakeup);
618624

@@ -638,6 +644,9 @@ void acpi_pm1_cnt_init(ACPIREGS *ar, MemoryRegion *parent,
638644
void acpi_pm1_cnt_reset(ACPIREGS *ar)
639645
{
640646
ar->pm1.cnt.cnt = 0;
647+
if (ar->pm1.cnt.acpi_only) {
648+
ar->pm1.cnt.cnt |= ACPI_BITMASK_SCI_ENABLE;
649+
}
641650
}
642651

643652
/* ACPI GPE */

hw/acpi/ich9.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
282282
acpi_pm_tmr_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);
283283
acpi_pm1_evt_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);
284284
acpi_pm1_cnt_init(&pm->acpi_regs, &pm->io, pm->disable_s3, pm->disable_s4,
285-
pm->s4_val);
285+
pm->s4_val, !pm->smm_compat && !smm_enabled);
286286

287287
acpi_gpe_init(&pm->acpi_regs, ICH9_PMIO_GPE0_LEN);
288288
memory_region_init_io(&pm->io_gpe, OBJECT(lpc_pci), &ich9_gpe_ops, pm,

hw/acpi/piix4.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct PIIX4PMState {
7474
qemu_irq irq;
7575
qemu_irq smi_irq;
7676
int smm_enabled;
77+
bool smm_compat;
7778
Notifier machine_ready;
7879
Notifier powerdown_notifier;
7980

@@ -496,7 +497,8 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)
496497

497498
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
498499
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
499-
acpi_pm1_cnt_init(&s->ar, &s->io, s->disable_s3, s->disable_s4, s->s4_val);
500+
acpi_pm1_cnt_init(&s->ar, &s->io, s->disable_s3, s->disable_s4, s->s4_val,
501+
!s->smm_compat && !s->smm_enabled);
500502
acpi_gpe_init(&s->ar, GPE_LEN);
501503

502504
s->powerdown_notifier.notify = piix4_pm_powerdown_req;
@@ -642,6 +644,7 @@ static Property piix4_pm_properties[] = {
642644
use_acpi_root_pci_hotplug, true),
643645
DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
644646
acpi_memory_hotplug.is_enabled, true),
647+
DEFINE_PROP_BOOL("smm-compat", PIIX4PMState, smm_compat, false),
645648
DEFINE_PROP_END_OF_LIST(),
646649
};
647650

hw/core/machine.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
#include "hw/virtio/virtio.h"
3737
#include "hw/virtio/virtio-pci.h"
3838

39-
GlobalProperty hw_compat_5_2[] = {};
39+
GlobalProperty hw_compat_5_2[] = {
40+
{ "ICH9-LPC", "smm-compat", "on"},
41+
{ "PIIX4_PM", "smm-compat", "on"},
42+
};
4043
const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
4144

4245
GlobalProperty hw_compat_5_1[] = {

hw/i386/acpi-build.c

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio = {
139139
static void init_common_fadt_data(MachineState *ms, Object *o,
140140
AcpiFadtData *data)
141141
{
142+
X86MachineState *x86ms = X86_MACHINE(ms);
143+
/*
144+
* "ICH9-LPC" or "PIIX4_PM" has "smm-compat" property to keep the old
145+
* behavior for compatibility irrelevant to smm_enabled, which doesn't
146+
* comforms to ACPI spec.
147+
*/
148+
bool smm_enabled = object_property_get_bool(o, "smm-compat", NULL) ?
149+
true : x86_machine_is_smm_enabled(x86ms);
142150
uint32_t io = object_property_get_uint(o, ACPI_PM_PROP_PM_IO_BASE, NULL);
143151
AmlAddressSpace as = AML_AS_SYSTEM_IO;
144152
AcpiFadtData fadt = {
@@ -159,12 +167,16 @@ static void init_common_fadt_data(MachineState *ms, Object *o,
159167
.rtc_century = RTC_CENTURY,
160168
.plvl2_lat = 0xfff /* C2 state not supported */,
161169
.plvl3_lat = 0xfff /* C3 state not supported */,
162-
.smi_cmd = ACPI_PORT_SMI_CMD,
170+
.smi_cmd = smm_enabled ? ACPI_PORT_SMI_CMD : 0,
163171
.sci_int = object_property_get_uint(o, ACPI_PM_PROP_SCI_INT, NULL),
164172
.acpi_enable_cmd =
165-
object_property_get_uint(o, ACPI_PM_PROP_ACPI_ENABLE_CMD, NULL),
173+
smm_enabled ?
174+
object_property_get_uint(o, ACPI_PM_PROP_ACPI_ENABLE_CMD, NULL) :
175+
0,
166176
.acpi_disable_cmd =
167-
object_property_get_uint(o, ACPI_PM_PROP_ACPI_DISABLE_CMD, NULL),
177+
smm_enabled ?
178+
object_property_get_uint(o, ACPI_PM_PROP_ACPI_DISABLE_CMD, NULL) :
179+
0,
168180
.pm1a_evt = { .space_id = as, .bit_width = 4 * 8, .address = io },
169181
.pm1a_cnt = { .space_id = as, .bit_width = 2 * 8,
170182
.address = io + 0x04 },
@@ -1060,6 +1072,46 @@ static void build_q35_pci0_int(Aml *table)
10601072
aml_append(table, sb_scope);
10611073
}
10621074

1075+
static Aml *build_q35_dram_controller(const AcpiMcfgInfo *mcfg)
1076+
{
1077+
Aml *dev;
1078+
Aml *resource_template;
1079+
1080+
/* DRAM controller */
1081+
dev = aml_device("DRAC");
1082+
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C01")));
1083+
1084+
resource_template = aml_resource_template();
1085+
if (mcfg->base + mcfg->size - 1 >= (1ULL << 32)) {
1086+
aml_append(resource_template,
1087+
aml_qword_memory(AML_POS_DECODE,
1088+
AML_MIN_FIXED,
1089+
AML_MAX_FIXED,
1090+
AML_NON_CACHEABLE,
1091+
AML_READ_WRITE,
1092+
0x0000000000000000,
1093+
mcfg->base,
1094+
mcfg->base + mcfg->size - 1,
1095+
0x0000000000000000,
1096+
mcfg->size));
1097+
} else {
1098+
aml_append(resource_template,
1099+
aml_dword_memory(AML_POS_DECODE,
1100+
AML_MIN_FIXED,
1101+
AML_MAX_FIXED,
1102+
AML_NON_CACHEABLE,
1103+
AML_READ_WRITE,
1104+
0x0000000000000000,
1105+
mcfg->base,
1106+
mcfg->base + mcfg->size - 1,
1107+
0x0000000000000000,
1108+
mcfg->size));
1109+
}
1110+
aml_append(dev, aml_name_decl("_CRS", resource_template));
1111+
1112+
return dev;
1113+
}
1114+
10631115
static void build_q35_isa_bridge(Aml *table)
10641116
{
10651117
Aml *dev;
@@ -1206,6 +1258,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
12061258
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
12071259
X86MachineState *x86ms = X86_MACHINE(machine);
12081260
AcpiMcfgInfo mcfg;
1261+
bool mcfg_valid = !!acpi_get_mcfg(&mcfg);
12091262
uint32_t nr_mem = machine->ram_slots;
12101263
int root_bus_limit = 0xFF;
12111264
PCIBus *bus = NULL;
@@ -1228,7 +1281,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
12281281
aml_append(sb_scope, dev);
12291282
aml_append(dsdt, sb_scope);
12301283

1231-
build_hpet_aml(dsdt);
1284+
if (misc->has_hpet) {
1285+
build_hpet_aml(dsdt);
1286+
}
12321287
build_piix4_isa_bridge(dsdt);
12331288
build_isa_devices_aml(dsdt);
12341289
if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
@@ -1244,6 +1299,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
12441299
aml_append(dev, aml_name_decl("_UID", aml_int(0)));
12451300
aml_append(dev, build_q35_osc_method());
12461301
aml_append(sb_scope, dev);
1302+
if (mcfg_valid) {
1303+
aml_append(sb_scope, build_q35_dram_controller(&mcfg));
1304+
}
12471305

12481306
if (pm->smi_on_cpuhp) {
12491307
/* reserve SMI block resources, IO ports 0xB2, 0xB3 */
@@ -1272,7 +1330,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
12721330

12731331
aml_append(dsdt, sb_scope);
12741332

1275-
build_hpet_aml(dsdt);
1333+
if (misc->has_hpet) {
1334+
build_hpet_aml(dsdt);
1335+
}
12761336
build_q35_isa_bridge(dsdt);
12771337
build_isa_devices_aml(dsdt);
12781338
build_q35_pci0_int(dsdt);
@@ -1374,7 +1434,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
13741434
* the PCI0._CRS. Add mmconfig to the set so it will be excluded
13751435
* too.
13761436
*/
1377-
if (acpi_get_mcfg(&mcfg)) {
1437+
if (mcfg_valid) {
13781438
crs_range_insert(crs_range_set.mem_ranges,
13791439
mcfg.base, mcfg.base + mcfg.size - 1);
13801440
}

hw/isa/lpc_ich9.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ static const VMStateDescription vmstate_ich9_lpc = {
775775

776776
static Property ich9_lpc_properties[] = {
777777
DEFINE_PROP_BOOL("noreboot", ICH9LPCState, pin_strap.spkr_hi, true),
778+
DEFINE_PROP_BOOL("smm-compat", ICH9LPCState, pm.smm_compat, false),
778779
DEFINE_PROP_BIT64("x-smi-broadcast", ICH9LPCState, smi_host_features,
779780
ICH9_LPC_SMI_F_BROADCAST_BIT, true),
780781
DEFINE_PROP_BIT64("x-smi-cpu-hotplug", ICH9LPCState, smi_host_features,

hw/isa/vt82c686.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static void via_pm_realize(PCIDevice *dev, Error **errp)
190190

191191
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
192192
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
193-
acpi_pm1_cnt_init(&s->ar, &s->io, false, false, 2);
193+
acpi_pm1_cnt_init(&s->ar, &s->io, false, false, 2, false);
194194
}
195195

196196
typedef struct via_pm_init_info {

hw/net/virtio-net.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -855,19 +855,19 @@ static void failover_add_primary(VirtIONet *n, Error **errp)
855855

856856
id = failover_find_primary_device_id(n);
857857
if (!id) {
858+
error_setg(errp, "Primary device not found");
859+
error_append_hint(errp, "Virtio-net failover will not work. Make "
860+
"sure primary device has parameter"
861+
" failover_pair_id=%s\n", n->netclient_name);
858862
return;
859863
}
860864
opts = qemu_opts_find(qemu_find_opts("device"), id);
861-
if (opts) {
862-
dev = qdev_device_add(opts, &err);
863-
if (err) {
864-
qemu_opts_del(opts);
865-
}
865+
g_assert(opts); /* cannot be NULL because id was found using opts list */
866+
dev = qdev_device_add(opts, &err);
867+
if (err) {
868+
qemu_opts_del(opts);
866869
} else {
867-
error_setg(errp, "Primary device not found");
868-
error_append_hint(errp, "Virtio-net failover will not work. Make "
869-
"sure primary device has parameter"
870-
" failover_pair_id=<virtio-net-id>\n");
870+
object_unref(OBJECT(dev));
871871
}
872872
error_propagate(errp, err);
873873
}

hw/pci-host/gpex-acpi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)
175175
aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num)));
176176
aml_append(dev, aml_name_decl("_UID", aml_int(bus_num)));
177177
aml_append(dev, aml_name_decl("_STR", aml_unicode("pxb Device")));
178+
aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
178179
if (numa_node != NUMA_NODE_UNASSIGNED) {
179180
aml_append(dev, aml_name_decl("_PXM", aml_int(numa_node)));
180181
}

hw/pci/pci.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,10 +2127,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
21272127
pci_qdev_unrealize(DEVICE(pci_dev));
21282128
return;
21292129
}
2130-
if (!(pci_dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION)
2131-
&& (PCI_FUNC(pci_dev->devfn) == 0)) {
2132-
qdev->allow_unplug_during_migration = true;
2133-
} else {
2130+
if ((pci_dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION)
2131+
|| (PCI_FUNC(pci_dev->devfn) != 0)) {
21342132
error_setg(errp, "failover: primary device must be in its own "
21352133
"PCI slot");
21362134
pci_qdev_unrealize(DEVICE(pci_dev));

0 commit comments

Comments
 (0)