On Fri, Jul 13, 2018 at 04:21:45PM -0700, Andy Lutomirski wrote: > On Wed, Jul 11, 2018 at 4:29 AM, Joerg Roedel <joro@xxxxxxxxxx> wrote: > > From: Joerg Roedel <jroedel@xxxxxxx> > > > > The mapping for entry-text might have changed in the kernel > > after it was cloned to the user page-table. Clone again > > to update the user page-table to bring the mapping in sync > > with the kernel again. > > Can't we just defer pti_init() until after mark_readonly()? What am I missing? I tried that: https://lore.kernel.org/lkml/1530618746-23116-1-git-send-email-joro@xxxxxxxxxx/ But while testing it turned out that the kernel potentially executes user-space code already before mark_readonly() has ran. This happens when some initcall requests a module and the initrd is already populated. Then usermode-helper kicks in and runs a userspace binary already. When pti_init() has not run yet the user-space page-table is completly empty, causing a triple fault when we switch to the user cr3 on the way to user-space. Regards, Joerg