mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-07 11:50:30 +00:00
hv:remove accessing shared log buffer cases between stac/clac
Shared buffer is allocated by VM and is protected by SMAP. Accessing to shared buffer between stac/clac pair will invalidate SMAP protection.This patch is to remove these cases. Fix minor stac/clac mis-usage,and add comments as stac/clac usage BKM Tracked-On: #2526 Signed-off-by: Yonghua Huang <yonghua.huang@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -464,6 +464,21 @@ static inline void write_xcr(int32_t reg, uint64_t val)
|
||||
asm volatile("xsetbv" : : "c" (reg), "a" ((uint32_t)val), "d" ((uint32_t)(val >> 32U)));
|
||||
}
|
||||
|
||||
/*
|
||||
* stac/clac pair is used to access guest's memory protected by SMAP,
|
||||
* following below flow:
|
||||
*
|
||||
* stac();
|
||||
* #access guest's memory.
|
||||
* clac();
|
||||
*
|
||||
* Notes:Avoid inserting another stac/clac pair between stac and clac,
|
||||
* As once clac after multiple stac will invalidate SMAP protection
|
||||
* and hence Page Fault crash.
|
||||
* Logging message to memory buffer will induce this case,
|
||||
* please disable SMAP temporlly or don't log messages to shared
|
||||
* memory buffer, if it is evitable for you for debug purpose.
|
||||
*/
|
||||
static inline void stac(void)
|
||||
{
|
||||
asm volatile ("stac" : : : "memory");
|
||||
|
Reference in New Issue
Block a user