From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6554A261B9B for ; Wed, 24 Jun 2026 22:03:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782338608; cv=none; b=p/5o1Dbqn+5SgwdSw6ptQ2lXEwCx+vr2jIpTxzFtLovHoW03qsdr/zUP4dn+WrCSHu63LjohSDyzKBjcnboyIk6SWe6w5E4huLOL2fr8v3xSFVZ8PfLsLiBxm1aIZOMlqYZsmCqUp4DWebE9bCXB5l3C9tQjJrZjd9n0P3ed0WE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782338608; c=relaxed/simple; bh=r5g6+V2Amp0yxvechpGrRZ8S0WXq2V+a9zpffLkRRbs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jBab5BFwkjQih2/cSEMCafPTLKu8G/bi3vJSegNgz15gz55N0/W/3rNkk57ROn2r/3f6Wqx8uP76cRO/4T5mwVSGONRueKObQRJVQVTl02COFbU5WX6ueBBNLW7e4BNJswsxVRcV7bSh8RB1VwsxWTmyKcuZ77KwZboQq+sG+2E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kt8Q55al; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kt8Q55al" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2c6b4271491so8440245ad.2 for ; Wed, 24 Jun 2026 15:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782338607; x=1782943407; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LrxdfhnpHc3n007Ugb6QRVTz2pRJtP7mIebzaELjk+Q=; b=kt8Q55alaDwoCFWKoa5bV7LcIVUuvYZ+cxeB620+DGabur7nuY8PEpVyhUSxvSnco4 OSwgjFGL9Eu0eZVhBoN19wU18B6Zd8Ea0vlTaDTPYK4VpqcUoKGVSZdsrtK/VVYBxi3m LOhFO78H2yV26E0pldjYBn/V1VvlesUVLbaVSI4LErRM9eVH488NhvbpjAglQjz3wxX2 F25V9ad6yPEW03J1fq69n5YEhpiMbb/ikzkY+aBne+O3cwFts9p045oRm2sQP4pem8LF G7rXCZ8D0e3jIfuOEACMzP5ulS7A5gVxxS+BcFHQyMJZ4QTJ15nam/3pnnT8VQBwOQ8l FZpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782338607; x=1782943407; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LrxdfhnpHc3n007Ugb6QRVTz2pRJtP7mIebzaELjk+Q=; b=XD+Hp1CwdB1wrl5gj6iWCuGwNtwUTkX52sJEiqm6Y19aDGqiQj9+sqItHKEZTW4rQT KcKpbOA9RZwRM4ERd6TO/rVEfEo7dVYV2s9vYj6z4cTdEu2V2+AK/CWBkcfT+i0RdjFo V6lVH87l9k/50MJaG8HKy809YUX2rytY9YvYbP9wlD2U2FBagWW/3GFSHMx59PVoHLBB +wllf36XhKEIWfR94wDOeCbKHwBy24kSrgyP+dBd2EqhqSQyhQY50us4ojlt5wBPdRC0 acQs78k2jWL7dBkXRc6bXGPhSDrC2ug0Y43q5MzH2E8DmgUFjtBZ1K6Zi2xbhMUkoJcY hpkA== X-Forwarded-Encrypted: i=1; AHgh+Rpt7tjVerKuGlBTg0ZGqnx9zgmGx7vU9DgLGCn9DsNDL51Fy4/KmKQCRLF8GAaiJdmtIYdQXUi+wUEFE/g=@vger.kernel.org X-Gm-Message-State: AOJu0Ywr7hWHp6gMoD+pVrRNkvbJ75t2aAcM/J0NL1ivGOPzy7ozlqDr S6cnWWOdAn3ZthoGSk/1CVkp+c6Dt+Ee8cC7woU7Hm2R/+zaa0aOyuGA9cxAgNjBWPBG4udqkme M5eJtEQ== X-Received: from plbl20.prod.google.com ([2002:a17:902:eb14:b0:2c7:e126:e2ca]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:d4d0:b0:2c2:21e9:5a7d with SMTP id d9443c01a7336-2c7fc8a9b4fmr173895ad.34.1782338606050; Wed, 24 Jun 2026 15:03:26 -0700 (PDT) Date: Wed, 24 Jun 2026 22:03:25 +0000 In-Reply-To: <20260624214955.6kkivefeuapcocib@desk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260622-vmscape-bhb-v12-0-76cbda0ae3e5@linux.intel.com> <20260622-vmscape-bhb-v12-7-76cbda0ae3e5@linux.intel.com> <20260624214955.6kkivefeuapcocib@desk> Message-ID: Subject: Re: [PATCH v12 07/12] static_call: Define EXPORT_STATIC_CALL_FOR_MODULES() From: Sean Christopherson To: Pawan Gupta Cc: x86@kernel.org, Jon Kohler , Nikolay Borisov , "H. Peter Anvin" , Josh Poimboeuf , David Kaplan , Borislav Petkov , Dave Hansen , Peter Zijlstra , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , KP Singh , Jiri Olsa , "David S. Miller" , David Laight , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , David Ahern , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , Stanislav Fomichev , Hao Luo , Paolo Bonzini , Jonathan Corbet , Jason Baron , Alice Ryhl , Steven Rostedt , Ard Biesheuvel , Shuah Khan , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Asit Mallick , Tao Zhang , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Wed, Jun 24, 2026, Pawan Gupta wrote: > On Wed, Jun 24, 2026 at 05:59:19AM -0700, Sean Christopherson wrote: > > On Tue, Jun 23, 2026, Pawan Gupta wrote: > > > There is EXPORT_STATIC_CALL_TRAMP() that hides the static key from all > > > modules. But there is no equivalent of EXPORT_SYMBOL_FOR_MODULES() to > > > restrict symbol visibility to only certain modules. > > > > > > Add EXPORT_STATIC_CALL_FOR_MODULES(name, mods) that wraps both the key and > > > the trampoline with EXPORT_SYMBOL_FOR_MODULES(), allowing only a limited > > > set of modules to see and update the static key. > > > > > > The immediate user is KVM, in the following commit. > > > > > > checkpatch reported below warnings with this change that I believe don't > > > apply in this case: > > > > > > include/linux/static_call.h:219: WARNING: Non-declarative macros with multiple statements should be enclosed in a do - while loop > > > include/linux/static_call.h:220: WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable > > > > > > Suggested-by: Peter Zijlstra > > > Signed-off-by: Pawan Gupta > > > --- ... > > Drat, I forgot about this. Exporting static call trampolines for KVM came up in > > another conversation[*]. I had already put together patches to effectively default > > to exporting only the trampoline, and also to deduplicate this code so that the > > CONFIG_HAVE_STATIC_CALL_INLINE=y / CONFIG_HAVE_STATIC_CALL=y / CONFIG_HAVE_STATIC_CALL=n > > implementations don't need to copy+paste the same lines of code. > > > > The attached patches touch a lot more code, and will conflict mightily with KVM > > changes I want to land in 7.3 (more use of a static_call in KVM). But if we get > > them applied (to tip tree) shortly after 7.2-rc1 and provide a topic branch/tag, > > then there shouldn't be too much juggling needed? > > > > If we want to go with the more aggressive cleanup, I'll formally post the patches. > > > > [*] https://lore.kernel.org/all/ahhoDGUz39KSGZ6o@google.com > > Thanks for the context. > > Earlier making the key ro-after-init came up as an option in a thread with > Peter. Does it look like a good option to you? No, it won't work for KVM. kvm.ko (owner of the keys) updates the keys only when a vendor module (kvm-intel.ko or kvm-amd.ko) is loaded, and updates keys *every* time a vendor module is loaded. So for KVM, the static calls need to be __read_mostly, not __ro_after_init. > diff --git a/include/linux/static_call.h b/include/linux/static_call.h > index b610afd1ed55..ea56da8fb446 100644 > --- a/include/linux/static_call.h > +++ b/include/linux/static_call.h > @@ -200,6 +200,14 @@ extern long __static_call_return0(void); > }; \ > ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name) > > +#define DEFINE_STATIC_CALL_NULL_RO_AFTER_INIT(name, _func) \ > + DECLARE_STATIC_CALL(name, _func); \ > + struct static_call_key STATIC_CALL_KEY(name) __ro_after_init = {\ > + .func = _func, \ > + .type = 1, \ > + }; \ > + ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name) > + > #define DEFINE_STATIC_CALL_RET0(name, _func) \ > DECLARE_STATIC_CALL(name, _func); \ > struct static_call_key STATIC_CALL_KEY(name) = { \