Skip to content

ramips: mt7620: keep code out of the first 32 KiB - #147

Closed
namiltd wants to merge 1 commit into
mainfrom
patch-9
Closed

namiltd wants to merge 1 commit into
mainfrom
patch-9

Conversation

@namiltd

@namiltd namiltd commented Nov 14, 2026

Copy link
Copy Markdown
Owner

The 24KEc of the MT7620/MT7628 can save a wrong EPC (bits 31:28) for an interrupt taken at the first instruction of a JAL target when the JAL is located in the first 32 KiB of a 256 MiB segment. The return from the interrupt then goes to 0x7... instead of 0x8..., and the kernel dies with "Unable to handle kernel paging request".

Instead of avoiding direct calls site by site (330, 331), keep all code out of that window:

  • 333: reserve 0x8000 bytes in front of _stext in head.S for SOC_MT7620 instead of 0x400, so kernel text starts at 0x80008000. The image is still loaded and entered at 0x80000000 and the padding is zeros (nops), so it works with any bootloader and compresses to almost nothing. Patch by Marco Martins.
  • 334: return the padding to the page allocator at late_initcall, so the RAM is only lost during boot (the first page is kept if ebase points into it).
  • 301-02: keep module code out of the window too. Skip such blocks in alloc_phys(), start the vmalloc fallback at VMALLOC_START + 32 KiB, WARN in module_finalize(), and make the physical PLT table optional. The platforms are selected by the new hidden MIPS_KSEG0_LOW_NOEXEC symbol (!64BIT, default y for SOC_MT7620).

330 and 331 forced indirect calls on MT7620 for two call sites. They are no longer needed and are removed.

This comment was marked as low quality.

@namiltd
namiltd force-pushed the patch-9 branch 5 times, most recently from cc07dbb to 833757b Compare November 14, 2026 21:00
The 24KEc of the MT7620/MT7628 can save a wrong EPC (bits 31:28) for an
interrupt taken at the first instruction of a JAL target when the JAL is
located in the first 32 KiB of a 256 MiB segment. The return from the
interrupt then goes to 0x7... instead of 0x8..., and the kernel dies with
"Unable to handle kernel paging request".

Instead of avoiding direct calls site by site (330, 331), keep all code
out of that window:

- 333: reserve 0x8000 bytes in front of _stext in head.S for SOC_MT7620
  instead of 0x400, so kernel text starts at 0x80008000. The image is
  still loaded and entered at 0x80000000 and the padding is zeros (nops),
  so it works with any bootloader and compresses to almost nothing.
  Patch by Marco Martins.
- 334: return the padding to the page allocator at late_initcall, so the
  RAM is only lost during boot (the first page is kept if ebase points
  into it).
- 301-02: keep module code out of the window too. Skip such blocks in
  alloc_phys(), start the vmalloc fallback at VMALLOC_START + 32 KiB,
  WARN in module_finalize(), and make the physical PLT table optional.
  The window is guarded for SOC_MT7620 without NO_EXCEPT_FILL, the
  same condition under which head.S pads.

330 and 331 forced indirect calls on MT7620 for two call sites. They are
no longer needed and are removed.

Signed-off-by: Mieczyslaw Nalewaj <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants