From: "Jiaxun Yang" <jiaxun.yang@flygoat.com>
To: "Huacai Chen" <chenhuacai@kernel.org>
Cc: "Xuerui Wang" <kernel@xen0n.name>,
loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH 1/2] LoongArch: Initialise unused Direct Map Windows
Date: Fri, 14 Jun 2024 03:17:38 +0100 [thread overview]
Message-ID: <3e3d6ee8-a758-4d99-be77-89b26b0ab591@app.fastmail.com> (raw)
In-Reply-To: <CAAhV-H7TqgJiR9z9jEOpv34kijONLVu5Bv2PChjUWxhMKU_Zvw@mail.gmail.com>
在2024年6月14日六月 上午3:13,Huacai Chen写道:
> Hi, Jiaxun,
>
> On Fri, Jun 14, 2024 at 12:41 AM Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
>>
>> DMW 2 & 3 are unused by kernel, however firmware may leave
>> garbage in them and interfere kernel's address mapping.
>>
>> Clear them as necessary.
> I think the current status is as expected, we don't want kernel access
> to non-8000 and non-9000 addresses. And low-end chips may have only
> two DMWs.
I see, I'll remove U-Boot's dependency to DMW 2 and 3 then.
Thanks
- Jiaxun
>
> Huacai
>
>
> Huacai
>
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>> ---
>> arch/loongarch/include/asm/loongarch.h | 4 ++++
>> arch/loongarch/include/asm/stackframe.h | 11 +++++++++++
>> arch/loongarch/kernel/head.S | 12 ++----------
>> arch/loongarch/power/suspend_asm.S | 6 +-----
>> drivers/firmware/efi/libstub/loongarch.c | 2 ++
>> 5 files changed, 20 insertions(+), 15 deletions(-)
>>
>> diff --git a/arch/loongarch/include/asm/loongarch.h b/arch/loongarch/include/asm/loongarch.h
>> index eb09adda54b7..3720096efcf9 100644
>> --- a/arch/loongarch/include/asm/loongarch.h
>> +++ b/arch/loongarch/include/asm/loongarch.h
>> @@ -889,6 +889,10 @@
>> #define CSR_DMW1_BASE (CSR_DMW1_VSEG << DMW_PABITS)
>> #define CSR_DMW1_INIT (CSR_DMW1_BASE | CSR_DMW1_MAT | CSR_DMW1_PLV0)
>>
>> +/* Direct Map window 2/3 - unused */
>> +#define CSR_DMW2_INIT 0
>> +#define CSR_DMW3_INIT 0
>> +
>> /* Performance Counter registers */
>> #define LOONGARCH_CSR_PERFCTRL0 0x200 /* 32 perf event 0 config */
>> #define LOONGARCH_CSR_PERFCNTR0 0x201 /* 64 perf event 0 count value */
>> diff --git a/arch/loongarch/include/asm/stackframe.h b/arch/loongarch/include/asm/stackframe.h
>> index d9eafd3ee3d1..10c5dcf56bc7 100644
>> --- a/arch/loongarch/include/asm/stackframe.h
>> +++ b/arch/loongarch/include/asm/stackframe.h
>> @@ -38,6 +38,17 @@
>> cfi_restore \reg \offset \docfi
>> .endm
>>
>> + .macro SETUP_DMWS temp1
>> + li.d \temp1, CSR_DMW0_INIT
>> + csrwr \temp1, LOONGARCH_CSR_DMWIN0
>> + li.d \temp1, CSR_DMW1_INIT
>> + csrwr \temp1, LOONGARCH_CSR_DMWIN1
>> + li.d \temp1, CSR_DMW2_INIT
>> + csrwr \temp1, LOONGARCH_CSR_DMWIN2
>> + li.d \temp1, CSR_DMW3_INIT
>> + csrwr \temp1, LOONGARCH_CSR_DMWIN3
>> + .endm
>> +
>> /* Jump to the runtime virtual address. */
>> .macro JUMP_VIRT_ADDR temp1 temp2
>> li.d \temp1, CACHE_BASE
>> diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S
>> index 4677ea8fa8e9..1a71fc09bfd6 100644
>> --- a/arch/loongarch/kernel/head.S
>> +++ b/arch/loongarch/kernel/head.S
>> @@ -44,11 +44,7 @@ SYM_DATA(kernel_fsize, .long _kernel_fsize);
>> SYM_CODE_START(kernel_entry) # kernel entry point
>>
>> /* Config direct window and set PG */
>> - li.d t0, CSR_DMW0_INIT # UC, PLV0, 0x8000 xxxx xxxx xxxx
>> - csrwr t0, LOONGARCH_CSR_DMWIN0
>> - li.d t0, CSR_DMW1_INIT # CA, PLV0, 0x9000 xxxx xxxx xxxx
>> - csrwr t0, LOONGARCH_CSR_DMWIN1
>> -
>> + SETUP_DMWS t0
>> JUMP_VIRT_ADDR t0, t1
>>
>> /* Enable PG */
>> @@ -124,11 +120,7 @@ SYM_CODE_END(kernel_entry)
>> * function after setting up the stack and tp registers.
>> */
>> SYM_CODE_START(smpboot_entry)
>> - li.d t0, CSR_DMW0_INIT # UC, PLV0
>> - csrwr t0, LOONGARCH_CSR_DMWIN0
>> - li.d t0, CSR_DMW1_INIT # CA, PLV0
>> - csrwr t0, LOONGARCH_CSR_DMWIN1
>> -
>> + SETUP_DMWS t0
>> JUMP_VIRT_ADDR t0, t1
>>
>> #ifdef CONFIG_PAGE_SIZE_4KB
>> diff --git a/arch/loongarch/power/suspend_asm.S b/arch/loongarch/power/suspend_asm.S
>> index e2fc3b4e31f0..6fdd74eb219b 100644
>> --- a/arch/loongarch/power/suspend_asm.S
>> +++ b/arch/loongarch/power/suspend_asm.S
>> @@ -73,11 +73,7 @@ SYM_FUNC_START(loongarch_suspend_enter)
>> * Reload all of the registers and return.
>> */
>> SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL)
>> - li.d t0, CSR_DMW0_INIT # UC, PLV0
>> - csrwr t0, LOONGARCH_CSR_DMWIN0
>> - li.d t0, CSR_DMW1_INIT # CA, PLV0
>> - csrwr t0, LOONGARCH_CSR_DMWIN1
>> -
>> + SETUP_DMWS t0
>> JUMP_VIRT_ADDR t0, t1
>>
>> /* Enable PG */
>> diff --git a/drivers/firmware/efi/libstub/loongarch.c b/drivers/firmware/efi/libstub/loongarch.c
>> index d0ef93551c44..3782d0a187d1 100644
>> --- a/drivers/firmware/efi/libstub/loongarch.c
>> +++ b/drivers/firmware/efi/libstub/loongarch.c
>> @@ -74,6 +74,8 @@ efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image,
>> /* Config Direct Mapping */
>> csr_write64(CSR_DMW0_INIT, LOONGARCH_CSR_DMWIN0);
>> csr_write64(CSR_DMW1_INIT, LOONGARCH_CSR_DMWIN1);
>> + csr_write64(CSR_DMW2_INIT, LOONGARCH_CSR_DMWIN2);
>> + csr_write64(CSR_DMW3_INIT, LOONGARCH_CSR_DMWIN3);
>>
>> real_kernel_entry = (void *)kernel_entry_address(kernel_addr, image);
>>
>>
>> --
>> 2.43.0
>>
>>
--
- Jiaxun
next prev parent reply other threads:[~2024-06-14 2:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 16:41 [PATCH 0/2] LoongArch: Fix S3 sleep on U-Boot + QEMU virt machine Jiaxun Yang
2024-06-13 16:41 ` [PATCH 1/2] LoongArch: Initialise unused Direct Map Windows Jiaxun Yang
2024-06-14 2:13 ` Huacai Chen
2024-06-14 2:17 ` Jiaxun Yang [this message]
2024-06-17 13:49 ` Huacai Chen
2024-06-13 16:41 ` [PATCH 2/2] LoongArch: Fix ACPI standard register based S3 support Jiaxun Yang
2024-06-14 2:11 ` Huacai Chen
2024-06-14 2:24 ` Jiaxun Yang
2024-06-14 2:32 ` Huacai Chen
2024-06-14 2:44 ` Jiaxun Yang
2024-06-17 13:49 ` Huacai Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3e3d6ee8-a758-4d99-be77-89b26b0ab591@app.fastmail.com \
--to=jiaxun.yang@flygoat.com \
--cc=chenhuacai@kernel.org \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®