|
@@ -23,6 +23,7 @@
|
|
#include "sysemu/hw_accel.h"
|
|
#include "sysemu/hw_accel.h"
|
|
#include "sysemu/reset.h"
|
|
#include "sysemu/reset.h"
|
|
#include <sys/ioctl.h>
|
|
#include <sys/ioctl.h>
|
|
|
|
+#include "hw/acpi/aml-build.h"
|
|
|
|
|
|
#define SGX_MAX_EPC_SECTIONS 8
|
|
#define SGX_MAX_EPC_SECTIONS 8
|
|
#define SGX_CPUID_EPC_INVALID 0x0
|
|
#define SGX_CPUID_EPC_INVALID 0x0
|
|
@@ -36,6 +37,46 @@
|
|
|
|
|
|
#define RETRY_NUM 2
|
|
#define RETRY_NUM 2
|
|
|
|
|
|
|
|
+static int sgx_epc_device_list(Object *obj, void *opaque)
|
|
|
|
+{
|
|
|
|
+ GSList **list = opaque;
|
|
|
|
+
|
|
|
|
+ if (object_dynamic_cast(obj, TYPE_SGX_EPC)) {
|
|
|
|
+ *list = g_slist_append(*list, DEVICE(obj));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ object_child_foreach(obj, sgx_epc_device_list, opaque);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static GSList *sgx_epc_get_device_list(void)
|
|
|
|
+{
|
|
|
|
+ GSList *list = NULL;
|
|
|
|
+
|
|
|
|
+ object_child_foreach(qdev_get_machine(), sgx_epc_device_list, &list);
|
|
|
|
+ return list;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void sgx_epc_build_srat(GArray *table_data)
|
|
|
|
+{
|
|
|
|
+ GSList *device_list = sgx_epc_get_device_list();
|
|
|
|
+
|
|
|
|
+ for (; device_list; device_list = device_list->next) {
|
|
|
|
+ DeviceState *dev = device_list->data;
|
|
|
|
+ Object *obj = OBJECT(dev);
|
|
|
|
+ uint64_t addr, size;
|
|
|
|
+ int node;
|
|
|
|
+
|
|
|
|
+ node = object_property_get_uint(obj, SGX_EPC_NUMA_NODE_PROP,
|
|
|
|
+ &error_abort);
|
|
|
|
+ addr = object_property_get_uint(obj, SGX_EPC_ADDR_PROP, &error_abort);
|
|
|
|
+ size = object_property_get_uint(obj, SGX_EPC_SIZE_PROP, &error_abort);
|
|
|
|
+
|
|
|
|
+ build_srat_memory(table_data, addr, size, node, MEM_AFFINITY_ENABLED);
|
|
|
|
+ }
|
|
|
|
+ g_slist_free(device_list);
|
|
|
|
+}
|
|
|
|
+
|
|
static uint64_t sgx_calc_section_metric(uint64_t low, uint64_t high)
|
|
static uint64_t sgx_calc_section_metric(uint64_t low, uint64_t high)
|
|
{
|
|
{
|
|
return (low & MAKE_64BIT_MASK(12, 20)) +
|
|
return (low & MAKE_64BIT_MASK(12, 20)) +
|
|
@@ -226,6 +267,9 @@ void pc_machine_init_sgx_epc(PCMachineState *pcms)
|
|
/* set the memdev link with memory backend */
|
|
/* set the memdev link with memory backend */
|
|
object_property_parse(obj, SGX_EPC_MEMDEV_PROP, list->value->memdev,
|
|
object_property_parse(obj, SGX_EPC_MEMDEV_PROP, list->value->memdev,
|
|
&error_fatal);
|
|
&error_fatal);
|
|
|
|
+ /* set the numa node property for sgx epc object */
|
|
|
|
+ object_property_set_uint(obj, SGX_EPC_NUMA_NODE_PROP, list->value->node,
|
|
|
|
+ &error_fatal);
|
|
object_property_set_bool(obj, "realized", true, &error_fatal);
|
|
object_property_set_bool(obj, "realized", true, &error_fatal);
|
|
object_unref(obj);
|
|
object_unref(obj);
|
|
}
|
|
}
|