Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 5093494

Browse files
committed
powerpc/uaccess: Use YZ asm constraint for ld
The 'ld' instruction requires a 4-byte aligned displacement because it is a DS-form instruction. But the "m" asm constraint doesn't enforce that. Add a special case of __get_user_asm2_goto() so that the "YZ" constraint can be used for "ld". The "Z" constraint is documented in the GCC manual PowerPC machine constraints, and specifies a "memory operand accessed with indexed or indirect addressing". "Y" is not documented in the manual but specifies a "memory operand for a DS-form instruction". Using both allows the compiler to generate a DS-form "ld" or X-form "ldx" as appropriate. The change has to be conditional on CONFIG_PPC_KERNEL_PREFIXED because the "Y" constraint does not guarantee 4-byte alignment when prefixed instructions are enabled. No build errors have been reported due to this, but the possibility is there depending on compiler code generation decisions. Fixes: c20beff ("powerpc/uaccess: Use flexible addressing with __put_user()/__get_user()") Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20240529123029.146953-2-mpe@ellerman.id.au
1 parent 2d43cc7 commit 5093494

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

arch/powerpc/include/asm/uaccess.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,19 @@ do { \
181181
#endif
182182

183183
#ifdef __powerpc64__
184+
#ifdef CONFIG_PPC_KERNEL_PREFIXED
184185
#define __get_user_asm2_goto(x, addr, label) \
185186
__get_user_asm_goto(x, addr, label, "ld")
187+
#else
188+
#define __get_user_asm2_goto(x, addr, label) \
189+
asm_goto_output( \
190+
"1: ld%U1%X1 %0, %1 # get_user\n" \
191+
EX_TABLE(1b, %l2) \
192+
: "=r" (x) \
193+
: DS_FORM_CONSTRAINT (*addr) \
194+
: \
195+
: label)
196+
#endif // CONFIG_PPC_KERNEL_PREFIXED
186197
#else /* __powerpc64__ */
187198
#define __get_user_asm2_goto(x, addr, label) \
188199
asm_goto_output( \

0 commit comments

Comments
 (0)