On 1/7/26 10:50 AM, Thomas Huth wrote:
On 10/12/2025 21.54, [email protected] wrote:
From: Jared Rossi <[email protected]>
The loadparm is required on s390x to pass the information to the boot
loader
such as which kernel should be started or whether the boot menu
should be shown.
Because PCI devices do not naturally allocate space for this, the
property is
added on an architecture specific basis.
Signed-off-by: Jared Rossi <[email protected]>
---
include/hw/pci/pci_device.h | 3 +++
hw/pci/pci.c | 39 +++++++++++++++++++++++++++++++++++++
hw/s390x/ipl.c | 11 +++++++++--
3 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h
index 88ccea5011..5cac6e1688 100644
--- a/include/hw/pci/pci_device.h
+++ b/include/hw/pci/pci_device.h
@@ -62,6 +62,9 @@ struct PCIDevice {
bool partially_hotplugged;
bool enabled;
+ /* only for s390x */
+ char *loadparm;
+
/* PCI config space */
uint8_t *config;
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index b1eba348e0..1ea0d7c54c 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -36,6 +36,7 @@
#include "migration/qemu-file-types.h"
#include "migration/vmstate.h"
#include "net/net.h"
+#include "system/arch_init.h"
#include "system/numa.h"
#include "system/runstate.h"
#include "system/system.h"
@@ -2825,6 +2826,43 @@ int pci_qdev_find_device(const char *id,
PCIDevice **pdev)
return rc;
}
+static char *pci_qdev_property_get_loadparm(Object *obj, Error
**errp)
+{
+ return g_strdup(PCI_DEVICE(obj)->loadparm);
+}
+
+static void pci_qdev_property_set_loadparm(Object *obj, const char
*value,
+ Error **errp)
+{
+ void *lp_str;
+
+ if (object_property_get_int(obj, "bootindex", NULL) < 0) {
+ error_setg(errp, "'loadparm' is only valid for boot devices");
+ return;
+ }
+
+ lp_str = g_malloc0(strlen(value) + 1);
+ if (!qdev_prop_sanitize_s390x_loadparm(lp_str, value, errp)) {
+ g_free(lp_str);
+ return;
+ }
+ PCI_DEVICE(obj)->loadparm = lp_str;
+}
+
+static void pci_qdev_property_add_specifics(DeviceClass *dc)
+{
+ ObjectClass *oc = OBJECT_CLASS(dc);
+
+ /* The loadparm property is only supported on s390x */
+ if (qemu_arch_available(QEMU_ARCH_S390X)) {
+ object_class_property_add_str(oc, "loadparm",
+ pci_qdev_property_get_loadparm,
+ pci_qdev_property_set_loadparm);
+ object_class_property_set_description(oc, "loadparm",
+ "load parameter (s390x
only)");
+ }
+}
Adding this unconditionally to each and every PCI device is a little
bit ugly ... could we please limit this to virtio-blk-pci devices for
now?
(or maybe check if there is a bootindex property, and only add it for
devices with a bootindex property?)
Thomas
Maybe I'm missing some nuance, but won't the check in
pci_qdev_property_set_loadparm() already enforce that this is only added
to boot devices?
Hmm... on second though, I guess the problem is that a loadparm property
will still be added (but not necessarily set) for all PCI devices? I
agree that is not good. I will limit what qualifies for the property to
be added in the first place.
Thanks,
Jared Rossi