On 19/07/21 13:21, Yang Zhong wrote:
+static void sgx_epc_del_subregion(DeviceState *dev) +{ + PCMachineState *pcms = PC_MACHINE(qdev_get_machine()); + SGXEPCState *sgx_epc = &pcms->sgx_epc; + SGXEPCDevice *epc = SGX_EPC(dev); + + /* del subregion and related operations */ + memory_region_del_subregion(&sgx_epc->mr, + host_memory_backend_get_memory(epc->hostmem)); + host_memory_backend_set_mapped(epc->hostmem, false); + g_free(sgx_epc->sections); + sgx_epc->sections = NULL; + + /* multiple epc devices, only zero the first time */ + if (epc_num == sgx_epc->nr_sections) { + sgx_epc->size = 0; + sgx_epc->nr_sections = 0; + } +}
Can it just invoke a method on the memory devices, without reusing the code in sgx_epc_realize? In particular why is it necessary to update sgx_epc->size and sgx_epc->nr_sections?
Paolo