From: Jacob Pan <jacob.jun.pan@linux.intel.com> To: LKML <linux-kernel@vger.kernel.org>, iommu@lists.linux-foundation.org, Joerg Roedel <joro@8bytes.org>, "Lu Baolu" <baolu.lu@linux.intel.com>, David Woodhouse <dwmw2@infradead.org> Cc: Yi Liu <yi.l.liu@intel.com>, Raj Ashok <ashok.raj@intel.com>, "Tian, Kevin" <kevin.tian@intel.com>, Eric Auger <eric.auger@redhat.com>, Jean-Philippe Brucker <jean-philippe@linaro.com>, Jacob Pan <jacob.jun.pan@linux.intel.com> Subject: [PATCH v2 4/4] iommu/vt-d: Calculate and set flags for handle_mm_fault Date: Tue, 2 Mar 2021 02:14:00 -0800 [thread overview] Message-ID: <1614680040-1989-5-git-send-email-jacob.jun.pan@linux.intel.com> (raw) In-Reply-To: <1614680040-1989-1-git-send-email-jacob.jun.pan@linux.intel.com> 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@intel.com> Acked-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com> --- 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; -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Jacob Pan <jacob.jun.pan@linux.intel.com> To: LKML <linux-kernel@vger.kernel.org>, iommu@lists.linux-foundation.org, Joerg Roedel <joro@8bytes.org>, "Lu Baolu" <baolu.lu@linux.intel.com>, David Woodhouse <dwmw2@infradead.org> Cc: "Tian, Kevin" <kevin.tian@intel.com>, Raj Ashok <ashok.raj@intel.com>, Jean-Philippe Brucker <jean-philippe@linaro.com> Subject: [PATCH v2 4/4] iommu/vt-d: Calculate and set flags for handle_mm_fault Date: Tue, 2 Mar 2021 02:14:00 -0800 [thread overview] Message-ID: <1614680040-1989-5-git-send-email-jacob.jun.pan@linux.intel.com> (raw) In-Reply-To: <1614680040-1989-1-git-send-email-jacob.jun.pan@linux.intel.com> 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@intel.com> Acked-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com> --- 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; -- 2.25.1 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2021-03-02 21:49 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-02 10:13 [PATCH v2 0/4] Misc vSVA fixes for VT-d Jacob Pan 2021-03-02 10:13 ` Jacob Pan 2021-03-02 10:13 ` [PATCH v2 1/4] iommu/vt-d: Enable write protect for supervisor SVM Jacob Pan 2021-03-02 10:13 ` Jacob Pan 2021-03-03 4:56 ` Lu Baolu 2021-03-03 4:56 ` Lu Baolu 2021-03-22 17:53 ` Guenter Roeck 2021-03-22 17:53 ` Guenter Roeck 2021-03-30 17:52 ` Jacob Pan 2021-03-30 17:52 ` Jacob Pan 2021-03-30 19:02 ` Guenter Roeck 2021-03-30 19:02 ` Guenter Roeck 2021-03-02 10:13 ` [PATCH v2 2/4] iommu/vt-d: Enable write protect propagation from guest Jacob Pan 2021-03-02 10:13 ` Jacob Pan 2021-03-03 4:57 ` Lu Baolu 2021-03-03 4:57 ` Lu Baolu 2021-03-02 10:13 ` [PATCH v2 3/4] iommu/vt-d: Reject unsupported page request modes Jacob Pan 2021-03-02 10:13 ` Jacob Pan 2021-03-02 10:14 ` Jacob Pan [this message] 2021-03-02 10:14 ` [PATCH v2 4/4] iommu/vt-d: Calculate and set flags for handle_mm_fault Jacob Pan 2021-03-18 10:43 ` [PATCH v2 0/4] Misc vSVA fixes for VT-d Joerg Roedel 2021-03-18 10:43 ` Joerg Roedel
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1614680040-1989-5-git-send-email-jacob.jun.pan@linux.intel.com \ --to=jacob.jun.pan@linux.intel.com \ --cc=ashok.raj@intel.com \ --cc=baolu.lu@linux.intel.com \ --cc=dwmw2@infradead.org \ --cc=eric.auger@redhat.com \ --cc=iommu@lists.linux-foundation.org \ --cc=jean-philippe@linaro.com \ --cc=joro@8bytes.org \ --cc=kevin.tian@intel.com \ --cc=linux-kernel@vger.kernel.org \ --cc=yi.l.liu@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.