Skip to content

mt7620: workaround jal imm26 and redundant PAGE_ALIGN - #20553

Merged
openwrt-bot merged 1 commit into
openwrt:mainfrom
namiltd:mt7620
Feb 24, 2026
Merged

openwrt-bot merged 1 commit into
openwrt:mainfrom
namiltd:mt7620

Conversation

@namiltd

@namiltd namiltd commented Oct 26, 2025 •

Copy link
Copy Markdown
Contributor

On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even "half-written" instructions when the compiler emits a direct 'jal imm26' call.
This is triggered in:

  • the small random helpers inside get_random_u32_below(), and
  • the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via a volatile function pointer (load into register + jalr) when building for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:

  • skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages() because the micro-randomization (< PAGE_SIZE) implemented by many ports (including MT7620) is negated immediately by PAGE_ALIGN(). Skipping the redundant PAGE_ALIGN() reduces exposure to the problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Since CONFIG_SOC_MT7620 is also set for mt7628, CONFIG_NET_RALINK_MT7620 is used to detect the correct platform.

Fixes: #16396, #20298, #20206

@zx2c4

zx2c4 commented Oct 26, 2025

Copy link
Copy Markdown
Contributor

This seems like a bandaid. What is the actual cause of the problem? Is this a hardware bug in making direct jumps? In that case, why has this not been observed elsewhere? Is this caused by a kernel bug elsewhere?

@zx2c4

zx2c4 commented Oct 26, 2025

Copy link
Copy Markdown
Contributor

When a J-type instruction is executed, a full 32-bit jump target address is formed by concatenating the high order four bits of the PC (the address of the instruction following the jump), the 26 bits of the target field, and two 0 bits.

So for 0x70360944 vs 0x80360944, what's going on here? The cpu somehow thinks that the address of the instruction following the jump is elsewhere? Is that address nearby the interrupt handler? Or user space? Or what's up here? Some cache not being flushed?

And why hasn't this been hit anywhere else?

@namiltd

namiltd commented Oct 26, 2025 •

Copy link
Copy Markdown
Contributor Author

I only observed this on ramips/mt7620 when executing while true ; do var=$(iw phy1-ap0 station dump | grep "Station") loops. I'm trying to investigate the cause by digging deeper and deeper into the code. I've found other workarounds, including changing the randomizer in the next step and disabling the interrupt for the get_random_u8..u32 timeframe. I'm now at the stage of protecting myself against invalid jumps.

At address 0x80360944, the get_random_u16 is invoked. When the address "changes" to 0x70360944, a crash occurs:

