Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64C1EC432BE for ; Fri, 27 Aug 2021 07:46:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30A5A600D0 for ; Fri, 27 Aug 2021 07:46:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 30A5A600D0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kge8zhvkZZpeIDVQu2Y8ZkzDDX7pXAuTxSnbJa9jLpo=; b=TDLbwgv1EhLdgS JxFbT2QfAa009/ursLmc7mbh7KdDCEWQB+NMkhzvQ58LLtafUw2tOcD+D8CFe2gkVg8+828JMKGpG aEoZpQ2PmKQsFOYpEiZFxvc3tcZGFFCwQ1DkhYX17icg1o56S/ukWXd+oy2WnihzBISiwAb8sgJud qLZE6UMR63d3jvd/RAPkOQUSEVgdL3ns5bHWeTAIEjd4OYuPukm/N2AaTAPVp75FKKA6YuODacJsN ndIG5JGiBZW2fKnLBivgGlg1gGdpOltrSmEEqu8YYPbG5nyZ49Vucpw5MAxRM4gHDAePalvqlM66E KHHVMnkUoc2YBotQRNXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJWYq-00BsmG-JH; Fri, 27 Aug 2021 07:46:00 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJWYf-00BslB-2B; Fri, 27 Aug 2021 07:45:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=mwqNvZJA9dIpDEWigadLmAt4ekXHrBRvbcdnGdey0lE=; b=I/IvqbDlSMWcIbpdOOAXfLAePd VnuHf80Ij7eT65HZ/ZmLgO4WMPy4itQhDo5T0oqUnYiX+gy+Rpm1rDaH4yfbNkb40sVQ1Gs3+K6Uq CAc6W/5Ofu26xIMuG6qfRfTVilpdhWEX2zSVyoNEfY39xPi+5hJeAJd/b2amtCtk8saRHvdqd3spd k3S7rVNP4X1Ahst2d+VG5ZMlKiq+sDTGG7S40hJJ0KnXYxsSWY1gkda21RFgy0QIi2/QZhbbB2Vlz 96YSYnpgLCOvEhsZUVTk4sOSCYRU5PzhafRroNnuKOSTjrZC6AYQI4zn9xh9YCEYcHiHS9VshLf0l /zvt21FA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJWXo-00EGbQ-KU; Fri, 27 Aug 2021 07:45:12 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 7022A30035D; Fri, 27 Aug 2021 09:44:52 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 549952C6670ED; Fri, 27 Aug 2021 09:44:52 +0200 (CEST) Date: Fri, 27 Aug 2021 09:44:52 +0200 From: Peter Zijlstra To: Like Xu Cc: Sean Christopherson , Alexander Shishkin , Jiri Olsa , Namhyung Kim , James Morse , Alexandru Elisei , Suzuki K Poulose , "H. Peter Anvin" , 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 , Zhu Lingshan , Will Deacon , Mark Rutland , Ingo Molnar , Arnaldo Carvalho de Melo , Catalin Marinas , Marc Zyngier , Guo Ren , Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Borislav Petkov , x86@kernel.org, Paolo Bonzini , Boris Ostrovsky , Juergen Gross , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel Subject: Re: [PATCH 00/15] perf: KVM: Fix, optimize, and clean up callbacks Message-ID: References: <20210827005718.585190-1-seanjc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Fri, Aug 27, 2021 at 02:52:25PM +0800, Like Xu wrote: > + STATIC BRANCH/CALL friends. > > On 27/8/2021 8:57 am, Sean Christopherson wrote: > > This started out as a small series[1] to fix a KVM bug related to Intel PT > > interrupt handling and snowballed horribly. > > > > The main problem being addressed is that the perf_guest_cbs are shared by > > all CPUs, can be nullified by KVM during module unload, and are not > > protected against concurrent access from NMI context. > > Shouldn't this be a generic issue of the static_call() usage ? > > At the beginning, we set up the static entry assuming perf_guest_cbs != NULL: > > if (perf_guest_cbs && perf_guest_cbs->handle_intel_pt_intr) { > static_call_update(x86_guest_handle_intel_pt_intr, > perf_guest_cbs->handle_intel_pt_intr); > } > > and then we unset the perf_guest_cbs and do the static function call like this: > > DECLARE_STATIC_CALL(x86_guest_handle_intel_pt_intr, > *(perf_guest_cbs->handle_intel_pt_intr)); > static int handle_pmi_common(struct pt_regs *regs, u64 status) > { > ... > if (!static_call(x86_guest_handle_intel_pt_intr)()) > intel_pt_interrupt(); > ... > } You just have to make sure all static_call() invocations that started before unreg are finished before continuing with the unload. synchronize_rcu() can help with that. This is module unload 101. Nothing specific to static_call(). _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv