Skip to contentSkip to conversation

pc: support user provided NIC naming/indexing

PATCH In review Igor Mammedov 4 participants 13 messages Mar 15, 2021 – May 14, 2021

lore
Share & tools
lore
#0 lore raw

cover pc: support user provided NIC naming/indexing

Changes since rfc:
* make sure that acpi-index unique
* use dedicated MMIO register for it
* drop syntetic acpi-label field in _DSM
* add more comments

Series implements support for 'onboard' naming scheme for network interfaces (1), which is based on PCI firmware spec and lets user to explicitly specify index that will be used by guest to name network interface, ex:

    -device e1000,acpi-index=33

should make guest rename NIC name to 'eno33' where 'eno' is default prefix for this scheme.

Hope is that it will allow to simplify launching VMs from template disk images with different set VM configurations without need to reconfigure guest network intrfaces or risk of loosing network connectivity.

For more detailed description/examples see patches [3-4/5]

1)
https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

Git repo for testing:
https://github.com/imammedo/qemu/branches acpi-index-v1

Igor Mammedov (6):
tests: acpi: temporary whitelist DSDT changes
pci: introduce apci-index property for PCI device
pci: acpi: ensure that acpi-index is unique
acpi: add aml_to_decimalstring() and aml_call6() helpers
pci: acpi: add _DSM method to PCI devices
tests: acpi: update expected blobs

 include/hw/acpi/aml-build.h      |   3 +
 include/hw/acpi/pci.h            |   1 +
 include/hw/acpi/pcihp.h          |   9 ++-
 include/hw/pci/pci.h             |   1 +
 hw/acpi/aml-build.c              |  28 ++++++++
 hw/acpi/pci.c                    |   1 -
 hw/acpi/pcihp.c                  | 104 ++++++++++++++++++++++++++-
 hw/acpi/piix4.c                  |   3 +-
 hw/acpi/trace-events             |   2 +
 hw/i386/acpi-build.c             | 118 +++++++++++++++++++++++++++++--
 hw/pci/pci.c                     |   1 +
 tests/data/acpi/pc/DSDT          | Bin 5065 -> 6002 bytes
 tests/data/acpi/pc/DSDT.acpihmat | Bin 6390 -> 7327 bytes
 tests/data/acpi/pc/DSDT.bridge   | Bin 6924 -> 8668 bytes
 tests/data/acpi/pc/DSDT.cphp     | Bin 5529 -> 6466 bytes
 tests/data/acpi/pc/DSDT.dimmpxm  | Bin 6719 -> 7656 bytes
 tests/data/acpi/pc/DSDT.hpbridge | Bin 5026 -> 5969 bytes
 tests/data/acpi/pc/DSDT.ipmikcs  | Bin 5137 -> 6074 bytes
 tests/data/acpi/pc/DSDT.memhp    | Bin 6424 -> 7361 bytes
 tests/data/acpi/pc/DSDT.nohpet   | Bin 4923 -> 5860 bytes
 tests/data/acpi/pc/DSDT.numamem  | Bin 5071 -> 6008 bytes
 tests/data/acpi/pc/DSDT.roothp   | Bin 5261 -> 6210 bytes
 22 files changed, 261 insertions(+), 10 deletions(-)
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/6 tests: acpi: temporary whitelist DSDT changes

---
 tests/qtest/bios-tables-test-allowed-diff.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +11 -0
index dfb8523c8b..fddcfc061f 100644
@@ -1 +1,12 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/pc/DSDT",
+"tests/data/acpi/pc/DSDT.acpihmat",
+"tests/data/acpi/pc/DSDT.bridge",
+"tests/data/acpi/pc/DSDT.cphp",
+"tests/data/acpi/pc/DSDT.dimmpxm",
+"tests/data/acpi/pc/DSDT.hpbridge",
+"tests/data/acpi/pc/DSDT.hpbrroot",
+"tests/data/acpi/pc/DSDT.ipmikcs",
+"tests/data/acpi/pc/DSDT.memhp",
+"tests/data/acpi/pc/DSDT.numamem",
+"tests/data/acpi/pc/DSDT.roothp",
Signature · 1 line
2.27.0
#2 lore raw

PATCH 2/6 pci: introduce apci-index property for PCI device

In reply to Igor Mammedov

In x86/ACPI world, linux distros are using predictable network interface naming since systemd v197. Which on QEMU based VMs results into path based naming scheme, that names network interfaces based on PCI topology.

With itm on has to plug NIC in exactly the same bus/slot, which was used when disk image was first provisioned/configured or one risks to loose network configuration due to NIC being renamed to actually used topology.
That also restricts freedom to reshape PCI configuration of VM without need to reconfigure used guest image.

systemd also offers "onboard" naming scheme which is preferred over PCI slot/topology one, provided that firmware implements:
"
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
"
that allows to assign user defined index to PCI device, which systemd will use to name NIC. For example, using
-device e1000,acpi-index=100
guest will rename NIC to 'eno100', where 'eno' is default prefix for "onboard" naming scheme. This doesn't require any advance configuration on guest side to com in effect at 'onboard' scheme takes priority over path based naming.

Hope is that 'acpi-index' it will be easier to consume by management layer, compared to forcing specific PCI topology and/or having several disk image templates for different topologies and will help to simplify process of spawning VM from the same template without need to reconfigure guest NIC.

This patch adds, 'acpi-index'* property and wires up a 32bit register on top of pci hotplug register block to pass index value to AML code at runtime. Following patch will add corresponding _DSM code and wire it up to PCI devices described in ACPI.

*) name comes from linux kernel terminology

---
v1:
* fix build failure of mips target
* move out handling acpi-index into separate MMIO register, instead of abusing unused PCI hotplug registers (mst)
* default acpi-index property value to 0
* set and check for max acpi-index value (systemd limitation)

---
 include/hw/acpi/pcihp.h |  9 +++++--
 include/hw/pci/pci.h    |  1 +
 hw/acpi/pci.c           |  1 -
 hw/acpi/pcihp.c         | 58 +++++++++++++++++++++++++++++++++++++++--
 hw/acpi/piix4.c         |  3 ++-
 hw/acpi/trace-events    |  2 ++
 hw/i386/acpi-build.c    | 13 ++++++++-
 hw/pci/pci.c            |  1 +
 8 files changed, 81 insertions(+), 7 deletions(-)