[  500.800986] CPU 0 Unable to handle kernel paging request at virtual address 70360944, epc == 70360944, ra == 800042ac
[  500.811907] Oops[#1]:
[  500.814230] CPU: 0 PID: 5378 Comm: iw Tainted: G           O       6.6.110 #0
[  500.821518] $ 0   : 00000000 00000001 00000002 fffff000
[  500.826875] $ 4   : 7fa6a000 7fa6a000 00000001 81a577ca
[  500.832229] $ 8   : 00000010 8060e80c 0010000b 8095d481
[  500.837582] $12   : 809bbb04 81d4950c 00000001 ffffff00
[  500.842936] $16   : 7fa6a000 00000001 82beb3a8 82e0c600
[  500.848290] $20   : 82dfe000 82e0ca5c 82e37dc0 00000001
[  500.853643] $24   : 00000000 ffffffff                  
[  500.858995] $28   : 82e96000 82e97d20 82e97de8 800042ac
[  500.864349] Hi    : 554a9555
[  500.867285] Lo    : 7ffaa000
[  500.870220] epc   : 70360944 0x70360944
[  500.874140] ra    : 800042ac arch_align_stack+0x50/0x70
[  500.879493] Status: 1100f403	KERNEL EXL IE 
[  500.883774] Cause : 50800008 (ExcCode 02)
[  500.887862] BadVA : 70360944
[  500.890797] PrId  : 00019650 (MIPS 24KEc)
[  500.894885] Modules linked in: rt2800soc(O) rt2800mmio(O) rt2800lib(O) pppoe ppp_async nft_fib_inet nf_flow_table_inet rt2x00soc(O) rt2x00mmio(O) rt2x00lib(O) pppox ppp_generic nft_reject_ipv6 nft_reject_ipv4 nft_reject_inet nft_reject nft_redir nft_quota nft_numgen nft_nat nft_masq nft_log nft_limit nft_hash nft_flow_offload nft_fib_ipv6 nft_fib_ipv4 nft_fib nft_ct nft_chain_nat nf_tables nf_nat_tftp nf_nat_snmp_basic nf_nat_sip nf_nat_pptp nf_nat_irc nf_nat_h323 nf_nat_amanda nf_nat nf_flow_table nf_conntrack_tftp nf_conntrack_snmp nf_conntrack_sip nf_conntrack_sane nf_conntrack_pptp nf_conntrack_netbios_ns nf_conntrack_irc nf_conntrack_h323 nf_conntrack_broadcast nf_conntrack_amanda nf_conntrack mt76x2e(O) mt76x2_common(O) mt76x02_lib(O) mt76(O) mac80211(O) cfg80211(O) ts_kmp ts_fsm ts_bm slhc nfnetlink nf_reject_ipv6 nf_reject_ipv4 nf_log_syslog nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c crc_ccitt compat(O) asn1_decoder sit tunnel4 ip_tunnel sha512_generic seqiv sha3_generic jitterentropy_rng drbg hmac geniv rng cmac
[  500.895410]  leds_gpio rtl8367b rtl8366_smi gpio_button_hotplug(O) crc32c_generic
[  500.995018] Process iw (pid: 5378, threadinfo=b49450ff, task=2b9c66c8, tls=77e83df4)
[  501.002933] Stack : 00001601 82dfeb40 00002ee2 809e3488 82e0ca00 801acaa8 81a57480 82dfe000
[  501.011502]         80783280 00000001 82e97de8 80179aa8 82b82820 00000007 00000000 8019ed44
[  501.020068]         00000000 00000000 00000000 00000000 0000000a 801cb770 00000000 82dfeb40
[  501.028632]         00000001 80031358 82e0ca00 81a57480 00000000 73d2acd8 ffffffff 82dfe000
[  501.037199]         82e0ca54 80149af8 81d96a80 82ec0b00 00000100 80203c1c 00000034 08e6ec94
[  501.045766]         ...
[  501.048265] Call Trace:
[  501.048270] 
[  501.052273] [<801acaa8>] setup_arg_pages+0x48/0x2cc
[  501.057325] [<80179aa8>] free_unref_page+0x4c/0x124
[  501.062324] [<8019ed44>] filp_close+0x14/0x34
[  501.066784] [<801cb770>] do_close_on_exec+0x108/0x154
[  501.071950] [<80031358>] flush_itimer_signals+0x34/0x5c
[  501.077342] [<80149af8>] arch_pick_mmap_layout+0x1a4/0x1c4
[  501.083002] [<80203c1c>] load_elf_phdrs+0x78/0xcc
[  501.087831] [<80205090>] load_elf_binary+0x2e0/0x1478
[  501.092997] [<801a3b74>] __kernel_read+0x164/0x2ac
[  501.097959] [<801ad264>] bprm_execve+0x1ec/0x560
[  501.102684] [<801ada74>] copy_string_kernel+0x110/0x250
[  501.108028] [<801ae5f8>] do_execveat_common+0x1b4/0x240
[  501.113369] [<8000fd54>] do_page_fault+0x1e4/0x554
[  501.118269] [<801af424>] sys_execve+0x34/0x48
[  501.122726] [<8000dd00>] syscall_common+0x34/0x58
[  501.127546] 
[  501.129062] Code: (Bad address in epc)
[  501.129062] 
[  501.134392] 
[  501.136021] ---[ end trace 0000000000000000 ]---
[  501.140909] Kernel panic - not syncing: Fatal exception
[  501.146256] Rebooting in 3 seconds..

@KanjiMonster

Copy link
Copy Markdown
Member

I agree with @zx2c4 that this looks like a band aid, and we should be seeing much more breakage if JAL is broken.

Also please do include any debug output you have showing the issue, and how you determined the cause. E.g. also include the code at arch_align_stack+0x50.

Also please do send this again upstream. Two things I noticed in your previous submission:

You didn't include any maintainers. You can run ./scripts/get_maintainer.pl <your.patch> to get a list of people to include (the most important are those that are Maintainer).

And more technical, your patch was broken, i.e tabs were converted to spaces, and one line was missing the initial +.

@namiltd

namiltd commented Oct 26, 2025

Copy link
Copy Markdown
Contributor Author

And more technical, your patch was broken, i.e tabs were converted to spaces, and one line was missing the initial +.

I'm sorry but I don't see spaces anywhere instead of tabs (except for one line where they are intentional), nor the missing +

@namiltd

namiltd commented Oct 26, 2025 •

Copy link
Copy Markdown
Contributor Author

arch_align_stack() function before patching:

8000425c <arch_align_stack>:
8000425c:	27bdffe8 	addiu	sp,sp,-24
80004260:	afb00010 	sw	s0,16(sp)
80004264:	afbf0014 	sw	ra,20(sp)
80004268:	8f820000 	lw	v0,0(gp)
8000426c:	8c420200 	lw	v0,512(v0)
80004270:	7c420480 	ext	v0,v0,0x12,0x1
80004274:	14400005 	bnez	v0,8000428c <arch_align_stack+0x30>
80004278:	00808025 	move	s0,a0
8000427c:	3c028078 	lui	v0,0x8078
80004280:	8c42549c 	lw	v0,21660(v0)
80004284:	14400007 	bnez	v0,800042a4 <arch_align_stack+0x48>
80004288:	00000000 	nop
8000428c:	8fbf0014 	lw	ra,20(sp)
80004290:	2402fff8 	li	v0,-8
80004294:	02021024 	and	v0,s0,v0
80004298:	8fb00010 	lw	s0,16(sp)
8000429c:	03e00008 	jr	ra
800042a0:	27bd0018 	addiu	sp,sp,24
800042a4:	0c0d8251 	jal	80360944 <get_random_u16> <------ jump
800042a8:	00000000 	nop
800042ac:	8fbf0014 	lw	ra,20(sp)
800042b0:	7c427900 	ext	v0,v0,0x4,0x10
800042b4:	02028023 	subu	s0,s0,v0
800042b8:	2402fff8 	li	v0,-8
800042bc:	02021024 	and	v0,s0,v0
800042c0:	8fb00010 	lw	s0,16(sp)
800042c4:	03e00008 	jr	ra
800042c8:	27bd0018 	addiu	sp,sp,24

and after:

8000425c <arch_align_stack>:
8000425c:	27bdffe0 	addiu	sp,sp,-32
80004260:	afb00018 	sw	s0,24(sp)
80004264:	afbf001c 	sw	ra,28(sp)
80004268:	8f820000 	lw	v0,0(gp)
8000426c:	8c420200 	lw	v0,512(v0)
80004270:	7c420480 	ext	v0,v0,0x12,0x1
80004274:	14400005 	bnez	v0,8000428c <arch_align_stack+0x30>
80004278:	00808025 	move	s0,a0
8000427c:	3c028078 	lui	v0,0x8078
80004280:	8c42549c 	lw	v0,21660(v0)
80004284:	14400007 	bnez	v0,800042a4 <arch_align_stack+0x48>
80004288:	3c028036 	lui	v0,0x8036
8000428c:	8fbf001c 	lw	ra,28(sp)
80004290:	2402fff8 	li	v0,-8
80004294:	02021024 	and	v0,s0,v0
80004298:	8fb00018 	lw	s0,24(sp)
8000429c:	03e00008 	jr	ra
800042a0:	27bd0020 	addiu	sp,sp,32
800042a4:	24420964 	addiu	v0,v0,2404
800042a8:	afa20014 	sw	v0,20(sp)
800042ac:	8fa20014 	lw	v0,20(sp)
800042b0:	0040f809 	jalr	v0 	<------ jump
800042b4:	00000000 	nop
800042b8:	8fbf001c 	lw	ra,28(sp)
800042bc:	7c427900 	ext	v0,v0,0x4,0x10
800042c0:	02028023 	subu	s0,s0,v0
800042c4:	2402fff8 	li	v0,-8
800042c8:	02021024 	and	v0,s0,v0
800042cc:	8fb00018 	lw	s0,24(sp)
800042d0:	03e00008 	jr	ra
800042d4:	27bd0020 	addiu	sp,sp,32

@KanjiMonster

KanjiMonster commented Oct 26, 2025 •

Copy link
Copy Markdown
Member

And more technical, your patch was broken, i.e tabs were converted to spaces, and one line was missing the initial +.

I'm sorry but I don't see spaces anywhere instead of tabs (except for one line where they are intentional), nor the missing +

https://patchwork.kernel.org/project/linux-mips/patch/[email protected]/ this is how your patch arrived on the list.

Note that there are no tabs (all spaces), and the line #if defined(CONFIG_MIPS) && !defined(CONFIG_CPU_MIPSR6) is broken, as its first character is neither +, - or a space.

Likewise the line after the + } does not have a space at all.

