Skip to content

Commit

Permalink
riscv: Constify sbi_ipi_ops
Browse files Browse the repository at this point in the history
Constify the sbi_ipi_ops so that it will be placed in the .rodata
section. This will cause attempts to modify it to fail when strict
page permissions are in place.

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
  • Loading branch information
Jisheng Zhang authored and Palmer Dabbelt committed Apr 26, 2021
1 parent e6a3022 commit 300f62c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions arch/riscv/include/asm/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int riscv_hartid_to_cpuid(int hartid);
void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out);

/* Set custom IPI operations */
void riscv_set_ipi_ops(struct riscv_ipi_ops *ops);
void riscv_set_ipi_ops(const struct riscv_ipi_ops *ops);

/* Clear IPI for current CPU */
void riscv_clear_ipi(void);
Expand Down Expand Up @@ -92,7 +92,7 @@ static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in,
cpumask_set_cpu(boot_cpu_hartid, out);
}

static inline void riscv_set_ipi_ops(struct riscv_ipi_ops *ops)
static inline void riscv_set_ipi_ops(const struct riscv_ipi_ops *ops)
{
}

Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/kernel/sbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ static void sbi_send_cpumask_ipi(const struct cpumask *target)
sbi_send_ipi(cpumask_bits(&hartid_mask));
}

static struct riscv_ipi_ops sbi_ipi_ops = {
static const struct riscv_ipi_ops sbi_ipi_ops = {
.ipi_inject = sbi_send_cpumask_ipi
};

Expand Down
4 changes: 2 additions & 2 deletions arch/riscv/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ static void ipi_stop(void)
wait_for_interrupt();
}

static struct riscv_ipi_ops *ipi_ops __ro_after_init;
static const struct riscv_ipi_ops *ipi_ops __ro_after_init;

void riscv_set_ipi_ops(struct riscv_ipi_ops *ops)
void riscv_set_ipi_ops(const struct riscv_ipi_ops *ops)
{
ipi_ops = ops;
}
Expand Down

0 comments on commit 300f62c

Please sign in to comment.