Skip to content

Commit 8cf6ecb

Browse files
Nysal Jan K.A.akpm00
authored andcommitted
selftests/mm: fix a build failure on powerpc
The compiler is unaware of the size of code generated by the ".rept" assembler directive. This results in the compiler emitting branch instructions where the offset to branch to exceeds the maximum allowed value, resulting in build failures like the following: CC protection_keys /tmp/ccypKWAE.s: Assembler messages: /tmp/ccypKWAE.s:2073: Error: operand out of range (0x0000000000020158 is not between 0xffffffffffff8000 and 0x0000000000007ffc) /tmp/ccypKWAE.s:2509: Error: operand out of range (0x0000000000020130 is not between 0xffffffffffff8000 and 0x0000000000007ffc) Fix the issue by manually adding nop instructions using the preprocessor. Link: https://lkml.kernel.org/r/20250428131937.641989-2-nysal@linux.ibm.com Fixes: 4603618 ("selftests/mm: build with -O2") Reported-by: Madhavan Srinivasan <maddy@linux.ibm.com> Signed-off-by: Nysal Jan K.A. <nysal@linux.ibm.com> Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com> Reviewed-by: Donet Tom <donettom@linux.ibm.com> Tested-by: Donet Tom <donettom@linux.ibm.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 22adb52 commit 8cf6ecb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tools/testing/selftests/mm/pkey-powerpc.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,18 @@ static inline void expect_fault_on_read_execonly_key(void *p1, int pkey)
104104
return;
105105
}
106106

107+
#define REPEAT_8(s) s s s s s s s s
108+
#define REPEAT_64(s) REPEAT_8(s) REPEAT_8(s) REPEAT_8(s) REPEAT_8(s) \
109+
REPEAT_8(s) REPEAT_8(s) REPEAT_8(s) REPEAT_8(s)
110+
#define REPEAT_512(s) REPEAT_64(s) REPEAT_64(s) REPEAT_64(s) REPEAT_64(s) \
111+
REPEAT_64(s) REPEAT_64(s) REPEAT_64(s) REPEAT_64(s)
112+
#define REPEAT_4096(s) REPEAT_512(s) REPEAT_512(s) REPEAT_512(s) REPEAT_512(s) \
113+
REPEAT_512(s) REPEAT_512(s) REPEAT_512(s) REPEAT_512(s)
114+
#define REPEAT_16384(s) REPEAT_4096(s) REPEAT_4096(s) \
115+
REPEAT_4096(s) REPEAT_4096(s)
116+
107117
/* 4-byte instructions * 16384 = 64K page */
108-
#define __page_o_noops() asm(".rept 16384 ; nop; .endr")
118+
#define __page_o_noops() asm(REPEAT_16384("nop\n"))
109119

110120
static inline void *malloc_pkey_with_mprotect_subpage(long size, int prot, u16 pkey)
111121
{

0 commit comments

Comments
 (0)