include/hw/acpi/pcihp.h +7 -2
index dfd375820f..2dd90aea30 100644
@@ -46,6 +46,7 @@ typedef struct AcpiPciHpPciStatus {
 typedef struct AcpiPciHpState {
     AcpiPciHpPciStatus acpi_pcihp_pci_status[ACPI_PCIHP_MAX_HOTPLUG_BUS];
     uint32_t hotplug_select;
+    uint32_t acpi_index;
     PCIBus *root;
     MemoryRegion io;
     bool legacy_piix;
@@ -71,13 +72,17 @@ void acpi_pcihp_reset(AcpiPciHpState *s, bool acpihp_root_off);
 
 extern const VMStateDescription vmstate_acpi_pcihp_pci_status;
 
-#define VMSTATE_PCI_HOTPLUG(pcihp, state, test_pcihp) \
+bool vmstate_acpi_pcihp_use_acpi_index(void *opaque, int version_id);
+
+#define VMSTATE_PCI_HOTPLUG(pcihp, state, test_pcihp, test_acpi_index) \
         VMSTATE_UINT32_TEST(pcihp.hotplug_select, state, \
                             test_pcihp), \
         VMSTATE_STRUCT_ARRAY_TEST(pcihp.acpi_pcihp_pci_status, state, \
                                   ACPI_PCIHP_MAX_HOTPLUG_BUS, \
                                   test_pcihp, 1, \
                                   vmstate_acpi_pcihp_pci_status, \
-                                  AcpiPciHpPciStatus)
+                                  AcpiPciHpPciStatus), \
+        VMSTATE_UINT32_TEST(pcihp.acpi_index, state, \
+                            test_acpi_index)
 
 #endif
include/hw/pci/pci.h +1 -0
index 1bc231480f..6be4e0c460 100644
@@ -359,6 +359,7 @@ struct PCIDevice {
 
     /* ID of standby device in net_failover pair */
     char *failover_pair_id;
+    uint32_t acpi_index;
 };
 
 void pci_register_bar(PCIDevice *pci_dev, int region_num,
hw/acpi/pci.c +0 -1
index ec455c3b25..75b1103ec4 100644
@@ -59,4 +59,3 @@ void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info,
     build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
                  "MCFG", table_data->len - mcfg_start, 1, oem_id, oem_table_id);
 }
-
hw/acpi/pcihp.c +56 -2

110 lines not on this page · raw message

hw/acpi/piix4.c +2 -1
index 1efc0ded9f..6056d51667 100644
@@ -297,7 +297,8 @@ static const VMStateDescription vmstate_acpi = {
             2, vmstate_pci_status,
             struct AcpiPciHpPciStatus),
         VMSTATE_PCI_HOTPLUG(acpi_pci_hotplug, PIIX4PMState,
-                            vmstate_test_use_acpi_hotplug_bridge),
+                            vmstate_test_use_acpi_hotplug_bridge,
+                            vmstate_acpi_pcihp_use_acpi_index),
         VMSTATE_END_OF_LIST()
     },
     .subsections = (const VMStateDescription*[]) {
hw/acpi/trace-events +2 -0
index f91ced477d..dcc1438f3a 100644
@@ -41,6 +41,8 @@ acpi_pci_unplug_request(int bsel, int slot) "bsel: %d slot: %d"
 acpi_pci_up_read(uint32_t val) "%" PRIu32
 acpi_pci_down_read(uint32_t val) "%" PRIu32
 acpi_pci_features_read(uint32_t val) "%" PRIu32
+acpi_pci_acpi_index_read(uint32_t val) "%" PRIu32
+acpi_pci_acpi_index_write(unsigned bsel, unsigned slot, uint32_t aidx) "bsel: %u slot: %u aidx: %" PRIu32
 acpi_pci_rmv_read(uint32_t val) "%" PRIu32
 acpi_pci_sel_read(uint32_t val) "%" PRIu32
 acpi_pci_ej_write(uint64_t addr, uint64_t data) "0x%" PRIx64 " <== %" PRIu64
hw/i386/acpi-build.c +12 -1
index 442b4629a9..e49fae2bfd 100644
@@ -1168,9 +1168,10 @@ static void build_piix4_pci_hotplug(Aml *table)
     aml_append(scope, field);
 
     aml_append(scope,
-        aml_operation_region("BNMR", AML_SYSTEM_IO, aml_int(0xae10), 0x04));
+        aml_operation_region("BNMR", AML_SYSTEM_IO, aml_int(0xae10), 0x08));
     field = aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
     aml_append(field, aml_named_field("BNUM", 32));
+    aml_append(field, aml_named_field("PIDX", 32));
     aml_append(scope, field);
 
     aml_append(scope, aml_mutex("BLCK", 0));
@@ -1184,6 +1185,16 @@ static void build_piix4_pci_hotplug(Aml *table)
     aml_append(method, aml_return(aml_int(0)));
     aml_append(scope, method);
 
+    method = aml_method("AIDX", 2, AML_NOTSERIALIZED);
+    aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
+    aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
+    aml_append(method,
+        aml_store(aml_shiftleft(aml_int(1), aml_arg(1)), aml_name("PIDX")));
+    aml_append(method, aml_store(aml_name("PIDX"), aml_local(0)));
+    aml_append(method, aml_release(aml_name("BLCK")));
+    aml_append(method, aml_return(aml_local(0)));
+    aml_append(scope, method);
+
     aml_append(table, scope);
 }
 
hw/pci/pci.c +1 -0
index 0eadcdbc9e..ac9a24889c 100644
@@ -79,6 +79,7 @@ static Property pci_props[] = {
                     QEMU_PCIE_EXTCAP_INIT_BITNR, true),
     DEFINE_PROP_STRING("failover_pair_id", PCIDevice,
                        failover_pair_id),
+    DEFINE_PROP_UINT32("acpi-index",  PCIDevice, acpi_index, 0),
     DEFINE_PROP_END_OF_LIST()
 };
 
Signature · 1 line
2.27.0
#3 lore raw

Re: [PATCH 2/6] pci: introduce apci-index property for PCI device

Quoted 35 lines · Igor Mammedov

In x86/ACPI world, linux distros are using predictable network interface naming since systemd v197. Which on QEMU based VMs results into path based naming scheme, that names network interfaces based on PCI topology.

With itm on has to plug NIC in exactly the same bus/slot, which was used when disk image was first provisioned/configured or one risks to loose network configuration due to NIC being renamed to actually used topology.
That also restricts freedom to reshape PCI configuration of VM without need to reconfigure used guest image.

systemd also offers "onboard" naming scheme which is preferred over PCI slot/topology one, provided that firmware implements:
"
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
"
that allows to assign user defined index to PCI device, which systemd will use to name NIC. For example, using
-device e1000,acpi-index=100
guest will rename NIC to 'eno100', where 'eno' is default prefix for "onboard" naming scheme. This doesn't require any advance configuration on guest side to com in effect at 'onboard' scheme takes priority over path based naming.

