From nobody Mon Feb 9 10:29:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1636596509; cv=none; d=zohomail.com; s=zohoarc; b=MCvnjGSzlOkLeCOXEhtpJgSJTG812w+ZLc0p+gnTyFa1q7dg0QZzXC3W7NoumvHzDWx5Kgjmr/6LmJwGaB026XoC8v9WvSymhB4oR7tSUD70NfeEs38Hck2PTbhz1dkb5wpaHHcHyVnWom2kaCJ/YeREb7YA7Ft6BXDm5EhmI+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636596509; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=hK/bb2+8SYaruhoQBxjUMD9dzEtjE9dODoHgmaxXM04=; b=VYv5ad4ZNXxK2qjflXsphnMNuY3iI0+a9zF4c+CiHR3XG58naurk72tcP56dgTlT8Wpt/V8Cjm4bDF44B7PfC4zGk6Bmbghnp05O3r5T/VkZUmrA5vbigGUYNDMT9pLUEWUSTZJs6EK3/9ztsWlQIceQsaglMhR4vyD9EgUFtbU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 163659650980275.15628603222376; Wed, 10 Nov 2021 18:08:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.224508.387834 (Exim 4.92) (envelope-from ) id 1mkzVE-0004XO-75; Thu, 11 Nov 2021 02:07:48 +0000 Received: by outflank-mailman (output) from mailman id 224508.387834; Thu, 11 Nov 2021 02:07:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mkzVE-0004Wq-0w; Thu, 11 Nov 2021 02:07:48 +0000 Received: by outflank-mailman (input) for mailman id 224508; Thu, 11 Nov 2021 02:07:46 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mkzVC-0004E5-Nz for xen-devel@lists.xenproject.org; Thu, 11 Nov 2021 02:07:46 +0000 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [2607:f8b0:4864:20::449]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 28f337b1-4294-11ec-9787-a32c541c8605; Thu, 11 Nov 2021 03:07:46 +0100 (CET) Received: by mail-pf1-x449.google.com with SMTP id z187-20020a6233c4000000b0047c2090f1abso2998379pfz.23 for ; Wed, 10 Nov 2021 18:07:45 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 28f337b1-4294-11ec-9787-a32c541c8605 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=hK/bb2+8SYaruhoQBxjUMD9dzEtjE9dODoHgmaxXM04=; b=ioMgfZT9xO/74nIuEa5s079HZzqYDthukPpMRSdF0C3awDBWthDsWqAFo50b69aUgk Nhl7hmTYeB+KSKGuShd9pnZgSHEJ4YdF59a3n2gw+3Am+iHw8BnPD9PQEuIObPEX1zet XT5oCTwKFkgZjUeOaAP52YI/QxstVIlhlvJS+3cp25s9mkhbYvGe1eTarbKtvSx415JI ECVQms8ylbLIS/A+wF3YHJcodbwqtGvWDNxp9OhyCccF49POD6LZ1YDg80r7wc3jC1/x 2UeOF3HXehBTuQGieAJ2PQ8fh4iSC2ZmT1gzNp9Gsi+Io2TQjCObkIi6pMuDLYQvs7JU qJOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=hK/bb2+8SYaruhoQBxjUMD9dzEtjE9dODoHgmaxXM04=; b=Khl5ghCR0GJbaGA/0hkqQO1pk+cOl5Jw/OSWEqCdhi8qn5hPLhMOmKNC246ANZPuiC u2LNTNaAur9zvGGwiXLH62y7GMVtC6aHLBZHh80pH4YncQ/hb5/1bJyJaH1IDo1T2cPT fpfEuy7HRZ1BCrR11txlB+xDO2+4CzUsxRybOhbFiEeLBmJi/M3jPaJL6mFKXflOAuTt 3kEnA0GSikln4F17dQqcXL6Hsq/ZHNeJ36MNZYqt8rlSv/dPLHytprhiOGiganvnzEJL QqX03HUjx77UV2rSZyOgjmF+xMmD8bAtZAjFQ9LU5+N9/gySF3fiq38SRTK+TnMSMBWt f/sQ== X-Gm-Message-State: AOAM532YJKmfDWNQYvq0wHE7uarP+Pz5UayReiU8Tkv7eIPlN92r12Y+ RieZIRmDGf05v4mgTRQmHISpYVNyQR4= X-Google-Smtp-Source: ABdhPJyQu0wj6xnqaOSUJnCa9iYYs/0X0i20LUCAU5FW0hNQJqyaWntSFAsP1Erw+w1uVAuo6SyrzLgxEvw= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a05:6a00:1822:b0:49f:c55b:6235 with SMTP id y34-20020a056a00182200b0049fc55b6235mr3668521pfa.66.1636596464117; Wed, 10 Nov 2021 18:07:44 -0800 (PST) Reply-To: Sean Christopherson Date: Thu, 11 Nov 2021 02:07:23 +0000 In-Reply-To: <20211111020738.2512932-1-seanjc@google.com> Message-Id: <20211111020738.2512932-3-seanjc@google.com> Mime-Version: 1.0 References: <20211111020738.2512932-1-seanjc@google.com> X-Mailer: git-send-email 2.34.0.rc0.344.g81b53c2807-goog Subject: [PATCH v4 02/17] KVM: x86: Register perf callbacks after calling vendor's hardware_setup() From: Sean Christopherson To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Will Deacon , Mark Rutland , Russell King , Marc Zyngier , Catalin Marinas , Guo Ren , Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, Paolo Bonzini , Boris Ostrovsky , Juergen Gross Cc: Alexander Shishkin , Jiri Olsa , Namhyung Kim , James Morse , Alexandru Elisei , Suzuki K Poulose , "H. Peter Anvin" , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Stefano Stabellini , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, Artem Kashkanov , Like Xu , Like Xu , Zhu Lingshan X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1636596511691100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Wait to register perf callbacks until after doing vendor hardaware setup. VMX's hardware_setup() configures Intel Processor Trace (PT) mode, and a future fix to register the Intel PT guest interrupt hook if and only if Intel PT is exposed to the guest will consume the configured PT mode. Delaying registration to hardware setup is effectively a nop as KVM's perf hooks all pivot on the per-CPU current_vcpu, which is non-NULL only when KVM is handling an IRQ/NMI in a VM-Exit path. I.e. current_vcpu will be NULL throughout both kvm_arch_init() and kvm_arch_hardware_setup(). Cc: Alexander Shishkin Cc: Artem Kashkanov Cc: stable@vger.kernel.org Acked-by: Paolo Bonzini Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c1c4e2b05a63..021b2c1ac9f0 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8567,8 +8567,6 @@ int kvm_arch_init(void *opaque) =20 kvm_timer_init(); =20 - perf_register_guest_info_callbacks(&kvm_guest_cbs); - if (boot_cpu_has(X86_FEATURE_XSAVE)) { host_xcr0 =3D xgetbv(XCR_XFEATURE_ENABLED_MASK); supported_xcr0 =3D host_xcr0 & KVM_SUPPORTED_XCR0; @@ -8600,7 +8598,6 @@ void kvm_arch_exit(void) clear_hv_tscchange_cb(); #endif kvm_lapic_exit(); - perf_unregister_guest_info_callbacks(&kvm_guest_cbs); =20 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block, @@ -11149,6 +11146,8 @@ int kvm_arch_hardware_setup(void *opaque) memcpy(&kvm_x86_ops, ops->runtime_ops, sizeof(kvm_x86_ops)); kvm_ops_static_call_update(); =20 + perf_register_guest_info_callbacks(&kvm_guest_cbs); + if (!kvm_cpu_cap_has(X86_FEATURE_XSAVES)) supported_xss =3D 0; =20 @@ -11176,6 +11175,8 @@ int kvm_arch_hardware_setup(void *opaque) =20 void kvm_arch_hardware_unsetup(void) { + perf_unregister_guest_info_callbacks(&kvm_guest_cbs); + static_call(kvm_x86_hardware_unsetup)(); } =20 --=20 2.34.0.rc0.344.g81b53c2807-goog