Skip to content

Commit 2a1944b

Browse files
committed
Merge tag 'riscv-for-linus-6.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: - A fix for cacheinfo DT probing to avoid reading non-boolean properties as booleans. - A fix for cpufeature to use bitmap_equal() instead of memcmp(), so unused bits are ignored. - Fixes for cmpxchg and futex cmpxchg that properly encode the sign extension requirements on inline asm, which results in spurious successes. This manifests in at least inode_set_ctime_current, but is likely just a disaster waiting to happen. - A fix for the rseq selftests, which was using an invalid constraint. - A pair of fixes for signal frame size handling: - We were reserving space for an extra empty extension context header on systems with extended signal context, thus resulting in unnecessarily large allocations. - We weren't properly checking for available extensions before calculating the signal stack size, which resulted in undersized stack allocations on some systems (at least those with T-Head custom vectors). Also, we've added Alex as a reviewer. He's been helping out a ton lately, thanks! * tag 'riscv-for-linus-6.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: MAINTAINERS: Add myself as a riscv reviewer riscv: signal: fix signal_minsigstksz riscv: signal: fix signal frame size rseq/selftests: Fix riscv rseq_offset_deref_addv inline asm riscv/futex: sign extend compare value in atomic cmpxchg riscv/atomic: Do proper sign extension also for unsigned in arch_cmpxchg riscv: cpufeature: use bitmap_equal() instead of memcmp() riscv: cacheinfo: Use of_property_present() for non-boolean properties
2 parents 2c24478 + 245aece commit 2a1944b

File tree

9 files changed

+15
-20
lines changed

9 files changed

+15
-20
lines changed

MAINTAINERS

+1
Original file line numberDiff line numberDiff line change
@@ -20328,6 +20328,7 @@ RISC-V ARCHITECTURE
2032820328
M: Paul Walmsley <[email protected]>
2032920329
M: Palmer Dabbelt <[email protected]>
2033020330
M: Albert Ou <[email protected]>
20331+
R: Alexandre Ghiti <[email protected]>
2033120332
2033220333
S: Supported
2033320334
Q: https://patchwork.kernel.org/project/linux-riscv/list/

arch/riscv/include/asm/cmpxchg.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
__arch_cmpxchg(".w", ".w" sc_sfx, ".w" cas_sfx, \
232232
sc_prepend, sc_append, \
233233
cas_prepend, cas_append, \
234-
__ret, __ptr, (long), __old, __new); \
234+
__ret, __ptr, (long)(int)(long), __old, __new); \
235235
break; \
236236
case 8: \
237237
__arch_cmpxchg(".d", ".d" sc_sfx, ".d" cas_sfx, \

arch/riscv/include/asm/futex.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
9393
_ASM_EXTABLE_UACCESS_ERR(1b, 3b, %[r]) \
9494
_ASM_EXTABLE_UACCESS_ERR(2b, 3b, %[r]) \
9595
: [r] "+r" (ret), [v] "=&r" (val), [u] "+m" (*uaddr), [t] "=&r" (tmp)
96-
: [ov] "Jr" (oldval), [nv] "Jr" (newval)
96+
: [ov] "Jr" ((long)(int)oldval), [nv] "Jr" (newval)
9797
: "memory");
9898
__disable_user_access();
9999

arch/riscv/kernel/cacheinfo.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ int populate_cache_leaves(unsigned int cpu)
108108
if (!np)
109109
return -ENOENT;
110110

111-
if (of_property_read_bool(np, "cache-size"))
111+
if (of_property_present(np, "cache-size"))
112112
ci_leaf_init(this_leaf++, CACHE_TYPE_UNIFIED, level);
113-
if (of_property_read_bool(np, "i-cache-size"))
113+
if (of_property_present(np, "i-cache-size"))
114114
ci_leaf_init(this_leaf++, CACHE_TYPE_INST, level);
115-
if (of_property_read_bool(np, "d-cache-size"))
115+
if (of_property_present(np, "d-cache-size"))
116116
ci_leaf_init(this_leaf++, CACHE_TYPE_DATA, level);
117117