Hope is that 'acpi-index' it will be easier to consume by management layer, compared to forcing specific PCI topology and/or having several disk image templates for different topologies and will help to simplify process of spawning VM from the same template without need to reconfigure guest NIC.

Quoted 5 lines

This patch adds, 'acpi-index'* property and wires up a 32bit register on top of pci hotplug register block to pass index value to AML code at runtime. Following patch will add corresponding _DSM code and wire it up to PCI devices described in ACPI.

You've illustrated usage & benefits with NICs, but IIUC, this feature is wired up for any PCI device. Are you aware of any usage of this feature for non-NIC devices ?

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw

Re: [PATCH 2/6] pci: introduce apci-index property for PCI device

Quoted 42 lines · On Tue, 6 Apr 2021 10:47:12 +0100 Daniel P. Berrangé <[email protected]>…
Quoted 35 lines · Igor Mammedov

In x86/ACPI world, linux distros are using predictable network interface naming since systemd v197. Which on QEMU based VMs results into path based naming scheme, that names network interfaces based on PCI topology.

With itm on has to plug NIC in exactly the same bus/slot, which was used when disk image was first provisioned/configured or one risks to loose network configuration due to NIC being renamed to actually used topology.
That also restricts freedom to reshape PCI configuration of VM without need to reconfigure used guest image.

systemd also offers "onboard" naming scheme which is preferred over PCI slot/topology one, provided that firmware implements:
"
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
"
that allows to assign user defined index to PCI device, which systemd will use to name NIC. For example, using
-device e1000,acpi-index=100
guest will rename NIC to 'eno100', where 'eno' is default prefix for "onboard" naming scheme. This doesn't require any advance configuration on guest side to com in effect at 'onboard' scheme takes priority over path based naming.

Hope is that 'acpi-index' it will be easier to consume by management layer, compared to forcing specific PCI topology and/or having several disk image templates for different topologies and will help to simplify process of spawning VM from the same template without need to reconfigure guest NIC.

Quoted 5 lines

This patch adds, 'acpi-index'* property and wires up a 32bit register on top of pci hotplug register block to pass index value to AML code at runtime. Following patch will add corresponding _DSM code and wire it up to PCI devices described in ACPI.

Quoted 3 lines

You've illustrated usage & benefits with NICs, but IIUC, this feature is wired up for any PCI device. Are you aware of any usage of this feature for non-NIC devices ?

I'm not aware of anything else that might currently use it.

It might be useful for virtio-win (HDDs/NICs) (as we saw recently breakage due to PCI root bus UID change, where devices installed on old QEMU enumerated as new instances breaking network config or causing boot issues)

As Lane mentioned, it would be really useful if we could add acpi-index as some meta data to qcow2 image so that new guest could import it at creation time.

Quoted 2 lines

Regards,
Daniel

#5 lore raw

Re: [PATCH 2/6] pci: introduce apci-index property for PCI device

In reply to Igor Mammedov
Quoted 41 lines · Igor Mammedov

In x86/ACPI world, linux distros are using predictable network interface naming since systemd v197. Which on QEMU based VMs results into path based naming scheme, that names network interfaces based on PCI topology.

With itm on has to plug NIC in exactly the same bus/slot, which was used when disk image was first provisioned/configured or one risks to loose network configuration due to NIC being renamed to actually used topology.
That also restricts freedom to reshape PCI configuration of VM without need to reconfigure used guest image.

systemd also offers "onboard" naming scheme which is preferred over PCI slot/topology one, provided that firmware implements:
"
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
"
that allows to assign user defined index to PCI device, which systemd will use to name NIC. For example, using
-device e1000,acpi-index=100
guest will rename NIC to 'eno100', where 'eno' is default prefix for "onboard" naming scheme. This doesn't require any advance configuration on guest side to com in effect at 'onboard' scheme takes priority over path based naming.

Hope is that 'acpi-index' it will be easier to consume by management layer, compared to forcing specific PCI topology and/or having several disk image templates for different topologies and will help to simplify process of spawning VM from the same template without need to reconfigure guest NIC.

This patch adds, 'acpi-index'* property and wires up a 32bit register on top of pci hotplug register block to pass index value to AML code at runtime. Following patch will add corresponding _DSM code and wire it up to PCI devices described in ACPI.

Quoted 3 lines

*) name comes from linux kernel terminology

So something to note here is that it's more or less linux centric even though it's from the spec:

Assignment of specific device names to multi-function devices installed in expansion slots, and/or PCI or PCI Express devices that are hot-added to expansion slots in operating system- environment would be handled in operating system-specific manner, and is not specified via this specification.

So I think commit log should note that point about hot add:
that even though spec excludes it, it seems to work because the Linux guest re-evaluate the method each time device is added.

Also, should not we exclude multi-function devices with this property? Or at least document that it won't work ...

Quoted 266 lines

---
v1:
* fix build failure of mips target
* move out handling acpi-index into separate MMIO register, instead of abusing unused PCI hotplug registers (mst)
* default acpi-index property value to 0
* set and check for max acpi-index value (systemd limitation)

---
 include/hw/acpi/pcihp.h |  9 +++++--
 include/hw/pci/pci.h    |  1 +
 hw/acpi/pci.c           |  1 -
 hw/acpi/pcihp.c         | 58 +++++++++++++++++++++++++++++++++++++++--
 hw/acpi/piix4.c         |  3 ++-
 hw/acpi/trace-events    |  2 ++
 hw/i386/acpi-build.c    | 13 ++++++++-
 hw/pci/pci.c            |  1 +
 8 files changed, 81 insertions(+), 7 deletions(-)
