Files
qemu-reims-vgpu/include/system/igvm-internal.h
T
Marc-André Lureau cab7a85020 igvm: make IgvmMemoryRegion a QOM
Make IgvmMemoryRegion a QOM object, embedding MemoryRegion, and use it
as the region owner. The IGVM list and memory subsystem can now hold
references independently, and QOM frees after the last reference is
dropped, fixing leaks reported by ASAN while running tests.

- object_unparent() is no longer needed, children are automatically unref
- switch to memory_region_init_ram_flags_nomigrate() as other helpers
  expect a DEVICE

Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-10-31 01:13:57 +04:00

89 lines
2.2 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>
typedef struct IgvmMemoryRegion IgvmMemoryRegion;
#define TYPE_IGVM_MEMORY_REGION "igvm-memory-region"
OBJECT_DECLARE_SIMPLE_TYPE(IgvmMemoryRegion, IGVM_MEMORY_REGION)
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;
/*
* cmdline: Command line for the software loaded from the IGVM file,
* if it asks for one.
*/
char *cmdline;
IgvmHandle file;
ResettableState reset_state;
QTAILQ_HEAD(, IgvmMemoryRegion) memory_regions;
};
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 {
IgvmCfg *cfg;
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;
/* 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);
uint8_t *
qigvm_get_param_data(QIgvm *igvm, const IGVM_VHS_PARAMETER *param,
uint32_t *param_size,
Error **errp);
#endif