[PATCH 7/7] x86/sgx: Add a reserved field to sgx_enclave_add_region to drop 'packed'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A reserved field could prove useful in the future, and packed structs
can result in inefficiencies due to its impact on alignment.

Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
---
 arch/x86/include/uapi/asm/sgx.h        | 4 +++-
 arch/x86/kernel/cpu/sgx/driver/ioctl.c | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/uapi/asm/sgx.h b/arch/x86/include/uapi/asm/sgx.h
index 18204722f238..e2d9b3d512ef 100644
--- a/arch/x86/include/uapi/asm/sgx.h
+++ b/arch/x86/include/uapi/asm/sgx.h
@@ -43,6 +43,7 @@ struct sgx_enclave_create  {
  * @secinfo:	address of the SECINFO data (common to the entire region)
  * @flags:	miscellaneous flags
  * @mrmask:	bitmask of 256 byte chunks to measure (applied per 4k page)
+ * @reserved:	reserved for future use, must be zero
  */
 struct sgx_enclave_add_region {
 	__u64	addr;
@@ -51,7 +52,8 @@ struct sgx_enclave_add_region {
 	__u64	secinfo;
 	__u32	flags;
 	__u16	mrmask;
-} __attribute__((__packed__));
+	__u16	reserved;
+};
 
 /**
  * struct sgx_enclave_init - parameter structure for the
diff --git a/arch/x86/kernel/cpu/sgx/driver/ioctl.c b/arch/x86/kernel/cpu/sgx/driver/ioctl.c
index e05a539e96fc..bae5f3155376 100644
--- a/arch/x86/kernel/cpu/sgx/driver/ioctl.c
+++ b/arch/x86/kernel/cpu/sgx/driver/ioctl.c
@@ -663,6 +663,9 @@ static long sgx_ioc_enclave_add_region(struct file *filep, void __user *arg)
 	if (!IS_ALIGNED(region.addr, 4096) || !IS_ALIGNED(region.size, 4096))
 		return -EINVAL;
 
+	if (region.reserved)
+		return -EINVAL;
+
 	if (!region.size)
 		return 0;
 
-- 
2.21.0




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux