[PATCH 4/4] LoongArch: Clear higher address bits in JUMP_VIRT_ADDR

From: Jiaxun Yang
Date: Tue May 21 2024 - 16:13:19 EST


In JUMP_VIRT_ADDR we are performing an or calculation on
address value directly from pcaddi.

This will only work if we are currently running from direct
translation addresses or firmware's DMW is configured exactly
same as kernel. Still, we should not rely on such assumption.

Fix by clearing higher bits in address comes from pcaddi,
so we can get real physcal address before applying or
operator.

Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>
---
arch/loongarch/include/asm/stackframe.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/include/asm/stackframe.h b/arch/loongarch/include/asm/stackframe.h
index 45b507a7b06f..a325d20a4503 100644
--- a/arch/loongarch/include/asm/stackframe.h
+++ b/arch/loongarch/include/asm/stackframe.h
@@ -42,8 +42,10 @@
.macro JUMP_VIRT_ADDR temp1 temp2
li.d \temp1, CACHE_BASE
pcaddi \temp2, 0
+ PTR_SLL \temp2, \temp2, (BITS_PER_LONG - DMW_PABITS)
+ PTR_SRL \temp2, \temp2, (BITS_PER_LONG - DMW_PABITS)
or \temp1, \temp1, \temp2
- jirl zero, \temp1, 0xc
+ jirl zero, \temp1, 0x14
.endm

.macro BACKUP_T0T1

--
2.43.0