From nobody Sun Sep 28 17:04:53 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=1758884561; cv=none; d=zohomail.com; s=zohoarc; b=mqUHh8p1YZKdtO5bdTDR/uB/J2x4OJZON714hupFyVyLSe76oqcM0uyoTtbeH0xu/nT6oedBpfdjQvd6+4MoKjIKcoHxItJXvoucVNnVZwz/4GTlRtnNzwTbQFHiobB+kFtKf8FC3rnslmx5XpGznHcR/88JX6z94QHz7LoqgEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758884561; 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=FBEMiCFVj3xvS3M2nmY01HIfGjSvVC9LBpvAbZyiaFI=; b=OH7TOejZgMfGKY64e7jMBYjjSlUULYBnnAYccPKuOk5/XJzdzhXf75cBKjGBVynevfbozONPPXElFOrG5fsPDvfcJIMwjyfFQisVwkmSQQZbPX2JT6XF8OVn4zP03Q5m5T9CgIiFrOrJxo170/uxJsNSVa2MTxT24vJ6FM9/Jgk= 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 1758884561950783.9423777303517; Fri, 26 Sep 2025 04:02:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v26BO-0007Bz-2U; Fri, 26 Sep 2025 07:00:10 -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 1v26BH-0007At-B7 for qemu-devel@nongnu.org; Fri, 26 Sep 2025 07:00:03 -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 1v26B4-0007SY-Tx for qemu-devel@nongnu.org; Fri, 26 Sep 2025 07:00:01 -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-499-3V-8H5E2PvCXV_Xg2O_6JA-1; Fri, 26 Sep 2025 06:59:36 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E6B5C19774E5; Fri, 26 Sep 2025 10:59:35 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.32.43]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A20C1195419F; Fri, 26 Sep 2025 10:59:35 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4E9ED1800619; Fri, 26 Sep 2025 12:59:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758884379; 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=FBEMiCFVj3xvS3M2nmY01HIfGjSvVC9LBpvAbZyiaFI=; b=Zes8eZMY+P4Ei06tFDipnlR8qjGjlXHLK8qLgiOQBe3++P4EleXO/i0Acry3gmdBo9UFyl PfRsO/5mTBiWa9wYJl3cgbFYgxuZ88iewvaZp2EkNVRV4Cu+bELyGV1qv6DGCAyFWwYJkt lXnye83gYYox4/nC6II+BlkJ8+GkLSs= X-MC-Unique: 3V-8H5E2PvCXV_Xg2O_6JA-1 X-Mimecast-MFC-AGG-ID: 3V-8H5E2PvCXV_Xg2O_6JA_1758884376 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Zhao Liu , Paolo Bonzini , Gerd Hoffmann Subject: [PATCH v2 4/4] igvm: track memory regions created Date: Fri, 26 Sep 2025 12:59:26 +0200 Message-ID: <20250926105926.121890-5-kraxel@redhat.com> In-Reply-To: <20250926105926.121890-1-kraxel@redhat.com> References: <20250926105926.121890-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.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.446, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, T_SPF_TEMPERROR=0.01 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: 1758884568495116600 Content-Type: text/plain; charset="utf-8" Keep a linked list of the memory regions created by igvm. Signed-off-by: Gerd Hoffmann --- backends/igvm.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/backends/igvm.c b/backends/igvm.c index 47600c361db4..5a8b4196149c 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -34,6 +34,11 @@ typedef struct QIgvmParameterData { uint32_t index; } QIgvmParameterData; =20 +typedef struct QIgvmMemoryRegion { + QTAILQ_ENTRY(QIgvmMemoryRegion) next; + MemoryRegion mr; +} QIgvmMemoryRegion; + /* * Some directives are specific to particular confidential computing platf= orms. * Define required types for each of those platforms here. @@ -79,6 +84,7 @@ typedef struct QIgvm { uint32_t compatibility_mask; unsigned current_header_index; QTAILQ_HEAD(, QIgvmParameterData) parameter_data; + QTAILQ_HEAD(, QIgvmMemoryRegion) memory_regions; IgvmPlatformType platform_type; =20 /* @@ -191,7 +197,7 @@ static void *qigvm_prepare_memory(QIgvm *ctx, uint64_t = addr, uint64_t size, int region_identifier, Error **errp) { ERRP_GUARD(); - MemoryRegion *igvm_pages =3D NULL; + QIgvmMemoryRegion *pages =3D NULL; Int128 gpa_region_size; MemoryRegionSection mrs =3D memory_region_find(get_system_memory(), addr, size); @@ -225,20 +231,21 @@ 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); + pages =3D g_new0(QIgvmMemoryRegion, 1); if (ctx->cgs && ctx->cgs->require_guest_memfd) { - if (!memory_region_init_ram_guest_memfd(igvm_pages, NULL, + if (!memory_region_init_ram_guest_memfd(&pages->mr, NULL, region_name, size, err= p)) { return NULL; } } else { - if (!memory_region_init_ram(igvm_pages, NULL, region_name, siz= e, + if (!memory_region_init_ram(&pages->mr, NULL, region_name, siz= e, errp)) { return NULL; } } - memory_region_add_subregion(get_system_memory(), addr, igvm_pages); - return memory_region_get_ram_ptr(igvm_pages); + memory_region_add_subregion(get_system_memory(), addr, &pages->mr); + QTAILQ_INSERT_TAIL(&ctx->memory_regions, pages, next); + return memory_region_get_ram_ptr(&pages->mr); } } =20 @@ -934,6 +941,7 @@ int qigvm_process_file(IgvmCfg *cfg, ConfidentialGuestS= upport *cgs, } =20 QTAILQ_INIT(&ctx.parameter_data); + QTAILQ_INIT(&ctx.memory_regions); =20 for (ctx.current_header_index =3D 0; ctx.current_header_index < (unsigned)header_count; --=20 2.51.0