From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Roy Hopkins <roy.hopkins@randomman.co.uk>,
Stefano Garzarella <sgarzare@redhat.com>,
Ani Sinha <anisinha@redhat.com>, Zhao Liu <zhao1.liu@intel.com>
Subject: [PATCH v3 4/5] igvm: track memory regions created
Date: Wed, 15 Oct 2025 13:23:41 +0200 [thread overview]
Message-ID: <20251015112342.1672955-5-kraxel@redhat.com> (raw)
In-Reply-To: <20251015112342.1672955-1-kraxel@redhat.com>
Keep a linked list of the memory regions created by igvm.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
backends/igvm.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/backends/igvm.c b/backends/igvm.c
index ee5ee74c7a66..1690fb334bf5 100644
--- a/backends/igvm.c
+++ b/backends/igvm.c
@@ -28,6 +28,11 @@ typedef struct QIgvmParameterData {
uint32_t index;
} QIgvmParameterData;
+typedef struct QIgvmMemoryRegion {
+ QTAILQ_ENTRY(QIgvmMemoryRegion) next;
+ MemoryRegion mr;
+} QIgvmMemoryRegion;
+
/*
* Some directives are specific to particular confidential computing platforms.
* Define required types for each of those platforms here.
@@ -73,6 +78,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;
/*
@@ -185,7 +191,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;
+ QIgvmMemoryRegion *pages = NULL;
Int128 gpa_region_size;
MemoryRegionSection mrs =
memory_region_find(get_system_memory(), addr, size);
@@ -219,20 +225,21 @@ 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);
+ pages = 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, errp)) {
return NULL;
}
} else {
- if (!memory_region_init_ram(igvm_pages, NULL, region_name, size,
+ if (!memory_region_init_ram(&pages->mr, NULL, region_name, size,
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);
}
}
@@ -928,6 +935,7 @@ int qigvm_process_file(IgvmCfg *cfg, ConfidentialGuestSupport *cgs,
}
QTAILQ_INIT(&ctx.parameter_data);
+ QTAILQ_INIT(&ctx.memory_regions);
for (ctx.current_header_index = 0;
ctx.current_header_index < (unsigned)header_count;
--
2.51.0
next prev parent reply other threads:[~2025-10-15 11:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 11:23 [PATCH v3 0/5] igvm: add support for igvm memory map parameter in native mode Gerd Hoffmann
2025-10-15 11:23 ` [PATCH v3 1/5] igvm: move igvm.h file to include/system Gerd Hoffmann
2025-10-16 4:47 ` Ani Sinha
2025-10-17 13:20 ` Stefano Garzarella
2025-10-15 11:23 ` [PATCH v3 2/5] igvm: add support for igvm memory map parameter in native mode Gerd Hoffmann
2025-10-17 13:23 ` Stefano Garzarella
2025-10-15 11:23 ` [PATCH v3 3/5] igvm: add support for initial register state load " Gerd Hoffmann
2025-10-17 13:56 ` Stefano Garzarella
2025-10-22 6:49 ` Gerd Hoffmann
2025-10-22 6:52 ` Gerd Hoffmann
2025-10-15 11:23 ` Gerd Hoffmann [this message]
2025-10-16 5:52 ` [PATCH v3 4/5] igvm: track memory regions created Ani Sinha
2025-10-17 13:58 ` Stefano Garzarella
2025-10-20 12:14 ` Gerd Hoffmann
2025-10-20 12:30 ` Stefano Garzarella
2025-10-15 11:23 ` [PATCH v3 5/5] igvm: add MAINTAINERS entry Gerd Hoffmann
2025-10-16 5:02 ` Ani Sinha
2025-10-22 6:57 ` Philippe Mathieu-Daudé
2025-10-22 8:51 ` Gerd Hoffmann
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=20251015112342.1672955-5-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=anisinha@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=roy.hopkins@randomman.co.uk \
--cc=sgarzare@redhat.com \
--cc=zhao1.liu@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).