lkml.org 
[lkml]   [2022]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] x86/mm: Do not verify W^X at boot up
On Tue, Oct 25, 2022 at 09:53:27AM -0700, Linus Torvalds wrote:
> On Tue, Oct 25, 2022 at 3:16 AM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > This seems to boot...
>
> This looks much better, thanks.
>
> But this:
>
> > diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
> > @@ -801,8 +803,9 @@ void __init poking_init(void)
> > spinlock_t *ptl;
> > pte_t *ptep;
> >
> > - poking_mm = copy_init_mm();
> > - BUG_ON(!poking_mm);
> > + __poking_mm = init_mm;
> > + mm_init(&__poking_mm, NULL, __poking_mm.user_ns);
> > + poking_mm = &__poking_mm;
>
> Should probably be just
>
> poking_mm = mm_alloc();
>
> because we shouldn't be messing with 'mm_init()' in places like this,
> and we shouldn't be exporting it either:

mm_alloc() uses allocate_mm() which requires a kmem_cache to be set-up.
Using the static storage and instead calling mm_init() on it avoids
that.

So I think we can have:

static struct mm_struct __poking_mm;

mm_init(&__poking_mm, NULL, init_mm.user_ns);

and leave out the assignment from init_mm.

\
 
 \ /
  Last update: 2022-10-25 19:48    [W:0.532 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site