From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Shivang Upadhyay <shivangu@linux.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
chleroy@kernel.org, ritesh.list@gmail.com,
sshegde@linux.ibm.com, peterz@infradead.org, ardb@kernel.org,
will@kernel.org, sv@linux.ibm.com, joe.lawrence@redhat.com,
song@kernel.org, mingo@kernel.org, mbenes@suse.cz
Subject: Re: [PATCH v3 00/11] objtool/powerpc: Fix up feature section alternatives at build time
Date: Wed, 2 Dec 2026 13:25:06 -0800 [thread overview]
Message-ID: <axCJHIhmBcbdlVFH@jpoimboe> (raw)
In-Reply-To: <20261202074059.899491-1-shivangu@linux.ibm.com>
On Wed, Dec 02, 2026 at 01:10:47PM +0530, Shivang Upadhyay wrote:
> The replacement code of a powerpc feature section (BEGIN_FTR_SECTION /
> FTR_SECTION_ELSE / ALT_FTR_SECTION_END macros) is emitted into a __ftr_alt_*
> section. At boot, apply_feature_fixups() copies the replacement code over it.
> Since the copy lands at a different address than the one it was linked for, the
> PC-relative branches in it have to be translated, which is currently done at
> runtime by patch_feature_section().
>
> This has two drawbacks:
>
> - __ftr_alt_* sections are allocatable but not executable, so the
> linker cannot insert branch stubs for them. They therefore have to
> be placed close to .text, and every branch in them must reach its
> target directly. This can break the build as the kernel grows.
Is this a real issue or is it theoretical?
> - The branches are translated on every boot, although everything
> needed to do it is known at link time.
x86 also does something similar for its alternatives, I'm not sure
that's much of a drawback though.
Presumably objtool-on-vmlinux adds some slowness to the build.
> This series moves the translation to build time. After vmlinux is
> linked, objtool is run on it with the new --alt-fixup option. It parses
> the __ftr_fixup, __mmu_ftr_fixup and __fw_ftr_fixup tables, and for each
> PC-relative relocation in the replacement code, asks the arch to rewrite
> the instruction so that it is valid at the place it will be copied to.
> With that, the __ftr_alt_* sections are marked executable and moved out
> of .text into their own output section, so the linker can insert stubs
> where needed.
>
> Objtool does not process modules or the VDSO, so the runtime translation
> is kept for those and only skipped for the core kernel.
So now there are two translation methods of instead of one?
Is there any reason why objtool coudn't be run on linked vDSO and
modules as well?
> Previously, Nicholas Piggin proposed a build-time solution using a custom
> powerpc tool [1]. The approach here builds on that idea, but uses
> objtool's existing ELF parsing and instruction patching infrastructure
> instead of a separate tool.
I notice that last approach was almost 10 years ago, just wondering if
this is a real problem that people are hitting.
--
Josh
next prev parent reply other threads:[~2026-12-02 21:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 7:40 Shivang Upadhyay
2026-12-02 7:40 ` [PATCH v3 01/11] objtool: Make symbol offsets section relative in linked objects Shivang Upadhyay
2026-12-02 7:40 ` [PATCH v3 02/11] objtool: Make relocation " Shivang Upadhyay
2026-12-02 7:40 ` [PATCH v3 03/11] objtool: Keep the layout of linked objects when writing them back Shivang Upadhyay
2026-12-02 7:40 ` [PATCH v3 04/11] objtool: Pass the objtool_file to arch_support_alt_relocation() Shivang Upadhyay
2026-12-02 7:40 ` [PATCH v3 05/11] objtool: Add --alt-fixup Shivang Upadhyay
2026-12-02 7:40 ` [PATCH v3 06/11] objtool: Describe special_entry parsing for --alt-fixup Shivang Upadhyay
2026-12-02 7:40 ` [PATCH v3 07/11] powerpc/lib: Extract branch patching helpers to code-patching-branch.c Shivang Upadhyay
2026-12-02 7:40 ` [PATCH v3 08/11] objtool/powerpc: Implement arch_support_alt_relocation() Shivang Upadhyay
2026-12-02 7:40 ` [PATCH v3 09/11] powerpc: Mark feature section alternatives as executable Shivang Upadhyay
2026-12-02 7:40 ` [PATCH v3 10/11] powerpc: Always build objtool for powerpc Shivang Upadhyay
2026-12-03 5:51 ` kernel test robot
2026-12-03 14:09 ` kernel test robot
2026-12-02 7:40 ` [PATCH v3 11/11] powerpc: Remove runtime checking of jumps in core kernel feature-fixup Shivang Upadhyay
2026-12-02 21:25 ` Josh Poimboeuf [this message]
2026-12-03 7:06 ` [PATCH v3 00/11] objtool/powerpc: Fix up feature section alternatives at build time Shivang Upadhyay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=axCJHIhmBcbdlVFH@jpoimboe \
--to=jpoimboe@kernel.org \
--cc=ardb@kernel.org \
--cc=chleroy@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mbenes@suse.cz \
--cc=mingo@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=peterz@infradead.org \
--cc=ritesh.list@gmail.com \
--cc=shivangu@linux.ibm.com \
--cc=song@kernel.org \
--cc=sshegde@linux.ibm.com \
--cc=sv@linux.ibm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®