[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211118192414.2c574541@xhacker>
Date: Thu, 18 Nov 2021 19:24:14 +0800
From: Jisheng Zhang <jszhang3@...l.ustc.edu.cn>
To: Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
"Björn Töpel" <bjorn@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Masahiro Yamada <masahiroy@...nel.org>,
Michal Marek <michal.lkml@...kovi.net>,
Nick Desaulniers <ndesaulniers@...gle.com>
Cc: Kefeng Wang <wangkefeng.wang@...wei.com>,
Tong Tiangen <tongtiangen@...wei.com>,
linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, bpf@...r.kernel.org,
linux-kbuild@...r.kernel.org
Subject: [PATCH 05/12] riscv: extable: make fixup_exception() return bool
From: Jisheng Zhang <jszhang@...nel.org>
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@...nel.org>
---
arch/riscv/include/asm/extable.h | 8 ++++----
arch/riscv/mm/extable.c | 6 +++---
arch/riscv/net/bpf_jit_comp64.c | 6 +++---
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/arch/riscv/include/asm/extable.h b/arch/riscv/include/asm/extable.h
index c48c020fcf4d..e4374dde02b4 100644
--- a/arch/riscv/include/asm/extable.h
+++ b/arch/riscv/include/asm/extable.h
@@ -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
diff --git a/arch/riscv/mm/extable.c b/arch/riscv/mm/extable.c
index cbb0db11b28f..d41bf38e37e9 100644
--- a/arch/riscv/mm/extable.c
+++ b/arch/riscv/mm/extable.c
@@ -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;
}
diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
index 2ca345c7b0bf..7714081cbb64 100644
--- a/arch/riscv/net/bpf_jit_comp64.c
+++ b/arch/riscv/net/bpf_jit_comp64.c
@@ -459,8 +459,8 @@ 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);
@@ -468,7 +468,7 @@ int rv_bpf_fixup_exception(const struct exception_table_entry *ex,
*(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 */
--
2.33.0
Powered by blists - more mailing lists