From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754037AbdJIIFC (ORCPT ); Mon, 9 Oct 2017 04:05:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34638 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753990AbdJIIE7 (ORCPT ); Mon, 9 Oct 2017 04:04:59 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DD57652748 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [PATCH 2/2] KVM: X86: XCR0 should be set to the fixed value on vCPU reset To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Wanpeng Li References: <1507430107-4338-1-git-send-email-wanpeng.li@hotmail.com> <1507430107-4338-2-git-send-email-wanpeng.li@hotmail.com> From: Paolo Bonzini Message-ID: <0298366f-5dcb-4bfd-2587-f6a033512120@redhat.com> Date: Mon, 9 Oct 2017 10:04:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1507430107-4338-2-git-send-email-wanpeng.li@hotmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 09 Oct 2017 08:04:59 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/10/2017 04:35, Wanpeng Li wrote: > From: Wanpeng Li > > 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 > Cc: Radim Krčmář > Signed-off-by: Wanpeng Li > --- > 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); > } > >