Re: [PATCH 00/23] KAISER: unmap most of the kernel from userspace page tables

From: Linus Torvalds
Date: Wed Nov 01 2017 - 12:08:14 EST


On Tue, Oct 31, 2017 at 4:44 PM, Dave Hansen
<dave.hansen@xxxxxxxxxxxxxxx> wrote:
> On 10/31/2017 04:27 PM, Linus Torvalds wrote:
>> (c) am I reading the code correctly, and the shadow page tables are
>> *completely* duplicated?
>>
>> That seems insane. Why isn't only tyhe top level shadowed, and
>> then lower levels are shared between the shadowed and the "kernel"
>> page tables?
>
> There are obviously two PGDs. The userspace half of the PGD is an exact
> copy so all the lower levels are shared. The userspace copying is
> done via the code we add to native_set_pgd().

So the thing that made me think you do all levels was that confusing
kaiser_pagetable_walk() code (and to a lesser degree
get_pa_from_mapping()).

That code definitely walks and allocates all levels.

So it really doesn't seem to be just sharing the top page table entry.

And that worries me because that seems to be a very fundamental coherency issue.

I'm assuming that this is about mapping only the individual kernel
parts, but I'd like to get comments and clarification about that.

Linus