118118
prev = np;
@@ -125,11 +125,11 @@ int populate_cache_leaves(unsigned int cpu)
125125
break;
126126
if (level <= levels)
127127
break;
128-
if (of_property_read_bool(np, "cache-size"))
128+
if (of_property_present(np, "cache-size"))
129129
ci_leaf_init(this_leaf++, CACHE_TYPE_UNIFIED, level);
130-
if (of_property_read_bool(np, "i-cache-size"))
130+
if (of_property_present(np, "i-cache-size"))
131131
ci_leaf_init(this_leaf++, CACHE_TYPE_INST, level);
132-
if (of_property_read_bool(np, "d-cache-size"))
132+
if (of_property_present(np, "d-cache-size"))
133133
ci_leaf_init(this_leaf++, CACHE_TYPE_DATA, level);
134134
levels = level;
135135
}

arch/riscv/kernel/cpufeature.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static void __init riscv_resolve_isa(unsigned long *source_isa,
479479
if (bit < RISCV_ISA_EXT_BASE)
480480
*this_hwcap |= isa2hwcap[bit];
481481
}
482-
} while (loop && memcmp(prev_resolved_isa, resolved_isa, sizeof(prev_resolved_isa)));
482+
} while (loop && !bitmap_equal(prev_resolved_isa, resolved_isa, RISCV_ISA_EXT_MAX));
483483
}
484484

485485
static void __init match_isa_ext(const char *name, const char *name_end, unsigned long *bitmap)

arch/riscv/kernel/setup.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ void __init setup_arch(char **cmdline_p)
322322

323323
riscv_init_cbo_blocksizes();
324324
riscv_fill_hwcap();
325-
init_rt_signal_env();
326325
apply_boot_alternatives();
326+
init_rt_signal_env();
327327

328328
if (IS_ENABLED(CONFIG_RISCV_ISA_ZICBOM) &&
329329
riscv_isa_extension_available(NULL, ZICBOM))

arch/riscv/kernel/signal.c

-6
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,6 @@ static size_t get_rt_frame_size(bool cal_all)
215215
if (cal_all || riscv_v_vstate_query(task_pt_regs(current)))
216216
total_context_size += riscv_v_sc_size;
217217
}
218-
/*
219-
* Preserved a __riscv_ctx_hdr for END signal context header if an
220-
* extension uses __riscv_extra_ext_header
221-
*/
222-
if (total_context_size)
223-
total_context_size += sizeof(struct __riscv_ctx_hdr);
224218

225219
frame_size += total_context_size;
226220

tools/testing/selftests/rseq/rseq-riscv-bits.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,16 @@ int RSEQ_TEMPLATE_IDENTIFIER(rseq_offset_deref_addv)(intptr_t *ptr, off_t off, i
243243
#ifdef RSEQ_COMPARE_TWICE
244244
RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, "%l[error1]")
245245
#endif
246-
RSEQ_ASM_OP_R_DEREF_ADDV(ptr, off, 3)
246+
RSEQ_ASM_OP_R_DEREF_ADDV(ptr, off, inc, 3)
247247
RSEQ_INJECT_ASM(4)
248248
RSEQ_ASM_DEFINE_ABORT(4, abort)
249249
: /* gcc asm goto does not allow outputs */
250250
: [cpu_id] "r" (cpu),
251251
[current_cpu_id] "m" (rseq_get_abi()->RSEQ_TEMPLATE_CPU_ID_FIELD),
252252
[rseq_cs] "m" (rseq_get_abi()->rseq_cs.arch.ptr),
253253
[ptr] "r" (ptr),
254-
[off] "er" (off),
255-
[inc] "er" (inc)
254+
[off] "r" (off),
255+
[inc] "r" (inc)
256256
RSEQ_INJECT_INPUT
257257
: "memory", RSEQ_ASM_TMP_REG_1
258258
RSEQ_INJECT_CLOBBER

tools/testing/selftests/rseq/rseq-riscv.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ do { \
158158
"bnez " RSEQ_ASM_TMP_REG_1 ", 222b\n" \
159159
"333:\n"
160160

161-
#define RSEQ_ASM_OP_R_DEREF_ADDV(ptr, off, post_commit_label) \
161+
#define RSEQ_ASM_OP_R_DEREF_ADDV(ptr, off, inc, post_commit_label) \
162162
"mv " RSEQ_ASM_TMP_REG_1 ", %[" __rseq_str(ptr) "]\n" \
163163
RSEQ_ASM_OP_R_ADD(off) \
164164
REG_L RSEQ_ASM_TMP_REG_1 ", 0(" RSEQ_ASM_TMP_REG_1 ")\n" \

0 commit comments

Comments
 (0)