Skip to content

Commit d785610

Browse files
committed
Merge tag 'powerpc-6.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - Ensure we never emit lwarx with EH=1 on 32-bit, because some 32-bit CPUs trap on it rather than ignoring it as they should. - Fix ftrace when building with clang, which was broken by some refactoring. - A couple of other minor fixes. Thanks to Christophe Leroy, Naveen N. Rao, Nick Desaulniers, Ondrej Mosnacek, Pali Rohár, Russell Currey, and Segher Boessenkool. * tag 'powerpc-6.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/kexec: Fix build failure from uninitialised variable powerpc/ppc-opcode: Fix PPC_RAW_TW() powerpc64/ftrace: Fix ftrace for clang builds powerpc: Make eh value more explicit when using lwarx powerpc: Don't hide eh field of lwarx behind a macro powerpc: Fix eh field when calling lwarx on PPC32
2 parents aea23e7 + 83ee9f2 commit d785610

File tree

6 files changed

+25
-30
lines changed

6 files changed

+25
-30
lines changed

arch/powerpc/include/asm/atomic.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,18 @@ static __always_inline bool
140140
arch_atomic_try_cmpxchg_lock(atomic_t *v, int *old, int new)
141141
{
142142
int r, o = *old;
143+
unsigned int eh = IS_ENABLED(CONFIG_PPC64);
143144

144145
__asm__ __volatile__ (
145-
"1: lwarx %0,0,%2,%5 # atomic_try_cmpxchg_acquire \n"
146+
"1: lwarx %0,0,%2,%[eh] # atomic_try_cmpxchg_acquire \n"
146147
" cmpw 0,%0,%3 \n"
147148
" bne- 2f \n"
148149
" stwcx. %4,0,%2 \n"
149150
" bne- 1b \n"
150151
"\t" PPC_ACQUIRE_BARRIER " \n"
151152
"2: \n"
152153
: "=&r" (r), "+m" (v->counter)
153-
: "r" (&v->counter), "r" (o), "r" (new), "i" (IS_ENABLED(CONFIG_PPC64) ? 1 : 0)
154+
: "r" (&v->counter), "r" (o), "r" (new), [eh] "n" (eh)
154155
: "cr0", "memory");
155156

156157
if (unlikely(r != o))

arch/powerpc/include/asm/bitops.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,15 @@ static inline unsigned long fn( \
163163
"bne- 1b\n" \
164164
postfix \
165165
: "=&r" (old), "=&r" (t) \
166-
: "rK" (mask), "r" (p), "i" (IS_ENABLED(CONFIG_PPC64) ? eh : 0) \
166+
: "rK" (mask), "r" (p), "n" (eh) \
167167
: "cc", "memory"); \
168168
return (old & mask); \
169169
}
170170

171171
DEFINE_TESTOP(test_and_set_bits, or, PPC_ATOMIC_ENTRY_BARRIER,
172172
PPC_ATOMIC_EXIT_BARRIER, 0)
173173
DEFINE_TESTOP(test_and_set_bits_lock, or, "",
174-
PPC_ACQUIRE_BARRIER, 1)
174+
PPC_ACQUIRE_BARRIER, IS_ENABLED(CONFIG_PPC64))
175175
DEFINE_TESTOP(test_and_change_bits, xor, PPC_ATOMIC_ENTRY_BARRIER,
176176
PPC_ATOMIC_EXIT_BARRIER, 0)
177177

arch/powerpc/include/asm/ppc-opcode.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@
343343
#define __PPC_SPR(r) ((((r) & 0x1f) << 16) | ((((r) >> 5) & 0x1f) << 11))
344344
#define __PPC_RC21 (0x1 << 10)
345345
#define __PPC_PRFX_R(r) (((r) & 0x1) << 20)
346+
#define __PPC_EH(eh) (((eh) & 0x1) << 0)
346347

347348
/*
348349
* Both low and high 16 bits are added as SIGNED additions, so if low 16 bits
@@ -359,16 +360,6 @@
359360
#define PPC_LI_MASK 0x03fffffc
360361
#define PPC_LI(v) ((v) & PPC_LI_MASK)
361362

362-
/*
363-
* Only use the larx hint bit on 64bit CPUs. e500v1/v2 based CPUs will treat a
364-
* larx with EH set as an illegal instruction.
365-
*/
366-
#ifdef CONFIG_PPC64
367-
#define __PPC_EH(eh) (((eh) & 0x1) << 0)
368-
#else
369-
#define __PPC_EH(eh) 0
370-
#endif
371-
372363
/* Base instruction encoding */
373364
#define PPC_RAW_CP_ABORT (0x7c00068c)
374365
#define PPC_RAW_COPY(a, b) (PPC_INST_COPY | ___PPC_RA(a) | ___PPC_RB(b))
@@ -580,7 +571,7 @@
580571

581572
#define PPC_RAW_BRANCH(offset) (0x48000000 | PPC_LI(offset))
582573
#define PPC_RAW_BL(offset) (0x48000001 | PPC_LI(offset))
583-
#define PPC_RAW_TW(t0, a, b) (0x7f000008 | ___PPC_RS(t0) | ___PPC_RA(a) | ___PPC_RB(b))
574+
#define PPC_RAW_TW(t0, a, b) (0x7c000008 | ___PPC_RS(t0) | ___PPC_RA(a) | ___PPC_RB(b))
584575
#define PPC_RAW_TRAP() PPC_RAW_TW(31, 0, 0)
585576
#define PPC_RAW_SETB(t, bfa) (0x7c000100 | ___PPC_RT(t) | ___PPC_RA((bfa) << 2))
586577

arch/powerpc/include/asm/simple_spinlock.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,19 @@ static inline int arch_spin_is_locked(arch_spinlock_t *lock)
4848
static inline unsigned long __arch_spin_trylock(arch_spinlock_t *lock)
4949
{
5050
unsigned long tmp, token;
51+
unsigned int eh = IS_ENABLED(CONFIG_PPC64);
5152

5253
token = LOCK_TOKEN;
5354
__asm__ __volatile__(
54-
"1: lwarx %0,0,%2,1\n\
55+
"1: lwarx %0,0,%2,%[eh]\n\
5556
cmpwi 0,%0,0\n\
5657
bne- 2f\n\
5758
stwcx. %1,0,%2\n\
5859
bne- 1b\n"
5960
PPC_ACQUIRE_BARRIER
6061
"2:"
6162
: "=&r" (tmp)
62-
: "r" (token), "r" (&lock->slock)
63+
: "r" (token), "r" (&lock->slock), [eh] "n" (eh)
6364
: "cr0", "memory");
6465

6566
return tmp;
@@ -156,17 +157,18 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock)
156157
static inline long __arch_read_trylock(arch_rwlock_t *rw)
157158
{
158159
long tmp;
160+
unsigned int eh = IS_ENABLED(CONFIG_PPC64);
159161

160162
__asm__ __volatile__(
161-
"1: lwarx %0,0,%1,1\n"
163+
"1: lwarx %0,0,%1,%[eh]\n"
162164
__DO_SIGN_EXTEND
163165
" addic. %0,%0,1\n\
164166
ble- 2f\n"
165167
" stwcx. %0,0,%1\n\
166168
bne- 1b\n"
167169
PPC_ACQUIRE_BARRIER
168170
"2:" : "=&r" (tmp)
169-
: "r" (&rw->lock)
171+
: "r" (&rw->lock), [eh] "n" (eh)
170172
: "cr0", "xer", "memory");
171173

172174
return tmp;
@@ -179,17 +181,18 @@ static inline long __arch_read_trylock(arch_rwlock_t *rw)
179181
static inline long __arch_write_trylock(arch_rwlock_t *rw)
180182
{
181183
long tmp, token;
184+
unsigned int eh = IS_ENABLED(CONFIG_PPC64);
182185

183186
token = WRLOCK_TOKEN;
184187
__asm__ __volatile__(
185-
"1: lwarx %0,0,%2,1\n\
188+
"1: lwarx %0,0,%2,%[eh]\n\
186189
cmpwi 0,%0,0\n\
187190
bne- 2f\n"
188191
" stwcx. %1,0,%2\n\
189192
bne- 1b\n"
190193
PPC_ACQUIRE_BARRIER
191194
"2:" : "=&r" (tmp)
192-
: "r" (token), "r" (&rw->lock)
195+
: "r" (token), "r" (&rw->lock), [eh] "n" (eh)
193196
: "cr0", "memory");
194197

195198
return tmp;

arch/powerpc/kernel/trace/ftrace.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,11 @@ int ftrace_make_nop(struct module *mod,
393393
*/
394394
static bool expected_nop_sequence(void *ip, ppc_inst_t op0, ppc_inst_t op1)
395395
{
396-
if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V1))
396+
if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS))
397+
return ppc_inst_equal(op0, ppc_inst(PPC_RAW_NOP()));
398+
else
397399
return ppc_inst_equal(op0, ppc_inst(PPC_RAW_BRANCH(8))) &&
398400
ppc_inst_equal(op1, ppc_inst(PPC_INST_LD_TOC));
399-
else
400-
return ppc_inst_equal(op0, ppc_inst(PPC_RAW_NOP()));
401401
}
402402

403403
static int
@@ -412,7 +412,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
412412
if (copy_inst_from_kernel_nofault(op, ip))
413413
return -EFAULT;
414414

415-
if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V1) &&
415+
if (!IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS) &&
416416
copy_inst_from_kernel_nofault(op + 1, ip + 4))
417417
return -EFAULT;
418418

arch/powerpc/kexec/file_load_64.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,17 +1043,17 @@ static int copy_property(void *fdt, int node_offset, const struct device_node *d
10431043
const char *propname)
10441044
{
10451045
const void *prop, *fdtprop;
1046-
int len = 0, fdtlen = 0, ret;
1046+
int len = 0, fdtlen = 0;
10471047

10481048
prop = of_get_property(dn, propname, &len);
10491049
fdtprop = fdt_getprop(fdt, node_offset, propname, &fdtlen);
10501050

10511051
if (fdtprop && !prop)
1052-
ret = fdt_delprop(fdt, node_offset, propname);
1052+
return fdt_delprop(fdt, node_offset, propname);
10531053
else if (prop)
1054-
ret = fdt_setprop(fdt, node_offset, propname, prop, len);
1055-
1056-
return ret;
1054+
return fdt_setprop(fdt, node_offset, propname, prop, len);
1055+
else
1056+
return -FDT_ERR_NOTFOUND;
10571057
}
10581058

10591059
static int update_pci_dma_nodes(void *fdt, const char *dmapropname)

0 commit comments

Comments
 (0)