[PATCH 4/5 v10] ARM: Initialize the mapping of KASan shadow memory

Mike Rapoport rppt at linux.ibm.com
Tue Jun 30 10:45:24 EDT 2020


On Tue, Jun 30, 2020 at 03:22:19PM +0200, Linus Walleij wrote:
> Hi Mike!
> 
> First a BIG THANKS for your help! With the aid of your review comments
> and the further comments from Russell I have really progressed with this
> patch set the last few days.
> 
> On Mon, Jun 15, 2020 at 4:33 PM Mike Rapoport <rppt at linux.ibm.com> wrote:
> 
> > > -#define pud_populate(mm,pmd,pte)     BUG()
> > > -
> > > +#ifndef CONFIG_KASAN
> > > +#define pud_populate(mm, pmd, pte)   BUG()
> > > +#else
> > > +#define pud_populate(mm, pmd, pte)   do { } while (0)
> >
> > Hmm, is this really necessary? Regardless of CONFIG_KASAN pud_populate()
> > should never be called for non-LPAE case...
> 
> It is necessary because the generic KASan code in
> mm/kasan/init.c unconditionally calls pud_populate() and act as
> if pud's always exist and need to be populated.
> 
> Possibly this means that pud_populate() should just be turned
> into do { } while (0) as well (like other functions called unconditionally
> from the VMM) but I'll leave this in for now.

Yes, making pud_populate() a NOP will match the "generic" implementation
in asm-generic/pgtable-nopmd.h. 

If this patchset will get to v12, maybe it would be worth doing that  :)

> >         cpu_switch_mm(tmp_pgd_table, &init_mm);
> >
> > And, why do we need a context switch here at all?
> 
> This is really just a way of reusing that function call to replace
> the master page table pointer TTBR0 (Translation Table Base Register)
> while setting up the shadow memory.

Right, but is this really necessary to create the shadow page table?

If I remember correctly, the mm parameter is anyway not used by ARM page
table manpulators and pgd_offset_k() can be replaced by
pgd_offset_pgd(tmp_pgd_table, ...).

> Yours,
> Linus Walleij

-- 
Sincerely yours,
Mike.



More information about the linux-arm-kernel mailing list