[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <163412979365.25758.7879693193208918421.tip-bot2@tip-bot2>
Date: Wed, 13 Oct 2021 12:56:33 -0000
From: "tip-bot2 for Paolo Bonzini" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Paolo Bonzini <pbonzini@...hat.com>, Borislav Petkov <bp@...e.de>,
Jarkko Sakkinen <jarkko@...nel.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: x86/sgx] x86/sgx/virt: Extract sgx_vepc_remove_page()
The following commit has been merged into the x86/sgx branch of tip:
Commit-ID: 33633b20e0da301f9009cc9aa00282acbc282a1f
Gitweb: https://git.kernel.org/tip/33633b20e0da301f9009cc9aa00282acbc282a1f
Author: Paolo Bonzini <pbonzini@...hat.com>
AuthorDate: Tue, 12 Oct 2021 06:57:07 -04:00
Committer: Borislav Petkov <bp@...e.de>
CommitterDate: Wed, 13 Oct 2021 11:57:44 +02:00
x86/sgx/virt: Extract sgx_vepc_remove_page()
For bare-metal SGX on real hardware, the hardware provides guaranteed
SGX state at reboot. For instance, all pages start out uninitialized.
The vepc driver provides a similar guarantee today for freshly-opened
vepc instances, but guests such as Windows expect all pages to be in
uninitialized state on startup, including after every guest reboot.
One way to do this is to simply close and reopen the /dev/sgx_vepc file
descriptor and re-mmap the virtual EPC. However, this is problematic
because it prevents sandboxing the userspace (for example forbidding
open() after the guest starts; this is doable with heavy use of SCM_RIGHTS
file descriptor passing).
In order to implement this, an ioctl will be needed that performs
EREMOVE on all pages mapped by a /dev/sgx_vepc file descriptor: other
possibilities, such as closing and reopening the device, are racy.
Start the implementation by creating a separate function with just
the __eremove() wrapper.
Signed-off-by: Paolo Bonzini <pbonzini@...hat.com>
Signed-off-by: Borislav Petkov <bp@...e.de>
Reviewed-by: Jarkko Sakkinen <jarkko@...nel.org>
Link: https://lkml.kernel.org/r/20211012105708.2070480-2-pbonzini@redhat.com
---
arch/x86/kernel/cpu/sgx/virt.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/sgx/virt.c b/arch/x86/kernel/cpu/sgx/virt.c
index 64511c4..59cdf3f 100644
--- a/arch/x86/kernel/cpu/sgx/virt.c
+++ b/arch/x86/kernel/cpu/sgx/virt.c
@@ -111,10 +111,8 @@ static int sgx_vepc_mmap(struct file *file, struct vm_area_struct *vma)
return 0;
}
-static int sgx_vepc_free_page(struct sgx_epc_page *epc_page)
+static int sgx_vepc_remove_page(struct sgx_epc_page *epc_page)
{
- int ret;
-
/*
* Take a previously guest-owned EPC page and return it to the
* general EPC page pool.
@@ -124,7 +122,12 @@ static int sgx_vepc_free_page(struct sgx_epc_page *epc_page)
* case that a guest properly EREMOVE'd this page, a superfluous
* EREMOVE is harmless.
*/
- ret = __eremove(sgx_get_epc_virt_addr(epc_page));
+ return __eremove(sgx_get_epc_virt_addr(epc_page));
+}
+
+static int sgx_vepc_free_page(struct sgx_epc_page *epc_page)
+{
+ int ret = sgx_vepc_remove_page(epc_page);
if (ret) {
/*
* Only SGX_CHILD_PRESENT is expected, which is because of
@@ -144,7 +147,6 @@ static int sgx_vepc_free_page(struct sgx_epc_page *epc_page)
}
sgx_free_epc_page(epc_page);
-
return 0;
}
Powered by blists - more mailing lists