mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-18 02:04:05 +08:00
iommu/vt-d: Implement SVM_FLAG_PRIVATE_PASID to allocate unique PASIDs
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
parent
0204a49609
commit
569e4f7782
@ -285,11 +285,12 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_
|
|||||||
pasid_max = 1 << 20;
|
pasid_max = 1 << 20;
|
||||||
|
|
||||||
mutex_lock(&pasid_mutex);
|
mutex_lock(&pasid_mutex);
|
||||||
if (pasid) {
|
if (pasid && !(flags & SVM_FLAG_PRIVATE_PASID)) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
idr_for_each_entry(&iommu->pasid_idr, svm, i) {
|
idr_for_each_entry(&iommu->pasid_idr, svm, i) {
|
||||||
if (svm->mm != current->mm)
|
if (svm->mm != current->mm ||
|
||||||
|
(svm->flags & SVM_FLAG_PRIVATE_PASID))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (svm->pasid >= pasid_max) {
|
if (svm->pasid >= pasid_max) {
|
||||||
@ -355,6 +356,7 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_
|
|||||||
svm->pasid = ret;
|
svm->pasid = ret;
|
||||||
svm->notifier.ops = &intel_mmuops;
|
svm->notifier.ops = &intel_mmuops;
|
||||||
svm->mm = get_task_mm(current);
|
svm->mm = get_task_mm(current);
|
||||||
|
svm->flags = flags;
|
||||||
INIT_LIST_HEAD_RCU(&svm->devs);
|
INIT_LIST_HEAD_RCU(&svm->devs);
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
if (!svm->mm || (ret = mmu_notifier_register(&svm->notifier, svm->mm))) {
|
if (!svm->mm || (ret = mmu_notifier_register(&svm->notifier, svm->mm))) {
|
||||||
|
@ -489,6 +489,7 @@ struct intel_svm {
|
|||||||
struct mmu_notifier notifier;
|
struct mmu_notifier notifier;
|
||||||
struct mm_struct *mm;
|
struct mm_struct *mm;
|
||||||
struct intel_iommu *iommu;
|
struct intel_iommu *iommu;
|
||||||
|
int flags;
|
||||||
int pasid;
|
int pasid;
|
||||||
struct list_head devs;
|
struct list_head devs;
|
||||||
};
|
};
|
||||||
|
@ -31,6 +31,17 @@ struct svm_dev_ops {
|
|||||||
#define SVM_REQ_EXEC (1<<1)
|
#define SVM_REQ_EXEC (1<<1)
|
||||||
#define SVM_REQ_PRIV (1<<0)
|
#define SVM_REQ_PRIV (1<<0)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The SVM_FLAG_PRIVATE_PASID flag requests a PASID which is *not* the "main"
|
||||||
|
* PASID for the current process. Even if a PASID already exists, a new one
|
||||||
|
* will be allocated. And the PASID allocated with SVM_FLAG_PRIVATE_PASID
|
||||||
|
* will not be given to subsequent callers. This facility allows a driver to
|
||||||
|
* disambiguate between multiple device contexts which access the same MM,
|
||||||
|
* if there is no other way to do so. It should be used sparingly, if at all.
|
||||||
|
*/
|
||||||
|
#define SVM_FLAG_PRIVATE_PASID (1<<0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* intel_svm_bind_mm() - Bind the current process to a PASID
|
* intel_svm_bind_mm() - Bind the current process to a PASID
|
||||||
* @dev: Device to be granted acccess
|
* @dev: Device to be granted acccess
|
||||||
|
Loading…
Reference in New Issue
Block a user