[PATCH 0/8] Re-enable ENQCMD and PASID MSR

From: Fenghua Yu
Date: Mon Sep 20 2021 - 16:06:26 EST


Since updating PASID (Process Address Space ID) MSR through IPI has a few
issues that are beyond repair, Thomas disables ENQCMD [1].

Please check Documentation/x86/sva.rst for various concepts and terms
related to PASID, ENQCMD, SVM (Shared Virtual Memory), etc.

This series re-enables ENQCMD and IA32_PASID MSR by using a #GP fix up
method previously published in [2]. A PASID is allocated to a mm once
a SVM is bound to the mm via intel_svm_bind() API. The #GP fix up method
updates the PASID MSR from the mm's PASID in #GP handler when one thread
in a process executes ENQCMD for the first time and one reference is taken
to the PASID. Once the MSR is uploaded, the thread keeps and can use it
for the rest life time of the thread. In exit(2) or unbind, the PASID's
reference is dropped and the PASID is freed if there is no reference.

References:
1. ENQCMD was disabled in upstream due to serious issues:
https://lore.kernel.org/linux-iommu/87mtsd6gr9.ffs@xxxxxxxxxxxxxxxxxxxxxxx/

2. #GP fix up PASID MSR:
https://lore.kernel.org/linux-iommu/1594684087-61184-1-git-send-email-fenghua.yu@xxxxxxxxx/

Fenghua Yu (7):
iommu/vt-d: Clean up unused PASID updating functions
x86/process: Clear PASID state for a newly forked/cloned thread
x86/traps: Demand-populate PASID MSR via #GP
x86/mmu: Add mm-based PASID refcounting
x86/cpufeatures: Re-enable ENQCMD
tools/objtool: Check for use of the ENQCMD instruction in the kernel
docs: x86: Change documentation for SVA (Shared Virtual Addressing)

Peter Zijlstra (1):
sched: Define and initialize a flag to identify valid PASID in the
task

Documentation/x86/sva.rst | 81 ++++++++++++++++++--
arch/x86/include/asm/disabled-features.h | 7 +-
arch/x86/include/asm/fpu/api.h | 6 +-
arch/x86/include/asm/iommu.h | 8 ++
arch/x86/include/asm/mmu_context.h | 2 +
arch/x86/kernel/fpu/xstate.c | 59 +++++++++++++++
arch/x86/kernel/process.c | 8 ++
arch/x86/kernel/traps.c | 12 +++
drivers/iommu/intel/svm.c | 95 ++++++++++++++++++------
include/linux/sched.h | 4 +
kernel/fork.c | 4 +
tools/objtool/arch/x86/decode.c | 10 ++-
tools/objtool/check.c | 20 +++++
tools/objtool/include/objtool/arch.h | 1 +
14 files changed, 283 insertions(+), 34 deletions(-)

--
2.33.0