Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp51232imu; Wed, 2 Jan 2019 13:55:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN4XH4LD7MivBO8VtunAbjQWXruIz8IfraGlDGXcRvr/iHHQblIZDOJCRqdoqLzztgtaOVxl X-Received: by 2002:a63:5320:: with SMTP id h32mr42934459pgb.414.1546466104288; Wed, 02 Jan 2019 13:55:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546466104; cv=none; d=google.com; s=arc-20160816; b=Ol7Xsitr3w8VgIB2F+aKIE5YgYh0d79YbTsbPgJgJeOmxJhekxnxgPpzWOMy1JrIg0 lodl4QHxx2bgBlTdCcT4b3YWuYXJrgoKqUI7I6mo3Bn1F5ejQvvA0I0pPu9zeMJgOTwP 7G6KxTDy4cDrXXStVH2fZyPeJN/skgTYXQmDC6urO13JDmjYTscEgKnvAW6kIPWkjt95 nQmFlYGMyLNhEghWxSyogxKilTY++uLSOlRh87sWN7p+dN1nzSl0bMyAOqg5JUj3R0OL +rMZRXqoO1NPk5RcpaCBEzELCiCbncJPmuEPBTrTlI09Iuf9O0n/B4V8B/UrTUh4BCF5 IX2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=cyyo8c3EjdBoIiqki4zsTyBy27w/WZFHasczEy+Zfvw=; b=jl+SPhG+otFAML/b0btYQ3Ae3V8g1sBHVg8tQQgMZSMmQZRz/OViV8azTGjTBiN8oD hIj2xIpkjU4nzx03+cbFsqOVT3UEkl7mYAFpQwQFrpCL4Ixc++LgQRdR2KQt0M2ZozUu FGLDwEuseCEdv9rFVVKdvcmf+ifB7Jf6hN4sWSx3pw97YWSrFwC2vasFhrLJmSny8Tg4 eYvKHvxB2PGvQw8/mf4q/P2McQOWsMLE8ojhWtfv6h6Jlp8YCu8cOiJmYjcZ1cn1JEcL 4Nugp0YYmgTXugZLnAilBLS6fBpEyVAf371+/6gczkV+ZO2F8jFyA7QARMWMKA42ExKm o5/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2si2541377pfy.29.2019.01.02.13.54.36; Wed, 02 Jan 2019 13:55:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728567AbfABSyz (ORCPT + 99 others); Wed, 2 Jan 2019 13:54:55 -0500 Received: from mga03.intel.com ([134.134.136.65]:51346 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728395AbfABSyz (ORCPT ); Wed, 2 Jan 2019 13:54:55 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jan 2019 10:54:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,432,1539673200"; d="scan'208";a="113674734" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.154]) by fmsmga008.fm.intel.com with ESMTP; 02 Jan 2019 10:54:53 -0800 Date: Wed, 2 Jan 2019 10:54:53 -0800 From: Sean Christopherson To: Yang Weijiang Cc: pbonzini@redhat.com, rkrcmar@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, mst@redhat.com, yu-cheng.yu@intel.com, yi.z.zhang@intel.com, hjl.tools@gmail.com, Zhang Yi Z Subject: Re: [PATCH v1 7/8] kvm:cpuid Fix xsaves area size calculation for CPUID.(EAX=0xD,ECX=1). Message-ID: <20190102185449.GE7460@linux.intel.com> References: <20181226081532.30698-1-weijiang.yang@intel.com> <20181226081532.30698-8-weijiang.yang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181226081532.30698-8-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 Wed, Dec 26, 2018 at 04:15:31PM +0800, Yang Weijiang wrote: > According to latest Software Development Manual vol.2/3.2, > for CPUID.(EAX=0xD,ECX=1), it should report xsaves area size > 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 5bac31e58955..55c282f71f93 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -121,7 +121,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 | > + best->ecx | ((u64)best->edx << 32), true); Passing the CPUID bits is wrong, it needs to be the guest's IA32_MSR_XSS. The CPUID bits enumerate what is legal to enable, not what features are actually enabled by software. > > /* > * The existing code assumes virtual address is 48-bit or 57-bit in the > -- > 2.17.1 >