[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <96124ae0-8d7e-864c-3de9-f8c0f2d7fffd@linux.intel.com>
Date: Sat, 20 Feb 2021 10:18:45 +0800
From: Lu Baolu <baolu.lu@...ux.intel.com>
To: Jacob Pan <jacob.jun.pan@...ux.intel.com>,
LKML <linux-kernel@...r.kernel.org>,
iommu@...ts.linux-foundation.org, Joerg Roedel <joro@...tes.org>
Cc: baolu.lu@...ux.intel.com, Yi Liu <yi.l.liu@...el.com>,
Raj Ashok <ashok.raj@...el.com>,
"Tian, Kevin" <kevin.tian@...el.com>, Wu Hao <hao.wu@...el.com>,
Yi Sun <yi.y.sun@...el.com>, Dave Jiang <dave.jiang@...el.com>,
Eric Auger <eric.auger@...hat.com>,
Jean-Philippe Brucker <jean-philippe@...aro.com>
Subject: Re: [PATCH 4/4] iommu/vt-d: Calculate and set flags for
handle_mm_fault
On 2/19/21 5:31 AM, Jacob Pan wrote:
> Page requests are originated from the user page fault. Therefore, we
> shall set FAULT_FLAG_USER.
>
> FAULT_FLAG_REMOTE indicates that we are walking an mm which is not
> guaranteed to be the same as the current->mm and should not be subject
> to protection key enforcement. Therefore, we should set FAULT_FLAG_REMOTE
> to avoid faults when both SVM and PKEY are used.
>
> References: commit 1b2ee1266ea6 ("mm/core: Do not enforce PKEY permissions on remote mm access")
> Reviewed-by: Raj Ashok <ashok.raj@...el.com>
> Signed-off-by: Jacob Pan <jacob.jun.pan@...ux.intel.com>
Acked-by: Lu Baolu <baolu.lu@...ux.intel.com>
Best regards,
baolu
> ---
> drivers/iommu/intel/svm.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
> index ff7ae7cc17d5..7bfd20a24a60 100644
> --- a/drivers/iommu/intel/svm.c
> +++ b/drivers/iommu/intel/svm.c
> @@ -1086,6 +1086,7 @@ static irqreturn_t prq_event_thread(int irq, void *d)
> struct intel_iommu *iommu = d;
> struct intel_svm *svm = NULL;
> int head, tail, handled = 0;
> + unsigned int flags = 0;
>
> /* Clear PPR bit before reading head/tail registers, to
> * ensure that we get a new interrupt if needed. */
> @@ -1186,9 +1187,11 @@ static irqreturn_t prq_event_thread(int irq, void *d)
> if (access_error(vma, req))
> goto invalid;
>
> - ret = handle_mm_fault(vma, address,
> - req->wr_req ? FAULT_FLAG_WRITE : 0,
> - NULL);
> + flags = FAULT_FLAG_USER | FAULT_FLAG_REMOTE;
> + if (req->wr_req)
> + flags |= FAULT_FLAG_WRITE;
> +
> + ret = handle_mm_fault(vma, address, flags, NULL);
> if (ret & VM_FAULT_ERROR)
> goto invalid;
>
>
Powered by blists - more mailing lists