Skip to content

Commit

Permalink
LoongArch: Fix earlycon parameter if KASAN enabled
Browse files Browse the repository at this point in the history
The earlycon parameter is based on fixmap, and fixmap addresses are not
supposed to be shadowed by KASAN. So return the kasan_early_shadow_page
in kasan_mem_to_shadow() if the input address is above FIXADDR_START.
Otherwise earlycon cannot work after kasan_init().

Cc: stable@vger.kernel.org
Fixes: 5aa4ac6 ("LoongArch: Add KASAN (Kernel Address Sanitizer) support")
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
  • Loading branch information
Huacai Chen committed Feb 6, 2024
1 parent 4551b30 commit 639420e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/loongarch/mm/kasan_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ void *kasan_mem_to_shadow(const void *addr)
unsigned long xrange = (maddr >> XRANGE_SHIFT) & 0xffff;
unsigned long offset = 0;

if (maddr >= FIXADDR_START)
return (void *)(kasan_early_shadow_page);

maddr &= XRANGE_SHADOW_MASK;
switch (xrange) {
case XKPRANGE_CC_SEG:
Expand Down

0 comments on commit 639420e

Please sign in to comment.