From nobody Sun Sep 28 16:36:34 2025 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=1758018753; cv=none; d=zohomail.com; s=zohoarc; b=nDAWoj5XpjNC7j2hoCRDRAcPzu/cckpyeYRtTqgmjwQxpY34FhSNKW26BCoF/V2W70YN91LH9GSaqSd0jh3H6vEnI7N8CmwKp4pJFGKTgQzDPkJNiHXyQ20Lhl+yLKM5RH1h0PdQE/iz/ZDu/8uI5vcNiVjIZp4m5jfp+UWpyww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758018753; 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=HoLLtDqNGVTdiRisEdK/jURVkbxy+tmYmSz13Vku/6Y=; b=e2Kz/sgX3J23a/LDdVRDmgDlxfmEbYBCRRvoc8q0C3lAbA0e0MPVex82GsM6N5dE2gKWmbcAPx8Q9uW5YoB8NN394hYOohLF1PKRyRPfqUBi5EiI/hQ47Jlz2n78uRRiPBhtaX/XmYYc8aDN5bi5wSEO9+lKuc6y1U/q+DO/XXY= 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 1758018753054349.9339507216032; Tue, 16 Sep 2025 03:32:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uySy5-0005Ch-21; Tue, 16 Sep 2025 06:31:25 -0400 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 1uySy1-0005Bm-7F for qemu-devel@nongnu.org; Tue, 16 Sep 2025 06:31:21 -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 1uySxw-0002Ci-9U for qemu-devel@nongnu.org; Tue, 16 Sep 2025 06:31:20 -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-602-VALydNDCNxyt0L8s6eUKiw-1; Tue, 16 Sep 2025 06:31:07 -0400 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 9E57D1956094; Tue, 16 Sep 2025 10:31:06 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.32.55]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E599819560B8; Tue, 16 Sep 2025 10:31:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 8ABC71800D58; Tue, 16 Sep 2025 12:31:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758018671; 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=HoLLtDqNGVTdiRisEdK/jURVkbxy+tmYmSz13Vku/6Y=; b=ALsQgthlB/zIWWCpQiCK3eD/ZDe9T9zP+JNr9F2koZePLUl/jxsyfZy5hzgvHJBKJJ4wKu zuGhGYKXodb5LK3121xsXyMij8wNLQLGoh3JJEfIT4h1ley6X4ctu/C/jnHIEzT5/oq9wb WDcnSRnVW48hL9k8jNWqxMCGjVpgZ4g= X-MC-Unique: VALydNDCNxyt0L8s6eUKiw-1 X-Mimecast-MFC-AGG-ID: VALydNDCNxyt0L8s6eUKiw_1758018666 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Zhao Liu , Gerd Hoffmann Subject: [PATCH 1/2] igvm: move igvm.h file to include/system Date: Tue, 16 Sep 2025 12:31:02 +0200 Message-ID: <20250916103103.400662-2-kraxel@redhat.com> In-Reply-To: <20250916103103.400662-1-kraxel@redhat.com> References: <20250916103103.400662-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=lists.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: -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.035, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 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: 1758018756395116600 Content-Type: text/plain; charset="utf-8" Prepare for arch-specific igvm code being added to the code base. Signed-off-by: Gerd Hoffmann --- {backends =3D> include/system}/igvm.h | 0 backends/igvm-cfg.c | 2 +- backends/igvm.c | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename {backends =3D> include/system}/igvm.h (100%) diff --git a/backends/igvm.h b/include/system/igvm.h similarity index 100% rename from backends/igvm.h rename to include/system/igvm.h diff --git a/backends/igvm-cfg.c b/backends/igvm-cfg.c index 45df63e06c1a..d00acf351249 100644 --- a/backends/igvm-cfg.c +++ b/backends/igvm-cfg.c @@ -12,7 +12,7 @@ #include "qemu/osdep.h" =20 #include "system/igvm-cfg.h" -#include "igvm.h" +#include "system/igvm.h" #include "qom/object_interfaces.h" =20 static char *get_igvm(Object *obj, Error **errp) diff --git a/backends/igvm.c b/backends/igvm.c index 9ad41582ee5e..723d45b755a0 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -11,8 +11,8 @@ =20 #include "qemu/osdep.h" =20 -#include "igvm.h" #include "qapi/error.h" +#include "system/igvm.h" #include "system/memory.h" #include "system/address-spaces.h" #include "hw/core/cpu.h" --=20 2.51.0 From nobody Sun Sep 28 16:36:34 2025 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=1758018750; cv=none; d=zohomail.com; s=zohoarc; b=l9N1qbdIpwdRWkgvczRV2blWRHVAxFJ+TCof2b6ELYeaYaG7Ruf/1JtDxURc3afl7LyaAf+FWdEgnJ2zSz9D3B04EzBOT9NVAPdu6WZJDRl5bdpL3zKooKozJstetHLypCM1bApUttWlyF8Z9HlSh1q/09i0H1iE2yZYFuZ1wBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758018750; 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=pC5ASnKY1LOCO3AnYGAVh/QbTuRCFijvTslzE+/AN9c=; b=PPPVtlJEQ5FjwvYmjLYeFooQKL+wNjFK1OlwPVa2Ijab2fALBkQ+Vg9hnRMtEnoJVNx8myizns4gvTQiGciJQKhcg9JzPt06LpANmnUhfgdwWchMCCO42dVrWm2gUwrbuVAmdzWIGdy0t3VUVfz/+tbdIfoC/J7zCeEtWtxmHtw= 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 17580187506441010.1625712856803; Tue, 16 Sep 2025 03:32:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uySy8-0005D6-8v; Tue, 16 Sep 2025 06:31:28 -0400 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 1uySy2-0005CD-SH for qemu-devel@nongnu.org; Tue, 16 Sep 2025 06:31:24 -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 1uySxx-0002Ct-Gl for qemu-devel@nongnu.org; Tue, 16 Sep 2025 06:31:22 -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-626-0FxEQjY3MFSbKtq4h2Gp_Q-1; Tue, 16 Sep 2025 06:31:11 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 3847D18002C0; Tue, 16 Sep 2025 10:31:10 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.32.55]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 20E941956056; Tue, 16 Sep 2025 10:31:09 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A621B1800D5B; Tue, 16 Sep 2025 12:31:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758018672; 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=pC5ASnKY1LOCO3AnYGAVh/QbTuRCFijvTslzE+/AN9c=; b=VabKaOGXmq9N9uccBb8wk6MYfRyGFTe8oF1LwBaVh2HlNWN+BObec3kXsbDghH3gEcBMO3 0OZqdcSse0ilb5u2EJ4uOmtpldB0Bp/nAStA/6ttowG7+UeFdxARG3gixSOGybXB0oCC5h U6ulDxVrZDR+ltL4dbks5yCayJBYwns= X-MC-Unique: 0FxEQjY3MFSbKtq4h2Gp_Q-1 X-Mimecast-MFC-AGG-ID: 0FxEQjY3MFSbKtq4h2Gp_Q_1758018670 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Zhao Liu , Gerd Hoffmann Subject: [PATCH 2/2] igvm: add support for igvm memory map parameter in native mode Date: Tue, 16 Sep 2025 12:31:03 +0200 Message-ID: <20250916103103.400662-3-kraxel@redhat.com> In-Reply-To: <20250916103103.400662-1-kraxel@redhat.com> References: <20250916103103.400662-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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.133.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.035, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 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: 1758018752884116601 Content-Type: text/plain; charset="utf-8" Add and wire up qigvm_x86_get_mem_map_entry function which converts the e820 table into an igvm memory map parameter. This makes igvm files for the native (non-confidential) platform with memory map parameter work. Signed-off-by: Gerd Hoffmann --- include/system/igvm.h | 5 +++++ backends/igvm.c | 18 +++++++++++++---- stubs/igvm.c | 21 ++++++++++++++++++++ target/i386/igvm.c | 44 +++++++++++++++++++++++++++++++++++++++++ stubs/meson.build | 1 + target/i386/meson.build | 3 +++ 6 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 stubs/igvm.c create mode 100644 target/i386/igvm.c diff --git a/include/system/igvm.h b/include/system/igvm.h index a4abab043a1f..3f72a40b8897 100644 --- a/include/system/igvm.h +++ b/include/system/igvm.h @@ -19,4 +19,9 @@ int qigvm_process_file(IgvmCfg *igvm, ConfidentialGuestSupport *cgs, bool onlyVpContext, Error **errp); =20 +/* x86 native */ +int qigvm_x86_get_mem_map_entry(int index, + ConfidentialGuestMemoryMapEntry *entry, + Error **errp); + #endif diff --git a/backends/igvm.c b/backends/igvm.c index 723d45b755a0..41f4e5e2e059 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -543,6 +543,8 @@ static int qigvm_directive_memory_map(QIgvm *ctx, const= uint8_t *header_data, Error **errp) { const IGVM_VHS_PARAMETER *param =3D (const IGVM_VHS_PARAMETER *)header= _data; + int (*get_mem_map_entry)(int index, ConfidentialGuestMemoryMapEntry *e= ntry, + Error **errp) =3D NULL; QIgvmParameterData *param_entry; int max_entry_count; int entry =3D 0; @@ -550,7 +552,16 @@ static int qigvm_directive_memory_map(QIgvm *ctx, cons= t uint8_t *header_data, ConfidentialGuestMemoryMapEntry cgmm_entry; int retval =3D 0; =20 - if (!ctx->cgs) { + if (ctx->cgs && ctx->cgsc->get_mem_map_entry) { + get_mem_map_entry =3D ctx->cgsc->get_mem_map_entry; + } + + if (!get_mem_map_entry) { + /* TODO: must check target arch when supporting non-x86 platforms = */ + get_mem_map_entry =3D qigvm_x86_get_mem_map_entry; + } + + if (!get_mem_map_entry) { error_setg(errp, "IGVM file contains a memory map but this is not suppor= ted " "by the current system."); @@ -565,7 +576,7 @@ static int qigvm_directive_memory_map(QIgvm *ctx, const= uint8_t *header_data, param_entry->size / sizeof(IGVM_VHS_MEMORY_MAP_ENTRY); mm_entry =3D (IGVM_VHS_MEMORY_MAP_ENTRY *)param_entry->data; =20 - retval =3D ctx->cgsc->get_mem_map_entry(entry, &cgmm_entry, er= rp); + retval =3D get_mem_map_entry(entry, &cgmm_entry, errp); while (retval =3D=3D 0) { if (entry > max_entry_count) { error_setg( @@ -598,8 +609,7 @@ static int qigvm_directive_memory_map(QIgvm *ctx, const= uint8_t *header_data, IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED; break; } - retval =3D - ctx->cgsc->get_mem_map_entry(++entry, &cgmm_entry, err= p); + retval =3D get_mem_map_entry(++entry, &cgmm_entry, errp); } if (retval < 0) { return retval; diff --git a/stubs/igvm.c b/stubs/igvm.c new file mode 100644 index 000000000000..c32058eb2a6e --- /dev/null +++ b/stubs/igvm.c @@ -0,0 +1,21 @@ +/* + * QEMU IGVM, stubs + * + * Copyright (C) 2026 Red Hat + * + * Authors: + * Gerd Hoffmann + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" + +#include "system/igvm.h" + +int qigvm_x86_get_mem_map_entry(int index, + ConfidentialGuestMemoryMapEntry *entry, + Error **errp) +{ + return -1; +} diff --git a/target/i386/igvm.c b/target/i386/igvm.c new file mode 100644 index 000000000000..e7a520cd07a0 --- /dev/null +++ b/target/i386/igvm.c @@ -0,0 +1,44 @@ +/* + * QEMU IGVM, support for native x86 guests + * + * Copyright (C) 2026 Red Hat + * + * Authors: + * Gerd Hoffmann + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" + +#include "hw/i386/e820_memory_layout.h" +#include "system/igvm.h" + +/* + * convert e820 table into igvm memory map + */ +int qigvm_x86_get_mem_map_entry(int index, + ConfidentialGuestMemoryMapEntry *entry, + Error **errp) +{ + struct e820_entry *table; + int num_entries; + + num_entries =3D e820_get_table(&table); + if ((index < 0) || (index >=3D num_entries)) { + return 1; + } + entry->gpa =3D table[index].address; + entry->size =3D table[index].length; + switch (table[index].type) { + case E820_RAM: + entry->type =3D CGS_MEM_RAM; + break; + case E820_RESERVED: + entry->type =3D CGS_MEM_RESERVED; + break; + default: + return -1; + } + return 0; +} diff --git a/stubs/meson.build b/stubs/meson.build index cef046e6854d..b362b2472373 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -73,6 +73,7 @@ if have_system stub_ss.add(files('dump.c')) stub_ss.add(files('cmos.c')) stub_ss.add(files('fw_cfg.c')) + stub_ss.add(files('igvm.c')) stub_ss.add(files('target-get-monitor-def.c')) stub_ss.add(files('target-monitor-defs.c')) stub_ss.add(files('win32-kbd-hook.c')) diff --git a/target/i386/meson.build b/target/i386/meson.build index 092af34e2d85..da2d5d80792b 100644 --- a/target/i386/meson.build +++ b/target/i386/meson.build @@ -25,6 +25,9 @@ i386_system_ss.add(files( )) i386_system_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files('sev-system-stub.c'= )) +if igvm.found() + i386_system_ss.add(files('igvm.c')) +endif =20 i386_user_ss =3D ss.source_set() =20 --=20 2.51.0