* [PATCH 0/1] riscv: Fix P4D_SHIFT definition for 3-level page table mode
@ 2022-12-01 13:51 Alexandre Ghiti
2022-12-01 13:51 ` [PATCH 1/1] " Alexandre Ghiti
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Alexandre Ghiti @ 2022-12-01 13:51 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Qinglin Pan, linux-mm,
linux-riscv, linux-kernel
Cc: Alexandre Ghiti
+cc linux-mm since I'm struggling to know how bad is this issue and
if this should be picked for 6.1-rc8 or not.
I tested this fix on an Ubuntu kernel in sv39 mode without any issue
but the version without the fix seems to work fine too, either this is
not a real issue or I don't exercise the right thing to make it visible.
Any help appreciated!
Alexandre Ghiti (1):
riscv: Fix P4D_SHIFT definition for 3-level page table mode
arch/riscv/include/asm/pgtable-64.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--
2.37.2
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 1/1] riscv: Fix P4D_SHIFT definition for 3-level page table mode 2022-12-01 13:51 [PATCH 0/1] riscv: Fix P4D_SHIFT definition for 3-level page table mode Alexandre Ghiti @ 2022-12-01 13:51 ` Alexandre Ghiti 2022-12-01 19:24 ` Palmer Dabbelt 2022-12-13 16:21 ` [PATCH 0/1] " Palmer Dabbelt 2022-12-13 16:30 ` patchwork-bot+linux-riscv 2 siblings, 1 reply; 5+ messages in thread From: Alexandre Ghiti @ 2022-12-01 13:51 UTC (permalink / raw) To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Qinglin Pan, linux-mm, linux-riscv, linux-kernel Cc: Alexandre Ghiti RISC-V kernels support 3,4,5-level page tables at runtime by folding upper levels. In case of a 3-level page table, PGDIR is folded into P4D which in turn is folded into PUD: PGDIR_SHIFT value is correctly set to the same value as PUD_SHIFT, but P4D_SHIFT is not, then any use of P4D_SHIFT will access invalid address bits (all set to 1). Fix this by dynamically defining P4D_SHIFT value, like we already do for PGDIR_SHIFT. Fixes: d10efa21a937 ("riscv: mm: Control p4d's folding by pgtable_l5_enabled") Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> --- arch/riscv/include/asm/pgtable-64.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h index dc42375c2357..42a042c0e13e 100644 --- a/arch/riscv/include/asm/pgtable-64.h +++ b/arch/riscv/include/asm/pgtable-64.h @@ -25,7 +25,11 @@ extern bool pgtable_l5_enabled; #define PGDIR_MASK (~(PGDIR_SIZE - 1)) /* p4d is folded into pgd in case of 4-level page table */ -#define P4D_SHIFT 39 +#define P4D_SHIFT_L3 30 +#define P4D_SHIFT_L4 39 +#define P4D_SHIFT_L5 39 +#define P4D_SHIFT (pgtable_l5_enabled ? P4D_SHIFT_L5 : \ + (pgtable_l4_enabled ? P4D_SHIFT_L4 : P4D_SHIFT_L3)) #define P4D_SIZE (_AC(1, UL) << P4D_SHIFT) #define P4D_MASK (~(P4D_SIZE - 1)) -- 2.37.2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] riscv: Fix P4D_SHIFT definition for 3-level page table mode 2022-12-01 13:51 ` [PATCH 1/1] " Alexandre Ghiti @ 2022-12-01 19:24 ` Palmer Dabbelt 0 siblings, 0 replies; 5+ messages in thread From: Palmer Dabbelt @ 2022-12-01 19:24 UTC (permalink / raw) To: alexghiti Cc: Paul Walmsley, aou, panqinglin2020, linux-mm, linux-riscv, linux-kernel, alexghiti On Thu, 01 Dec 2022 05:51:28 PST (-0800), alexghiti@rivosinc.com wrote: > RISC-V kernels support 3,4,5-level page tables at runtime by folding > upper levels. > > In case of a 3-level page table, PGDIR is folded into P4D which in turn > is folded into PUD: PGDIR_SHIFT value is correctly set to the same value > as PUD_SHIFT, but P4D_SHIFT is not, then any use of P4D_SHIFT will access > invalid address bits (all set to 1). > > Fix this by dynamically defining P4D_SHIFT value, like we already do for > PGDIR_SHIFT. > > Fixes: d10efa21a937 ("riscv: mm: Control p4d's folding by pgtable_l5_enabled") > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> > --- > arch/riscv/include/asm/pgtable-64.h | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h > index dc42375c2357..42a042c0e13e 100644 > --- a/arch/riscv/include/asm/pgtable-64.h > +++ b/arch/riscv/include/asm/pgtable-64.h > @@ -25,7 +25,11 @@ extern bool pgtable_l5_enabled; > #define PGDIR_MASK (~(PGDIR_SIZE - 1)) > > /* p4d is folded into pgd in case of 4-level page table */ > -#define P4D_SHIFT 39 > +#define P4D_SHIFT_L3 30 > +#define P4D_SHIFT_L4 39 > +#define P4D_SHIFT_L5 39 > +#define P4D_SHIFT (pgtable_l5_enabled ? P4D_SHIFT_L5 : \ > + (pgtable_l4_enabled ? P4D_SHIFT_L4 : P4D_SHIFT_L3)) > #define P4D_SIZE (_AC(1, UL) << P4D_SHIFT) > #define P4D_MASK (~(P4D_SIZE - 1)) Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> Too late for this week, but if someone's got a concrete regression then I'm happy to take it next week. Otherwise it'll end up on for-next, it'll be backported anyway but this way it'll have a touch more time. Thanks! ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/1] riscv: Fix P4D_SHIFT definition for 3-level page table mode 2022-12-01 13:51 [PATCH 0/1] riscv: Fix P4D_SHIFT definition for 3-level page table mode Alexandre Ghiti 2022-12-01 13:51 ` [PATCH 1/1] " Alexandre Ghiti @ 2022-12-13 16:21 ` Palmer Dabbelt 2022-12-13 16:30 ` patchwork-bot+linux-riscv 2 siblings, 0 replies; 5+ messages in thread From: Palmer Dabbelt @ 2022-12-13 16:21 UTC (permalink / raw) To: Paul Walmsley, Qinglin Pan, Palmer Dabbelt, linux-kernel, Alexandre Ghiti, linux-mm, Albert Ou, linux-riscv On Thu, 1 Dec 2022 14:51:27 +0100, Alexandre Ghiti wrote: > +cc linux-mm since I'm struggling to know how bad is this issue and > if this should be picked for 6.1-rc8 or not. > > I tested this fix on an Ubuntu kernel in sv39 mode without any issue > but the version without the fix seems to work fine too, either this is > not a real issue or I don't exercise the right thing to make it visible. > > [...] Applied, thanks! [1/1] riscv: Fix P4D_SHIFT definition for 3-level page table mode https://git.kernel.org/palmer/c/71fc3621efc3 Best regards, -- Palmer Dabbelt <palmer@rivosinc.com> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/1] riscv: Fix P4D_SHIFT definition for 3-level page table mode 2022-12-01 13:51 [PATCH 0/1] riscv: Fix P4D_SHIFT definition for 3-level page table mode Alexandre Ghiti 2022-12-01 13:51 ` [PATCH 1/1] " Alexandre Ghiti 2022-12-13 16:21 ` [PATCH 0/1] " Palmer Dabbelt @ 2022-12-13 16:30 ` patchwork-bot+linux-riscv 2 siblings, 0 replies; 5+ messages in thread From: patchwork-bot+linux-riscv @ 2022-12-13 16:30 UTC (permalink / raw) To: Alexandre Ghiti Cc: linux-riscv, paul.walmsley, palmer, aou, panqinglin2020, linux-mm, linux-kernel Hello: This patch was applied to riscv/linux.git (for-next) by Palmer Dabbelt <palmer@rivosinc.com>: On Thu, 1 Dec 2022 14:51:27 +0100 you wrote: > +cc linux-mm since I'm struggling to know how bad is this issue and > if this should be picked for 6.1-rc8 or not. > > I tested this fix on an Ubuntu kernel in sv39 mode without any issue > but the version without the fix seems to work fine too, either this is > not a real issue or I don't exercise the right thing to make it visible. > > [...] Here is the summary with links: - [1/1] riscv: Fix P4D_SHIFT definition for 3-level page table mode https://git.kernel.org/riscv/c/71fc3621efc3 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-12-13 16:30 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-12-01 13:51 [PATCH 0/1] riscv: Fix P4D_SHIFT definition for 3-level page table mode Alexandre Ghiti 2022-12-01 13:51 ` [PATCH 1/1] " Alexandre Ghiti 2022-12-01 19:24 ` Palmer Dabbelt 2022-12-13 16:21 ` [PATCH 0/1] " Palmer Dabbelt 2022-12-13 16:30 ` patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox