Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp247646iob; Mon, 2 May 2022 18:27:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkcqS0qB3NEd6DuGvzagjYBzUWhJUhHrLTRR61o+QOxHmAEP4jUpWFURoFVhiJ/rEnCrUv X-Received: by 2002:a63:e116:0:b0:3ab:812a:d5b8 with SMTP id z22-20020a63e116000000b003ab812ad5b8mr11659723pgh.457.1651541259031; Mon, 02 May 2022 18:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651541259; cv=none; d=google.com; s=arc-20160816; b=szoVSwRN3eh83w4zdyoY5/ztZWZzOh4UODLa6T5hHd8LMPIRfFrDvSZ84d0Wu7t7C0 NUr6U0VXdBx5prLbZzj1crv1BX/CRFw8JJop6/98MdMuN3U7OWvgMde5+n9ZKws3CGrM FQ0sVjNxYSc4W17J0YxYx61SqbziZzvnfXHf0E0yWQoYd71vUHknbPrzfUCAPpa935Y7 p0EFHXQ7XQVhQKIwkKWZnYtdh0LDI2FSxi+oH5qMcMfRiGR7sWobVQD3oylCVN8693Nq b/CsW+HrFdh5tg8OLqAHnzyl1V81lZtjI4inqRDpWUj+TzYBKShLIJ/mEbfy9Ya55tSc 2aMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=z7Cw+Kh2PwkVaz2CcLvmIqjqnZHIcRL3vzxNDm28vQI=; b=qUI+WKSKAybWzSS+okqhlgL8ae01fxnbu5lko5ABHxufsjjVQwpbXghP/g+64O66d9 yUV+DcVHFF3MlW10zVy1rJSyLlIVCUJSKAnjVGftOgHW4Kiq6hmuYC4wCp2nekf9Tv2w xani+EKLbbsdFGvmA0BRogIuepQyNgzB9TqdNKth6ut/plXVwWUEHmTeBEv01Kz7ZJl0 HvEUdreXkR8ZXWfVAl9atzrDZTeMY+9D/TLYBo/6B6NgckGQ6gTcR87KFKLbxK8xQL/e NWucller1HWwfSi24wmKCkaELz0ZZU/SBJ++qbH9zkNZeGfDKSYfy9jaEzwfATy3X8qU l+3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qUJMJzIg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z36-20020a631924000000b003c2699c807esi1534962pgl.152.2022.05.02.18.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 18:27:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qUJMJzIg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BC12D6A42A; Mon, 2 May 2022 18:06:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230113AbiEBXyc (ORCPT + 99 others); Mon, 2 May 2022 19:54:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232217AbiEBXyO (ORCPT ); Mon, 2 May 2022 19:54:14 -0400 Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A41CCA2 for ; Mon, 2 May 2022 16:50:44 -0700 (PDT) Received: by mail-oo1-xc35.google.com with SMTP id y27-20020a4a9c1b000000b0032129651bb0so2849837ooj.2 for ; Mon, 02 May 2022 16:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=z7Cw+Kh2PwkVaz2CcLvmIqjqnZHIcRL3vzxNDm28vQI=; b=qUJMJzIghsthGyWraON5sQRLlRKSCoeCtBLqhKJxW+nZKX+BqUjkWgnilkYzSgnBqs ZgN1/gkwEi+9c2RnHpNtWioNpP/BXFLJBZdzymI1P+EuPoyeJWQL/nxy1AnvGQ159gqR zXwryGn81LW3dUC6mRtWsiyH4qnVUV+qCk+lcynIagdTX4YkYsJ3A6WfUAZnf2QV0BKv kWxI50BXL7mFaYi67tBF1BlWawAv+ZAAsnLzMI0Vdw3tg7DP8ChWMB7X3AnzKqttwNpo E7TF149IXP7bGqe9ftVMsqI8K5u+dBCsBKqJT/UeB3z3AIs17lfGrqtomLhC/oR0QrF5 ZgQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z7Cw+Kh2PwkVaz2CcLvmIqjqnZHIcRL3vzxNDm28vQI=; b=n56nEyusNqRIy741Q5jKvky9P0aYsc5bfuCe50rbke6fs+j9MnvwvSpfdUcyXmw4Hd M5CwOqP5BDEf9x9pmzy+YnIYc0ryOnwlV7nKohmK7NojKD7orqghO4SjDaFp9onSb/E1 DsQM3inmg76dByq20vRYYaC7Re9L6CN8nT7ekPpxsC1liLImqCfka/MW+lXAyCQKEfSg 7Gn8T/gvf61CiB0cteMh4kR6NwuLtfNW2B5lx2/QYUTNQlhavepob+hbwQR6IBRAI/qK GlO5PjW2pwtoQRqUO/kj6Oe5k/y0LpqlA8vC3rsHb1oW4zJv3UdqXu4f3GrW6nImGFmd ZBJA== X-Gm-Message-State: AOAM530rkHfPJelI209LdufxODsMEU/moHuE9xccbbOmWa9VqKD+7iSV 1Fq7vHWKF4P0H+X04bPyKAqxRwwQ0ds+X41tDSD4aA== X-Received: by 2002:a4a:bb10:0:b0:35e:d6a9:3208 with SMTP id f16-20020a4abb10000000b0035ed6a93208mr4306723oop.85.1651535443613; Mon, 02 May 2022 16:50:43 -0700 (PDT) MIME-Version: 1.0 References: <3fef83d9c2b2f7516e8ff50d60851f29a4bcb716.1651058600.git.sandipan.das@amd.com> In-Reply-To: <3fef83d9c2b2f7516e8ff50d60851f29a4bcb716.1651058600.git.sandipan.das@amd.com> From: Jim Mattson Date: Mon, 2 May 2022 16:50:32 -0700 Message-ID: Subject: Re: [PATCH v4 7/7] kvm: x86/cpuid: Fix CPUID leaf 0xA To: Sandipan Das Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, x86@kernel.org, peterz@infradead.org, bp@alien8.de, dave.hansen@linux.intel.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org, jolsa@kernel.org, tglx@linutronix.de, mingo@redhat.com, pbonzini@redhat.com, like.xu.linux@gmail.com, eranian@google.com, puwen@hygon.cn, ananth.narayan@amd.com, ravi.bangoria@amd.com, santosh.shukla@amd.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 On Wed, Apr 27, 2022 at 4:34 AM Sandipan Das wrote: > > On some x86 processors, CPUID leaf 0xA provides information > on Architectural Performance Monitoring features. It > advertises a PMU version which Qemu uses to determine the > availability of additional MSRs to manage the PMCs. > > Upon receiving a KVM_GET_SUPPORTED_CPUID ioctl request for > the same, the kernel constructs return values based on the > x86_pmu_capability irrespective of the vendor. > > This leaf and the additional MSRs are not supported on AMD > and Hygon processors. If AMD PerfMonV2 is detected, the PMU > version is set to 2 and guest startup breaks because of an > attempt to access a non-existent MSR. Return zeros to avoid > this. > > Fixes: a6c06ed1a60a ("KVM: Expose the architectural performance monitoring CPUID leaf") > Reported-by: Vasant Hegde > Signed-off-by: Sandipan Das > --- > arch/x86/kvm/cpuid.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c > index 4b62d80bb22f..e66ebb747084 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -872,6 +872,11 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) > union cpuid10_eax eax; > union cpuid10_edx edx; > > + if (!static_cpu_has(X86_FEATURE_ARCH_PERFMON)) { Should this be checking kvm_cpu_cap_has(X86_FEATURE_ARCH_PERFMON) instead? > + entry->eax = entry->ebx = entry->ecx = entry->edx = 0; > + break; > + } > + > perf_get_x86_pmu_capability(&cap); > > /* > -- > 2.34.1 >