Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5321926imu; Wed, 26 Dec 2018 00:14:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN4mp8FiBWE0ztAWxZNUzuKnbhtovjMAHG0d5qLcLrxhK8rKHoJqLq+UmcPfK06vCy0GD7RD X-Received: by 2002:a17:902:2f03:: with SMTP id s3mr18556974plb.277.1545812065197; Wed, 26 Dec 2018 00:14:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545812065; cv=none; d=google.com; s=arc-20160816; b=d7PGpyNZzLKtxFahI5Xjoq5z8rB0f4z4IXGYib2XYWncRh9dqLuYLI2MlzU2PgRWpe 4wDPsfmSlGOGOIHDbVYe8W8GQ/U1v+2TXvQA8btMlaKnbD8+LfIhubblAaqYK6jt0mYO UUdnm/bPEuklLaGZxMTTJnTXr4xn+KMWhwZ8d6d3fLuBDLhVfHPS/uAZC4IcHCh+nQeQ YAisKo29FEKDR/qM/h3+rG5xwXS13LBCo2RlVQJZ59FdjRzHopjOZSPnG451VWmaLj+f npjaxZ0Rx4bxiuka2fYdnbPuNWBJmFTxttNn3fP0vndggduScGGTBJcpMNkSBhzPT1hU BLhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=bLlK8uOXMQgwY+gPbRqLE4oglOaxbYjxUgm/48Cunb0=; b=f9s8OcgjkRjc/LVwBDVL+mWnapFeO0gC0ygIKhhTcnJk+sT3VGyOnt1tCToH6n9D4F r3PVk1FZIymNJDf5kxoTnKSeYIrmnJvxZeu2155kPTmJEChR+SJPtArHVhosA8ydg7CE wVJEAparlJMABgCZBn+l2FtFeEnWSxkraS8ySZMuHf3oMQBtDSEQPuzcWFO2WVWAj+6R Zt0LPDWWmLYLCGkA0vcNdkGDaAuXydGP76j/Wqfxx3FkziOSC/B4tA9tE3PNi3bd7GEQ Wv6oJHfb/F8ktyO2xLjxga3FgTtoH0lQ+Jbyar9M63MjYbEtvmovU9dPF/3b0aDyjH9l czxQ== 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 d10si11559619pgf.136.2018.12.26.00.14.04; Wed, 26 Dec 2018 00:14:25 -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 S1726640AbeLZIMw (ORCPT + 99 others); Wed, 26 Dec 2018 03:12:52 -0500 Received: from mga11.intel.com ([192.55.52.93]:64132 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726595AbeLZIMv (ORCPT ); Wed, 26 Dec 2018 03:12:51 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Dec 2018 00:12:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,400,1539673200"; d="scan'208";a="104759727" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.239.13.104]) by orsmga008.jf.intel.com with ESMTP; 26 Dec 2018 00:12:49 -0800 From: Yang Weijiang To: 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 Cc: Yang Weijiang , Zhang Yi Z Subject: [PATCH v1 7/8] kvm:cpuid Fix xsaves area size calculation for CPUID.(EAX=0xD,ECX=1). Date: Wed, 26 Dec 2018 16:15:31 +0800 Message-Id: <20181226081532.30698-8-weijiang.yang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181226081532.30698-1-weijiang.yang@intel.com> References: <20181226081532.30698-1-weijiang.yang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); /* * The existing code assumes virtual address is 48-bit or 57-bit in the -- 2.17.1