pc: acpi: revert back to 5.2 PCI slot enumeration
cover pc: acpi: revert back to 5.2 PCI slot enumeration
Commit b7f23f62e40 (pci: acpi: add _DSM method to PCI devices), regressed network interface naming for Linux guests in some cases. This reverts PCI slot enumeration to its state before 6.0. For details see 2/3 patch.
Thanks Stefan for troubleshooting!
Igor Mammedov (2):
tests: acpi: prepare for changing DSDT tables
acpi: pc: revert back to v5.2 PCI slot enumeration
tests/qtest/bios-tables-test-allowed-diff.h | 10 ++++++++++ hw/i386/acpi-build.c | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/2 tests: acpi: prepare for changing DSDT tables
--- tests/qtest/bios-tables-test-allowed-diff.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +10 -0
@@ -1 +1,11 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.ipmikcs" , +"tests/data/acpi/pc/DSDT.cphp" , +"tests/data/acpi/pc/DSDT.memhp" , +"tests/data/acpi/pc/DSDT.numamem" , +"tests/data/acpi/pc/DSDT.nohpet" , +"tests/data/acpi/pc/DSDT.dimmpxm" , +"tests/data/acpi/pc/DSDT.acpihmat" , +"tests/data/acpi/pc/DSDT.hpbridge",
Signature · 1 line
2.27.0
PATCH 2/2 acpi: pc: revert back to v5.2 PCI slot enumeration
In reply to Igor MammedovCommit [1] moved _SUN variable from only hot-pluggable to all devices. This made linux kernel enumerate extra slots that weren't present before. If extra slot happens to be be enumerated first and there is a device in th same slot but on other bridge, linux kernel will add -N suffix to slot name of the later, thus changing NIC name compared to QEMU 5.2. This in some case confuses systemd, if it is using SLOT NIC naming scheme and interface name becomes not the same as it was under QEMU-5.2.
Reproducer QEMU CLI:
-M pc-i440fx-5.2 -nodefaults \
-device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x3 \
-device virtio-net-pci,id=nic1,bus=pci.1,addr=0x1 \
-device virtio-net-pci,id=nic2,bus=pci.1,addr=0x2 \
-device virtio-net-pci,id=nic3,bus=pci.1,addr=0x3
with RHEL8 guest produces following results:
v5.2:
kernel: virtio_net virtio0 ens1: renamed from eth0
kernel: virtio_net virtio2 ens3: renamed from eth2
kernel: virtio_net virtio1 enp1s2: renamed from eth1
(slot 2 is assigned to empty bus 0 slot and virtio1
is assigned to 2-2 slot, and renaming falls back, for some reason, to path based naming scheme)
v6.0:
kernel: virtio_net virtio0 ens1: renamed from eth0
kernel: virtio_net virtio2 ens3: renamed from eth2
systemd-udevd[299]: Error changing net interface name 'eth1' to 'ens3': File exists systemd-udevd[299]: could not rename interface '3' from 'eth1' to 'ens3': File exists
(with commit [1] kernel assigns virtio2 to 3-2 slot
since bridge advertises _SUN=0x3 and kernel assigns
slot 3 to bridge. Still it manages to rename virtio2
correctly to ens3, however systemd gets confused with virtio1
where slot allocation exactly the same (2-2) as in 5.2 case
and tries to rename it to ens3 which is rightfully taken by
virtio2)
I'm not sure what breaks in systemd interface renaming (it probably should be investigated), but on QEMU side we can safely revert _SUN to 5.2 behavior (i.e. avoid cold-plugged bridges and non hot-pluggable device classes), without breaking acpi-index, which uses slot numbers but it doesn't have to use _SUN, it could use an arbitrary variable name that has the same slot value).
It will help existing VMs to keep networking with non trivial configs in working order since systemd will do its interface renaming magic as it used to do.
1)
---
shameless plug: one more reason to use new acpi-index for interface naming, so naming won't depend on enumeration rules kernel or systemd use (so far it's available only for 'pc' machine, but with Julia's acpi pci hotplug reviewed, there is a hope for q35 also supporting it since 6.1).
--- hw/i386/acpi-build.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
hw/i386/acpi-build.c +7 -2
@@ -435,11 +435,15 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_append (dev,aml_name_decl ("_ADR" ,aml_int (slot <<16 )));if (bsel) { -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); +/* +* Can't declare _SUN here for every device as it changes 'slot' +* enumeration order in linux kernel, so use another variable for it +*/ +aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); method =aml_method ("_DSM" ,4 ,AML_SERIALIZED );aml_append (method,aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ),aml_arg (2 ), -aml_arg (3 ),aml_name ("BSEL" ),aml_name ("_SUN" )) +aml_arg (3 ),aml_name ("BSEL" ),aml_name ("ASUN" )) ));aml_append (dev, method); }
@@ -466,6 +470,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); }else if (hotplug_enabled_dev) { +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));/* add _EJ0 to make slot hotpluggable */ method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); aml_append(method,
Signature · 1 line
2.27.0
PATCH 3/3 tests: acpi: pc: update expected DSDT blobs
In reply to Igor Mammedov@@ -930,20 +930,20 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)
Device (S00)
{
Name (_ADR, Zero) // _ADR: Address- Name (_SUN, Zero) // _SUN: Slot User Number
+ Name (ASUN, Zero)
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method {
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, ASUN))
}
}
Device (S10)
{
Name (_ADR, 0x00020000) // _ADR: Address- Name (_SUN, 0x02) // _SUN: Slot User Number
+ Name (ASUN, 0x02)
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method {
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, ASUN))
}
Method (_S1D, 0, NotSerialized) // _S1D: S1 Device State
with a hank per bridge:
@@ -965,10 +965,10 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)
Device (S18)
{
Name (_ADR, 0x00030000) // _ADR: Address- Name (_SUN, 0x03) // _SUN: Slot User Number
+ Name (ASUN, 0x03)
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method {
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, ASUN))
}
}--- tests/qtest/bios-tables-test-allowed-diff.h | 10 ---------- tests/data/acpi/pc/DSDT | Bin 6002 -> 6002 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7327 -> 7327 bytes tests/data/acpi/pc/DSDT.bridge | Bin 8668 -> 8668 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6466 -> 6466 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 7656 -> 7656 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5969 -> 5969 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6074 -> 6074 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7361 -> 7361 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 5860 -> 5860 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6008 -> 6008 bytes 11 files changed, 10 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -10
@@ -1,11 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT" , -"tests/data/acpi/pc/DSDT.bridge" , -"tests/data/acpi/pc/DSDT.ipmikcs" , -"tests/data/acpi/pc/DSDT.cphp" , -"tests/data/acpi/pc/DSDT.memhp" , -"tests/data/acpi/pc/DSDT.numamem" , -"tests/data/acpi/pc/DSDT.nohpet" , -"tests/data/acpi/pc/DSDT.dimmpxm" , -"tests/data/acpi/pc/DSDT.acpihmat" , -"tests/data/acpi/pc/DSDT.hpbridge",
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
Signature · 1 line
2.27.0
Quoted 22 lines · Igor Mammedov
Commit
b7f23f62e40(pci: acpi: add_DSMmethod to PCI devices), regressed network interface naming for Linux guests in some cases. This reverts PCI slot enumeration to its state before 6.0. For details see 2/3 patch.Thanks Stefan for troubleshooting!
Reported-by [email protected]Igor Mammedov (2):
tests: acpi: prepare for changing DSDT tables
acpi: pc: revert back to v5.2 PCI slot enumerationtests/qtest/bios-tables-test-allowed-diff.h | 10 ++++++++++ hw/i386/acpi-build.c | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)
Quoted 14 lines · Igor Mammedov
Commit
b7f23f62e40(pci: acpi: add_DSMmethod to PCI devices), regressed network interface naming for Linux guests in some cases. This reverts PCI slot enumeration to its state before 6.0. For details see 2/3 patch.Thanks Stefan for troubleshooting!
Reported-by [email protected]
Quoted 11 lines
Igor Mammedov (2):
tests: acpi: prepare for changing DSDT tables
acpi: pc: revert back to v5.2 PCI slot enumerationtests/qtest/bios-tables-test-allowed-diff.h | 10 ++++++++++ hw/i386/acpi-build.c | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)Signature · 1 line
2.27.0
Quoted 23 lines · Stefan Hajnoczi
Quoted 22 lines · Igor Mammedov
Commit
b7f23f62e40(pci: acpi: add_DSMmethod to PCI devices), regressed network interface naming for Linux guests in some cases. This reverts PCI slot enumeration to its state before 6.0. For details see 2/3 patch.Thanks Stefan for troubleshooting!
Reported-by [email protected]Igor Mammedov (2):
tests: acpi: prepare for changing DSDT tables
acpi: pc: revert back to v5.2 PCI slot enumerationtests/qtest/bios-tables-test-allowed-diff.h | 10 ++++++++++ hw/i386/acpi-build.c | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 3 lines
Signature · 1 line
2.27.0Reviewed-by Stefan Hajnoczi <[email protected]>
Tagged, thanks!