LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Nanyong Sun <email@example.com>
To: Palmer Dabbelt <firstname.lastname@example.org>, <email@example.com>
Cc: Paul Walmsley <firstname.lastname@example.org>, <email@example.com>,
"Anup Patel" <Anup.Patel@wdc.com>,
Atish Patra <Atish.Patra@wdc.com>, <firstname.lastname@example.org>,
<email@example.com>, <firstname.lastname@example.org>, <email@example.com>
Subject: Re: [PATCH v2 -next] riscv: mm: remove redundant trampoline PGD for 64bit
Date: Wed, 8 Sep 2021 14:42:04 +0800 [thread overview]
Message-ID: <firstname.lastname@example.org> (raw)
On 2021/8/14 6:08, Palmer Dabbelt wrote:
> On Mon, 02 Aug 2021 05:43:02 PDT (-0700), email@example.com wrote:
>> Hi Nanyong,
>> Le 28/07/2021 à 13:55, Alex Ghiti a écrit :
>>> Le 28/07/2021 à 04:49, Nanyong Sun a écrit :
>>>> Remove redundant trampoline PGD for 64bit and add more comment
>>>> for why 32bit systems need trampoline PGD.
>>>> + /*
>>>> + * Switch to kernel page tables. A full fence is necessary
>>>> in order to
>>>> + * avoid using the trampoline translations, which are only
>>>> correct for
>>>> + * the first superpage. Fetching the fence is guarnteed
>>>> to work
>>>> + * because that first superpage is translated the same way.
>>>> + */
>>>> + csrw CSR_SATP, a2
>>>> + sfence.vma
>>>> /* Set trap vector to spin forever to help debug */
>>>> la a0, .Lsecondary_park
>>>> csrw CSR_TVEC, a0
>> I suppose stvec was set this way to catch any problem with early_pg_dir,
>> you moved that and then this defeats this original purpose.
I don't think so, before set early_pg_dir to satp, it's the
physical address world, we must set stvec as
the first place in virtual address world we want jump to. And I don't
think ".Lsecondary_park " can catch
problem of bad early_pg_dir, if the basic page table is wrong, CPU also
can not go to the virtual address stored in stvec correctly.
More, in the original code, before set trampoline_pg_dir, what if the
trampoline_pg_dir had a problem?
> The specific issue is that the JTAG debug spec is defined (or at least
> was when I was using it, it's been years since I've needed to do that)
> in terms of committed instructions. Thus if you end up in a position
> where the processer is unable to commit an instruction you also lose
> the ability to do anything meaningful with the debugger, thus
> essentially locking up the system.
> The most common way to end up in a situation where the processor is
> unable to commit an instruction is to have a fault with an invalid
> trap vector: maybe dangling from M-mode, the last boot, reset,
> whatever. Then as soon as you take a trap the system locks up. Any
> trap before we have a working trap handler is a bug, but it's way
> harder to debug things when the debugger doesn't function.
> There is of course no way to fundamentally prevent these sort of
> no-commitable-instruction situations, but I got into the habbit of
> just setting up a trivial trap entry point ASAP -- it probably took a
> dozen rounds of trying to debug the debugger only to realize it was
> per spec to hang, but that idiom eventually crept into pretty much
> Not sure if the debug spec is still written this way (or if debuggers
> respect it), as I haven't had to use one in a while.
>>>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>>>> index ac48742fa6fc..306fcb2334fa 100644
>>>> --- a/arch/riscv/mm/init.c
>>>> +++ b/arch/riscv/mm/init.c
>>>> @@ -219,13 +219,17 @@ unsigned long pfn_base __ro_after_init;
>>>> pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
>>>> +#ifndef CONFIG_64BIT
>>>> pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
>>>> +#endif /* CONFIG_64BIT */
>> As stated in Documentation/process/coding-style.rst, it is better to use
>> __maybe_unused rather than #ifdefs.
I'm afraid that __maybe_unused can not save one page memory here.
>> Overall this version adds more complexity to assembly code than I
>> thought, but I don't see any way to improve that (which does not mean
>> there isn't!).
Thanks for your review, let me figure out a better solution.
>>> linux-riscv mailing list
> linux-riscv mailing list
next prev parent reply other threads:[~2021-09-08 6:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-28 2:49 Nanyong Sun
2021-07-28 11:55 ` Alex Ghiti
2021-08-02 12:43 ` Alex Ghiti
2021-08-13 22:08 ` Palmer Dabbelt
2021-09-08 6:42 ` Nanyong Sun [this message]
2021-09-08 8:56 ` Alex Ghiti
2021-09-09 3:23 ` Nanyong Sun
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:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--subject='Re: [PATCH v2 -next] riscv: mm: remove redundant trampoline PGD for 64bit' \
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).