Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste

From: Heiko Carstens
Date: Fri Jun 02 2017 - 06:29:02 EST


On Fri, Jun 02, 2017 at 11:46:47AM +0200, Martin Schwidefsky wrote:
> On Fri, 2 Jun 2017 09:02:10 +0200
> Heiko Carstens <heiko.carstens@xxxxxxxxxx> wrote:
> > Maybe this is a bit over-simplified, but might work.
> This is not over-simplified at all, that does work:

Good!

> +struct arch_elf_state {
> +};
> +
> +#define INIT_ARCH_ELF_STATE { }
> +
> +#define arch_elf_pt_proc(ehdr, phdr, elf, interp, state) (0)
> +#define arch_check_elf(ehdr, interp, interp_ehdr, state) \
> +({ \
> + struct elf64_hdr *hdr = (void*) ehdr; \
> + int _rc = 0; \
> + if (hdr->e_ident[EI_CLASS] == ELFCLASS64 && \
> + (hdr->e_flags & 0x00000002) && \
> + !page_table_allocate_pgste && \
> + !current->mm->context.alloc_pgste) { \
> + current->mm->context.alloc_pgste = 1; \

However, I think this is over-simplified, unless I'm mistaken.

If you set current->mm->context.alloc_pgste here, then that means that 4k
page tables will be freed when the original mm will be released, instead of
the correct 2k ones.

I think you need an additional intermediate context flag here. Something
like current->mm->context.request_pgste or whatever, no?