Skip to content

Commit

Permalink
riscv: extable: make fixup_exception() return bool
Browse files Browse the repository at this point in the history
The return values of fixup_exception() and riscv_bpf_fixup_exception()
represent a boolean condition rather than an error code, so it's better
to return `bool` rather than `int`.

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
  • Loading branch information
Jisheng Zhang authored and Palmer Dabbelt committed Jan 6, 2022
1 parent c07935c commit ef127bc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions arch/riscv/include/asm/extable.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ struct exception_table_entry {

#define ARCH_HAS_RELATIVE_EXTABLE

int fixup_exception(struct pt_regs *regs);
bool fixup_exception(struct pt_regs *regs);

#if defined(CONFIG_BPF_JIT) && defined(CONFIG_ARCH_RV64I)
int rv_bpf_fixup_exception(const struct exception_table_entry *ex, struct pt_regs *regs);
bool rv_bpf_fixup_exception(const struct exception_table_entry *ex, struct pt_regs *regs);
#else
static inline int
static inline bool
rv_bpf_fixup_exception(const struct exception_table_entry *ex,
struct pt_regs *regs)
{
return 0;
return false;
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions arch/riscv/mm/extable.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
#include <linux/module.h>
#include <linux/uaccess.h>

int fixup_exception(struct pt_regs *regs)
bool fixup_exception(struct pt_regs *regs)
{
const struct exception_table_entry *fixup;

fixup = search_exception_tables(regs->epc);
if (!fixup)
return 0;
return false;

if (regs->epc >= BPF_JIT_REGION_START && regs->epc < BPF_JIT_REGION_END)
return rv_bpf_fixup_exception(fixup, regs);

regs->epc = (unsigned long)&fixup->fixup + fixup->fixup;
return 1;
return true;
}
6 changes: 3 additions & 3 deletions arch/riscv/net/bpf_jit_comp64.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,16 +459,16 @@ static int emit_call(bool fixed, u64 addr, struct rv_jit_context *ctx)
#define BPF_FIXUP_OFFSET_MASK GENMASK(26, 0)
#define BPF_FIXUP_REG_MASK GENMASK(31, 27)

int rv_bpf_fixup_exception(const struct exception_table_entry *ex,
struct pt_regs *regs)
bool rv_bpf_fixup_exception(const struct exception_table_entry *ex,
struct pt_regs *regs)
{
off_t offset = FIELD_GET(BPF_FIXUP_OFFSET_MASK, ex->fixup);
int regs_offset = FIELD_GET(BPF_FIXUP_REG_MASK, ex->fixup);

*(unsigned long *)((void *)regs + pt_regmap[regs_offset]) = 0;
regs->epc = (unsigned long)&ex->fixup - offset;

return 1;
return true;
}

/* For accesses to BTF pointers, add an entry to the exception table */
Expand Down

0 comments on commit ef127bc

Please sign in to comment.