From nobody Fri Oct 23 20:56:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1792600420; cv=none; d=zohomail.com; s=zohoarc; b=C7LmVEtAx24mX981BJTVd8P6DRVJh7zy3yAjTfmKTrlBOlA/kYV4oDU/vhTeRMdQ7uoxoAJTiNrBNdBzC3b/ACtjFjQSPGSpnzmdn0FD+PWOeE+IhgECdN9geCdyaLMJudiGYQKW0mePN5RCHUJNeRKVIg/K/AQNzXTVETlrP8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792600420; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HbURt7v9JUeQGhBp2lGuz+nQCWNIMP9K6cbbgKupvA4=; b=inQ2gvDc2OVxTSMytrlphfqDPAxIhPJ1D1JWPAn6siOBGNNhqHDae63qgHKq5l3Yf01ZSu5qnVcLJpguYj8wl4NCe4IAJrLiDTDliGaQ+U6iY5DMWEIuatSd6XYZJEaS5J0O8WOQPG1/G2SYgNEHEdB9yRlRhk0v1EBZNIaiv34= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792600420112994.3693284017426; Wed, 21 Oct 2026 09:33:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJZFJ-0007Ux-1W; Wed, 21 Oct 2026 12:32:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFC-0007TD-Ro for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZF9-0006UE-Lz for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:50 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-iVK0IVqhNwmpeBzbgj2NFA-1; Wed, 21 Oct 2026 16:32:42 +0000 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 845BF195607F; Wed, 21 Oct 2026 16:32:41 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.54]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 94E021956087; Wed, 21 Oct 2026 16:32:40 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 5808A182758E; Wed, 21 Oct 2026 18:32:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792600366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HbURt7v9JUeQGhBp2lGuz+nQCWNIMP9K6cbbgKupvA4=; b=Ca0okcYdrq82Auk3jPo/GbMk2HBfVgTkHOAz0nr+apnLVKfY8esZmM3OZuX3b4F0P23EJv 3YRFsQKSX0YJZjqVNTEd9ngbdwuy/+dF446pj76xHCci5AH20IaBXf3nLA8f3VnJtPWLT3 1EYHYxfNcnRYi5wDDOAPBjou0LUdkAI= X-MC-Unique: iVK0IVqhNwmpeBzbgj2NFA-1 X-Mimecast-MFC-AGG-ID: iVK0IVqhNwmpeBzbgj2NFA_1792600361 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Stefano Garzarella , Marcelo Tosatti , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Pierrick Bouvier , Zhao Liu , Ani Sinha , Paolo Bonzini , Eric Blake , Gerd Hoffmann , Luigi Leonardi Subject: [PULL 01/10] sev: split set_guest_policy into set_guest_policy and set_id_block Date: Wed, 21 Oct 2026 18:32:29 +0200 Message-ID: <20261021163239.1131460-2-kraxel@redhat.com> In-Reply-To: <20261021163239.1131460-1-kraxel@redhat.com> References: <20261021163239.1131460-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1792600421743158500 Content-Type: text/plain; charset="utf-8" From: Luigi Leonardi The set_guest_policy callback on ConfidentialGuestSupportClass mixed two unrelated jobs: writing the guest policy bits and providing the SEV-SNP ID block/ID auth for LAUNCH_FINISH. The two are only related because both come from the same 'policy' section of the SEV/SEV-SNP launch flow, but they need to be set at different times: the policy must be in effect before LAUNCH_START, while the ID block is only needed before LAUNCH_FINISH. Split the combined callback into set_guest_policy(policy_type, policy, errp) and set_id_block(id_block, id_block_size, id_auth, id_auth_size, errp), keeping both call sites exactly where the combined callback used to be called from. No functional change. Signed-off-by: Luigi Leonardi Reviewed-by: Ani Sinha Message-ID: <20260907-fix_igvm_policy-v2-1-c8c50f1dbfda@redhat.com> Signed-off-by: Gerd Hoffmann --- include/system/confidential-guest-support.h | 28 ++-- backends/confidential-guest-support.c | 15 +- backends/igvm.c | 14 +- target/i386/sev.c | 144 +++++++++++--------- 4 files changed, 113 insertions(+), 88 deletions(-) diff --git a/include/system/confidential-guest-support.h b/include/system/c= onfidential-guest-support.h index 5dca71730880..6d35ddb97a75 100644 --- a/include/system/confidential-guest-support.h +++ b/include/system/confidential-guest-support.h @@ -128,21 +128,23 @@ typedef struct ConfidentialGuestSupportClass { uint16_t cpu_index, Error **errp); =20 /* - * Set the guest policy. The policy can be used to configure the - * confidential platform, such as if debug is enabled or not and can c= ontain - * information about expected launch measurements, signed verification= of - * guest configuration and other platform data. - * - * The format of the policy data is specific to each platform. For exa= mple, - * SEV-SNP uses a policy bitfield in the 'policy' argument and provide= s an - * ID block and ID authentication in the 'policy_data' parameters. The= type - * of policy data is identified by the 'policy_type' argument. + * Set the guest policy for the confidential platform. The policy + * configures properties of the guest, such as whether debug is + * enabled. Its format is platform-specific; for SEV/SEV-ES and + * SEV-SNP it is a policy bitfield. Must be called before LAUNCH_START + * so the policy is in effect for launch. */ int (*set_guest_policy)(ConfidentialGuestPolicyType policy_type, - uint64_t policy, - void *policy_data1, uint32_t policy_data1_size, - void *policy_data2, uint32_t policy_data2_size, - Error **errp); + uint64_t policy, Error **errp); + + /* + * Set the SEV-SNP ID block and ID authentication block. These are + * passed to SNP_LAUNCH_FINISH to provide signed verification of the + * guest configuration. + */ + int (*set_id_block)(void *id_block, uint32_t id_block_size, + void *id_auth, uint32_t id_auth_size, + Error **errp); =20 /* * Iterate the system memory map, getting the entry with the given ind= ex diff --git a/backends/confidential-guest-support.c b/backends/confidential-= guest-support.c index 156dd15e6677..d60d1f6eaaea 100644 --- a/backends/confidential-guest-support.c +++ b/backends/confidential-guest-support.c @@ -39,16 +39,22 @@ static int set_guest_state(hwaddr gpa, uint8_t *ptr, ui= nt64_t len, } =20 static int set_guest_policy(ConfidentialGuestPolicyType policy_type, - uint64_t policy, - void *policy_data1, uint32_t policy_data1_size, - void *policy_data2, uint32_t policy_data2_size, - Error **errp) + uint64_t policy, Error **errp) { error_setg(errp, "Setting confidential guest policy is not supported for thi= s platform"); return -1; } =20 +static int set_id_block(void *id_block, uint32_t id_block_size, + void *id_auth, uint32_t id_auth_size, + Error **errp) +{ + error_setg(errp, + "Setting ID block is not supported for this platform"); + return -1; +} + static int get_mem_map_entry(int index, ConfidentialGuestMemoryMapEntry *e= ntry, Error **errp) { @@ -65,6 +71,7 @@ static void confidential_guest_support_class_init(ObjectC= lass *oc, cgsc->check_support =3D check_support; cgsc->set_guest_state =3D set_guest_state; cgsc->set_guest_policy =3D set_guest_policy; + cgsc->set_id_block =3D set_id_block; cgsc->get_mem_map_entry =3D get_mem_map_entry; } =20 diff --git a/backends/igvm.c b/backends/igvm.c index 58f3097e8518..1aa6803cfa25 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -1006,14 +1006,22 @@ static int qigvm_handle_policy(QIgvm *ctx, Error **= errp) if (ctx->platform_type =3D=3D IGVM_PLATFORM_TYPE_SEV_SNP) { int id_block_len =3D 0; int id_auth_len =3D 0; + int retval; + if (ctx->id_block) { ctx->id_block->policy =3D ctx->sev_policy; id_block_len =3D sizeof(struct sev_id_block); id_auth_len =3D sizeof(struct sev_id_authentication); } - return ctx->cgsc->set_guest_policy(GUEST_POLICY_SEV, ctx->sev_poli= cy, - ctx->id_block, id_block_len, - ctx->id_auth, id_auth_len, errp); + + retval =3D ctx->cgsc->set_guest_policy(GUEST_POLICY_SEV, ctx->sev_= policy, + errp); + if (retval < 0) { + return retval; + } + + return ctx->cgsc->set_id_block(ctx->id_block, id_block_len, + ctx->id_auth, id_auth_len, errp); } return 0; } diff --git a/target/i386/sev.c b/target/i386/sev.c index cc16c6b07123..b53d13e2fa28 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -2726,9 +2726,7 @@ static int cgs_get_mem_map_entry(int index, } =20 static int cgs_set_guest_policy(ConfidentialGuestPolicyType policy_type, - uint64_t policy, void *policy_data1, - uint32_t policy_data1_size, void *policy_d= ata2, - uint32_t policy_data2_size, Error **errp) + uint64_t policy, Error **errp) { SevCommonState *sev_common =3D SEV_COMMON(MACHINE(qdev_get_machine())-= >cgs); if (sev_common->state =3D=3D SEV_STATE_UNINIT) { @@ -2741,81 +2739,90 @@ static int cgs_set_guest_policy(ConfidentialGuestPo= licyType policy_type, policy_type); return -1; } - /* - * SEV-SNP handles policy differently. The policy flags are defined in - * kvm_start_conf.policy and an ID block and ID auth can be provided. - */ + + /* do not reset existing policy if policy was not set in IGVM */ + if (policy =3D=3D 0) { + return 0; + } + if (sev_snp_enabled()) { SevSnpGuestState *sev_snp_guest =3D SEV_SNP_GUEST(MACHINE(qdev_get_machine())->cgs); - struct kvm_sev_snp_launch_finish *finish =3D - &sev_snp_guest->kvm_finish_conf; =20 - /* - * The policy consists of flags in 'policy' and optionally an ID b= lock - * and ID auth in policy_data1 and policy_data2 respectively. The = ID - * block and auth are optional so clear any previous ID block and = auth - * and set them if provided, but always set the policy flags. - */ - g_free(sev_snp_guest->id_block); - g_free((guchar *)finish->id_block_uaddr); - g_free(sev_snp_guest->id_auth); - g_free((guchar *)finish->id_auth_uaddr); - sev_snp_guest->id_block =3D NULL; - finish->id_block_uaddr =3D 0; - sev_snp_guest->id_auth =3D NULL; - finish->id_auth_uaddr =3D 0; - - if (policy_data1_size > 0) { - struct sev_snp_id_authentication *id_auth =3D - (struct sev_snp_id_authentication *)policy_data2; - - if (policy_data1_size !=3D KVM_SEV_SNP_ID_BLOCK_SIZE) { - error_setg(errp, "SEV: Invalid SEV-SNP ID block: incorrect= size"); - return -1; - } - if (policy_data2_size !=3D KVM_SEV_SNP_ID_AUTH_SIZE) { - error_setg(errp, - "SEV: Invalid SEV-SNP ID auth block: incorrect = size"); - return -1; - } - assert(policy_data1 !=3D NULL); - assert(policy_data2 !=3D NULL); - - finish->id_block_uaddr =3D - (__u64)g_memdup2(policy_data1, KVM_SEV_SNP_ID_BLOCK_SIZE); - finish->id_auth_uaddr =3D - (__u64)g_memdup2(policy_data2, KVM_SEV_SNP_ID_AUTH_SIZE); - - /* - * Check if an author key has been provided and use that to fl= ag - * whether the author key is enabled. The first of the author = key - * must be non-zero to indicate the key type, which will curre= ntly - * always be 2. - */ - sev_snp_guest->kvm_finish_conf.auth_key_en =3D - id_auth->author_key[0] ? 1 : 0; - finish->id_block_en =3D 1; - } - - /* do not reset existing policy if policy was not set in IGVM */ - if (policy !=3D 0) { - sev_snp_guest->kvm_start_conf.policy =3D policy; - } + sev_snp_guest->kvm_start_conf.policy =3D policy; } else { SevGuestState *sev_guest =3D SEV_GUEST(MACHINE(qdev_get_machine())= ->cgs); - /* Only the policy flags are supported for SEV and SEV-ES */ - if ((policy_data1_size > 0) || (policy_data2_size > 0) || !sev_gue= st) { - error_setg(errp, "SEV: An ID block/ID auth block has been prov= ided " - "but SEV-SNP is not enabled"); + + sev_guest->policy =3D policy; + } + return 0; +} + +static int cgs_set_id_block(void *id_block, uint32_t id_block_size, + void *id_auth, uint32_t id_auth_size, + Error **errp) +{ + SevCommonState *sev_common =3D SEV_COMMON(MACHINE(qdev_get_machine())-= >cgs); + if (sev_common->state =3D=3D SEV_STATE_UNINIT) { + /* Pre-processing of IGVM file called from sev_common_kvm_init() */ + return 0; + } + + if (!sev_snp_enabled()) { + error_setg(errp, "SEV: ID block is only supported for SEV-SNP"); + return -1; + } + + SevSnpGuestState *sev_snp_guest =3D + SEV_SNP_GUEST(MACHINE(qdev_get_machine())->cgs); + struct kvm_sev_snp_launch_finish *finish =3D + &sev_snp_guest->kvm_finish_conf; + + /* + * Drop any ID block and ID auth from a previous pass before repopulat= ing + * them, then set them only if an ID block was provided. + */ + g_free(sev_snp_guest->id_block); + g_free((guchar *)finish->id_block_uaddr); + g_free(sev_snp_guest->id_auth); + g_free((guchar *)finish->id_auth_uaddr); + sev_snp_guest->id_block =3D NULL; + finish->id_block_uaddr =3D 0; + sev_snp_guest->id_auth =3D NULL; + finish->id_auth_uaddr =3D 0; + + if (id_block_size > 0) { + struct sev_snp_id_authentication *auth =3D + (struct sev_snp_id_authentication *)id_auth; + + if (id_block_size !=3D KVM_SEV_SNP_ID_BLOCK_SIZE) { + error_setg(errp, "SEV: Invalid SEV-SNP ID block: incorrect siz= e"); return -1; } - - /* do not reset existing policy if policy was not set in IGVM */ - if (policy !=3D 0) { - sev_guest->policy =3D policy; + if (id_auth_size !=3D KVM_SEV_SNP_ID_AUTH_SIZE) { + error_setg(errp, + "SEV: Invalid SEV-SNP ID auth block: incorrect size= "); + return -1; } + assert(id_block !=3D NULL); + assert(id_auth !=3D NULL); + + finish->id_block_uaddr =3D + (__u64)g_memdup2(id_block, KVM_SEV_SNP_ID_BLOCK_SIZE); + finish->id_auth_uaddr =3D + (__u64)g_memdup2(id_auth, KVM_SEV_SNP_ID_AUTH_SIZE); + + /* + * Check if an author key has been provided and use that to flag + * whether the author key is enabled. The first of the author key + * must be non-zero to indicate the key type, which will currently + * always be 2. + */ + sev_snp_guest->kvm_finish_conf.auth_key_en =3D + auth->author_key[0] ? 1 : 0; + finish->id_block_en =3D 1; } + return 0; } =20 @@ -2881,6 +2888,7 @@ sev_common_instance_init(Object *obj) cgs->set_guest_state =3D cgs_set_guest_state; cgs->get_mem_map_entry =3D cgs_get_mem_map_entry; cgs->set_guest_policy =3D cgs_set_guest_policy; + cgs->set_id_block =3D cgs_set_id_block; cgs->can_rebuild_guest_state =3D true; =20 QTAILQ_INIT(&sev_common->launch_vmsa); --=20 2.56.0 From nobody Fri Oct 23 20:56:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1792600540; cv=none; d=zohomail.com; s=zohoarc; b=ZiJbRh+k4k6NCnBE4lWJFnNbv6iBg+r851kr0xRVuEkkPO7LynyPQBV4DqNEA2hr9GN2kOny9IyosI7RmVo7xNGQC6ujt5nEtwaToRyDV5nGsLES7IPhsTlMzEyDvZBR4O619dt8WDY4O7GGq4FvT/loJBN6KzLYrbpB+YrX058= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792600540; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=q2MrFdc6Sie1JbwGOY2VkttNuMrZ212OJNslhmZssDs=; b=Z7A7nstWxPN5orr9A3G77JzqlMEAJD1JvOW/ckxoPFPNEUh1ttWGGow/xV/ogG0vsvrmQEgKbsmHPXiDi3lrqSLusLRWwCGynxueOkyQPfA1PpkGT0NCXNBtCe0r7ew3nagyd9RjXtB0Fm/fKYv7m4YnSH4WNFY1R+W2NpVvKxw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792600540018243.98823897562443; Wed, 21 Oct 2026 09:35:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJZFM-0007Vo-Kp; Wed, 21 Oct 2026 12:33:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFE-0007TR-Cn for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFB-0006UR-0C for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:52 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-z1vvkXVMOdSkHPsDkU7_6A-1; Wed, 21 Oct 2026 16:32:43 +0000 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AF4E41956094; Wed, 21 Oct 2026 16:32:42 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.54]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D849A5BC; Wed, 21 Oct 2026 16:32:41 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 668911827590; Wed, 21 Oct 2026 18:32:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792600368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q2MrFdc6Sie1JbwGOY2VkttNuMrZ212OJNslhmZssDs=; b=QG7LSA3H8QxO2FWYBQuwIHaNfVOTtzUhbXR8oIRz9OYLbX7lDR20IvpT6QFrkneMuNnGRE SXviBOSC2w+bmm2MWDN/kl6qqdjENgy7tXIUq5I1JKClr71y/HppE1T1Btd4bUs/yG+ETG liB4uKq3XJqxyATicaZFDuodkPszw5M= X-MC-Unique: z1vvkXVMOdSkHPsDkU7_6A-1 X-Mimecast-MFC-AGG-ID: z1vvkXVMOdSkHPsDkU7_6A_1792600362 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Stefano Garzarella , Marcelo Tosatti , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Pierrick Bouvier , Zhao Liu , Ani Sinha , Paolo Bonzini , Eric Blake , Gerd Hoffmann , Luigi Leonardi Subject: [PULL 02/10] igvm: move set_id_block call into the SNP ID block directive handler Date: Wed, 21 Oct 2026 18:32:30 +0200 Message-ID: <20261021163239.1131460-3-kraxel@redhat.com> In-Reply-To: <20261021163239.1131460-1-kraxel@redhat.com> References: <20261021163239.1131460-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1792600541458158500 Content-Type: text/plain; charset="utf-8" From: Luigi Leonardi set_id_block only makes sense when the IGVM file contains an IGVM_VHT_SNP_ID_BLOCK directive. Move the call from qigvm_handle_policy (which continues to handle the set_guest_policy call) into qigvm_directive_snp_id_block, where the ID block and ID auth are populated. This avoids a no-op call to set_id_block when no ID block is present. The ID block embeds the guest policy, so the policy must be known by the time the directive is handled. Process the initialization section (which carries the GUEST_POLICY header) before the directive section, and copy ctx->sev_policy into the ID block in the directive handler. Signed-off-by: Luigi Leonardi Message-ID: <20260907-fix_igvm_policy-v2-2-c8c50f1dbfda@redhat.com> Signed-off-by: Gerd Hoffmann --- backends/igvm.c | 80 ++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/backends/igvm.c b/backends/igvm.c index 1aa6803cfa25..2ee60ada94b9 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -821,6 +821,8 @@ static int qigvm_directive_snp_id_block(QIgvm *ctx, con= st uint8_t *header_data, ctx->id_block->version =3D IGVM_SEV_ID_BLOCK_VERSION; memcpy(ctx->id_block->ld, igvm_id->ld, sizeof(ctx->id_block->ld)); =20 + ctx->id_block->policy =3D ctx->sev_policy; + ctx->id_auth->id_key_alg =3D igvm_id->id_key_algorithm; assert(sizeof(igvm_id->id_key_signature) <=3D sizeof(ctx->id_auth->id_block_sig)); @@ -848,6 +850,14 @@ static int qigvm_directive_snp_id_block(QIgvm *ctx, co= nst uint8_t *header_data, memcpy(&ctx->id_auth->author_key[76], &igvm_id->author_public_key.qy, 72); =20 + if (ctx->cgsc) { + return ctx->cgsc->set_id_block(ctx->id_block, + sizeof(struct sev_id_block), + ctx->id_auth, + sizeof(struct sev_id_authentication= ), + errp); + } + return 0; } =20 @@ -1004,24 +1014,8 @@ static int qigvm_supported_platform_compat_mask(QIgv= m *ctx, Error **errp) static int qigvm_handle_policy(QIgvm *ctx, Error **errp) { if (ctx->platform_type =3D=3D IGVM_PLATFORM_TYPE_SEV_SNP) { - int id_block_len =3D 0; - int id_auth_len =3D 0; - int retval; - - if (ctx->id_block) { - ctx->id_block->policy =3D ctx->sev_policy; - id_block_len =3D sizeof(struct sev_id_block); - id_auth_len =3D sizeof(struct sev_id_authentication); - } - - retval =3D ctx->cgsc->set_guest_policy(GUEST_POLICY_SEV, ctx->sev_= policy, - errp); - if (retval < 0) { - return retval; - } - - return ctx->cgsc->set_id_block(ctx->id_block, id_block_len, - ctx->id_auth, id_auth_len, errp); + return ctx->cgsc->set_guest_policy(GUEST_POLICY_SEV, ctx->sev_poli= cy, + errp); } return 0; } @@ -1083,6 +1077,34 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *m= achine_state, goto cleanup; } =20 + /* + * Process the initialization section first so that the guest policy is + * known before the directive section is handled. The SNP ID block + * directive embeds the guest policy into the ID block, so the policy = from + * the guest policy initialization header must be available by then. + */ + header_count =3D + igvm_header_count(ctx.cfg->file, IGVM_HEADER_SECTION_INITIALIZATIO= N); + if (header_count < 0) { + error_setg( + errp, + "Invalid initialization header count in IGVM file. Error code:= %X", + header_count); + goto cleanup; + } + + for (ctx.current_header_index =3D 0; + ctx.current_header_index < (unsigned)header_count; + ctx.current_header_index++) { + IgvmVariableHeaderType type =3D + igvm_get_header_type(ctx.cfg->file, + IGVM_HEADER_SECTION_INITIALIZATION, + ctx.current_header_index); + if (qigvm_handler(&ctx, type, errp) < 0) { + goto cleanup; + } + } + header_count =3D igvm_header_count(ctx.cfg->file, IGVM_HEADER_SECTION_DIRECTIVE); if (header_count <=3D 0) { @@ -1116,28 +1138,6 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *m= achine_state, goto cleanup_parameters; } =20 - header_count =3D - igvm_header_count(ctx.cfg->file, IGVM_HEADER_SECTION_INITIALIZATIO= N); - if (header_count < 0) { - error_setg( - errp, - "Invalid initialization header count in IGVM file. Error code:= %X", - header_count); - goto cleanup_parameters; - } - - for (ctx.current_header_index =3D 0; - ctx.current_header_index < (unsigned)header_count; - ctx.current_header_index++) { - IgvmVariableHeaderType type =3D - igvm_get_header_type(ctx.cfg->file, - IGVM_HEADER_SECTION_INITIALIZATION, - ctx.current_header_index); - if (qigvm_handler(&ctx, type, errp) < 0) { - goto cleanup_parameters; - } - } - /* * Contiguous pages of data with compatible flags are grouped together= in * order to reduce the number of memory regions we create. Make sure t= he --=20 2.56.0 From nobody Fri Oct 23 20:56:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1792600481; cv=none; d=zohomail.com; s=zohoarc; b=eRl/SXvdFb4KMsEB7uryJ4yGUXht4r2POaXHxYEYOgw1d3eeXN7wJ66XI1+Kap5jwkyo9n+K0Nb+r8z3yQBehunkgOogsBTwZBFG3nGQKVCAJmv25Ky9/tGr49BANuPHAwT53QVV+4gyHQUkg2nJlCKpcYSq6QMJGf2E2+CNQXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792600481; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3yOq+0SmiKD4ABIG/MWGp5EqJWbc1XKSVkbY1vpqHNA=; b=GGoj0GZJYocps6x0Ujzf5tbI7+hT8oBDpipf1FFjty8yB77V63/yyNRXYMwVSTwr97AM/ZRHCHgOJ12OAabTxqXM90KBmbKAmQjFYJRU2vFRggpqvTNMsLDhIIJNCACUFJGjTgt/Tr22uE7mKYC7l+a50kGgfcTx+2c4TWZrILg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792600481603807.6031276803325; Wed, 21 Oct 2026 09:34:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJZFc-0007Zz-PL; Wed, 21 Oct 2026 12:33:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFH-0007Ub-Sl for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFG-0006Vv-4A for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:55 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-342-5FibhARGN1KXE4ZvAFowEw-1; Wed, 21 Oct 2026 12:32:44 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 474A71800662; Wed, 21 Oct 2026 16:32:43 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.54]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 70F381803A40; Wed, 21 Oct 2026 16:32:42 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A16D01827591; Wed, 21 Oct 2026 18:32:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792600372; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3yOq+0SmiKD4ABIG/MWGp5EqJWbc1XKSVkbY1vpqHNA=; b=alK8SfL1bekD8lboA//5jLebhP0T8QZF4Bn7eMGIwlGjFHT1drDtJJCgs5mupnuagsgkgZ axdpPzcjK4CfW8u+9g1OE6Cw+2eLzei/x7fycNpjmibF36QDKH8J45Yng2Og96nqy/pbRj 5NWlg+Ild4HLvOXyTLe9maSLmOjLAnQ= X-MC-Unique: 5FibhARGN1KXE4ZvAFowEw-1 X-Mimecast-MFC-AGG-ID: 5FibhARGN1KXE4ZvAFowEw_1792600363 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Stefano Garzarella , Marcelo Tosatti , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Pierrick Bouvier , Zhao Liu , Ani Sinha , Paolo Bonzini , Eric Blake , Gerd Hoffmann , Luigi Leonardi Subject: [PULL 03/10] i386/sev: convert the guest policy properties to custom accessors Date: Wed, 21 Oct 2026 18:32:31 +0200 Message-ID: <20261021163239.1131460-4-kraxel@redhat.com> In-Reply-To: <20261021163239.1131460-1-kraxel@redhat.com> References: <20261021163239.1131460-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1792600482546158501 Content-Type: text/plain; charset="utf-8" From: Luigi Leonardi 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. Reviewed-by: Ani Sinha Signed-off-by: Luigi Leonardi Message-ID: <20260907-fix_igvm_policy-v2-3-c8c50f1dbfda@redhat.com> Signed-off-by: Gerd Hoffmann --- 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 b53d13e2fa28..38f97fd9b2b3 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -2996,6 +2996,22 @@ sev_guest_class_init(ObjectClass *oc, const void *da= ta) "use legacy VM type to maintain measurement compatibility with= older QEMU or kernel versions."); } =20 +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) { @@ -3004,8 +3020,8 @@ sev_guest_instance_init(Object *obj) sev_guest->policy =3D 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); =20 sev_guest->legacy_vm_type =3D ON_OFF_AUTO_AUTO; @@ -3044,9 +3060,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.poli= cy, - errp); + SevSnpGuestState *sev_snp_guest =3D SEV_SNP_GUEST(obj); + + if (!visit_type_uint64(v, name, + (uint64_t *)&sev_snp_guest->kvm_start_conf.poli= cy, + errp)) { + return; + } } =20 static char * --=20 2.56.0 From nobody Fri Oct 23 20:56:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1792600486; cv=none; d=zohomail.com; s=zohoarc; b=axnhOuUn2pOLXMzhjhi9L8wV5u+fOeXwoZ6g7xWY+NaWtYTD7YSBjnwbcEu+oyhnqvYqRzD3xrtf1rQ9nXRMdZnQbOOJorVIpTMnJ9RJThFDaSvahwzLNmmAZw538PYbBv5RkdJxRvIjDr39GcBxNeIPY99ESF2EOwiJE6QwlAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792600486; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mo9A88zTUtWCxiYeFyiKtbxLLu+CYvfULiG4sQRriTU=; b=hW51i0enTfEsWz+q3bwDjEVIfWL5YsauSf6T72JP9eKxqIUbk7dKEdYUN4biaNa8dxgcDtJgP4DoVRzDYuwW1c6Mkpc1Yf5ED4TAuqoN9jF5P0TmK1yGXYrKRBMRSJHVsoUWfll3uxAXFJgccj1UU/BowrZa2Z9OPVnuztY5dPw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792600486342435.86706403918924; Wed, 21 Oct 2026 09:34:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJZFM-0007Vl-K2; Wed, 21 Oct 2026 12:33:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFF-0007TT-Gz for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFB-0006UZ-Jm for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:52 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-319-vDBKqBqAP3i7Vvm3pvuLVg-1; Wed, 21 Oct 2026 16:32:45 +0000 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 01EA31956089; Wed, 21 Oct 2026 16:32:44 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.54]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 821087D5; Wed, 21 Oct 2026 16:32:43 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C3FCF1827592; Wed, 21 Oct 2026 18:32:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792600368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mo9A88zTUtWCxiYeFyiKtbxLLu+CYvfULiG4sQRriTU=; b=Gg9hVCN0gXx1coF/uY1M+njtjY6HNsj76hoisGxrlQfzadUOSno+fJkypb+gvw0cuVMaUG SKq6vS0QsNSsP+poPYfAUTWUGlL0kN+E6DtznmlWzKoYJZO0jC2nT+mYQNpFIv67/3jFO0 LGXiWye8YGVecXOMQ3FoBe/48m+et4Q= X-MC-Unique: vDBKqBqAP3i7Vvm3pvuLVg-1 X-Mimecast-MFC-AGG-ID: vDBKqBqAP3i7Vvm3pvuLVg_1792600364 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Stefano Garzarella , Marcelo Tosatti , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Pierrick Bouvier , Zhao Liu , Ani Sinha , Paolo Bonzini , Eric Blake , Gerd Hoffmann , Luigi Leonardi Subject: [PULL 04/10] i386/sev: add a get_guest_policy callback Date: Wed, 21 Oct 2026 18:32:32 +0200 Message-ID: <20261021163239.1131460-5-kraxel@redhat.com> In-Reply-To: <20261021163239.1131460-1-kraxel@redhat.com> References: <20261021163239.1131460-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1792600488725158500 Content-Type: text/plain; charset="utf-8" From: Luigi Leonardi The next patch populates the SEV-SNP ID block's policy field. That value must be whatever policy is currently in effect on the platform but there is no way to read it back: the policy can come either from an IGVM GUEST_POLICY header or from the command line, and the command line sets it directly into the SEV/SNP guest struct without going through IGVM. Reading it back from the platform is the only source that always reflects the value in effect, regardless of where it came from. Add a get_guest_policy callback to ConfidentialGuestSupportClass for this purpose. It is not yet used; the following patch wires it into the SNP ID block population. Signed-off-by: Luigi Leonardi Message-ID: <20260907-fix_igvm_policy-v2-4-c8c50f1dbfda@redhat.com> Signed-off-by: Gerd Hoffmann --- include/system/confidential-guest-support.h | 8 +++++++ backends/confidential-guest-support.c | 9 ++++++++ target/i386/sev.c | 24 +++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/include/system/confidential-guest-support.h b/include/system/c= onfidential-guest-support.h index 6d35ddb97a75..27ae0a21b6ad 100644 --- a/include/system/confidential-guest-support.h +++ b/include/system/confidential-guest-support.h @@ -137,6 +137,14 @@ typedef struct ConfidentialGuestSupportClass { int (*set_guest_policy)(ConfidentialGuestPolicyType policy_type, uint64_t policy, Error **errp); =20 + /* + * Get the guest policy currently configured for the confidential + * platform, be it from the command line or from a previous call to + * set_guest_policy. Its format is the same as for set_guest_policy. + */ + int (*get_guest_policy)(ConfidentialGuestPolicyType policy_type, + uint64_t *policy, Error **errp); + /* * Set the SEV-SNP ID block and ID authentication block. These are * passed to SNP_LAUNCH_FINISH to provide signed verification of the diff --git a/backends/confidential-guest-support.c b/backends/confidential-= guest-support.c index d60d1f6eaaea..91701f1a5f5b 100644 --- a/backends/confidential-guest-support.c +++ b/backends/confidential-guest-support.c @@ -46,6 +46,14 @@ static int set_guest_policy(ConfidentialGuestPolicyType = policy_type, return -1; } =20 +static int get_guest_policy(ConfidentialGuestPolicyType policy_type, + uint64_t *policy, Error **errp) +{ + error_setg(errp, + "Getting 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) @@ -71,6 +79,7 @@ static void confidential_guest_support_class_init(ObjectC= lass *oc, cgsc->check_support =3D check_support; cgsc->set_guest_state =3D set_guest_state; cgsc->set_guest_policy =3D set_guest_policy; + cgsc->get_guest_policy =3D get_guest_policy; cgsc->set_id_block =3D set_id_block; cgsc->get_mem_map_entry =3D get_mem_map_entry; } diff --git a/target/i386/sev.c b/target/i386/sev.c index 38f97fd9b2b3..f11fdb6590ef 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -2758,6 +2758,29 @@ static int cgs_set_guest_policy(ConfidentialGuestPol= icyType policy_type, return 0; } =20 +static int cgs_get_guest_policy(ConfidentialGuestPolicyType policy_type, + uint64_t *policy, Error **errp) +{ + SevCommonState *sev_common =3D SEV_COMMON(MACHINE(qdev_get_machine())-= >cgs); + + if (policy_type !=3D 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 =3D SEV_SNP_GUEST(sev_common); + + *policy =3D sev_snp_guest->kvm_start_conf.policy; + } else { + SevGuestState *sev_guest =3D SEV_GUEST(sev_common); + + *policy =3D sev_guest->policy; + } + return 0; +} + static int cgs_set_id_block(void *id_block, uint32_t id_block_size, void *id_auth, uint32_t id_auth_size, Error **errp) @@ -2888,6 +2911,7 @@ sev_common_instance_init(Object *obj) cgs->set_guest_state =3D cgs_set_guest_state; cgs->get_mem_map_entry =3D cgs_get_mem_map_entry; cgs->set_guest_policy =3D cgs_set_guest_policy; + cgs->get_guest_policy =3D cgs_get_guest_policy; cgs->set_id_block =3D cgs_set_id_block; cgs->can_rebuild_guest_state =3D true; =20 --=20 2.56.0 From nobody Fri Oct 23 20:56:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1792600420; cv=none; d=zohomail.com; s=zohoarc; b=WSJjr63HyPyV7/oUp1BAzP2MFMm2ta+/gz46z4PQUJ7CS1nS9xWCR9Z4lWd3d8uCjqH3xRz57PqzYpwfrmbXDsu8P9qnfroDBoPfn9pz9lfK326L2sdBfmnyQFQCCy/xWAK/OGrMFPUOdvC8gqxtyUrH4pqORAqLwIogdGmLbkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792600420; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mx3NJOt7EtEZ3D64HV5SqRuwJTZwQpbp8v/NGhoKJls=; b=nlzrF/U5NCwbmN1+8b2PBg/52eMP90Ep00ru7lzy9MpvQHhRjqAgk3H0eWTkUkcPrP9uiQRPfFCNU+S4xHMrhfokcBruUiKEKogpCKtrbvjPg/zlygBqOyQnHlqQuMLIR+AZTcbnYz9O6CUY2cMcGwb0A+5CiAndCDdCp2OfCE4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792600419831507.6778137903606; Wed, 21 Oct 2026 09:33:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJZFg-0007bT-4g; Wed, 21 Oct 2026 12:33:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFG-0007Tb-KV for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFB-0006UW-C9 for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:52 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-374-paQ6od0dMEOAiay9-J2iVQ-1; Wed, 21 Oct 2026 16:32:45 +0000 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0318F19560BC; Wed, 21 Oct 2026 16:32:44 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.54]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B1BC618004D2; Wed, 21 Oct 2026 16:32:43 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DF9C31827593; Wed, 21 Oct 2026 18:32:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792600368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mx3NJOt7EtEZ3D64HV5SqRuwJTZwQpbp8v/NGhoKJls=; b=OkMG+ZMCtPTWke65OZNleUUmaHfKg+LfPAVVXyS1cjVG45UUnpPxgCYBPDKodWp4dY+FZt QIN0MB3mUZswZVFaaGj+65lFZr3MxKNlBTShPHtVq5z2auxVHMHuijWZBfH1uubCOkN+MG KaTbd4NYMrSMkMeAxeRE1dDutVwZOnU= X-MC-Unique: paQ6od0dMEOAiay9-J2iVQ-1 X-Mimecast-MFC-AGG-ID: paQ6od0dMEOAiay9-J2iVQ_1792600364 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Stefano Garzarella , Marcelo Tosatti , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Pierrick Bouvier , Zhao Liu , Ani Sinha , Paolo Bonzini , Eric Blake , Gerd Hoffmann , Luigi Leonardi Subject: [PULL 05/10] igvm/sev: forward the IGVM guest policy to the platform before launch Date: Wed, 21 Oct 2026 18:32:33 +0200 Message-ID: <20261021163239.1131460-6-kraxel@redhat.com> In-Reply-To: <20261021163239.1131460-1-kraxel@redhat.com> References: <20261021163239.1131460-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1792600421742158500 Content-Type: text/plain; charset="utf-8" From: Luigi Leonardi set_guest_policy was called from qigvm_handle_policy at the end of qigvm_process_file, after LAUNCH_START had already been issued for both SEV/SEV-ES and SEV-SNP. The guest was therefore launched with whatever policy was already configured (the command-line value, or the platform default if none was given) instead of the one requested by the IGVM file, quietly breaking attestation since the policy is part of the attestation report. Move the call into qigvm_initialization_guest_policy, which runs while the initialization section is processed. Because that section is now handled during the pre-launch pass (see previous patch), the call happens before LAUNCH_START, so the policy is in effect for launch. Drop qigvm_handle_policy, whose only remaining job was that misplaced call. cgs_set_guest_policy no longer special-cases SEV_STATE_UNINIT: that guard used to skip the pre-processing pass so the policy was applied later, but forwarding it during pre-processing, before LAUNCH_START, is now precisely the point. The 'policy =3D=3D 0 means unset' guard is dropped too, since the call site now only fires when the IGVM file actually provides a GUEST_POLICY header. The command line can also set a policy. It now takes precedence: if it differs from the IGVM one, print a warning and keep the command-line value instead of silently overriding it. Also reject a policy that doesn't fit in the 32-bit SEV/SEV-ES policy field instead of truncating it. Finally, use the get_guest_policy callback added by the previous patch to populate the SNP ID block's policy field. The command line sets its policy directly into the SEV/SNP guest's own struct, bypassing IGVM entirely, so ctx->sev_policy only ever reflects a GUEST_POLICY header and is 0 otherwise, causing SNP_LAUNCH_FINISH to reject the ID block whenever the file relies on a command-line policy. Reading the policy back from the platform instead always gets the value actually in effect, regardless of its source. ctx->sev_policy is now unused and removed. Link: https://gitlab.com/qemu-project/qemu/-/work_items/4189 Fixes: 915b47078d ("backends/igvm: Handle policy for SEV guests") Signed-off-by: Luigi Leonardi Message-ID: <20260907-fix_igvm_policy-v2-5-c8c50f1dbfda@redhat.com> Signed-off-by: Gerd Hoffmann --- include/system/igvm-internal.h | 3 --- backends/igvm.c | 27 ++++++++++--------------- target/i386/sev.c | 37 +++++++++++++++++++++++----------- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/include/system/igvm-internal.h b/include/system/igvm-internal.h index b3b64cb58444..d88268bf602c 100644 --- a/include/system/igvm-internal.h +++ b/include/system/igvm-internal.h @@ -64,9 +64,6 @@ struct QIgvm { struct sev_id_block *id_block; struct sev_id_authentication *id_auth; =20 - /* Define the guest policy for SEV guests */ - uint64_t sev_policy; - /* These variables keep track of contiguous page regions */ IGVM_VHS_PAGE_DATA region_prev_page_data; uint64_t region_start; diff --git a/backends/igvm.c b/backends/igvm.c index 2ee60ada94b9..ef45794744bc 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -821,8 +821,6 @@ static int qigvm_directive_snp_id_block(QIgvm *ctx, con= st uint8_t *header_data, ctx->id_block->version =3D IGVM_SEV_ID_BLOCK_VERSION; memcpy(ctx->id_block->ld, igvm_id->ld, sizeof(ctx->id_block->ld)); =20 - ctx->id_block->policy =3D ctx->sev_policy; - ctx->id_auth->id_key_alg =3D igvm_id->id_key_algorithm; assert(sizeof(igvm_id->id_key_signature) <=3D sizeof(ctx->id_auth->id_block_sig)); @@ -851,6 +849,13 @@ static int qigvm_directive_snp_id_block(QIgvm *ctx, co= nst uint8_t *header_data, 72); =20 if (ctx->cgsc) { + uint64_t policy; + + if (ctx->cgsc->get_guest_policy(GUEST_POLICY_SEV, &policy, errp) <= 0) { + return -1; + } + ctx->id_block->policy =3D policy; + return ctx->cgsc->set_id_block(ctx->id_block, sizeof(struct sev_id_block), ctx->id_auth, @@ -910,7 +915,10 @@ static int qigvm_initialization_guest_policy(QIgvm *ct= x, (const IGVM_VHS_GUEST_POLICY *)header_data; =20 if (guest->compatibility_mask & ctx->compatibility_mask) { - ctx->sev_policy =3D guest->policy; + if (ctx->cgsc) { + return ctx->cgsc->set_guest_policy(GUEST_POLICY_SEV, + guest->policy, errp); + } } return 0; } @@ -1011,15 +1019,6 @@ static int qigvm_supported_platform_compat_mask(QIgv= m *ctx, Error **errp) return 0; } =20 -static int qigvm_handle_policy(QIgvm *ctx, Error **errp) -{ - if (ctx->platform_type =3D=3D IGVM_PLATFORM_TYPE_SEV_SNP) { - return ctx->cgsc->set_guest_policy(GUEST_POLICY_SEV, ctx->sev_poli= cy, - errp); - } - return 0; -} - IgvmHandle qigvm_file_init(char *filename, Error **errp) { IgvmHandle igvm; @@ -1145,10 +1144,6 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *m= achine_state, */ retval =3D qigvm_process_mem_page(&ctx, NULL, errp); =20 - if (retval =3D=3D 0) { - retval =3D qigvm_handle_policy(&ctx, errp); - } - cleanup_parameters: QTAILQ_FOREACH(parameter, &ctx.parameter_data, next) { diff --git a/target/i386/sev.c b/target/i386/sev.c index f11fdb6590ef..11072b00dce7 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; =20 /* runtime state */ uint8_t api_major; @@ -2729,10 +2731,6 @@ static int cgs_set_guest_policy(ConfidentialGuestPol= icyType policy_type, uint64_t policy, Error **errp) { SevCommonState *sev_common =3D SEV_COMMON(MACHINE(qdev_get_machine())-= >cgs); - if (sev_common->state =3D=3D SEV_STATE_UNINIT) { - /* Pre-processing of IGVM file called from sev_common_kvm_init() */ - return 0; - } =20 if (policy_type !=3D GUEST_POLICY_SEV) { error_setg(errp, "SEV: Invalid guest policy type provided for SEV:= %d", @@ -2740,18 +2738,31 @@ static int cgs_set_guest_policy(ConfidentialGuestPo= licyType policy_type, return -1; } =20 - /* do not reset existing policy if policy was not set in IGVM */ - if (policy =3D=3D 0) { - return 0; - } - if (sev_snp_enabled()) { - SevSnpGuestState *sev_snp_guest =3D - SEV_SNP_GUEST(MACHINE(qdev_get_machine())->cgs); + SevSnpGuestState *sev_snp_guest =3D SEV_SNP_GUEST(sev_common); + + if (sev_common->policy_set && + sev_snp_guest->kvm_start_conf.policy !=3D policy) { + warn_report_once("SNP: policy mismatch between IGVM and CLI, " + "keeping the command-line policy"); + return 0; + } =20 sev_snp_guest->kvm_start_conf.policy =3D policy; } else { - SevGuestState *sev_guest =3D SEV_GUEST(MACHINE(qdev_get_machine())= ->cgs); + SevGuestState *sev_guest =3D SEV_GUEST(sev_common); + + if (sev_common->policy_set && sev_guest->policy !=3D policy) { + warn_report_once("SEV: policy mismatch between IGVM and CLI, " + "keeping the command-line policy"); + return 0; + } + + if (policy > UINT32_MAX) { + error_setg(errp, "SEV: policy 0x%" PRIx64 " does not fit in th= e " + "32-bit SEV/SEV-ES guest policy field", policy); + return -1; + } =20 sev_guest->policy =3D policy; } @@ -3034,6 +3045,7 @@ sev_guest_set_policy(Object *obj, Visitor *v, const c= har *name, if (!visit_type_uint32(v, name, &SEV_GUEST(obj)->policy, errp)) { return; } + SEV_COMMON(obj)->policy_set =3D true; } =20 static void @@ -3091,6 +3103,7 @@ sev_snp_guest_set_policy(Object *obj, Visitor *v, con= st char *name, errp)) { return; } + SEV_COMMON(obj)->policy_set =3D true; } =20 static char * --=20 2.56.0 From nobody Fri Oct 23 20:56:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1792600494; cv=none; d=zohomail.com; s=zohoarc; b=Srnw83hx9MWMRSrz2skzc6VpBr63TxffATaIBXNCE15dwYdHDbc6v8z5k3FYJ07S8o5qbpJoG05xr3MYh5rj1KGLEQA74DKbDLc0bxg4+CqJCQor1lE6o02sMFE7zpoLr1hOfw4km0m66HaCK5wmyluM3+nM1ElnT7QJrT/MEQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792600494; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Oi199wsf8nTgvRE+hN//iXiFJETYhH2ljQFRicUL4uc=; b=D5rM7Dpff1oOLTXSHyI55VlnccQ4tj4Qh7Y57+ZMiISoE+IGQJcMl3IPU7R/Sm9E7NPCVOifKdu40t2PTgHXjEuuhf6HHHpEdjeuWopWCUkWgl1eaKVlJet87HGgtLTQ2AI29SPG+aJANIuEzTyg0KywzL7IcUcIqtAaX//WIoY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792600494807958.1647904981608; Wed, 21 Oct 2026 09:34:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJZFc-0007ZU-H5; Wed, 21 Oct 2026 12:33:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFG-0007TZ-J7 for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFB-0006Uq-V9 for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:53 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-361-6p3gm9sYPdqHSWpBhsvuEw-1; Wed, 21 Oct 2026 16:32:45 +0000 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C4646195608E; Wed, 21 Oct 2026 16:32:44 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.54]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6B2F8362; Wed, 21 Oct 2026 16:32:44 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EEBD91827594; Wed, 21 Oct 2026 18:32:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792600369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oi199wsf8nTgvRE+hN//iXiFJETYhH2ljQFRicUL4uc=; b=foZZudLGENB//PT6EqhTtSOgA6U3HbO47CZ4UnlAZf/cT6u/CPnyoCKlbEV4Dzv33Jbbxx AZKVTDl2a0L73xMlVazMINCTBXoxm+U+SAmZHwRmMhDGG9m1I/bMbNpnVQq71Q0lLCmrvf +wlM/jiO2fh8ToaATffx5swwFD9a4y4= X-MC-Unique: 6p3gm9sYPdqHSWpBhsvuEw-1 X-Mimecast-MFC-AGG-ID: 6p3gm9sYPdqHSWpBhsvuEw_1792600364 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Stefano Garzarella , Marcelo Tosatti , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Pierrick Bouvier , Zhao Liu , Ani Sinha , Paolo Bonzini , Eric Blake , Gerd Hoffmann , Luigi Leonardi Subject: [PULL 06/10] backends/igvm: supply an empty device tree when the machine has none Date: Wed, 21 Oct 2026 18:32:34 +0200 Message-ID: <20261021163239.1131460-7-kraxel@redhat.com> In-Reply-To: <20261021163239.1131460-1-kraxel@redhat.com> References: <20261021163239.1131460-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1792600496956158500 Content-Type: text/plain; charset="utf-8" From: Luigi Leonardi Commit 1c4bd8f13c ("igvm: add device tree parameter support") added handling for the IGVM device tree parameter directive. The handler fails when the machine has not built a device tree of its own, so an IGVM file carrying that directive cannot be booted on such a machine, for example q35. An empty tree satisfies the IGVM file's request, so build and supply one instead of rejecting the whole file. While at it, rename fdt_packed to fdt, which better reflects the content of the variable, as it does not always hold a packed fdt. Signed-off-by: Luigi Leonardi Message-ID: <20260923-relax_dt-v1-1-ff40f2a06acd@redhat.com> Signed-off-by: Gerd Hoffmann --- backends/igvm.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/backends/igvm.c b/backends/igvm.c index ef45794744bc..5a1416fe8eac 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -29,6 +29,9 @@ =20 #ifdef CONFIG_FDT #include + +/* Enough for the header, the memory reservation block and an empty root n= ode */ +#define EMPTY_FDT_SIZE 256 #endif =20 #ifndef IGVM_VHT_OPTIONAL_BIT @@ -871,7 +874,7 @@ static int qigvm_directive_device_tree(QIgvm *ctx, cons= t uint8_t *header_data, Error **errp) { const IGVM_VHS_PARAMETER *param =3D (const IGVM_VHS_PARAMETER *)header= _data; - g_autofree void *fdt_packed =3D NULL; + g_autofree void *fdt =3D NULL; uint8_t *param_data; uint32_t param_size; uint32_t fdt_size; @@ -881,20 +884,27 @@ static int qigvm_directive_device_tree(QIgvm *ctx, co= nst uint8_t *header_data, return -1; } =20 - if (ctx->machine_state->fdt =3D=3D NULL) { - error_setg(errp, "IGVM: device tree not available"); - return -1; + if (ctx->machine_state->fdt) { + fdt =3D g_memdup2(ctx->machine_state->fdt, + fdt_totalsize(ctx->machine_state->fdt)); + } else { + /* + * The machine doesn't build a device tree of its own. + * Supply an empty tree rather than rejecting the IGVM file. + */ + fdt =3D g_malloc0(EMPTY_FDT_SIZE); + if (fdt_create_empty_tree(fdt, EMPTY_FDT_SIZE)) { + error_setg(errp, "IGVM: failed to create an empty device tree"= ); + return -1; + } } =20 - fdt_size =3D fdt_totalsize(ctx->machine_state->fdt); - fdt_packed =3D g_memdup2(ctx->machine_state->fdt, fdt_size); - - if (fdt_pack(fdt_packed)) { + if (fdt_pack(fdt)) { error_setg(errp, "IGVM: failed to pack device tree"); return -1; } =20 - fdt_size =3D fdt_totalsize(fdt_packed); + fdt_size =3D fdt_totalsize(fdt); if (fdt_size > param_size) { error_setg(errp, "IGVM: device tree size exceeds parameter area" @@ -902,7 +912,7 @@ static int qigvm_directive_device_tree(QIgvm *ctx, cons= t uint8_t *header_data, return -1; } =20 - memcpy(param_data, fdt_packed, fdt_size); + memcpy(param_data, fdt, fdt_size); =20 return 0; } --=20 2.56.0 From nobody Fri Oct 23 20:56:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1792600420; cv=none; d=zohomail.com; s=zohoarc; b=FhwJts+uBigH+VPUPaQbez5jkVciJFprF4M16gu0m+b/qM4j8w5tzKjltOpFNFhUyOd2Q6E7zXTYcgmB7AkQlnZHPtb9Ifrf8Wfj9CZycouEt++6I+xJqpggrS4gJjZe1UuA0TL/qgRgqxjH/BdlnqK2Xe5w6p5u9XZtJRZfJpE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792600420; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gLTZUdvM7A2N0fyJWg2lNT3PdveXqvyLDgdRIcYomkY=; b=QA5oETlIaigOF69uniex530CgXikibIO/l+fsRFlTcLqG6Z+4CFDDEYt5uUT9VqG3JMtVK1tGEaiE6D4PSlaPJJJ6b2RbAxnVgacUEi9Zj5lvvwzZiMdqSk5BkBnMyjzMz6vPBgQV4Ouj0mhfGWEs+bPgfvHM6DIpSglwitju+o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792600420477668.1075547108146; Wed, 21 Oct 2026 09:33:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJZFJ-0007Uy-1X; Wed, 21 Oct 2026 12:32:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFG-0007TY-I2 for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFC-0006Uv-3R for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:53 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-361-eafSKQN9MK6VQ6x3s3WKaQ-1; Wed, 21 Oct 2026 16:32:46 +0000 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C07FD19560B9; Wed, 21 Oct 2026 16:32:44 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.54]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 78A1118005B7; Wed, 21 Oct 2026 16:32:44 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0885A1827595; Wed, 21 Oct 2026 18:32:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792600369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gLTZUdvM7A2N0fyJWg2lNT3PdveXqvyLDgdRIcYomkY=; b=FM6JtLnqftmNi2uNGtWBl/ccXZk7r3ViN6kaOHaIAerSki8KcXg4VUYRQfwhEzCD4BMFl/ whcMPc9OXp2y2DX5NMeh1E28YUB9gCbECCCYP7ukGbfGnW9JxHjD3d2IEzhKr0dEzDDV6G tr02HGoSI59L0Nm/sD/rTLjpOqSjMfM= X-MC-Unique: eafSKQN9MK6VQ6x3s3WKaQ-1 X-Mimecast-MFC-AGG-ID: eafSKQN9MK6VQ6x3s3WKaQ_1792600364 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Stefano Garzarella , Marcelo Tosatti , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Pierrick Bouvier , Zhao Liu , Ani Sinha , Paolo Bonzini , Eric Blake , Gerd Hoffmann , Martin Pitt , qemu-stable@nongnu.org Subject: [PULL 07/10] hw/uefi: fix ContentInfo detection in wrap_pkcs7() Date: Wed, 21 Oct 2026 18:32:35 +0200 Message-ID: <20261021163239.1131460-8-kraxel@redhat.com> In-Reply-To: <20261021163239.1131460-1-kraxel@redhat.com> References: <20261021163239.1131460-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1792600421653158500 Content-Type: text/plain; charset="utf-8" From: Martin Pitt Fix wrap_pkcs7()'s detection for an already present PKCS ContentInfo envelope: It previously compared byte 15 with 0x0a (ASN.1 ENUMERATED) instead of 0xa0 (the [0] EXPLICIT context tag of ContentInfo.content). See the original edk2 function [1] where this was taken from. Due to that typo, an already wrapped signature got wrapped a second time, and gnutls_pkcs7_import() rejected it. This breaks Secure Boot key enrollment with .auth files carrying the envelope, as created by systemd's "bootctl --secure-boot-auto-enroll". [1] https://github.com/tianocore/edk2/blob/8f8372439d8ec5f565dbda1548c18deb= 068e0080/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyCommon.c#L68 Fixes: 3e33af2cb306 ("hw/uefi: add var-service-pkcs7.c") Cc: qemu-stable@nongnu.org Signed-off-by: Martin Pitt Message-ID: Signed-off-by: Gerd Hoffmann --- hw/uefi/var-service-pkcs7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/uefi/var-service-pkcs7.c b/hw/uefi/var-service-pkcs7.c index 8a1f1395a2fb..a47f36492ff8 100644 --- a/hw/uefi/var-service-pkcs7.c +++ b/hw/uefi/var-service-pkcs7.c @@ -80,7 +80,7 @@ static void wrap_pkcs7(gnutls_datum_t *pkcs7) pkcs7->data[4] =3D=3D 0x06 && pkcs7->data[5] =3D=3D 0x09 && memcmp(pkcs7->data + 6, signed_data_oid, sizeof(signed_data_oid)) = =3D=3D 0 && - pkcs7->data[15] =3D=3D 0x0a && + pkcs7->data[15] =3D=3D 0xa0 && pkcs7->data[16] =3D=3D 0x82) { return; } --=20 2.56.0 From nobody Fri Oct 23 20:56:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1792600430; cv=none; d=zohomail.com; s=zohoarc; b=gTFpparZDMInCfSs6Oep0u5FZdW4VS6WuWCjKbXfyygBgVaDpAmvUghQh5Z/GMs2/oUvHS9ehsEA4rY+Te3KF/eHLcq6F19Nq/7jCERazTmmxjQ1JZTYpd+PZAxCdot71vGVPtCAgQmt0S661kAQpVdiUjLjNMNRY/rWydV0WZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792600430; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=M09Bt5Xqymo5EruqBYA5nEGo9deFrSjSyw/JX8fKg1E=; b=BNxpAfodJ7JY274yS9AZH0nRkB4MLB4+/cw0dvcvcWo5T61MhfWZJqMZjLmqcAkSk+2c85v6aPo4BkxCGwuUkW+O73dKr9gGpU2uPqAxgjAXsGnpWG/T/+I9LV2kUuWSrL4broDU7OsPidx3YDXkSW6CaRYXOB8NM6Q5bQrI0Es= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792600430290347.777463037477; Wed, 21 Oct 2026 09:33:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJZFb-0007Yp-Jv; Wed, 21 Oct 2026 12:33:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFE-0007TS-HN for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFA-0006UO-Q4 for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:52 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-22-kmBmVSG3NiijxmWRoMD2EA-1; Wed, 21 Oct 2026 12:32:46 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7807B1800578; Wed, 21 Oct 2026 16:32:45 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.54]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 324EB1803A51; Wed, 21 Oct 2026 16:32:45 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 217301827596; Wed, 21 Oct 2026 18:32:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792600368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M09Bt5Xqymo5EruqBYA5nEGo9deFrSjSyw/JX8fKg1E=; b=M/uLaEZKZBGgOinVsC8b8h2aNo50RZfrHVqMNY2Vayl+RTvAjSlMGdbLBk7A23xDe6ikH8 ZPJG8ILavEVsMKdwMdxDXt4mU4OVHX2mCKVOiygADG/JJIbi4/ANyUQKinkugaOuWTehdl 7ri1FdCdRs6w8q3Y9BhAXS1P56OdyrE= X-MC-Unique: kmBmVSG3NiijxmWRoMD2EA-1 X-Mimecast-MFC-AGG-ID: kmBmVSG3NiijxmWRoMD2EA_1792600365 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Stefano Garzarella , Marcelo Tosatti , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Pierrick Bouvier , Zhao Liu , Ani Sinha , Paolo Bonzini , Eric Blake , Gerd Hoffmann , Luigi Leonardi Subject: [PULL 08/10] igvm: add command line parameter support Date: Wed, 21 Oct 2026 18:32:36 +0200 Message-ID: <20261021163239.1131460-9-kraxel@redhat.com> In-Reply-To: <20261021163239.1131460-1-kraxel@redhat.com> References: <20261021163239.1131460-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1792600431907158500 Content-Type: text/plain; charset="utf-8" From: Luigi Leonardi Add a "cmdline" property to the igvm-cfg object and a handler for the IGVM_VHT_COMMAND_LINE directive, which copies the string into the parameter area the directive points at. The command line is passed to whatever software the IGVM file loads, such as an SVSM. For example, SVSM can use it to select the serial port it logs to. Acked-by: Markus Armbruster Signed-off-by: Luigi Leonardi Reviewed-by: Stefano Garzarella Message-ID: <20261019-igvm_command_line-v3-1-29aeacbd6cd7@redhat.com> Signed-off-by: Gerd Hoffmann --- include/system/igvm-internal.h | 5 +++++ backends/igvm-cfg.c | 21 +++++++++++++++++++++ backends/igvm.c | 31 +++++++++++++++++++++++++++++++ qapi/qom.json | 7 ++++++- qemu-options.hx | 6 +++++- 5 files changed, 68 insertions(+), 2 deletions(-) diff --git a/include/system/igvm-internal.h b/include/system/igvm-internal.h index d88268bf602c..7ec6c204721b 100644 --- a/include/system/igvm-internal.h +++ b/include/system/igvm-internal.h @@ -32,6 +32,11 @@ struct IgvmCfg { * format. */ char *filename; + /* + * cmdline: Command line for the software loaded from the IGVM file, + * if it asks for one. + */ + char *cmdline; IgvmHandle file; ResettableState reset_state; QTAILQ_HEAD(, IgvmMemoryRegion) memory_regions; diff --git a/backends/igvm-cfg.c b/backends/igvm-cfg.c index 935ba54f54f3..653f79bef58e 100644 --- a/backends/igvm-cfg.c +++ b/backends/igvm-cfg.c @@ -34,6 +34,19 @@ static void set_igvm(Object *obj, const char *value, Err= or **errp) igvm->filename =3D g_strdup(value); } =20 +static char *get_cmdline(Object *obj, Error **errp) +{ + IgvmCfg *igvm =3D IGVM_CFG(obj); + return g_strdup(igvm->cmdline); +} + +static void set_cmdline(Object *obj, const char *value, Error **errp) +{ + IgvmCfg *igvm =3D IGVM_CFG(obj); + g_free(igvm->cmdline); + igvm->cmdline =3D g_strdup(value); +} + static ResettableState *igvm_reset_state(Object *obj) { IgvmCfg *igvm =3D IGVM_CFG(obj); @@ -85,6 +98,13 @@ static void igvm_cfg_class_init(ObjectClass *oc, const v= oid *data) object_class_property_set_description(oc, "file", "Set the IGVM filename to use"); =20 + object_class_property_add_str(oc, "cmdline", get_cmdline, set_cmdline); + object_class_property_set_description(oc, "cmdline", + "Set the command line for the " + "software loaded from the IGVM " + "file (copied verbatim, not " + "parsed by QEMU)"); + igvmc->process =3D qigvm_process_file; =20 rc->get_state =3D igvm_reset_state; @@ -112,4 +132,5 @@ static void igvm_cfg_finalize(Object *obj) igvm_free(igvm->file); } g_free(igvm->filename); + g_free(igvm->cmdline); } diff --git a/backends/igvm.c b/backends/igvm.c index 5a1416fe8eac..4b9d78630863 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -161,6 +161,8 @@ static int qigvm_directive_snp_id_block(QIgvm *ctx, con= st uint8_t *header_data, static int qigvm_initialization_guest_policy(QIgvm *ctx, const uint8_t *header_data, Error **errp); +static int qigvm_directive_command_line(QIgvm *ctx, const uint8_t *header_= data, + Error **errp); #ifdef CONFIG_FDT static int qigvm_directive_device_tree(QIgvm *ctx, const uint8_t *header_d= ata, Error **errp); @@ -195,6 +197,8 @@ static struct QIGVMHandler handlers[] =3D { qigvm_initialization_guest_policy }, { IGVM_VHT_MADT, IGVM_HEADER_SECTION_DIRECTIVE, qigvm_directive_madt }, + { IGVM_VHT_COMMAND_LINE, IGVM_HEADER_SECTION_DIRECTIVE, + qigvm_directive_command_line }, #ifdef CONFIG_FDT { IGVM_VHT_DEVICE_TREE, IGVM_HEADER_SECTION_DIRECTIVE, qigvm_directive_device_tree }, @@ -869,6 +873,33 @@ static int qigvm_directive_snp_id_block(QIgvm *ctx, co= nst uint8_t *header_data, return 0; } =20 +static int qigvm_directive_command_line(QIgvm *ctx, const uint8_t *header_= data, + Error **errp) +{ + const IGVM_VHS_PARAMETER *param =3D (const IGVM_VHS_PARAMETER *)header= _data; + const char *cmdline =3D ctx->cfg->cmdline ? ctx->cfg->cmdline : ""; + uint8_t *param_data; + uint32_t param_size; + size_t cmdline_size =3D strlen(cmdline) + 1; + + param_data =3D qigvm_get_param_data(ctx, param, ¶m_size, errp); + if (!param_data) { + return -1; + } + + if (cmdline_size > param_size) { + error_setg(errp, + "IGVM: command line size %zu exceeds the %u byte " + "parameter area defined in IGVM file", + cmdline_size, param_size); + return -1; + } + + memcpy(param_data, cmdline, cmdline_size); + + return 0; +} + #ifdef CONFIG_FDT static int qigvm_directive_device_tree(QIgvm *ctx, const uint8_t *header_d= ata, Error **errp) diff --git a/qapi/qom.json b/qapi/qom.json index 49f222796ab4..4810d53e585e 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -977,11 +977,16 @@ # # @file: IGVM file to use to configure guest # +# @cmdline: command line for the software loaded from the IGVM file. +# Its format is specific to that software. Passed verbatim: QEMU +# does not parse it. +# Ignored if the IGVM file does not ask for one. (since 11.2) +# # Since: 10.1 ## { 'struct': 'IgvmCfgProperties', 'if': 'CONFIG_IGVM', - 'data': { 'file': 'str' } } + 'data': { 'file': 'str', '*cmdline': 'str' } } =20 ## # @SevCommonProperties: diff --git a/qemu-options.hx b/qemu-options.hx index 2f6863180b0f..f72f30e246d6 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -6496,7 +6496,7 @@ SRST -machine ...,confidential-guest-support=3Dtdx \\ ...... =20 - ``-object igvm-cfg,file=3Dfile`` + ``-object igvm-cfg,file=3Dfile[,cmdline=3Dstring]`` Create an IGVM configuration object that defines the initial state of the guest using a file in that conforms to the Independent Guest Virtual Machine (IGVM) file format. @@ -6509,6 +6509,10 @@ SRST memory of the virtual machine and, depending on the platform, can define the initial processor state, memory map and parameters. =20 + The optional ``cmdline`` parameter is a command line passed + verbatim to the software loaded from the IGVM file, if the file + requests one. Its format is specific to that software. + The IGVM file is expected to contain the firmware for the virtual machine, therefore an ``igvm-cfg`` object cannot be provided along with other ways of specifying firmware, such as the ``-bios`` --=20 2.56.0 From nobody Fri Oct 23 20:56:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1792600519; cv=none; d=zohomail.com; s=zohoarc; b=Dvz6mTsr/ZYPvDMwT4rnNNcVcRLNGce/aknYXF705NI5Dn9XYCBzDenjneaQp3MKLBWhSOQeyUEC46UQBgFsH0vVLGeqFhxVjYzNWsOSz07qZxcG72f1Hzto5fOjNP8UPVrhWGaVt8CEHDcBQHzMBrw30q69L4N1i/YWeH7rvoI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792600519; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OtTEJg5RIHFFJ9ZZ5a0yaGlFu79+ZaA7uoWE9DGvTDw=; b=daXrcGv2TA+vs+58huxc14EG+wj17rDhJaPuDq1y7sYfUQa+Keby+4YLMhLf4tWimf8Nq9bDJSTNtZpeXqeR2KOVeuvFNk7J/gZq+1TFFYp4c9apLlDx1n3Peou4L2iIYlUKtSUfLKZZ8oYD+gJ21AKKfuLLiXqdhjeKlyqjvis= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17926005190721019.445003209192; Wed, 21 Oct 2026 09:35:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJZFM-0007VR-Hq; Wed, 21 Oct 2026 12:33:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFG-0007Te-Rr for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFC-0006VA-Pw for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:53 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-265-EyfYKAXeOG636wyFjUSQHQ-1; Wed, 21 Oct 2026 12:32:46 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7FFC71955F1B; Wed, 21 Oct 2026 16:32:45 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.54]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3A4EC5BC; Wed, 21 Oct 2026 16:32:45 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2F82F1827597; Wed, 21 Oct 2026 18:32:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792600370; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OtTEJg5RIHFFJ9ZZ5a0yaGlFu79+ZaA7uoWE9DGvTDw=; b=B8gj1if88AGPE/t8FxyEiCrUH0UePUWfqwvmoTcU52Wag7l7mPfM4uF76BWLgseXHv4/Sb gI+bqPbDuNLEN92MidtL8agZzaxMj0kdc/9Wj/8fbGAv7nGDw+UJjPVd0EFtM3A3TK8J56 NuUh00J4JE++09mEHDv0uuPphMGwRDo= X-MC-Unique: EyfYKAXeOG636wyFjUSQHQ-1 X-Mimecast-MFC-AGG-ID: EyfYKAXeOG636wyFjUSQHQ_1792600365 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Stefano Garzarella , Marcelo Tosatti , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Pierrick Bouvier , Zhao Liu , Ani Sinha , Paolo Bonzini , Eric Blake , Gerd Hoffmann , Luigi Leonardi Subject: [PULL 09/10] docs/system/igvm: document MADT, COMMAND_LINE and DEVICE_TREE directives Date: Wed, 21 Oct 2026 18:32:37 +0200 Message-ID: <20261021163239.1131460-10-kraxel@redhat.com> In-Reply-To: <20261021163239.1131460-1-kraxel@redhat.com> References: <20261021163239.1131460-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1792600521165158500 Content-Type: text/plain; charset="utf-8" From: Luigi Leonardi The MADT and DEVICE_TREE directives were added without updating the list of supported directives. Document them, together with the COMMAND_LINE directive added in the previous patch. Suggested-by: Stefano Garzarella Signed-off-by: Luigi Leonardi Reviewed-by: Stefano Garzarella Message-ID: <20261019-igvm_command_line-v3-2-29aeacbd6cd7@redhat.com> Signed-off-by: Gerd Hoffmann --- docs/system/igvm.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/system/igvm.rst b/docs/system/igvm.rst index 9db8ae43d21d..da1e965f545f 100644 --- a/docs/system/igvm.rst +++ b/docs/system/igvm.rst @@ -72,6 +72,14 @@ SEV-ES, SEV-SNP and non-confidential platforms. * - IGVM_VHT_ENVIRONMENT_INFO_PARAMETER - The ``memory_is_shared`` parameter is set to 1 in the guest paramet= er page. + * - IGVM_VHT_MADT + - The parameter area is populated with the ACPI MADT generated by QEM= U. + * - IGVM_VHT_COMMAND_LINE + - The parameter area is populated with the ``cmdline`` property of the + ``igvm-cfg`` object, or an empty string if it is not set. + * - IGVM_VHT_DEVICE_TREE + - The parameter area is populated with the device tree generated by Q= EMU. + Only available when QEMU is built with FDT support. =20 .. list-table:: Additional SEV, SEV-ES & SEV_SNP Supported Directives :widths: 25 75 --=20 2.56.0 From nobody Fri Oct 23 20:56:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1792600481; cv=none; d=zohomail.com; s=zohoarc; b=ZfPa8TJ1TYv7N/mpeAGofsFlBgUzDuCbI2G9o0RlCO++DQ+Ef2Lb+iX5cGyAnE14QgTHO3iy7o89fW8oxE9S25MMTDcFrjOicNvH0AQTML1trrTtJVXAukFYxW/Q06Ykt8Yv4PdmW1biQqEmPdMs0qQR6HzihUonXXIytrWkgUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792600481; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=10yZLh8hPPLWb86UtjEQBBrvb3K+69MRCSe8pZYeX/Y=; b=a1LyASdi4lqg9PAqobJhPp+p/UnnnlCzfCdcSDnTBgVFSn6Pozu8KwA7RK6X/9sR+6DwH3SKIkXOysZoSGKqbIO96gAXULBs0MxxXVVee+PkTMIml7UXAdDQtwdUJHjvTW0WXggxxLVJ+xV58HwcAKgYs+JWZNsgs17FHU0zE78= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792600481636740.747229202691; Wed, 21 Oct 2026 09:34:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJZFX-0007XK-4K; Wed, 21 Oct 2026 12:33:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFE-0007TQ-7z for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJZFB-0006Ue-Dd for qemu-devel@nongnu.org; Wed, 21 Oct 2026 12:32:51 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-gynGLf-qM4SnTryflJGB7g-1; Wed, 21 Oct 2026 16:32:47 +0000 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 50EBF1956071; Wed, 21 Oct 2026 16:32:46 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.54]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0D73518005B7; Wed, 21 Oct 2026 16:32:46 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3D6D91827598; Wed, 21 Oct 2026 18:32:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792600368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=10yZLh8hPPLWb86UtjEQBBrvb3K+69MRCSe8pZYeX/Y=; b=cToZl4gXHyjgcVgSQakH1tiZJcFodsDiTXV/OGTR+in+lOmnqskP1azsRymuoXixQnIApQ kHl4Xk0JxmVetuephgsxLAAnB+zVOy5zaEdWkv8gWK+XQnqLYdskpl5nWMhCtfZMIjnriM b9XhSUh4fFvfrSiDS0kxsBpKkhPU0Eg= X-MC-Unique: gynGLf-qM4SnTryflJGB7g-1 X-Mimecast-MFC-AGG-ID: gynGLf-qM4SnTryflJGB7g_1792600366 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Stefano Garzarella , Marcelo Tosatti , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Pierrick Bouvier , Zhao Liu , Ani Sinha , Paolo Bonzini , Eric Blake , Gerd Hoffmann Subject: [PULL 10/10] backends/igvm: fix parameter area entries leak Date: Wed, 21 Oct 2026 18:32:38 +0200 Message-ID: <20261021163239.1131460-11-kraxel@redhat.com> In-Reply-To: <20261021163239.1131460-1-kraxel@redhat.com> References: <20261021163239.1131460-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1792600482521158500 Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella qigvm_directive_parameter_area() allocates a QIgvmParameterData entry for each parameter area, allocates the data buffer, and queues it in the list. At the end of qigvm_process_file() we iterate the list to only free the data buffer of each entry, but never the entry itself, so all of them are leaked. Let's also free the entry itself and remove it from the list. We could avoid the removal since the list lives on the stack, but it's better to leave the list consistent. Fixes: c1d466d267cf ("backends/igvm: Add IGVM loader and configuration") Signed-off-by: Stefano Garzarella Message-ID: <20261021082459.72038-1-sgarzare@redhat.com> Signed-off-by: Gerd Hoffmann --- backends/igvm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backends/igvm.c b/backends/igvm.c index 4b9d78630863..cf8b762d824c 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -1086,7 +1086,7 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *ma= chine_state, bool onlyVpContext, Error **errp) { int32_t header_count; - QIgvmParameterData *parameter; + QIgvmParameterData *parameter, *tmp; int retval =3D -1; QIgvm ctx; =20 @@ -1186,10 +1186,11 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *= machine_state, retval =3D qigvm_process_mem_page(&ctx, NULL, errp); =20 cleanup_parameters: - QTAILQ_FOREACH(parameter, &ctx.parameter_data, next) + QTAILQ_FOREACH_SAFE(parameter, &ctx.parameter_data, next, tmp) { + QTAILQ_REMOVE(&ctx.parameter_data, parameter, next); g_free(parameter->data); - parameter->data =3D NULL; + g_free(parameter); } g_free(ctx.id_block); g_free(ctx.id_auth); --=20 2.56.0