From nobody Tue Feb 10 09:22:18 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EC402DC77E; Mon, 9 Feb 2026 08:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626982; cv=none; b=CYskoenMyceQxItBNdnSKOTs5ysCoodbKNesrDnRUj69encrfyCq0svuuVqWFloqgAh24T9ErGynStbZG3QsGmAbmK6/tkwd45O/kHJMttcSRahAMAfIMAaFEIGycHnr3Awbb1cgsk9okM27aRDJPEzKEmXghpgZ2ECuFoA+2HI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626982; c=relaxed/simple; bh=3IuTcTExlcru3YTsk+SAa46ZIl8gDT/yEaK1io4hJcQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mtQI5InLiTqedQnUjIUh3rtAWi94Nn4+hnEb8J92DLtOnSiBDcxmSB8Q1a4kbujmaM5d8bSDePzSSV5FnKJhpHnuXqjpr7gpwer6tFUntumZBLFgCKTF2aU9Nm6uPml8APU0G+QiQk81JFSS1O9dNC7YzS3s0cmXz23GhKILbpU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=fF1AoKqL; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="fF1AoKqL" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 618MsFKb369791; Mon, 9 Feb 2026 08:49:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=swzmicMpwiMbx8mDS bwNndtctxSKq8Ub8sOhW5HI1og=; b=fF1AoKqLfdckc6vWgvjkz+PHgASRx8aRT kq7waiXEZ3Fm+TipOyUA9tnie5ar1mRydD+O2H6D7ugu7a+lDTfrRs0jq6PD1MA6 FltUBiKh0gWkGZhctJolKtuxhFBdt9w88ZrYxO0hAKURpw0XNV1yGwv6ylMHazuw K+8NWNkxEpNyuKZLZI4DhTOMXzuTEhChNIDh7Y0Zc0HfCZ6htnR0uoHyMCdgMx2v BPuQZ/yFE4r3T8fToa50w2tQU2sSlvLmbI4X4DNej6RmkHUdIWEhrOE4DnaLG/uU WSpses+2nSPa4jveyXFFiO71aP6tkV4hoJFCpA1XluCUmiLcQ4q6w== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4c696wn121-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:49:19 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 6193F7Ef012996; Mon, 9 Feb 2026 08:49:19 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4c6h7k4bc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:49:19 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6198nE9129557040 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Feb 2026 08:49:14 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 159FA2005A; Mon, 9 Feb 2026 08:49:14 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1DEB320043; Mon, 9 Feb 2026 08:49:10 +0000 (GMT) Received: from li-2fa77bcc-2701-11b2-a85c-cd621c23b6bd.in.ibm.com (unknown [9.79.195.233]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Feb 2026 08:49:09 +0000 (GMT) From: Sathvika Vasireddy To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: nathan@kernel.org, masahiroy@kernel.org, kees@kernel.org, naveen@kernel.org, jpoimboe@kernel.org, peterz@infradead.org, npiggin@gmail.com, maddy@linux.ibm.com, segher@kernel.crashing.org, christophe.leroy@csgroup.eu, mingo@kernel.org, mpe@ellerman.id.au, sv@linux.ibm.com, nsc@kernel.org Subject: [RFC PATCH v3 6/6] powerpc: Enable build-time feature fixup processing by default Date: Mon, 9 Feb 2026 14:18:20 +0530 Message-ID: <20260209084820.57298-7-sv@linux.ibm.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260209084820.57298-1-sv@linux.ibm.com> References: <20260209084820.57298-1-sv@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=WZYBqkhX c=1 sm=1 tr=0 ts=69899f90 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=CCpqsmhAAAAA:8 a=pGLkceISAAAA:8 a=VnNF1IyMAAAA:8 a=VskAbI2hzQZqgVltqkQA:9 a=ul9cdbp4aOFLsgKbc677:22 X-Proofpoint-GUID: OKeoAZ_qGQIChqA9D9J6OY22ZY98-8Pe X-Proofpoint-ORIG-GUID: _e2wpXSxv9mlaPRqxf5o3pOZrAJ7h1if X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjA5MDA3MiBTYWx0ZWRfX4sKG2cWTbN0G aAfUTY1xWxqWq89QeCu8Jv3K7bEYb0FFWTMsLcY6U6xxy37EsVI5LUC3mAk+407DqyOy+8Nv07K uYccfshHtpMRJe/aJ4VdXi64BG+waABEFT65T2m6Xq8Mnv1xGc7dhQWxW8WuT5IqPjwRY3eMeUT LQN+JSbKAXIWTQq0+9GrJURg29Q6cel16U17Txck3+8IDgFzWHw13Rm4zsv94AtJyoDFP7zEie9 Z4BFF/NTOw7B2y0O+gweRBw/Nt5tLUfRaVgydPGRZsU2fzSd/oNzH1SKmhx4fWBiSHEKLS2TuU2 zqNEg/wMVUlss9bacH1O2ozdaT1jLvFiygq8OWSpkdlAg9Ny1rUaTUh1ZQ0Mh3ju5xqewOF4b5G M5EMsPjuekHjZjJFSsWDwOR/7R6Im23bVIjwF+TCXsPJNCYLWW4NbhtNdtLARVz1NtABjh9prxb vke6nj6QTp48jeHXxeA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-08_05,2026-02-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602090072 Content-Type: text/plain; charset="utf-8" Enable HAVE_OBJTOOL_FTR_FIXUP by default on PowerPC architecture. - Remove runtime branch translation logic from patch_alt_instruction() - Add --emit-relocs linker flags for post-link fixup processing - Update ftr_alt section attributes to include executable flag - Strip the --emit-relocs relocation sections (.rel*) from the final vmlinux after processing Co-developed-by: Nicholas Piggin Signed-off-by: Nicholas Piggin Signed-off-by: Sathvika Vasireddy --- arch/powerpc/Kconfig | 3 +++ arch/powerpc/Makefile | 5 +++++ arch/powerpc/include/asm/feature-fixups.h | 2 +- arch/powerpc/kernel/vmlinux.lds.S | 8 ++++++-- arch/powerpc/lib/feature-fixups.c | 12 ------------ scripts/Makefile.vmlinux | 5 +++++ 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index b8d36a261009..aedb11912672 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -23,6 +23,9 @@ config 64BIT bool default y if PPC64 =20 +config HAVE_OBJTOOL_FTR_FIXUP + def_bool y + config LIVEPATCH_64 def_bool PPC64 depends on LIVEPATCH diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index a58b1029592c..8e1dab5f3c9a 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -105,6 +105,11 @@ LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) :=3D -pie --no-d= ynamic-linker LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) +=3D -z notext LDFLAGS_vmlinux :=3D $(LDFLAGS_vmlinux-y) =20 +# --emit-relocs required for post-link fixup of alternate feature +# text section relocations. +LDFLAGS_vmlinux +=3D --emit-relocs +KBUILD_LDFLAGS_MODULE +=3D --emit-relocs + ifdef CONFIG_PPC64 ifndef CONFIG_PPC_KERNEL_PCREL # -mcmodel=3Dmedium breaks modules because it uses 32bit offsets from diff --git a/arch/powerpc/include/asm/feature-fixups.h b/arch/powerpc/inclu= de/asm/feature-fixups.h index 756a6c694018..d6ae92a292ec 100644 --- a/arch/powerpc/include/asm/feature-fixups.h +++ b/arch/powerpc/include/asm/feature-fixups.h @@ -32,7 +32,7 @@ =20 #define FTR_SECTION_ELSE_NESTED(label) \ label##2: \ - .pushsection __ftr_alt_##label,"a"; \ + .pushsection __ftr_alt_##label, "ax"; \ .align 2; \ label##3: =20 diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinu= x.lds.S index 15850296c0a9..70a4de464b34 100644 --- a/arch/powerpc/kernel/vmlinux.lds.S +++ b/arch/powerpc/kernel/vmlinux.lds.S @@ -99,8 +99,8 @@ SECTIONS .text : AT(ADDR(.text) - LOAD_OFFSET) { ALIGN_FUNCTION(); #endif - /* careful! __ftr_alt_* sections need to be close to .text */ - *(.text.hot .text.hot.* TEXT_MAIN .text.fixup .text.unlikely .text.unlik= ely.* .fixup __ftr_alt_* .ref.text); + *(.text.hot .text.hot.* TEXT_MAIN .text.fixup .text.unlikely + .text.unlikely.* .fixup .ref.text); *(.tramp.ftrace.text); NOINSTR_TEXT SCHED_TEXT @@ -267,6 +267,10 @@ SECTIONS _einittext =3D .; } :text =20 + .__ftr_alternates.text : AT(ADDR(.__ftr_alternates.text) - LOAD_OFFSET) { + *(__ftr_alt*); + } + /* .exit.text is discarded at runtime, not link time, * to deal with references from __bug_table */ diff --git a/arch/powerpc/lib/feature-fixups.c b/arch/powerpc/lib/feature-f= ixups.c index 587c8cf1230f..269e992b1631 100644 --- a/arch/powerpc/lib/feature-fixups.c +++ b/arch/powerpc/lib/feature-fixups.c @@ -53,22 +53,10 @@ static u32 *calc_addr(struct fixup_entry *fcur, long of= fset) =20 static int patch_alt_instruction(u32 *src, u32 *dest, u32 *alt_start, u32 = *alt_end) { - int err; ppc_inst_t instr; =20 instr =3D ppc_inst_read(src); =20 - if (instr_is_relative_branch(ppc_inst_read(src))) { - u32 *target =3D (u32 *)branch_target(src); - - /* Branch within the section doesn't need translating */ - if (target < alt_start || target > alt_end) { - err =3D translate_branch(&instr, dest, src); - if (err) - return 1; - } - } - raw_patch_instruction(dest, instr); =20 return 0; diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index e3dd7fc62f20..3d2a203b8908 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -88,6 +88,11 @@ remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) +=3D = '.rel*' '!.rel*.dyn' # https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dcommit;h=3Dc12d9fa2= afe7abcbe407a00e15719e1a1350c2a7 remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) +=3D '.rel.*' =20 +# --emit-relocs produces .rela.* sections needed by objtool --ftr-fixup; +# strip them from vmlinux after fixup processing is complete. +remove-section-$(CONFIG_HAVE_OBJTOOL_FTR_FIXUP) +=3D '.rel*' '!.rel*.dy= n' +remove-section-$(CONFIG_HAVE_OBJTOOL_FTR_FIXUP) +=3D '.rel.*' + remove-symbols :=3D -w --strip-unneeded-symbol=3D'__mod_device_table__*' =20 # To avoid warnings: "empty loadable segment detected at ..." from GNU obj= copy, --=20 2.43.0