summaryrefslogtreecommitdiff
path: root/arch/x86/kernel/cpu/sgx/encls.h
diff options
context:
space:
mode:
authorSean Christopherson <sean.j.christopherson@intel.com>2021-03-19 10:23:06 +0300
committerBorislav Petkov <bp@suse.de>2021-04-06 10:43:42 +0300
commita67136b458e5e63822b19c35794451122fe2bf3e (patch)
treea8c6cd83a88169cb238fd46bd2aa9ca5505c4b19 /arch/x86/kernel/cpu/sgx/encls.h
parent32ddda8e445df3de477db14d386fb3518042224a (diff)
downloadlinux-a67136b458e5e63822b19c35794451122fe2bf3e.tar.xz
x86/sgx: Add encls_faulted() helper
Add a helper to extract the fault indicator from an encoded ENCLS return value. SGX virtualization will also need to detect ENCLS faults. Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> Signed-off-by: Kai Huang <kai.huang@intel.com> Signed-off-by: Borislav Petkov <bp@suse.de> Acked-by: Jarkko Sakkinen <jarkko@kernel.org> Acked-by: Dave Hansen <dave.hansen@intel.com> Link: https://lkml.kernel.org/r/c1f955898110de2f669da536fc6cf62e003dff88.1616136308.git.kai.huang@intel.com
Diffstat (limited to 'arch/x86/kernel/cpu/sgx/encls.h')
-rw-r--r--arch/x86/kernel/cpu/sgx/encls.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/arch/x86/kernel/cpu/sgx/encls.h b/arch/x86/kernel/cpu/sgx/encls.h
index be5c49689980..9b204843b78d 100644
--- a/arch/x86/kernel/cpu/sgx/encls.h
+++ b/arch/x86/kernel/cpu/sgx/encls.h
@@ -40,6 +40,19 @@
} while (0); \
}
+/*
+ * encls_faulted() - Check if an ENCLS leaf faulted given an error code
+ * @ret: the return value of an ENCLS leaf function call
+ *
+ * Return:
+ * - true: ENCLS leaf faulted.
+ * - false: Otherwise.
+ */
+static inline bool encls_faulted(int ret)
+{
+ return ret & ENCLS_FAULT_FLAG;
+}
+
/**
* encls_failed() - Check if an ENCLS function failed
* @ret: the return value of an ENCLS function call
@@ -50,7 +63,7 @@
*/
static inline bool encls_failed(int ret)
{
- if (ret & ENCLS_FAULT_FLAG)
+ if (encls_faulted(ret))
return ENCLS_TRAPNR(ret) != X86_TRAP_PF;
return !!ret;