Re: [PATCH 05/23] x86, kaiser: unmap kernel from userspace page tables (core patch)
From: Jiri Kosina
Date: Fri Jan 05 2018 - 16:14:14 EST
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();
> >>
> >> 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.
> >
> > I did put this on my TODO list, but for later.
> >
> > (and yes, I tried clearing _PAGE_USER from init_mm's PGD, and no obvious
> > breakages appeared, but I wanted to give it more thought later).
>
> Feel free to add my Ack on this.
Thanks. I'll extract the patch out of this thread and submit it
separately, so that it doesn't get lost buried here.
> I'd personally much rather muck with random relatively unused bits of
> the efi code than touch the core PGD code.
Exactly. Especially at this point.
> We need to go look at it again in the 4.16 timeframe, probably.
Agreed. On my TODO list already.
Thanks,
--
Jiri Kosina
SUSE Labs