From nobody Tue Feb 10 02:43:30 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=1770120297; cv=none; d=zohomail.com; s=zohoarc; b=jmE6a9ZqouhMHPQOsKjdZ/ywvboKlbuKhhChitUr02SB5i0ZNPlzUL/d67ih0vhDZbo04+ylSYXkmzSRSIV8LASKGM3OwwkhEM1xZcudQX0pcGMlKufSqWM3SpDpga6E0mR3v8DNmzZEbLis3PuapdFrCql68/QRVEOsB//4Cig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770120297; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0aCRPDrxg4NCu6mP5DGl6oPrRVZb+Wkaw1NUKhZqgnI=; b=ftEfGHm6jWjyRaG/HXkGnbu1HChH4AN6BfKNvzZMHbOlCKZdC82Gq+Jxg5TA11S0iw66d+5kO01w/V0F8SthwjY+w57Gm+b2zPzLyfU9/D+MlXwa7yXdurV5nrl/K2nU0rMjB75bQpB+UZlsrHDiVlOFX/WlbJa2g9lS+ydJrNA= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770120297103374.1084855389839; Tue, 3 Feb 2026 04:04:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vnF8l-00082q-2O; Tue, 03 Feb 2026 07:04:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vnF8f-0007uI-A1 for qemu-devel@nongnu.org; Tue, 03 Feb 2026 07:04:15 -0500 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 1vnF8d-0007gY-En for qemu-devel@nongnu.org; Tue, 03 Feb 2026 07:04:13 -0500 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-175--qBoOQ6hNIGjAyotWTN-pA-1; Tue, 03 Feb 2026 07:04:07 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 061EC1956050; Tue, 3 Feb 2026 12:04:06 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.34.28]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4BE231800285; Tue, 3 Feb 2026 12:04:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9BD79182626B; Tue, 03 Feb 2026 13:03:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770120250; 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=0aCRPDrxg4NCu6mP5DGl6oPrRVZb+Wkaw1NUKhZqgnI=; b=gWYpqh/wbIt1cBere5+I+H7ApW8mJyAbDd/HkYEM0XgE2TCymJeVkXS5f5oWGpm5kPmUzA zsdyM6iS3IZJviHM1FlE4LcueudityYVq7jhWHCIuPniPadjbgdBsOMk+kKhllJpmUtUwo UmCh4anLfKT6AzoI1xqkYB6vMaDTODA= X-MC-Unique: -qBoOQ6hNIGjAyotWTN-pA-1 X-Mimecast-MFC-AGG-ID: -qBoOQ6hNIGjAyotWTN-pA_1770120246 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Igor Mammedov , Paolo Bonzini , Marcel Apfelbaum , Ani Sinha , Pierrick Bouvier , Eduardo Habkost , Zhao Liu , Stefano Garzarella , Marcelo Tosatti , "Michael S. Tsirkin" , Richard Henderson , kvm@vger.kernel.org, Gerd Hoffmann , Oliver Steffen , Luigi Leonardi Subject: [PULL 15/17] igvm: Pass machine state to IGVM file processing Date: Tue, 3 Feb 2026 13:03:40 +0100 Message-ID: <20260203120343.656961-16-kraxel@redhat.com> In-Reply-To: <20260203120343.656961-1-kraxel@redhat.com> References: <20260203120343.656961-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 1770120299138158500 Content-Type: text/plain; charset="utf-8" From: Oliver Steffen Pass the full MachineState to the IGVM backend during file processing, instead of just the ConfidentialGuestSupport struct (which is a member of the MachineState). This replaces the cgs parameter of qigvm_process_file() with the machine state to make it available in the IGVM processing context. We will use it later to generate MADT data there to pass to the guest as IGVM parameter. Reviewed-by: Luigi Leonardi Signed-off-by: Oliver Steffen Message-ID: <20260130054714.715928-8-osteffen@redhat.com> Signed-off-by: Gerd Hoffmann --- include/system/igvm-cfg.h | 3 ++- include/system/igvm-internal.h | 3 ++- include/system/igvm.h | 5 +++-- backends/igvm-cfg.c | 2 +- backends/igvm.c | 28 ++++++++++++++++------------ target/i386/sev.c | 3 +-- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/include/system/igvm-cfg.h b/include/system/igvm-cfg.h index 6c07f3084082..e06d611f7446 100644 --- a/include/system/igvm-cfg.h +++ b/include/system/igvm-cfg.h @@ -12,6 +12,7 @@ #ifndef QEMU_IGVM_CFG_H #define QEMU_IGVM_CFG_H =20 +#include "hw/core/boards.h" #include "qemu/typedefs.h" #include "qom/object.h" =20 @@ -27,7 +28,7 @@ typedef struct IgvmCfgClass { * * Returns 0 for ok and -1 on error. */ - int (*process)(IgvmCfg *cfg, ConfidentialGuestSupport *cgs, + int (*process)(IgvmCfg *cfg, MachineState *machine_state, bool onlyVpContext, Error **errp); =20 } IgvmCfgClass; diff --git a/include/system/igvm-internal.h b/include/system/igvm-internal.h index 019f95e86615..1d36519ab082 100644 --- a/include/system/igvm-internal.h +++ b/include/system/igvm-internal.h @@ -12,6 +12,7 @@ #include "qemu/queue.h" #include "qemu/typedefs.h" #include "qom/object.h" +#include "hw/core/boards.h" #include "hw/core/resettable.h" =20 #include "system/confidential-guest-support.h" @@ -43,7 +44,7 @@ typedef struct QIgvmParameterData { */ typedef struct QIgvm { IgvmHandle file; - ConfidentialGuestSupport *cgs; + MachineState *machine_state; ConfidentialGuestSupportClass *cgsc; uint32_t compatibility_mask; unsigned current_header_index; diff --git a/include/system/igvm.h b/include/system/igvm.h index 8355e54e95fc..5573a6111ae7 100644 --- a/include/system/igvm.h +++ b/include/system/igvm.h @@ -12,12 +12,13 @@ #ifndef BACKENDS_IGVM_H #define BACKENDS_IGVM_H =20 +#include "hw/core/boards.h" #include "qemu/typedefs.h" #include "system/confidential-guest-support.h" #include "qapi/error.h" =20 -int qigvm_process_file(IgvmCfg *igvm, ConfidentialGuestSupport *cgs, - bool onlyVpContext, Error **errp); +int qigvm_process_file(IgvmCfg *igvm, MachineState *machine_state, + bool onlyVpContext, Error **errp); =20 /* x86 native */ int qigvm_x86_get_mem_map_entry(int index, diff --git a/backends/igvm-cfg.c b/backends/igvm-cfg.c index f236b523df3b..64589ca34f24 100644 --- a/backends/igvm-cfg.c +++ b/backends/igvm-cfg.c @@ -52,7 +52,7 @@ static void igvm_reset_hold(Object *obj, ResetType type) =20 trace_igvm_reset_hold(type); =20 - qigvm_process_file(igvm, ms->cgs, false, &error_fatal); + qigvm_process_file(igvm, ms, false, &error_fatal); } =20 static void igvm_reset_exit(Object *obj, ResetType type) diff --git a/backends/igvm.c b/backends/igvm.c index ffd1c325b661..3e7c0ea41d14 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -202,7 +202,8 @@ static void *qigvm_prepare_memory(QIgvm *ctx, uint64_t = addr, uint64_t size, g_autofree char *region_name =3D g_strdup_printf("igvm.%X", region_identifier); igvm_pages =3D g_new0(MemoryRegion, 1); - if (ctx->cgs && ctx->cgs->require_guest_memfd) { + if (ctx->machine_state->cgs && + ctx->machine_state->cgs->require_guest_memfd) { if (!memory_region_init_ram_guest_memfd(igvm_pages, NULL, region_name, size, err= p)) { return NULL; @@ -322,7 +323,7 @@ static int qigvm_process_mem_region(QIgvm *ctx, unsigne= d start_index, * If a confidential guest support object is provided then use it to s= et the * guest state. */ - if (ctx->cgs) { + if (ctx->machine_state->cgs) { cgs_page_type =3D qigvm_type_to_cgs_type(page_type, flags->unmeasured, zero); if (cgs_page_type < 0) { @@ -424,7 +425,7 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const= uint8_t *header_data, =20 data =3D (uint8_t *)igvm_get_buffer(ctx->file, data_handle); =20 - if (ctx->cgs) { + if (ctx->machine_state->cgs) { result =3D ctx->cgsc->set_guest_state( vp_context->gpa, data, igvm_get_buffer_size(ctx->file, data_ha= ndle), CGS_PAGE_TYPE_VMSA, vp_context->vp_index, errp); @@ -494,7 +495,7 @@ static int qigvm_directive_parameter_insert(QIgvm *ctx, * If a confidential guest support object is provided then use it to * set the guest state. */ - if (ctx->cgs) { + if (ctx->machine_state->cgs) { result =3D ctx->cgsc->set_guest_state(param->gpa, region, param_entry->size, CGS_PAGE_TYPE_UNMEASURED, 0, @@ -535,7 +536,7 @@ static int qigvm_directive_memory_map(QIgvm *ctx, const= uint8_t *header_data, ConfidentialGuestMemoryMapEntry cgmm_entry; int retval =3D 0; =20 - if (ctx->cgs && ctx->cgsc->get_mem_map_entry) { + if (ctx->machine_state->cgs && ctx->cgsc->get_mem_map_entry) { get_mem_map_entry =3D ctx->cgsc->get_mem_map_entry; =20 } else if (target_arch() =3D=3D SYS_EMU_TARGET_X86_64) { @@ -661,7 +662,7 @@ static int qigvm_directive_required_memory(QIgvm *ctx, if (!region) { return -1; } - if (ctx->cgs) { + if (ctx->machine_state->cgs) { result =3D ctx->cgsc->set_guest_state(mem->gpa, region, mem->number_of_by= tes, CGS_PAGE_TYPE_REQUIRED_MEMORY, 0, e= rrp); @@ -779,14 +780,14 @@ static int qigvm_supported_platform_compat_mask(QIgvm= *ctx, Error **errp) sizeof( IGVM_VHS_VARIABLE_HEAD= ER)); if ((platform->platform_type =3D=3D IGVM_PLATFORM_TYPE_SEV_ES)= && - ctx->cgs) { + ctx->machine_state->cgs) { if (ctx->cgsc->check_support( CGS_PLATFORM_SEV_ES, platform->platform_version, platform->highest_vtl, platform->shared_gpa_bounda= ry)) { compatibility_mask_sev_es =3D platform->compatibility_= mask; } } else if ((platform->platform_type =3D=3D IGVM_PLATFORM_TYPE_= SEV) && - ctx->cgs) { + ctx->machine_state->cgs) { if (ctx->cgsc->check_support( CGS_PLATFORM_SEV, platform->platform_version, platform->highest_vtl, platform->shared_gpa_bounda= ry)) { @@ -794,7 +795,7 @@ static int qigvm_supported_platform_compat_mask(QIgvm *= ctx, Error **errp) } } else if ((platform->platform_type =3D=3D IGVM_PLATFORM_TYPE_SEV_SNP) && - ctx->cgs) { + ctx->machine_state->cgs) { if (ctx->cgsc->check_support( CGS_PLATFORM_SEV_SNP, platform->platform_version, platform->highest_vtl, platform->shared_gpa_bounda= ry)) { @@ -867,7 +868,7 @@ IgvmHandle qigvm_file_init(char *filename, Error **errp) return igvm; } =20 -int qigvm_process_file(IgvmCfg *cfg, ConfidentialGuestSupport *cgs, +int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state, bool onlyVpContext, Error **errp) { int32_t header_count; @@ -883,13 +884,16 @@ int qigvm_process_file(IgvmCfg *cfg, ConfidentialGues= tSupport *cgs, ctx.file =3D cfg->file; trace_igvm_process_file(cfg->file, onlyVpContext); =20 + ctx.machine_state =3D machine_state; + /* * The ConfidentialGuestSupport object is optional and allows a confid= ential * guest platform to perform extra processing, such as page measuremen= t, on * IGVM directives. */ - ctx.cgs =3D cgs; - ctx.cgsc =3D cgs ? CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(cgs) : NULL; + ctx.cgsc =3D machine_state->cgs ? + CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(machine_state->cgs= ) : + NULL; =20 /* * Check that the IGVM file provides configuration for the current diff --git a/target/i386/sev.c b/target/i386/sev.c index fef9f441c61e..acdcb9c4e681 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -1892,8 +1892,7 @@ static int sev_common_kvm_init(ConfidentialGuestSuppo= rt *cgs, Error **errp) */ if (x86machine->igvm) { if (IGVM_CFG_GET_CLASS(x86machine->igvm) - ->process(x86machine->igvm, machine->cgs, true, errp) = =3D=3D - -1) { + ->process(x86machine->igvm, machine, true, errp) =3D= =3D -1) { return -1; } /* --=20 2.52.0