hv: ept: flush cache for modified ept entries

EPT tables are shared by MMU and IOMMU.
Some IOMMUs don't support page-walk coherency, the cpu cache of EPT entires
should be flushed to memory after modifications, so that the modifications
are visible to the IOMMUs.

This patch adds a new interface to flush the cache of modified EPT entires.
There are different implementations for EPT/PPT entries:
- For PPT, there is no need to flush the cpu cache after update.
- For EPT, need to call iommu_flush_cache to make the modifications visible
to IOMMUs.

Tracked-On: #3607
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Binbin Wu
2019-07-01 13:39:20 +08:00
committed by ACRN System Integration
parent 2abd8b34ef
commit 5c81659713
7 changed files with 43 additions and 30 deletions

View File

@@ -71,6 +71,7 @@ struct memory_ops {
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);
};
extern const struct memory_ops ppt_mem_ops;

View File

@@ -257,9 +257,10 @@ static inline uint64_t get_pgentry(const uint64_t *pte)
/*
* pgentry may means pml4e/pdpte/pde/pte
*/
static inline void set_pgentry(uint64_t *ptep, uint64_t pte)
static inline void set_pgentry(uint64_t *ptep, uint64_t pte, const struct memory_ops *mem_ops)
{
*ptep = pte;
mem_ops->clflush_pagewalk(ptep);
}
static inline uint64_t pde_large(uint64_t pde)