Commit e8c328d7 authored by Mark Rutland's avatar Mark Rutland Committed by Will Deacon
Browse files

arm64: extable: make fixup_exception() return bool



The return values of fixup_exception() and arm64_bpf_fixup_exception()
represent a boolean condition rather than an error code, so for clarity
it would be better to return `bool` rather than `int`.

This patch adjusts the code accordingly. While we're modifying the
prototype, we also remove the unnecessary `extern` keyword, so that this
won't look out of place when we make subsequent additions to the header.

There should be no functional change as a result of this patch.

Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: James Morse <james.morse@arm.com>
Cc: Jean-Philippe Brucker <jean-philippe@linaro.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20211019160219.5202-9-mark.rutland@arm.com


Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 819771cc
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -32,16 +32,16 @@ static inline bool in_bpf_jit(struct pt_regs *regs)
}

#ifdef CONFIG_BPF_JIT
int arm64_bpf_fixup_exception(const struct exception_table_entry *ex,
bool arm64_bpf_fixup_exception(const struct exception_table_entry *ex,
			      struct pt_regs *regs);
#else /* !CONFIG_BPF_JIT */
static inline
int arm64_bpf_fixup_exception(const struct exception_table_entry *ex,
bool arm64_bpf_fixup_exception(const struct exception_table_entry *ex,
			       struct pt_regs *regs)
{
	return 0;
	return false;
}
#endif /* !CONFIG_BPF_JIT */

extern int fixup_exception(struct pt_regs *regs);
bool fixup_exception(struct pt_regs *regs);
#endif
+3 −3
Original line number Diff line number Diff line
@@ -6,17 +6,17 @@
#include <linux/extable.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(instruction_pointer(regs));
	if (!fixup)
		return 0;
		return false;

	if (in_bpf_jit(regs))
		return arm64_bpf_fixup_exception(fixup, regs);

	regs->pc = (unsigned long)&fixup->fixup + fixup->fixup;
	return 1;
	return true;
}
+3 −3
Original line number Diff line number Diff line
@@ -358,7 +358,7 @@ static void build_epilogue(struct jit_ctx *ctx)
#define BPF_FIXUP_OFFSET_MASK	GENMASK(26, 0)
#define BPF_FIXUP_REG_MASK	GENMASK(31, 27)

int arm64_bpf_fixup_exception(const struct exception_table_entry *ex,
bool arm64_bpf_fixup_exception(const struct exception_table_entry *ex,
			       struct pt_regs *regs)
{
	off_t offset = FIELD_GET(BPF_FIXUP_OFFSET_MASK, ex->fixup);
@@ -366,7 +366,7 @@ int arm64_bpf_fixup_exception(const struct exception_table_entry *ex,

	regs->regs[dst_reg] = 0;
	regs->pc = (unsigned long)&ex->fixup - offset;
	return 1;
	return true;
}

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