mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-14 21:52:18 -06:00
* SGX implementation for x86
* Miscellaneous bugfixes * Fix dependencies from ROMs to qtests -----BEGIN PGP SIGNATURE----- iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmFVu/sUHHBib256aW5p QHJlZGhhdC5jb20ACgkQv/vSX3jHroNFUgf+OexjKqJw4qzbDdQrxWqw3upoFblk y4OrmrhCyCKDwPghnjHUEVGHnNKqKpCLoIvtvFZ7xX/qezpMtZxVUliOVNQGmioR MZU/DbdlvVL/t8yKjfz1ljshk55hnSJ7rAv8LBA+B3uNzyJ+LZU9+Kbvmei5oyex nenCtXnoVNBJMvTBE/KfJbp0UasEb1OTvPBa0Y7mHyDub28FDPKr9WZbloCLUtE+ uXwbZ34VRDsxbLnXh+BJ+ljOQLdsJErAkiPKTnW1/3W8Ti7PzOzvLpbSIVdBv/9A U1qOEm48BjCrG/tFJvTUm0ZM7AHmqYfvmwpenDpL0FhReohMdUa3pycQ9g== =Hicy -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging * SGX implementation for x86 * Miscellaneous bugfixes * Fix dependencies from ROMs to qtests # gpg: Signature made Thu 30 Sep 2021 14:30:35 BST # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini-gitlab/tags/for-upstream: (33 commits) meson_options.txt: Switch the default value for the vnc option to 'auto' build-sys: add HAVE_IPPROTO_MPTCP memory: Add tracepoint for dirty sync memory: Name all the memory listeners target/i386: Fix memory leak in sev_read_file_base64() tests: qtest: bios-tables-test depends on the unpacked edk2 ROMs meson: unpack edk2 firmware even if --disable-blobs target/i386: Add the query-sgx-capabilities QMP command target/i386: Add HMP and QMP interfaces for SGX docs/system: Add SGX documentation to the system manual sgx-epc: Add the fill_device_info() callback support i440fx: Add support for SGX EPC q35: Add support for SGX EPC i386: acpi: Add SGX EPC entry to ACPI tables i386/pc: Add e820 entry for SGX EPC section(s) hw/i386/pc: Account for SGX EPC sections when calculating device memory hw/i386/fw_cfg: Set SGX bits in feature control fw_cfg accordingly Adjust min CPUID level to 0x12 when SGX is enabled i386: Propagate SGX CPUID sub-leafs to KVM i386: kvm: Add support for exposing PROVISIONKEY to guest ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
0021c4765a
64 changed files with 1397 additions and 38 deletions
|
@ -190,6 +190,9 @@ typedef struct IOMMUTLBEvent {
|
|||
*/
|
||||
#define RAM_NORESERVE (1 << 7)
|
||||
|
||||
/* RAM that isn't accessible through normal means. */
|
||||
#define RAM_PROTECTED (1 << 8)
|
||||
|
||||
static inline void iommu_notifier_init(IOMMUNotifier *n, IOMMUNotify fn,
|
||||
IOMMUNotifierFlag flags,
|
||||
hwaddr start, hwaddr end,
|
||||
|
@ -979,6 +982,14 @@ struct MemoryListener {
|
|||
*/
|
||||
unsigned priority;
|
||||
|
||||
/**
|
||||
* @name:
|
||||
*
|
||||
* Name of the listener. It can be used in contexts where we'd like to
|
||||
* identify one memory listener with the rest.
|
||||
*/
|
||||
const char *name;
|
||||
|
||||
/* private: */
|
||||
AddressSpace *address_space;
|
||||
QTAILQ_ENTRY(MemoryListener) link;
|
||||
|
@ -1267,7 +1278,7 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
|
|||
* @name: the name of the region.
|
||||
* @size: size of the region.
|
||||
* @ram_flags: RamBlock flags. Supported flags: RAM_SHARED, RAM_PMEM,
|
||||
* RAM_NORESERVE.
|
||||
* RAM_NORESERVE, RAM_PROTECTED.
|
||||
* @fd: the fd to mmap.
|
||||
* @offset: offset within the file referenced by fd
|
||||
* @errp: pointer to Error*, to store an error if it happens.
|
||||
|
@ -1568,6 +1579,16 @@ static inline bool memory_region_is_romd(MemoryRegion *mr)
|
|||
return mr->rom_device && mr->romd_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* memory_region_is_protected: check whether a memory region is protected
|
||||
*
|
||||
* Returns %true if a memory region is protected RAM and cannot be accessed
|
||||
* via standard mechanisms, e.g. DMA.
|
||||
*
|
||||
* @mr: the memory region being queried
|
||||
*/
|
||||
bool memory_region_is_protected(MemoryRegion *mr);
|
||||
|
||||
/**
|
||||
* memory_region_get_iommu: check whether a memory region is an iommu
|
||||
*
|
||||
|
|
28
include/hw/i386/hostmem-epc.h
Normal file
28
include/hw/i386/hostmem-epc.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* SGX EPC backend
|
||||
*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* Authors:
|
||||
* Sean Christopherson <sean.j.christopherson@intel.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
#ifndef QEMU_HOSTMEM_EPC_H
|
||||
#define QEMU_HOSTMEM_EPC_H
|
||||
|
||||
#include "sysemu/hostmem.h"
|
||||
|
||||
#define TYPE_MEMORY_BACKEND_EPC "memory-backend-epc"
|
||||
|
||||
#define MEMORY_BACKEND_EPC(obj) \
|
||||
OBJECT_CHECK(HostMemoryBackendEpc, (obj), TYPE_MEMORY_BACKEND_EPC)
|
||||
|
||||
typedef struct HostMemoryBackendEpc HostMemoryBackendEpc;
|
||||
|
||||
struct HostMemoryBackendEpc {
|
||||
HostMemoryBackend parent_obj;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -12,6 +12,7 @@
|
|||
#include "hw/acpi/acpi_dev_interface.h"
|
||||
#include "hw/hotplug.h"
|
||||
#include "qom/object.h"
|
||||
#include "hw/i386/sgx-epc.h"
|
||||
|
||||
#define HPET_INTCAP "hpet-intcap"
|
||||
|
||||
|
@ -49,6 +50,8 @@ typedef struct PCMachineState {
|
|||
|
||||
/* ACPI Memory hotplug IO base address */
|
||||
hwaddr memhp_io_base;
|
||||
|
||||
SGXEPCState sgx_epc;
|
||||
} PCMachineState;
|
||||
|
||||
#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
|
||||
|
@ -192,6 +195,9 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size);
|
|||
void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
|
||||
const CPUArchIdList *apic_ids, GArray *entry);
|
||||
|
||||
/* sgx.c */
|
||||
void pc_machine_init_sgx_epc(PCMachineState *pcms);
|
||||
|
||||
extern GlobalProperty pc_compat_6_1[];
|
||||
extern const size_t pc_compat_6_1_len;
|
||||
|
||||
|
|
67
include/hw/i386/sgx-epc.h
Normal file
67
include/hw/i386/sgx-epc.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* SGX EPC device
|
||||
*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* Authors:
|
||||
* Sean Christopherson <sean.j.christopherson@intel.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
#ifndef QEMU_SGX_EPC_H
|
||||
#define QEMU_SGX_EPC_H
|
||||
|
||||
#include "hw/i386/hostmem-epc.h"
|
||||
|
||||
#define TYPE_SGX_EPC "sgx-epc"
|
||||
#define SGX_EPC(obj) \
|
||||
OBJECT_CHECK(SGXEPCDevice, (obj), TYPE_SGX_EPC)
|
||||
#define SGX_EPC_CLASS(oc) \
|
||||
OBJECT_CLASS_CHECK(SGXEPCDeviceClass, (oc), TYPE_SGX_EPC)
|
||||
#define SGX_EPC_GET_CLASS(obj) \
|
||||
OBJECT_GET_CLASS(SGXEPCDeviceClass, (obj), TYPE_SGX_EPC)
|
||||
|
||||
#define SGX_EPC_ADDR_PROP "addr"
|
||||
#define SGX_EPC_SIZE_PROP "size"
|
||||
#define SGX_EPC_MEMDEV_PROP "memdev"
|
||||
|
||||
/**
|
||||
* SGXEPCDevice:
|
||||
* @addr: starting guest physical address, where @SGXEPCDevice is mapped.
|
||||
* Default value: 0, means that address is auto-allocated.
|
||||
* @hostmem: host memory backend providing memory for @SGXEPCDevice
|
||||
*/
|
||||
typedef struct SGXEPCDevice {
|
||||
/* private */
|
||||
DeviceState parent_obj;
|
||||
|
||||
/* public */
|
||||
uint64_t addr;
|
||||
HostMemoryBackendEpc *hostmem;
|
||||
} SGXEPCDevice;
|
||||
|
||||
/*
|
||||
* @base: address in guest physical address space where EPC regions start
|
||||
* @mr: address space container for memory devices
|
||||
*/
|
||||
typedef struct SGXEPCState {
|
||||
uint64_t base;
|
||||
uint64_t size;
|
||||
|
||||
MemoryRegion mr;
|
||||
|
||||
struct SGXEPCDevice **sections;
|
||||
int nr_sections;
|
||||
} SGXEPCState;
|
||||
|
||||
int sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size);
|
||||
|
||||
static inline uint64_t sgx_epc_above_4g_end(SGXEPCState *sgx_epc)
|
||||
{
|
||||
assert(sgx_epc != NULL && sgx_epc->base >= 0x100000000ULL);
|
||||
|
||||
return sgx_epc->base + sgx_epc->size;
|
||||
}
|
||||
|
||||
#endif
|
12
include/hw/i386/sgx.h
Normal file
12
include/hw/i386/sgx.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef QEMU_SGX_H
|
||||
#define QEMU_SGX_H
|
||||
|
||||
#include "qom/object.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qapi/qapi-types-misc-target.h"
|
||||
|
||||
SGXInfo *sgx_get_info(Error **errp);
|
||||
SGXInfo *sgx_get_capabilities(Error **errp);
|
||||
|
||||
#endif
|
|
@ -62,6 +62,7 @@ struct X86MachineState {
|
|||
unsigned pci_irq_mask;
|
||||
unsigned apic_id_limit;
|
||||
uint16_t boot_cpus;
|
||||
SgxEPCList *sgx_epc_list;
|
||||
|
||||
OnOffAuto smm;
|
||||
OnOffAuto acpi;
|
||||
|
|
|
@ -49,5 +49,6 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict);
|
|||
void hmp_mce(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_local_apic(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_io_apic(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_sgx(Monitor *mon, const QDict *qdict);
|
||||
|
||||
#endif /* MONITOR_HMP_TARGET_H */
|
||||
|
|
|
@ -37,7 +37,7 @@ typedef struct KVMMemoryListener {
|
|||
} KVMMemoryListener;
|
||||
|
||||
void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml,
|
||||
AddressSpace *as, int as_id);
|
||||
AddressSpace *as, int as_id, const char *name);
|
||||
|
||||
void kvm_set_max_memslot_size(hwaddr max_slot_size);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue