Skip to content

Commit 00e6982

Browse files
committed
Merge tag 'riscv-for-linus-6.17-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Paul Walmsley: - LTO fix for clang when building with CONFIG_CMODEL_MEDLOW - Fix for ACPI CPPC CSR read/write return values - Several fixes for incorrect access widths in thread_info.cpu reads - Fix an issue in __put_user_nocheck() that was causing the glibc tst-socket-timestamp test to fail - Initialize struct kexec_buf records in several kexec-related functions, which were generating UBSAN warnings - Two fixes for sparse warnings * tag 'riscv-for-linus-6.17-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: Fix sparse warning about different address spaces riscv: Fix sparse warning in __get_user_error() riscv: kexec: Initialize kexec_buf struct riscv: use lw when reading int cpu in asm_per_cpu riscv, bpf: use lw when reading int cpu in bpf_get_smp_processor_id riscv, bpf: use lw when reading int cpu in BPF_MOV64_PERCPU_REG riscv: uaccess: fix __put_user_nocheck for unaligned accesses riscv: use lw when reading int cpu in new_vmalloc_check ACPI: RISC-V: Fix FFH_CPPC_CSR error handling riscv: Only allow LTO with CMODEL_MEDANY
2 parents b236920 + a03ee11 commit 00e6982

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

arch/riscv/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ config RISCV
6565
select ARCH_SUPPORTS_HUGE_PFNMAP if TRANSPARENT_HUGEPAGE
6666
select ARCH_SUPPORTS_HUGETLBFS if MMU
6767
# LLD >= 14: https://github.com/llvm/llvm-project/issues/50505
68-
select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000
68+
select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000 && CMODEL_MEDANY
6969
select ARCH_SUPPORTS_LTO_CLANG_THIN if LLD_VERSION >= 140000
7070
select ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS if 64BIT && MMU
7171
select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU

arch/riscv/include/asm/asm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
#endif
9292

9393
.macro asm_per_cpu dst sym tmp
94-
REG_L \tmp, TASK_TI_CPU_NUM(tp)
94+
lw \tmp, TASK_TI_CPU_NUM(tp)
9595
slli \tmp, \tmp, PER_CPU_OFFSET_SHIFT
9696
la \dst, __per_cpu_offset
9797
add \dst, \dst, \tmp

arch/riscv/include/asm/uaccess.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ do { \
209209
err = 0; \
210210
break; \
211211
__gu_failed: \
212-
x = 0; \
212+
x = (__typeof__(x))0; \
213213
err = -EFAULT; \
214214
} while (0)
215215

