Re: [PATCHv3 15/17] x86/mm: Implement sync_direct_mapping()

From: Kirill A. Shutemov
Date: Mon Jun 18 2018 - 09:33:21 EST


On Wed, Jun 13, 2018 at 06:41:21PM +0000, Dave Hansen wrote:
> On 06/12/2018 07:39 AM, Kirill A. Shutemov wrote:
> > arch/x86/include/asm/mktme.h | 6 +
> > arch/x86/mm/init_64.c | 6 +
> > arch/x86/mm/mktme.c | 444 +++++++++++++++++++++++++++++++++++
> > 3 files changed, 456 insertions(+)
>
> Can we not do any better than 400 lines of new open-coded pagetable
> hacking?

It's not pretty, but I don't see much options.

I first tried to modify routines that initialize/modify/remove parts of
direct mapping to keep all per-KeyID direct mappings in sync from start.
But it didn't really fly. We need to initialize direct mapping very early
when we don't have a way to allocated page in a usual way. We have very
limited pool of pre-allocated pages to allocate page tables from and it's
not able to satisfy demand for multiple direct mappings.

So I had to go with syncing it later on. When we have working page
allocator.

Regarding open-codeness, we need to walk two subtrees in lock steps.
I don't see how get mm/pagewalk.c to work in such use case. (And I don't
really like callback-based pagewalker.)

--
Kirill A. Shutemov