Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp79116iob; Tue, 3 May 2022 11:59:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYQYXmCFLlmUn3MYSBlViXWvCCdDDp6Q05/KgLk2moNrI8SsmMfP6G0CUZdYpOH+Sba10n X-Received: by 2002:a05:6870:d38e:b0:ed:a69d:d537 with SMTP id k14-20020a056870d38e00b000eda69dd537mr2452383oag.19.1651604390261; Tue, 03 May 2022 11:59:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651604390; cv=none; d=google.com; s=arc-20160816; b=RFOWfjQkf1ZN9Dwa+pumqfDTr+SbnuRDFmFXxnG4NONMGxlLzFdeE4jadCPzAXPrCm fxwgYGT046n5J4COU5OhpR5o5OTRwX3TcmkGfqX0wEvkgvtj6X2pn0E/3uqUTVjR5p7n 1aIR5pLTe9WGl1PtRuR6ehOMTWFNuWk2KN5MpVtWikCLxRCdyK/l5+MX3dbehBuZ8XN+ khc57Dnsz1zKV6JhWC7CQkCNmUFwxwk+thG0phaVgxRJL6B7kt/J3we0jOde/sz0FGIx vW2HAK8ibK5p4K/L+jU4Mcs1WY2UeR5ZSE45oVk5+ur/HpgThRV6BbK00MArhY6A5FY6 TmsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=6NUbQ9yWtqpo0VvAgqEBwOM8q51whPE1UMGmRuUeo40=; b=RpJ5JjHr2kA+/9hf5/3i+Fo0sQD0wsDLIkEiLeyubMWF7Bw2tWShxv9vrOpi7fsqBE SGVw7A2CgvBq8vzVYEXOakNDW1mwvpsVv+fjK8z/vNw/aIjOe7y7UVIVjegXnq3dK8lD j8PiMEchwChjp6DbArkfOnoQ4tgFOAkKZP0BenQ5u5bfMBr6uDtJsB5pN167v0gmD+cj pxoLuofJ8wqTKJ3LJoIlplPfYYFT9m/nXnCfpNY8e7tKRbZMYP3CGhdHa7J1ySLK/LC4 AymlG4mfk4AWTObPbWWcPbaITOmmDl7PNs143PB5lmnm0R2m+QdLIslNuPDNok4tdEl1 z5ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=INlnCTuH; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a6-20020acab106000000b002ef88b8d40dsi10442332oif.278.2022.05.03.11.58.46; Tue, 03 May 2022 11:59:50 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=INlnCTuH; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237754AbiECPHB (ORCPT + 99 others); Tue, 3 May 2022 11:07:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232613AbiECPG6 (ORCPT ); Tue, 3 May 2022 11:06:58 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 116C739813 for ; Tue, 3 May 2022 08:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651590205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6NUbQ9yWtqpo0VvAgqEBwOM8q51whPE1UMGmRuUeo40=; b=INlnCTuHxRTdp8TtK5Qb5/NhVYEOFKGapLgkNia7qaQa6QKrcG+7cmrfm2q4XHN4I5BNsR jak+mFhz47rjfcGN3jT36LBqzTRTHt/QK7oCeq+zZezzMpic/mSQ156c/IAWTfwv60KGBM N9UzVtLI4nfyBDpOgl0xqgSPI/ETpDg= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-zEHQQnAcNR6pb4Y0hVmM_A-1; Tue, 03 May 2022 11:02:36 -0400 X-MC-Unique: zEHQQnAcNR6pb4Y0hVmM_A-1 Received: by mail-lf1-f72.google.com with SMTP id h12-20020a05651211cc00b00471af04ec12so8131629lfr.15 for ; Tue, 03 May 2022 08:02:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=6NUbQ9yWtqpo0VvAgqEBwOM8q51whPE1UMGmRuUeo40=; b=EQZRIkt6VLN4QV77l+sefMBPrRKrTU6v6YynpOKKMg/1hJKCnjQXpZxDoPUEyR3QjT CEIrbKAt8Sq2h11/tOPcPBg9MxZ4d8NC9Ob8eOQj42R9IQb2lTHO98rqjt1SEV6SNACR QbbyBAInHHh25yp85JakBr1IbN/P4RpvyDsyY7DneJvZYiiNWfpfSSoJSAsm3kL2CMCl XdS3Bdg+GtD5rP52z6saBNwOaiAsppf8fJEdYiaaNL5I6+30i+52AmO8UF0hSlUQ2x2G //sO78gfb0/TWfQfhqVMzbGssOoW1N2lLx5XfuJ4ZQnzewCbBfxZkrULPsNMxaEHDJbK XgEg== X-Gm-Message-State: AOAM532HXyVhMpVzwA/QyBLnJfNkqxXxV5xf6qf3aT5PYIS/oisZ3UC4 C7atDo4Kj1fmldoXZSXRlPNohPCg9gPWmlR8VeKrfYRO529mIx5LEV9v5DG1e+z8HYfKYFscCiV AQAZS7Y7ytsi/x4R1JFuFx0b6 X-Received: by 2002:a5d:554a:0:b0:20a:d511:c514 with SMTP id g10-20020a5d554a000000b0020ad511c514mr12301995wrw.347.1651579447286; Tue, 03 May 2022 05:04:07 -0700 (PDT) X-Received: by 2002:a5d:554a:0:b0:20a:d511:c514 with SMTP id g10-20020a5d554a000000b0020ad511c514mr12301971wrw.347.1651579447072; Tue, 03 May 2022 05:04:07 -0700 (PDT) Received: from [10.32.181.74] (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.googlemail.com with ESMTPSA id a25-20020adfb519000000b0020c5253d920sm11988545wrd.108.2022.05.03.05.04.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 May 2022 05:04:06 -0700 (PDT) Message-ID: <68a3c5b5-cb02-a22b-d05b-a141c41a9cad@redhat.com> Date: Tue, 3 May 2022 14:04:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v4 7/7] kvm: x86/cpuid: Fix CPUID leaf 0xA Content-Language: en-US To: Jim Mattson , 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, like.xu.linux@gmail.com, eranian@google.com, puwen@hygon.cn, ananth.narayan@amd.com, ravi.bangoria@amd.com, santosh.shukla@amd.com References: <3fef83d9c2b2f7516e8ff50d60851f29a4bcb716.1651058600.git.sandipan.das@amd.com> From: Paolo Bonzini In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On 5/3/22 01:50, Jim Mattson wrote: > 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? Ah, it cannot because X86_FEATURE_ARCH_PERFMON is a synthetic feature. kvm_cpu_cap_has only works with features that are backed by CPUID bits. Paolo