>> > +static bool fixup_pasid_exception(void) >> > +{ >> > + if (!cpu_feature_enabled(X86_FEATURE_ENQCMD)) >> > + return false; >> > + >> > + return __fixup_pasid_exception(); >> > +} > > That is, shouldn't the above at the very least decode the instruction > causing the #GP and check it's this ENQCMD thing?
It can't reliably do that because some other thread in the process may have re-written the memory that regs->ip points at (bizarre case, but I think Dave Hansen brought it up). So it would just add extra code, and still only be a hint. Without the check this sequence is possible: 1) Process binds an accelerator (so mm->pasid is set) 2) Task in the process executes something other than ENQCMD that gets a #GP 3) Kernel says "Oh, mm->pasid is set, I'll initialize the IA32_PASID MSR to see if that fixes it" 4) Nope. Re-executing the instruction at step #2 just gives another #GP 5) Kernel says "I already set IA32_PASID, so this must be something else ... do regular #GP actions" Now if the task catches the signal that results from step #5 and avoids termination, it will have IA32_PASID set ... but to the right value should it go on to actually execute ENQCMD at some future point. So the corner case from not knowing whether this #GP was from ENQCMD or not is harmless. -Tony _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu