Repository navigation
mt7620: workaround jal imm26 and redundant PAGE_ALIGN - #20553
Conversation
|
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? |
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? |
|
I only observed this on ramips/mt7620 when executing At address 0x80360944, the get_random_u16 is invoked. When the address "changes" to 0x70360944, a crash occurs: |
|
I agree with @zx2c4 that this looks like a band aid, and we should be seeing much more breakage if 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 Also please do send this again upstream. Two things I noticed in your previous submission: You didn't include any maintainers. You can run 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 + |
|
arch_align_stack() function before patching: and after: |
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 Likewise the line after the This is what I get when I try to apply the patch: |
|
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). |
@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. |
|
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. |
|
@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 |
|
There's a similar situation in #20206 |
|
does anyone know whether kernel 6.6 was affected as well or not? |
|
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. |
|
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. |
|
Hello, I've faced this similar issue on the mt7620 class platform provoking reboots. 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. @namiltd why it is not good enough to use it as an interim solution? |
🤔 that is literally, what he said
now others have to decide whether they are in favor of merging a workaround/interim solution or not |
|
This cannot possibly be a real fix of the issue. We need something that addresses the root cause. |
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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)
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]>
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
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
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
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)
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)
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)
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:
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:
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