x86/sgx: Remove unnecessary kmap() from sgx_ioc_enclave_init()
authorIra Weiny <ira.weiny@intel.com>
Wed, 24 Mar 2021 18:22:46 +0000 (11:22 -0700)
committerBorislav Petkov <bp@suse.de>
Thu, 25 Mar 2021 08:50:32 +0000 (09:50 +0100)
commit633b0616cfe085679471a4c0fae02e8c3a1a9866
tree908486d7ae417a5619a1fbb3a529136d3defcc75
parentf33dece70e11ce82a09cb1ea2d7c32347b82c67e
x86/sgx: Remove unnecessary kmap() from sgx_ioc_enclave_init()

kmap() is inefficient and is being replaced by kmap_local_page(), if
possible. There is no readily apparent reason why initp_page needs to be
allocated and kmap'ed() except that 'sigstruct' needs to be page-aligned
and 'token' 512 byte-aligned.

Rather than change it to kmap_local_page(), use kmalloc() instead
because kmalloc() can give this alignment when allocating PAGE_SIZE
bytes.

Remove the alloc_page()/kmap() and replace with kmalloc(PAGE_SIZE, ...)
to get a page aligned kernel address.

In addition, add a comment to document the alignment requirements so that
others don't attempt to 'fix' this again.

 [ bp: Massage commit message. ]

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210324182246.2484875-1-ira.weiny@intel.com
arch/x86/kernel/cpu/sgx/ioctl.c