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 24621C61D97 for ; Mon, 30 Jan 2023 17:40:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237177AbjA3RkU (ORCPT ); Mon, 30 Jan 2023 12:40:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238114AbjA3RkM (ORCPT ); Mon, 30 Jan 2023 12:40:12 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FEA2CDEA for ; Mon, 30 Jan 2023 09:40:10 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id r8so5546148pls.2 for ; Mon, 30 Jan 2023 09:40:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xV8DppwJAf9tyNq0/SZILKbSGVT5eHp+lhWdWpdE0Vk=; b=mwsV2U6E9NIQdJcV7qSqHab8lmPcC5Z0K5lAUoXsHYv2dQk0ZFHU3POun/qJsGT/WB 9HI0P5uN2YUCbrJKL8BH+UY6+YW1tUoQcwXoEvaAGI0bmm/zh0eKHkCfQ75Xdd8h5giI e/VZCIQUVfzmlUtBeEoP+vOf5lQyWNpu3K8xG9v64ESTgKD9/vcZg/+nm1wPkUgY7pGB jNuSxxiQNnRF8876+H6ps23UMaKO4MWLbqfnFKfGEcmgDJaqs+IZmFVaqBXp1WjIJltS TEvOrSV2RwdRbefArY8l6xmVsSLOnJpKrmgFszxWuoxhLOysZs5WJFRiHHLADkusTVz6 yNbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xV8DppwJAf9tyNq0/SZILKbSGVT5eHp+lhWdWpdE0Vk=; b=2V2r1xLuhg8s5E9DRqts6FumLTrri5UDMLXIYlLl6wZIFbqv2R/3I0DTeyZQ16ZGJx eFRcfS9f9xeTx5UAQ7/V3uQlY3Fahxcd3IG130XyLNh33jtc2YIRYDNhzHBgwy3ipLtO ua622wrQ7MWTrLK8MSyyzUllXFzdq7whXSFREbdkRPu6MOR58upHTgyrtGfOPZNp1BJW JKkg98aESgIAVt4MtNKgcK8sgf0bYuwWpI6pWWzVwACfL5l4rI8tvDzixFlm/JspLRw1 i+5gpWtlvASMtNoMTLSerJ6SEBb9T7+tuBWog2tGT+AoVQ7S4zld4z8lyAVWdNKGsJ4s xFqA== X-Gm-Message-State: AO0yUKVeLoksNgN+ki4+J4V4+arARKwOtgxIZjZm3XrLwdJhSfCETb/E Sba65sH9mnSHV6o0dGRcnkpuBw== X-Google-Smtp-Source: AK7set/Fz1pK27zp9EA5Qozm1kbJ1bo3+FAAuIBSU6H65HIx7r+dP1VQwD6Ok2yxDLU++C0IjZyTkg== X-Received: by 2002:a17:902:d70a:b0:193:256d:8afe with SMTP id w10-20020a170902d70a00b00193256d8afemr842607ply.2.1675100409274; Mon, 30 Jan 2023 09:40:09 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id bg6-20020a1709028e8600b00189a50d2a3esm8070156plb.241.2023.01.30.09.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 09:40:08 -0800 (PST) Date: Mon, 30 Jan 2023 17:40:05 +0000 From: Sean Christopherson To: Like Xu Cc: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v3 1/3] KVM: x86/pmu: Disable guest PEBS on hybird cpu due to heterogeneity Message-ID: References: <20221109082802.27543-1-likexu@tencent.com> <20221109082802.27543-2-likexu@tencent.com> <9b422d58-72ab-051f-e317-02b4d8e7211d@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9b422d58-72ab-051f-e317-02b4d8e7211d@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 30, 2023, Like Xu wrote: > On 20/1/2023 8:47 am, Sean Christopherson wrote: > > On Wed, Nov 09, 2022, Like Xu wrote: > > > From: Like Xu > > > > > > From vPMU enabling perspective, KVM does not have proper support for > > > hybird x86 core. The reported perf_capabilities value (e.g. the format > > > of pebs record) depends on the type of cpu the kvm-intel module is init. > > > When a vcpu of one pebs format migrates to a vcpu of another pebs format, > > > the incorrect parsing of pebs records by guest can make profiling data > > > analysis extremely problematic. > > > > > > The safe way to fix this is to disable this part of the support until the > > > guest recognizes that it is running on the hybird cpu, which is appropriate > > > at the moment given that x86 hybrid architectures are not heavily touted > > > in the data center market. > > > > > > Signed-off-by: Like Xu > > > --- > > > arch/x86/kvm/vmx/capabilities.h | 4 +++- > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > diff --git a/arch/x86/kvm/vmx/capabilities.h b/arch/x86/kvm/vmx/capabilities.h > > > index cd2ac9536c99..ea0498684048 100644 > > > --- a/arch/x86/kvm/vmx/capabilities.h > > > +++ b/arch/x86/kvm/vmx/capabilities.h > > > @@ -392,7 +392,9 @@ static inline bool vmx_pt_mode_is_host_guest(void) > > > static inline bool vmx_pebs_supported(void) > > > { > > > - return boot_cpu_has(X86_FEATURE_PEBS) && kvm_pmu_cap.pebs_ept; > > > + return boot_cpu_has(X86_FEATURE_PEBS) && > > > + !boot_cpu_has(X86_FEATURE_HYBRID_CPU) && > > > + kvm_pmu_cap.pebs_ept; > > > > I assume the patch I just posted[*] to disable the vPMU entirely is sufficient, or > > AFAI, some developers doing client-side virtualization on a hybrid cpu will > specifically want vPMU, > in which case it makes perfect sense for KVM to expose common pmu > capabilities (not PEBS at the current) of big and little cores, such as the > most basic performance counter. > > > do we need this as well in order to hide X86_FEATURE_DS and X86_FEATURE_DTES64? > > I think we still need this diff. Better to prioritize this minor feature a > little bit for hungry users. That wasn't my question. My question was whether or not wholesale disabling vPMU is sufficient to prevent issues with PEBS. Unless we need this patch on top of disabling the vPMU, my strong preference is to disable vPMU, or at the very least make it off-by-default and require a explicit override. I agree that there are users that want to enable vPMU for hybrid CPUs, but as stated in the link below, that needs to be a dedicated enabling effort. I don't see any reason to exempt PEBS from that. E.g. isn't PEBS usable if userspace pins vCPUs to pCPUs and enumerates an accurate topology to the guest? > > [*] https://lore.kernel.org/all/20230120004051.2043777-1-seanjc@google.com