include/hw/acpi/pcihp.h +7 -2
index dfd375820f..2dd90aea30 100644
@@ -46,6 +46,7 @@ typedef struct AcpiPciHpPciStatus {
 typedef struct AcpiPciHpState {
     AcpiPciHpPciStatus acpi_pcihp_pci_status[ACPI_PCIHP_MAX_HOTPLUG_BUS];
     uint32_t hotplug_select;
+    uint32_t acpi_index;
     PCIBus *root;
     MemoryRegion io;
     bool legacy_piix;
@@ -71,13 +72,17 @@ void acpi_pcihp_reset(AcpiPciHpState *s, bool acpihp_root_off);
 
 extern const VMStateDescription vmstate_acpi_pcihp_pci_status;
 
-#define VMSTATE_PCI_HOTPLUG(pcihp, state, test_pcihp) \
+bool vmstate_acpi_pcihp_use_acpi_index(void *opaque, int version_id);
+
+#define VMSTATE_PCI_HOTPLUG(pcihp, state, test_pcihp, test_acpi_index) \
         VMSTATE_UINT32_TEST(pcihp.hotplug_select, state, \
                             test_pcihp), \
         VMSTATE_STRUCT_ARRAY_TEST(pcihp.acpi_pcihp_pci_status, state, \
                                   ACPI_PCIHP_MAX_HOTPLUG_BUS, \
                                   test_pcihp, 1, \
                                   vmstate_acpi_pcihp_pci_status, \
-                                  AcpiPciHpPciStatus)
+                                  AcpiPciHpPciStatus), \
+        VMSTATE_UINT32_TEST(pcihp.acpi_index, state, \
+                            test_acpi_index)
 
 #endif
include/hw/pci/pci.h +1 -0
index 1bc231480f..6be4e0c460 100644
@@ -359,6 +359,7 @@ struct PCIDevice {
 
     /* ID of standby device in net_failover pair */
     char *failover_pair_id;
+    uint32_t acpi_index;
 };
 
 void pci_register_bar(PCIDevice *pci_dev, int region_num,
hw/acpi/pci.c +0 -1
index ec455c3b25..75b1103ec4 100644
@@ -59,4 +59,3 @@ void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info,
     build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
                  "MCFG", table_data->len - mcfg_start, 1, oem_id, oem_table_id);
 }
-
hw/acpi/pcihp.c +56 -2
index 9dc4d3e2db..ceab287bd3 100644
@@ -39,12 +39,13 @@
 #include "trace.h"
 
 #define ACPI_PCIHP_ADDR 0xae00
-#define ACPI_PCIHP_SIZE 0x0014
+#define ACPI_PCIHP_SIZE 0x0018
 #define PCI_UP_BASE 0x0000
 #define PCI_DOWN_BASE 0x0004
 #define PCI_EJ_BASE 0x0008
 #define PCI_RMV_BASE 0x000c
 #define PCI_SEL_BASE 0x0010
+#define PCI_AIDX_BASE 0x0014
 
 typedef struct AcpiPciHpFind {
     int bsel;
@@ -251,9 +252,13 @@ void acpi_pcihp_reset(AcpiPciHpState *s, bool acpihp_root_off)
     acpi_pcihp_update(s);
 }
 
+#define ONBOARD_INDEX_MAX (16 * 1024 - 1)
+
 void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev,
                                    DeviceState *dev, Error **errp)
 {
+    PCIDevice *pdev = PCI_DEVICE(dev);
+
     /* Only hotplugged devices need the hotplug capability. */
     if (dev->hotplugged &&
         acpi_pcihp_get_bsel(pci_get_bus(PCI_DEVICE(dev))) < 0) {
@@ -261,6 +266,17 @@ void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev,
                    ACPI_PCIHP_PROP_BSEL "' set");
         return;
     }
+
+    /*
+     * capped by systemd (see: udev-builtin-net_id.c)
+     * as it's the only known user honor it to avoid users
+     * misconfigure QEMU and then wonder why acpi-index doesn't work
+     */
+    if (pdev->acpi_index > ONBOARD_INDEX_MAX) {
+        error_setg(errp, "acpi-index should be less or equal to %u",
+                   ONBOARD_INDEX_MAX);
+        return;
+    }
 }
 
 void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
@@ -347,7 +363,6 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)
         trace_acpi_pci_down_read(val);
         break;
     case PCI_EJ_BASE:
-        /* No feature defined yet */
         trace_acpi_pci_features_read(val);
         break;
     case PCI_RMV_BASE:
@@ -357,6 +372,12 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)
     case PCI_SEL_BASE:
         val = s->hotplug_select;
         trace_acpi_pci_sel_read(val);
+        break;
+    case PCI_AIDX_BASE:
+        val = s->acpi_index;
+        s->acpi_index = 0;
+        trace_acpi_pci_acpi_index_read(val);
+        break;
     default:
         break;
     }
@@ -367,8 +388,35 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)
 static void pci_write(void *opaque, hwaddr addr, uint64_t data,
                       unsigned int size)
 {
+    int slot;
+    PCIBus *bus;
+    BusChild *kid, *next;
     AcpiPciHpState *s = opaque;
+
+    s->acpi_index = 0;
     switch (addr) {
+    case PCI_AIDX_BASE:
+        /*
+         * fetch acpi-index for specified slot so that follow up read from
+         * PCI_AIDX_BASE can return it to guest
+         */
+        slot = ctz32(data);
+
+        if (s->hotplug_select >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
+            break;
+        }
+
+        bus = acpi_pcihp_find_hotplug_bus(s, s->hotplug_select);
+        QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) {
+            Object *o = OBJECT(kid->child);
+            PCIDevice *dev = PCI_DEVICE(o);
+            if (PCI_SLOT(dev->devfn) == slot) {
+                s->acpi_index = object_property_get_uint(o, "acpi-index", NULL);
+                break;
+            }
+        }
+        trace_acpi_pci_acpi_index_write(s->hotplug_select, slot, s->acpi_index);
+        break;
     case PCI_EJ_BASE:
         if (s->hotplug_select >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
             break;
@@ -413,6 +461,12 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, PCIBus *root_bus,
                                    OBJ_PROP_FLAG_READ);
 }
 
+bool vmstate_acpi_pcihp_use_acpi_index(void *opaque, int version_id)
+{
+     AcpiPciHpState *s = opaque;
+     return s->acpi_index;
+}
+
 const VMStateDescription vmstate_acpi_pcihp_pci_status = {
     .name = "acpi_pcihp_pci_status",
     .version_id = 1,
hw/acpi/piix4.c +2 -1
index 1efc0ded9f..6056d51667 100644
@@ -297,7 +297,8 @@ static const VMStateDescription vmstate_acpi = {
             2, vmstate_pci_status,
             struct AcpiPciHpPciStatus),
         VMSTATE_PCI_HOTPLUG(acpi_pci_hotplug, PIIX4PMState,
-                            vmstate_test_use_acpi_hotplug_bridge),
+                            vmstate_test_use_acpi_hotplug_bridge,
+                            vmstate_acpi_pcihp_use_acpi_index),
         VMSTATE_END_OF_LIST()
     },
     .subsections = (const VMStateDescription*[]) {
hw/acpi/trace-events +2 -0
index f91ced477d..dcc1438f3a 100644
@@ -41,6 +41,8 @@ acpi_pci_unplug_request(int bsel, int slot) "bsel: %d slot: %d"
 acpi_pci_up_read(uint32_t val) "%" PRIu32
 acpi_pci_down_read(uint32_t val) "%" PRIu32
 acpi_pci_features_read(uint32_t val) "%" PRIu32
+acpi_pci_acpi_index_read(uint32_t val) "%" PRIu32
+acpi_pci_acpi_index_write(unsigned bsel, unsigned slot, uint32_t aidx) "bsel: %u slot: %u aidx: %" PRIu32
 acpi_pci_rmv_read(uint32_t val) "%" PRIu32
 acpi_pci_sel_read(uint32_t val) "%" PRIu32
 acpi_pci_ej_write(uint64_t addr, uint64_t data) "0x%" PRIx64 " <== %" PRIu64
hw/i386/acpi-build.c +12 -1
index 442b4629a9..e49fae2bfd 100644
@@ -1168,9 +1168,10 @@ static void build_piix4_pci_hotplug(Aml *table)
     aml_append(scope, field);
 
     aml_append(scope,
-        aml_operation_region("BNMR", AML_SYSTEM_IO, aml_int(0xae10), 0x04));
+        aml_operation_region("BNMR", AML_SYSTEM_IO, aml_int(0xae10), 0x08));
     field = aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
     aml_append(field, aml_named_field("BNUM", 32));
