| 1 | /* |
| 2 | * QEMU IGVM private data structures |
| 3 | * |
| 4 | * Everything which depends on igvm library headers goes here. |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 7 | */ |
| 8 | |
| 9 | #ifndef QEMU_IGVM_INTERNAL_H |
| 10 | #define QEMU_IGVM_INTERNAL_H |
| 11 | |
| 12 | #include "qemu/queue.h" |
| 13 | #include "qemu/typedefs.h" |
| 14 | #include "qom/object.h" |
| 15 | #include "hw/core/boards.h" |
| 16 | #include "hw/core/resettable.h" |
| 17 | |
| 18 | #include "system/confidential-guest-support.h" |
| 19 | #include <igvm/igvm.h> |
| 20 | |
| 21 | typedef struct IgvmMemoryRegion { |
| 22 | QTAILQ_ENTRY(IgvmMemoryRegion) next; |
| 23 | MemoryRegion *mr; |
| 24 | } IgvmMemoryRegion; |
| 25 | |
| 26 | struct IgvmCfg { |
| 27 | Object parent_obj; |
| 28 | |
| 29 | /* |
| 30 | * filename: Filename that specifies a file that contains the configuration |
| 31 | * of the guest in Independent Guest Virtual Machine (IGVM) |
| 32 | * format. |
| 33 | */ |
| 34 | char *filename; |
| 35 | IgvmHandle file; |
| 36 | ResettableState reset_state; |
| 37 | QTAILQ_HEAD(, IgvmMemoryRegion) memory_regions; |
| 38 | }; |
| 39 | |
| 40 | typedef struct QIgvmParameterData { |
| 41 | QTAILQ_ENTRY(QIgvmParameterData) next; |
| 42 | uint8_t *data; |
| 43 | uint32_t size; |
| 44 | uint32_t index; |
| 45 | } QIgvmParameterData; |
| 46 | |
| 47 | /* |
| 48 | * QIgvm contains the information required during processing of a single IGVM |
| 49 | * file. |
| 50 | */ |
| 51 | struct QIgvm { |
| 52 | IgvmCfg *cfg; |
| 53 | MachineState *machine_state; |
| 54 | ConfidentialGuestSupportClass *cgsc; |
| 55 | uint32_t compatibility_mask; |
| 56 | unsigned current_header_index; |
| 57 | QTAILQ_HEAD(, QIgvmParameterData) parameter_data; |
| 58 | IgvmPlatformType platform_type; |
| 59 | |
| 60 | /* |
| 61 | * SEV-SNP platforms can contain an ID block and authentication |
| 62 | * that should be verified by the guest. |
| 63 | */ |
| 64 | struct sev_id_block *id_block; |
| 65 | struct sev_id_authentication *id_auth; |
| 66 | |
| 67 | /* Define the guest policy for SEV guests */ |
| 68 | uint64_t sev_policy; |
| 69 | |
| 70 | /* These variables keep track of contiguous page regions */ |
| 71 | IGVM_VHS_PAGE_DATA region_prev_page_data; |
| 72 | uint64_t region_start; |
| 73 | unsigned region_start_index; |
| 74 | unsigned region_last_index; |
| 75 | unsigned region_page_count; |
| 76 | }; |
| 77 | |
| 78 | IgvmHandle qigvm_file_init(char *filename, Error **errp); |
| 79 | |
| 80 | QIgvmParameterData* |
| 81 | qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index, |
| 82 | Error **errp); |
| 83 | |
| 84 | #endif |