From: Ani Sinha <anisinha@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Ani Sinha <anisinha@redhat.com>
Cc: ani@anisinha.ca, agraf@csgraf.de, graf@amazon.com, qemu-devel@nongnu.org
Subject: [PATCH v6 02/11] igvm: track memory regions
Date: Mon, 17 Aug 2026 19:49:57 +0530 [thread overview]
Message-ID: <20260817142010.80693-3-anisinha@redhat.com> (raw)
In-Reply-To: <20260817142010.80693-1-anisinha@redhat.com>
From: Gerd Hoffmann <kraxel@redhat.com>
Memory regions added by the current IGVM needs to be tracked so that they can be
freed when a new IGVM is loaded.
Reviewed-by: Ani Sinha <anisinha@redhat.com>
Reviewed-by: Alexander Graf <graf@amazon.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
backends/igvm-cfg.c | 1 +
backends/igvm.c | 20 ++++++++++++--------
include/system/igvm-internal.h | 6 ++++++
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/backends/igvm-cfg.c b/backends/igvm-cfg.c
index e1f09855f6..38438a7b1e 100644
--- a/backends/igvm-cfg.c
+++ b/backends/igvm-cfg.c
@@ -65,6 +65,7 @@ static void igvm_complete(UserCreatable *uc, Error **errp)
IgvmCfg *igvm = IGVM_CFG(uc);
igvm->file = qigvm_file_init(igvm->filename, errp);
+ QTAILQ_INIT(&igvm->memory_regions);
}
OBJECT_DEFINE_TYPE_WITH_INTERFACES(IgvmCfg, igvm_cfg, IGVM_CFG, OBJECT,
diff --git a/backends/igvm.c b/backends/igvm.c
index 534032fed8..9e7c90d386 100644
--- a/backends/igvm.c
+++ b/backends/igvm.c
@@ -220,7 +220,7 @@ static void *qigvm_prepare_memory(QIgvm *ctx, uint64_t addr, uint64_t size,
int region_identifier, Error **errp)
{
ERRP_GUARD();
- MemoryRegion *igvm_pages = NULL;
+ IgvmMemoryRegion *imr = NULL;
Int128 gpa_region_size;
MemoryRegionSection mrs =
memory_region_find(get_system_memory(), addr, size);
@@ -254,23 +254,27 @@ static void *qigvm_prepare_memory(QIgvm *ctx, uint64_t addr, uint64_t size,
*/
g_autofree char *region_name =
g_strdup_printf("igvm.%X", region_identifier);
- igvm_pages = g_new0(MemoryRegion, 1);
+ imr = g_new0(IgvmMemoryRegion, 1);
+ imr->mr = g_new0(MemoryRegion, 1);
if (ctx->machine_state->cgs &&
ctx->machine_state->cgs->require_guest_memfd) {
- if (!memory_region_init_ram_guest_memfd(igvm_pages, NULL,
+ if (!memory_region_init_ram_guest_memfd(imr->mr, NULL,
region_name, size, errp)) {
- g_free(igvm_pages);
+ g_free(imr->mr);
+ g_free(imr);
return NULL;
}
} else {
- if (!memory_region_init_ram(igvm_pages, NULL, region_name, size,
+ if (!memory_region_init_ram(imr->mr, NULL, region_name, size,
errp)) {
- g_free(igvm_pages);
+ g_free(imr->mr);
+ g_free(imr);
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, imr->mr);
+ QTAILQ_INSERT_TAIL(&ctx->cfg->memory_regions, imr, next);
+ return memory_region_get_ram_ptr(imr->mr);
}
}
diff --git a/include/system/igvm-internal.h b/include/system/igvm-internal.h
index b5720fae0c..9e9fa1d9af 100644
--- a/include/system/igvm-internal.h
+++ b/include/system/igvm-internal.h
@@ -18,6 +18,11 @@
#include "system/confidential-guest-support.h"
#include <igvm/igvm.h>
+typedef struct IgvmMemoryRegion {
+ QTAILQ_ENTRY(IgvmMemoryRegion) next;
+ MemoryRegion *mr;
+} IgvmMemoryRegion;
+
struct IgvmCfg {
Object parent_obj;
@@ -29,6 +34,7 @@ struct IgvmCfg {
char *filename;
IgvmHandle file;
ResettableState reset_state;
+ QTAILQ_HEAD(, IgvmMemoryRegion) memory_regions;
};
typedef struct QIgvmParameterData {
--
2.42.0
next prev parent reply other threads:[~2026-08-17 14:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 14:19 [PATCH v6 00/11] Introducing guest driven VM launch update mechanism (BYOF interface) Ani Sinha
2026-08-17 14:19 ` [PATCH v6 01/11] igvm: store IgvmCfg pointer in QIgvm Ani Sinha
2026-08-17 14:19 ` Ani Sinha [this message]
2026-08-17 14:19 ` [PATCH v6 03/11] igvm: cleanup memory regions Ani Sinha
2026-08-17 14:19 ` [PATCH v6 04/11] system/memory: add a tracepoint for memory_region_finalize Ani Sinha
2026-08-17 14:20 ` [PATCH v6 05/11] backends/igvm: add a tracepoint for qigvm_cleanup_memory Ani Sinha
2026-08-17 14:20 ` [PATCH v6 06/11] hw/misc/vmlaunchupdate: add api header Ani Sinha
2026-08-18 9:22 ` Gerd Hoffman
2026-08-19 4:31 ` Ani Sinha
2026-08-17 14:20 ` [PATCH v6 07/11] hw/misc/vmlaunchupdate: Introduce hypervisor fw-cfg interface support Ani Sinha
2026-08-17 14:20 ` [PATCH v6 08/11] docs/spec: Add a specification document for vm-launch-update device Ani Sinha
2026-08-17 14:20 ` [PATCH v6 09/11] tests/qtest: Add small igvm files for testing purpose Ani Sinha
2026-08-17 14:20 ` [PATCH v6 10/11] Add functional and unit tests for the vm-launch-update device Ani Sinha
2026-08-17 14:20 ` [PATCH v6 11/11] Update MAINTAINERS Ani Sinha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260817142010.80693-3-anisinha@redhat.com \
--to=anisinha@redhat.com \
--cc=agraf@csgraf.de \
--cc=ani@anisinha.ca \
--cc=graf@amazon.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.