+    aml_append(field, aml_named_field("PIDX", 32));
     aml_append(scope, field);
 
     aml_append(scope, aml_mutex("BLCK", 0));
@@ -1184,6 +1185,16 @@ static void build_piix4_pci_hotplug(Aml *table)
     aml_append(method, aml_return(aml_int(0)));
     aml_append(scope, method);
 
+    method = aml_method("AIDX", 2, AML_NOTSERIALIZED);
+    aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
+    aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
+    aml_append(method,
+        aml_store(aml_shiftleft(aml_int(1), aml_arg(1)), aml_name("PIDX")));
+    aml_append(method, aml_store(aml_name("PIDX"), aml_local(0)));
+    aml_append(method, aml_release(aml_name("BLCK")));
+    aml_append(method, aml_return(aml_local(0)));
+    aml_append(scope, method);
+
     aml_append(table, scope);
 }
 
hw/pci/pci.c +1 -0
index 0eadcdbc9e..ac9a24889c 100644
@@ -79,6 +79,7 @@ static Property pci_props[] = {
                     QEMU_PCIE_EXTCAP_INIT_BITNR, true),
     DEFINE_PROP_STRING("failover_pair_id", PCIDevice,
                        failover_pair_id),
+    DEFINE_PROP_UINT32("acpi-index",  PCIDevice, acpi_index, 0),
     DEFINE_PROP_END_OF_LIST()
 };
 
Signature · 1 line
2.27.0
#6 lore raw

PATCH 3/6 pci: acpi: ensure that acpi-index is unique

In reply to Igor Mammedov

it helps to avoid device naming conflicts when guest OS is configured to use acpi-index for naming.
Spec ialso says so:

PCI Firmware Specification Revision 3.2
4.6.7. _DSM for Naming a PCI or PCI Express Device Under Operating Systems "
Instance number must be unique under \_SB scope. This instance number does not have to be sequential in a given system configuration.
"

---
 hw/acpi/pcihp.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
hw/acpi/pcihp.c +46 -0
index ceab287bd3..f4cb3c979d 100644
@@ -52,6 +52,21 @@ typedef struct AcpiPciHpFind {
     PCIBus *bus;
 } AcpiPciHpFind;
 
+static gint g_cmp_uint32(gconstpointer a, gconstpointer b, gpointer user_data)
+{
+    return a - b;
+}
+
+static GSequence *pci_acpi_index_list(void)
+{
+    static GSequence *used_acpi_index_list;
+
+    if (!used_acpi_index_list) {
+        used_acpi_index_list = g_sequence_new(NULL);
+    }
+    return used_acpi_index_list;
+}
+
 static int acpi_pcihp_get_bsel(PCIBus *bus)
 {
     Error *local_err = NULL;
@@ -277,6 +292,23 @@ void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev,
                    ONBOARD_INDEX_MAX);
         return;
     }
+
+    /*
+     * make sure that acpi-index is unique across all present PCI devices
+     */
+    if (pdev->acpi_index) {
+        GSequence *used_indexes = pci_acpi_index_list();
+
+        if (g_sequence_lookup(used_indexes, GINT_TO_POINTER(pdev->acpi_index),
+                              g_cmp_uint32, NULL)) {
+            error_setg(errp, "a PCI device with acpi-index = %" PRIu32
+                       " already exist", pdev->acpi_index);
+            return;
+        }
+        g_sequence_insert_sorted(used_indexes,
+                                 GINT_TO_POINTER(pdev->acpi_index),
+                                 g_cmp_uint32, NULL);
+    }
 }
 
 void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
@@ -315,8 +347,22 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
 void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
                                  DeviceState *dev, Error **errp)
 {
+    PCIDevice *pdev = PCI_DEVICE(dev);
+
     trace_acpi_pci_unplug(PCI_SLOT(PCI_DEVICE(dev)->devfn),
                           acpi_pcihp_get_bsel(pci_get_bus(PCI_DEVICE(dev))));
+
+    /*
+     * clean up acpi-index so it could reused by another device
+     */
+    if (pdev->acpi_index) {
+        GSequence *used_indexes = pci_acpi_index_list();
+
+        g_sequence_remove(g_sequence_lookup(used_indexes,
+                          GINT_TO_POINTER(pdev->acpi_index),
+                          g_cmp_uint32, NULL));
+    }
+
     qdev_unrealize(dev);
 }
 
Signature · 1 line
2.27.0
#7 lore raw

PATCH 4/6 acpi: add aml_to_decimalstring() and aml_call6() helpers

In reply to Igor Mammedov

it will be used by follow up patches

---
 include/hw/acpi/aml-build.h |  3 +++
 hw/acpi/aml-build.c         | 28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)
include/hw/acpi/aml-build.h +3 -0
index 380d3e3924..e652106e26 100644
@@ -301,6 +301,7 @@ Aml *aml_arg(int pos);
 Aml *aml_to_integer(Aml *arg);
 Aml *aml_to_hexstring(Aml *src, Aml *dst);
 Aml *aml_to_buffer(Aml *src, Aml *dst);
+Aml *aml_to_decimalstring(Aml *src, Aml *dst);
 Aml *aml_store(Aml *val, Aml *target);
 Aml *aml_and(Aml *arg1, Aml *arg2, Aml *dst);
 Aml *aml_or(Aml *arg1, Aml *arg2, Aml *dst);
@@ -323,6 +324,8 @@ Aml *aml_call3(const char *method, Aml *arg1, Aml *arg2, Aml *arg3);
 Aml *aml_call4(const char *method, Aml *arg1, Aml *arg2, Aml *arg3, Aml *arg4);
 Aml *aml_call5(const char *method, Aml *arg1, Aml *arg2, Aml *arg3, Aml *arg4,
                Aml *arg5);
