From nobody Fri Dec 19 19:15:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1F56C4332F for ; Wed, 16 Feb 2022 10:27:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232916AbiBPK12 (ORCPT ); Wed, 16 Feb 2022 05:27:28 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229729AbiBPK1E (ORCPT ); Wed, 16 Feb 2022 05:27:04 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE02B210AF9; Wed, 16 Feb 2022 02:26:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645007212; x=1676543212; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j2ygaDTqFQonP4prthFBv11MRQhNuMTyC+t4CIkON/s=; b=e2qmQhghbr9/3mlQ6lTc+khA9oee7BFL8LRa2B4fc/EEmMhuqlu2QPqw nAAAr1Cn/YBVMbXfjy/YTkD3Bnh/NFoRwi8g/TdEfNeztdrMcp4vnA69R qYNd7xqdUpB8D08FhU17mEiGuhVC/PWKAblhiohBd/JdsLOSRgWN1rHlF Ipp9GQzmJ/K9yARZoduufbXKojLrRw7fXUwO85wYy1iTw9fLwwvM9NMfD 4uya9uHL8JJ4f+J15ga9PuhpOo3ncCXm/XzlQCND5PuQ6HCFv44AGSSgC uAqcA+5jzrBmxBoXMvwIpw34Y8kPPO2lIshhfCFQ5Gu2WeBzWAP8HECRV A==; X-IronPort-AV: E=McAfee;i="6200,9189,10259"; a="231201159" X-IronPort-AV: E=Sophos;i="5.88,373,1635231600"; d="scan'208";a="231201159" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2022 02:26:51 -0800 X-IronPort-AV: E=Sophos;i="5.88,373,1635231600"; d="scan'208";a="498708588" Received: from embargo.jf.intel.com ([10.165.9.183]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2022 02:26:50 -0800 From: Yang Weijiang To: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com, like.xu.linux@gmail.com, vkuznets@redhat.com, wei.w.wang@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Yang Weijiang Subject: [PATCH v9 06/17] KVM: x86: Add Arch LBR MSRs to msrs_to_save_all list Date: Tue, 15 Feb 2022 16:25:33 -0500 Message-Id: <20220215212544.51666-7-weijiang.yang@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220215212544.51666-1-weijiang.yang@intel.com> References: <20220215212544.51666-1-weijiang.yang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Arch LBR MSR_ARCH_LBR_DEPTH and MSR_ARCH_LBR_CTL are queried by userspace application before it wants to {save|restore} the Arch LBR data. Other LBR related data MSRs are omitted here intentionally due to lengthy list(32*3). Userspace can still use KVM_{GET|SET}_MSRS to access them if necessary. Suggested-by: Jim Mattson Signed-off-by: Yang Weijiang Reviewed-by: Jim Mattson --- arch/x86/kvm/x86.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 8891329d594c..5d8a0364a3cc 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1394,6 +1394,7 @@ static const u32 msrs_to_save_all[] =3D { MSR_F15H_PERF_CTR3, MSR_F15H_PERF_CTR4, MSR_F15H_PERF_CTR5, MSR_IA32_XFD, MSR_IA32_XFD_ERR, MSR_IA32_XSS, + MSR_ARCH_LBR_CTL, MSR_ARCH_LBR_DEPTH, }; =20 static u32 msrs_to_save[ARRAY_SIZE(msrs_to_save_all)]; @@ -6634,6 +6635,11 @@ static void kvm_init_msr_list(void) if (!supported_xss) continue; break; + case MSR_ARCH_LBR_DEPTH: + case MSR_ARCH_LBR_CTL: + if (!kvm_cpu_cap_has(X86_FEATURE_ARCH_LBR)) + continue; + break; default: break; } --=20 2.27.0