Skip to content

Commit

Permalink
LoongArch: Add JUMP_VIRT_ADDR macro implementation to avoid using la.abs
Browse files Browse the repository at this point in the history
Add JUMP_VIRT_ADDR macro implementation to avoid using la.abs directly.
This is a preparation for subsequent patches.

Signed-off-by: Youling Tang <tangyouling@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
  • Loading branch information
Youling Tang authored and Huacai Chen committed Feb 25, 2023
1 parent f733f11 commit 8cbd5eb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
9 changes: 9 additions & 0 deletions arch/loongarch/include/asm/stackframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <linux/threads.h>

#include <asm/addrspace.h>
#include <asm/asm.h>
#include <asm/asmmacro.h>
#include <asm/asm-offsets.h>
Expand Down Expand Up @@ -36,6 +37,14 @@
cfi_restore \reg \offset \docfi
.endm

/* Jump to the runtime virtual address. */
.macro JUMP_VIRT_ADDR temp1 temp2
li.d \temp1, CACHE_BASE
pcaddi \temp2, 0
or \temp1, \temp1, \temp2
jirl zero, \temp1, 0xc
.endm

.macro BACKUP_T0T1
csrwr t0, EXCEPTION_KS0
csrwr t1, EXCEPTION_KS1
Expand Down
12 changes: 4 additions & 8 deletions arch/loongarch/kernel/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ SYM_CODE_START(kernel_entry) # kernel entry point
li.d t0, CSR_DMW1_INIT # CA, PLV0, 0x9000 xxxx xxxx xxxx
csrwr t0, LOONGARCH_CSR_DMWIN1

/* We might not get launched at the address the kernel is linked to,
so we jump there. */
la.abs t0, 0f
jr t0
0:
JUMP_VIRT_ADDR t0, t1

/* Enable PG */
li.w t0, 0xb0 # PLV=0, IE=0, PG=1
csrwr t0, LOONGARCH_CSR_CRMD
Expand Down Expand Up @@ -106,9 +103,8 @@ SYM_CODE_START(smpboot_entry)
li.d t0, CSR_DMW1_INIT # CA, PLV0
csrwr t0, LOONGARCH_CSR_DMWIN1

la.abs t0, 0f
jr t0
0:
JUMP_VIRT_ADDR t0, t1

/* Enable PG */
li.w t0, 0xb0 # PLV=0, IE=0, PG=1
csrwr t0, LOONGARCH_CSR_CRMD
Expand Down
5 changes: 2 additions & 3 deletions arch/loongarch/power/suspend_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL)
li.d t0, CSR_DMW1_INIT # CA, PLV0
csrwr t0, LOONGARCH_CSR_DMWIN1

la.abs t0, 0f
jr t0
0:
JUMP_VIRT_ADDR t0, t1

la.pcrel t0, acpi_saved_sp
ld.d sp, t0, 0
SETUP_WAKEUP
Expand Down

0 comments on commit 8cbd5eb

Please sign in to comment.