+Aml *aml_call6(const char *method, Aml *arg1, Aml *arg2, Aml *arg3, Aml *arg4,
+               Aml *arg5, Aml *arg6);
 Aml *aml_gpio_int(AmlConsumerAndProducer con_and_pro,
                   AmlLevelAndEdge edge_level,
                   AmlActiveHighAndLow active_level, AmlShared shared,
hw/acpi/aml-build.c +28 -0
index a2cd7a5830..d33ce8954a 100644
@@ -634,6 +634,19 @@ Aml *aml_to_buffer(Aml *src, Aml *dst)
     return var;
 }
 
+/* ACPI 2.0a: 17.2.4.4 Type 2 Opcodes Encoding: DefToDecimalString */
+Aml *aml_to_decimalstring(Aml *src, Aml *dst)
+{
+    Aml *var = aml_opcode(0x97 /* ToDecimalStringOp */);
+    aml_append(var, src);
+    if (dst) {
+        aml_append(var, dst);
+    } else {
+        build_append_byte(var->buf, 0x00 /* NullNameOp */);
+    }
+    return var;
+}
+
 /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefStore */
 Aml *aml_store(Aml *val, Aml *target)
 {
@@ -835,6 +848,21 @@ Aml *aml_call5(const char *method, Aml *arg1, Aml *arg2, Aml *arg3, Aml *arg4,
     return var;
 }
 
+/* helper to call method with 5 arguments */
+Aml *aml_call6(const char *method, Aml *arg1, Aml *arg2, Aml *arg3, Aml *arg4,
+               Aml *arg5, Aml *arg6)
+{
+    Aml *var = aml_alloc();
+    build_append_namestring(var->buf, "%s", method);
+    aml_append(var, arg1);
+    aml_append(var, arg2);
+    aml_append(var, arg3);
+    aml_append(var, arg4);
+    aml_append(var, arg5);
+    aml_append(var, arg6);
+    return var;
+}
+
 /*
  * ACPI 5.0: 6.4.3.8.1 GPIO Connection Descriptor
  * Type 1, Large Item Name 0xC
Signature · 1 line
2.27.0
#8 lore raw

PATCH 5/6 pci: acpi: add _DSM method to PCI devices

In reply to Igor Mammedov

Implement _DSM according to:
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
and wire it up to cold and hot-plugged PCI devices. Feature depends on ACPI hotplug being enabled (as that provides PCI devices descriptions in ACPI and MMIO registers that are reused to fetch acpi-index).

acpi-index should work for
- cold plugged NICs:

      $QEMU -device e1000,acpi-index=100
         => 'eno100'
  - hot-plugged
      (monitor) device_add e1000,acpi-index=200,id=remove_me
         => 'eno200'
  - re-plugged
      (monitor) device_del remove_me
      (monitor) device_add e1000,acpi-index=1
         => 'eno1'

Windows also sees index under "PCI Label Id" field in properties dialog but otherwise it doesn't seem to have any effect.

---
v1:
* drop optional text label
* do not report capability if PIDX is not supported (i.e. old QEMU)

---
 include/hw/acpi/pci.h |   1 +
 hw/i386/acpi-build.c  | 105 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 103 insertions(+), 3 deletions(-)
include/hw/acpi/pci.h +1 -0
index e514f179d8..b5deee0a9d 100644
@@ -35,4 +35,5 @@ typedef struct AcpiMcfgInfo {
 
 void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info,
                 const char *oem_id, const char *oem_table_id);
+Aml *aml_pci_device_dsm(void);
 #endif
hw/i386/acpi-build.c +102 -3

135 lines not on this page · raw message

Signature · 1 line
2.27.0
#9 lore raw

PATCH 6/6 tests: acpi: update expected blobs

In reply to Igor Mammedov

expected changes are:
* larger BNMR operation region
* new PIDX field and method to fetch acpi-index
* PDSM method that implements PCI device _DSM +
per device _DSM that calls PDSM

@@ -221,10 +221,11 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)

             B0EJ,   32
         }

- OperationRegion (BNMR, SystemIO, 0xAE10, 0x04)
+ OperationRegion (BNMR, SystemIO, 0xAE10, 0x08)
Field (BNMR, DWordAcc, NoLock, WriteAsZeros) {

-            BNUM,   32
+            BNUM,   32,
+            PIDX,   32
         }

         Mutex (BLCK, 0x00)
@@ -236,6 +237,52 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
             Release (BLCK)
             Return (Zero)
         }
+
+        Method (AIDX, 2, NotSerialized)
+        {
+            Acquire (BLCK, 0xFFFF)
+            BNUM = Arg0
+            PIDX = (One << Arg1)
+            Local0 = PIDX /* \_SB_.PCI0.PIDX */
+            Release (BLCK)
+            Return (Local0)

+ }
+
+ Method (PDSM, 6, Serialized)
+ {
+ If ((Arg0 == ToUUID ("e5c937d0-3553-4d7a-9117-ea4d19c3434d") /* Device Labeling Interface */))
+ {

+                Local0 = AIDX (Arg4, Arg5)
+                If ((Arg2 == Zero))
+                {

+ If ((Arg1 == 0x02))
+ {
+ If (!((Local0 == Zero) | (Local0 == 0xFFFFFFFF)))
+ {
+ Return (Buffer (One)
+ {
+ 0x81 // .
+ })
+ }
+ }
+
+ Return (Buffer (One)
+ {
+ 0x00 // .
+ })

+                }
+                ElseIf ((Arg2 == 0x07))
+                {

+ Local1 = Package (0x02)
+ {
+ Zero,
+ ""
+ }
+ Local1 [Zero] = Local0
+ Return (Local1)
+ }
+ }
+ }

     }

     Scope (_SB)
@@ -785,7 +832,7 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
                     0xAE00,             // Range Minimum
                     0xAE00,             // Range Maximum
                     0x01,               // Alignment
-                    0x14,               // Length
+                    0x18,               // Length
                     )
             })
         }
