Re: [PATCH v6 12/12] x86/traps: Fix up invalid PASID

From: Dave Hansen
Date: Mon Aug 03 2020 - 12:36:59 EST

On 8/3/20 8:12 AM, Andy Lutomirski wrote:
> I could easily be convinced that the PASID fixup is so trivial and so
> obviously free of misfiring in a way that causes an infinite loop that
> this code is fine. But I think we first need to answer the bigger
> question of why we're doing a lazy fixup in the first place.

There was an (internal to Intel) implementation of this about a year ago
that used smp_call_function_many() to force the MSR state into all
threads of a process. I took one look at it, decided there was a 0%
chance of it actually functioning and recommended we find another way.
While I'm sure it could be done more efficiently, the implementation I
looked at took ~200 lines of code and comments. It started to look too
much like another instance of mm->cpumask for my comfort.

The only other option I could think of would be an ABI where threads
were required to call into the kernel at least once after creation
before calling ENQCMD. All ENQCMDs would be required to be "wrapped" by
code doing this syscall. Something like this:

if (!thread_local(did_pasid_init))
sys_pasid_init(); // new syscall or prctl

thread_local(did_pasid_init) = 1;

// ENQCMD here