Skip to content

Commit 590cae7

Browse files
committed
Merge tag 'riscv-for-linus-7.2-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Paul Walmsley: - Fix a crash when a kretprobe reads from the stack - Fix an issue with the build-time mcount sorter that broke ftrace - Fix the rv32 IRQ stack frame padding to match the ABI - Only defer IOMMU configuration during initialization. This avoids an issue where IOMMU configuration could be indefinitely deferred - Add the missing build salt to the vDSO - Now that RISC-V systems with higher numbers of cores are starting to become available, raise NR_CPUS for RISC-V to 256 - Clean up some warnings from sparse caused by the RISC-V-optimized RAID6 code - Clean up our __cpu_up() code with a few minor fixes * tag 'riscv-for-linus-7.2-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: probes: save original sp in rethook trampoline riscv: Fix 32-bit call_on_irq_stack() frame pointer ABI scripts/sorttable: Handle RISC-V patchable ftrace entries riscv: smp: use secs_to_jiffies in __cpu_up ACPI: RIMT: Only defer the IOMMU configuration in init stage riscv: Add build salt to the vDSO raid6: fix raid6_recov_rvv symbol undeclared warning raid6: fix riscv symbol undeclared warnigns riscv: Raise default NR_CPUS for 64BIT to 256
2 parents 6cf48bf + bc7b086 commit 590cae7

10 files changed

Lines changed: 30 additions & 16 deletions

File tree

arch/riscv/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,8 @@ config NR_CPUS
454454
range 2 32 if RISCV_SBI_V01 && 32BIT
455455
range 2 64 if RISCV_SBI_V01 && 64BIT
456456
default "32" if 32BIT
457-
default "64" if 64BIT
457+
default "64" if RISCV_SBI_V01 && 64BIT
458+
default "256" if !RISCV_SBI_V01 && 64BIT
458459

459460
config HOTPLUG_CPU
460461
bool "Support for hot-pluggable CPUs"

arch/riscv/kernel/asm-offsets.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,8 @@ void asm_offsets(void)
501501
OFFSET(SBI_HART_BOOT_STACK_PTR_OFFSET, sbi_hart_boot_data, stack_ptr);
502502

503503
DEFINE(STACKFRAME_SIZE_ON_STACK, ALIGN(sizeof(struct stackframe), STACK_ALIGN));
504-
OFFSET(STACKFRAME_FP, stackframe, fp);
505-
OFFSET(STACKFRAME_RA, stackframe, ra);
504+
DEFINE(STACKFRAME_FP, offsetof(struct stackframe, fp) - sizeof(struct stackframe));
505+
DEFINE(STACKFRAME_RA, offsetof(struct stackframe, ra) - sizeof(struct stackframe));
506506
#ifdef CONFIG_FUNCTION_TRACER
507507
DEFINE(FTRACE_OPS_FUNC, offsetof(struct ftrace_ops, func));
508508
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS

arch/riscv/kernel/entry.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ SYM_CODE_END(ret_from_fork_user_asm)
386386
SYM_FUNC_START(call_on_irq_stack)
387387
/* Create a frame record to save ra and s0 (fp) */
388388
addi sp, sp, -STACKFRAME_SIZE_ON_STACK
389-
REG_S ra, STACKFRAME_RA(sp)
390-
REG_S s0, STACKFRAME_FP(sp)
389+
REG_S ra, (STACKFRAME_SIZE_ON_STACK + STACKFRAME_RA)(sp)
390+
REG_S s0, (STACKFRAME_SIZE_ON_STACK + STACKFRAME_FP)(sp)
391391
addi s0, sp, STACKFRAME_SIZE_ON_STACK
392392

393393
/* Switch to the per-CPU shadow call stack */
@@ -405,8 +405,8 @@ SYM_FUNC_START(call_on_irq_stack)
405405

406406
/* Switch back to the thread stack and restore ra and s0 */
407407
addi sp, s0, -STACKFRAME_SIZE_ON_STACK
408-
REG_L ra, STACKFRAME_RA(sp)
409-
REG_L s0, STACKFRAME_FP(sp)
408+
REG_L ra, (STACKFRAME_SIZE_ON_STACK + STACKFRAME_RA)(sp)
409+
REG_L s0, (STACKFRAME_SIZE_ON_STACK + STACKFRAME_FP)(sp)
410410
addi sp, sp, STACKFRAME_SIZE_ON_STACK
411411