@@ -842,11 +889,22 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
             Device (S00)
             {
                 Name (_ADR, Zero)  // _ADR: Address
+                Name (_SUN, Zero)  // _SUN: Slot User Number
+                Method (_DSM, 4, Serialized)  // _DSM: Device-Specific Method
+                {
+                    Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+                }
             }

             Device (S10)
             {
                 Name (_ADR, 0x00020000)  // _ADR: Address
+                Name (_SUN, 0x02)  // _SUN: Slot User Number
+                Method (_DSM, 4, Serialized)  // _DSM: Device-Specific Method
+                {

+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ }
+
Method (_S1D, 0, NotSerialized) // _S1D: S1 Device State {
Return (Zero)
[...]

---
 tests/qtest/bios-tables-test-allowed-diff.h |  11 -----------
 tests/data/acpi/pc/DSDT                     | Bin 5065 -> 6002 bytes
 tests/data/acpi/pc/DSDT.acpihmat            | Bin 6390 -> 7327 bytes
 tests/data/acpi/pc/DSDT.bridge              | Bin 6924 -> 8668 bytes
 tests/data/acpi/pc/DSDT.cphp                | Bin 5529 -> 6466 bytes
 tests/data/acpi/pc/DSDT.dimmpxm             | Bin 6719 -> 7656 bytes
 tests/data/acpi/pc/DSDT.hpbridge            | Bin 5026 -> 5969 bytes
 tests/data/acpi/pc/DSDT.ipmikcs             | Bin 5137 -> 6074 bytes
 tests/data/acpi/pc/DSDT.memhp               | Bin 6424 -> 7361 bytes
 tests/data/acpi/pc/DSDT.nohpet              | Bin 4923 -> 5860 bytes
 tests/data/acpi/pc/DSDT.numamem             | Bin 5071 -> 6008 bytes
 tests/data/acpi/pc/DSDT.roothp              | Bin 5261 -> 6210 bytes
 12 files changed, 11 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -11
index fddcfc061f..dfb8523c8b 100644
@@ -1,12 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/pc/DSDT",
-"tests/data/acpi/pc/DSDT.acpihmat",
-"tests/data/acpi/pc/DSDT.bridge",
-"tests/data/acpi/pc/DSDT.cphp",
-"tests/data/acpi/pc/DSDT.dimmpxm",
-"tests/data/acpi/pc/DSDT.hpbridge",
-"tests/data/acpi/pc/DSDT.hpbrroot",
-"tests/data/acpi/pc/DSDT.ipmikcs",
-"tests/data/acpi/pc/DSDT.memhp",
-"tests/data/acpi/pc/DSDT.numamem",
-"tests/data/acpi/pc/DSDT.roothp",
tests/data/acpi/pc/DSDT binary +0 -0
index 11ef89bd322271ee30f3971b880dadfda565d413..b9dd9b38e4ef720636ba19ccbdf262de8a6439d5 100644
GIT binary patch
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
index c561e91be79f80dbea1cf4eb0f8658541a3aab2f..cba5a1dcb0464e56753bc0b931a4dd2e3b209787 100644
GIT binary patch
tests/data/acpi/pc/DSDT.bridge binary +0 -0
index a234075518fa8e187349d64c313779cc25db8299..a9b4d5659457f6de30b993962bce673c9413d81d 100644
GIT binary patch
tests/data/acpi/pc/DSDT.cphp binary +0 -0
index 6ac47a7d1001c711b957f8e28cab1a143d2cf65f..8d86155e275aa688f8767dd92c4b9df08b4a18ad 100644
GIT binary patch
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
index d24377279c307adeaba2b98aba20677872dfbbda..e00a447f92b27f9a91be802eb11fe89dc0457e20 100644
GIT binary patch
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
index 9dfac45eab12b680bc963d0528553a7149a378cc..5d8ba195055f2eda74223323baeb88390ea36739 100644
GIT binary patch
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
index 1814f291b704d737d3578b83fbcc6e090384943a..01e53bd436698db6f6adfff584ec56cb99074a5f 100644
GIT binary patch
tests/data/acpi/pc/DSDT.memhp binary +0 -0
index 3c81339d397969e954c94eb03f2654c57e024a6e..b8103799b45224c08344369931b87cf3b7797d7e 100644
GIT binary patch
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
index d7d21be070c3b879e558193cbf8ded5a64c15eda..d4f0050533f970128774f825274177096a46c3b8 100644
GIT binary patch
tests/data/acpi/pc/DSDT.numamem binary +0 -0
index 195f8da900c5fc56c504adfef756af8f74f5823d..8632dfe8a8bdd991871a1e633162eb9a2e1497ea 100644
GIT binary patch
tests/data/acpi/pc/DSDT.roothp binary +0 -0
index 1d0a2c2f3cc4bfac75948d2ed6a69403cd18379b..cee3b4d80b51ad30153953ace46127923ce8b271 100644
GIT binary patch
Signature · 1 line
2.27.0
#10 lore raw
In reply to Igor Mammedov
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [PATCH 0/6] pc: support user provided NIC naming/indexing

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
c0692b4 tests: acpi: update expected blobs
1a843d9 pci: acpi: add _DSM method to PCI devices 6b55586 acpi: add aml_to_decimalstring() and aml_call6() helpers 7b887f4 pci: acpi: ensure that acpi-index is unique 4056291 pci: introduce apci-index property for PCI device 9bd3a1b tests: acpi: temporary whitelist DSDT changes

=== OUTPUT BEGIN ===
1/6 Checking commit 9bd3a1b94c0f (tests: acpi: temporary whitelist DSDT changes) 2/6 Checking commit 40562915acde (pci: introduce apci-index property for PCI device)
ERROR: Macros with complex values should be enclosed in parenthesis #284: FILE: include/hw/acpi/pcihp.h:77:

+#define VMSTATE_PCI_HOTPLUG(pcihp, state, test_pcihp, test_acpi_index) \
         VMSTATE_UINT32_TEST(pcihp.hotplug_select, state, \
                             test_pcihp), \
         VMSTATE_STRUCT_ARRAY_TEST(pcihp.acpi_pcihp_pci_status, state, \
                                   ACPI_PCIHP_MAX_HOTPLUG_BUS, \
                                   test_pcihp, 1, \
                                   vmstate_acpi_pcihp_pci_status, \

- AcpiPciHpPciStatus)
+ AcpiPciHpPciStatus), \
+ VMSTATE_UINT32_TEST(pcihp.acpi_index, state, \
+ test_acpi_index)

total: 1 errors, 0 warnings, 197 lines checked

Patch 2/6 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

3/6 Checking commit 7b887f42419a (pci: acpi: ensure that acpi-index is unique) 4/6 Checking commit 6b555869ad66 (acpi: add aml_to_decimalstring() and aml_call6() helpers)
WARNING: Block comments use a leading /* on a separate line
#27: FILE: hw/acpi/aml-build.c:640:
+ Aml *var = aml_opcode(0x97 /* ToDecimalStringOp */);

WARNING: Block comments use a leading /* on a separate line #32: FILE: hw/acpi/aml-build.c:645:
+ build_append_byte(var->buf, 0x00 /* NullNameOp */);

total: 0 errors, 2 warnings, 55 lines checked

Patch 4/6 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
5/6 Checking commit 1a843d9de55e (pci: acpi: add _DSM method to PCI devices)
WARNING: Block comments use a leading /* on a separate line #127: FILE: hw/i386/acpi-build.c:568:
+ 1 /* have supported functions */ |

