From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f50.google.com (mail-dl1-f50.google.com [74.125.82.50]) (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 0695F3EDAC5 for ; Thu, 12 Mar 2026 17:18:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773335940; cv=none; b=lepFKqQrAy8wyAcNCwuK/htsvq5dQbik9BiY0gaSvqyKnShjTXToK75s9Ks+W69DGKPV6IOUKOhwS8OLoH6Uss522SpWimZ8nSqz3GIs0CR3hSxmhLvVCWyhzFK9GjkjzD1KifDLovbLeUegHK147m0ba2YzEVnpdkKmG1ypj2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773335940; c=relaxed/simple; bh=2DyJ8lnC1ffswG3cfvrH8ldY+pLM26LTaV++/K7wf+U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KZde2h/W/L/dGORYZ8ZVnvmp7QshNSnFkEAoxJyR2WNEFgdMIauI+z5KkSDA6bpObkSF4rGUjkNSi6yhfry/u2M5oxMcQ0xrf1Q49OEq74Z33aY5r9zoe/tzGgbSyBNjuMdryl4YILMycx4VtQAN5DfgG5GufSUmhcBpNxc/TKA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=PLmLD7/D; arc=none smtp.client-ip=74.125.82.50 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=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PLmLD7/D" Received: by mail-dl1-f50.google.com with SMTP id a92af1059eb24-1270fc2bdf2so979c88.0 for ; Thu, 12 Mar 2026 10:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773335937; x=1773940737; darn=vger.kernel.org; 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=QQrPOJ4IgTYDp8ptNQZ8cyDSS7gullqrxNuyd+nPtUw=; b=PLmLD7/D+t22xX5KdyOIcTYY63ORAymEu4eJ5drtPthX61O9c6Q3uqJ4VOQ7+uzL+h pkgtSIg/weiJESI+hqA8DNrJh147UawUyAcRAMjL2ZXb735aXU9tDtg9HI/w/rmI2Hyx R1azu6sWMgHrdZDOT+45+olTl4p5GDYJdPK/VUSyJt2Fe/vQ0m/PGnA7sn0RnQlzviGh jYtr49PEG7eYV7CBhafYjxjsXVSa2D4qqQ87/bNGevE92RXKMCkUIJiUCvpZOu/JiMw5 wqEWeC0+QygYgEcIoFSvlpwQY/f403v654A9yVd69TXvDXEGmzSyIO953KRMxXVR6LLb wlXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773335937; x=1773940737; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QQrPOJ4IgTYDp8ptNQZ8cyDSS7gullqrxNuyd+nPtUw=; b=Wj5zriMRn76HsWnAlkpPdwbmP3n7xm9tAO6aI5ftifWa/p9ic+tbXz2dva5xbtja47 BXCKUU1cTkqmqDoQYbTa7kxyDwC9tWGP+YhkXZZYmPx0tY5ZXPDXRjiHUxvnjoJvwroj 3FpyyE5w5ELkG/mphzvlUdTWF8Gb2uteWi86ejoSYh6yFxwilNMm3ePU65mmujaIdLTX n3bJhc6pZFwBNBA5IHjyiB2PbzBgS32S8moRR1yDMblXWATn9Jv2IR1/WeN9aKerj3Wo Az0jGl/J3jpu64ABqpFEk24fNO/1csjpk7ICj3Clw2rWDdyx7wtiwBe5EjUQY0cUeBk4 u4jg== X-Forwarded-Encrypted: i=1; AJvYcCVSJwGhVr4LN7qkbHIAKkxCs/q6Po48atFrcCpEpq06CR2ZTy/dwnaFFdW+O+DUJ19oksxW4qhKSN+5gtY=@vger.kernel.org X-Gm-Message-State: AOJu0Yz5ukfes8WGpGZPPRD4W+R7GQV6jNYNaYjPMX5huttj9D91fMRK BuwHZF/FnXPFaCHa7NmkcX9ZCc0jEALrSqWql5NbYybe1uuTj9j+t+sAbip02apNxg== X-Gm-Gg: ATEYQzwdrlUOgMNOVqdUn4Ueqvckm+v9spRkAFN982KTCJPYu8OsL+y9Wf/+5urpB/C l3+37UApe3yfJcrE+wjRGaH+sx5aUpCFrZ/TZRBm7OB93xgUzD3ekvZbxL0eGthE3YalhMtPziF z1qI+hG6zDs1d0aFpZkDgPEq0ppdG1wQzsaMI7nj+hq1WCcjfMxPBv0cOwSGImsktyCBYM4gqpO TzO1+vsTR91onXcIsxva790/5dyK4ivk4NWDaM+bvXaxGZINZon1Ld4N61RQZwaNoWz9pqe31cg 0F0bwi4LmfvCcqat2Vmg9n7u7c2iqyr5UnTGFbReZGjyXFpjDSRm9L8jPAHTMNBkOUbc0QUYRhy K/A8Nifw/PrDFJRrwrWhV38PwCj/AQs4w97Kve0Y6KyWUjE9k1LUsfwFvKmcN/DFF7WU8ePJjri EjuihwYyYNHLhAWw/60Vz5sLwloi42LEgjpZunX6MiZyzss65eqYWuC/UZV1k0kA== X-Received: by 2002:a05:701b:4294:20b0:11a:4c75:a45b with SMTP id a92af1059eb24-128f43a0537mr6681c88.10.1773335936173; Thu, 12 Mar 2026 10:18:56 -0700 (PDT) Received: from google.com (154.52.125.34.bc.googleusercontent.com. [34.125.52.154]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2be8aa4ff66sm7182541eec.19.2026.03.12.10.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2026 10:18:55 -0700 (PDT) Date: Thu, 12 Mar 2026 17:18:51 +0000 From: Carlos Llamas To: Peter Zijlstra Cc: Ard Biesheuvel , Sami Tolvanen , Catalin Marinas , Will Deacon , Josh Poimboeuf , Jason Baron , Alice Ryhl , Steven Rostedt , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Valentin Schneider , Kees Cook , Linus Walleij , Borislav Petkov , Nathan Chancellor , Thomas Gleixner , Mathieu Desnoyers , Shaopeng Tan , Jens Remus , Juergen Gross , Conor Dooley , David Kaplan , Lukas Bulwahn , Jinjie Ruan , James Morse , Thomas Huth , Sean Christopherson , Paolo Bonzini , kernel-team@android.com, linux-kernel@vger.kernel.org, Will McVicker , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , "moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)" , "open list:PERFORMANCE EVENTS SUBSYSTEM" Subject: Re: [PATCH] static_call: use CFI-compliant return0 stubs Message-ID: References: <20260309223156.GA73501@google.com> <20260311225822.1565895-1-cmllamas@google.com> <20260311231406.GZ606826@noisy.programming.kicks-ass.net> <742d77a8-3c53-4814-9dd6-81e8317cd829@app.fastmail.com> <20260312080740.GC606826@noisy.programming.kicks-ass.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260312080740.GC606826@noisy.programming.kicks-ass.net> On Thu, Mar 12, 2026 at 09:07:40AM +0100, Peter Zijlstra wrote: > On Thu, Mar 12, 2026 at 08:40:11AM +0100, Ard Biesheuvel wrote: > > So far, we have managed to avoid the blessings of objtool on arm64, > > and the complexity associated with the inline patching is not really > > justified, given that on arm64, there is not really a need to avoid > > indirect calls (and as Peter says, we might end up with them anyway) > > > > A while ago, I had a stab at implementing the out-of-line variety [0], > > but nobody cared enough to even respond. It is rather concise, and > > localised to arm64, so it is something we might consider for > > CONFIG_CFI builds. It is essentially the same sequence that arm64 uses > > for trampolines between modules and the kernel if they are out of > > direct branching range, with some .rodata patching to change the > > target. (arm64 basically only permits code patching without stopping > > the machine when it involves patching branch opcodes into NOPS or vice > > versa). Great! I'll go read your implementation then. > > Doing so for only CONFIG_CFI makes sense because it removes the CFI > > overhead for all static calls, although it adds back some overhead for > > the trampoline. But there is currently no need to do this > > unconditionally. > > Right, so your v3 is very simple and straight forward, and should work > as an end run around the CFI issue, by effectively doing that indirect > tail call in the trampoline outside of the compiler generated software > cfi things. > > And I think I like your thing better because it handles all possible > cases, not just the ret0 oddity and isn't in fact much larger. SGTM, I'll switch over to testing Ard's patch. Thanks, Carlos Llamas