@@ -311,7 +311,7 @@ do { \
311311
do { \
312312
if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && \
313313
!IS_ALIGNED((uintptr_t)__gu_ptr, sizeof(*__gu_ptr))) { \
314-
__inttype(x) ___val = (__inttype(x))x; \
314+
__typeof__(*(__gu_ptr)) ___val = (x); \
315315
if (__asm_copy_to_user_sum_enabled(__gu_ptr, &(___val), sizeof(*__gu_ptr))) \
316316
goto label; \
317317
break; \
@@ -438,10 +438,10 @@ unsigned long __must_check clear_user(void __user *to, unsigned long n)
438438
}
439439

440440
#define __get_kernel_nofault(dst, src, type, err_label) \
441-
__get_user_nocheck(*((type *)(dst)), (type *)(src), err_label)
441+
__get_user_nocheck(*((type *)(dst)), (__force __user type *)(src), err_label)
442442

443443
#define __put_kernel_nofault(dst, src, type, err_label) \
444-
__put_user_nocheck(*((type *)(src)), (type *)(dst), err_label)
444+
__put_user_nocheck(*((type *)(src)), (__force __user type *)(dst), err_label)
445445

446446
static __must_check __always_inline bool user_access_begin(const void __user *ptr, size_t len)
447447
{

arch/riscv/kernel/entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* a0 = &new_vmalloc[BIT_WORD(cpu)]
4747
* a1 = BIT_MASK(cpu)
4848
*/
49-
REG_L a2, TASK_TI_CPU(tp)
49+
lw a2, TASK_TI_CPU(tp)
5050
/*
5151
* Compute the new_vmalloc element position:
5252
* (cpu / 64) * 8 = (cpu >> 6) << 3

arch/riscv/kernel/kexec_elf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static int riscv_kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
2828
int i;
2929
int ret = 0;
3030
size_t size;
31-
struct kexec_buf kbuf;
31+
struct kexec_buf kbuf = {};
3232
const struct elf_phdr *phdr;
3333

3434
kbuf.image = image;
@@ -66,7 +66,7 @@ static int elf_find_pbase(struct kimage *image, unsigned long kernel_len,
6666
{
6767
int i;
6868
int ret;
69-
struct kexec_buf kbuf;
69+
struct kexec_buf kbuf = {};
7070
const struct elf_phdr *phdr;
7171
unsigned long lowest_paddr = ULONG_MAX;
7272
unsigned long lowest_vaddr = ULONG_MAX;

arch/riscv/kernel/kexec_image.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static void *image_load(struct kimage *image,
4141
struct riscv_image_header *h;
4242
u64 flags;
4343
bool be_image, be_kernel;
44-
struct kexec_buf kbuf;
44+
struct kexec_buf kbuf = {};
4545
int ret;
4646

4747
/* Check Image header */

arch/riscv/kernel/machine_kexec_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ int load_extra_segments(struct kimage *image, unsigned long kernel_start,
261261
int ret;
262262
void *fdt;
263263
unsigned long initrd_pbase = 0UL;
264-
struct kexec_buf kbuf;
264+
struct kexec_buf kbuf = {};
265265
char *modified_cmdline = NULL;
266266

267267
kbuf.image = image;

arch/riscv/net/bpf_jit_comp64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
13561356
emit_mv(rd, rs, ctx);
13571357
#ifdef CONFIG_SMP
13581358
/* Load current CPU number in T1 */
1359-
emit_ld(RV_REG_T1, offsetof(struct thread_info, cpu),
1359+
emit_lw(RV_REG_T1, offsetof(struct thread_info, cpu),
13601360
RV_REG_TP, ctx);
13611361
/* Load address of __per_cpu_offset array in T2 */
13621362
emit_addr(RV_REG_T2, (u64)&__per_cpu_offset, extra_pass, ctx);
@@ -1763,7 +1763,7 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
17631763
*/
17641764
if (insn->src_reg == 0 && insn->imm == BPF_FUNC_get_smp_processor_id) {
17651765
/* Load current CPU number in R0 */
1766-
emit_ld(bpf_to_rv_reg(BPF_REG_0, ctx), offsetof(struct thread_info, cpu),
1766+
emit_lw(bpf_to_rv_reg(BPF_REG_0, ctx), offsetof(struct thread_info, cpu),
17671767
RV_REG_TP, ctx);
17681768
break;
17691769
}

drivers/acpi/riscv/cppc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ int cpc_read_ffh(int cpu, struct cpc_reg *reg, u64 *val)
119119

120120
*val = data.ret.value;
121121

122-
return (data.ret.error) ? sbi_err_map_linux_errno(data.ret.error) : 0;
122+
return data.ret.error;
123123
}
124124

125125
return -EINVAL;
@@ -148,7 +148,7 @@ int cpc_write_ffh(int cpu, struct cpc_reg *reg, u64 val)
148148

149149
smp_call_function_single(cpu, cppc_ffh_csr_write, &data, 1);
150150

151-
return (data.ret.error) ? sbi_err_map_linux_errno(data.ret.error) : 0;
151+
return data.ret.error;
152152
}
153153

154154
return -EINVAL;

0 commit comments

Comments
 (0)