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 01/11] igvm: store IgvmCfg pointer in QIgvm
Date: Mon, 17 Aug 2026 19:49:56 +0530 [thread overview]
Message-ID: <20260817142010.80693-2-anisinha@redhat.com> (raw)
In-Reply-To: <20260817142010.80693-1-anisinha@redhat.com>
From: Gerd Hoffmann <kraxel@redhat.com>
Store a pointer to IgvmCfg instead of only IgvmFile in QIgvm. Allows to
store additional state in the (persistent) IgvmCfg struct.
Reviewed-by: Ani Sinha <anisinha@redhat.com>
Reviewed-by: Alexander Graf <graf@amazon.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
backends/igvm.c | 57 ++++++++++++++++++++--------------
include/system/igvm-internal.h | 2 +-
2 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/backends/igvm.c b/backends/igvm.c
index 80e87fe602..534032fed8 100644
--- a/backends/igvm.c
+++ b/backends/igvm.c
@@ -178,7 +178,8 @@ static int qigvm_handler(QIgvm *ctx, IgvmVariableHeaderType raw_type,
if (handlers[handler].type != type) {
continue;
}
- header_handle = igvm_get_header(ctx->file, handlers[handler].section,
+ header_handle = igvm_get_header(ctx->cfg->file,
+ handlers[handler].section,
ctx->current_header_index);
if (header_handle < 0) {
error_setg(
@@ -187,7 +188,7 @@ static int qigvm_handler(QIgvm *ctx, IgvmVariableHeaderType raw_type,
(int)header_handle);
return -1;
}
- header_data = igvm_get_buffer(ctx->file, header_handle);
+ header_data = igvm_get_buffer(ctx->cfg->file, header_handle);
if (header_data != NULL) {
header_data += sizeof(IGVM_VHS_VARIABLE_HEADER);
result = handlers[handler].handler(ctx, header_data, errp);
@@ -198,7 +199,7 @@ static int qigvm_handler(QIgvm *ctx, IgvmVariableHeaderType raw_type,
header_handle, type);
result = -1;
}
- igvm_free_buffer(ctx->file, header_handle);
+ igvm_free_buffer(ctx->cfg->file, header_handle);
return result;
}
@@ -344,7 +345,8 @@ static int qigvm_process_mem_region(QIgvm *ctx, unsigned start_index,
for (page_index = 0; page_index < page_count; page_index++) {
data_handle = igvm_get_header_data(
- ctx->file, IGVM_HEADER_SECTION_DIRECTIVE, page_index + start_index);
+ ctx->cfg->file, IGVM_HEADER_SECTION_DIRECTIVE,
+ page_index + start_index);
if (data_handle == IGVMAPI_NO_DATA) {
/* No data indicates a zero page */
memset(®ion[page_index * page_size], 0, page_size);
@@ -357,7 +359,7 @@ static int qigvm_process_mem_region(QIgvm *ctx, unsigned start_index,
return -1;
} else {
zero = false;
- data_size = igvm_get_buffer_size(ctx->file, data_handle);
+ data_size = igvm_get_buffer_size(ctx->cfg->file, data_handle);
if (data_size < page_size) {
memset(®ion[page_index * page_size], 0, page_size);
} else if (data_size > page_size) {
@@ -367,14 +369,14 @@ static int qigvm_process_mem_region(QIgvm *ctx, unsigned start_index,
page_index + start_index);
return -1;
}
- data = igvm_get_buffer(ctx->file, data_handle);
+ data = igvm_get_buffer(ctx->cfg->file, data_handle);
if (data == NULL) {
error_setg(errp, "IGVM: No buffer for handle %d", data_handle);
- igvm_free_buffer(ctx->file, data_handle);
+ igvm_free_buffer(ctx->cfg->file, data_handle);
return -1;
}
memcpy(®ion[page_index * page_size], data, data_size);
- igvm_free_buffer(ctx->file, data_handle);
+ igvm_free_buffer(ctx->cfg->file, data_handle);
}
}
@@ -411,7 +413,8 @@ static int qigvm_process_mem_page(QIgvm *ctx,
ctx->region_start = page_data->gpa;
ctx->region_start_index = ctx->current_header_index;
} else {
- if (!qigvm_page_attrs_equal(ctx->file, ctx->current_header_index,
+ if (!qigvm_page_attrs_equal(ctx->cfg->file,
+ ctx->current_header_index,
page_data,
&ctx->region_prev_page_data) ||
((ctx->region_prev_page_data.gpa +
@@ -474,7 +477,8 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_data,
return 0;
}
- data_handle = igvm_get_header_data(ctx->file, IGVM_HEADER_SECTION_DIRECTIVE,
+ data_handle = igvm_get_header_data(ctx->cfg->file,
+ IGVM_HEADER_SECTION_DIRECTIVE,
ctx->current_header_index);
if (data_handle < 0) {
error_setg(errp, "Invalid VP context in IGVM file. Error code: %X",
@@ -482,7 +486,7 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_data,
return -1;
}
- data = (uint8_t *)igvm_get_buffer(ctx->file, data_handle);
+ data = (uint8_t *)igvm_get_buffer(ctx->cfg->file, data_handle);
if (data == NULL) {
error_setg(errp, "IGVM: No buffer for handle %d", data_handle);
result = -1;
@@ -491,7 +495,8 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_data,
if (ctx->machine_state->cgs) {
result = ctx->cgsc->set_guest_state(
- vp_context->gpa, data, igvm_get_buffer_size(ctx->file, data_handle),
+ vp_context->gpa, data,
+ igvm_get_buffer_size(ctx->cfg->file, data_handle),
CGS_PAGE_TYPE_VMSA, vp_context->vp_index, errp);
} else if (target_arch() == SYS_EMU_TARGET_X86_64) {
result = qigvm_x86_set_vp_context(data, vp_context->vp_index, errp);
@@ -504,7 +509,7 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_data,
}
exit:
- igvm_free_buffer(ctx->file, data_handle);
+ igvm_free_buffer(ctx->cfg->file, data_handle);
if (result < 0) {
return result;
}
@@ -863,7 +868,8 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp)
uint32_t compatibility_mask_sev_snp = 0;
uint32_t compatibility_mask = 0;
- header_count = igvm_header_count(ctx->file, IGVM_HEADER_SECTION_PLATFORM);
+ header_count = igvm_header_count(ctx->cfg->file,
+ IGVM_HEADER_SECTION_PLATFORM);
if (header_count < 0) {
error_setg(errp,
"Invalid platform header count in IGVM file. Error code: %X",
@@ -874,11 +880,11 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp)
for (header_index = 0; header_index < (unsigned)header_count;
header_index++) {
IgvmVariableHeaderType typ = igvm_get_header_type(
- ctx->file, IGVM_HEADER_SECTION_PLATFORM, header_index);
+ ctx->cfg->file, IGVM_HEADER_SECTION_PLATFORM, header_index);
typ = igvm_vht_type(typ);
if (typ == IGVM_VHT_SUPPORTED_PLATFORM) {
header_handle = igvm_get_header(
- ctx->file, IGVM_HEADER_SECTION_PLATFORM, header_index);
+ ctx->cfg->file, IGVM_HEADER_SECTION_PLATFORM, header_index);
if (header_handle < 0) {
error_setg(errp,
"Invalid platform header in IGVM file. "
@@ -887,11 +893,11 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp)
return -1;
}
platform =
- (IGVM_VHS_SUPPORTED_PLATFORM *)(igvm_get_buffer(ctx->file,
+ (IGVM_VHS_SUPPORTED_PLATFORM *)(igvm_get_buffer(ctx->cfg->file,
header_handle));
if (platform == NULL) {
error_setg(errp, "IGVM: No buffer for handle %d", header_handle);
- igvm_free_buffer(ctx->file, header_handle);
+ igvm_free_buffer(ctx->cfg->file, header_handle);
return -1;
}
@@ -922,7 +928,7 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp)
} else if (platform->platform_type == IGVM_PLATFORM_TYPE_NATIVE) {
compatibility_mask = platform->compatibility_mask;
}
- igvm_free_buffer(ctx->file, header_handle);
+ igvm_free_buffer(ctx->cfg->file, header_handle);
}
}
/* Choose the strongest supported isolation technology */
@@ -999,7 +1005,7 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state,
error_setg(errp, "No IGVM file loaded.");
return -1;
}
- ctx.file = cfg->file;
+ ctx.cfg = cfg;
trace_igvm_process_file(cfg->file, onlyVpContext);
ctx.machine_state = machine_state;
@@ -1021,7 +1027,8 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state,
goto cleanup;
}
- header_count = igvm_header_count(ctx.file, IGVM_HEADER_SECTION_DIRECTIVE);
+ header_count = igvm_header_count(ctx.cfg->file,
+ IGVM_HEADER_SECTION_DIRECTIVE);
if (header_count <= 0) {
error_setg(
errp, "Invalid directive header count in IGVM file. Error code: %X",
@@ -1035,7 +1042,8 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state,
ctx.current_header_index < (unsigned)header_count;
ctx.current_header_index++) {
IgvmVariableHeaderType raw_type = igvm_get_header_type(
- ctx.file, IGVM_HEADER_SECTION_DIRECTIVE, ctx.current_header_index);
+ ctx.cfg->file, IGVM_HEADER_SECTION_DIRECTIVE,
+ ctx.current_header_index);
if (!onlyVpContext || igvm_vht_type(raw_type) == IGVM_VHT_VP_CONTEXT) {
if (qigvm_handler(&ctx, raw_type, errp) < 0) {
goto cleanup_parameters;
@@ -1053,7 +1061,7 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state,
}
header_count =
- igvm_header_count(ctx.file, IGVM_HEADER_SECTION_INITIALIZATION);
+ igvm_header_count(ctx.cfg->file, IGVM_HEADER_SECTION_INITIALIZATION);
if (header_count < 0) {
error_setg(
errp,
@@ -1066,7 +1074,8 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state,
ctx.current_header_index < (unsigned)header_count;
ctx.current_header_index++) {
IgvmVariableHeaderType type =
- igvm_get_header_type(ctx.file, IGVM_HEADER_SECTION_INITIALIZATION,
+ igvm_get_header_type(ctx.cfg->file,
+ IGVM_HEADER_SECTION_INITIALIZATION,
ctx.current_header_index);
if (qigvm_handler(&ctx, type, errp) < 0) {
goto cleanup_parameters;
diff --git a/include/system/igvm-internal.h b/include/system/igvm-internal.h
index 7eb3792ed8..b5720fae0c 100644
--- a/include/system/igvm-internal.h
+++ b/include/system/igvm-internal.h
@@ -43,7 +43,7 @@ typedef struct QIgvmParameterData {
* file.
*/
struct QIgvm {
- IgvmHandle file;
+ IgvmCfg *cfg;
MachineState *machine_state;
ConfidentialGuestSupportClass *cgsc;
uint32_t compatibility_mask;
--
2.42.0
next prev parent reply other threads:[~2026-08-17 14:22 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 ` Ani Sinha [this message]
2026-08-17 14:19 ` [PATCH v6 02/11] igvm: track memory regions Ani Sinha
2026-08-17 14:19 ` [PATCH v6 03/11] igvm: cleanup " 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-2-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.