All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC] x86/sgx: Do not increase encl->refcount for VMAs
@ 2019-06-13 16:30 Jarkko Sakkinen
  2019-06-13 16:30 ` Jarkko Sakkinen
  2019-06-17 16:40 ` Jarkko Sakkinen
  0 siblings, 2 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2019-06-13 16:30 UTC (permalink / raw)
  To: linux-sgx; +Cc: luto, cedric.xing, Jarkko Sakkinen

Since the device file stays open up until all VMAs have been closed
we do not need to increase encl->refcount for VMAs. sgx_open() will
increase it once and sgx_release() will decrease at a point where
the device file is not mapped. anymore.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
Based on the commentary from Andy and Cedric.
 arch/x86/kernel/cpu/sgx/driver/main.c | 2 --
 arch/x86/kernel/cpu/sgx/encl.c        | 3 ---
 2 files changed, 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/driver/main.c b/arch/x86/kernel/cpu/sgx/driver/main.c
index 87735ce8b5ba..0c831ee5e2de 100644
--- a/arch/x86/kernel/cpu/sgx/driver/main.c
+++ b/arch/x86/kernel/cpu/sgx/driver/main.c
@@ -68,8 +68,6 @@ static int sgx_mmap(struct file *file, struct vm_area_struct *vma)
 	vma->vm_flags |= VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP | VM_IO;
 	vma->vm_private_data = encl;
 
-	kref_get(&encl->refcount);
-
 	return 0;
 }
 
diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
index 6b190eccd02e..9566eb72d417 100644
--- a/arch/x86/kernel/cpu/sgx/encl.c
+++ b/arch/x86/kernel/cpu/sgx/encl.c
@@ -208,7 +208,6 @@ static void sgx_vma_open(struct vm_area_struct *vma)
 			goto error;
 	}
 
-	kref_get(&encl->refcount);
 	return;
 
 error:
@@ -230,8 +229,6 @@ static void sgx_vma_close(struct vm_area_struct *vma)
 		/* Release kref for the VMA. */
 		kref_put(&encl_mm->refcount, sgx_encl_mm_release);
 	}
-
-	kref_put(&encl->refcount, sgx_encl_release);
 }
 
 static unsigned int sgx_vma_fault(struct vm_fault *vmf)
-- 
2.20.1


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

end of thread, other threads:[~2019-06-20 19:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-13 16:30 [PATCH RFC] x86/sgx: Do not increase encl->refcount for VMAs Jarkko Sakkinen
2019-06-13 16:30 ` Jarkko Sakkinen
2019-06-17 16:40 ` Jarkko Sakkinen
2019-06-17 16:52   ` Sean Christopherson
2019-06-19 12:46     ` Jarkko Sakkinen
2019-06-19 15:34       ` Sean Christopherson
2019-06-20 19:08         ` Jarkko Sakkinen

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.