Intel SGX development
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: sean.j.christopherson@intel.com
Cc: linux-sgx@vger.kernel.org,
	Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Subject: [PATCH] x86/sgx: rip off the refcount from sgx_encl_add_page flow
Date: Wed, 19 Jun 2019 15:21:43 +0300	[thread overview]
Message-ID: <20190619122143.12028-1-jarkko.sakkinen@linux.intel.com> (raw)

With the file bound approach we can flush the work queue when the file
is closed.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 arch/x86/kernel/cpu/sgx/driver/ioctl.c | 3 +--
 arch/x86/kernel/cpu/sgx/driver/main.c  | 1 +
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/driver/ioctl.c b/arch/x86/kernel/cpu/sgx/driver/ioctl.c
index d17c60dca114..f56d3c712dc4 100644
--- a/arch/x86/kernel/cpu/sgx/driver/ioctl.c
+++ b/arch/x86/kernel/cpu/sgx/driver/ioctl.c
@@ -172,7 +172,7 @@ static void sgx_add_page_worker(struct work_struct *work)
 
 next:
 		kfree(req);
-	} while (!kref_put(&encl->refcount, sgx_encl_release) && !is_empty);
+	} while (!is_empty);
 }
 
 static u32 sgx_calc_ssaframesize(u32 miscselect, u64 xfrm)
@@ -520,7 +520,6 @@ static int __sgx_encl_add_page(struct sgx_encl *encl,
 	req->encl_page = encl_page;
 	req->mrmask = mrmask;
 	empty = list_empty(&encl->add_page_reqs);
-	kref_get(&encl->refcount);
 	list_add_tail(&req->list, &encl->add_page_reqs);
 	if (empty)
 		queue_work(sgx_encl_wq, &encl->work);
diff --git a/arch/x86/kernel/cpu/sgx/driver/main.c b/arch/x86/kernel/cpu/sgx/driver/main.c
index 0c831ee5e2de..9ea082372682 100644
--- a/arch/x86/kernel/cpu/sgx/driver/main.c
+++ b/arch/x86/kernel/cpu/sgx/driver/main.c
@@ -47,6 +47,7 @@ static int sgx_release(struct inode *inode, struct file *file)
 {
 	struct sgx_encl *encl = file->private_data;
 
+	flush_work(&encl->work);
 	kref_put(&encl->refcount, sgx_encl_release);
 
 	return 0;
-- 
2.20.1


             reply	other threads:[~2019-06-19 12:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-19 12:21 Jarkko Sakkinen [this message]
2019-06-19 15:43 ` [PATCH] x86/sgx: rip off the refcount from sgx_encl_add_page flow Sean Christopherson
2019-06-20 19:23   ` Jarkko Sakkinen

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=20190619122143.12028-1-jarkko.sakkinen@linux.intel.com \
    --to=jarkko.sakkinen@linux.intel.com \
    --cc=linux-sgx@vger.kernel.org \
    --cc=sean.j.christopherson@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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox