Skip to content

Commit

Permalink
riscv: Call riscv_user_isa_enable() only on the boot hart
Browse files Browse the repository at this point in the history
Now that the [ms]envcfg CSR value is maintained per thread, not per
hart, riscv_user_isa_enable() only needs to be called once during boot,
to set the value for the init task. This also allows it to be marked as
__init.

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Deepak Gupta <debug@rivosinc.com>
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
Link: https://lore.kernel.org/r/20240814081126.956287-4-samuel.holland@sifive.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
  • Loading branch information
Samuel Holland authored and Palmer Dabbelt committed Oct 5, 2024

Unverified

No user is associated with the committer email.
1 parent 5fc7355 commit 368546e
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion arch/riscv/include/asm/cpufeature.h
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ DECLARE_PER_CPU(struct riscv_cpuinfo, riscv_cpuinfo);
/* Per-cpu ISA extensions. */
extern struct riscv_isainfo hart_isa[NR_CPUS];

void riscv_user_isa_enable(void);
void __init riscv_user_isa_enable(void);

#define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size, _validate) { \
.name = #_name, \
4 changes: 2 additions & 2 deletions arch/riscv/kernel/cpufeature.c
Original file line number Diff line number Diff line change
@@ -920,12 +920,12 @@ unsigned long riscv_get_elf_hwcap(void)
return hwcap;
}

void riscv_user_isa_enable(void)
void __init riscv_user_isa_enable(void)
{
if (riscv_has_extension_unlikely(RISCV_ISA_EXT_ZICBOZ))
current->thread.envcfg |= ENVCFG_CBZE;
else if (any_cpu_has_zicboz)
pr_warn_once("Zicboz disabled as it is unavailable on some harts\n");
pr_warn("Zicboz disabled as it is unavailable on some harts\n");
}

#ifdef CONFIG_RISCV_ALTERNATIVE
2 changes: 0 additions & 2 deletions arch/riscv/kernel/smpboot.c
Original file line number Diff line number Diff line change
@@ -233,8 +233,6 @@ asmlinkage __visible void smp_callin(void)
numa_add_cpu(curr_cpuid);
set_cpu_online(curr_cpuid, true);

riscv_user_isa_enable();

/*
* Remote cache and TLB flushes are ignored while the CPU is offline,
* so flush them both right now just in case.

0 comments on commit 368546e

Please sign in to comment.