mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 05:57:33 +00:00
hv: xsave: bugfix for init value
The init value for XCR0 and XSS should be the same with spec: In SDM Vol1 13.3: XCR0[0] is associated with x87 state (see Section 13.5.1). XCR0[0] is always 1. The other bits in XCR0 are all 0 coming out of RESET. The IA32_XSS MSR (with MSR index DA0H) is zero coming out of RESET. The previous code try to fix the xsave area leak to other VMs during init phase, but bring the error to linux. Besides, it cannot avoid the possible leak in running phase. Need find a better solution. Tracked-On: #4430 Signed-off-by: Conghui Chen <conghui.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
96f92373cd
commit
c246d1c9b8
@ -262,24 +262,18 @@ static void set_vcpu_mode(struct acrn_vcpu *vcpu, uint32_t cs_attr, uint64_t ia3
|
||||
|
||||
static void init_xsave(struct acrn_vcpu *vcpu)
|
||||
{
|
||||
struct cpuinfo_x86 *cpu_info = get_pcpu_info();
|
||||
struct ext_context *ectx = &(vcpu->arch.contexts[vcpu->arch.cur_context].ext_ctx);
|
||||
struct xsave_area *area = &ectx->xs_area;
|
||||
|
||||
/* Get user state components */
|
||||
ectx->xcr0 = ((uint64_t)cpu_info->cpuid_leaves[FEAT_D_0_EDX] << 32U)
|
||||
+ cpu_info->cpuid_leaves[FEAT_D_0_EAX];
|
||||
|
||||
/* Get supervisor state components */
|
||||
ectx->xss = ((uint64_t)cpu_info->cpuid_leaves[FEAT_D_1_EDX] << 32U)
|
||||
+ cpu_info->cpuid_leaves[FEAT_D_1_ECX];
|
||||
ectx->xcr0 = XSAVE_FPU;
|
||||
ectx->xss = 0U;
|
||||
(void)memset((void *)area, 0U, XSAVE_STATE_AREA_SIZE);
|
||||
|
||||
/* xsaves only support compacted format, so set it in xcomp_bv[63],
|
||||
* keep the reset area in header area as zero.
|
||||
* With this config, the first time a vcpu is scheduled in, it will
|
||||
* initiate all the xsave componets */
|
||||
* keep the reset area in header area as zero. */
|
||||
ectx->xs_area.xsave_hdr.hdr.xcomp_bv |= XSAVE_COMPACTED_FORMAT;
|
||||
|
||||
}
|
||||
|
||||
void set_vcpu_regs(struct acrn_vcpu *vcpu, struct acrn_vcpu_regs *vcpu_regs)
|
||||
{
|
||||
struct ext_context *ectx;
|
||||
|
@ -157,6 +157,8 @@
|
||||
XSAVE_LEGACY_AREA_SIZE)
|
||||
#define XSAVE_COMPACTED_FORMAT (1UL << 63U)
|
||||
|
||||
#define XSAVE_FPU (1UL << 0U)
|
||||
|
||||
#define CPU_CONTEXT_OFFSET_RAX 0U
|
||||
#define CPU_CONTEXT_OFFSET_RCX 8U
|
||||
#define CPU_CONTEXT_OFFSET_RDX 16U
|
||||
|
Loading…
Reference in New Issue
Block a user