riscv, bpf: Fix RV32 broken build, and silence RV64 warning
Subsystems (5)
Björn Töpel
maintainerPATCH 1/1 riscv, bpf: Fix RV32 broken build, and silence RV64 warning
Commit 252c765bd764 ("riscv, bpf: Add BPF exception tables") only addressed RV64, and broke the RV32 build [1]. Fix by gating the exception tables code with CONFIG_ARCH_RV64I.
Further, silence a "-Wmissing-prototypes" warning [2] in the RV64 BPF JIT.
[1] https://lore.kernel.org/llvm/[email protected]/
[2] https://lore.kernel.org/llvm/[email protected]/
---
Tong/Daniel: The RV32 build has been broken since Thursday. I'll try to fast-track a bit, and commit a quick-fix for it. Hope that's OK with you, Tong!
I've verified the build on my machine using riscv32 GCC 9.3.0 and riscv64 GCC 11.2.0.
Björn
---arch/riscv/mm/extable.c | 4 ++--
arch/riscv/net/bpf_jit_comp64.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
arch/riscv/mm/extable.c +2 -2
@@ -11,7 +11,7 @@#include <linux/module.h> #include <linux/uaccess.h> -#ifdef CONFIG_BPF_JIT +#if defined(CONFIG_BPF_JIT ) && defined(CONFIG_ARCH_RV64I )int rv_bpf_fixup_exception (const struct exception_table_entry *ex,struct pt_regs *regs);#endif
@@ -23,7 +23,7 @@ int fixup_exception(struct pt_regs *regs)if (!fixup)return 0 ; -#ifdef CONFIG_BPF_JIT +#if defined(CONFIG_BPF_JIT ) && defined(CONFIG_ARCH_RV64I )if (regs->epc >=BPF_JIT_REGION_START && regs->epc <BPF_JIT_REGION_END )return rv_bpf_fixup_exception (fixup, regs);#endif
arch/riscv/net/bpf_jit_comp64.c +2 -0
@@ -459,6 +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);int rv_bpf_fixup_exception (const struct exception_table_entry *ex,struct pt_regs *regs) {
base-commit: cc0356d6a02e064387c16a83cb96fe43ef33181e
Signature · 1 line
2.32.0
Daniel Borkmann
maintainerQuoted 12 lines · Björn Töpel
Commit
252c765bd764("riscv, bpf: Add BPF exception tables") only addressed RV64, and broke the RV32 build [1]. Fix by gating the exception tables code withCONFIG_ARCH_RV64I.Further, silence a "-Wmissing-prototypes" warning [2] in the RV64 BPF JIT.
[1] https://lore.kernel.org/llvm/[email protected]/
[2] https://lore.kernel.org/llvm/[email protected]/Fixes 252c765bd764 ("riscv, bpf: Add BPF exception tables")Signed-off-by Björn Töpel <[email protected]>
Quoted 7 lines
---
Tong/Daniel: The RV32 build has been broken since Thursday. I'll try to fast-track a bit, and commit a quick-fix for it. Hope that's OK with you, Tong!I've verified the build on my machine using riscv32 GCC 9.3.0 and riscv64 GCC 11.2.0.
Thanks for the fix Bjorn!
Quoted 31 lines
arch/riscv/mm/extable.c| 4 ++--arch/riscv/net/bpf_jit_comp64.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)arch/riscv/mm/extable.c +2
-2@@ -11,7 +11,7 @@#include <linux/module.h> #include <linux/uaccess.h> -#ifdef CONFIG_BPF_JIT +#if defined(CONFIG_BPF_JIT ) && defined(CONFIG_ARCH_RV64I )int rv_bpf_fixup_exception (const struct exception_table_entry *ex,struct pt_regs *regs);#endif @@ -23,7 +23,7 @@ int fixup_exception(struct pt_regs *regs)if (!fixup)return 0 ; -#ifdef CONFIG_BPF_JIT +#if defined(CONFIG_BPF_JIT ) && defined(CONFIG_ARCH_RV64I )if (regs->epc >=BPF_JIT_REGION_START && regs->epc <BPF_JIT_REGION_END )return rv_bpf_fixup_exception (fixup, regs);#endif arch/riscv/net/bpf_jit_comp64.c +0
-0
arch/riscv/net/bpf_jit_comp64.c static int emit_call(bool fixed, u64 addr, struct rv_jit_context *ctx) · line 463
Quoted 5 lines
arch/riscv/net/bpf_jit_comp64.c +2
-0@@ -459,6 +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);
I'm okay to take this as a quick fix, but if its not too much hassle, could we add a arch/riscv/include/asm/extable.h in similar fashion like arm64 or x86 where we move the ex_handler_bpf() signature there, did you have a chance to check?
Quoted 6 lines
arch/riscv/net/bpf_jit_comp64.c +0
-0int rv_bpf_fixup_exception (const struct exception_table_entry *ex,struct pt_regs *regs) {base-commit:
cc0356d6a02e064387c16a83cb96fe43ef33181e
Thanks,
Daniel
tongtiangen
Reviewed-byQuoted 51 lines · Daniel Borkmann
Quoted 12 lines · Björn Töpel
Commit
252c765bd764("riscv, bpf: Add BPF exception tables") only addressed RV64, and broke the RV32 build [1]. Fix by gating the exception tables code withCONFIG_ARCH_RV64I.Further, silence a "-Wmissing-prototypes" warning [2] in the RV64 BPF JIT.
[1] https://lore.kernel.org/llvm/[email protected]/
[2] https://lore.kernel.org/llvm/[email protected]/Fixes 252c765bd764 ("riscv, bpf: Add BPF exception tables")Signed-off-by Björn Töpel <[email protected]>Quoted 7 lines
---
Tong/Daniel: The RV32 build has been broken since Thursday. I'll try to fast-track a bit, and commit a quick-fix for it. Hope that's OK with you, Tong!I've verified the build on my machine using riscv32 GCC 9.3.0 and riscv64 GCC 11.2.0.
Thanks for the fix Bjorn!
Quoted 28 lines
arch/riscv/mm/extable.c| 4 ++--arch/riscv/net/bpf_jit_comp64.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)arch/riscv/mm/extable.c +2
-0@@ -11,7 +11,7 @@#include <linux/module.h> #include <linux/uaccess.h> -#ifdef CONFIG_BPF_JIT +#if defined(CONFIG_BPF_JIT) && defined(CONFIG_ARCH_RV64I) int rv_bpf_fixup_exception(const struct exception_table_entry *ex, struct pt_regs *regs); #endif @@ -23,7 +23,7 @@ int fixup_exception(struct pt_regs *regs) if (!fixup) return 0; -#ifdef CONFIG_BPF_JIT +#if defined(CONFIG_BPF_JIT) && defined(CONFIG_ARCH_RV64I) if (regs->epc >= BPF_JIT_REGION_START && regs->epc < BPF_JIT_REGION_END) return rv_bpf_fixup_exception(fixup, regs); #endifarch/riscv/net/bpf_jit_comp64.c +0
-0@@ -459,6 +459,8 @@ static int emit_call(bool fixed, u64 addr, struct rv_jit_context *ctx)
Quoted 8 lines
arch/riscv/net/bpf_jit_comp64.c static int emit_call(bool fixed, u64 addr, struct rv_jit_context *ctx) · line 463
Quoted 4 lines
arch/riscv/net/bpf_jit_comp64.c +1
-0#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);I'm okay to take this as a quick fix, but if its not too much hassle, could we add a
arch/riscv/include/asm/extable.hin similar fashion like arm64 or x86 where we move theex_handler_bpf()signature there, did you have a chance to check?
Hi Daniel:
On the question of whether to add asm/extable.h, I have an in-depth discussion with Björn, both schemes are OK.
This patch is the scheme of adding a header file:
https://lore.kernel.org/bpf/[email protected]/
Thanks.
Quoted 12 lines
Quoted 7 lines
arch/riscv/net/bpf_jit_comp64.c +0
-0int rv_bpf_fixup_exception (const struct exception_table_entry *ex,struct pt_regs *regs) {base-commit:
cc0356d6a02e064387c16a83cb96fe43ef33181eThanks,
Daniel
.
Quoted 58 lines · Daniel Borkmann
Quoted 12 lines · Björn Töpel
Commit
252c765bd764("riscv, bpf: Add BPF exception tables") only addressed RV64, and broke the RV32 build [1]. Fix by gating the exception tables code withCONFIG_ARCH_RV64I.Further, silence a "-Wmissing-prototypes" warning [2] in the RV64 BPF JIT.
[1] https://lore.kernel.org/llvm/[email protected]/
[2] https://lore.kernel.org/llvm/[email protected]/Fixes 252c765bd764 ("riscv, bpf: Add BPF exception tables")Signed-off-by Björn Töpel <[email protected]>Quoted 7 lines
---
Tong/Daniel: The RV32 build has been broken since Thursday. I'll try to fast-track a bit, and commit a quick-fix for it. Hope that's OK with you, Tong!I've verified the build on my machine using riscv32 GCC 9.3.0 and riscv64 GCC 11.2.0.
Thanks for the fix Bjorn!
Quoted 34 lines
arch/riscv/mm/extable.c| 4 ++--arch/riscv/net/bpf_jit_comp64.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)arch/riscv/mm/extable.c +2
-2@@ -11,7 +11,7 @@#include <linux/module.h> #include <linux/uaccess.h> -#ifdef CONFIG_BPF_JIT +#if defined(CONFIG_BPF_JIT ) && defined(CONFIG_ARCH_RV64I )int rv_bpf_fixup_exception (const struct exception_table_entry *ex,struct pt_regs *regs);#endif @@ -23,7 +23,7 @@ int fixup_exception(struct pt_regs *regs)if (!fixup)return 0 ; -#ifdef CONFIG_BPF_JIT +#if defined(CONFIG_BPF_JIT ) && defined(CONFIG_ARCH_RV64I )if (regs->epc >=BPF_JIT_REGION_START && regs->epc <BPF_JIT_REGION_END )return rv_bpf_fixup_exception (fixup, regs);#endif arch/riscv/net/bpf_jit_comp64.c +0
-0@@ -459,6 +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)
Quoted 7 lines
arch/riscv/net/bpf_jit_comp64.c static int emit_call(bool fixed, u64 addr, struct rv_jit_context *ctx) · line 463
Quoted 2 lines
arch/riscv/net/bpf_jit_comp64.c +2
-0+int rv_bpf_fixup_exception (const struct exception_table_entry *ex, +struct pt_regs *regs);I'm okay to take this as a quick fix, but if its not too much hassle, could we add a
arch/riscv/include/asm/extable.hin similar fashion like arm64 or x86 where we move theex_handler_bpf()signature there, did you have a chance to check?
OK! I've not looked into it yet!
There's a patch out from Jisheng on the RV list, which is starting some consolidation work [1].
@Jisheng What do you think about adding type/handlers [2,3] as arm64/x86 recently did, to your series?
Björn
[1] https://lore.kernel.org/linux-riscv/20211022001957.1eba8f04@xhacker/
[2] https://lore.kernel.org/linux-arm-kernel/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/
Daniel Borkmann
maintainerQuoted 24 lines · Björn Töpel
Quoted 23 lines · Daniel Borkmann
Quoted 12 lines · Björn Töpel
Commit
252c765bd764("riscv, bpf: Add BPF exception tables") only addressed RV64, and broke the RV32 build [1]. Fix by gating the exception tables code withCONFIG_ARCH_RV64I.Further, silence a "-Wmissing-prototypes" warning [2] in the RV64 BPF JIT.
[1] https://lore.kernel.org/llvm/[email protected]/
[2] https://lore.kernel.org/llvm/[email protected]/Fixes 252c765bd764 ("riscv, bpf: Add BPF exception tables")Signed-off-by Björn Töpel <[email protected]>Quoted 7 lines
---
Tong/Daniel: The RV32 build has been broken since Thursday. I'll try to fast-track a bit, and commit a quick-fix for it. Hope that's OK with you, Tong!I've verified the build on my machine using riscv32 GCC 9.3.0 and riscv64 GCC 11.2.0.
Thanks for the fix Bjorn!
[...]
Quoted 7 lines
Quoted 6 lines
arch/riscv/net/bpf_jit_comp64.c static int emit_call(bool fixed, u64 addr, struct rv_jit_context *ctx) · line 463
Quoted 2 lines
arch/riscv/net/bpf_jit_comp64.c +2
-0+int rv_bpf_fixup_exception (const struct exception_table_entry *ex, +struct pt_regs *regs);I'm okay to take this as a quick fix, but if its not too much hassle, could we add a
arch/riscv/include/asm/extable.hin similar fashion like arm64 or x86 where we move theex_handler_bpf()signature there, did you have a chance to check?
Quoted 7 lines
OK! I've not looked into it yet!
There's a patch out from Jisheng on the RV list, which is starting some consolidation work [1].
@Jisheng What do you think about adding type/handlers [2,3] as arm64/x86 recently did, to your series?
Fyi, Bjorn, took your fix into bpf so we can move forward wrt broken build & warning given its small anyway and I'm doing bpf PR very soon today. Either way, Jisheng, you or Tong can follow-up looking into the extable streamlining wrt arm64/x86. Thanks!
This patch was applied to bpf/bpf.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Daniel Borkmann <[email protected]>:
Quoted 8 lines · On Wed, 3 Nov 2021 12:54:53 +0100 you wrote:
Commit
252c765bd764("riscv, bpf: Add BPF exception tables") only addressed RV64, and broke the RV32 build [1]. Fix by gating the exception tables code withCONFIG_ARCH_RV64I.Further, silence a "-Wmissing-prototypes" warning [2] in the RV64 BPF JIT.
[...]
Here is the summary with links:
- [bpf-next] riscv, bpf: Fix RV32 broken build, and silence RV64 warning
https://git.kernel.org/bpf/bpf/c/f47d4ffe3a84
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html