Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5322258imu; Wed, 26 Dec 2018 00:14:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN7CWFfBYW26vPQ1PglJ+bJZFC2LgMGFozz3X36DCf0RnzAIQYTWwXionPlaONWbOQ+rbTDh X-Received: by 2002:a63:df50:: with SMTP id h16mr18280972pgj.421.1545812099176; Wed, 26 Dec 2018 00:14:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545812099; cv=none; d=google.com; s=arc-20160816; b=LPVox+ewCNq/0BRMYyJXZCcdD+5vHfxgIPPGURdzGwalbcKffRw1F0+wOaI4gDxynx LeOKdtmSlBa9DIWWCtVyUmPvUIthwFL5/S58ZgZMZ57yY2uTqXtMhfNAaM6syP/XmNhy 2haWPRipmge8+Dq5YXU7775s0mCBvoFwXhMINl9+r5duZKWFxquDlrN1FhI3XlqsD3to B8ErLIeA1Xe3iaQTtEbF+d6h+lvL9SVuPUNWxmbQRNMLh9vUJGOkKGJ4ActZgCGe/v9s uAeyK+yZ67sFvcTzoPF3iselbKS4G4F0tsAKjirPLstqWXGzrUBaFVmt76k0qtXuuw7i tkBg== 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=MrznkNrSXrSSdQeM8IRXmWXHcI4dbs990H9n87c4EUY=; b=etTPz1WvvgfIadj2WOZxz8yJ5bA3mi2VuWNEKO7s3cMx+QvznTx5nOW2Vn4PVYA+a8 K1B52fjM7DvPjuzQVudU07KrTCvNhKOplXg4kjJg34J1dLBuNNYrV6lCN1meCBp2OcT/ TmZKUFLUJ+32t6SSwQ36jl7cLrz9vrTvGlF3lLZ414REx51IcUy1r303QuilZ8CXZicb k2t7KyTlct/TTTvpXixD//JCHAYlXcmEEVWusL34ktCA48DpFaCShnV2fjZCCXrKbvVn RSIM3ZNX/6VJR3f0hSOMrfLC3LWy+stTMyASKr5k875adepGepIyCbbG78fGSFkWs42C rL0Q== 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 o61si14789485pld.246.2018.12.26.00.14.44; Wed, 26 Dec 2018 00:14:59 -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 S1726716AbeLZINH (ORCPT + 99 others); Wed, 26 Dec 2018 03:13:07 -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 S1726556AbeLZIMt (ORCPT ); Wed, 26 Dec 2018 03:12:49 -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:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,400,1539673200"; d="scan'208";a="104759720" 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:47 -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 6/8] kvm:cpuid Add CPUID support for CET xsaves component query. Date: Wed, 26 Dec 2018 16:15:30 +0800 Message-Id: <20181226081532.30698-7-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 CET xsaves component size is queried through CPUID.(EAX=0xD, ECX=11) and CPUID.(EAX=0xD, ECX=12). Signed-off-by: Zhang Yi Z Signed-off-by: Yang Weijiang --- arch/x86/kvm/cpuid.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 7bcfa61375c0..5bac31e58955 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -565,6 +565,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, case 0xd: { int idx, i; u64 supported = kvm_supported_xcr0(); + u64 sv_supported; entry->eax &= supported; entry->ebx = xstate_required_size(supported, false); @@ -584,18 +585,23 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, entry[i].eax &= kvm_cpuid_D_1_eax_x86_features; cpuid_mask(&entry[i].eax, CPUID_D_1_EAX); entry[i].ebx = 0; + sv_supported = entry[i].ecx + + ((u64)entry[i].edx << 32); if (entry[i].eax & (F(XSAVES)|F(XSAVEC))) entry[i].ebx = xstate_required_size(supported, true); - } else { + } else if (!(entry[i].ecx & 1)) { if (entry[i].eax == 0 || !(supported & mask)) continue; - if (WARN_ON_ONCE(entry[i].ecx & 1)) + entry[i].ecx = 0; + entry[i].edx = 0; + } else { + if (entry[i].eax == 0 || !(sv_supported & mask)) continue; + entry[i].ecx = 1; + entry[i].edx = 0; } - entry[i].ecx = 0; - entry[i].edx = 0; entry[i].flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX; ++*nent; -- 2.17.1