From ba8b8a5b213789d478eeb518763614bc2d0f98e0 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 8 Dec 2022 08:53:36 -0500 Subject: [PATCH] Fixes for 5.4 Signed-off-by: Sasha Levin --- .../9p-fd-use-p9_hdrsz-for-header-size.patch | 56 +++ ...n-check-logical-size-for-buffer-size.patch | 53 +++ ...ction-prototype-mismatch-in-snd_seq_.patch | 77 ++++ ...fix-stacktraces-for-tracepoint-event.patch | 70 ++++ ...-fix-no-mmu-zero_page-implementation.patch | 141 +++++++ ...-disable-arm_global_timer-on-rk3066-.patch | 64 +++ ...-rockchip-fix-ir-receiver-node-names.patch | 36 ++ ...ckchip-fix-node-name-for-hym8563-rtc.patch | 91 ++++ ...hip-rk3188-fix-lcdc1-rgb24-node-name.patch | 36 ++ ...ip-keep-i2s1-disabled-for-gpio-funct.patch | 36 ++ ...pcm-add-null-check-in-be-reparenting.patch | 37 ++ ...-unaligned-encoded-writes-when-attem.patch | 161 ++++++++ ...on-use-kzalloc-in-fbcon_prepare_logo.patch | 93 +++++ ...x-gup-fast-interaction-by-sending-ip.patch | 107 +++++ ...voke-mmu-notifiers-in-shmem-file-col.patch | 90 ++++ ...ke-the-right-locks-for-page-table-re.patch | 141 +++++++ ...i_wwan-add-u-blox-0x1342-composition.patch | 53 +++ ...slg51000-wait-after-asserting-cs-pin.patch | 44 ++ ...0-fix-get-status-of-twl6032-regulato.patch | 69 ++++ queue-5.4/series | 22 + .../xen-netback-do-some-code-cleanup.patch | 147 +++++++ ...t-call-kfree_skb-with-interrupts-dis.patch | 105 +++++ ...re-protocol-headers-don-t-fall-in-th.patch | 390 ++++++++++++++++++ 23 files changed, 2119 insertions(+) create mode 100644 queue-5.4/9p-fd-use-p9_hdrsz-for-header-size.patch create mode 100644 queue-5.4/9p-xen-check-logical-size-for-buffer-size.patch create mode 100644 queue-5.4/alsa-seq-fix-function-prototype-mismatch-in-snd_seq_.patch create mode 100644 queue-5.4/arm-9251-1-perf-fix-stacktraces-for-tracepoint-event.patch create mode 100644 queue-5.4/arm-9266-1-mm-fix-no-mmu-zero_page-implementation.patch create mode 100644 queue-5.4/arm-dts-rockchip-disable-arm_global_timer-on-rk3066-.patch create mode 100644 queue-5.4/arm-dts-rockchip-fix-ir-receiver-node-names.patch create mode 100644 queue-5.4/arm-dts-rockchip-fix-node-name-for-hym8563-rtc.patch create mode 100644 queue-5.4/arm-dts-rockchip-rk3188-fix-lcdc1-rgb24-node-name.patch create mode 100644 queue-5.4/arm64-dts-rockchip-keep-i2s1-disabled-for-gpio-funct.patch create mode 100644 queue-5.4/asoc-soc-pcm-add-null-check-in-be-reparenting.patch create mode 100644 queue-5.4/btrfs-send-avoid-unaligned-encoded-writes-when-attem.patch create mode 100644 queue-5.4/fbcon-use-kzalloc-in-fbcon_prepare_logo.patch create mode 100644 queue-5.4/mm-khugepaged-fix-gup-fast-interaction-by-sending-ip.patch create mode 100644 queue-5.4/mm-khugepaged-invoke-mmu-notifiers-in-shmem-file-col.patch create mode 100644 queue-5.4/mm-khugepaged-take-the-right-locks-for-page-table-re.patch create mode 100644 queue-5.4/net-usb-qmi_wwan-add-u-blox-0x1342-composition.patch create mode 100644 queue-5.4/regulator-slg51000-wait-after-asserting-cs-pin.patch create mode 100644 queue-5.4/regulator-twl6030-fix-get-status-of-twl6032-regulato.patch create mode 100644 queue-5.4/series create mode 100644 queue-5.4/xen-netback-do-some-code-cleanup.patch create mode 100644 queue-5.4/xen-netback-don-t-call-kfree_skb-with-interrupts-dis.patch create mode 100644 queue-5.4/xen-netback-ensure-protocol-headers-don-t-fall-in-th.patch diff --git a/queue-5.4/9p-fd-use-p9_hdrsz-for-header-size.patch b/queue-5.4/9p-fd-use-p9_hdrsz-for-header-size.patch new file mode 100644 index 00000000000..e8273b4f51d --- /dev/null +++ b/queue-5.4/9p-fd-use-p9_hdrsz-for-header-size.patch @@ -0,0 +1,56 @@ +From 6a93dcd3b59e2974bed7d937fca5911e2c40acad Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 17 Nov 2022 17:11:59 +0800 +Subject: 9p/fd: Use P9_HDRSZ for header size + +From: GUO Zihua + +[ Upstream commit 6854fadbeee10891ed74246bdc05031906b6c8cf ] + +Cleanup hardcoded header sizes to use P9_HDRSZ instead of '7' + +Link: https://lkml.kernel.org/r/20221117091159.31533-4-guozihua@huawei.com +Signed-off-by: GUO Zihua +Reviewed-by: Christian Schoenebeck +[Dominique: commit message adjusted to make sense after offset size +adjustment got removed] +Signed-off-by: Dominique Martinet +Signed-off-by: Sasha Levin +--- + net/9p/trans_fd.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c +index 23c1d78ab1e4..872568cca926 100644 +--- a/net/9p/trans_fd.c ++++ b/net/9p/trans_fd.c +@@ -118,7 +118,7 @@ struct p9_conn { + struct list_head unsent_req_list; + struct p9_req_t *rreq; + struct p9_req_t *wreq; +- char tmp_buf[7]; ++ char tmp_buf[P9_HDRSZ]; + struct p9_fcall rc; + int wpos; + int wsize; +@@ -291,7 +291,7 @@ static void p9_read_work(struct work_struct *work) + if (!m->rc.sdata) { + m->rc.sdata = m->tmp_buf; + m->rc.offset = 0; +- m->rc.capacity = 7; /* start by reading header */ ++ m->rc.capacity = P9_HDRSZ; /* start by reading header */ + } + + clear_bit(Rpending, &m->wsched); +@@ -314,7 +314,7 @@ static void p9_read_work(struct work_struct *work) + p9_debug(P9_DEBUG_TRANS, "got new header\n"); + + /* Header size */ +- m->rc.size = 7; ++ m->rc.size = P9_HDRSZ; + err = p9_parse_header(&m->rc, &m->rc.size, NULL, NULL, 0); + if (err) { + p9_debug(P9_DEBUG_ERROR, +-- +2.35.1 + diff --git a/queue-5.4/9p-xen-check-logical-size-for-buffer-size.patch b/queue-5.4/9p-xen-check-logical-size-for-buffer-size.patch new file mode 100644 index 00000000000..66fcca892fd --- /dev/null +++ b/queue-5.4/9p-xen-check-logical-size-for-buffer-size.patch @@ -0,0 +1,53 @@ +From 630d3c0c1996b0f5bf5808cd7fce9e60e6473700 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 18 Nov 2022 22:44:41 +0900 +Subject: 9p/xen: check logical size for buffer size + +From: Dominique Martinet + +[ Upstream commit 391c18cf776eb4569ecda1f7794f360fe0a45a26 ] + +trans_xen did not check the data fits into the buffer before copying +from the xen ring, but we probably should. +Add a check that just skips the request and return an error to +userspace if it did not fit + +Tested-by: Stefano Stabellini +Reviewed-by: Christian Schoenebeck +Link: https://lkml.kernel.org/r/20221118135542.63400-1-asmadeus@codewreck.org +Signed-off-by: Dominique Martinet +Signed-off-by: Sasha Levin +--- + net/9p/trans_xen.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c +index 2779ec1053a0..f043938ae782 100644 +--- a/net/9p/trans_xen.c ++++ b/net/9p/trans_xen.c +@@ -230,6 +230,14 @@ static void p9_xen_response(struct work_struct *work) + continue; + } + ++ if (h.size > req->rc.capacity) { ++ dev_warn(&priv->dev->dev, ++ "requested packet size too big: %d for tag %d with capacity %zd\n", ++ h.size, h.tag, req->rc.capacity); ++ req->status = REQ_STATUS_ERROR; ++ goto recv_error; ++ } ++ + memcpy(&req->rc, &h, sizeof(h)); + req->rc.offset = 0; + +@@ -239,6 +247,7 @@ static void p9_xen_response(struct work_struct *work) + masked_prod, &masked_cons, + XEN_9PFS_RING_SIZE); + ++recv_error: + virt_mb(); + cons += h.size; + ring->intf->in_cons = cons; +-- +2.35.1 + diff --git a/queue-5.4/alsa-seq-fix-function-prototype-mismatch-in-snd_seq_.patch b/queue-5.4/alsa-seq-fix-function-prototype-mismatch-in-snd_seq_.patch new file mode 100644 index 00000000000..a4d78f51e6f --- /dev/null +++ b/queue-5.4/alsa-seq-fix-function-prototype-mismatch-in-snd_seq_.patch @@ -0,0 +1,77 @@ +From ba72c5fb3adf1da5a30b26e816afc31507946696 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 18 Nov 2022 15:23:50 -0800 +Subject: ALSA: seq: Fix function prototype mismatch in + snd_seq_expand_var_event + +From: Kees Cook + +[ Upstream commit 05530ef7cf7c7d700f6753f058999b1b5099a026 ] + +With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), +indirect call targets are validated against the expected function +pointer prototype to make sure the call target is valid to help mitigate +ROP attacks. If they are not identical, there is a failure at run time, +which manifests as either a kernel panic or thread getting killed. + +seq_copy_in_user() and seq_copy_in_kernel() did not have prototypes +matching snd_seq_dump_func_t. Adjust this and remove the casts. There +are not resulting binary output differences. + +This was found as a result of Clang's new -Wcast-function-type-strict +flag, which is more sensitive than the simpler -Wcast-function-type, +which only checks for type width mismatches. + +Reported-by: kernel test robot +Link: https://lore.kernel.org/lkml/202211041527.HD8TLSE1-lkp@intel.com +Cc: Jaroslav Kysela +Cc: Takashi Iwai +Cc: "Gustavo A. R. Silva" +Cc: alsa-devel@alsa-project.org +Signed-off-by: Kees Cook +Link: https://lore.kernel.org/r/20221118232346.never.380-kees@kernel.org +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/core/seq/seq_memory.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c +index 65db1a7c77b7..bb76a2dd0a2f 100644 +--- a/sound/core/seq/seq_memory.c ++++ b/sound/core/seq/seq_memory.c +@@ -112,15 +112,19 @@ EXPORT_SYMBOL(snd_seq_dump_var_event); + * expand the variable length event to linear buffer space. + */ + +-static int seq_copy_in_kernel(char **bufptr, const void *src, int size) ++static int seq_copy_in_kernel(void *ptr, void *src, int size) + { ++ char **bufptr = ptr; ++ + memcpy(*bufptr, src, size); + *bufptr += size; + return 0; + } + +-static int seq_copy_in_user(char __user **bufptr, const void *src, int size) ++static int seq_copy_in_user(void *ptr, void *src, int size) + { ++ char __user **bufptr = ptr; ++ + if (copy_to_user(*bufptr, src, size)) + return -EFAULT; + *bufptr += size; +@@ -149,8 +153,7 @@ int snd_seq_expand_var_event(const struct snd_seq_event *event, int count, char + return newlen; + } + err = snd_seq_dump_var_event(event, +- in_kernel ? (snd_seq_dump_func_t)seq_copy_in_kernel : +- (snd_seq_dump_func_t)seq_copy_in_user, ++ in_kernel ? seq_copy_in_kernel : seq_copy_in_user, + &buf); + return err < 0 ? err : newlen; + } +-- +2.35.1 + diff --git a/queue-5.4/arm-9251-1-perf-fix-stacktraces-for-tracepoint-event.patch b/queue-5.4/arm-9251-1-perf-fix-stacktraces-for-tracepoint-event.patch new file mode 100644 index 00000000000..26f8a93786f --- /dev/null +++ b/queue-5.4/arm-9251-1-perf-fix-stacktraces-for-tracepoint-event.patch @@ -0,0 +1,70 @@ +From c48b00ade754930b7d7adcd788c9025e4dcc4e6b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 26 Sep 2022 16:09:12 +0100 +Subject: ARM: 9251/1: perf: Fix stacktraces for tracepoint events in THUMB2 + kernels + +From: Tomislav Novak + +[ Upstream commit 612695bccfdbd52004551308a55bae410e7cd22f ] + +Store the frame address where arm_get_current_stackframe() looks for it +(ARM_r7 instead of ARM_fp if CONFIG_THUMB2_KERNEL=y). Otherwise frame->fp +gets set to 0, causing unwind_frame() to fail. + + # bpftrace -e 't:sched:sched_switch { @[kstack] = count(); exit(); }' + Attaching 1 probe... + @[ + __schedule+1059 + ]: 1 + +A typical first unwind instruction is 0x97 (SP = R7), so after executing +it SP ends up being 0 and -URC_FAILURE is returned. + + unwind_frame(pc = ac9da7d7 lr = 00000000 sp = c69bdda0 fp = 00000000) + unwind_find_idx(ac9da7d7) + unwind_exec_insn: insn = 00000097 + unwind_exec_insn: fp = 00000000 sp = 00000000 lr = 00000000 pc = 00000000 + +With this patch: + + # bpftrace -e 't:sched:sched_switch { @[kstack] = count(); exit(); }' + Attaching 1 probe... + @[ + __schedule+1059 + __schedule+1059 + schedule+79 + schedule_hrtimeout_range_clock+163 + schedule_hrtimeout_range+17 + ep_poll+471 + SyS_epoll_wait+111 + sys_epoll_pwait+231 + __ret_fast_syscall+1 + ]: 1 + +Link: https://lore.kernel.org/r/20220920230728.2617421-1-tnovak@fb.com/ + +Reviewed-by: Linus Walleij +Signed-off-by: Tomislav Novak +Signed-off-by: Russell King (Oracle) +Signed-off-by: Sasha Levin +--- + arch/arm/include/asm/perf_event.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm/include/asm/perf_event.h b/arch/arm/include/asm/perf_event.h +index fe87397c3d8c..bdbc1e590891 100644 +--- a/arch/arm/include/asm/perf_event.h ++++ b/arch/arm/include/asm/perf_event.h +@@ -17,7 +17,7 @@ extern unsigned long perf_misc_flags(struct pt_regs *regs); + + #define perf_arch_fetch_caller_regs(regs, __ip) { \ + (regs)->ARM_pc = (__ip); \ +- (regs)->ARM_fp = (unsigned long) __builtin_frame_address(0); \ ++ frame_pointer((regs)) = (unsigned long) __builtin_frame_address(0); \ + (regs)->ARM_sp = current_stack_pointer; \ + (regs)->ARM_cpsr = SVC_MODE; \ + } +-- +2.35.1 + diff --git a/queue-5.4/arm-9266-1-mm-fix-no-mmu-zero_page-implementation.patch b/queue-5.4/arm-9266-1-mm-fix-no-mmu-zero_page-implementation.patch new file mode 100644 index 00000000000..cfe15a82780 --- /dev/null +++ b/queue-5.4/arm-9266-1-mm-fix-no-mmu-zero_page-implementation.patch @@ -0,0 +1,141 @@ +From 02b98d4422afe54fd793f3ae27896e6d8066e004 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 4 Nov 2022 21:46:18 +0100 +Subject: ARM: 9266/1: mm: fix no-MMU ZERO_PAGE() implementation + +From: Giulio Benetti + +[ Upstream commit 340a982825f76f1cff0daa605970fe47321b5ee7 ] + +Actually in no-MMU SoCs(i.e. i.MXRT) ZERO_PAGE(vaddr) expands to +``` +virt_to_page(0) +``` +that in order expands to: +``` +pfn_to_page(virt_to_pfn(0)) +``` +and then virt_to_pfn(0) to: +``` + ((((unsigned long)(0) - PAGE_OFFSET) >> PAGE_SHIFT) + + PHYS_PFN_OFFSET) +``` +where PAGE_OFFSET and PHYS_PFN_OFFSET are the DRAM offset(0x80000000) and +PAGE_SHIFT is 12. This way we obtain 16MB(0x01000000) summed to the base of +DRAM(0x80000000). +When ZERO_PAGE(0) is then used, for example in bio_add_page(), the page +gets an address that is out of DRAM bounds. +So instead of using fake virtual page 0 let's allocate a dedicated +zero_page during paging_init() and assign it to a global 'struct page * +empty_zero_page' the same way mmu.c does and it's the same approach used +in m68k with commit dc068f462179 as discussed here[0]. Then let's move +ZERO_PAGE() definition to the top of pgtable.h to be in common between +mmu.c and nommu.c. + +[0]: https://lore.kernel.org/linux-m68k/2a462b23-5b8e-bbf4-ec7d-778434a3b9d7@google.com/T/#m1266ceb63 +ad140743174d6b3070364d3c9a5179b + +Signed-off-by: Giulio Benetti +Reviewed-by: Arnd Bergmann +Signed-off-by: Russell King (Oracle) +Signed-off-by: Sasha Levin +--- + arch/arm/include/asm/pgtable-nommu.h | 6 ------ + arch/arm/include/asm/pgtable.h | 16 +++++++++------- + arch/arm/mm/nommu.c | 19 +++++++++++++++++++ + 3 files changed, 28 insertions(+), 13 deletions(-) + +diff --git a/arch/arm/include/asm/pgtable-nommu.h b/arch/arm/include/asm/pgtable-nommu.h +index 010fa1a35a68..e8ac2f95fb37 100644 +--- a/arch/arm/include/asm/pgtable-nommu.h ++++ b/arch/arm/include/asm/pgtable-nommu.h +@@ -51,12 +51,6 @@ + + typedef pte_t *pte_addr_t; + +-/* +- * ZERO_PAGE is a global shared page that is always zero: used +- * for zero-mapped memory areas etc.. +- */ +-#define ZERO_PAGE(vaddr) (virt_to_page(0)) +- + /* + * Mark the prot value as uncacheable and unbufferable. + */ +diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h +index 3ae120cd1715..ecfd6e7e128f 100644 +--- a/arch/arm/include/asm/pgtable.h ++++ b/arch/arm/include/asm/pgtable.h +@@ -10,6 +10,15 @@ + #include + #include + ++#ifndef __ASSEMBLY__ ++/* ++ * ZERO_PAGE is a global shared page that is always zero: used ++ * for zero-mapped memory areas etc.. ++ */ ++extern struct page *empty_zero_page; ++#define ZERO_PAGE(vaddr) (empty_zero_page) ++#endif ++ + #ifndef CONFIG_MMU + + #include +@@ -166,13 +175,6 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, + #define __S111 __PAGE_SHARED_EXEC + + #ifndef __ASSEMBLY__ +-/* +- * ZERO_PAGE is a global shared page that is always zero: used +- * for zero-mapped memory areas etc.. +- */ +-extern struct page *empty_zero_page; +-#define ZERO_PAGE(vaddr) (empty_zero_page) +- + + extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; + +diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c +index 24ecf8d30a1e..a3ad8a1b0e07 100644 +--- a/arch/arm/mm/nommu.c ++++ b/arch/arm/mm/nommu.c +@@ -26,6 +26,13 @@ + + unsigned long vectors_base; + ++/* ++ * empty_zero_page is a special page that is used for ++ * zero-initialized data and COW. ++ */ ++struct page *empty_zero_page; ++EXPORT_SYMBOL(empty_zero_page); ++ + #ifdef CONFIG_ARM_MPU + struct mpu_rgn_info mpu_rgn_info; + #endif +@@ -148,9 +155,21 @@ void __init adjust_lowmem_bounds(void) + */ + void __init paging_init(const struct machine_desc *mdesc) + { ++ void *zero_page; ++ + early_trap_init((void *)vectors_base); + mpu_setup(); ++ ++ /* allocate the zero page. */ ++ zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE); ++ if (!zero_page) ++ panic("%s: Failed to allocate %lu bytes align=0x%lx\n", ++ __func__, PAGE_SIZE, PAGE_SIZE); ++ + bootmem_init(); ++ ++ empty_zero_page = virt_to_page(zero_page); ++ flush_dcache_page(empty_zero_page); + } + + /* +-- +2.35.1 + diff --git a/queue-5.4/arm-dts-rockchip-disable-arm_global_timer-on-rk3066-.patch b/queue-5.4/arm-dts-rockchip-disable-arm_global_timer-on-rk3066-.patch new file mode 100644 index 00000000000..6d1e048f293 --- /dev/null +++ b/queue-5.4/arm-dts-rockchip-disable-arm_global_timer-on-rk3066-.patch @@ -0,0 +1,64 @@ +From ac03c32153a95159d98abc6effaf1ea357b54b44 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 30 Oct 2022 21:56:29 +0100 +Subject: ARM: dts: rockchip: disable arm_global_timer on rk3066 and rk3188 + +From: Johan Jonker + +[ Upstream commit da74858a475782a3f16470907814c8cc5950ad68 ] + +The clock source and the sched_clock provided by the arm_global_timer +on Rockchip rk3066a/rk3188 are quite unstable because their rates +depend on the CPU frequency. + +Recent changes to the arm_global_timer driver makes it impossible to use. + +On the other side, the arm_global_timer has a higher rating than the +ROCKCHIP_TIMER, it will be selected by default by the time framework +while we want to use the stable Rockchip clock source. + +Keep the arm_global_timer disabled in order to have the +DW_APB_TIMER (rk3066a) or ROCKCHIP_TIMER (rk3188) selected by default. + +Signed-off-by: Johan Jonker +Link: https://lore.kernel.org/r/f275ca8d-fd0a-26e5-b978-b7f3df815e0a@gmail.com +Signed-off-by: Heiko Stuebner +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/rk3188.dtsi | 1 - + arch/arm/boot/dts/rk3xxx.dtsi | 7 +++++++ + 2 files changed, 7 insertions(+), 1 deletion(-) + +diff --git a/arch/arm/boot/dts/rk3188.dtsi b/arch/arm/boot/dts/rk3188.dtsi +index 95d558dc163c..5e8ba80d7b4f 100644 +--- a/arch/arm/boot/dts/rk3188.dtsi ++++ b/arch/arm/boot/dts/rk3188.dtsi +@@ -632,7 +632,6 @@ + + &global_timer { + interrupts = ; +- status = "disabled"; + }; + + &local_timer { +diff --git a/arch/arm/boot/dts/rk3xxx.dtsi b/arch/arm/boot/dts/rk3xxx.dtsi +index bce0b05ef7bf..0580eea90fbc 100644 +--- a/arch/arm/boot/dts/rk3xxx.dtsi ++++ b/arch/arm/boot/dts/rk3xxx.dtsi +@@ -108,6 +108,13 @@ + reg = <0x1013c200 0x20>; + interrupts = ; + clocks = <&cru CORE_PERI>; ++ status = "disabled"; ++ /* The clock source and the sched_clock provided by the arm_global_timer ++ * on Rockchip rk3066a/rk3188 are quite unstable because their rates ++ * depend on the CPU frequency. ++ * Keep the arm_global_timer disabled in order to have the ++ * DW_APB_TIMER (rk3066a) or ROCKCHIP_TIMER (rk3188) selected by default. ++ */ + }; + + local_timer: local-timer@1013c600 { +-- +2.35.1 + diff --git a/queue-5.4/arm-dts-rockchip-fix-ir-receiver-node-names.patch b/queue-5.4/arm-dts-rockchip-fix-ir-receiver-node-names.patch new file mode 100644 index 00000000000..137d7d188a4 --- /dev/null +++ b/queue-5.4/arm-dts-rockchip-fix-ir-receiver-node-names.patch @@ -0,0 +1,36 @@ +From 0f38fb91dcfc1669b8ec495a752d01d010429fed Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 27 Oct 2022 10:58:22 +0200 +Subject: ARM: dts: rockchip: fix ir-receiver node names + +From: Johan Jonker + +[ Upstream commit dd847fe34cdf1e89afed1af24986359f13082bfb ] + +Fix ir-receiver node names on Rockchip boards, +so that they match with regex: '^ir(-receiver)?(@[a-f0-9]+)?$' + +Signed-off-by: Johan Jonker +Link: https://lore.kernel.org/r/ea5af279-f44c-afea-023d-bb37f5a0d58d@gmail.com +Signed-off-by: Heiko Stuebner +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/rk3188-radxarock.dts | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm/boot/dts/rk3188-radxarock.dts b/arch/arm/boot/dts/rk3188-radxarock.dts +index c9a7f5409960..f8e51ca3ee00 100644 +--- a/arch/arm/boot/dts/rk3188-radxarock.dts ++++ b/arch/arm/boot/dts/rk3188-radxarock.dts +@@ -67,7 +67,7 @@ + #sound-dai-cells = <0>; + }; + +- ir_recv: gpio-ir-receiver { ++ ir_recv: ir-receiver { + compatible = "gpio-ir-receiver"; + gpios = <&gpio0 RK_PB2 GPIO_ACTIVE_LOW>; + pinctrl-names = "default"; +-- +2.35.1 + diff --git a/queue-5.4/arm-dts-rockchip-fix-node-name-for-hym8563-rtc.patch b/queue-5.4/arm-dts-rockchip-fix-node-name-for-hym8563-rtc.patch new file mode 100644 index 00000000000..d7341c896ca --- /dev/null +++ b/queue-5.4/arm-dts-rockchip-fix-node-name-for-hym8563-rtc.patch @@ -0,0 +1,91 @@ +From daf5866a5d7920d4a6c80fe506ba7e1660740b70 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 24 Oct 2022 18:55:46 +0200 +Subject: arm: dts: rockchip: fix node name for hym8563 rtc + +From: Sebastian Reichel + +[ Upstream commit 17b57beafccb4569accbfc8c11390744cf59c021 ] + +Fix the node name for hym8563 in all arm rockchip devicetrees. + +Signed-off-by: Sebastian Reichel +Link: https://lore.kernel.org/r/20221024165549.74574-4-sebastian.reichel@collabora.com +Signed-off-by: Heiko Stuebner +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/rk3036-evb.dts | 2 +- + arch/arm/boot/dts/rk3288-evb-act8846.dts | 2 +- + arch/arm/boot/dts/rk3288-firefly.dtsi | 2 +- + arch/arm/boot/dts/rk3288-miqi.dts | 2 +- + arch/arm/boot/dts/rk3288-rock2-square.dts | 2 +- + 5 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/arch/arm/boot/dts/rk3036-evb.dts b/arch/arm/boot/dts/rk3036-evb.dts +index 2a7e6624efb9..ea23ba98625e 100644 +--- a/arch/arm/boot/dts/rk3036-evb.dts ++++ b/arch/arm/boot/dts/rk3036-evb.dts +@@ -31,7 +31,7 @@ + &i2c1 { + status = "okay"; + +- hym8563: hym8563@51 { ++ hym8563: rtc@51 { + compatible = "haoyu,hym8563"; + reg = <0x51>; + #clock-cells = <0>; +diff --git a/arch/arm/boot/dts/rk3288-evb-act8846.dts b/arch/arm/boot/dts/rk3288-evb-act8846.dts +index 80080767c365..9ac40c100e3f 100644 +--- a/arch/arm/boot/dts/rk3288-evb-act8846.dts ++++ b/arch/arm/boot/dts/rk3288-evb-act8846.dts +@@ -53,7 +53,7 @@ + vin-supply = <&vcc_sys>; + }; + +- hym8563@51 { ++ rtc@51 { + compatible = "haoyu,hym8563"; + reg = <0x51>; + +diff --git a/arch/arm/boot/dts/rk3288-firefly.dtsi b/arch/arm/boot/dts/rk3288-firefly.dtsi +index 5e0a19004e46..8d418881166f 100644 +--- a/arch/arm/boot/dts/rk3288-firefly.dtsi ++++ b/arch/arm/boot/dts/rk3288-firefly.dtsi +@@ -233,7 +233,7 @@ + vin-supply = <&vcc_sys>; + }; + +- hym8563: hym8563@51 { ++ hym8563: rtc@51 { + compatible = "haoyu,hym8563"; + reg = <0x51>; + #clock-cells = <0>; +diff --git a/arch/arm/boot/dts/rk3288-miqi.dts b/arch/arm/boot/dts/rk3288-miqi.dts +index c41d012c8850..bf8f3f9bb4d5 100644 +--- a/arch/arm/boot/dts/rk3288-miqi.dts ++++ b/arch/arm/boot/dts/rk3288-miqi.dts +@@ -145,7 +145,7 @@ + vin-supply = <&vcc_sys>; + }; + +- hym8563: hym8563@51 { ++ hym8563: rtc@51 { + compatible = "haoyu,hym8563"; + reg = <0x51>; + #clock-cells = <0>; +diff --git a/arch/arm/boot/dts/rk3288-rock2-square.dts b/arch/arm/boot/dts/rk3288-rock2-square.dts +index cdcdc921ee09..7220de126635 100644 +--- a/arch/arm/boot/dts/rk3288-rock2-square.dts ++++ b/arch/arm/boot/dts/rk3288-rock2-square.dts +@@ -165,7 +165,7 @@ + }; + + &i2c0 { +- hym8563: hym8563@51 { ++ hym8563: rtc@51 { + compatible = "haoyu,hym8563"; + reg = <0x51>; + #clock-cells = <0>; +-- +2.35.1 + diff --git a/queue-5.4/arm-dts-rockchip-rk3188-fix-lcdc1-rgb24-node-name.patch b/queue-5.4/arm-dts-rockchip-rk3188-fix-lcdc1-rgb24-node-name.patch new file mode 100644 index 00000000000..373a8cc92a8 --- /dev/null +++ b/queue-5.4/arm-dts-rockchip-rk3188-fix-lcdc1-rgb24-node-name.patch @@ -0,0 +1,36 @@ +From 2f1c67b530ec20afc3c43960888a8baaf89e06c6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 27 Oct 2022 01:31:37 +0200 +Subject: ARM: dts: rockchip: rk3188: fix lcdc1-rgb24 node name + +From: Johan Jonker + +[ Upstream commit 11871e20bcb23c00966e785a124fb72bc8340af4 ] + +The lcdc1-rgb24 node name is out of line with the rest +of the rk3188 lcdc1 node, so fix it. + +Signed-off-by: Johan Jonker +Link: https://lore.kernel.org/r/7b9c0a6f-626b-07e8-ae74-7e0f08b8d241@gmail.com +Signed-off-by: Heiko Stuebner +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/rk3188.dtsi | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm/boot/dts/rk3188.dtsi b/arch/arm/boot/dts/rk3188.dtsi +index ee8a24a0e3cb..95d558dc163c 100644 +--- a/arch/arm/boot/dts/rk3188.dtsi ++++ b/arch/arm/boot/dts/rk3188.dtsi +@@ -404,7 +404,7 @@ + rockchip,pins = <2 RK_PD3 1 &pcfg_pull_none>; + }; + +- lcdc1_rgb24: ldcd1-rgb24 { ++ lcdc1_rgb24: lcdc1-rgb24 { + rockchip,pins = <2 RK_PA0 1 &pcfg_pull_none>, + <2 RK_PA1 1 &pcfg_pull_none>, + <2 RK_PA2 1 &pcfg_pull_none>, +-- +2.35.1 + diff --git a/queue-5.4/arm64-dts-rockchip-keep-i2s1-disabled-for-gpio-funct.patch b/queue-5.4/arm64-dts-rockchip-keep-i2s1-disabled-for-gpio-funct.patch new file mode 100644 index 00000000000..8c72d7852a7 --- /dev/null +++ b/queue-5.4/arm64-dts-rockchip-keep-i2s1-disabled-for-gpio-funct.patch @@ -0,0 +1,36 @@ +From b5331f3e44817e747dba9440d4defe3dd64ad4a8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 24 Sep 2022 11:28:12 +0000 +Subject: arm64: dts: rockchip: keep I2S1 disabled for GPIO function on ROCK Pi + 4 series + +From: FUKAUMI Naoki + +[ Upstream commit 849c19d14940b87332d5d59c7fc581d73f2099fd ] + +I2S1 pins are exposed on 40-pin header on Radxa ROCK Pi 4 series. +their default function is GPIO, so I2S1 need to be disabled. + +Signed-off-by: FUKAUMI Naoki +Link: https://lore.kernel.org/r/20220924112812.1219-1-naoki@radxa.com +Signed-off-by: Heiko Stuebner +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dts | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dts b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dts +index da3b031d4bef..79d04a664b82 100644 +--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dts ++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dts +@@ -441,7 +441,6 @@ + &i2s1 { + rockchip,playback-channels = <2>; + rockchip,capture-channels = <2>; +- status = "okay"; + }; + + &i2s2 { +-- +2.35.1 + diff --git a/queue-5.4/asoc-soc-pcm-add-null-check-in-be-reparenting.patch b/queue-5.4/asoc-soc-pcm-add-null-check-in-be-reparenting.patch new file mode 100644 index 00000000000..a0d4e664e4d --- /dev/null +++ b/queue-5.4/asoc-soc-pcm-add-null-check-in-be-reparenting.patch @@ -0,0 +1,37 @@ +From e9fb1137a5fe9828cd7d2913c35a7effdfaa45ab Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 22 Nov 2022 12:01:13 +0530 +Subject: ASoC: soc-pcm: Add NULL check in BE reparenting + +From: Srinivasa Rao Mandadapu + +[ Upstream commit db8f91d424fe0ea6db337aca8bc05908bbce1498 ] + +Add NULL check in dpcm_be_reparent API, to handle +kernel NULL pointer dereference error. +The issue occurred in fuzzing test. + +Signed-off-by: Srinivasa Rao Mandadapu +Link: https://lore.kernel.org/r/1669098673-29703-1-git-send-email-quic_srivasam@quicinc.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/soc-pcm.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c +index 1196167364d4..2f1ab70a68fc 100644 +--- a/sound/soc/soc-pcm.c ++++ b/sound/soc/soc-pcm.c +@@ -1201,6 +1201,8 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, + return; + + be_substream = snd_soc_dpcm_get_substream(be, stream); ++ if (!be_substream) ++ return; + + for_each_dpcm_fe(be, stream, dpcm) { + if (dpcm->fe == fe) +-- +2.35.1 + diff --git a/queue-5.4/btrfs-send-avoid-unaligned-encoded-writes-when-attem.patch b/queue-5.4/btrfs-send-avoid-unaligned-encoded-writes-when-attem.patch new file mode 100644 index 00000000000..f71f91de349 --- /dev/null +++ b/queue-5.4/btrfs-send-avoid-unaligned-encoded-writes-when-attem.patch @@ -0,0 +1,161 @@ +From 711e3e2bb21f29958a52bd6dc2af06feca0d739d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 15 Nov 2022 16:29:44 +0000 +Subject: btrfs: send: avoid unaligned encoded writes when attempting to clone + range + +From: Filipe Manana + +[ Upstream commit a11452a3709e217492798cf3686ac2cc8eb3fb51 ] + +When trying to see if we can clone a file range, there are cases where we +end up sending two write operations in case the inode from the source root +has an i_size that is not sector size aligned and the length from the +current offset to its i_size is less than the remaining length we are +trying to clone. + +Issuing two write operations when we could instead issue a single write +operation is not incorrect. However it is not optimal, specially if the +extents are compressed and the flag BTRFS_SEND_FLAG_COMPRESSED was passed +to the send ioctl. In that case we can end up sending an encoded write +with an offset that is not sector size aligned, which makes the receiver +fallback to decompressing the data and writing it using regular buffered +IO (so re-compressing the data in case the fs is mounted with compression +enabled), because encoded writes fail with -EINVAL when an offset is not +sector size aligned. + +The following example, which triggered a bug in the receiver code for the +fallback logic of decompressing + regular buffer IO and is fixed by the +patchset referred in a Link at the bottom of this changelog, is an example +where we have the non-optimal behaviour due to an unaligned encoded write: + + $ cat test.sh + #!/bin/bash + + DEV=/dev/sdj + MNT=/mnt/sdj + + mkfs.btrfs -f $DEV > /dev/null + mount -o compress $DEV $MNT + + # File foo has a size of 33K, not aligned to the sector size. + xfs_io -f -c "pwrite -S 0xab 0 33K" $MNT/foo + + xfs_io -f -c "pwrite -S 0xcd 0 64K" $MNT/bar + + # Now clone the first 32K of file bar into foo at offset 0. + xfs_io -c "reflink $MNT/bar 0 0 32K" $MNT/foo + + # Snapshot the default subvolume and create a full send stream (v2). + btrfs subvolume snapshot -r $MNT $MNT/snap + + btrfs send --compressed-data -f /tmp/test.send $MNT/snap + + echo -e "\nFile bar in the original filesystem:" + od -A d -t x1 $MNT/snap/bar + + umount $MNT + mkfs.btrfs -f $DEV > /dev/null + mount $DEV $MNT + + echo -e "\nReceiving stream in a new filesystem..." + btrfs receive -f /tmp/test.send $MNT + + echo -e "\nFile bar in the new filesystem:" + od -A d -t x1 $MNT/snap/bar + + umount $MNT + +Before this patch, the send stream included one regular write and one +encoded write for file 'bar', with the later being not sector size aligned +and causing the receiver to fallback to decompression + buffered writes. +The output of the btrfs receive command in verbose mode (-vvv): + + (...) + mkfile o258-7-0 + rename o258-7-0 -> bar + utimes + clone bar - source=foo source offset=0 offset=0 length=32768 + write bar - offset=32768 length=1024 + encoded_write bar - offset=33792, len=4096, unencoded_offset=33792, unencoded_file_len=31744, unencoded_len=65536, compression=1, encryption=0 + encoded_write bar - falling back to decompress and write due to errno 22 ("Invalid argument") + (...) + +This patch avoids the regular write followed by an unaligned encoded write +so that we end up sending a single encoded write that is aligned. So after +this patch the stream content is (output of btrfs receive -vvv): + + (...) + mkfile o258-7-0 + rename o258-7-0 -> bar + utimes + clone bar - source=foo source offset=0 offset=0 length=32768 + encoded_write bar - offset=32768, len=4096, unencoded_offset=32768, unencoded_file_len=32768, unencoded_len=65536, compression=1, encryption=0 + (...) + +So we get more optimal behaviour and avoid the silent data loss bug in +versions of btrfs-progs affected by the bug referred by the Link tag +below (btrfs-progs v5.19, v5.19.1, v6.0 and v6.0.1). + +Link: https://lore.kernel.org/linux-btrfs/cover.1668529099.git.fdmanana@suse.com/ +Reviewed-by: Boris Burkov +Signed-off-by: Filipe Manana +Signed-off-by: David Sterba +Signed-off-by: Sasha Levin +--- + fs/btrfs/send.c | 24 +++++++++++++++++++++++- + 1 file changed, 23 insertions(+), 1 deletion(-) + +diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c +index e258fc484cea..fb1996980d26 100644 +--- a/fs/btrfs/send.c ++++ b/fs/btrfs/send.c +@@ -5405,6 +5405,7 @@ static int clone_range(struct send_ctx *sctx, + u64 ext_len; + u64 clone_len; + u64 clone_data_offset; ++ bool crossed_src_i_size = false; + + if (slot >= btrfs_header_nritems(leaf)) { + ret = btrfs_next_leaf(clone_root->root, path); +@@ -5461,8 +5462,10 @@ static int clone_range(struct send_ctx *sctx, + if (key.offset >= clone_src_i_size) + break; + +- if (key.offset + ext_len > clone_src_i_size) ++ if (key.offset + ext_len > clone_src_i_size) { + ext_len = clone_src_i_size - key.offset; ++ crossed_src_i_size = true; ++ } + + clone_data_offset = btrfs_file_extent_offset(leaf, ei); + if (btrfs_file_extent_disk_bytenr(leaf, ei) == disk_byte) { +@@ -5522,6 +5525,25 @@ static int clone_range(struct send_ctx *sctx, + ret = send_clone(sctx, offset, clone_len, + clone_root); + } ++ } else if (crossed_src_i_size && clone_len < len) { ++ /* ++ * If we are at i_size of the clone source inode and we ++ * can not clone from it, terminate the loop. This is ++ * to avoid sending two write operations, one with a ++ * length matching clone_len and the final one after ++ * this loop with a length of len - clone_len. ++ * ++ * When using encoded writes (BTRFS_SEND_FLAG_COMPRESSED ++ * was passed to the send ioctl), this helps avoid ++ * sending an encoded write for an offset that is not ++ * sector size aligned, in case the i_size of the source ++ * inode is not sector size aligned. That will make the ++ * receiver fallback to decompression of the data and ++ * writing it using regular buffered IO, therefore while ++ * not incorrect, it's not optimal due decompression and ++ * possible re-compression at the receiver. ++ */ ++ break; + } else { + ret = send_extent_data(sctx, offset, clone_len); + } +-- +2.35.1 + diff --git a/queue-5.4/fbcon-use-kzalloc-in-fbcon_prepare_logo.patch b/queue-5.4/fbcon-use-kzalloc-in-fbcon_prepare_logo.patch new file mode 100644 index 00000000000..ecda01d6315 --- /dev/null +++ b/queue-5.4/fbcon-use-kzalloc-in-fbcon_prepare_logo.patch @@ -0,0 +1,93 @@ +From 2910ef91e737230b9c56e97c13a65e0add8826c0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 18 Nov 2022 00:27:58 +0900 +Subject: fbcon: Use kzalloc() in fbcon_prepare_logo() + +From: Tetsuo Handa + +[ Upstream commit a6a00d7e8ffd78d1cdb7a43f1278f081038c638f ] + +A kernel built with syzbot's config file reported that + + scr_memcpyw(q, save, array3_size(logo_lines, new_cols, 2)) + +causes uninitialized "save" to be copied. + + ---------- + [drm] Initialized vgem 1.0.0 20120112 for vgem on minor 0 + [drm] Initialized vkms 1.0.0 20180514 for vkms on minor 1 + Console: switching to colour frame buffer device 128x48 + ===================================================== + BUG: KMSAN: uninit-value in do_update_region+0x4b8/0xba0 + do_update_region+0x4b8/0xba0 + update_region+0x40d/0x840 + fbcon_switch+0x3364/0x35e0 + redraw_screen+0xae3/0x18a0 + do_bind_con_driver+0x1cb3/0x1df0 + do_take_over_console+0x11cb/0x13f0 + fbcon_fb_registered+0xacc/0xfd0 + register_framebuffer+0x1179/0x1320 + __drm_fb_helper_initial_config_and_unlock+0x23ad/0x2b40 + drm_fbdev_client_hotplug+0xbea/0xda0 + drm_fbdev_generic_setup+0x65e/0x9d0 + vkms_init+0x9f3/0xc76 + (...snipped...) + + Uninit was stored to memory at: + fbcon_prepare_logo+0x143b/0x1940 + fbcon_init+0x2c1b/0x31c0 + visual_init+0x3e7/0x820 + do_bind_con_driver+0x14a4/0x1df0 + do_take_over_console+0x11cb/0x13f0 + fbcon_fb_registered+0xacc/0xfd0 + register_framebuffer+0x1179/0x1320 + __drm_fb_helper_initial_config_and_unlock+0x23ad/0x2b40 + drm_fbdev_client_hotplug+0xbea/0xda0 + drm_fbdev_generic_setup+0x65e/0x9d0 + vkms_init+0x9f3/0xc76 + (...snipped...) + + Uninit was created at: + __kmem_cache_alloc_node+0xb69/0x1020 + __kmalloc+0x379/0x680 + fbcon_prepare_logo+0x704/0x1940 + fbcon_init+0x2c1b/0x31c0 + visual_init+0x3e7/0x820 + do_bind_con_driver+0x14a4/0x1df0 + do_take_over_console+0x11cb/0x13f0 + fbcon_fb_registered+0xacc/0xfd0 + register_framebuffer+0x1179/0x1320 + __drm_fb_helper_initial_config_and_unlock+0x23ad/0x2b40 + drm_fbdev_client_hotplug+0xbea/0xda0 + drm_fbdev_generic_setup+0x65e/0x9d0 + vkms_init+0x9f3/0xc76 + (...snipped...) + + CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.1.0-rc4-00356-g8f2975c2bb4c #924 + Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 + ---------- + +Signed-off-by: Tetsuo Handa +Signed-off-by: Daniel Vetter +Link: https://patchwork.freedesktop.org/patch/msgid/cad03d25-0ea0-32c4-8173-fd1895314bce@I-love.SAKURA.ne.jp +Signed-off-by: Sasha Levin +--- + drivers/video/fbdev/core/fbcon.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c +index 4a544e1e2038..673af5937489 100644 +--- a/drivers/video/fbdev/core/fbcon.c ++++ b/drivers/video/fbdev/core/fbcon.c +@@ -604,7 +604,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, + if (scr_readw(r) != vc->vc_video_erase_char) + break; + if (r != q && new_rows >= rows + logo_lines) { +- save = kmalloc(array3_size(logo_lines, new_cols, 2), ++ save = kzalloc(array3_size(logo_lines, new_cols, 2), + GFP_KERNEL); + if (save) { + int i = cols < new_cols ? cols : new_cols; +-- +2.35.1 + diff --git a/queue-5.4/mm-khugepaged-fix-gup-fast-interaction-by-sending-ip.patch b/queue-5.4/mm-khugepaged-fix-gup-fast-interaction-by-sending-ip.patch new file mode 100644 index 00000000000..6e027950890 --- /dev/null +++ b/queue-5.4/mm-khugepaged-fix-gup-fast-interaction-by-sending-ip.patch @@ -0,0 +1,107 @@ +From 8e4c7773ec8dcf01c860a9b2b011d9d2f1521ff4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 6 Dec 2022 18:16:09 +0100 +Subject: mm/khugepaged: fix GUP-fast interaction by sending IPI + +From: Jann Horn + +commit 2ba99c5e08812494bc57f319fb562f527d9bacd8 upstream. + +Since commit 70cbc3cc78a99 ("mm: gup: fix the fast GUP race against THP +collapse"), the lockless_pages_from_mm() fastpath rechecks the pmd_t to +ensure that the page table was not removed by khugepaged in between. + +However, lockless_pages_from_mm() still requires that the page table is +not concurrently freed. Fix it by sending IPIs (if the architecture uses +semi-RCU-style page table freeing) before freeing/reusing page tables. + +Link: https://lkml.kernel.org/r/20221129154730.2274278-2-jannh@google.com +Link: https://lkml.kernel.org/r/20221128180252.1684965-2-jannh@google.com +Link: https://lkml.kernel.org/r/20221125213714.4115729-2-jannh@google.com +Fixes: ba76149f47d8 ("thp: khugepaged") +Signed-off-by: Jann Horn +Reviewed-by: Yang Shi +Acked-by: David Hildenbrand +Cc: John Hubbard +Cc: Peter Xu +Cc: +Signed-off-by: Andrew Morton +[manual backport: two of the three places in khugepaged that can free +ptes were refactored into a common helper between 5.15 and 6.0; +TLB flushing was refactored between 5.4 and 5.10] +Signed-off-by: Jann Horn +Signed-off-by: Sasha Levin +--- + include/asm-generic/tlb.h | 4 ++++ + mm/khugepaged.c | 3 +++ + mm/mmu_gather.c | 5 +++++ + 3 files changed, 12 insertions(+) + +diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h +index 268674c1d568..b06240b67199 100644 +--- a/include/asm-generic/tlb.h ++++ b/include/asm-generic/tlb.h +@@ -190,12 +190,16 @@ extern void tlb_remove_table(struct mmu_gather *tlb, void *table); + #define tlb_needs_table_invalidate() (true) + #endif + ++void tlb_remove_table_sync_one(void); ++ + #else + + #ifdef tlb_needs_table_invalidate + #error tlb_needs_table_invalidate() requires HAVE_RCU_TABLE_FREE + #endif + ++static inline void tlb_remove_table_sync_one(void) { } ++ + #endif /* CONFIG_HAVE_RCU_TABLE_FREE */ + + +diff --git a/mm/khugepaged.c b/mm/khugepaged.c +index 55631cd73939..a8f2605cbd0d 100644 +--- a/mm/khugepaged.c ++++ b/mm/khugepaged.c +@@ -1060,6 +1060,7 @@ static void collapse_huge_page(struct mm_struct *mm, + _pmd = pmdp_collapse_flush(vma, address, pmd); + spin_unlock(pmd_ptl); + mmu_notifier_invalidate_range_end(&range); ++ tlb_remove_table_sync_one(); + + spin_lock(pte_ptl); + isolated = __collapse_huge_page_isolate(vma, address, pte); +@@ -1407,6 +1408,7 @@ void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr) + /* step 4: collapse pmd */ + _pmd = pmdp_collapse_flush(vma, haddr, pmd); + mm_dec_nr_ptes(mm); ++ tlb_remove_table_sync_one(); + pte_free(mm, pmd_pgtable(_pmd)); + + i_mmap_unlock_write(vma->vm_file->f_mapping); +@@ -1494,6 +1496,7 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff) + /* assume page table is clear */ + _pmd = pmdp_collapse_flush(vma, addr, pmd); + mm_dec_nr_ptes(mm); ++ tlb_remove_table_sync_one(); + pte_free(mm, pmd_pgtable(_pmd)); + } + up_write(&mm->mmap_sem); +diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c +index 7c1b8f67af7b..341aa036b03c 100644 +--- a/mm/mmu_gather.c ++++ b/mm/mmu_gather.c +@@ -117,6 +117,11 @@ static void tlb_remove_table_smp_sync(void *arg) + /* Simply deliver the interrupt */ + } + ++void tlb_remove_table_sync_one(void) ++{ ++ smp_call_function(tlb_remove_table_smp_sync, NULL, 1); ++} ++ + static void tlb_remove_table_one(void *table) + { + /* +-- +2.35.1 + diff --git a/queue-5.4/mm-khugepaged-invoke-mmu-notifiers-in-shmem-file-col.patch b/queue-5.4/mm-khugepaged-invoke-mmu-notifiers-in-shmem-file-col.patch new file mode 100644 index 00000000000..f97bd336b43 --- /dev/null +++ b/queue-5.4/mm-khugepaged-invoke-mmu-notifiers-in-shmem-file-col.patch @@ -0,0 +1,90 @@ +From b4048a65e9a46b977bfd6d5335528e8ee00e667e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 6 Dec 2022 18:16:10 +0100 +Subject: mm/khugepaged: invoke MMU notifiers in shmem/file collapse paths + +From: Jann Horn + +commit f268f6cf875f3220afc77bdd0bf1bb136eb54db9 upstream. + +Any codepath that zaps page table entries must invoke MMU notifiers to +ensure that secondary MMUs (like KVM) don't keep accessing pages which +aren't mapped anymore. Secondary MMUs don't hold their own references to +pages that are mirrored over, so failing to notify them can lead to page +use-after-free. + +I'm marking this as addressing an issue introduced in commit f3f0e1d2150b +("khugepaged: add support of collapse for tmpfs/shmem pages"), but most of +the security impact of this only came in commit 27e1f8273113 ("khugepaged: +enable collapse pmd for pte-mapped THP"), which actually omitted flushes +for the removal of present PTEs, not just for the removal of empty page +tables. + +Link: https://lkml.kernel.org/r/20221129154730.2274278-3-jannh@google.com +Link: https://lkml.kernel.org/r/20221128180252.1684965-3-jannh@google.com +Link: https://lkml.kernel.org/r/20221125213714.4115729-3-jannh@google.com +Fixes: f3f0e1d2150b ("khugepaged: add support of collapse for tmpfs/shmem pages") +Signed-off-by: Jann Horn +Acked-by: David Hildenbrand +Reviewed-by: Yang Shi +Cc: John Hubbard +Cc: Peter Xu +Cc: +Signed-off-by: Andrew Morton +[manual backport: this code was refactored from two copies into a common +helper between 5.15 and 6.0] +Signed-off-by: Jann Horn +Signed-off-by: Sasha Levin +--- + mm/khugepaged.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/mm/khugepaged.c b/mm/khugepaged.c +index a8f2605cbd0d..8e67d2e5ff39 100644 +--- a/mm/khugepaged.c ++++ b/mm/khugepaged.c +@@ -1313,6 +1313,7 @@ void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr) + spinlock_t *ptl; + int count = 0; + int i; ++ struct mmu_notifier_range range; + + if (!vma || !vma->vm_file || + vma->vm_start > haddr || vma->vm_end < haddr + HPAGE_PMD_SIZE) +@@ -1406,9 +1407,13 @@ void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr) + } + + /* step 4: collapse pmd */ ++ mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, NULL, mm, haddr, ++ haddr + HPAGE_PMD_SIZE); ++ mmu_notifier_invalidate_range_start(&range); + _pmd = pmdp_collapse_flush(vma, haddr, pmd); + mm_dec_nr_ptes(mm); + tlb_remove_table_sync_one(); ++ mmu_notifier_invalidate_range_end(&range); + pte_free(mm, pmd_pgtable(_pmd)); + + i_mmap_unlock_write(vma->vm_file->f_mapping); +@@ -1493,11 +1498,19 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff) + */ + if (down_write_trylock(&mm->mmap_sem)) { + if (!khugepaged_test_exit(mm)) { ++ struct mmu_notifier_range range; ++ ++ mmu_notifier_range_init(&range, ++ MMU_NOTIFY_CLEAR, 0, ++ NULL, mm, addr, ++ addr + HPAGE_PMD_SIZE); ++ mmu_notifier_invalidate_range_start(&range); + /* assume page table is clear */ + _pmd = pmdp_collapse_flush(vma, addr, pmd); + mm_dec_nr_ptes(mm); + tlb_remove_table_sync_one(); + pte_free(mm, pmd_pgtable(_pmd)); ++ mmu_notifier_invalidate_range_end(&range); + } + up_write(&mm->mmap_sem); + } else { +-- +2.35.1 + diff --git a/queue-5.4/mm-khugepaged-take-the-right-locks-for-page-table-re.patch b/queue-5.4/mm-khugepaged-take-the-right-locks-for-page-table-re.patch new file mode 100644 index 00000000000..e9f63df9679 --- /dev/null +++ b/queue-5.4/mm-khugepaged-take-the-right-locks-for-page-table-re.patch @@ -0,0 +1,141 @@ +From 2c8998a09ae0e0afe97d2c8373efcc5ee09181fb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 6 Dec 2022 18:16:11 +0100 +Subject: mm/khugepaged: take the right locks for page table retraction + +From: Jann Horn + +commit 8d3c106e19e8d251da31ff4cc7462e4565d65084 upstream. + +pagetable walks on address ranges mapped by VMAs can be done under the +mmap lock, the lock of an anon_vma attached to the VMA, or the lock of the +VMA's address_space. Only one of these needs to be held, and it does not +need to be held in exclusive mode. + +Under those circumstances, the rules for concurrent access to page table +entries are: + + - Terminal page table entries (entries that don't point to another page + table) can be arbitrarily changed under the page table lock, with the + exception that they always need to be consistent for + hardware page table walks and lockless_pages_from_mm(). + This includes that they can be changed into non-terminal entries. + - Non-terminal page table entries (which point to another page table) + can not be modified; readers are allowed to READ_ONCE() an entry, verify + that it is non-terminal, and then assume that its value will stay as-is. + +Retracting a page table involves modifying a non-terminal entry, so +page-table-level locks are insufficient to protect against concurrent page +table traversal; it requires taking all the higher-level locks under which +it is possible to start a page walk in the relevant range in exclusive +mode. + +The collapse_huge_page() path for anonymous THP already follows this rule, +but the shmem/file THP path was getting it wrong, making it possible for +concurrent rmap-based operations to cause corruption. + +Link: https://lkml.kernel.org/r/20221129154730.2274278-1-jannh@google.com +Link: https://lkml.kernel.org/r/20221128180252.1684965-1-jannh@google.com +Link: https://lkml.kernel.org/r/20221125213714.4115729-1-jannh@google.com +Fixes: 27e1f8273113 ("khugepaged: enable collapse pmd for pte-mapped THP") +Signed-off-by: Jann Horn +Reviewed-by: Yang Shi +Acked-by: David Hildenbrand +Cc: John Hubbard +Cc: Peter Xu +Cc: +Signed-off-by: Andrew Morton +[manual backport: this code was refactored from two copies into a common +helper between 5.15 and 6.0] +Signed-off-by: Jann Horn +Signed-off-by: Sasha Levin +--- + mm/khugepaged.c | 31 ++++++++++++++++++++++++++----- + 1 file changed, 26 insertions(+), 5 deletions(-) + +diff --git a/mm/khugepaged.c b/mm/khugepaged.c +index 3c2326568193..55631cd73939 100644 +--- a/mm/khugepaged.c ++++ b/mm/khugepaged.c +@@ -1326,6 +1326,14 @@ void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr) + if (!hugepage_vma_check(vma, vma->vm_flags | VM_HUGEPAGE)) + return; + ++ /* ++ * Symmetry with retract_page_tables(): Exclude MAP_PRIVATE mappings ++ * that got written to. Without this, we'd have to also lock the ++ * anon_vma if one exists. ++ */ ++ if (vma->anon_vma) ++ return; ++ + hpage = find_lock_page(vma->vm_file->f_mapping, + linear_page_index(vma, haddr)); + if (!hpage) +@@ -1338,6 +1346,19 @@ void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr) + if (!pmd) + goto drop_hpage; + ++ /* ++ * We need to lock the mapping so that from here on, only GUP-fast and ++ * hardware page walks can access the parts of the page tables that ++ * we're operating on. ++ */ ++ i_mmap_lock_write(vma->vm_file->f_mapping); ++ ++ /* ++ * This spinlock should be unnecessary: Nobody else should be accessing ++ * the page tables under spinlock protection here, only ++ * lockless_pages_from_mm() and the hardware page walker can access page ++ * tables while all the high-level locks are held in write mode. ++ */ + start_pte = pte_offset_map_lock(mm, pmd, haddr, &ptl); + + /* step 1: check all mapped PTEs are to the right huge page */ +@@ -1384,12 +1405,12 @@ void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr) + } + + /* step 4: collapse pmd */ +- ptl = pmd_lock(vma->vm_mm, pmd); + _pmd = pmdp_collapse_flush(vma, haddr, pmd); +- spin_unlock(ptl); + mm_dec_nr_ptes(mm); + pte_free(mm, pmd_pgtable(_pmd)); + ++ i_mmap_unlock_write(vma->vm_file->f_mapping); ++ + drop_hpage: + unlock_page(hpage); + put_page(hpage); +@@ -1397,6 +1418,7 @@ void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr) + + abort: + pte_unmap_unlock(start_pte, ptl); ++ i_mmap_unlock_write(vma->vm_file->f_mapping); + goto drop_hpage; + } + +@@ -1446,7 +1468,8 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff) + * An alternative would be drop the check, but check that page + * table is clear before calling pmdp_collapse_flush() under + * ptl. It has higher chance to recover THP for the VMA, but +- * has higher cost too. ++ * has higher cost too. It would also probably require locking ++ * the anon_vma. + */ + if (vma->anon_vma) + continue; +@@ -1468,10 +1491,8 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff) + */ + if (down_write_trylock(&mm->mmap_sem)) { + if (!khugepaged_test_exit(mm)) { +- spinlock_t *ptl = pmd_lock(mm, pmd); + /* assume page table is clear */ + _pmd = pmdp_collapse_flush(vma, addr, pmd); +- spin_unlock(ptl); + mm_dec_nr_ptes(mm); + pte_free(mm, pmd_pgtable(_pmd)); + } +-- +2.35.1 + diff --git a/queue-5.4/net-usb-qmi_wwan-add-u-blox-0x1342-composition.patch b/queue-5.4/net-usb-qmi_wwan-add-u-blox-0x1342-composition.patch new file mode 100644 index 00000000000..35850e7c0d9 --- /dev/null +++ b/queue-5.4/net-usb-qmi_wwan-add-u-blox-0x1342-composition.patch @@ -0,0 +1,53 @@ +From 4e398ee2eea637ccd633a7213a32ad81a069116e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 21 Nov 2022 13:54:55 +0100 +Subject: net: usb: qmi_wwan: add u-blox 0x1342 composition +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Davide Tronchin + +[ Upstream commit a487069e11b6527373f7c6f435d8998051d0b5d9 ] + +Add RmNet support for LARA-L6. + +LARA-L6 module can be configured (by AT interface) in three different +USB modes: +* Default mode (Vendor ID: 0x1546 Product ID: 0x1341) with 4 serial +interfaces +* RmNet mode (Vendor ID: 0x1546 Product ID: 0x1342) with 4 serial +interfaces and 1 RmNet virtual network interface +* CDC-ECM mode (Vendor ID: 0x1546 Product ID: 0x1343) with 4 serial +interface and 1 CDC-ECM virtual network interface + +In RmNet mode LARA-L6 exposes the following interfaces: +If 0: Diagnostic +If 1: AT parser +If 2: AT parser +If 3: AT parset/alternative functions +If 4: RMNET interface + +Signed-off-by: Davide Tronchin +Acked-by: Bjørn Mork +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/usb/qmi_wwan.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c +index 7f0e3b09f776..c310cdbfd583 100644 +--- a/drivers/net/usb/qmi_wwan.c ++++ b/drivers/net/usb/qmi_wwan.c +@@ -1374,6 +1374,7 @@ static const struct usb_device_id products[] = { + {QMI_FIXED_INTF(0x0489, 0xe0b4, 0)}, /* Foxconn T77W968 LTE */ + {QMI_FIXED_INTF(0x0489, 0xe0b5, 0)}, /* Foxconn T77W968 LTE with eSIM support*/ + {QMI_FIXED_INTF(0x2692, 0x9025, 4)}, /* Cellient MPL200 (rebranded Qualcomm 05c6:9025) */ ++ {QMI_QUIRK_SET_DTR(0x1546, 0x1342, 4)}, /* u-blox LARA-L6 */ + + /* 4. Gobi 1000 devices */ + {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ +-- +2.35.1 + diff --git a/queue-5.4/regulator-slg51000-wait-after-asserting-cs-pin.patch b/queue-5.4/regulator-slg51000-wait-after-asserting-cs-pin.patch new file mode 100644 index 00000000000..fd528a63451 --- /dev/null +++ b/queue-5.4/regulator-slg51000-wait-after-asserting-cs-pin.patch @@ -0,0 +1,44 @@ +From 557759c2a40c03c998b390d9b0fd857d1df13669 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 18 Nov 2022 14:10:35 +0100 +Subject: regulator: slg51000: Wait after asserting CS pin + +From: Konrad Dybcio + +[ Upstream commit 0b24dfa587c6cc7484cfb170da5c7dd73451f670 ] + +Sony's downstream driver [1], among some other changes, adds a +seemingly random 10ms usleep_range, which turned out to be necessary +for the hardware to function properly on at least Sony Xperia 1 IV. +Without this, I2C transactions with the SLG51000 straight up fail. + +Relax (10-10ms -> 10-11ms) and add the aforementioned sleep to make +sure the hardware has some time to wake up. + +(nagara-2.0.0-mlc/vendor/semc/hardware/camera-kernel-module/) +[1] https://developer.sony.com/file/download/open-source-archive-for-64-0-m-4-29/ + +Signed-off-by: Konrad Dybcio +Link: https://lore.kernel.org/r/20221118131035.54874-1-konrad.dybcio@linaro.org +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + drivers/regulator/slg51000-regulator.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/regulator/slg51000-regulator.c b/drivers/regulator/slg51000-regulator.c +index a0565daecace..5a18d7e620a5 100644 +--- a/drivers/regulator/slg51000-regulator.c ++++ b/drivers/regulator/slg51000-regulator.c +@@ -465,6 +465,8 @@ static int slg51000_i2c_probe(struct i2c_client *client, + chip->cs_gpiod = cs_gpiod; + } + ++ usleep_range(10000, 11000); ++ + i2c_set_clientdata(client, chip); + chip->chip_irq = client->irq; + chip->dev = dev; +-- +2.35.1 + diff --git a/queue-5.4/regulator-twl6030-fix-get-status-of-twl6032-regulato.patch b/queue-5.4/regulator-twl6030-fix-get-status-of-twl6032-regulato.patch new file mode 100644 index 00000000000..ec7eb153cd8 --- /dev/null +++ b/queue-5.4/regulator-twl6030-fix-get-status-of-twl6032-regulato.patch @@ -0,0 +1,69 @@ +From 026c3568c3f7f62a33275b4b03d306a852ec151c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 20 Nov 2022 23:12:08 +0100 +Subject: regulator: twl6030: fix get status of twl6032 regulators + +From: Andreas Kemnade + +[ Upstream commit 31a6297b89aabc81b274c093a308a7f5b55081a7 ] + +Status is reported as always off in the 6032 case. Status +reporting now matches the logic in the setters. Once of +the differences to the 6030 is that there are no groups, +therefore the state needs to be read out in the lower bits. + +Signed-off-by: Andreas Kemnade +Link: https://lore.kernel.org/r/20221120221208.3093727-3-andreas@kemnade.info +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + drivers/regulator/twl6030-regulator.c | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +diff --git a/drivers/regulator/twl6030-regulator.c b/drivers/regulator/twl6030-regulator.c +index 4ffb32ffec35..71625db3a6f1 100644 +--- a/drivers/regulator/twl6030-regulator.c ++++ b/drivers/regulator/twl6030-regulator.c +@@ -67,6 +67,7 @@ struct twlreg_info { + #define TWL6030_CFG_STATE_SLEEP 0x03 + #define TWL6030_CFG_STATE_GRP_SHIFT 5 + #define TWL6030_CFG_STATE_APP_SHIFT 2 ++#define TWL6030_CFG_STATE_MASK 0x03 + #define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT) + #define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\ + TWL6030_CFG_STATE_APP_SHIFT) +@@ -128,13 +129,14 @@ static int twl6030reg_is_enabled(struct regulator_dev *rdev) + if (grp < 0) + return grp; + grp &= P1_GRP_6030; ++ val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); ++ val = TWL6030_CFG_STATE_APP(val); + } else { ++ val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); ++ val &= TWL6030_CFG_STATE_MASK; + grp = 1; + } + +- val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); +- val = TWL6030_CFG_STATE_APP(val); +- + return grp && (val == TWL6030_CFG_STATE_ON); + } + +@@ -187,7 +189,12 @@ static int twl6030reg_get_status(struct regulator_dev *rdev) + + val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); + +- switch (TWL6030_CFG_STATE_APP(val)) { ++ if (info->features & TWL6032_SUBCLASS) ++ val &= TWL6030_CFG_STATE_MASK; ++ else ++ val = TWL6030_CFG_STATE_APP(val); ++ ++ switch (val) { + case TWL6030_CFG_STATE_ON: + return REGULATOR_STATUS_NORMAL; + +-- +2.35.1 + diff --git a/queue-5.4/series b/queue-5.4/series new file mode 100644 index 00000000000..1e47eeb01bb --- /dev/null +++ b/queue-5.4/series @@ -0,0 +1,22 @@ +arm64-dts-rockchip-keep-i2s1-disabled-for-gpio-funct.patch +arm-dts-rockchip-fix-node-name-for-hym8563-rtc.patch +arm-dts-rockchip-fix-ir-receiver-node-names.patch +arm-dts-rockchip-rk3188-fix-lcdc1-rgb24-node-name.patch +arm-9251-1-perf-fix-stacktraces-for-tracepoint-event.patch +arm-9266-1-mm-fix-no-mmu-zero_page-implementation.patch +arm-dts-rockchip-disable-arm_global_timer-on-rk3066-.patch +9p-fd-use-p9_hdrsz-for-header-size.patch +regulator-slg51000-wait-after-asserting-cs-pin.patch +alsa-seq-fix-function-prototype-mismatch-in-snd_seq_.patch +btrfs-send-avoid-unaligned-encoded-writes-when-attem.patch +asoc-soc-pcm-add-null-check-in-be-reparenting.patch +regulator-twl6030-fix-get-status-of-twl6032-regulato.patch +fbcon-use-kzalloc-in-fbcon_prepare_logo.patch +9p-xen-check-logical-size-for-buffer-size.patch +net-usb-qmi_wwan-add-u-blox-0x1342-composition.patch +mm-khugepaged-take-the-right-locks-for-page-table-re.patch +mm-khugepaged-fix-gup-fast-interaction-by-sending-ip.patch +mm-khugepaged-invoke-mmu-notifiers-in-shmem-file-col.patch +xen-netback-ensure-protocol-headers-don-t-fall-in-th.patch +xen-netback-do-some-code-cleanup.patch +xen-netback-don-t-call-kfree_skb-with-interrupts-dis.patch diff --git a/queue-5.4/xen-netback-do-some-code-cleanup.patch b/queue-5.4/xen-netback-do-some-code-cleanup.patch new file mode 100644 index 00000000000..087fed74105 --- /dev/null +++ b/queue-5.4/xen-netback-do-some-code-cleanup.patch @@ -0,0 +1,147 @@ +From dd1cbce34e5fee30583d1aa8dba6c14e376816a9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 8 Jun 2022 06:37:26 +0200 +Subject: xen/netback: do some code cleanup + +From: Juergen Gross + +[ Upstream commit 5834e72eda0b7e5767eb107259d98eef19ebd11f ] + +Remove some unused macros and functions, make local functions static. + +Signed-off-by: Juergen Gross +Acked-by: Wei Liu +Link: https://lore.kernel.org/r/20220608043726.9380-1-jgross@suse.com +Signed-off-by: Jakub Kicinski +Stable-dep-of: 74e7e1efdad4 ("xen/netback: don't call kfree_skb() with interrupts disabled") +Signed-off-by: Sasha Levin +--- + drivers/net/xen-netback/common.h | 12 ------------ + drivers/net/xen-netback/interface.c | 16 +--------------- + drivers/net/xen-netback/netback.c | 4 +++- + drivers/net/xen-netback/rx.c | 2 +- + 4 files changed, 5 insertions(+), 29 deletions(-) + +diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h +index f7e746f1c9fb..fa52d5ffca72 100644 +--- a/drivers/net/xen-netback/common.h ++++ b/drivers/net/xen-netback/common.h +@@ -48,7 +48,6 @@ + #include + + typedef unsigned int pending_ring_idx_t; +-#define INVALID_PENDING_RING_IDX (~0U) + + struct pending_tx_info { + struct xen_netif_tx_request req; /* tx request */ +@@ -82,8 +81,6 @@ struct xenvif_rx_meta { + /* Discriminate from any valid pending_idx value. */ + #define INVALID_PENDING_IDX 0xFFFF + +-#define MAX_BUFFER_OFFSET XEN_PAGE_SIZE +- + #define MAX_PENDING_REQS XEN_NETIF_TX_RING_SIZE + + /* The maximum number of frags is derived from the size of a grant (same +@@ -364,11 +361,6 @@ void xenvif_free(struct xenvif *vif); + int xenvif_xenbus_init(void); + void xenvif_xenbus_fini(void); + +-int xenvif_schedulable(struct xenvif *vif); +- +-int xenvif_queue_stopped(struct xenvif_queue *queue); +-void xenvif_wake_queue(struct xenvif_queue *queue); +- + /* (Un)Map communication rings. */ + void xenvif_unmap_frontend_data_rings(struct xenvif_queue *queue); + int xenvif_map_frontend_data_rings(struct xenvif_queue *queue, +@@ -391,7 +383,6 @@ int xenvif_dealloc_kthread(void *data); + irqreturn_t xenvif_ctrl_irq_fn(int irq, void *data); + + bool xenvif_have_rx_work(struct xenvif_queue *queue, bool test_kthread); +-void xenvif_rx_action(struct xenvif_queue *queue); + void xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb); + + void xenvif_carrier_on(struct xenvif *vif); +@@ -399,9 +390,6 @@ void xenvif_carrier_on(struct xenvif *vif); + /* Callback from stack when TX packet can be released */ + void xenvif_zerocopy_callback(struct ubuf_info *ubuf, bool zerocopy_success); + +-/* Unmap a pending page and release it back to the guest */ +-void xenvif_idx_unmap(struct xenvif_queue *queue, u16 pending_idx); +- + static inline pending_ring_idx_t nr_pending_reqs(struct xenvif_queue *queue) + { + return MAX_PENDING_REQS - +diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c +index 809089587301..5efe86b3ba06 100644 +--- a/drivers/net/xen-netback/interface.c ++++ b/drivers/net/xen-netback/interface.c +@@ -70,7 +70,7 @@ void xenvif_skb_zerocopy_complete(struct xenvif_queue *queue) + wake_up(&queue->dealloc_wq); + } + +-int xenvif_schedulable(struct xenvif *vif) ++static int xenvif_schedulable(struct xenvif *vif) + { + return netif_running(vif->dev) && + test_bit(VIF_STATUS_CONNECTED, &vif->status) && +@@ -178,20 +178,6 @@ irqreturn_t xenvif_interrupt(int irq, void *dev_id) + return IRQ_HANDLED; + } + +-int xenvif_queue_stopped(struct xenvif_queue *queue) +-{ +- struct net_device *dev = queue->vif->dev; +- unsigned int id = queue->id; +- return netif_tx_queue_stopped(netdev_get_tx_queue(dev, id)); +-} +- +-void xenvif_wake_queue(struct xenvif_queue *queue) +-{ +- struct net_device *dev = queue->vif->dev; +- unsigned int id = queue->id; +- netif_tx_wake_queue(netdev_get_tx_queue(dev, id)); +-} +- + static u16 xenvif_select_queue(struct net_device *dev, struct sk_buff *skb, + struct net_device *sb_dev) + { +diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c +index 5706a1694c9c..982e501173f1 100644 +--- a/drivers/net/xen-netback/netback.c ++++ b/drivers/net/xen-netback/netback.c +@@ -105,6 +105,8 @@ static void make_tx_response(struct xenvif_queue *queue, + s8 st); + static void push_tx_responses(struct xenvif_queue *queue); + ++static void xenvif_idx_unmap(struct xenvif_queue *queue, u16 pending_idx); ++ + static inline int tx_work_todo(struct xenvif_queue *queue); + + static inline unsigned long idx_to_pfn(struct xenvif_queue *queue, +@@ -1433,7 +1435,7 @@ static void push_tx_responses(struct xenvif_queue *queue) + notify_remote_via_irq(queue->tx_irq); + } + +-void xenvif_idx_unmap(struct xenvif_queue *queue, u16 pending_idx) ++static void xenvif_idx_unmap(struct xenvif_queue *queue, u16 pending_idx) + { + int ret; + struct gnttab_unmap_grant_ref tx_unmap_op; +diff --git a/drivers/net/xen-netback/rx.c b/drivers/net/xen-netback/rx.c +index 85a5a622ec18..6f940a32dcb8 100644 +--- a/drivers/net/xen-netback/rx.c ++++ b/drivers/net/xen-netback/rx.c +@@ -473,7 +473,7 @@ static void xenvif_rx_skb(struct xenvif_queue *queue) + + #define RX_BATCH_SIZE 64 + +-void xenvif_rx_action(struct xenvif_queue *queue) ++static void xenvif_rx_action(struct xenvif_queue *queue) + { + struct sk_buff_head completed_skbs; + unsigned int work_done = 0; +-- +2.35.1 + diff --git a/queue-5.4/xen-netback-don-t-call-kfree_skb-with-interrupts-dis.patch b/queue-5.4/xen-netback-don-t-call-kfree_skb-with-interrupts-dis.patch new file mode 100644 index 00000000000..a6ac5b2e2ba --- /dev/null +++ b/queue-5.4/xen-netback-don-t-call-kfree_skb-with-interrupts-dis.patch @@ -0,0 +1,105 @@ +From 6c8b56459cc451660516ae5918d1ebdb002fb8b2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 6 Dec 2022 08:54:24 +0100 +Subject: xen/netback: don't call kfree_skb() with interrupts disabled + +From: Juergen Gross + +[ Upstream commit 74e7e1efdad45580cc3839f2a155174cf158f9b5 ] + +It is not allowed to call kfree_skb() from hardware interrupt +context or with interrupts being disabled. So remove kfree_skb() +from the spin_lock_irqsave() section and use the already existing +"drop" label in xenvif_start_xmit() for dropping the SKB. At the +same time replace the dev_kfree_skb() call there with a call of +dev_kfree_skb_any(), as xenvif_start_xmit() can be called with +disabled interrupts. + +This is XSA-424 / CVE-2022-42328 / CVE-2022-42329. + +Fixes: be81992f9086 ("xen/netback: don't queue unlimited number of packages") +Reported-by: Yang Yingliang +Signed-off-by: Juergen Gross +Reviewed-by: Jan Beulich +Signed-off-by: Juergen Gross +Signed-off-by: Sasha Levin +--- + drivers/net/xen-netback/common.h | 2 +- + drivers/net/xen-netback/interface.c | 6 ++++-- + drivers/net/xen-netback/rx.c | 8 +++++--- + 3 files changed, 10 insertions(+), 6 deletions(-) + +diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h +index fa52d5ffca72..ced413d394cd 100644 +--- a/drivers/net/xen-netback/common.h ++++ b/drivers/net/xen-netback/common.h +@@ -383,7 +383,7 @@ int xenvif_dealloc_kthread(void *data); + irqreturn_t xenvif_ctrl_irq_fn(int irq, void *data); + + bool xenvif_have_rx_work(struct xenvif_queue *queue, bool test_kthread); +-void xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb); ++bool xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb); + + void xenvif_carrier_on(struct xenvif *vif); + +diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c +index 5efe86b3ba06..6432f6e7fd54 100644 +--- a/drivers/net/xen-netback/interface.c ++++ b/drivers/net/xen-netback/interface.c +@@ -255,14 +255,16 @@ xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev) + if (vif->hash.alg == XEN_NETIF_CTRL_HASH_ALGORITHM_NONE) + skb_clear_hash(skb); + +- xenvif_rx_queue_tail(queue, skb); ++ if (!xenvif_rx_queue_tail(queue, skb)) ++ goto drop; ++ + xenvif_kick_thread(queue); + + return NETDEV_TX_OK; + + drop: + vif->dev->stats.tx_dropped++; +- dev_kfree_skb(skb); ++ dev_kfree_skb_any(skb); + return NETDEV_TX_OK; + } + +diff --git a/drivers/net/xen-netback/rx.c b/drivers/net/xen-netback/rx.c +index 6f940a32dcb8..ab216970137c 100644 +--- a/drivers/net/xen-netback/rx.c ++++ b/drivers/net/xen-netback/rx.c +@@ -82,9 +82,10 @@ static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue) + return false; + } + +-void xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb) ++bool xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb) + { + unsigned long flags; ++ bool ret = true; + + spin_lock_irqsave(&queue->rx_queue.lock, flags); + +@@ -92,8 +93,7 @@ void xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb) + struct net_device *dev = queue->vif->dev; + + netif_tx_stop_queue(netdev_get_tx_queue(dev, queue->id)); +- kfree_skb(skb); +- queue->vif->dev->stats.rx_dropped++; ++ ret = false; + } else { + if (skb_queue_empty(&queue->rx_queue)) + xenvif_update_needed_slots(queue, skb); +@@ -104,6 +104,8 @@ void xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb) + } + + spin_unlock_irqrestore(&queue->rx_queue.lock, flags); ++ ++ return ret; + } + + static struct sk_buff *xenvif_rx_dequeue(struct xenvif_queue *queue) +-- +2.35.1 + diff --git a/queue-5.4/xen-netback-ensure-protocol-headers-don-t-fall-in-th.patch b/queue-5.4/xen-netback-ensure-protocol-headers-don-t-fall-in-th.patch new file mode 100644 index 00000000000..2527b976231 --- /dev/null +++ b/queue-5.4/xen-netback-ensure-protocol-headers-don-t-fall-in-th.patch @@ -0,0 +1,390 @@ +From 74fdb1fa0d1ebd09bcf0408396accce7b00af896 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 22 Nov 2022 09:16:59 +0000 +Subject: xen/netback: Ensure protocol headers don't fall in the non-linear + area + +From: Ross Lagerwall + +[ Upstream commit ad7f402ae4f466647c3a669b8a6f3e5d4271c84a ] + +In some cases, the frontend may send a packet where the protocol headers +are spread across multiple slots. This would result in netback creating +an skb where the protocol headers spill over into the non-linear area. +Some drivers and NICs don't handle this properly resulting in an +interface reset or worse. + +This issue was introduced by the removal of an unconditional skb pull in +the tx path to improve performance. Fix this without reintroducing the +pull by setting up grant copy ops for as many slots as needed to reach +the XEN_NETBACK_TX_COPY_LEN size. Adjust the rest of the code to handle +multiple copy operations per skb. + +This is XSA-423 / CVE-2022-3643. + +Fixes: 7e5d7753956b ("xen-netback: remove unconditional __pskb_pull_tail() in guest Tx path") +Signed-off-by: Ross Lagerwall +Reviewed-by: Paul Durrant +Signed-off-by: Juergen Gross +Signed-off-by: Sasha Levin +--- + drivers/net/xen-netback/netback.c | 223 ++++++++++++++++-------------- + 1 file changed, 123 insertions(+), 100 deletions(-) + +diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c +index 995566a2785f..5706a1694c9c 100644 +--- a/drivers/net/xen-netback/netback.c ++++ b/drivers/net/xen-netback/netback.c +@@ -323,10 +323,13 @@ static int xenvif_count_requests(struct xenvif_queue *queue, + + + struct xenvif_tx_cb { +- u16 pending_idx; ++ u16 copy_pending_idx[XEN_NETBK_LEGACY_SLOTS_MAX + 1]; ++ u8 copy_count; + }; + + #define XENVIF_TX_CB(skb) ((struct xenvif_tx_cb *)(skb)->cb) ++#define copy_pending_idx(skb, i) (XENVIF_TX_CB(skb)->copy_pending_idx[i]) ++#define copy_count(skb) (XENVIF_TX_CB(skb)->copy_count) + + static inline void xenvif_tx_create_map_op(struct xenvif_queue *queue, + u16 pending_idx, +@@ -361,31 +364,93 @@ static inline struct sk_buff *xenvif_alloc_skb(unsigned int size) + return skb; + } + +-static struct gnttab_map_grant_ref *xenvif_get_requests(struct xenvif_queue *queue, +- struct sk_buff *skb, +- struct xen_netif_tx_request *txp, +- struct gnttab_map_grant_ref *gop, +- unsigned int frag_overflow, +- struct sk_buff *nskb) ++static void xenvif_get_requests(struct xenvif_queue *queue, ++ struct sk_buff *skb, ++ struct xen_netif_tx_request *first, ++ struct xen_netif_tx_request *txfrags, ++ unsigned *copy_ops, ++ unsigned *map_ops, ++ unsigned int frag_overflow, ++ struct sk_buff *nskb, ++ unsigned int extra_count, ++ unsigned int data_len) + { + struct skb_shared_info *shinfo = skb_shinfo(skb); + skb_frag_t *frags = shinfo->frags; +- u16 pending_idx = XENVIF_TX_CB(skb)->pending_idx; +- int start; ++ u16 pending_idx; + pending_ring_idx_t index; + unsigned int nr_slots; ++ struct gnttab_copy *cop = queue->tx_copy_ops + *copy_ops; ++ struct gnttab_map_grant_ref *gop = queue->tx_map_ops + *map_ops; ++ struct xen_netif_tx_request *txp = first; ++ ++ nr_slots = shinfo->nr_frags + 1; ++ ++ copy_count(skb) = 0; ++ ++ /* Create copy ops for exactly data_len bytes into the skb head. */ ++ __skb_put(skb, data_len); ++ while (data_len > 0) { ++ int amount = data_len > txp->size ? txp->size : data_len; ++ ++ cop->source.u.ref = txp->gref; ++ cop->source.domid = queue->vif->domid; ++ cop->source.offset = txp->offset; ++ ++ cop->dest.domid = DOMID_SELF; ++ cop->dest.offset = (offset_in_page(skb->data + ++ skb_headlen(skb) - ++ data_len)) & ~XEN_PAGE_MASK; ++ cop->dest.u.gmfn = virt_to_gfn(skb->data + skb_headlen(skb) ++ - data_len); ++ ++ cop->len = amount; ++ cop->flags = GNTCOPY_source_gref; + +- nr_slots = shinfo->nr_frags; ++ index = pending_index(queue->pending_cons); ++ pending_idx = queue->pending_ring[index]; ++ callback_param(queue, pending_idx).ctx = NULL; ++ copy_pending_idx(skb, copy_count(skb)) = pending_idx; ++ copy_count(skb)++; ++ ++ cop++; ++ data_len -= amount; + +- /* Skip first skb fragment if it is on same page as header fragment. */ +- start = (frag_get_pending_idx(&shinfo->frags[0]) == pending_idx); ++ if (amount == txp->size) { ++ /* The copy op covered the full tx_request */ ++ ++ memcpy(&queue->pending_tx_info[pending_idx].req, ++ txp, sizeof(*txp)); ++ queue->pending_tx_info[pending_idx].extra_count = ++ (txp == first) ? extra_count : 0; ++ ++ if (txp == first) ++ txp = txfrags; ++ else ++ txp++; ++ queue->pending_cons++; ++ nr_slots--; ++ } else { ++ /* The copy op partially covered the tx_request. ++ * The remainder will be mapped. ++ */ ++ txp->offset += amount; ++ txp->size -= amount; ++ } ++ } + +- for (shinfo->nr_frags = start; shinfo->nr_frags < nr_slots; +- shinfo->nr_frags++, txp++, gop++) { ++ for (shinfo->nr_frags = 0; shinfo->nr_frags < nr_slots; ++ shinfo->nr_frags++, gop++) { + index = pending_index(queue->pending_cons++); + pending_idx = queue->pending_ring[index]; +- xenvif_tx_create_map_op(queue, pending_idx, txp, 0, gop); ++ xenvif_tx_create_map_op(queue, pending_idx, txp, ++ txp == first ? extra_count : 0, gop); + frag_set_pending_idx(&frags[shinfo->nr_frags], pending_idx); ++ ++ if (txp == first) ++ txp = txfrags; ++ else ++ txp++; + } + + if (frag_overflow) { +@@ -406,7 +471,8 @@ static struct gnttab_map_grant_ref *xenvif_get_requests(struct xenvif_queue *que + skb_shinfo(skb)->frag_list = nskb; + } + +- return gop; ++ (*copy_ops) = cop - queue->tx_copy_ops; ++ (*map_ops) = gop - queue->tx_map_ops; + } + + static inline void xenvif_grant_handle_set(struct xenvif_queue *queue, +@@ -442,7 +508,7 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue, + struct gnttab_copy **gopp_copy) + { + struct gnttab_map_grant_ref *gop_map = *gopp_map; +- u16 pending_idx = XENVIF_TX_CB(skb)->pending_idx; ++ u16 pending_idx; + /* This always points to the shinfo of the skb being checked, which + * could be either the first or the one on the frag_list + */ +@@ -453,24 +519,37 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue, + struct skb_shared_info *first_shinfo = NULL; + int nr_frags = shinfo->nr_frags; + const bool sharedslot = nr_frags && +- frag_get_pending_idx(&shinfo->frags[0]) == pending_idx; ++ frag_get_pending_idx(&shinfo->frags[0]) == ++ copy_pending_idx(skb, copy_count(skb) - 1); + int i, err; + +- /* Check status of header. */ +- err = (*gopp_copy)->status; +- if (unlikely(err)) { +- if (net_ratelimit()) +- netdev_dbg(queue->vif->dev, +- "Grant copy of header failed! status: %d pending_idx: %u ref: %u\n", +- (*gopp_copy)->status, +- pending_idx, +- (*gopp_copy)->source.u.ref); +- /* The first frag might still have this slot mapped */ +- if (!sharedslot) +- xenvif_idx_release(queue, pending_idx, +- XEN_NETIF_RSP_ERROR); ++ for (i = 0; i < copy_count(skb); i++) { ++ int newerr; ++ ++ /* Check status of header. */ ++ pending_idx = copy_pending_idx(skb, i); ++ ++ newerr = (*gopp_copy)->status; ++ if (likely(!newerr)) { ++ /* The first frag might still have this slot mapped */ ++ if (i < copy_count(skb) - 1 || !sharedslot) ++ xenvif_idx_release(queue, pending_idx, ++ XEN_NETIF_RSP_OKAY); ++ } else { ++ err = newerr; ++ if (net_ratelimit()) ++ netdev_dbg(queue->vif->dev, ++ "Grant copy of header failed! status: %d pending_idx: %u ref: %u\n", ++ (*gopp_copy)->status, ++ pending_idx, ++ (*gopp_copy)->source.u.ref); ++ /* The first frag might still have this slot mapped */ ++ if (i < copy_count(skb) - 1 || !sharedslot) ++ xenvif_idx_release(queue, pending_idx, ++ XEN_NETIF_RSP_ERROR); ++ } ++ (*gopp_copy)++; + } +- (*gopp_copy)++; + + check_frags: + for (i = 0; i < nr_frags; i++, gop_map++) { +@@ -517,14 +596,6 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue, + if (err) + continue; + +- /* First error: if the header haven't shared a slot with the +- * first frag, release it as well. +- */ +- if (!sharedslot) +- xenvif_idx_release(queue, +- XENVIF_TX_CB(skb)->pending_idx, +- XEN_NETIF_RSP_OKAY); +- + /* Invalidate preceding fragments of this skb. */ + for (j = 0; j < i; j++) { + pending_idx = frag_get_pending_idx(&shinfo->frags[j]); +@@ -794,7 +865,6 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, + unsigned *copy_ops, + unsigned *map_ops) + { +- struct gnttab_map_grant_ref *gop = queue->tx_map_ops; + struct sk_buff *skb, *nskb; + int ret; + unsigned int frag_overflow; +@@ -876,8 +946,12 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, + continue; + } + ++ data_len = (txreq.size > XEN_NETBACK_TX_COPY_LEN) ? ++ XEN_NETBACK_TX_COPY_LEN : txreq.size; ++ + ret = xenvif_count_requests(queue, &txreq, extra_count, + txfrags, work_to_do); ++ + if (unlikely(ret < 0)) + break; + +@@ -903,9 +977,8 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, + index = pending_index(queue->pending_cons); + pending_idx = queue->pending_ring[index]; + +- data_len = (txreq.size > XEN_NETBACK_TX_COPY_LEN && +- ret < XEN_NETBK_LEGACY_SLOTS_MAX) ? +- XEN_NETBACK_TX_COPY_LEN : txreq.size; ++ if (ret >= XEN_NETBK_LEGACY_SLOTS_MAX - 1 && data_len < txreq.size) ++ data_len = txreq.size; + + skb = xenvif_alloc_skb(data_len); + if (unlikely(skb == NULL)) { +@@ -916,8 +989,6 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, + } + + skb_shinfo(skb)->nr_frags = ret; +- if (data_len < txreq.size) +- skb_shinfo(skb)->nr_frags++; + /* At this point shinfo->nr_frags is in fact the number of + * slots, which can be as large as XEN_NETBK_LEGACY_SLOTS_MAX. + */ +@@ -979,54 +1050,19 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, + type); + } + +- XENVIF_TX_CB(skb)->pending_idx = pending_idx; +- +- __skb_put(skb, data_len); +- queue->tx_copy_ops[*copy_ops].source.u.ref = txreq.gref; +- queue->tx_copy_ops[*copy_ops].source.domid = queue->vif->domid; +- queue->tx_copy_ops[*copy_ops].source.offset = txreq.offset; +- +- queue->tx_copy_ops[*copy_ops].dest.u.gmfn = +- virt_to_gfn(skb->data); +- queue->tx_copy_ops[*copy_ops].dest.domid = DOMID_SELF; +- queue->tx_copy_ops[*copy_ops].dest.offset = +- offset_in_page(skb->data) & ~XEN_PAGE_MASK; +- +- queue->tx_copy_ops[*copy_ops].len = data_len; +- queue->tx_copy_ops[*copy_ops].flags = GNTCOPY_source_gref; +- +- (*copy_ops)++; +- +- if (data_len < txreq.size) { +- frag_set_pending_idx(&skb_shinfo(skb)->frags[0], +- pending_idx); +- xenvif_tx_create_map_op(queue, pending_idx, &txreq, +- extra_count, gop); +- gop++; +- } else { +- frag_set_pending_idx(&skb_shinfo(skb)->frags[0], +- INVALID_PENDING_IDX); +- memcpy(&queue->pending_tx_info[pending_idx].req, +- &txreq, sizeof(txreq)); +- queue->pending_tx_info[pending_idx].extra_count = +- extra_count; +- } +- +- queue->pending_cons++; +- +- gop = xenvif_get_requests(queue, skb, txfrags, gop, +- frag_overflow, nskb); ++ xenvif_get_requests(queue, skb, &txreq, txfrags, copy_ops, ++ map_ops, frag_overflow, nskb, extra_count, ++ data_len); + + __skb_queue_tail(&queue->tx_queue, skb); + + queue->tx.req_cons = idx; + +- if (((gop-queue->tx_map_ops) >= ARRAY_SIZE(queue->tx_map_ops)) || ++ if ((*map_ops >= ARRAY_SIZE(queue->tx_map_ops)) || + (*copy_ops >= ARRAY_SIZE(queue->tx_copy_ops))) + break; + } + +- (*map_ops) = gop - queue->tx_map_ops; + return; + } + +@@ -1105,9 +1141,8 @@ static int xenvif_tx_submit(struct xenvif_queue *queue) + while ((skb = __skb_dequeue(&queue->tx_queue)) != NULL) { + struct xen_netif_tx_request *txp; + u16 pending_idx; +- unsigned data_len; + +- pending_idx = XENVIF_TX_CB(skb)->pending_idx; ++ pending_idx = copy_pending_idx(skb, 0); + txp = &queue->pending_tx_info[pending_idx].req; + + /* Check the remap error code. */ +@@ -1126,18 +1161,6 @@ static int xenvif_tx_submit(struct xenvif_queue *queue) + continue; + } + +- data_len = skb->len; +- callback_param(queue, pending_idx).ctx = NULL; +- if (data_len < txp->size) { +- /* Append the packet payload as a fragment. */ +- txp->offset += data_len; +- txp->size -= data_len; +- } else { +- /* Schedule a response immediately. */ +- xenvif_idx_release(queue, pending_idx, +- XEN_NETIF_RSP_OKAY); +- } +- + if (txp->flags & XEN_NETTXF_csum_blank) + skb->ip_summed = CHECKSUM_PARTIAL; + else if (txp->flags & XEN_NETTXF_data_validated) +@@ -1323,7 +1346,7 @@ static inline void xenvif_tx_dealloc_action(struct xenvif_queue *queue) + /* Called after netfront has transmitted */ + int xenvif_tx_action(struct xenvif_queue *queue, int budget) + { +- unsigned nr_mops, nr_cops = 0; ++ unsigned nr_mops = 0, nr_cops = 0; + int work_done, ret; + + if (unlikely(!tx_work_todo(queue))) +-- +2.35.1 + -- 2.47.3