On 8/11/20 7:20 PM, Jessica Clarke wrote: > From 6c13e42cb95025e5f7ea3ac1a1262817bf3fcfec Mon Sep 17 00:00:00 2001 > From: Jessica Clarke <jrtc27@xxxxxxxxxx> > Date: Tue, 11 Aug 2020 19:18:28 +0200 > Subject: [PATCH] arch/ia64: Restore arch-specific pgd_offset_k implementation > > IA-64 is special and treats pgd_offset_k differently from pgd_offset by > not including the region number, and init_mm's PGD is such that it only > points to the kernel's region's PGD. This was broken in 974b9b2c68 which > unified the two and therfore included the region number, causing it to > index way out of bounds of the kernel's PGD and cause the kernel to hang > during early boot. Thus, permit pgd_offset_k to be overridden like the > other macros and override it on IA-64 with the old implementation. Also > update the comment to clarify that this is not just an optimisation but > a required implementation detail. > > Fixes: 974b9b2c68 ("mm: consolidate pte_index() and pte_offset_*() definitions") > Reported-by: John Paul Adrian Glaubitz <glaubitz@xxxxxxxxxxxxxxxxxxx> > Signed-off-by: Jessica Clarke <jrtc27@xxxxxxxxxx> > --- > arch/ia64/include/asm/pgtable.h | 8 ++++++++ > include/linux/pgtable.h | 2 ++ > 2 files changed, 10 insertions(+) > > diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h > index 10850897a91c..2ac2199d99ce 100644 > --- a/arch/ia64/include/asm/pgtable.h > +++ b/arch/ia64/include/asm/pgtable.h > @@ -366,6 +366,14 @@ pgd_index (unsigned long address) > } > #define pgd_index pgd_index > > +/* > + * In the kernel's mapped region we know everything is in region number 5, so > + * as an optimisation its PGD already points to the area for that region, but > + * that means not adding the region here is required, not just an optimisation. > + */ > +#define pgd_offset_k(addr) \ > + (init_mm.pgd + (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))) > + > /* Look up a pgd entry in the gate area. On IA-64, the gate-area > resides in the kernel-mapped segment, hence we use pgd_offset_k() > here. */ > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index 53e97da1e8e2..73c64fe098ba 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -117,7 +117,9 @@ static inline pgd_t *pgd_offset_pgd(pgd_t *pgd, unsigned long address) > * a shortcut which implies the use of the kernel's pgd, instead > * of a process's > */ > +#ifndef pgd_offset_k > #define pgd_offset_k(address) pgd_offset(&init_mm, (address)) > +#endif > > /* > * In many cases it is known that a virtual address is mapped at PMD or PTE > Yes, this fixes it for me. The kernel boots fine again. Also, no build issues. Tested-by: John Paul Adrian Glaubitz <glaubitz@xxxxxxxxxxxxxxxxxxx> Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@xxxxxxxxxx `. `' Freie Universitaet Berlin - glaubitz@xxxxxxxxxxxxxxxxxxx `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913