Files
qemu/include/system/igvm-internal.h
Luigi Leonardi 4d3b9dc4d1 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>
2026-07-02 11:14:19 +02:00

79 lines
1.9 KiB
C

/*
* QEMU IGVM private data structures
*
* Everything which depends on igvm library headers goes here.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef QEMU_IGVM_INTERNAL_H
#define QEMU_IGVM_INTERNAL_H
#include "qemu/queue.h"
#include "qemu/typedefs.h"
#include "qom/object.h"
#include "hw/core/boards.h"
#include "hw/core/resettable.h"
#include "system/confidential-guest-support.h"
#include <igvm/igvm.h>
struct IgvmCfg {
Object parent_obj;
/*
* filename: Filename that specifies a file that contains the configuration
* of the guest in Independent Guest Virtual Machine (IGVM)
* format.
*/
char *filename;
IgvmHandle file;
ResettableState reset_state;
};
typedef struct QIgvmParameterData {
QTAILQ_ENTRY(QIgvmParameterData) next;
uint8_t *data;
uint32_t size;
uint32_t index;
} QIgvmParameterData;
/*
* QIgvm contains the information required during processing of a single IGVM
* file.
*/
struct QIgvm {
IgvmHandle file;
MachineState *machine_state;
ConfidentialGuestSupportClass *cgsc;
uint32_t compatibility_mask;
unsigned current_header_index;
QTAILQ_HEAD(, QIgvmParameterData) parameter_data;
IgvmPlatformType platform_type;
/*
* SEV-SNP platforms can contain an ID block and authentication
* that should be verified by the guest.
*/
struct sev_id_block *id_block;
struct sev_id_authentication *id_auth;
/* Define the guest policy for SEV guests */
uint64_t sev_policy;
/* These variables keep track of contiguous page regions */
IGVM_VHS_PAGE_DATA region_prev_page_data;
uint64_t region_start;
unsigned region_start_index;
unsigned region_last_index;
unsigned region_page_count;
};
IgvmHandle qigvm_file_init(char *filename, Error **errp);
QIgvmParameterData*
qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index,
Error **errp);
#endif