From: Will Deacon <will@kernel.org>
To: Mark Rutland <mark.rutland@arm.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>,
Nathan Chancellor <nathan@kernel.org>,
linux-arm-kernel@lists.infradead.org,
Catalin Marinas <catalin.marinas@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] arm64/mm: Drop redundant BUG_ON(!pgtable_alloc)
Date: Mon, 21 Nov 2022 12:51:29 +0000 [thread overview]
Message-ID: <20221121125128.GA7097@willie-the-truck> (raw)
In-Reply-To: <Y3tuxzl54BvG406t@FVFF77S0Q05N.cambridge.arm.com>
On Mon, Nov 21, 2022 at 12:27:51PM +0000, Mark Rutland wrote:
> On Mon, Nov 21, 2022 at 11:00:42AM +0530, Anshuman Khandual wrote:
> > On 11/20/22 21:46, Nathan Chancellor wrote:
> > > I just bisected a boot failure in our QEMU-based continuous integration
> > > setup to this change as commit 9ed2b4616d4e ("arm64/mm: Drop redundant
> > > BUG_ON(!pgtable_alloc)") in the arm64 tree. There is no output so the
> > > panic clearly happens early at boot. If I move back to the previous
> > > commit and add a WARN_ON() like so:
> > >
> > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> > > index d386033a074c..9280a92ff920 100644
> > > --- a/arch/arm64/mm/mmu.c
> > > +++ b/arch/arm64/mm/mmu.c
> > > @@ -383,6 +383,7 @@ static void __create_pgd_mapping_locked(pgd_t *pgdir, phys_addr_t phys,
> > > phys &= PAGE_MASK;
> > > addr = virt & PAGE_MASK;
> > > end = PAGE_ALIGN(virt + size);
> > > + WARN_ON(!pgtable_alloc);
> > >
> > > do {
> > > next = pgd_addr_end(addr, end);
> > >
> > > I do see some stacktraces. I have attached the boot log from QEMU.
> > >
> > > If there is any additional information I can provide or patches I can
> > > test, I am more than happy to do so.
> >
> > There are couple of instances, where __create_pgd_mapping() function gets called
> > without a valid pgtable alloc function (NULL is passed on instead), as it is not
> > expected to allocate page table pages, during the mapping process. The following
> > change after this patch should solve the reported problem.
> >
> > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> > index 9ea8e9039992..a00563122fcb 100644
> > --- a/arch/arm64/mm/mmu.c
> > +++ b/arch/arm64/mm/mmu.c
> > @@ -42,6 +42,7 @@
> > #define NO_BLOCK_MAPPINGS BIT(0)
> > #define NO_CONT_MAPPINGS BIT(1)
> > #define NO_EXEC_MAPPINGS BIT(2) /* assumes FEAT_HPDS is not used */
> > +#define NO_ALLOC_MAPPINGS BIT(3) /* does not allocate page table pages */
> >
> > int idmap_t0sz __ro_after_init;
> >
> > @@ -380,7 +381,7 @@ static void __create_pgd_mapping_locked(pgd_t *pgdir, phys_addr_t phys,
> > phys &= PAGE_MASK;
> > addr = virt & PAGE_MASK;
> > end = PAGE_ALIGN(virt + size);
> > - BUG_ON(!pgtable_alloc);
> > + BUG_ON(!(flags & NO_ALLOC_MAPPINGS) && !pgtable_alloc);
> >
> > do {
> > next = pgd_addr_end(addr, end);
> > @@ -453,7 +454,7 @@ static void __init create_mapping_noalloc(phys_addr_t phys, unsigned long virt,
> > return;
> > }
> > __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot, NULL,
> > - NO_CONT_MAPPINGS);
> > + NO_CONT_MAPPINGS | NO_ALLOC_MAPPINGS);
> > }
> >
> > void __init create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
> > @@ -481,7 +482,7 @@ static void update_mapping_prot(phys_addr_t phys, unsigned long virt,
> > }
> >
> > __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot, NULL,
> > - NO_CONT_MAPPINGS);
> > + NO_CONT_MAPPINGS | NO_ALLOC_MAPPINGS);
> >
> > /* flush the TLBs after updating live kernel mappings */
> > flush_tlb_kernel_range(virt, virt + size);
>
> This is now more complicated than what we had originally, and it doesn't catch
> the case where the caller sets NO_ALLOC_MAPPINGS but the callee ends up needing
> to perform an allocation, which the old code would have caught.
>
> This is clearly more subtle than we thought initially; for now could we please
> just drop the patch?
Absolutely, this was supposed to be a trivial cleanup but clearly it's much
more than that. I'll revert it today.
Thanks, Nathan!
Will
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-11-21 12:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-18 5:31 [PATCH] arm64/mm: Drop redundant BUG_ON(!pgtable_alloc) Anshuman Khandual
2022-11-18 11:10 ` Mark Rutland
2022-11-18 19:40 ` Will Deacon
2022-11-20 16:16 ` Nathan Chancellor
2022-11-21 5:30 ` Anshuman Khandual
2022-11-21 12:27 ` Mark Rutland
2022-11-21 12:51 ` Will Deacon [this message]
2022-11-21 13:56 ` Robin Murphy
2022-11-22 3:13 ` Anshuman Khandual
2022-11-22 14:12 ` Biju Das
2022-11-22 19:08 ` Robin Murphy
[not found] <CA+G9fYuYashEQsCfScoVbVqAxeXC4w6VnenO-5dHDH8OEfFBTQ@mail.gmail.com>
2022-11-21 18:03 ` Will Deacon
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=20221121125128.GA7097@willie-the-truck \
--to=will@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=nathan@kernel.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox