From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Luigi Leonardi <leonardi@redhat.com>
Cc: Ani Sinha <anisinha@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>,
Gerd Hoffmann <kraxel@redhat.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Zhao Liu <zhao1.liu@intel.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH 4/4] igvm/sev: forward the IGVM guest policy to the platform before launch
Date: Thu, 3 Sep 2026 12:50:31 +0100 [thread overview]
Message-ID: <aplfB4L_WoFdpeBD@redhat.com> (raw)
In-Reply-To: <aplQKjieyMHUoCWs@leonardi-redhat>
On Thu, Sep 03, 2026 at 01:02:17PM +0200, Luigi Leonardi wrote:
> On Thu, Sep 03, 2026 at 03:33:30PM +0530, Ani Sinha wrote:
> >
> >
> > > On 3 Sep 2026, at 2:31 PM, Luigi Leonardi <leonardi@redhat.com> wrote:
> > >
> > > Hi Ani,
> > >
> > > On Thu, Sep 03, 2026 at 02:16:30PM +0530, Ani Sinha wrote:
> > > >
> > > >
> > > > > On 1 Sep 2026, at 3:39 PM, Luigi Leonardi <leonardi@redhat.com> wrote:
> > > > >
> > > > > The guest policy carried in the IGVM guest-policy initialization header
> > > > > was parsed into QIgvm but never forwarded to the confidential guest
> > > > > platform: the previous callback ran at the end of qigvm_process_file,
> > > > > after LAUNCH_START had already been issued, so writing the policy had
> > > > > no effect.
> > > > >
> > > > > Add a set_guest_policy callback and invoke it from the guest-policy
> > > > > initialization handler, so the policy reaches the platform before
> > > > > LAUNCH_START.
> > > > >
> > > > > The guest policy can also be set on the command line. As it is part of
> > > > > the attestation report, silently overriding it would cause attestation
> > > > > to fail, so return an error if the command-line value differs from the
> > > > > one supplied by the IGVM file.
> > > > >
> > > > > Link: https://gitlab.com/qemu-project/qemu/-/work_items/4189
> > > > > Fixes: 915b47078d ("backends/igvm: Handle policy for SEV guests")
> > > > > Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
> > > > > ---
> > > > > backends/confidential-guest-support.c | 9 ++++++++
> > > > > backends/igvm.c | 4 ++++
> > > > > target/i386/sev.c | 39 +++++++++++++++++++++++++++++++++++
> > > > > 3 files changed, 52 insertions(+)
> > > > >
> > > > > diff --git a/backends/confidential-guest-support.c b/backends/confidential-guest-support.c
> > > > > index a0b36d2da5..c0d15b4a76 100644
> > > > > --- a/backends/confidential-guest-support.c
> > > > > +++ b/backends/confidential-guest-support.c
> > > > > @@ -38,6 +38,14 @@ static int set_guest_state(hwaddr gpa, uint8_t *ptr, uint64_t len,
> > > > > return -1;
> > > > > }
> > > > >
> > > > > +static int set_guest_policy(ConfidentialGuestPolicyType policy_type,
> > > > > + uint64_t policy, Error **errp)
> > > > > +{
> > > > > + error_setg(errp,
> > > > > + "Setting guest policy is not supported for this platform");
> > > > > + return -1;
> > > > > +}
> > > > > +
> > > > > static int set_id_block(void *id_block, uint32_t id_block_size,
> > > > > void *id_auth, uint32_t id_auth_size,
> > > > > Error **errp)
> > > > > @@ -62,6 +70,7 @@ static void confidential_guest_support_class_init(ObjectClass *oc,
> > > > > ConfidentialGuestSupportClass *cgsc = CONFIDENTIAL_GUEST_SUPPORT_CLASS(oc);
> > > > > cgsc->check_support = check_support;
> > > > > cgsc->set_guest_state = set_guest_state;
> > > > > + cgsc->set_guest_policy = set_guest_policy;
> > > > > cgsc->set_id_block = set_id_block;
> > > > > cgsc->get_mem_map_entry = get_mem_map_entry;
> > > > > }
> > > > > diff --git a/backends/igvm.c b/backends/igvm.c
> > > > > index 6545382546..5131ee7829 100644
> > > > > --- a/backends/igvm.c
> > > > > +++ b/backends/igvm.c
> > > > > @@ -868,6 +868,10 @@ static int qigvm_initialization_guest_policy(QIgvm *ctx,
> > > > >
> > > > > if (guest->compatibility_mask & ctx->compatibility_mask) {
> > > > > ctx->sev_policy = guest->policy;
> > > > > + if (ctx->cgsc) {
> > > > > + return ctx->cgsc->set_guest_policy(GUEST_POLICY_SEV,
> > > > > + guest->policy, errp);
> > > > > + }
> > > > > }
> > > > > return 0;
> > > > > }
> > > > > diff --git a/target/i386/sev.c b/target/i386/sev.c
> > > > > index c76cdba8d2..533ea4b54e 100644
> > > > > --- a/target/i386/sev.c
> > > > > +++ b/target/i386/sev.c
> > > > > @@ -128,6 +128,8 @@ struct SevCommonState {
> > > > > bool kernel_hashes;
> > > > > uint64_t sev_features;
> > > > > uint64_t supported_sev_features;
> > > > > + /* whether the guest policy was explicitly set on the command line */
> > > > > + bool policy_set;
> > > > >
> > > > > /* runtime state */
> > > > > uint8_t api_major;
> > > > > @@ -2723,6 +2725,40 @@ static int cgs_get_mem_map_entry(int index,
> > > > > return 0;
> > > > > }
> > > > >
> > > > > +static int cgs_set_guest_policy(ConfidentialGuestPolicyType policy_type,
> > > > > + uint64_t policy, Error **errp)
> > > > > +{
> > > > > + SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs);
> > > > > +
> > > > > + if (policy_type != GUEST_POLICY_SEV) {
> > > > > + error_setg(errp, "SEV: Invalid guest policy type provided for SEV: %d",
> > > > > + policy_type);
> > > > > + return -1;
> > > > > + }
> > > > > +
> > > > > + if (sev_snp_enabled()) {
> > > > > + SevSnpGuestState *sev_snp_guest = SEV_SNP_GUEST(sev_common);
> > > > > +
> > > > > + if (sev_common->policy_set &&
> > > > > + sev_snp_guest->kvm_start_conf.policy != policy) {
> > > > > + error_setg(errp, "SNP: policy mismatch between IGVM and CLI");
> > > > > + return -1;
> > > > > + }
> > > > > +
> > > > > + sev_snp_guest->kvm_start_conf.policy = policy;
> > >
> > > Thanks for you review!
> > >
> > > >
> > > > I had fixed a bug initially here where we need to check if the policy passed is not 0. I am not sure if that fix is still needed here.
> > > > Please test this scenario:
> > > > a) Generate an IGVM file with policy set to 0.
> > >
> > > 0 is not a valid sev-snp guest policy: bit 17 is reserved and must be 1.
> > > It's a valid sev/sev-es policy though.
> > >
> > > > b) Start a confidential SEV-SNP guest with policy set in command line and with this IGVM.
> > > > I think with your patch this will fail as the policies won’t match.
> > >
> > > Correct: this was suggested by Gerd, as this is something unexpected. I
> > > think it would break launch measurement.
> >
> > Yes I think the right thing to do is that if the policy is correctly set by IGVM, override the one set in the cli with the one in IGVM. Otherwise ignore IGVM policy.
As a general rule, if the user passes a parameter to QEMU, it should
always either be honoured, or result in an error. Selectively ignoring
user input has proved to be a generally bad idea, as it tends to mask
user configuration mistakes.
> mmh why? I might be missing something, but for now I'm not really convinced:
> if we have a policy set in IGVM we should use that one. Overriding it using the
> CLI, may cause measurement failure. If we have an IGVM image with a wrong policy
> set, then the problem should be fixed there.
If the user choose to override policy on the CLI, isn't it now just
their problem to also figure out what the new expected measurement
will be ?
Why wouldn't we just honour the IGVM by default, and if the CLI
has further customizations let them override the IGVM, and leave
the user to figure out the implications.
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
next prev parent reply other threads:[~2026-09-03 11:50 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 ` [PATCH 3/4] i386/sev: convert the guest policy properties to custom accessors Luigi Leonardi
2026-09-03 8:46 ` 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é [this message]
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=aplfB4L_WoFdpeBD@redhat.com \
--to=berrange@redhat.com \
--cc=anisinha@redhat.com \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=leonardi@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox