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

Jiaxun Yang posted 4 patches 1 year, 8 months ago
There is a newer version of this series
[PATCH v2 4/4] LoongArch: Override higher address bits in JUMP_VIRT_ADDR
Posted by Jiaxun Yang 1 year, 8 months ago
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
1:1 mapping addresses or firmware's DMW is configured exactly
same as kernel. Still, we should not rely on such assumption.

Fix by overriding higher bits in address comes from pcaddi,
so we can get rid of or operator.

Cc: stable@vger.kernel.org
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
v2: Overriding address with bstrins
---
 arch/loongarch/include/asm/stackframe.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/loongarch/include/asm/stackframe.h b/arch/loongarch/include/asm/stackframe.h
index 45b507a7b06f..51dec8b17d16 100644
--- a/arch/loongarch/include/asm/stackframe.h
+++ b/arch/loongarch/include/asm/stackframe.h
@@ -42,7 +42,7 @@
 	.macro JUMP_VIRT_ADDR temp1 temp2
 	li.d	\temp1, CACHE_BASE
 	pcaddi	\temp2, 0
-	or	\temp1, \temp1, \temp2
+	bstrins.d	\temp1, \temp2, (DMW_PABITS - 1), 0
 	jirl	zero, \temp1, 0xc
 	.endm
 

-- 
2.43.0
Re: [PATCH v2 4/4] LoongArch: Override higher address bits in JUMP_VIRT_ADDR
Posted by Huacai Chen 1 year, 8 months ago
Hi, Jiaxun,

On Wed, May 22, 2024 at 2:30 PM Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
>
> 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
> 1:1 mapping addresses or firmware's DMW is configured exactly
> same as kernel. Still, we should not rely on such assumption.
>
> Fix by overriding higher bits in address comes from pcaddi,
> so we can get rid of or operator.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
> v2: Overriding address with bstrins
> ---
>  arch/loongarch/include/asm/stackframe.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/include/asm/stackframe.h b/arch/loongarch/include/asm/stackframe.h
> index 45b507a7b06f..51dec8b17d16 100644
> --- a/arch/loongarch/include/asm/stackframe.h
> +++ b/arch/loongarch/include/asm/stackframe.h
> @@ -42,7 +42,7 @@
>         .macro JUMP_VIRT_ADDR temp1 temp2
>         li.d    \temp1, CACHE_BASE
>         pcaddi  \temp2, 0
> -       or      \temp1, \temp1, \temp2
> +       bstrins.d       \temp1, \temp2, (DMW_PABITS - 1), 0
>         jirl    zero, \temp1, 0xc
>         .endm
Can we align the first parameter about the first parameter?

Huacai
>
>
> --
> 2.43.0
>