mirror of
https://github.com/qemu/qemu.git
synced 2026-02-04 02:24:38 +00:00
igvm: Fill MADT IGVM parameter field on x86_64
Use the new acpi_build_madt_standalone() function to fill the MADT parameter field. The IGVM parameter can be consumed by Coconut SVSM [1], instead of relying on the fw_cfg interface, which has caused problems before due to unexpected access [2,3]. Using IGVM parameters is the default way for Coconut SVSM across hypervisors; switching over would allow removing specialized code paths for QEMU in Coconut. Coconut SVSM needs to know the SMP configuration, but does not look at any other ACPI data, nor does it interact with the PCI bus settings. Since the MADT is static and not linked with other ACPI tables, it can be supplied stand-alone like this. Generating the MADT twice (during ACPI table building and IGVM processing) seems acceptable, since there is no infrastructure to obtain the MADT out of the ACPI table memory area. In any case OVMF, which runs after SVSM has already been initialized, will continue reading all ACPI tables via fw_cfg and provide fixed up ACPI data to the OS as before without any changes. The IGVM parameter handler is implemented for the i386 machine target and stubbed for all others. [1] https://github.com/coconut-svsm/svsm/pull/858 [2] https://gitlab.com/qemu-project/qemu/-/issues/2882 [3] https://github.com/coconut-svsm/svsm/issues/646 Signed-off-by: Oliver Steffen <osteffen@redhat.com> Message-ID: <20260130054714.715928-10-osteffen@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
committed by
Gerd Hoffmann
parent
81553078a1
commit
dea1f68a5c
@@ -128,6 +128,8 @@ static struct QIGVMHandler handlers[] = {
|
||||
qigvm_directive_snp_id_block },
|
||||
{ IGVM_VHT_GUEST_POLICY, IGVM_HEADER_SECTION_INITIALIZATION,
|
||||
qigvm_initialization_guest_policy },
|
||||
{ IGVM_VHT_MADT, IGVM_HEADER_SECTION_DIRECTIVE,
|
||||
qigvm_directive_madt },
|
||||
};
|
||||
|
||||
static int qigvm_handler(QIgvm *ctx, uint32_t type, Error **errp)
|
||||
|
||||
@@ -74,4 +74,9 @@ IgvmHandle qigvm_file_init(char *filename, Error **errp);
|
||||
QIgvmParameterData*
|
||||
qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index);
|
||||
|
||||
/*
|
||||
* IGVM parameter handlers
|
||||
*/
|
||||
int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
|
||||
#include "system/igvm.h"
|
||||
#include "system/igvm-internal.h"
|
||||
|
||||
int qigvm_x86_get_mem_map_entry(int index,
|
||||
ConfidentialGuestMemoryMapEntry *entry,
|
||||
@@ -24,3 +25,8 @@ int qigvm_x86_set_vp_context(void *data, int index, Error **errp)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
|
||||
#include "cpu.h"
|
||||
#include "hw/i386/e820_memory_layout.h"
|
||||
#include "hw/i386/acpi-build.h"
|
||||
#include "system/igvm.h"
|
||||
#include "system/igvm-internal.h"
|
||||
|
||||
struct IgvmNativeVpContextX64 {
|
||||
uint64_t rax;
|
||||
@@ -178,3 +180,33 @@ void qigvm_x86_bsp_reset(CPUX86State *env)
|
||||
|
||||
qigvm_x86_load_context(bsp_context, env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process MADT IGVM parameter
|
||||
*/
|
||||
int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp)
|
||||
{
|
||||
const IGVM_VHS_PARAMETER *param = (const IGVM_VHS_PARAMETER *)header_data;
|
||||
QIgvmParameterData *param_entry;
|
||||
int result = 0;
|
||||
|
||||
/* Find the parameter area that should hold the MADT data */
|
||||
param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
|
||||
if (param_entry == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
GArray *madt = acpi_build_madt_standalone(ctx->machine_state);
|
||||
|
||||
if (madt->len <= param_entry->size) {
|
||||
memcpy(param_entry->data, madt->data, madt->len);
|
||||
} else {
|
||||
error_setg(
|
||||
errp,
|
||||
"IGVM: MADT size exceeds parameter area defined in IGVM file");
|
||||
result = -1;
|
||||
}
|
||||
|
||||
g_array_free(madt, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user