Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2561794pxp; Tue, 22 Mar 2022 00:43:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAWvHt9jkCnKMCvjpMiKXMrGBTN+CJALaLysg1nz9gcT6bfz9UhMU1LXjMM7SMZ6qZhQVD X-Received: by 2002:a17:902:f70d:b0:14f:a1e1:b9b3 with SMTP id h13-20020a170902f70d00b0014fa1e1b9b3mr16998379plo.36.1647935024349; Tue, 22 Mar 2022 00:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647935024; cv=none; d=google.com; s=arc-20160816; b=tOoYz3yBOMWiBpeAdh8Uhj6zIYyAHA1GjzMf1HhciEQIiIve41H1O4y3olErbNUh72 VL+J4WYR1XGPkOi0bSYGkW2FDJ8FsRkehV5Cr04Kq0PGvO7eXLcrMI/4K9zDCDNoQGI5 zUBZBNtGlQS3JpYYOjbK+CDpKenc5FyL0O365TNSAcQgFqZJQXPkcRz3fo3eOrikZXaL YhpBIv98PAcynpv4h66B+uGjP4Jdb86mElHYi8AeYaoeVCqWDHO/gRkojhmwdySBGiNK O+o8qJDlwZ7b2Wu1hmRQ7LORVvNTaqVNJoJCCXfZRzCV/Qyw4eHmfqcC+bhka+NuVsi1 RFnw== 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 :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=r4xA4YpWvDAW9lMA2GfpmJRYpPh3E38DjIkUV0HV+uY=; b=B/b3Ao78zmGboSHj4eA1uA4MRSka3M8mr/yAG0/X6qxDzlTE2RXoUHe+O/w7nDErex TvUL+usgTjf2QU2WO8j20BMzucGbl1IAMH99gUDJD4wSR21lgd2vqqPm9HWIgwKuslGN Vx8SuFRMhR/ktL0DuBtxgBtLK/uKamEe2sUmQCUlB2nTrdBfitP0uGIY8U7S1vsUN0Vg gGxIzXXos+aNKLEbEBiVPAeAhhzYKQQqKB/zcNnRH/AmqBq7Rd7jJydfcHVx02yBi4qe m3R1jWCignCAJP4mGg0kHkOFSH4iJ3d/91AWNYIIaCNxQ8rJICc4ZW4jCmQQUsGvIO7r MFlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="XNxhv4/i"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r6-20020a63ec46000000b003829ad9d9basi3414820pgj.788.2022.03.22.00.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 00:43:44 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="XNxhv4/i"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2BCE41EAED; Tue, 22 Mar 2022 00:31:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237513AbiCVHdT (ORCPT + 99 others); Tue, 22 Mar 2022 03:33:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237518AbiCVHdR (ORCPT ); Tue, 22 Mar 2022 03:33:17 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E8EC1CFCD; Tue, 22 Mar 2022 00:31:50 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id v4so14960610pjh.2; Tue, 22 Mar 2022 00:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=r4xA4YpWvDAW9lMA2GfpmJRYpPh3E38DjIkUV0HV+uY=; b=XNxhv4/i9m6xgW7eDDhyYG5Ouj06COWiugANv4Hkgo/bnHhuClzi/M1F8FtdhuUz1Z /H3sM5jaLVfiRLC/RbTSr2MQt4XDfMmPFlyOQ2bXzz/wIGD+kba5AY4rDD04iDgxk7S0 WL+pt8MqZ22r8E9Y/WzOT3H84OufyyXg1FW8TJCB2VssakOsljaCIFdQZHDiklMp65cD EG3mxmqPc6YnxE+zmv+JY/wbwJeEhliVwN5Eu8oXvTj15G5tjOkdatnEjOZA41ygJCdr ZzqWfUrdxqcEyTQBWAcnr580fWrRaowZuJlqGQO4mY/jqp188491P3DmC9kikYcaYYGx 0AlQ== 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:organization:in-reply-to :content-transfer-encoding; bh=r4xA4YpWvDAW9lMA2GfpmJRYpPh3E38DjIkUV0HV+uY=; b=mnPvFZxGn86s33RQuh+Fcz9Yl3IMCHYJVKH54/1RSXju5fVsV/YOA3LnRhSXh/FwH/ KVH6cmAP15A4vORabc+jyxh4/Nk+Yuuc6g/bIAi/+X0bfqnKtuNV/SmWTAUz/b2phn8r lCDZpgW7XuXX8UcFPSuUr4+FtlYMJlQfnG2a7TtJPtUVurZZeHP0z6Mr/Hl+7l01Csl0 SUHY8haU6mYeJRFdQWzX1eMfF9igQTA9CEpsCdJjGxL1OOA+gcdnx9rSpjFL+dfzxFRy ai3Hw+x8kVS0RV8wA/1jGl77/dF0L0427pSiJeB9POXhHmEbdOAeU9OCQHzfeUhLo1Ix nm7w== X-Gm-Message-State: AOAM533715zWRndaoS7zbx6CNL8NxDTabhZbyxEvvkmDAI1XMSibLvS6 CoQAIjXkyfA37GflXHY14zE= X-Received: by 2002:a17:902:f683:b0:153:ee22:18b7 with SMTP id l3-20020a170902f68300b00153ee2218b7mr16451640plg.159.1647934310027; Tue, 22 Mar 2022 00:31:50 -0700 (PDT) Received: from [192.168.255.10] ([203.205.141.112]) by smtp.gmail.com with ESMTPSA id t8-20020aa79468000000b004f764340d8bsm23806525pfq.92.2022.03.22.00.31.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Mar 2022 00:31:49 -0700 (PDT) Message-ID: <7c3c082c-2cad-44ae-1b66-6b1ab73dc11e@gmail.com> Date: Tue, 22 Mar 2022 15:31:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH 7/7] kvm: x86/cpuid: Fix Architectural Performance Monitoring support Content-Language: en-US To: Sandipan Das Cc: 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, jmattson@google.com, eranian@google.com, ananth.narayan@amd.com, ravi.bangoria@amd.com, santosh.shukla@amd.com, kvm list , "linux-kernel@vger.kernel.org" , linux-perf-users@vger.kernel.org, x86@kernel.org References: From: Like Xu Organization: Tencent In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 17/3/2022 2:28 pm, Sandipan Das wrote: > CPUID 0xA provides information on Architectural Performance > Monitoring features on some x86 processors. 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 CPUID function and additional MSRs are not supported on > AMD processors. If 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 The new 0003 patch introduces this issue (and more kvm issues) due to "x86_pmu.version = 2", so this is not a fix in the strictest sense. Btw, do you need my effort to virtualize AMD PerfMonV2 ? > 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 b8f8d268d058..1d9ca5726167 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -865,6 +865,11 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) > union cpuid10_eax eax; > union cpuid10_edx edx; > > + if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { > + entry->eax = entry->ebx = entry->ecx = entry->edx = 0; > + break; > + } > + > perf_get_x86_pmu_capability(&cap); > > /*