From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796281654; b=Gb/KTnXN++jrsLEbR9vm0hSf3BmoaT1IPagikACQgKUPklq0j6cPcT+P3ymWW6ZyIW1c NhOLWBmVTVDJbi4L1GvHog40iRLFXxAW3tYvV49W+GM41rberlhXRWicxfM+R3dnWYzTQ JG22eHpJlxmTuHz4nIhAC2emjbhbU7kgfiVUwnrYTo8jcQp10E90vR4GmeWbVedMhhZvs Yopa75KEIi0KYbmtYD65JXeIUhpoXgWGdGEMYIG9XNbFBarh6Hqn/q0XhhIwMmNY67vbL w7J7lLxIGafoZCse7FFi9SbmsDSthh0Vo3xFkm6cH2bjqvCkbr4Dr9DkwfRrzNFw2Uw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796281654; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:Message-ID:Subject:From:To:Cc: Date:In-Reply-To:References:Content-Type:Content-Transfer-Encoding: User-Agent:MIME-Version:X-TM-AS-GCONF:X-Proofpoint-Reinject: X-Authority-Analysis:X-Proofpoint-GUID:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-ORIG-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=J3Mv+QXhOLLylNtFts7KLcPzmUuKCyE80xLYykRjO4o=; b=NX0HVbhYySM3+dBLYlL8WYXUfxVHfx5NIe3N6Qffh9+Mt2DKNDxWpXL/lnZLTBV0yoAd POWZUQYz9SGxopER9BOwmArHYUqZnW9PPeEdEG0wsrUfhoCHANejVHpcnJb9f2oU2OC6S 7ZAkRNDppquOk4fhTS75fgzbTROlRaCutGJEDBWxx5Az19hxq+DUpjNaGAwIrLce4uE0r jofSrAfUb3tcZspH6vrbdS+Y+GNQXG5p8LpgtCRLGyGedSZ2nLmvZzHkoOm1yL51gnqLO 9NbxB6kDMAAiG56gWS4HqpX3Coe3xGiPncIoiQEi8wduBedBtrT2AK14iESsztqylnQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b="m/aZ6t8N"; arc=none smtp.remote-ip=148.163.158.5 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACAF6606A334 for ; Thu, 3 Dec 2026 07:07:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ACAF6606A334 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.a=rsa-sha256 header.s=pp1 header.b=m/aZ6t8N Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B374oWU2699830; Thu, 3 Dec 2026 07:06:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=J3Mv+Q XhOLLylNtFts7KLcPzmUuKCyE80xLYykRjO4o=; b=m/aZ6t8NYN1432E6vxnUlS +OTy27qRPp4IfRBnQJXhx4Mp4rVcAYjcN/RQDg18uU/rLJf1Dy4v57y404OYr63l c/3n84XezyCjnuHZ3WBRJ5LTbH9yDvp7NbDDRn4MgQy9eW5W9HG1XVJPTfqUmmH9 SANdiZUeIYhK/jhCZyzG5dM4yQKDXTeqFNe9XmYm2sfcGaEQQaNIYcsAHCCcTQGT OpfaTEl9fSSXoTOywPOH1p8+0D2A7Cl7qSKW8VuhcXjIdFBcxgdTflVzCmv3wSQH ouDlxpnUQE/Q9lvcyh1nRvLmjcbKGLbpJ9bnBY1N8J08dr366crF4xwtD9pKGHxg == 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 4jan7uun8q-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 03 Dec 2026 07:06:53 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B36nJ4x1233314; Thu, 3 Dec 2026 07:06:52 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ja2uv6rrq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Dec 2026 07:06:52 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B376oKs12321380 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 Dec 2026 07:06:51 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E085958064; Thu, 3 Dec 2026 07:06:50 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9CD058057; Thu, 3 Dec 2026 07:06:44 +0000 (GMT) Received: from shivang.upadyay (unknown [9.123.11.24]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 3 Dec 2026 07:06:44 +0000 (GMT) Message-ID: <3c3f8c66080fbd98257ecbde0dc9162dbabfd48a.camel@linux.ibm.com> Subject: Re: [PATCH v3 00/11] objtool/powerpc: Fix up feature section alternatives at build time From: Shivang Upadhyay To: Josh Poimboeuf 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 Date: Thu, 03 Dec 2026 12:36:43 +0530 In-Reply-To: References: <20261202074059.899491-1-shivangu@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-2.fc43) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=Vvy2kO2n c=1 sm=1 tr=0 ts=6b11150d cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=Df79qlCRRTV8DTToyTYA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: ctQ9YHl--Xy8M4w5EgntY90n-AKtchUy X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAzMDAyOCBTYWx0ZWRfX06blfY7glx2g 1ZAdHQt/HD2j+kk+tWCvL2sR2k253FFha3FB6hHK1j05CvkRUgjrRwWR0yfIdUBqgkqrLGY4TVC yJZ9G47K7b8h8Pqz0qEMUrxKaSPoZ+o= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAzMDAyOCBTYWx0ZWRfX03BJfYMOb33z G/94JLJeBsmLSnoWC9hyLWmFgW+KJWck0pUKjFrYFosBW2YvpzAazwx25EBTCwO+uszaVu5cMcZ xN6u+Jp86sKpsO85ZLykS6gBj9vTFyHLiD3vNikRrwKesj7YXz56Z4FiEynjGaU0oMBCEX7Hiwd 9FNRZmXYJNdGIDGUBzMnMSTjmBros7SEh7LtkFPHKINJ8mERTQ0ckhQW6VCLRqdOVkG6H2mR+rC MrL31S+lhh5Qn6ifGkkjGKlS37PwKWpBkXnGmuoi/pcb8Fx3JOEO+pC+dPYFB4igXncXJTwv5EY x1PjZF5dAvKqWxz9vVlrfK8UdO+FoWF+pHF7LLIMVxPf3iSfzh0ZEQh8HMF41xg9aCUYegV7AWQ 0ewyIGlVLC3Z9dokj2EtBZVooh2B+ciEx2q+TL23ixuJKBSENzeYFe4ZyU3EosTRyBcHcD4GtPb fsJsF4kWt33aF/h4G6Q== X-Proofpoint-ORIG-GUID: LPMGT2knAdEbkJyjrfUQVFrOFPuHf2_S X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-03_02,2026-12-02_07,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 priorityscore=1501 spamscore=0 impostorscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612030028 On Wed, 2026-12-02 at 13:25 -0800, Josh Poimboeuf wrote: > 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.=C2=A0 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(). > >=20 > > This has two drawbacks: > >=20 > > =C2=A0- __ftr_alt_* sections are allocatable but not executable, so the > > =C2=A0=C2=A0 linker cannot insert branch stubs for them.=C2=A0 They the= refore have > > to > > =C2=A0=C2=A0 be placed close to .text, and every branch in them must re= ach > > its > > =C2=A0=C2=A0 target directly.=C2=A0 This can break the build as the ker= nel grows. >=20 > Is this a real issue or is it theoretical? Hi Josh, I haven't hit this myself, but Nick and Sathvika ran into it while working on alt features. I believe the failing case was conditional branches (bc, R_PPC_REL14), which can only reach =C2=B132KB. On ppc64le the sections are aligned to the page size, commonly 64KB, so a branch from an alt section can easily end up out of range of its target, specially when alt section adds length to top of head section. >=20 > > =C2=A0- The branches are translated on every boot, although everything > > =C2=A0=C2=A0 needed to do it is known at link time. >=20 > x86 also does something similar for its alternatives, I'm not sure > that's much of a drawback though. >=20 > Presumably objtool-on-vmlinux adds some slowness to the build. >=20 Not much, There are not many instructions to patch. time ./tools/objtool/objtool --link --alt-fixup ./vmlinux.unstripped=20 real 0m0.901s user 0m0.582s sys 0m0.309s > > This series moves the translation to build time.=C2=A0 After vmlinux is > > linked, objtool is run on it with the new --alt-fixup option.=C2=A0 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. > >=20 > > Objtool does not process modules or the VDSO, so the runtime > > translation > > is kept for those and only skipped for the core kernel. >=20 > So now there are two translation methods of instead of one? >=20 > Is there any reason why objtool coudn't be run on linked vDSO and > modules as well? >=20 It should not be hard to achieve. Currently I could not find any example for alt feature implemented for VDSO or modules, to test. ~Shivang. > > Previously, Nicholas Piggin proposed a build-time solution using a > > custom > > powerpc tool [1].=C2=A0 The approach here builds on that idea, but uses > > objtool's existing ELF parsing and instruction patching > > infrastructure > > instead of a separate tool. >=20 > I notice that last approach was almost 10 years ago, just wondering > if > this is a real problem that people are hitting.