From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EFEDC4360F for ; Tue, 2 Apr 2019 20:27:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE15020674 for ; Tue, 2 Apr 2019 20:27:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726315AbfDBU1B (ORCPT ); Tue, 2 Apr 2019 16:27:01 -0400 Received: from mga05.intel.com ([192.55.52.43]:58878 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfDBU1B (ORCPT ); Tue, 2 Apr 2019 16:27:01 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Apr 2019 13:27:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,302,1549958400"; d="scan'208";a="157628449" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.181]) by fmsmga002.fm.intel.com with ESMTP; 02 Apr 2019 13:27:00 -0700 Date: Tue, 2 Apr 2019 13:27:00 -0700 From: Sean Christopherson To: Yang Weijiang Cc: pbonzini@redhat.com, kvm@vger.kernel.org, mst@redhat.com, rkrcmar@redhat.com, jmattson@google.com, linux-kernel@vger.kernel.org, yu-cheng.yu@intel.com, Zhang Yi Z Subject: Re: [RFC PATCH v4 3/8] KVM:CPUID: Fix xsaves area size calculation for CPUID.(EAX=0xD,ECX=1). Message-ID: <20190402202700.GH31303@linux.intel.com> References: <20190318150351.15550-1-weijiang.yang@intel.com> <20190318150351.15550-4-weijiang.yang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190318150351.15550-4-weijiang.yang@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 18, 2019 at 11:03:46PM +0800, Yang Weijiang wrote: > According to latest Software Development Manual vol.2/3.2, Most readers of this code are already familiar with the SDM acronym, and if they're not, "Intel SDM" provides great search results. No need to define it here. Avoid referencing specific sections, they tend to change. > for CPUID.(EAX=0xD,ECX=1), it should report xsaves area size When quoting the SDM, it's usually best to avoid "should" and simply state what the SDM says. In other words, the SDM doesn't hedge on what the processor should (not) do, it documents the exact behavior. E.g.: According to the SDM, Vol 2, CPUID(EAX=0xD,ECX=1) reports the XSAVE are size containing all states enabled by XCR0|IA32_MSR_XSS. > containing all states enabled by XCR0|IA32_MSR_XSS. > > Signed-off-by: Zhang Yi Z > Signed-off-by: Yang Weijiang > --- > arch/x86/kvm/cpuid.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c > index 53abd6019c68..29d6a5cdc746 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -126,7 +126,8 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu) > > best = kvm_find_cpuid_entry(vcpu, 0xD, 1); > if (best && (best->eax & (F(XSAVES) | F(XSAVEC)))) > - best->ebx = xstate_required_size(vcpu->arch.xcr0, true); > + best->ebx = xstate_required_size(vcpu->arch.xcr0 | > + kvm_supported_xss(), true); > > /* > * The existing code assumes virtual address is 48-bit or 57-bit in the > -- > 2.17.1 >