All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luigi Leonardi <leonardi@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	 Stefano Garzarella <sgarzare@redhat.com>,
	Ani Sinha <anisinha@redhat.com>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	Zhao Liu <zhao1.liu@intel.com>,
	 Marcelo Tosatti <mtosatti@redhat.com>,
	kvm@vger.kernel.org,  Luigi Leonardi <leonardi@redhat.com>
Subject: [PATCH 3/4] i386/sev: convert the guest policy properties to custom accessors
Date: Tue, 01 Sep 2026 12:09:20 +0200	[thread overview]
Message-ID: <20260901-fix_igvm_policy-v1-3-e93a6cf8c5ac@redhat.com> (raw)
In-Reply-To: <20260901-fix_igvm_policy-v1-0-e93a6cf8c5ac@redhat.com>

Both SEV/SEV-ES and SEV-SNP expose a "policy" object property. The
SEV/SEV-ES one was registered as a plain uint32 pointer property, and
the SEV-SNP setter ignored the result of the visit.

Give both properties explicit getter/setter functions and check the
return value of the visit in the setters. This is preparation for
tracking whether the guest policy was set on the command line.

No functional change intended.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
---
 target/i386/sev.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/target/i386/sev.c b/target/i386/sev.c
index 465415c535..c76cdba8d2 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -2956,6 +2956,22 @@ sev_guest_class_init(ObjectClass *oc, const void *data)
             "use legacy VM type to maintain measurement compatibility with older QEMU or kernel versions.");
 }
 
+static void
+sev_guest_get_policy(Object *obj, Visitor *v, const char *name,
+                     void *opaque, Error **errp)
+{
+    visit_type_uint32(v, name, &SEV_GUEST(obj)->policy, errp);
+}
+
+static void
+sev_guest_set_policy(Object *obj, Visitor *v, const char *name,
+                     void *opaque, Error **errp)
+{
+    if (!visit_type_uint32(v, name, &SEV_GUEST(obj)->policy, errp)) {
+        return;
+    }
+}
+
 static void
 sev_guest_instance_init(Object *obj)
 {
@@ -2964,8 +2980,8 @@ sev_guest_instance_init(Object *obj)
     sev_guest->policy = DEFAULT_GUEST_POLICY;
     object_property_add_uint32_ptr(obj, "handle", &sev_guest->handle,
                                    OBJ_PROP_FLAG_READWRITE);
-    object_property_add_uint32_ptr(obj, "policy", &sev_guest->policy,
-                                   OBJ_PROP_FLAG_READWRITE);
+    object_property_add(obj, "policy", "uint32", sev_guest_get_policy,
+                        sev_guest_set_policy, NULL, NULL);
     object_apply_compat_props(obj);
 
     sev_guest->legacy_vm_type = ON_OFF_AUTO_AUTO;
@@ -3004,9 +3020,13 @@ static void
 sev_snp_guest_set_policy(Object *obj, Visitor *v, const char *name,
                          void *opaque, Error **errp)
 {
-    visit_type_uint64(v, name,
-                      (uint64_t *)&SEV_SNP_GUEST(obj)->kvm_start_conf.policy,
-                      errp);
+    SevSnpGuestState *sev_snp_guest = SEV_SNP_GUEST(obj);
+
+    if (!visit_type_uint64(v, name,
+                           (uint64_t *)&sev_snp_guest->kvm_start_conf.policy,
+                           errp)) {
+        return;
+    }
 }
 
 static char *

-- 
2.55.0


  parent reply	other threads:[~2026-09-01 10:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 10:09 [PATCH 0/4] igvm/sev: apply the IGVM guest policy before launch Luigi Leonardi
2026-09-01 10:09 ` [PATCH 1/4] sev: rename set_guest_policy to set_id_block and remove dead policy code Luigi Leonardi
2026-09-03  8:47   ` Ani Sinha
2026-09-03 10:32   ` Stefano Garzarella
2026-09-03 10:47     ` Luigi Leonardi
2026-09-03 13:55       ` Stefano Garzarella
2026-09-04  5:29         ` Gerd Hoffmann
2026-09-01 10:09 ` [PATCH 2/4] igvm: move set_id_block call into the SNP ID block directive handler Luigi Leonardi
2026-09-03 12:57   ` Stefano Garzarella
2026-09-03 13:29     ` Luigi Leonardi
2026-09-03 15:53       ` Stefano Garzarella
2026-09-01 10:09 ` Luigi Leonardi [this message]
2026-09-03  8:46   ` [PATCH 3/4] i386/sev: convert the guest policy properties to custom accessors Ani Sinha
2026-09-01 10:09 ` [PATCH 4/4] igvm/sev: forward the IGVM guest policy to the platform before launch Luigi Leonardi
2026-09-03  8:46   ` Ani Sinha
2026-09-03  9:01     ` Luigi Leonardi
2026-09-03 10:03       ` Ani Sinha
2026-09-03 11:02         ` Luigi Leonardi
2026-09-03 11:34           ` Ani Sinha
2026-09-03 11:50           ` Daniel P. Berrangé
2026-09-03 13:28             ` Stefano Garzarella
2026-09-03 13:40               ` Luigi Leonardi
2026-09-04  5:45                 ` Gerd Hoffmann
2026-09-03 13:14   ` Stefano Garzarella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260901-fix_igvm_policy-v1-3-e93a6cf8c5ac@redhat.com \
    --to=leonardi@redhat.com \
    --cc=anisinha@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.