Skip to contentSkip to conversation

s390x: Expose pv attribute in QOM

PATCH Superseded Janosch Frank 4 participants 7 messages Sep 23 – Sep 24

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390x: Expose pv attribute in QOM

People doing VM management requested a way to query if a VM is in PV or not. This of course does never replace attestation, it's merely QEMU's view of the situation.

CC Hendrik Brueckner <[email protected]>
---
 hw/s390x/s390-virtio-ccw.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
hw/s390x/s390-virtio-ccw.c +13 -0
index 7fb78d8fa1..42ecfa59f3 100644
@@ -838,6 +838,13 @@ static inline void machine_set_secure_boot(Object *obj, bool value,
     ms->secure_boot = value;
 }
 
+static inline bool machine_get_pv(Object *obj, Error **errp)
+{
+    S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
+
+    return ms->pv;
+}
+
  /*
   * S390x-specific global compatibility properties.
   *
@@ -919,6 +926,12 @@ static void ccw_machine_class_init(ObjectClass *oc, const void *data)
                                    machine_set_secure_boot);
     object_class_property_set_description(oc, "secure-boot",
             "enable/disable secure boot");
+
+    object_class_property_add_bool(oc, "pv",
+                                   machine_get_pv,
+                                   NULL);
+    object_class_property_set_description(oc, "pv",
+            "protected virtualization state (read-only)");
 }
 
 static inline void s390_machine_initfn(Object *obj)
Signature · 1 line
2.53.0
#2 lore raw
In reply to Janosch Frank
Quoted 6 lines · Janosch Frank

People doing VM management requested a way to query if a VM is in PV or not. This of course does never replace attestation, it's merely QEMU's view of the situation.

CC Hendrik Brueckner <[email protected]>

I wondered for a bit about migration, but seeing as it's fenced for pv I think the only weird scenario would be migrating to an older QEMU using a pre-11.2 machine type and go from being able to see the attribute read 'false' to no longer being able to see the attribute with the same qemu command line.

Do you think that would matter for tooling e.g. do we need tie the visibility of the property to 11.2+ machine?

Quoted 35 lines
---
 hw/s390x/s390-virtio-ccw.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
hw/s390x/s390-virtio-ccw.c +13 -0
index 7fb78d8fa1..42ecfa59f3 100644
@@ -838,6 +838,13 @@ static inline void machine_set_secure_boot(Object *obj, bool value,
     ms->secure_boot = value;
 }
 
+static inline bool machine_get_pv(Object *obj, Error **errp)
+{
+    S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
+
+    return ms->pv;
+}
+
  /*
   * S390x-specific global compatibility properties.
   *
@@ -919,6 +926,12 @@ static void ccw_machine_class_init(ObjectClass *oc, const void *data)
                                    machine_set_secure_boot);
     object_class_property_set_description(oc, "secure-boot",
             "enable/disable secure boot");
+
+    object_class_property_add_bool(oc, "pv",
+                                   machine_get_pv,
+                                   NULL);
+    object_class_property_set_description(oc, "pv",
+            "protected virtualization state (read-only)");
 }
 
 static inline void s390_machine_initfn(Object *obj)
#3 lore raw

Am 23.09.26 um 23:44 schrieb Matthew Rosato:

Quoted 8 lines · Janosch Frank
Quoted 6 lines

People doing VM management requested a way to query if a VM is in PV or not. This of course does never replace attestation, it's merely QEMU's view of the situation.

CC Hendrik Brueckner <[email protected]>
Quoted 8 lines

I wondered for a bit about migration, but seeing as it's fenced for pv I think the only weird scenario would be migrating to an older QEMU using a pre-11.2 machine type and go from being able to see the attribute read 'false' to no longer being able to see the attribute with the same qemu command line.

Do you think that would matter for tooling e.g. do we need tie the visibility of the property to 11.2+ machine?

I dont think so
- Whether the property exists depends on the QEMU binary, not the machine type. Tools find it with qom-list.
- The command line can't change, because the property can't be set.
- Other read-only properties aren't tied to machine versions either, e.g. spapr vfio-no-msix-emulation

Reviewed-by on v1 1/1
#4 lore raw
In reply to Janosch Frank

Am 23.09.26 um 10:33 schrieb Janosch Frank:

Quoted 3 lines

People doing VM management requested a way to query if a VM is in PV or not. This of course does never replace attestation, it's merely QEMU's view of the situation.

Maybe make it more obvious that this is really about the runtime property (has the guest switched into secure and yet yet switched back via reboot).

Same for set_description, maybe something like "true while the guest runs in protected virtualization mode (read-only)", plus one line in docs/system/s390x/protvirt.rst. The docs line matters because read-only properties don't appear in -M s390-ccw-virtio,help

In any case

Quoted 38 lines
CC Hendrik Brueckner <[email protected]>
---
  hw/s390x/s390-virtio-ccw.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
hw/s390x/s390-virtio-ccw.c +13 -0
index 7fb78d8fa1..42ecfa59f3 100644
@@ -838,6 +838,13 @@ static inline void machine_set_secure_boot(Object *obj, bool value,
      ms->secure_boot = value;
  }
 
+static inline bool machine_get_pv(Object *obj, Error **errp)
+{
+    S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
+
+    return ms->pv;
+}
+
   /*
    * S390x-specific global compatibility properties.
    *
@@ -919,6 +926,12 @@ static void ccw_machine_class_init(ObjectClass *oc, const void *data)
                                     machine_set_secure_boot);
      object_class_property_set_description(oc, "secure-boot",
              "enable/disable secure boot");
+
+    object_class_property_add_bool(oc, "pv",
+                                   machine_get_pv,
+                                   NULL);
+    object_class_property_set_description(oc, "pv",
+            "protected virtualization state (read-only)");
  }
 
  static inline void s390_machine_initfn(Object *obj)
#5 lore raw
Quoted 11 lines · Christian Borntraeger

Am 23.09.26 um 10:33 schrieb Janosch Frank:

Quoted 3 lines

People doing VM management requested a way to query if a VM is in PV or not. This of course does never replace attestation, it's merely QEMU's view of the situation.

Maybe make it more obvious that this is really about the runtime property (has the guest switched into secure and yet yet switched back via reboot).

Quoted 9 lines

Same for set_description, maybe something like "true while the guest runs in protected virtualization mode (read-only)", plus one line in docs/system/s390x/protvirt.rst. The docs line matters because read-only properties don't appear in -M s390-ccw-virtio,help

In any case

Something like this for the docs?

PV property
-----------

The s390x-ccw machine exposes the read-only runtime "pv" property. This property is true if a guest successfully made the transition into PV mode as reported by KVM and hasn't yet exited PV mode via a reboot. This does not replace PV attestation which is the only authoritative way to get a definitive answer if a guest is truly protected.

#6 lore raw

Am 24.09.26 um 10:35 schrieb Janosch Frank:

Quoted 27 lines · Christian Borntraeger
Quoted 11 lines

Am 23.09.26 um 10:33 schrieb Janosch Frank:

Quoted 3 lines

People doing VM management requested a way to query if a VM is in PV or not. This of course does never replace attestation, it's merely QEMU's view of the situation.

Maybe make it more obvious that this is really about the runtime property (has the guest switched into secure and yet yet switched back via reboot).

Quoted 9 lines

Same for set_description, maybe something like "true while the guest runs in protected virtualization mode (read-only)", plus one line in docs/system/s390x/protvirt.rst. The docs line matters because read-only properties don't appear in -M s390-ccw-virtio,help

In any case

Something like this for the docs?

PV property
-----------

Quoted 7 lines

The s390x-ccw machine exposes the read-only runtime "pv" property. This property is true if a guest successfully made the transition into PV mode as reported by KVM and hasn't yet exited PV mode via a reboot. This does not replace PV attestation which is the only authoritative way to get a definitive answer if a guest is truly protected.

looks good.