linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Take mmap_sem when calling get_user_pages
@ 2014-04-28 22:27 suravee.suthikulpanit
  2014-05-06 18:14 ` Joerg Roedel
  2014-05-12 19:04 ` Joerg Roedel
  0 siblings, 2 replies; 5+ messages in thread
From: suravee.suthikulpanit @ 2014-04-28 22:27 UTC (permalink / raw)
  To: iommu, joro; +Cc: linux-kernel, kim.naru, jay.cornwall, Suravee Suthikulpanit

From: Jay Cornwall <jay.cornwall@amd.com>

get_user_pages requires caller to hold a read lock on mmap_sem.

Signed-off-by: Jay Cornwall <jay.cornwall@amd.com>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
 drivers/iommu/amd_iommu_v2.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
index 5208828..203b2e6 100644
--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -504,8 +504,10 @@ static void do_fault(struct work_struct *work)
 
 	write = !!(fault->flags & PPR_FAULT_WRITE);
 
+	down_read(&fault->state->mm->mmap_sem);
 	npages = get_user_pages(fault->state->task, fault->state->mm,
 				fault->address, 1, write, 0, &page, NULL);
+	up_read(&fault->state->mm->mmap_sem);
 
 	if (npages == 1) {
 		put_page(page);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] iommu/amd: Take mmap_sem when calling get_user_pages
  2014-04-28 22:27 [PATCH] iommu/amd: Take mmap_sem when calling get_user_pages suravee.suthikulpanit
@ 2014-05-06 18:14 ` Joerg Roedel
  2014-05-06 19:11   ` Suravee Suthikulanit
  2014-05-12 19:04 ` Joerg Roedel
  1 sibling, 1 reply; 5+ messages in thread
From: Joerg Roedel @ 2014-05-06 18:14 UTC (permalink / raw)
  To: suravee.suthikulpanit; +Cc: iommu, linux-kernel, kim.naru, jay.cornwall

On Mon, Apr 28, 2014 at 05:27:46PM -0500, Suthikulpanit, Suravee wrote:
> From: Jay Cornwall <jay.cornwall@amd.com>
> 
> get_user_pages requires caller to hold a read lock on mmap_sem.

Right, but can't we just switch to get_user_pages_fast instead?


	Joerg



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iommu/amd: Take mmap_sem when calling get_user_pages
  2014-05-06 18:14 ` Joerg Roedel
@ 2014-05-06 19:11   ` Suravee Suthikulanit
  2014-05-06 19:27     ` Suravee Suthikulanit
  0 siblings, 1 reply; 5+ messages in thread
From: Suravee Suthikulanit @ 2014-05-06 19:11 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, linux-kernel, kim.naru, jay.cornwall

On 5/6/2014 1:14 PM, Joerg Roedel wrote:
> On Mon, Apr 28, 2014 at 05:27:46PM -0500, Suthikulpanit, Suravee wrote:
>> From: Jay Cornwall <jay.cornwall@amd.com>
>>
>> get_user_pages requires caller to hold a read lock on mmap_sem.
>
> Right, but can't we just switch to get_user_pages_fast instead?
>
>
> 	Joerg
>

You're right. I think it can. Let me spin out another patch.

Suravee


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iommu/amd: Take mmap_sem when calling get_user_pages
  2014-05-06 19:11   ` Suravee Suthikulanit
@ 2014-05-06 19:27     ` Suravee Suthikulanit
  0 siblings, 0 replies; 5+ messages in thread
From: Suravee Suthikulanit @ 2014-05-06 19:27 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, linux-kernel, kim.naru, jay.cornwall

On 5/6/2014 2:11 PM, Suravee Suthikulanit wrote:
> On 5/6/2014 1:14 PM, Joerg Roedel wrote:
>> On Mon, Apr 28, 2014 at 05:27:46PM -0500, Suthikulpanit, Suravee wrote:
>>> From: Jay Cornwall <jay.cornwall@amd.com>
>>>
>>> get_user_pages requires caller to hold a read lock on mmap_sem.
>>
>> Right, but can't we just switch to get_user_pages_fast instead?
>>
>>
>>     Joerg
>>
>
> You're right. I think it can. Let me spin out another patch.
>
> Suravee
>

Actually, we would have to provide the pointer to task_struct for the 
corresponding PASID which is not necessary "current".  So I take it 
back. I don't think we can use _fast.

Suravee

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iommu/amd: Take mmap_sem when calling get_user_pages
  2014-04-28 22:27 [PATCH] iommu/amd: Take mmap_sem when calling get_user_pages suravee.suthikulpanit
  2014-05-06 18:14 ` Joerg Roedel
@ 2014-05-12 19:04 ` Joerg Roedel
  1 sibling, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2014-05-12 19:04 UTC (permalink / raw)
  To: suravee.suthikulpanit; +Cc: iommu, linux-kernel, kim.naru, jay.cornwall

On Mon, Apr 28, 2014 at 05:27:46PM -0500, suravee.suthikulpanit@amd.com wrote:
> From: Jay Cornwall <jay.cornwall@amd.com>
> 
> get_user_pages requires caller to hold a read lock on mmap_sem.
> 
> Signed-off-by: Jay Cornwall <jay.cornwall@amd.com>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>

Applied, thanks Jay and Suravee.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-05-12 19:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-28 22:27 [PATCH] iommu/amd: Take mmap_sem when calling get_user_pages suravee.suthikulpanit
2014-05-06 18:14 ` Joerg Roedel
2014-05-06 19:11   ` Suravee Suthikulanit
2014-05-06 19:27     ` Suravee Suthikulanit
2014-05-12 19:04 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).