From 5621fabbcbb15107067cad54afae41e9d91137f5 Mon Sep 17 00:00:00 2001 From: Li Fei1 Date: Fri, 19 Feb 2021 09:25:59 +0800 Subject: [PATCH] hv: memory: remove get_sworld_memory_base API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit memory_ops structure will be changed to store page table related fields. However, secure world memory base address is not one of them, it's VM related. So save sworld_memory_base_hva in vm_arch structure directly. Signed-off-by: Li Fei1 Acked-by: Eddie Dong Tracked-On: #5788 --- hypervisor/arch/x86/guest/vm.c | 4 +--- hypervisor/arch/x86/page.c | 8 +------- hypervisor/include/arch/x86/guest/vm.h | 1 + hypervisor/include/arch/x86/page.h | 2 -- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index 5024cb06f..635c960bf 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -515,10 +515,8 @@ int32_t create_vm(uint16_t vm_id, uint64_t pcpu_bitmap, struct acrn_vm_config *v vm->sworld_control.flag.supported = 1U; } if (vm->sworld_control.flag.supported != 0UL) { - struct memory_ops *ept_mem_ops = &vm->arch_vm.ept_mem_ops; - ept_add_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp, - hva2hpa(ept_mem_ops->get_sworld_memory_base(ept_mem_ops->info)), + hva2hpa(vm->arch_vm.sworld_memory_base_hva), TRUSTY_EPT_REBASE_GPA, TRUSTY_RAM_SIZE, EPT_WB | EPT_RWX); } if (vm_config->name[0] == '\0') { diff --git a/hypervisor/arch/x86/page.c b/hypervisor/arch/x86/page.c index b94428a68..446605414 100644 --- a/hypervisor/arch/x86/page.c +++ b/hypervisor/arch/x86/page.c @@ -215,11 +215,6 @@ static inline struct page *ept_get_pt_page(const union pgtable_pages_info *info, return pt_page; } -static inline void *ept_get_sworld_memory_base(const union pgtable_pages_info *info) -{ - return info->ept.sworld_memory_base; -} - /* The function is used to disable execute right for (2MB / 1GB)large pages in EPT */ static inline void ept_tweak_exe_right(uint64_t *entry) { @@ -266,8 +261,7 @@ void init_ept_mem_ops(struct memory_ops *mem_ops, uint16_t vm_id) ept_pages_info[vm_id].ept.nworld_pt_base = post_uos_nworld_pt_pages[page_idx]; #endif ept_pages_info[vm_id].ept.sworld_pgtable_base = post_uos_sworld_pgtable_pages[page_idx]; - ept_pages_info[vm_id].ept.sworld_memory_base = post_uos_sworld_memory[page_idx]; - mem_ops->get_sworld_memory_base = ept_get_sworld_memory_base; + vm->arch_vm.sworld_memory_base_hva = post_uos_sworld_memory[page_idx]; } mem_ops->info = &ept_pages_info[vm_id]; mem_ops->get_default_access_right = ept_get_default_access_right; diff --git a/hypervisor/include/arch/x86/guest/vm.h b/hypervisor/include/arch/x86/guest/vm.h index bd677ffcd..9c25d4b29 100644 --- a/hypervisor/include/arch/x86/guest/vm.h +++ b/hypervisor/include/arch/x86/guest/vm.h @@ -107,6 +107,7 @@ struct vm_arch { * but Normal World can not access Secure World's memory. */ void *sworld_eptp; + void *sworld_memory_base_hva; struct memory_ops ept_mem_ops; struct acrn_vioapics vioapics; /* Virtual IOAPIC/s */ diff --git a/hypervisor/include/arch/x86/page.h b/hypervisor/include/arch/x86/page.h index 26dba2e55..d9e9e43e6 100644 --- a/hypervisor/include/arch/x86/page.h +++ b/hypervisor/include/arch/x86/page.h @@ -93,7 +93,6 @@ union pgtable_pages_info { struct page *nworld_pd_base; struct page *nworld_pt_base; struct page *sworld_pgtable_base; - struct page *sworld_memory_base; } ept; }; @@ -106,7 +105,6 @@ struct memory_ops { struct page *(*get_pdpt_page)(const union pgtable_pages_info *info, uint64_t gpa); struct page *(*get_pd_page)(const union pgtable_pages_info *info, uint64_t gpa); struct page *(*get_pt_page)(const union pgtable_pages_info *info, uint64_t gpa); - void *(*get_sworld_memory_base)(const union pgtable_pages_info *info); void (*clflush_pagewalk)(const void *p); void (*tweak_exe_right)(uint64_t *entry); void (*recover_exe_right)(uint64_t *entry);