Re: [PATCH 1/2] x86/arch_prctl: add ARCH_SET_{COMPAT,NATIVE} to change compatible mode

From: Andy Lutomirski
Date: Wed Apr 06 2016 - 14:49:48 EST


On Wed, Apr 6, 2016 at 11:04 AM, Andy Lutomirski <luto@xxxxxxxxxxxxxx> wrote:
> [cc Dave Hansen for MPX]
>

> - For MPX, could we track which syscall called mpx_enable_management?
> I.e. can we stash in_compat_syscall's return from
> mpx_enable_management and use that instead of trying to determine the
> MPX data structure format by the mm's initial type?
>

Even this may be more complicated than necessary. Could the MPX
helpers just use user_64bit_mode? After all, if your bounds
structures don't match your bitness and you take an MPX fault, you are
screwed no matter what the kernel does, so why not just have the
kernel helpers look at the user state?

Hmm. There's mpx_unmap_tables, too, which complicates things.

FWIW, caching the bounds directory address may not be so important.
On my Skylake laptop, reading BNDCSR using XSAVE (RFBM set to just
BNDCSR) takes about 100 cycles and reading it using XSAVEC takes about
75 cycles.

--Andy