total: 0 errors, 1 warnings, 140 lines checked

Patch 5/6 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
6/6 Checking commit c0692b4b7df0 (tests: acpi: update expected blobs) === OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#11 lore raw
Quoted 39 lines · On Mon, 15 Mar 2021 11:36:49 -0700 (PDT) [email protected] wrote:

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [PATCH 0/6] pc: support user provided NIC naming/indexing

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
c0692b4 tests: acpi: update expected blobs
1a843d9 pci: acpi: add _DSM method to PCI devices 6b55586 acpi: add aml_to_decimalstring() and aml_call6() helpers 7b887f4 pci: acpi: ensure that acpi-index is unique 4056291 pci: introduce apci-index property for PCI device 9bd3a1b tests: acpi: temporary whitelist DSDT changes

=== OUTPUT BEGIN ===
1/6 Checking commit 9bd3a1b94c0f (tests: acpi: temporary whitelist DSDT changes) 2/6 Checking commit 40562915acde (pci: introduce apci-index property for PCI device)
ERROR: Macros with complex values should be enclosed in parenthesis #284: FILE: include/hw/acpi/pcihp.h:77:

(quoted diff) +1 -0
+#define VMSTATE_PCI_HOTPLUG(pcihp, state, test_pcihp, test_acpi_index) \

Review

Quoted 10 lines
(quoted diff) +3 -1
         VMSTATE_UINT32_TEST(pcihp.hotplug_select, state, \
                             test_pcihp), \
         VMSTATE_STRUCT_ARRAY_TEST(pcihp.acpi_pcihp_pci_status, state, \
                                   ACPI_PCIHP_MAX_HOTPLUG_BUS, \
                                   test_pcihp, 1, \
                                   vmstate_acpi_pcihp_pci_status, \
-                                  AcpiPciHpPciStatus)
+                                  AcpiPciHpPciStatus), \
+        VMSTATE_UINT32_TEST(pcihp.acpi_index, state, \
+                            test_acpi_index)

probably false positive
(I don't know what's wrong here and how to fix it)

Quoted 5 lines

total: 1 errors, 0 warnings, 197 lines checked

Patch 2/6 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

below warnings are intentional to follow comments style we use within aml-build.c

Quoted 36 lines

3/6 Checking commit 7b887f42419a (pci: acpi: ensure that acpi-index is unique) 4/6 Checking commit 6b555869ad66 (acpi: add aml_to_decimalstring() and aml_call6() helpers)
WARNING: Block comments use a leading /* on a separate line
#27: FILE: hw/acpi/aml-build.c:640:
+ Aml *var = aml_opcode(0x97 /* ToDecimalStringOp */);

WARNING: Block comments use a leading /* on a separate line #32: FILE: hw/acpi/aml-build.c:645:
+ build_append_byte(var->buf, 0x00 /* NullNameOp */);

total: 0 errors, 2 warnings, 55 lines checked

Patch 4/6 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
5/6 Checking commit 1a843d9de55e (pci: acpi: add _DSM method to PCI devices)
WARNING: Block comments use a leading /* on a separate line #127: FILE: hw/i386/acpi-build.c:568:
+ 1 /* have supported functions */ |

total: 0 errors, 1 warnings, 140 lines checked

Patch 5/6 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
6/6 Checking commit c0692b4b7df0 (tests: acpi: update expected blobs) === OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#12 lore raw
In reply to Igor Mammedov
Quoted 6 lines · Igor Mammedov

Changes since rfc:
* make sure that acpi-index unique
* use dedicated MMIO register for it
* drop syntetic acpi-label field in _DSM
* add more comments

Could you rebase and repost please?
Some comments in commit log about use for non-NIC devices
would be helpful (even if it's just that "currently does not seem to be useful for non-NICs").

Quoted 60 lines

Series implements support for 'onboard' naming scheme for network interfaces (1), which is based on PCI firmware spec and lets user to explicitly specify index that will be used by guest to name network interface, ex:

    -device e1000,acpi-index=33

should make guest rename NIC name to 'eno33' where 'eno' is default prefix for this scheme.

Hope is that it will allow to simplify launching VMs from template disk images with different set VM configurations without need to reconfigure guest network intrfaces or risk of loosing network connectivity.

For more detailed description/examples see patches [3-4/5]

1)
https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

Git repo for testing:
https://github.com/imammedo/qemu/branches acpi-index-v1

Igor Mammedov (6):
tests: acpi: temporary whitelist DSDT changes
pci: introduce apci-index property for PCI device
pci: acpi: ensure that acpi-index is unique
acpi: add aml_to_decimalstring() and aml_call6() helpers
pci: acpi: add _DSM method to PCI devices
tests: acpi: update expected blobs

 include/hw/acpi/aml-build.h      |   3 +
 include/hw/acpi/pci.h            |   1 +
 include/hw/acpi/pcihp.h          |   9 ++-
 include/hw/pci/pci.h             |   1 +
 hw/acpi/aml-build.c              |  28 ++++++++
 hw/acpi/pci.c                    |   1 -
 hw/acpi/pcihp.c                  | 104 ++++++++++++++++++++++++++-
 hw/acpi/piix4.c                  |   3 +-
 hw/acpi/trace-events             |   2 +
 hw/i386/acpi-build.c             | 118 +++++++++++++++++++++++++++++--
 hw/pci/pci.c                     |   1 +
 tests/data/acpi/pc/DSDT          | Bin 5065 -> 6002 bytes
 tests/data/acpi/pc/DSDT.acpihmat | Bin 6390 -> 7327 bytes
 tests/data/acpi/pc/DSDT.bridge   | Bin 6924 -> 8668 bytes
 tests/data/acpi/pc/DSDT.cphp     | Bin 5529 -> 6466 bytes
 tests/data/acpi/pc/DSDT.dimmpxm  | Bin 6719 -> 7656 bytes
 tests/data/acpi/pc/DSDT.hpbridge | Bin 5026 -> 5969 bytes
 tests/data/acpi/pc/DSDT.ipmikcs  | Bin 5137 -> 6074 bytes
 tests/data/acpi/pc/DSDT.memhp    | Bin 6424 -> 7361 bytes
 tests/data/acpi/pc/DSDT.nohpet   | Bin 4923 -> 5860 bytes
 tests/data/acpi/pc/DSDT.numamem  | Bin 5071 -> 6008 bytes
 tests/data/acpi/pc/DSDT.roothp   | Bin 5261 -> 6210 bytes
 22 files changed, 261 insertions(+), 10 deletions(-)
Signature · 1 line
2.27.0