This is what I get when I try to apply the patch:

applying: ramips/mt7620: IRQ-protect stack ASLR randomization in arch_align_stack
error: corrupt patch at line 4
Patch failed at 0001 ramips/mt7620: IRQ-protect stack ASLR randomization in arch_align_stack
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

@namiltd

namiltd commented Oct 26, 2025

Copy link
Copy Markdown
Contributor Author

I don't know if the problem is in the kernel itself or in the patches in openwrt such as 305-mips_module_reloc.patch.

@KanjiMonster

Copy link
Copy Markdown
Member

I don't know if the problem is in the kernel itself or in the patches in openwrt such as 305-mips_module_reloc.patch.

You can test the latter by removing the patch and checking if it still happens. None of the space saving patches in OpenWrt are essential; I regularly build and run kernels without them (netbooted, not flashed though).

@namiltd

namiltd commented Oct 26, 2025 •

Copy link
Copy Markdown
Contributor Author

https://patchwork.kernel.org/project/linux-mips/patch/[email protected]/ this is how your patch arrived on the list.

Note that there are no tabs (all spaces), and the line #if defined(CONFIG_MIPS) && !defined(CONFIG_CPU_MIPSR6) is broken, as its first character is neither +, - or a space.

Likewise the line after the + } does not have a space at all.

