OSDN Git Service

x86/sgx: Add SGX page allocator functions
authorJarkko Sakkinen <jarkko@kernel.org>
Thu, 12 Nov 2020 22:01:20 +0000 (00:01 +0200)
committerBorislav Petkov <bp@suse.de>
Tue, 17 Nov 2020 13:36:13 +0000 (14:36 +0100)
commitd2285493bef310b66b56dfe4eb75c1e2f431ea5c
tree0e4dac4184a6086a496cb4cb77ab1b69d1b7f769
parent38853a303982e3be3eccb1a1132399a5c5e2d806
x86/sgx: Add SGX page allocator functions

Add functions for runtime allocation and free.

This allocator and its algorithms are as simple as it gets.  They do a
linear search across all EPC sections and find the first free page.  They
are not NUMA-aware and only hand out individual pages.  The SGX hardware
does not support large pages, so something more complicated like a buddy
allocator is unwarranted.

The free function (sgx_free_epc_page()) implicitly calls ENCLS[EREMOVE],
which returns the page to the uninitialized state.  This ensures that the
page is ready for use at the next allocation.

Co-developed-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Jethro Beekman <jethro@fortanix.com>
Link: https://lkml.kernel.org/r/20201112220135.165028-10-jarkko@kernel.org
arch/x86/kernel/cpu/sgx/main.c
arch/x86/kernel/cpu/sgx/sgx.h