[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJF2gTSW-ixSdV73kqpJ=yYjYnKFQtS3NfzvjBVBVU1D==7YEg@mail.gmail.com>
Date: Thu, 22 Sep 2022 14:17:04 +0800
From: Guo Ren <guoren@...nel.org>
To: Samuel Holland <samuel@...lland.org>
Cc: Palmer Dabbelt <palmer@...belt.com>,
linux-riscv@...ts.infradead.org, Albert Ou <aou@...s.berkeley.edu>,
Heiko Stuebner <heiko@...ech.de>,
Paul Walmsley <paul.walmsley@...ive.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] riscv: Fix crash during early errata patching
Good catch!
Reviewed-by: Guo Ren <guoren@...nel.org>
On Thu, Sep 22, 2022 at 1:47 PM Samuel Holland <samuel@...lland.org> wrote:
>
> The patch function for the T-Head PBMT errata calls __pa_symbol() before
> relocation. This crashes when CONFIG_DEBUG_VIRTUAL is enabled, because
> __pa_symbol() forwards to __phys_addr_symbol(), and __phys_addr_symbol()
> checks against the absolute kernel start/end address.
>
> Fix this by directly using the underlying kernel_mapping_va_to_pa().
>
> Fixes: a35707c3d850 ("riscv: add memory-type errata for T-Head")
> Signed-off-by: Samuel Holland <samuel@...lland.org>
> ---
>
> arch/riscv/errata/thead/errata.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/errata/thead/errata.c b/arch/riscv/errata/thead/errata.c
> index 202c83f677b2..83174f13783e 100644
> --- a/arch/riscv/errata/thead/errata.c
> +++ b/arch/riscv/errata/thead/errata.c
> @@ -76,8 +76,9 @@ void __init_or_module thead_errata_patch_func(struct alt_entry *begin, struct al
> if (cpu_req_errata & tmp) {
> /* On vm-alternatives, the mmu isn't running yet */
> if (stage == RISCV_ALTERNATIVES_EARLY_BOOT)
> - memcpy((void *)__pa_symbol(alt->old_ptr),
> - (void *)__pa_symbol(alt->alt_ptr), alt->alt_len);
> + memcpy((void *)kernel_mapping_va_to_pa((unsigned long)alt->old_ptr),
> + (void *)kernel_mapping_va_to_pa((unsigned long)alt->alt_ptr),
> + alt->alt_len);
> else
> patch_text_nosync(alt->old_ptr, alt->alt_ptr, alt->alt_len);
> }
> --
> 2.35.1
>
--
Best Regards
Guo Ren
Powered by blists - more mailing lists