From: Samuel Holland <samuel@sholland.org> To: Palmer Dabbelt <palmer@dabbelt.com>, linux-riscv@lists.infradead.org Cc: Samuel Holland <samuel@sholland.org>, Albert Ou <aou@eecs.berkeley.edu>, Guo Ren <guoren@kernel.org>, Heiko Stuebner <heiko@sntech.de>, Paul Walmsley <paul.walmsley@sifive.com>, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] riscv: Fix crash during early errata patching Date: Thu, 22 Sep 2022 00:47:41 -0500 [thread overview] Message-ID: <20220922054743.30159-1-samuel@sholland.org> (raw) 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@sholland.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
WARNING: multiple messages have this Message-ID (diff)
From: Samuel Holland <samuel@sholland.org> To: Palmer Dabbelt <palmer@dabbelt.com>, linux-riscv@lists.infradead.org Cc: Samuel Holland <samuel@sholland.org>, Albert Ou <aou@eecs.berkeley.edu>, Guo Ren <guoren@kernel.org>, Heiko Stuebner <heiko@sntech.de>, Paul Walmsley <paul.walmsley@sifive.com>, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] riscv: Fix crash during early errata patching Date: Thu, 22 Sep 2022 00:47:41 -0500 [thread overview] Message-ID: <20220922054743.30159-1-samuel@sholland.org> (raw) 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@sholland.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 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv
next reply other threads:[~2022-09-22 5:47 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-22 5:47 Samuel Holland [this message] 2022-09-22 5:47 ` [PATCH 1/2] riscv: Fix crash during early errata patching Samuel Holland 2022-09-22 5:47 ` [PATCH 2/2] riscv: Move cast inside kernel_mapping_[pv]a_to_[vp]a Samuel Holland 2022-09-22 5:47 ` Samuel Holland 2022-09-22 7:34 ` Alexandre Ghiti 2022-09-22 7:34 ` Alexandre Ghiti 2022-09-23 9:35 ` Heiko Stuebner 2022-09-23 9:35 ` Heiko Stuebner 2022-09-22 6:17 ` [PATCH 1/2] riscv: Fix crash during early errata patching Guo Ren 2022-09-22 6:17 ` Guo Ren 2022-09-22 7:31 ` Alexandre Ghiti 2022-09-22 7:31 ` Alexandre Ghiti 2022-09-23 10:18 ` Heiko Stuebner 2022-09-23 10:18 ` Heiko Stuebner 2022-12-09 19:00 ` Palmer Dabbelt 2022-12-09 19:00 ` Palmer Dabbelt
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=20220922054743.30159-1-samuel@sholland.org \ --to=samuel@sholland.org \ --cc=aou@eecs.berkeley.edu \ --cc=guoren@kernel.org \ --cc=heiko@sntech.de \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-riscv@lists.infradead.org \ --cc=palmer@dabbelt.com \ --cc=paul.walmsley@sifive.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.