* [PATCH] RISC-V: mm: Fix set_satp_mode() for platform not having Sv57
@ 2022-04-12 3:33 Anup Patel
2022-04-15 4:47 ` 潘庆霖
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Anup Patel @ 2022-04-12 3:33 UTC (permalink / raw)
To: Palmer Dabbelt, Paul Walmsley
Cc: Alexandre Ghiti, Atish Patra, Alistair Francis, Anup Patel,
linux-riscv, linux-kernel, Anup Patel, Mayuresh Chitale
When Sv57 is not available the satp.MODE test in set_satp_mode() will
fail and lead to pgdir re-programming for Sv48. The pgdir re-programming
will fail as well due to pre-existing pgdir entry used for Sv57 and as
a result kernel fails to boot on RISC-V platform not having Sv57.
To fix above issue, we should clear the pgdir memory in set_satp_mode()
before re-programming.
Fixes: 011f09d12052 ("riscv: mm: Set sv57 on defaultly")
Reported-by: Mayuresh Chitale <mchitale@ventanamicro.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
arch/riscv/mm/init.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 9535bea8688c..b0793dc0c291 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -718,6 +718,7 @@ static __init void set_satp_mode(void)
if (!check_l4) {
disable_pgtable_l5();
check_l4 = true;
+ memset(early_pg_dir, 0, PAGE_SIZE);
goto retry;
}
disable_pgtable_l4();
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] RISC-V: mm: Fix set_satp_mode() for platform not having Sv57
2022-04-12 3:33 [PATCH] RISC-V: mm: Fix set_satp_mode() for platform not having Sv57 Anup Patel
@ 2022-04-15 4:47 ` 潘庆霖
2022-04-15 4:53 ` Anup Patel
2022-04-15 5:47 ` Atish Patra
2022-04-21 9:30 ` Anup Patel
2 siblings, 1 reply; 7+ messages in thread
From: 潘庆霖 @ 2022-04-15 4:47 UTC (permalink / raw)
To: Anup Patel
Cc: Palmer Dabbelt, Paul Walmsley, Alexandre Ghiti, Atish Patra,
Alistair Francis, Anup Patel, linux-riscv, linux-kernel,
Mayuresh Chitale
Hi Anup,
>
> When Sv57 is not available the satp.MODE test in set_satp_mode() will
> fail and lead to pgdir re-programming for Sv48. The pgdir re-programming
> will fail as well due to pre-existing pgdir entry used for Sv57 and as
> a result kernel fails to boot on RISC-V platform not having Sv57.
>
> To fix above issue, we should clear the pgdir memory in set_satp_mode()
> before re-programming.
>
> Fixes: 011f09d12052 ("riscv: mm: Set sv57 on defaultly")
> Reported-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> ---
> arch/riscv/mm/init.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 9535bea8688c..b0793dc0c291 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -718,6 +718,7 @@ static __init void set_satp_mode(void)
> if (!check_l4) {
> disable_pgtable_l5();
> check_l4 = true;
> + memset(early_pg_dir, 0, PAGE_SIZE);
> goto retry;
> }
> disable_pgtable_l4();
> --
I find it that the set_satp_mode function is in .init.text section which begins at 0x80800000.
And its pgd_index in both Sv48 and Sv57 will be 0. So it may not be necessary to clear the
early_pg_dir when the kernel find Sv57 is not supported? And may I get the steps of reproduction
from you?
Yours,
Qinglin
</apatel@ventanamicro.com></mchitale@ventanamicro.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] RISC-V: mm: Fix set_satp_mode() for platform not having Sv57
2022-04-15 4:47 ` 潘庆霖
@ 2022-04-15 4:53 ` Anup Patel
2022-04-15 5:10 ` 潘庆霖
0 siblings, 1 reply; 7+ messages in thread
From: Anup Patel @ 2022-04-15 4:53 UTC (permalink / raw)
To: 潘庆霖
Cc: Palmer Dabbelt, Paul Walmsley, Alexandre Ghiti, Atish Patra,
Alistair Francis, Anup Patel, linux-riscv,
linux-kernel@vger.kernel.org List, Mayuresh Chitale
On Fri, Apr 15, 2022 at 10:18 AM 潘庆霖 <panqinglin2020@iscas.ac.cn> wrote:
>
> Hi Anup,
>
> >
> > When Sv57 is not available the satp.MODE test in set_satp_mode() will
> > fail and lead to pgdir re-programming for Sv48. The pgdir re-programming
> > will fail as well due to pre-existing pgdir entry used for Sv57 and as
> > a result kernel fails to boot on RISC-V platform not having Sv57.
> >
> > To fix above issue, we should clear the pgdir memory in set_satp_mode()
> > before re-programming.
> >
> > Fixes: 011f09d12052 ("riscv: mm: Set sv57 on defaultly")
> > Reported-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> > Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> > ---
> > arch/riscv/mm/init.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> > index 9535bea8688c..b0793dc0c291 100644
> > --- a/arch/riscv/mm/init.c
> > +++ b/arch/riscv/mm/init.c
> > @@ -718,6 +718,7 @@ static __init void set_satp_mode(void)
> > if (!check_l4) {
> > disable_pgtable_l5();
> > check_l4 = true;
> > + memset(early_pg_dir, 0, PAGE_SIZE);
> > goto retry;
> > }
> > disable_pgtable_l4();
> > --
>
>
> I find it that the set_satp_mode function is in .init.text section which begins at 0x80800000.
> And its pgd_index in both Sv48 and Sv57 will be 0. So it may not be necessary to clear the
> early_pg_dir when the kernel find Sv57 is not supported? And may I get the steps of reproduction
> from you?
We can't assume that it will be the same pgd_index for Sv48 and Sv57.
For example, some hypothetical SoC might have RAM starting after 1TB space.
We should ensure that early_pg_dir is cleaned entirely for detecting the next
mode.
Regards,
Anup
>
> Yours,
> Qinglin
> </apatel@ventanamicro.com></mchitale@ventanamicro.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Re: [PATCH] RISC-V: mm: Fix set_satp_mode() for platform not having Sv57
2022-04-15 4:53 ` Anup Patel
@ 2022-04-15 5:10 ` 潘庆霖
0 siblings, 0 replies; 7+ messages in thread
From: 潘庆霖 @ 2022-04-15 5:10 UTC (permalink / raw)
To: Anup Patel
Cc: Palmer Dabbelt, Paul Walmsley, Alexandre Ghiti, Atish Patra,
Alistair Francis, Anup Patel, linux-riscv,
linux-kernel@vger.kernel.org List, Mayuresh Chitale
Hi Anup,
>
> We can't assume that it will be the same pgd_index for Sv48 and Sv57.
>
> For example, some hypothetical SoC might have RAM starting after 1TB space.
>
> We should ensure that early_pg_dir is cleaned entirely for detecting the next
> mode.
>
Got it. Your idea is really more stable. Thank you for pointing out that!
Yours,
Qinglin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] RISC-V: mm: Fix set_satp_mode() for platform not having Sv57
2022-04-12 3:33 [PATCH] RISC-V: mm: Fix set_satp_mode() for platform not having Sv57 Anup Patel
2022-04-15 4:47 ` 潘庆霖
@ 2022-04-15 5:47 ` Atish Patra
2022-04-21 9:30 ` Anup Patel
2 siblings, 0 replies; 7+ messages in thread
From: Atish Patra @ 2022-04-15 5:47 UTC (permalink / raw)
To: Anup Patel
Cc: Palmer Dabbelt, Paul Walmsley, Alexandre Ghiti, Alistair Francis,
Anup Patel, linux-riscv, linux-kernel@vger.kernel.org List,
Mayuresh Chitale
On Mon, Apr 11, 2022 at 8:34 PM Anup Patel <apatel@ventanamicro.com> wrote:
>
> When Sv57 is not available the satp.MODE test in set_satp_mode() will
> fail and lead to pgdir re-programming for Sv48. The pgdir re-programming
> will fail as well due to pre-existing pgdir entry used for Sv57 and as
> a result kernel fails to boot on RISC-V platform not having Sv57.
>
> To fix above issue, we should clear the pgdir memory in set_satp_mode()
> before re-programming.
>
> Fixes: 011f09d12052 ("riscv: mm: Set sv57 on defaultly")
> Reported-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> ---
> arch/riscv/mm/init.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 9535bea8688c..b0793dc0c291 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -718,6 +718,7 @@ static __init void set_satp_mode(void)
> if (!check_l4) {
> disable_pgtable_l5();
> check_l4 = true;
> + memset(early_pg_dir, 0, PAGE_SIZE);
> goto retry;
> }
> disable_pgtable_l4();
> --
> 2.25.1
>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
--
Regards,
Atish
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] RISC-V: mm: Fix set_satp_mode() for platform not having Sv57
2022-04-12 3:33 [PATCH] RISC-V: mm: Fix set_satp_mode() for platform not having Sv57 Anup Patel
2022-04-15 4:47 ` 潘庆霖
2022-04-15 5:47 ` Atish Patra
@ 2022-04-21 9:30 ` Anup Patel
2022-04-21 21:12 ` Palmer Dabbelt
2 siblings, 1 reply; 7+ messages in thread
From: Anup Patel @ 2022-04-21 9:30 UTC (permalink / raw)
To: Palmer Dabbelt, Paul Walmsley
Cc: Alexandre Ghiti, Atish Patra, Alistair Francis, Anup Patel,
linux-riscv, linux-kernel@vger.kernel.org List, Mayuresh Chitale
Hi Palmer,
On Tue, Apr 12, 2022 at 9:04 AM Anup Patel <apatel@ventanamicro.com> wrote:
>
> When Sv57 is not available the satp.MODE test in set_satp_mode() will
> fail and lead to pgdir re-programming for Sv48. The pgdir re-programming
> will fail as well due to pre-existing pgdir entry used for Sv57 and as
> a result kernel fails to boot on RISC-V platform not having Sv57.
>
> To fix above issue, we should clear the pgdir memory in set_satp_mode()
> before re-programming.
>
> Fixes: 011f09d12052 ("riscv: mm: Set sv57 on defaultly")
> Reported-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Can this be considered for 5.18-rcX ?
Regards,
Anup
> ---
> arch/riscv/mm/init.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 9535bea8688c..b0793dc0c291 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -718,6 +718,7 @@ static __init void set_satp_mode(void)
> if (!check_l4) {
> disable_pgtable_l5();
> check_l4 = true;
> + memset(early_pg_dir, 0, PAGE_SIZE);
> goto retry;
> }
> disable_pgtable_l4();
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] RISC-V: mm: Fix set_satp_mode() for platform not having Sv57
2022-04-21 9:30 ` Anup Patel
@ 2022-04-21 21:12 ` Palmer Dabbelt
0 siblings, 0 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2022-04-21 21:12 UTC (permalink / raw)
To: apatel
Cc: Paul Walmsley, alexandre.ghiti, atishp, Alistair Francis, anup,
linux-riscv, linux-kernel, mchitale
On Thu, 21 Apr 2022 02:30:05 PDT (-0700), apatel@ventanamicro.com wrote:
> Hi Palmer,
>
> On Tue, Apr 12, 2022 at 9:04 AM Anup Patel <apatel@ventanamicro.com> wrote:
>>
>> When Sv57 is not available the satp.MODE test in set_satp_mode() will
>> fail and lead to pgdir re-programming for Sv48. The pgdir re-programming
>> will fail as well due to pre-existing pgdir entry used for Sv57 and as
>> a result kernel fails to boot on RISC-V platform not having Sv57.
>>
>> To fix above issue, we should clear the pgdir memory in set_satp_mode()
>> before re-programming.
>>
>> Fixes: 011f09d12052 ("riscv: mm: Set sv57 on defaultly")
>> Reported-by: Mayuresh Chitale <mchitale@ventanamicro.com>
>> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
>
> Can this be considered for 5.18-rcX ?
Sorry, there's a queue but I just say this one at the top and it's super
simple so I'm going to take it now -- IRC is good to ping this sort of
stuff.
It's in fixes.
Thanks!
>
> Regards,
> Anup
>
>> ---
>> arch/riscv/mm/init.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>> index 9535bea8688c..b0793dc0c291 100644
>> --- a/arch/riscv/mm/init.c
>> +++ b/arch/riscv/mm/init.c
>> @@ -718,6 +718,7 @@ static __init void set_satp_mode(void)
>> if (!check_l4) {
>> disable_pgtable_l5();
>> check_l4 = true;
>> + memset(early_pg_dir, 0, PAGE_SIZE);
>> goto retry;
>> }
>> disable_pgtable_l4();
>> --
>> 2.25.1
>>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-04-21 21:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 3:33 [PATCH] RISC-V: mm: Fix set_satp_mode() for platform not having Sv57 Anup Patel
2022-04-15 4:47 ` 潘庆霖
2022-04-15 4:53 ` Anup Patel
2022-04-15 5:10 ` 潘庆霖
2022-04-15 5:47 ` Atish Patra
2022-04-21 9:30 ` Anup Patel
2022-04-21 21:12 ` Palmer Dabbelt
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).