From patchwork Tue Jan 24 23:48:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 4485 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp7451wrn; Tue, 24 Jan 2023 16:16:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXudErTDMGdYJJIp+HJ8wmFpFHZuetG7oDrPkMUFtJMszaPbFXl1lSClEmoq78RtaIZx2Q64 X-Received: by 2002:a17:906:5283:b0:84d:4be4:aa2b with SMTP id c3-20020a170906528300b0084d4be4aa2bmr43653392ejm.68.1674605817579; Tue, 24 Jan 2023 16:16:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674605817; cv=none; d=google.com; s=arc-20160816; b=Mz37MfCBOQN6U36l9HXim07+Co6fIu2e7U/hJBQWMQlY0EUi+Dy2XsLEABmIllJd58 LA3oHf+Qf4WyAtSEkYC9jqxm4s3t3aNpN1vixBx8P1K4WPCRSOFsKnUiI8Y6z7zB6rW+ 1N23zYa0RGX7z/ZWabWJiK8G+vyirrZLzb1E/lw1tZ9PKuuXcm6WJmYRU6k+Dg9keTGg NH08mnUbG6w74osFXFEaJfNy0mKBualXbmUSpJjSwYXAWpkAJ71XrqQYL4TEDG/s/H/P j/xIL6dEecFk6E9TxASE5+DdVLmhBEG/fFhEXILsa4qcpF6Xp6gfUBSvTh2ubnU7wPJV EZvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :reply-to:dkim-signature; bh=d6FbEmiz72YXUF5K5FVTrlen52BVkfJLOr5PvlROo8A=; b=ZtE1Mhs/Go8GkZOJ3JiWyzEm0Au0PZKho3s0I7e0liiObsI+BLcvQeNFsRFMBBdCzY B4du5/VcScLGddcmdp/h9esX/Fs7I0nAgGRyEr+MeiQJYLoFlTbNREhXtIuWwXc5Nhpk WHpEvTUStFO9Li+SJ9JgE+ZTnSc/QH5Ri8mRfxYFj6VUWtYPWqJM83rfDcDBA9ZkQOiT XAKdL8G8VpQ/gcqxvZQSpKskBnqyHpfmHjj6SWzYG2Mn1V7tLxaZiUlafxMlfwt55zsK /bAT52Crj0l3HGqdr7xFu1xrqFIpu+FY8K64W40JUY6ARLzgDu7+Fg1f12NN/5oxHra8 FLyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=K9XMKyWb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v13-20020a056402174d00b0049e9fee3c34si3981346edx.386.2023.01.24.16.16.12; Tue, 24 Jan 2023 16:16:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=K9XMKyWb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234225AbjAXXtQ (ORCPT + 99 others); Tue, 24 Jan 2023 18:49:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231286AbjAXXtP (ORCPT ); Tue, 24 Jan 2023 18:49:15 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37EBFD3 for ; Tue, 24 Jan 2023 15:49:14 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id d21-20020a25add5000000b007ff8112e8b8so16284278ybe.17 for ; Tue, 24 Jan 2023 15:49:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=d6FbEmiz72YXUF5K5FVTrlen52BVkfJLOr5PvlROo8A=; b=K9XMKyWbz63tF2PqKNK+SOWcmnOAY2M73kFwBL17z7cU+H8wzfp2g/Q23QhwV+oIo3 3cjND5YSIhGMeSQCr7QNyUOmlaLgfLtBCIVzz9iVC4xT8vQZavyJzu7Ee6ze6mskN+i+ fBcXBbo5L4hkRUQWRR2rhBWyUWfzHGWfrKzwrqcbsfXZSjnkgEjwstjxxmXaT3B5hFOH oQq4/MlnjN79Tb1qvn48D9vK4MBFQx8J1SPqJwhHcAMKEmbFWjUQZHWOj15X5AlLbeHT 1LCUuixjbarbmjHY+VYRZBah+TGeil+eGE67aY7WE7HZSUhkINVL2FTvpPcja4RXBNXM o1eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=d6FbEmiz72YXUF5K5FVTrlen52BVkfJLOr5PvlROo8A=; b=S5eKIyMCm7A+HdG/4l2hI86zvL+5aHPKusW001/WtxWgo3q4GVgq79xMTQpqlREb0C 7DYFeuaKDwAAynu8Ow4srFM/udG8RqR77UNR7Td/UGoze6ihxa3zNsfTfhuha7pzBQZV I7iWyUirrDXOka/LGQjB+SCUSLg3GvCokbcfxGDOVyniqq+eLNPaCnbWWlmyYAQjf+Ko YMiHlleuS8ymHEijLv6mK1x8+nuDAAsQ+VVsRy2ipuPWeTg/ZwQyg7LRvHrCeB06tMT3 P4CxAobZALKlpcG6r71TJFf6pWIPzJeOhSAoPoMYuOxHz9xojqE/VX/g5K4Vjih6vPe7 wUHA== X-Gm-Message-State: AFqh2kpvacYW4ESmjihZoswqBNAcDwN9UtLnm23jmW89mQ3/gsgkLsm8 nmaOAo1yN5Hz+XPERkHFfYRL4wl5SJ8= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:4ac1:0:b0:4ec:933c:6c99 with SMTP id x184-20020a814ac1000000b004ec933c6c99mr3437689ywa.61.1674604153483; Tue, 24 Jan 2023 15:49:13 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 24 Jan 2023 23:48:59 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog Message-ID: <20230124234905.3774678-1-seanjc@google.com> Subject: [PATCH 0/6] KVM: x86/pmu: Misc PMU MSR fixes From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Aaron Lewis , Weijiang Yang , Like Xu X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755951470051338433?= X-GMAIL-MSGID: =?utf-8?q?1755951470051338433?= Fix a handful of minor PMU MSR issues, mostly related to KVM's reporting and handling of MSRs when the PMU is disabled. E.g. running the state_test selftest with enable_pmu=0 fails because KVM tells userspace to save/restore the fixed counter MSRs, but then rejects attempts to access said MSRs from userspace. Aaron and Like, My plan is to apply this rather quickly, e.g. later this week, as the AMD PMU v2 series can be simplified by taking a dependency on the kvm_pmu_cap.num_counters_gp fix (patch 1). But I'll make sure to place the patches at the end of the pmu queue so that it'll be easy to unwind if there's a fatal bug without affecting the hashes of other PMU stuff destined for 6.3. In other words, please review/test sometime in the next few weeks, even if I queue it. Thanks! Based on: git@github.com:kvm-x86/linux.git pmu Like Xu (1): KVM: x86/pmu: Don't tell userspace to save MSRs for non-existent fixed PMCs Sean Christopherson (5): KVM: x86/pmu: Cap kvm_pmu_cap.num_counters_gp at KVM's internal max KVM: x86/pmu: Gate all "unimplemented MSR" prints on report_ignored_msrs KVM: x86/pmu: Use separate array for defining "PMU MSRs to save" KVM: x86/pmu: Don't tell userspace to save PMU MSRs if PMU is disabled KVM: x86/pmu: Provide "error" semantics for unsupported-but-known PMU MSRs arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/hyperv.c | 10 +- arch/x86/kvm/pmu.h | 5 +- arch/x86/kvm/svm/pmu.c | 1 + arch/x86/kvm/svm/svm.c | 5 +- arch/x86/kvm/vmx/pmu_intel.c | 1 + arch/x86/kvm/vmx/vmx.c | 4 +- arch/x86/kvm/x86.c | 229 +++++++++++++++++--------------- arch/x86/kvm/x86.h | 12 ++ 9 files changed, 149 insertions(+), 119 deletions(-) base-commit: 647ffac11ebbbd21e04dd11a7125decb99eeee65