@KanjiMonster You are writing about the wrong patch. This PR covers other changes to achieve the same goal: preventing crashes on mt7620.

@KanjiMonster

Copy link
Copy Markdown
Member

@KanjiMonster You are writing about the wrong patch. This PR covers other changes to achieve the same goal: preventing crashes on mt7620.

I am talking/asking about sending this again upstream, and talking about issues with your last attempt, to increase the likelyhood that the next attempt does get attention.

@namiltd

namiltd commented Oct 26, 2025 •

Copy link
Copy Markdown
Contributor Author

In the current patch, I'm using CONFIG_NET_RALINK_MT7620, which is defined in OpenWrt; it's not present in the stock kernel. Therefore, it can't be used for upstream in its current form.
Patch 305-mips_module_reloc.patch is already integrated into kernel 6.12, so I'm still looking for other reasons.

@neheb

neheb commented Oct 26, 2025

Copy link
Copy Markdown
Contributor

@zx2c4 there might be a cache issue honestly. reminds me of mt7621 having broken cache invalidation: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20251024&id=55a2aa08b3af519a9693f99cdf7fa6d8b62d9f65

@namiltd

namiltd commented Oct 27, 2025 •

Copy link
Copy Markdown
Contributor Author

There's a similar situation in #20206
I will change the jump to 32bit to workaround this problem too.

@Djfe

Djfe commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

does anyone know whether kernel 6.6 was affected as well or not?

@namiltd

namiltd commented Oct 27, 2025 •

Copy link
Copy Markdown
Contributor Author

The problem with this PR occurred on 24.10.4 - kernel v6.6 and snapshot - kernel 6.12. The problem #20206 was only found on snapshot - kernel v6.12.

@namiltd

namiltd commented Oct 28, 2025

Copy link
Copy Markdown
Contributor Author

Currently, PR increases stability on kernel 6.6 and 6.12. I think that until the cause is found, this workaround is the best solution.

@namiltd namiltd changed the title mt7620: avoid direct jal imm26 in random helper; conditional stack align mt7620: avoid direct jal imm26 in a few call sites and skip redundant PAGE_ALIGN Oct 28, 2025
@joseluissanromatato

Copy link
Copy Markdown

Hello,

I've faced this similar issue on the mt7620 class platform provoking reboots.

