* [PATCH] arm64: Fix 5-level paging support in kexec/hibernate trampoline
@ 2025-01-10 17:51 Ard Biesheuvel
2025-01-13 5:01 ` Anshuman Khandual
2025-02-04 13:09 ` Will Deacon
0 siblings, 2 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2025-01-10 17:51 UTC (permalink / raw)
To: linux-arm-kernel; +Cc: will, catalin.marinas, Ard Biesheuvel
From: Ard Biesheuvel <ardb@kernel.org>
Add the missing code to allocate P4D level page tables when cloning the
the kernel page tables. This fixes a crash that may be observed when
attempting to resume from hibernation on an LPA2 capable system with 4k
pages, which therefore uses 5 levels of paging.
Presumably, kexec is equally affected.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/arm64/mm/trans_pgd.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/arm64/mm/trans_pgd.c b/arch/arm64/mm/trans_pgd.c
index 0f7b484cb2ff..84594f02f780 100644
--- a/arch/arm64/mm/trans_pgd.c
+++ b/arch/arm64/mm/trans_pgd.c
@@ -162,6 +162,13 @@ static int copy_p4d(struct trans_pgd_info *info, pgd_t *dst_pgdp,
unsigned long next;
unsigned long addr = start;
+ if (pgd_none(READ_ONCE(*dst_pgdp))) {
+ dst_p4dp = trans_alloc(info);
+ if (!dst_p4dp)
+ return -ENOMEM;
+ pgd_populate(NULL, dst_pgdp, dst_p4dp);
+ }
+
dst_p4dp = p4d_offset(dst_pgdp, start);
src_p4dp = p4d_offset(src_pgdp, start);
do {
--
2.47.1.688.g23fc6f90ad-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: Fix 5-level paging support in kexec/hibernate trampoline
2025-01-10 17:51 [PATCH] arm64: Fix 5-level paging support in kexec/hibernate trampoline Ard Biesheuvel
@ 2025-01-13 5:01 ` Anshuman Khandual
2025-01-13 12:07 ` Ard Biesheuvel
2025-02-04 13:09 ` Will Deacon
1 sibling, 1 reply; 4+ messages in thread
From: Anshuman Khandual @ 2025-01-13 5:01 UTC (permalink / raw)
To: Ard Biesheuvel, linux-arm-kernel; +Cc: will, catalin.marinas, Ard Biesheuvel
On 1/10/25 23:21, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@kernel.org>
>
> Add the missing code to allocate P4D level page tables when cloning the
> the kernel page tables. This fixes a crash that may be observed when
> attempting to resume from hibernation on an LPA2 capable system with 4k
> pages, which therefore uses 5 levels of paging.
>
> Presumably, kexec is equally affected.
>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> arch/arm64/mm/trans_pgd.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/arch/arm64/mm/trans_pgd.c b/arch/arm64/mm/trans_pgd.c
> index 0f7b484cb2ff..84594f02f780 100644
> --- a/arch/arm64/mm/trans_pgd.c
> +++ b/arch/arm64/mm/trans_pgd.c
> @@ -162,6 +162,13 @@ static int copy_p4d(struct trans_pgd_info *info, pgd_t *dst_pgdp,
> unsigned long next;
> unsigned long addr = start;
>
> + if (pgd_none(READ_ONCE(*dst_pgdp))) {
> + dst_p4dp = trans_alloc(info);
> + if (!dst_p4dp)
> + return -ENOMEM;
> + pgd_populate(NULL, dst_pgdp, dst_p4dp);
Just wondering would not dst_p4dp goes unused (and probably leaked) when
pgtable_l5_enabled() is not enabled ? Similar scenario might also exist
in copy_pud() as well with respect to pgtable_l4_enabled().
pgd_populate()
__pgd_populate()
if (pgtable_l5_enabled())
set_pgd()
> + }
> +
> dst_p4dp = p4d_offset(dst_pgdp, start);
> src_p4dp = p4d_offset(src_pgdp, start);
> do {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: Fix 5-level paging support in kexec/hibernate trampoline
2025-01-13 5:01 ` Anshuman Khandual
@ 2025-01-13 12:07 ` Ard Biesheuvel
0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2025-01-13 12:07 UTC (permalink / raw)
To: Anshuman Khandual; +Cc: Ard Biesheuvel, linux-arm-kernel, will, catalin.marinas
On Mon, 13 Jan 2025 at 06:01, Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
>
>
> On 1/10/25 23:21, Ard Biesheuvel wrote:
> > From: Ard Biesheuvel <ardb@kernel.org>
> >
> > Add the missing code to allocate P4D level page tables when cloning the
> > the kernel page tables. This fixes a crash that may be observed when
> > attempting to resume from hibernation on an LPA2 capable system with 4k
> > pages, which therefore uses 5 levels of paging.
> >
> > Presumably, kexec is equally affected.
> >
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> > ---
> > arch/arm64/mm/trans_pgd.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/arch/arm64/mm/trans_pgd.c b/arch/arm64/mm/trans_pgd.c
> > index 0f7b484cb2ff..84594f02f780 100644
> > --- a/arch/arm64/mm/trans_pgd.c
> > +++ b/arch/arm64/mm/trans_pgd.c
> > @@ -162,6 +162,13 @@ static int copy_p4d(struct trans_pgd_info *info, pgd_t *dst_pgdp,
> > unsigned long next;
> > unsigned long addr = start;
> >
> > + if (pgd_none(READ_ONCE(*dst_pgdp))) {
> > + dst_p4dp = trans_alloc(info);
> > + if (!dst_p4dp)
> > + return -ENOMEM;
> > + pgd_populate(NULL, dst_pgdp, dst_p4dp);
>
> Just wondering would not dst_p4dp goes unused (and probably leaked) when
> pgtable_l5_enabled() is not enabled ?
Would pgd_none() ever return TRUE in that case?
> Similar scenario might also exist
> in copy_pud() as well with respect to pgtable_l4_enabled().
>
> pgd_populate()
> __pgd_populate()
> if (pgtable_l5_enabled())
> set_pgd()
>
> > + }
> > +
> > dst_p4dp = p4d_offset(dst_pgdp, start);
> > src_p4dp = p4d_offset(src_pgdp, start);
> > do {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: Fix 5-level paging support in kexec/hibernate trampoline
2025-01-10 17:51 [PATCH] arm64: Fix 5-level paging support in kexec/hibernate trampoline Ard Biesheuvel
2025-01-13 5:01 ` Anshuman Khandual
@ 2025-02-04 13:09 ` Will Deacon
1 sibling, 0 replies; 4+ messages in thread
From: Will Deacon @ 2025-02-04 13:09 UTC (permalink / raw)
To: linux-arm-kernel, Ard Biesheuvel
Cc: catalin.marinas, kernel-team, Will Deacon, Ard Biesheuvel
On Fri, 10 Jan 2025 18:51:46 +0100, Ard Biesheuvel wrote:
> Add the missing code to allocate P4D level page tables when cloning the
> the kernel page tables. This fixes a crash that may be observed when
> attempting to resume from hibernation on an LPA2 capable system with 4k
> pages, which therefore uses 5 levels of paging.
>
> Presumably, kexec is equally affected.
>
> [...]
Applied to arm64 (for-next/fixes), thanks!
[1/1] arm64: Fix 5-level paging support in kexec/hibernate trampoline
https://git.kernel.org/arm64/c/3648027de1fa
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-02-04 13:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-10 17:51 [PATCH] arm64: Fix 5-level paging support in kexec/hibernate trampoline Ard Biesheuvel
2025-01-13 5:01 ` Anshuman Khandual
2025-01-13 12:07 ` Ard Biesheuvel
2025-02-04 13:09 ` Will Deacon
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).