From 7018a13cb631edde9844113b45f3d057ce331ee0 Mon Sep 17 00:00:00 2001 From: Yuan Liu Date: Fri, 14 Jun 2019 14:26:03 +0800 Subject: [PATCH] HV: Add ept_flush_leaf_page API The ept_flush_leaf_page API is used to flush address space from a ept page entry, user can use it to match walk_ept_mr to flush VM address space. Signed-off-by: Jack Ren Signed-off-by: Yuan Liu Reviewed-by: Li, Fei1 Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/ept.c | 17 +++++++++++++++++ hypervisor/include/arch/x86/guest/ept.h | 11 +++++++++++ 2 files changed, 28 insertions(+) diff --git a/hypervisor/arch/x86/guest/ept.c b/hypervisor/arch/x86/guest/ept.c index 77e8784da..0000cc07d 100644 --- a/hypervisor/arch/x86/guest/ept.c +++ b/hypervisor/arch/x86/guest/ept.c @@ -156,6 +156,23 @@ void ept_del_mr(struct acrn_vm *vm, uint64_t *pml4_page, uint64_t gpa, uint64_t } } +/** + * @pre pge != NULL && size > 0. + */ +void ept_flush_leaf_page(uint64_t *pge, uint64_t size) +{ + uint64_t hpa = INVALID_HPA; + void *hva = NULL; + + if ((*pge & EPT_MT_MASK) != EPT_UNCACHED) { + hpa = (*pge & (~(size - 1UL))); + hva = hpa2hva(hpa); + stac(); + flush_address_space(hva, size); + clac(); + } +} + /** * @pre: vm != NULL. */ diff --git a/hypervisor/include/arch/x86/guest/ept.h b/hypervisor/include/arch/x86/guest/ept.h index 3e2d920da..cb16cde90 100644 --- a/hypervisor/include/arch/x86/guest/ept.h +++ b/hypervisor/include/arch/x86/guest/ept.h @@ -106,6 +106,17 @@ void ept_modify_mr(struct acrn_vm *vm, uint64_t *pml4_page, uint64_t gpa, void ept_del_mr(struct acrn_vm *vm, uint64_t *pml4_page, uint64_t gpa, uint64_t size); +/** + * @brief Flush address space from the page entry + * + * @param[in] pge the pointer that points to the page entry + * + * @param[in] size the size of the page + * + * @return None + */ +void ept_flush_leaf_page(uint64_t *pge, uint64_t size); + /** * @brief Get EPT pointer of the vm *