Skip to content

Commit 8381469

Browse files
committed
Merge tag 'powerpc-6.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - Enforce full ordering for ATOMIC operations with BPF_FETCH - Fix uaccess build errors seen with GCC 13/14 - Fix build errors on ppc32 due to ARCH_HAS_KERNEL_FPU_SUPPORT - Drop error message from lparcfg guest name lookup Thanks to Christophe Leroy, Guenter Roeck, Nathan Lynch, Naveen N Rao, Puranjay Mohan, and Samuel Holland. * tag 'powerpc-6.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc: Limit ARCH_HAS_KERNEL_FPU_SUPPORT to PPC64 powerpc/uaccess: Use YZ asm constraint for ld powerpc/uaccess: Fix build errors seen with GCC 13/14 powerpc/pseries/lparcfg: drop error message from guest name lookup powerpc/bpf: enforce full ordering for ATOMIC operations with BPF_FETCH
2 parents 54bec8e + be2fc65 commit 8381469

File tree

5 files changed

+54
-3
lines changed

5 files changed

+54
-3
lines changed

arch/powerpc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ config PPC
137137
select ARCH_HAS_GCOV_PROFILE_ALL
138138
select ARCH_HAS_HUGEPD if HUGETLB_PAGE
139139
select ARCH_HAS_KCOV
140-
select ARCH_HAS_KERNEL_FPU_SUPPORT if PPC_FPU
140+
select ARCH_HAS_KERNEL_FPU_SUPPORT if PPC64 && PPC_FPU
141141
select ARCH_HAS_MEMBARRIER_CALLBACKS
142142
select ARCH_HAS_MEMBARRIER_SYNC_CORE
143143
select ARCH_HAS_MEMREMAP_COMPAT_ALIGN if PPC_64S_HASH_MMU

arch/powerpc/include/asm/uaccess.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,25 @@ __pu_failed: \
9292
: label)
9393
#endif
9494

95+
#ifdef CONFIG_CC_IS_CLANG
96+
#define DS_FORM_CONSTRAINT "Z<>"
97+
#else
98+
#define DS_FORM_CONSTRAINT "YZ<>"
99+
#endif
100+
95101
#ifdef __powerpc64__
102+
#ifdef CONFIG_PPC_KERNEL_PREFIXED
96103
#define __put_user_asm2_goto(x, ptr, label) \
97104
__put_user_asm_goto(x, ptr, label, "std")
105+
#else
106+
#define __put_user_asm2_goto(x, addr, label) \
107+
asm goto ("1: std%U1%X1 %0,%1 # put_user\n" \
108+
EX_TABLE(1b, %l2) \
109+
: \
110+
: "r" (x), DS_FORM_CONSTRAINT (*addr) \
111+
: \
112+
: label)
113+
#endif // CONFIG_PPC_KERNEL_PREFIXED
98114
#else /* __powerpc64__ */
99115
#define __put_user_asm2_goto(x, addr, label) \
100116
asm goto( \
@@ -165,8 +181,19 @@ do { \
165181
#endif
166182

167183
#ifdef __powerpc64__
184+
#ifdef CONFIG_PPC_KERNEL_PREFIXED
168185
#define __get_user_asm2_goto(x, addr, label) \
169186
__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
170197
#else /* __powerpc64__ */
171198
#define __get_user_asm2_goto(x, addr, label) \
172199
asm_goto_output( \

arch/powerpc/net/bpf_jit_comp32.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,15 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code
900900

901901
/* Get offset into TMP_REG */
902902
EMIT(PPC_RAW_LI(tmp_reg, off));
903+
/*
904+
* Enforce full ordering for operations with BPF_FETCH by emitting a 'sync'
905+
* before and after the operation.
906+
*
907+
* This is a requirement in the Linux Kernel Memory Model.
908+
* See __cmpxchg_u32() in asm/cmpxchg.h as an example.
909+
*/
910+
if ((imm & BPF_FETCH) && IS_ENABLED(CONFIG_SMP))
911+
EMIT(PPC_RAW_SYNC());
903912
tmp_idx = ctx->idx * 4;
904913
/* load value from memory into r0 */
905914
EMIT(PPC_RAW_LWARX(_R0, tmp_reg, dst_reg, 0));
@@ -953,6 +962,9 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code
953962

954963
/* For the BPF_FETCH variant, get old data into src_reg */
955964
if (imm & BPF_FETCH) {
965+
/* Emit 'sync' to enforce full ordering */
966+
if (IS_ENABLED(CONFIG_SMP))
967+
EMIT(PPC_RAW_SYNC());
956968
EMIT(PPC_RAW_MR(ret_reg, ax_reg));
957969
if (!fp->aux->verifier_zext)
958970
EMIT(PPC_RAW_LI(ret_reg - 1, 0)); /* higher 32-bit */

arch/powerpc/net/bpf_jit_comp64.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,15 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code
846846

847847
/* Get offset into TMP_REG_1 */
848848
EMIT(PPC_RAW_LI(tmp1_reg, off));
849+
/*
850+
* Enforce full ordering for operations with BPF_FETCH by emitting a 'sync'
851+
* before and after the operation.
852+
*
853+
* This is a requirement in the Linux Kernel Memory Model.
854+
* See __cmpxchg_u64() in asm/cmpxchg.h as an example.
855+
*/
856+
if ((imm & BPF_FETCH) && IS_ENABLED(CONFIG_SMP))
857+
EMIT(PPC_RAW_SYNC());
849858
tmp_idx = ctx->idx * 4;
850859
/* load value from memory into TMP_REG_2 */
851860
if (size == BPF_DW)
@@ -908,6 +917,9 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code
908917
PPC_BCC_SHORT(COND_NE, tmp_idx);
909918

910919
if (imm & BPF_FETCH) {
920+
/* Emit 'sync' to enforce full ordering */
921+
if (IS_ENABLED(CONFIG_SMP))
922+
EMIT(PPC_RAW_SYNC());
911923
EMIT(PPC_RAW_MR(ret_reg, _R0));
912924
/*
913925
* Skip unnecessary zero-extension for 32-bit cmpxchg.

arch/powerpc/platforms/pseries/lparcfg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ static int read_dt_lpar_name(struct seq_file *m)
371371

372372
static void read_lpar_name(struct seq_file *m)
373373
{
374-
if (read_rtas_lpar_name(m) && read_dt_lpar_name(m))
375-
pr_err_once("Error can't get the LPAR name");
374+
if (read_rtas_lpar_name(m))
375+
read_dt_lpar_name(m);
376376
}
377377

378378
#define SPLPAR_MAXLENGTH 1026*(sizeof(char))

0 commit comments

Comments
 (0)