412412
ret

arch/riscv/kernel/probes/rethook_trampoline.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
REG_S x29, PT_T4(sp)
4242
REG_S x30, PT_T5(sp)
4343
REG_S x31, PT_T6(sp)
44+
/* save original sp */
45+
addi a0, sp, PT_SIZE_ON_STACK
46+
REG_S a0, PT_SP(sp)
4447
.endm
4548

4649
.macro restore_all_base_regs

arch/riscv/kernel/smpboot.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,12 @@ int arch_cpuhp_kick_ap_alive(unsigned int cpu, struct task_struct *tidle)
189189
#else
190190
int __cpu_up(unsigned int cpu, struct task_struct *tidle)
191191
{
192-
int ret = 0;
192+
int ret;
193193
tidle->thread_info.cpu = cpu;
194194

195195
ret = start_secondary_cpu(cpu, tidle);
196196
if (!ret) {
197-
wait_for_completion_timeout(&cpu_running,
198-
msecs_to_jiffies(1000));
197+
wait_for_completion_timeout(&cpu_running, secs_to_jiffies(1));
199198

200199
if (!cpu_online(cpu)) {
201200
pr_crit("CPU%u: failed to come online\n", cpu);

arch/riscv/kernel/vdso/note.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Here we can supply some information useful to userland.
55
*/
66

7+
#include <linux/build-salt.h>
78
#include <linux/elfnote.h>
89
#include <linux/version.h>
910
#include <asm/assembler.h>
@@ -12,4 +13,6 @@ ELFNOTE_START(Linux, 0, "a")
1213
.long LINUX_VERSION_CODE
1314
ELFNOTE_END
1415

16+
BUILD_SALT
17+
1518
emit_riscv_feature_1_and

drivers/acpi/riscv/rimt.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <linux/acpi.h>
1111
#include <linux/acpi_rimt.h>
12+
#include <linux/device/driver.h>
1213
#include <linux/iommu.h>
1314
#include <linux/list.h>
1415
#include <linux/pci.h>
@@ -257,11 +258,11 @@ static int rimt_iommu_xlate(struct device *dev, struct acpi_rimt_node *node, u32
257258
rimt_fwnode = rimt_get_fwnode(node);
258259

259260
/*
260-
* The IOMMU drivers may not be probed yet.
261-
* Defer the IOMMU configuration
261+
* The IOMMU drivers may not be probed yet. Defer the IOMMU
262+
* configuration if it's still in initialization stage.
262263
*/
263264
if (!rimt_fwnode)
264-
return -EPROBE_DEFER;
265+
return driver_deferred_probe_check_state(dev);
265266

266267
/*
267268
* EPROBE_DEFER ensures IOMMU is probed before the devices that

lib/raid/raid6/riscv/recov_rvv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/raid/pq.h>
99
#include "algos.h"
1010
#include "rvv.h"
11+
#include "pq_arch.h"
1112

1213
static void __raid6_2data_recov_rvv(int bytes, u8 *p, u8 *q, u8 *dp,
1314
u8 *dq, const u8 *pbmul,

lib/raid/raid6/riscv/rvv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#include "rvv.h"
13+
#include "pq_arch.h"
1314

1415
#ifdef __riscv_vector
1516
#error "This code must be built without compiler support for vector"

scripts/sorttable.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -891,17 +891,22 @@ static int do_file(char const *const fname, void *addr)
891891
table_sort_t custom_sort = NULL;
892892

893893
switch (elf_map_machine(ehdr)) {
894-
case EM_AARCH64:
895894
#ifdef MCOUNT_SORT_ENABLED
895+
case EM_AARCH64:
896+
/* arm64 also needs RELA-based weak-function fixups. */
896897
sort_reloc = true;
897898
rela_type = 0x403;
898-
/* arm64 uses patchable function entry placing before function */
899+
/* fallthrough */
900+
case EM_RISCV:
901+
/* arm64 and RISC-V place patchable entries before the function. */
899902
before_func = 8;
903+
#else
904+
case EM_AARCH64:
905+
case EM_RISCV:
900906
#endif
901907
/* fallthrough */
902908
case EM_386:
903909
case EM_LOONGARCH:
904-
case EM_RISCV:
905910
case EM_S390:
906911
case EM_X86_64:
907912
custom_sort = sort_relative_table_with_data;

0 commit comments

Comments
 (0)