On 2022/10/11 07:10, Dave Hansen wrote: > On 9/19/22 23:39, Zhiquan Li wrote: >> --- a/arch/x86/kernel/cpu/sgx/virt.c >> +++ b/arch/x86/kernel/cpu/sgx/virt.c >> @@ -46,10 +46,12 @@ static int __sgx_vepc_fault(struct sgx_vepc *vepc, >> if (epc_page) >> return 0; >> >> - epc_page = sgx_alloc_epc_page(vepc, false); >> + epc_page = sgx_alloc_epc_page((void *)addr, false); >> if (IS_ERR(epc_page)) >> return PTR_ERR(epc_page); > > One thing not clear from the changelog: This actually changes the value > getting passed into sgx_alloc_epc_page() and set in the page->owner field. > > What effect does this have? If I apply these and run the tree at this > commit, what happens? What behavior changes? > > Was this 'vepc' value simply not used before? Yes, it was not used before. Kai had confirmed this point: https://lore.kernel.org/all/fa93057f417b1f630d8199381589c415a0ec710b.camel@xxxxxxxxx/ The initial idea is to add a new struct sgx_vepc_page to hold 'vaddr' and the reversed relationship from EPC page to struct sgx_vepc: struct sgx_vepc_page { unsigned long vaddr; struct sgx_vepc *vepc; }; But which means there will be additional 16 bytes memory consumption on host for each EPC page assigned into guest. Jarkko suggested us repurpose the 'owner' field: https://lore.kernel.org/linux-sgx/Yoa90l89OTQX0NYk@xxxxxx/ 1. It can save memory. 2. We don't have any scenario need the reversed relationship from EPC page to struct sgx_vepc, keeping the relationship from VEPC to EPC pages is enough. May I add below description to explain behavior changes in changelog? The behavior is changed when allocating an EPC page to a virtual EPC, the virtual address of the virtual EPC will be passed as the first argument of sgx_alloc_epc_page() which be assigned to 'encl_owner' field of struct sgx_epc_page. After that, the reversed relationship from an EPC page to virtual EPC doesn't exist, in practice, such relationship is useless. Thanks & Best Regards, Zhiquan