mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-24 06:29:19 +00:00
hv: xsave: move assembler to individual function
Current code avoid the rule 88 S in MISRA-C, so move xsaves and xrstors assembler to individual functions. Tracked-On: #4436 Signed-off-by: Conghui Chen <conghui.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
2f7483065b
commit
595cefe3f2
@ -729,22 +729,14 @@ void save_xsave_area(struct ext_context *ectx)
|
|||||||
{
|
{
|
||||||
ectx->xcr0 = read_xcr(0);
|
ectx->xcr0 = read_xcr(0);
|
||||||
ectx->xss = msr_read(MSR_IA32_XSS);
|
ectx->xss = msr_read(MSR_IA32_XSS);
|
||||||
asm volatile("xsaves %0"
|
xsaves(&ectx->xs_area, UINT64_MAX);
|
||||||
: : "m" (ectx->xs_area),
|
|
||||||
"d" (UINT32_MAX),
|
|
||||||
"a" (UINT32_MAX):
|
|
||||||
"memory");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rstore_xsave_area(const struct ext_context *ectx)
|
void rstore_xsave_area(const struct ext_context *ectx)
|
||||||
{
|
{
|
||||||
write_xcr(0, ectx->xcr0);
|
write_xcr(0, ectx->xcr0);
|
||||||
msr_write(MSR_IA32_XSS, ectx->xss);
|
msr_write(MSR_IA32_XSS, ectx->xss);
|
||||||
asm volatile("xrstors %0"
|
xrstors(&ectx->xs_area, UINT64_MAX);
|
||||||
: : "m" (ectx->xs_area),
|
|
||||||
"d" (UINT32_MAX),
|
|
||||||
"a" (UINT32_MAX):
|
|
||||||
"memory");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO:
|
/* TODO:
|
||||||
|
@ -635,6 +635,25 @@ static inline uint64_t read_xcr(int32_t reg)
|
|||||||
asm volatile ("xgetbv ": "=a"(xcrl), "=d"(xcrh) : "c" (reg));
|
asm volatile ("xgetbv ": "=a"(xcrl), "=d"(xcrh) : "c" (reg));
|
||||||
return (((uint64_t)xcrh << 32U) | xcrl);
|
return (((uint64_t)xcrh << 32U) | xcrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void xsaves(struct xsave_area *region_addr, uint64_t mask)
|
||||||
|
{
|
||||||
|
asm volatile("xsaves %0"
|
||||||
|
: : "m" (*(region_addr)),
|
||||||
|
"d" ((uint32_t)(mask >> 32U)),
|
||||||
|
"a" ((uint32_t)mask):
|
||||||
|
"memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void xrstors(const struct xsave_area *region_addr, uint64_t mask)
|
||||||
|
{
|
||||||
|
asm volatile("xrstors %0"
|
||||||
|
: : "m" (*(region_addr)),
|
||||||
|
"d" ((uint32_t)(mask >> 32U)),
|
||||||
|
"a" ((uint32_t)mask):
|
||||||
|
"memory");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* stac/clac pair is used to access guest's memory protected by SMAP,
|
* stac/clac pair is used to access guest's memory protected by SMAP,
|
||||||
* following below flow:
|
* following below flow:
|
||||||
|
Loading…
Reference in New Issue
Block a user