--- /dev/null
+From 181127fb76e62d06ab17a75fd610129688612343 Mon Sep 17 00:00:00 2001
+From: Martin KaFai Lau <martin.lau@kernel.org>
+Date: Fri, 17 Feb 2023 12:13:09 -0800
+Subject: Revert "bpf, test_run: fix &xdp_frame misplacement for LIVE_FRAMES"
+
+From: Martin KaFai Lau <martin.lau@kernel.org>
+
+commit 181127fb76e62d06ab17a75fd610129688612343 upstream.
+
+This reverts commit 6c20822fada1b8adb77fa450d03a0d449686a4a9.
+
+build bot failed on arch with different cache line size:
+https://lore.kernel.org/bpf/50c35055-afa9-d01e-9a05-ea5351280e4f@intel.com/
+
+Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/bpf/test_run.c | 29 +++------------
+ tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c | 7 +--
+ 2 files changed, 9 insertions(+), 27 deletions(-)
+
+--- a/net/bpf/test_run.c
++++ b/net/bpf/test_run.c
+@@ -97,11 +97,8 @@ reset:
+ struct xdp_page_head {
+ struct xdp_buff orig_ctx;
+ struct xdp_buff ctx;
+- union {
+- /* ::data_hard_start starts here */
+- DECLARE_FLEX_ARRAY(struct xdp_frame, frame);
+- DECLARE_FLEX_ARRAY(u8, data);
+- };
++ struct xdp_frame frm;
++ u8 data[];
+ };
+
+ struct xdp_test_data {
+@@ -119,20 +116,6 @@ struct xdp_test_data {
+ #define TEST_XDP_FRAME_SIZE (PAGE_SIZE - sizeof(struct xdp_page_head))
+ #define TEST_XDP_MAX_BATCH 256
+
+-#if BITS_PER_LONG == 64 && PAGE_SIZE == SZ_4K
+-/* tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c:%MAX_PKT_SIZE
+- * must be updated accordingly when any of these changes, otherwise BPF
+- * selftests will fail.
+- */
+-#ifdef __s390x__
+-#define TEST_MAX_PKT_SIZE 3216
+-#else
+-#define TEST_MAX_PKT_SIZE 3408
+-#endif
+-static_assert(SKB_WITH_OVERHEAD(TEST_XDP_FRAME_SIZE - XDP_PACKET_HEADROOM) ==
+- TEST_MAX_PKT_SIZE);
+-#endif
+-
+ static void xdp_test_run_init_page(struct page *page, void *arg)
+ {
+ struct xdp_page_head *head = phys_to_virt(page_to_phys(page));
+@@ -149,8 +132,8 @@ static void xdp_test_run_init_page(struc
+ headroom -= meta_len;
+
+ new_ctx = &head->ctx;
+- frm = head->frame;
+- data = head->data;
++ frm = &head->frm;
++ data = &head->data;
+ memcpy(data + headroom, orig_ctx->data_meta, frm_len);
+
+ xdp_init_buff(new_ctx, TEST_XDP_FRAME_SIZE, &xdp->rxq);
+@@ -240,7 +223,7 @@ static void reset_ctx(struct xdp_page_he
+ head->ctx.data = head->orig_ctx.data;
+ head->ctx.data_meta = head->orig_ctx.data_meta;
+ head->ctx.data_end = head->orig_ctx.data_end;
+- xdp_update_frame_from_buff(&head->ctx, head->frame);
++ xdp_update_frame_from_buff(&head->ctx, &head->frm);
+ }
+
+ static int xdp_recv_frames(struct xdp_frame **frames, int nframes,
+@@ -302,7 +285,7 @@ static int xdp_test_run_batch(struct xdp
+ head = phys_to_virt(page_to_phys(page));
+ reset_ctx(head);
+ ctx = &head->ctx;
+- frm = head->frame;
++ frm = &head->frm;
+ xdp->frame_cnt++;
+
+ act = bpf_prog_run_xdp(prog, ctx);
+--- a/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
++++ b/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
+@@ -63,13 +63,12 @@ static int attach_tc_prog(struct bpf_tc_
+ }
+
+ /* The maximum permissible size is: PAGE_SIZE - sizeof(struct xdp_page_head) -
+- * SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) - XDP_PACKET_HEADROOM =
+- * 3408 bytes for 64-byte cacheline and 3216 for 256-byte one.
++ * sizeof(struct skb_shared_info) - XDP_PACKET_HEADROOM = 3368 bytes
+ */
+ #if defined(__s390x__)
+-#define MAX_PKT_SIZE 3216
++#define MAX_PKT_SIZE 3176
+ #else
+-#define MAX_PKT_SIZE 3408
++#define MAX_PKT_SIZE 3368
+ #endif
+ static void test_max_pkt_size(int fd)
+ {
--- /dev/null
+From bf89b7ee52af5a5944fa3539e86089f72475055b Mon Sep 17 00:00:00 2001
+From: Conor Dooley <conor@kernel.org>
+Date: Thu, 2 Mar 2023 17:41:55 +0000
+Subject: RISC-V: fix taking the text_mutex twice during sifive errata patching
+
+From: Conor Dooley <conor@kernel.org>
+
+commit bf89b7ee52af5a5944fa3539e86089f72475055b upstream.
+
+Chris pointed out that some bonehead, *cough* me *cough*, added two
+mutex_locks() to the SiFive errata patching. The second was meant to
+have been a mutex_unlock().
+
+This results in errors such as
+
+Unable to handle kernel NULL pointer dereference at virtual address 0000000000000030
+Oops [#1]
+Modules linked in:
+CPU: 0 PID: 0 Comm: swapper Not tainted
+6.2.0-rc1-starlight-00079-g9493e6f3ce02 #229
+Hardware name: BeagleV Starlight Beta (DT)
+epc : __schedule+0x42/0x500
+ ra : schedule+0x46/0xce
+epc : ffffffff8065957c ra : ffffffff80659a80 sp : ffffffff81203c80
+ gp : ffffffff812d50a0 tp : ffffffff8120db40 t0 : ffffffff81203d68
+ t1 : 0000000000000001 t2 : 4c45203a76637369 s0 : ffffffff81203cf0
+ s1 : ffffffff8120db40 a0 : 0000000000000000 a1 : ffffffff81213958
+ a2 : ffffffff81213958 a3 : 0000000000000000 a4 : 0000000000000000
+ a5 : ffffffff80a1bd00 a6 : 0000000000000000 a7 : 0000000052464e43
+ s2 : ffffffff8120db41 s3 : ffffffff80a1ad00 s4 : 0000000000000000
+ s5 : 0000000000000002 s6 : ffffffff81213938 s7 : 0000000000000000
+ s8 : 0000000000000000 s9 : 0000000000000001 s10: ffffffff812d7204
+ s11: ffffffff80d3c920 t3 : 0000000000000001 t4 : ffffffff812e6dd7
+ t5 : ffffffff812e6dd8 t6 : ffffffff81203bb8
+status: 0000000200000100 badaddr: 0000000000000030 cause: 000000000000000d
+[<ffffffff80659a80>] schedule+0x46/0xce
+[<ffffffff80659dce>] schedule_preempt_disabled+0x16/0x28
+[<ffffffff8065ae0c>] __mutex_lock.constprop.0+0x3fe/0x652
+[<ffffffff8065b138>] __mutex_lock_slowpath+0xe/0x16
+[<ffffffff8065b182>] mutex_lock+0x42/0x4c
+[<ffffffff8000ad94>] sifive_errata_patch_func+0xf6/0x18c
+[<ffffffff80002b92>] _apply_alternatives+0x74/0x76
+[<ffffffff80802ee8>] apply_boot_alternatives+0x3c/0xfa
+[<ffffffff80803cb0>] setup_arch+0x60c/0x640
+[<ffffffff80800926>] start_kernel+0x8e/0x99c
+---[ end trace 0000000000000000 ]---
+
+Reported-by: Chris Hofstaedtler <zeha@debian.org>
+Fixes: 9493e6f3ce02 ("RISC-V: take text_mutex during alternative patching")
+Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
+Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Link: https://lore.kernel.org/r/20230302174154.970746-1-conor@kernel.org
+[Palmer: pick up Geert's bug report from the thread]
+Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/riscv/errata/sifive/errata.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/riscv/errata/sifive/errata.c
++++ b/arch/riscv/errata/sifive/errata.c
+@@ -110,7 +110,7 @@ void __init_or_module sifive_errata_patc
+ if (cpu_req_errata & tmp) {
+ mutex_lock(&text_mutex);
+ patch_text_nosync(alt->old_ptr, alt->alt_ptr, alt->alt_len);
+- mutex_lock(&text_mutex);
++ mutex_unlock(&text_mutex);
+ cpu_apply_errata |= tmp;
+ }
+ }