Re: [PATCH 05/23] x86, kaiser: unmap kernel from userspace page tables (core patch)
From: Andrea Arcangeli
Date: Fri Jan 05 2018 - 14:55:43 EST
On Fri, Jan 05, 2018 at 08:17:17PM +0100, Jiri Kosina wrote:
> On Fri, 5 Jan 2018, Dave Hansen wrote:
>
> > > --- a/arch/x86/platform/efi/efi_64.c
> > > +++ b/arch/x86/platform/efi/efi_64.c
> > > @@ -95,6 +95,12 @@ pgd_t * __init efi_call_phys_prolog(void
> > > save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE);
> > > vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
> > > set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
> > > + /*
> > > + * pgprot API doesn't clear it for PGD
> > > + *
> > > + * Will be brought back automatically in _epilog()
> > > + */
> > > + pgd_offset_k(pgd * PGDIR_SIZE)->pgd &= ~_PAGE_NX;
> > > }
> > > __flush_tlb_all();
Upstream & downstream looks different, how the above looks completely
different I don't know, but I got it and updating is easy. Great
catch.
> >
> > Wait a sec... Where does the _PAGE_USER come from? Shouldn't we see
> > the &init_mm in there and *not* set _PAGE_USER?
>
> That's because pgd_populate() uses _PAGE_TABLE and not _KERNPG_TABLE for
> reasons that are behind me.
For vsyscalls? I also had to single out warnings out of init_mm.pgd
for the same reasons.
How does the below (untested) look?