From 770e48b6c588c47c5c3f4ce0889aa1d7890ab1df Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 3 Dec 2025 14:41:14 +0100 Subject: [PATCH] 5.15-stable patches added patches: libbpf-fix-invalid-return-address-register-in-s390.patch libbpf-fix-riscv-register-names.patch libbpf-riscv-use-a0-for-rc-register.patch selftests-bpf-don-t-rely-on-preserving-volatile-in-pt_regs-macros-in-loop3.patch --- ...alid-return-address-register-in-s390.patch | 37 ++++++++++++++++ .../libbpf-fix-riscv-register-names.patch | 37 ++++++++++++++++ .../libbpf-riscv-use-a0-for-rc-register.patch | 41 ++++++++++++++++++ ...-volatile-in-pt_regs-macros-in-loop3.patch | 42 +++++++++++++++++++ queue-5.15/series | 4 ++ 5 files changed, 161 insertions(+) create mode 100644 queue-5.15/libbpf-fix-invalid-return-address-register-in-s390.patch create mode 100644 queue-5.15/libbpf-fix-riscv-register-names.patch create mode 100644 queue-5.15/libbpf-riscv-use-a0-for-rc-register.patch create mode 100644 queue-5.15/selftests-bpf-don-t-rely-on-preserving-volatile-in-pt_regs-macros-in-loop3.patch diff --git a/queue-5.15/libbpf-fix-invalid-return-address-register-in-s390.patch b/queue-5.15/libbpf-fix-invalid-return-address-register-in-s390.patch new file mode 100644 index 0000000000..9a990e5cbc --- /dev/null +++ b/queue-5.15/libbpf-fix-invalid-return-address-register-in-s390.patch @@ -0,0 +1,37 @@ +From 7244eb669397f309c3d014264823cdc9cb3f8e6b Mon Sep 17 00:00:00 2001 +From: "Daniel T. Lee" +Date: Sat, 24 Dec 2022 16:15:27 +0900 +Subject: libbpf: Fix invalid return address register in s390 + +From: Daniel T. Lee + +commit 7244eb669397f309c3d014264823cdc9cb3f8e6b upstream. + +There is currently an invalid register mapping in the s390 return +address register. As the manual[1] states, the return address can be +found at r14. In bpf_tracing.h, the s390 registers were named +gprs(general purpose registers). This commit fixes the problem by +correcting the mistyped mapping. + +[1]: https://uclibc.org/docs/psABI-s390x.pdf#page=14 + +Fixes: 3cc31d794097 ("libbpf: Normalize PT_REGS_xxx() macro definitions") +Signed-off-by: Daniel T. Lee +Signed-off-by: Andrii Nakryiko +Link: https://lore.kernel.org/bpf/20221224071527.2292-7-danieltimlee@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + tools/lib/bpf/bpf_tracing.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/tools/lib/bpf/bpf_tracing.h ++++ b/tools/lib/bpf/bpf_tracing.h +@@ -119,7 +119,7 @@ + #define __PT_PARM3_REG gprs[4] + #define __PT_PARM4_REG gprs[5] + #define __PT_PARM5_REG gprs[6] +-#define __PT_RET_REG grps[14] ++#define __PT_RET_REG gprs[14] + #define __PT_FP_REG gprs[11] /* Works only with CONFIG_FRAME_POINTER */ + #define __PT_RC_REG gprs[2] + #define __PT_SP_REG gprs[15] diff --git a/queue-5.15/libbpf-fix-riscv-register-names.patch b/queue-5.15/libbpf-fix-riscv-register-names.patch new file mode 100644 index 0000000000..d8e70f92a3 --- /dev/null +++ b/queue-5.15/libbpf-fix-riscv-register-names.patch @@ -0,0 +1,37 @@ +From 5c101153bfd67387ba159b7864176217a40757da Mon Sep 17 00:00:00 2001 +From: Ilya Leoshkevich +Date: Wed, 9 Feb 2022 03:17:40 +0100 +Subject: libbpf: Fix riscv register names + +From: Ilya Leoshkevich + +commit 5c101153bfd67387ba159b7864176217a40757da upstream. + +riscv registers are accessed via struct user_regs_struct, not struct +pt_regs. The program counter member in this struct is called pc, not +epc. The frame pointer is called s0, not fp. + +Fixes: 3cc31d794097 ("libbpf: Normalize PT_REGS_xxx() macro definitions") +Signed-off-by: Ilya Leoshkevich +Signed-off-by: Andrii Nakryiko +Link: https://lore.kernel.org/bpf/20220209021745.2215452-6-iii@linux.ibm.com +Signed-off-by: Greg Kroah-Hartman +--- + tools/lib/bpf/bpf_tracing.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/tools/lib/bpf/bpf_tracing.h ++++ b/tools/lib/bpf/bpf_tracing.h +@@ -206,10 +206,10 @@ + #define __PT_PARM4_REG a3 + #define __PT_PARM5_REG a4 + #define __PT_RET_REG ra +-#define __PT_FP_REG fp ++#define __PT_FP_REG s0 + #define __PT_RC_REG a5 + #define __PT_SP_REG sp +-#define __PT_IP_REG epc ++#define __PT_IP_REG pc + + #endif + diff --git a/queue-5.15/libbpf-riscv-use-a0-for-rc-register.patch b/queue-5.15/libbpf-riscv-use-a0-for-rc-register.patch new file mode 100644 index 0000000000..e849696553 --- /dev/null +++ b/queue-5.15/libbpf-riscv-use-a0-for-rc-register.patch @@ -0,0 +1,41 @@ +From 935dc35c75318fa213d26808ad8bb130fb0b486e Mon Sep 17 00:00:00 2001 +From: Yixun Lan +Date: Wed, 6 Jul 2022 22:02:04 +0800 +Subject: libbpf, riscv: Use a0 for RC register +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Yixun Lan + +commit 935dc35c75318fa213d26808ad8bb130fb0b486e upstream. + +According to the RISC-V calling convention register usage here [0], a0 +is used as return value register, so rename it to make it consistent +with the spec. + + [0] section 18.2, table 18.2 + https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf + +Fixes: 589fed479ba1 ("riscv, libbpf: Add RISC-V (RV64) support to bpf_tracing.h") +Signed-off-by: Yixun Lan +Signed-off-by: Daniel Borkmann +Acked-by: Björn Töpel +Acked-by: Amjad OULED-AMEUR +Link: https://lore.kernel.org/bpf/20220706140204.47926-1-dlan@gentoo.org +Signed-off-by: Greg Kroah-Hartman +--- + tools/lib/bpf/bpf_tracing.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/tools/lib/bpf/bpf_tracing.h ++++ b/tools/lib/bpf/bpf_tracing.h +@@ -207,7 +207,7 @@ + #define __PT_PARM5_REG a4 + #define __PT_RET_REG ra + #define __PT_FP_REG s0 +-#define __PT_RC_REG a5 ++#define __PT_RC_REG a0 + #define __PT_SP_REG sp + #define __PT_IP_REG pc + diff --git a/queue-5.15/selftests-bpf-don-t-rely-on-preserving-volatile-in-pt_regs-macros-in-loop3.patch b/queue-5.15/selftests-bpf-don-t-rely-on-preserving-volatile-in-pt_regs-macros-in-loop3.patch new file mode 100644 index 0000000000..71e2581f06 --- /dev/null +++ b/queue-5.15/selftests-bpf-don-t-rely-on-preserving-volatile-in-pt_regs-macros-in-loop3.patch @@ -0,0 +1,42 @@ +From 70bc793382a0e37ba4e35e4d1a317b280b829a44 Mon Sep 17 00:00:00 2001 +From: Andrii Nakryiko +Date: Thu, 6 Jan 2022 12:51:56 -0800 +Subject: selftests/bpf: Don't rely on preserving volatile in PT_REGS macros in loop3 + +From: Andrii Nakryiko + +commit 70bc793382a0e37ba4e35e4d1a317b280b829a44 upstream. + +PT_REGS*() macro on some architectures force-cast struct pt_regs to +other types (user_pt_regs, etc) and might drop volatile modifiers, if any. +Volatile isn't really required as pt_regs value isn't supposed to change +during the BPF program run, so this is correct behavior. + +But progs/loop3.c relies on that volatile modifier to ensure that loop +is preserved. Fix loop3.c by declaring i and sum variables as volatile +instead. It preserves the loop and makes the test pass on all +architectures (including s390x which is currently broken). + +Fixes: 3cc31d794097 ("libbpf: Normalize PT_REGS_xxx() macro definitions") +Signed-off-by: Andrii Nakryiko +Signed-off-by: Daniel Borkmann +Link: https://lore.kernel.org/bpf/20220106205156.955373-1-andrii@kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/bpf/progs/loop3.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/tools/testing/selftests/bpf/progs/loop3.c ++++ b/tools/testing/selftests/bpf/progs/loop3.c +@@ -12,9 +12,9 @@ + char _license[] SEC("license") = "GPL"; + + SEC("raw_tracepoint/consume_skb") +-int while_true(volatile struct pt_regs* ctx) ++int while_true(struct pt_regs *ctx) + { +- __u64 i = 0, sum = 0; ++ volatile __u64 i = 0, sum = 0; + do { + i++; + sum += PT_REGS_RC(ctx); diff --git a/queue-5.15/series b/queue-5.15/series index 17d906fb2f..a1bc0caa2a 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -388,3 +388,7 @@ usb-renesas_usbhs-fix-synchronous-external-abort-on-unbind.patch usb-typec-ucsi-psy-set-max-current-to-zero-when-disconnected.patch bluetooth-add-more-enc-key-size-check.patch scsi-pm80xx-set-phy-enable_completion-only-when-we.patch +selftests-bpf-don-t-rely-on-preserving-volatile-in-pt_regs-macros-in-loop3.patch +libbpf-fix-riscv-register-names.patch +libbpf-riscv-use-a0-for-rc-register.patch +libbpf-fix-invalid-return-address-register-in-s390.patch -- 2.47.3