[  334.701551] CPU 0 Unable to handle kernel paging request at virtual address 703614d8, epcc
[  334.712521] Oops[#1]:
[  334.714848] CPU: 0 PID: 6878 Comm: usbmode Tainted: G           O       6.6.104 #0
[  334.722582] $ 0   : 00000000 00000001 00000002 fffff000
[  334.727946] $ 4   : 7fa5b000 7fa5b000 00000001 0065646f
[  334.733300] $ 8   : 00000010 8061b02c 00000010 80808080
[  334.738654] $12   : fefefeff 00000001 00000001 ffffff00
[  334.744009] $16   : 7fa5b000 00000001 834ddb40 8580d600
[  334.749363] $20   : 8587cb40 8580d05c 837f61e0 00000001
[  334.754718] $24   : 00000000 ffffffff                  
[  334.760073] $28   : 8359a000 8359bd20 8359bde8 800042ac
[  334.765429] Hi    : 554a9555
[  334.768365] Lo    : 7ffaa000
[  334.771301] epc   : 703614d8 0x703614d8
[  334.775223] ra    : 800042ac arch_align_stack+0x50/0x70
[  334.780577] Status: 1100a403 KERNEL EXL IE 
[  334.784862] Cause : 50800008 (ExcCode 02)
[  334.788953] BadVA : 703614d8
[  334.791889] PrId  : 00019650 (MIPS 24KEc)
[  334.795979] Modules linked in: rt2800soc(O) rt2800mmio(O) rt2800lib(O) qcserial pppoe pppt
[  334.796649]  x_tables ip_set_list_set ip_set_hash_netportnet ip_set_hash_netport ip_set_hc
[  334.942094] Process usbmode (pid: 6878, threadinfo=0ef2b16c, task=6a331fd0, tls=77e81df4)
[  334.950453] Stack : 00001601 835553c0 00003561 80a01e64 8580d000 801ac798 834b4a80 8587cb0
[  334.959026]         80793280 00000001 8359bde8 80179798 00000000 00000000 00000000 0000000
[  334.967594]         00000000 00000000 00000000 00000000 00000001 834b4a80 00000000 8355530
[  334.976162]         00000001 80031368 8580d000 834b4a80 00000000 22ef8f0c ffffffff 8587cb0
[  334.984731]         8580d054 80149a5c 81827900 85841f00 00000100 80203b94 00000034 b47f443
[  334.993301]         ...
[  334.995803] Call Trace:
[  334.995808] 
[  334.999814] [<801ac798>] setup_arg_pages+0x48/0x2cc
[  335.004811] [<80179798>] free_unref_page+0x4c/0x124
[  335.009814] [<80031368>] flush_itimer_signals+0x34/0x5c
[  335.015159] [<80149a5c>] arch_pick_mmap_layout+0x1a4/0x1c4
[  335.020773] [<80203b94>] load_elf_phdrs+0x78/0xcc
[  335.025605] [<80205008>] load_elf_binary+0x2e0/0x1478
[  335.030774] [<801a3864>] __kernel_read+0x164/0x2ac
[  335.035688] [<801b19ac>] getname_kernel+0x34/0x100
[  335.040606] [<801acf54>] bprm_execve+0x1ec/0x560
[  335.045326] [<801ad764>] copy_string_kernel+0x110/0x250
[  335.050673] [<801ae2e8>] do_execveat_common+0x1b4/0x240
[  335.056016] [<8000fd54>] do_page_fault+0x1e4/0x554
[  335.060918] [<801af114>] sys_execve+0x34/0x48
[  335.065380] [<8000dd00>] syscall_common+0x34/0x58
[  335.070208] 
[  335.071726] Code: (Bad address in epc)
[  335.071726] 
[  335.077056] 
[  335.078699] ---[ end trace 0000000000000000 ]---
[  335.083421] Kernel panic - not syncing: Fatal exception

I've tested this patch and it works well for me on kernel 6.6.110 in version 24.10.4. I no longer experience reboots, and the device is now stable.
I'm happy to help with any follow-up needed to get it merged upstream.

@namiltd why it is not good enough to use it as an interim solution?

@Djfe

Djfe commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

@namiltd why it is not good enough to use it as an interim solution?

🤔 that is literally, what he said

until the cause is found, this workaround is the best solution.

now others have to decide whether they are in favor of merging a workaround/interim solution or not

@zx2c4

zx2c4 commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

This cannot possibly be a real fix of the issue. We need something that addresses the root cause.

dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 5, 2026
Linux 6.18 introduced direct calls to mix_pool_bytes() in the timer entropy
bootstrap. On MT7620N these were observed jumping to an address with the
wrong high nibble and crashing early during boot.

Call through a volatile function pointer on MT7620 so GCC emits jalr. This
follows the workaround already merged for other affected call sites.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 5, 2026
Additional direct J-type call failures were reproduced in
spi_finalize_current_message() and udp6_ehashfn() with Linux 6.18.

Compile only spi.o and IPv6 udp.o with -mlong-calls. Applying the option
globally changes the frame-engine code enough to wedge MT7620 PDMA on its
first transmit descriptor, while this targeted form boots and passes
sustained bidirectional traffic.

Refresh the hunk offset in
821-SPI-ralink-add-Ralink-SoC-spi-driver.patch after adding four lines to
drivers/spi/Makefile. The embedded patch content is unchanged.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 7, 2026
Linux 6.18 introduced direct calls to mix_pool_bytes() in the timer entropy
bootstrap. On MT7620N these were observed jumping to an address with the
wrong high nibble and crashing early during boot.

Call through a volatile function pointer on MT7620 so GCC emits jalr. This
follows the workaround already merged for other affected call sites.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 7, 2026
Additional direct J-type call failures were reproduced in
spi_finalize_current_message() and udp6_ehashfn() with Linux 6.18.

Compile only spi.o and IPv6 udp.o with -mlong-calls. Applying the option
globally changes the frame-engine code enough to wedge MT7620 PDMA on its
first transmit descriptor, while this targeted form boots and passes
sustained bidirectional traffic.

Refresh the hunk offset in
821-SPI-ralink-add-Ralink-SoC-spi-driver.patch after adding four lines to
drivers/spi/Makefile. The embedded patch content is unchanged.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 8, 2026
Linux 6.18 introduced direct calls to mix_pool_bytes() in the timer entropy
bootstrap. On MT7620N these were observed jumping to an address with the
wrong high nibble and crashing early during boot.

Call through a volatile function pointer on MT7620 so GCC emits jalr. This
follows the workaround already merged for other affected call sites.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 8, 2026
Additional direct J-type call failures were reproduced in
spi_finalize_current_message() and udp6_ehashfn() with Linux 6.18.

Compile only spi.o and IPv6 udp.o with -mlong-calls. Applying the option
globally changes the frame-engine code enough to wedge MT7620 PDMA on its
first transmit descriptor, while this targeted form boots and passes
sustained bidirectional traffic.

Refresh the hunk offset in
821-SPI-ralink-add-Ralink-SoC-spi-driver.patch after adding four lines to
drivers/spi/Makefile. The embedded patch content is unchanged.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 9, 2026
Linux 6.18 introduced direct calls to mix_pool_bytes() in the timer entropy
bootstrap. On MT7620N these were observed jumping to an address with the
wrong high nibble and crashing early during boot.

Call through a volatile function pointer on MT7620 so GCC emits jalr. This
follows the workaround already merged for other affected call sites.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 9, 2026
Additional direct J-type call failures were reproduced in
spi_finalize_current_message() and udp6_ehashfn() with Linux 6.18.

Compile only spi.o and IPv6 udp.o with -mlong-calls. Applying the option
globally changes the frame-engine code enough to wedge MT7620 PDMA on its
first transmit descriptor, while this targeted form boots and passes
sustained bidirectional traffic.

Refresh the hunk offset in
821-SPI-ralink-add-Ralink-SoC-spi-driver.patch after adding four lines to
drivers/spi/Makefile. The embedded patch content is unchanged.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 14, 2026
Linux 6.18 introduced direct calls to mix_pool_bytes() in the timer
entropy bootstrap. On MT7620N these were observed jumping to an address
with the wrong high nibble and crashing early during boot.

Compile random.o with -mlong-calls for MT7620. This covers the affected
entropy bootstrap calls without target-specific function-pointer
indirection in generic random code.

Link: openwrt#20553

Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 14, 2026
Additional direct J-type call failures were reproduced in
spi_finalize_current_message() and udp6_ehashfn() with Linux 6.18.

Compile only spi.o and IPv6 udp.o with -mlong-calls. Applying the
option globally changes the frame-engine code enough to wedge MT7620
PDMA on its first transmit descriptor, while this targeted form boots
and passes sustained bidirectional traffic.

Refresh the hunk offset in
821-SPI-ralink-add-Ralink-SoC-spi-driver.patch after adding four lines
to drivers/spi/Makefile. The embedded patch content is unchanged.

Link: openwrt#20553

Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 14, 2026
Linux 6.18 introduced direct calls to mix_pool_bytes() in the timer
entropy bootstrap. On MT7620N these were observed jumping to an address
with the wrong high nibble and crashing early during boot.

Compile random.o with -mlong-calls for MT7620. This covers the affected
entropy bootstrap calls without target-specific function-pointer
indirection in generic random code.

Link: openwrt#20553

Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 14, 2026
Additional direct J-type call failures were reproduced in
spi_finalize_current_message() and udp6_ehashfn() with Linux 6.18.

Compile only spi.o and IPv6 udp.o with -mlong-calls. Applying the
option globally changes the frame-engine code enough to wedge MT7620
PDMA on its first transmit descriptor, while this targeted form boots
and passes sustained bidirectional traffic.

Refresh the hunk offset in
821-SPI-ralink-add-Ralink-SoC-spi-driver.patch after adding four lines
to drivers/spi/Makefile. The embedded patch content is unchanged.

Link: openwrt#20553

Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 14, 2026
Additional direct J-type call failures were reproduced in
spi_finalize_current_message() and udp6_ehashfn() with Linux 6.18.

Compile only spi.o and IPv6 udp.o with -mlong-calls. Applying the
option globally changes the frame-engine code enough to wedge MT7620
PDMA on its first transmit descriptor, while this targeted form boots
and passes sustained bidirectional traffic.

Refresh the hunk offset in
821-SPI-ralink-add-Ralink-SoC-spi-driver.patch after adding four lines
to drivers/spi/Makefile. The embedded patch content is unchanged.

Link: openwrt#20553

Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 15, 2026
MT7620 can sporadically execute direct J-type calls with an incorrect high
address nibble.  Linux 6.18 code generation and layout exposed failures in
the entropy bootstrap, SPI core and IPv6 UDP code.

Compile only random.o, spi.o and IPv6 udp.o with -mlong-calls.  Applying
the option globally was tested on MT7620N hardware and prevents PDMA from
processing its first transmit descriptor.  The targeted workaround boots
and passes sustained bidirectional traffic while retaining the known-good
frame-engine code generation.

Keep the workaround in one kernel patch because all three objects address
the same MT7620 direct-call failure mechanism.  Refresh the SPI driver
patch offset after adding four lines to drivers/spi/Makefile.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 15, 2026
MT7620 can sporadically execute direct J-type calls with an incorrect high
address nibble.  Linux 6.18 code generation and layout exposed failures in
the entropy bootstrap, SPI core and IPv6 UDP code.

Compile only random.o, spi.o and IPv6 udp.o with -mlong-calls.  Applying
the option globally was tested on MT7620N hardware and prevents PDMA from
processing its first transmit descriptor.  The targeted workaround boots
and passes sustained bidirectional traffic while retaining the known-good
frame-engine code generation.

Keep the workaround in one kernel patch because all three objects address
the same MT7620 direct-call failure mechanism.  Refresh the SPI driver
patch offset after adding four lines to drivers/spi/Makefile.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 16, 2026
MT7620 can sporadically execute direct J-type calls with an incorrect high
address nibble.  Linux 6.18 code generation and layout exposed failures in
the entropy bootstrap, SPI core and IPv6 UDP code.

Compile only random.o, spi.o and IPv6 udp.o with -mlong-calls.  Applying
the option globally was tested on MT7620N hardware and prevents PDMA from
processing its first transmit descriptor.  The targeted workaround boots
and passes sustained bidirectional traffic while retaining the known-good
frame-engine code generation.

Keep the workaround in one kernel patch because all three objects address
the same MT7620 direct-call failure mechanism.  Refresh the SPI driver
patch offset after adding four lines to drivers/spi/Makefile.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 16, 2026
MT7620 can sporadically execute direct J-type calls with an incorrect high
address nibble.  Linux 6.18 code generation and layout exposed failures in
the entropy bootstrap, SPI core and IPv6 UDP code.

Compile only random.o, spi.o and IPv6 udp.o with -mlong-calls.  Applying
the option globally was tested on MT7620N hardware and prevents PDMA from
processing its first transmit descriptor.  The targeted workaround boots
and passes sustained bidirectional traffic while retaining the known-good
frame-engine code generation.

Keep the workaround in one kernel patch because all three objects address
the same MT7620 direct-call failure mechanism.  Refresh the SPI driver
patch offset after adding four lines to drivers/spi/Makefile.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 24, 2026
MT7620 can sporadically execute direct J-type calls with an incorrect high
address nibble.  Linux 6.18 code generation and layout exposed failures in
the entropy bootstrap, SPI core and IPv6 UDP code.

Compile only random.o, spi.o and IPv6 udp.o with -mlong-calls.  Applying
the option globally was tested on MT7620N hardware and prevents PDMA from
processing its first transmit descriptor.  The targeted workaround boots
and passes sustained bidirectional traffic while retaining the known-good
frame-engine code generation.

Keep the workaround in one kernel patch because all three objects address
the same MT7620 direct-call failure mechanism.  Refresh the SPI driver
patch offset after adding four lines to drivers/spi/Makefile.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Sep 3, 2026
Linux 6.18 introduced direct calls to mix_pool_bytes() in the timer entropy
bootstrap. On MT7620N these were observed jumping to an address with the
wrong high nibble and crashing early during boot.

Call through a volatile function pointer on MT7620 so GCC emits jalr. This
follows the workaround already merged for other affected call sites.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Sep 3, 2026
Additional direct J-type call failures were reproduced in
spi_finalize_current_message() and udp6_ehashfn() with Linux 6.18.

Compile only spi.o and IPv6 udp.o with -mlong-calls. Applying the option
globally changes the frame-engine code enough to wedge MT7620 PDMA on its
first transmit descriptor, while this targeted form boots and passes
sustained bidirectional traffic.

Refresh the hunk offset in
821-SPI-ralink-add-Ralink-SoC-spi-driver.patch after adding four lines to
drivers/spi/Makefile. The embedded patch content is unchanged.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
LuisMitaHL pushed a commit to LuisMitaHL/LooperWrt that referenced this pull request Sep 21, 2026
On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic
wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even
"half-written" instructions when the compiler emits a direct 'jal imm26'
call.
This is triggered in:
  - the small random helpers inside get_random_u32_below(), and
  - the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via
a volatile function pointer (load into register + jalr) when building
for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:
  - skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages()
    because the micro-randomization (< PAGE_SIZE) implemented by many
    ports (including MT7620) is negated immediately by PAGE_ALIGN().
    Skipping the redundant PAGE_ALIGN() reduces exposure to the
    problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Signed-off-by: Mieczyslaw Nalewaj <[email protected]>
Link: openwrt#20553
Signed-off-by: Robert Marko <[email protected]>
(cherry picked from commit 22ccb44)
Quarx2k pushed a commit to Quarx2k/OpenWRT-BE7000 that referenced this pull request Sep 22, 2026
On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic
wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even
"half-written" instructions when the compiler emits a direct 'jal imm26'
call.
This is triggered in:
  - the small random helpers inside get_random_u32_below(), and
  - the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via
a volatile function pointer (load into register + jalr) when building
for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:
  - skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages()
    because the micro-randomization (< PAGE_SIZE) implemented by many
    ports (including MT7620) is negated immediately by PAGE_ALIGN().
    Skipping the redundant PAGE_ALIGN() reduces exposure to the
    problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Signed-off-by: Mieczyslaw Nalewaj <[email protected]>
Link: openwrt/openwrt#20553
Signed-off-by: Robert Marko <[email protected]>
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Oct 1, 2026
MT7620 can sporadically execute direct J-type calls with an incorrect high
address nibble.  Linux 6.18 code generation and layout exposed failures in
the entropy bootstrap, SPI core and IPv6 UDP code.

Compile only random.o, spi.o and IPv6 udp.o with -mlong-calls.  Applying
the option globally was tested on MT7620N hardware and prevents PDMA from
processing its first transmit descriptor.  The targeted workaround boots
and passes sustained bidirectional traffic while retaining the known-good
frame-engine code generation.

Keep the workaround in one kernel patch because all three objects address
the same MT7620 direct-call failure mechanism.  Refresh the SPI driver
patch offset after adding four lines to drivers/spi/Makefile.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
Assisted-by: Codex:gpt-6.1-sol
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Oct 2, 2026
MT7620 can sporadically execute direct J-type calls with an incorrect high
address nibble.  Linux 6.18 code generation and layout exposed failures in
the entropy bootstrap, SPI core and IPv6 UDP code.

Compile only random.o, spi.o and IPv6 udp.o with -mlong-calls.  Applying
the option globally was tested on MT7620N hardware and prevents PDMA from
processing its first transmit descriptor.  The targeted workaround boots
and passes sustained bidirectional traffic while retaining the known-good
frame-engine code generation.

Keep the workaround in one kernel patch because all three objects address
the same MT7620 direct-call failure mechanism.  Refresh the SPI driver
patch offset after adding four lines to drivers/spi/Makefile.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
Assisted-by: Codex:gpt-6.1-sol
dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Oct 2, 2026
MT7620 can sporadically execute direct J-type calls with an incorrect high
address nibble.  Linux 6.18 code generation and layout exposed failures in
the entropy bootstrap, SPI core and IPv6 UDP code.

Compile only random.o, spi.o and IPv6 udp.o with -mlong-calls.  Applying
the option globally was tested on MT7620N hardware and prevents PDMA from
processing its first transmit descriptor.  The targeted workaround boots
and passes sustained bidirectional traffic while retaining the known-good
frame-engine code generation.

Keep the workaround in one kernel patch because all three objects address
the same MT7620 direct-call failure mechanism.  Refresh the SPI driver
patch offset after adding four lines to drivers/spi/Makefile.

Link: openwrt#20553
Signed-off-by: Gleb Pesin <[email protected]>
Assisted-by: Codex:gpt-6.1-sol
codelinaro-mirror-sync Bot pushed a commit to CodeLinaro-mirror/le_owrt_prplwrt that referenced this pull request Oct 18, 2026
On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic
wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even
"half-written" instructions when the compiler emits a direct 'jal imm26'
call.
This is triggered in:
  - the small random helpers inside get_random_u32_below(), and
  - the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via
a volatile function pointer (load into register + jalr) when building
for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:
  - skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages()
    because the micro-randomization (< PAGE_SIZE) implemented by many
    ports (including MT7620) is negated immediately by PAGE_ALIGN().
    Skipping the redundant PAGE_ALIGN() reduces exposure to the
    problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Signed-off-by: Mieczyslaw Nalewaj <[email protected]>
Link: openwrt/openwrt#20553
(cherry picked from commit 22ccb445e611018ede702e6c0798640353632cce)
Link: openwrt/openwrt#22216
Signed-off-by: Robert Marko <[email protected]>
(cherry picked from commit f700509)
codelinaro-mirror-sync Bot pushed a commit to CodeLinaro-mirror/le_owrt_prplwrt that referenced this pull request Oct 18, 2026
On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic
wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even
"half-written" instructions when the compiler emits a direct 'jal imm26'
call.
This is triggered in:
  - the small random helpers inside get_random_u32_below(), and
  - the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via
a volatile function pointer (load into register + jalr) when building
for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:
  - skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages()
    because the micro-randomization (< PAGE_SIZE) implemented by many
    ports (including MT7620) is negated immediately by PAGE_ALIGN().
    Skipping the redundant PAGE_ALIGN() reduces exposure to the
    problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Signed-off-by: Mieczyslaw Nalewaj <[email protected]>
Link: openwrt/openwrt#20553
(cherry picked from commit 22ccb445e611018ede702e6c0798640353632cce)
Link: openwrt/openwrt#22216
Signed-off-by: Robert Marko <[email protected]>
(cherry picked from commit f700509)
sKyissKy pushed a commit to sKyissKy/immortalwrt-mt798x-6.6 that referenced this pull request Nov 19, 2026
On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic
wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even
"half-written" instructions when the compiler emits a direct 'jal imm26'
call.
This is triggered in:
  - the small random helpers inside get_random_u32_below(), and
  - the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via
a volatile function pointer (load into register + jalr) when building
for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:
  - skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages()
    because the micro-randomization (< PAGE_SIZE) implemented by many
    ports (including MT7620) is negated immediately by PAGE_ALIGN().
    Skipping the redundant PAGE_ALIGN() reduces exposure to the
    problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Signed-off-by: Mieczyslaw Nalewaj <[email protected]>
Link: openwrt/openwrt#20553
(cherry picked from commit 22ccb44)
Link: openwrt/openwrt#22216
Signed-off-by: Robert Marko <[email protected]>

(cherry picked from commit f700509)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

target/ramips pull request/issue for ramips target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mt7620 crash since kernel > 6.6.45