mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-07 03:40:27 +00:00
hv: enable SMAP in hypervisor
With SMAP enabled, hypervisor can't access pages that owned by guest(either SOS or UOS), and an override is is provided: stac()/clac() to enable/disable access to guest's memory pages. Pre-conditon: Mark hypervisor owned pages as supervisor mode (U/S = 0), and set all othter memory pages as user mode (U/S = 1). Tracked-On: #2056 Signed-off-by: Yonghua Huang <yonghua.huang@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
@@ -531,6 +531,17 @@ write_xcr(int32_t reg, uint64_t val)
|
||||
high = (uint32_t)(val >> 32U);
|
||||
asm volatile("xsetbv" : : "c" (reg), "a" (low), "d" (high));
|
||||
}
|
||||
|
||||
static inline void stac(void)
|
||||
{
|
||||
asm volatile ("stac" : : : "memory");
|
||||
}
|
||||
|
||||
static inline void clac(void)
|
||||
{
|
||||
asm volatile ("clac" : : : "memory");
|
||||
}
|
||||
|
||||
#else /* ASSEMBLER defined */
|
||||
|
||||
#endif /* ASSEMBLER defined */
|
||||
|
@@ -106,6 +106,14 @@ void enable_paging(void);
|
||||
* @return None
|
||||
*/
|
||||
void enable_smep(void);
|
||||
|
||||
/**
|
||||
* @brief Supervisor-mode Access Prevention (SMAP) enable
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void enable_smap(void);
|
||||
|
||||
/**
|
||||
* @brief MMU page tables initialization
|
||||
*
|
||||
@@ -116,6 +124,8 @@ void mmu_add(uint64_t *pml4_page, uint64_t paddr_base, uint64_t vaddr_base,
|
||||
uint64_t size, uint64_t prot, const struct memory_ops *mem_ops);
|
||||
void mmu_modify_or_del(uint64_t *pml4_page, uint64_t vaddr_base, uint64_t size,
|
||||
uint64_t prot_set, uint64_t prot_clr, const struct memory_ops *mem_ops, uint32_t type);
|
||||
void hv_access_memory_region_update(uint64_t base, uint64_t size);
|
||||
|
||||
/**
|
||||
* @brief EPT and VPID capability checking
|
||||
*
|
||||
|
Reference in New Issue
Block a user