lkml.org 
[lkml]   [2017]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/2] KVM: X86: XCR0 should be set to the fixed value on vCPU reset
From
Date
On 08/10/2017 04:35, Wanpeng Li wrote:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
>
> SDM section 2.6 mentioned:
>
> After reset, all bits (except bit 0) in XCR0 are cleared to zero; XCR0[0] is set to 1.
>
> This patch sets XCRO to the 0x1 after vCPU reset.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
> arch/x86/kvm/x86.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index b0d2915..c784cd6 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -7816,6 +7816,8 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
> vcpu->arch.regs_avail = ~0;
> vcpu->arch.regs_dirty = ~0;
>
> + vcpu->arch.xcr0 = XFEATURE_MASK_FP;

XCR0 is unchanged by INIT. There are many other registers that are
zeroed by RESET by not INIT; KVM pretty much relies on userspace doing
that. On the other hand, it's useful to zero here those registers that
are zeroed by INIT as well:

- XSS

- BNDCFGU, BND0-BND3, BNDCFGS (BNDCFGS probably would go in
vmx_vcpu_reset, the others are in vcpu->arch.guest_fpu.state.xsave).

> kvm_x86_ops->vcpu_reset(vcpu, init_event);
> }
>
>

\
 
 \ /
  Last update: 2017-10-09 10:05    [W:0.201 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site