mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
igvm: Report error on missing parameter area in directive handlers
Parameter areas are how an IGVM file tells QEMU to allocate buffers for runtime information the guest needs — VP count, memory map, MADT and so on. Usage directives reference a parameter area by index to tell QEMU where to write each piece of data. If the index doesn't match any declared parameter area, the data has nowhere to go and should be treated as an error. The directive handlers that look up a parameter area all return 0 (success) when `qigvm_find_param_entry()` can't find it. Therefore, the load succeeds but the guest never gets the expected parameters. Note that the IGVM library already validates parameter area indices when the file is loaded, so this path should only be reachable with a malformed file that bypassed library validation. This is defensive programming against that case. Report the error with error_setg() and return -1 instead. Signed-off-by: Luigi Leonardi <leonardi@redhat.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Message-ID: <20260626-microvm_device_tree-v6-1-9cd13cf057e2@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
committed by
Gerd Hoffmann
parent
b833716681
commit
4d3b9dc4d1
@@ -81,7 +81,8 @@ struct QEMU_PACKED sev_id_authentication {
|
||||
#define IGVM_SEV_ID_BLOCK_VERSION 1
|
||||
|
||||
QIgvmParameterData*
|
||||
qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index)
|
||||
qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index,
|
||||
Error **errp)
|
||||
{
|
||||
QIgvmParameterData *param_entry;
|
||||
QTAILQ_FOREACH(param_entry, &igvm->parameter_data, next)
|
||||
@@ -90,7 +91,8 @@ qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index)
|
||||
return param_entry;
|
||||
}
|
||||
}
|
||||
warn_report("IGVM: No parameter area for index %u", parameter_area_index);
|
||||
error_setg(errp, "IGVM: parameter area index %u not found",
|
||||
parameter_area_index);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -528,9 +530,10 @@ static int qigvm_directive_parameter_insert(QIgvm *ctx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
|
||||
param_entry = qigvm_find_param_entry(ctx,
|
||||
param->parameter_area_index, errp);
|
||||
if (param_entry == NULL) {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
region = qigvm_prepare_memory(ctx, param->gpa, param_entry->size,
|
||||
@@ -601,9 +604,10 @@ static int qigvm_directive_memory_map(QIgvm *ctx, const uint8_t *header_data,
|
||||
}
|
||||
|
||||
/* Find the parameter area that should hold the memory map */
|
||||
param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
|
||||
param_entry = qigvm_find_param_entry(ctx,
|
||||
param->parameter_area_index, errp);
|
||||
if (param_entry == NULL) {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
max_entry_count = param_entry->size / sizeof(IGVM_VHS_MEMORY_MAP_ENTRY);
|
||||
@@ -660,9 +664,10 @@ static int qigvm_directive_vp_count(QIgvm *ctx, const uint8_t *header_data,
|
||||
uint32_t *vp_count;
|
||||
CPUState *cpu;
|
||||
|
||||
param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
|
||||
param_entry = qigvm_find_param_entry(ctx,
|
||||
param->parameter_area_index, errp);
|
||||
if (param_entry == NULL) {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
vp_count = (uint32_t *)(param_entry->data + param->byte_offset);
|
||||
@@ -683,9 +688,10 @@ static int qigvm_directive_environment_info(QIgvm *ctx,
|
||||
QIgvmParameterData *param_entry;
|
||||
IgvmEnvironmentInfo *environmental_state;
|
||||
|
||||
param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
|
||||
param_entry = qigvm_find_param_entry(ctx,
|
||||
param->parameter_area_index, errp);
|
||||
if (param_entry == NULL) {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
environmental_state =
|
||||
|
||||
@@ -72,6 +72,7 @@ struct QIgvm {
|
||||
IgvmHandle qigvm_file_init(char *filename, Error **errp);
|
||||
|
||||
QIgvmParameterData*
|
||||
qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index);
|
||||
qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index,
|
||||
Error **errp);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -191,9 +191,10 @@ int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp)
|
||||
int result = 0;
|
||||
|
||||
/* Find the parameter area that should hold the MADT data */
|
||||
param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
|
||||
param_entry = qigvm_find_param_entry(ctx,
|
||||
param->parameter_area_index, errp);
|
||||
if (param_entry == NULL) {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
GArray *madt = acpi_build_madt_standalone(ctx->machine_state);
|
||||
|
||||
Reference in New Issue
Block a user