12
12
#include "encls.h"
13
13
#include "sgx.h"
14
14
15
+ static int sgx_encl_lookup_backing (struct sgx_encl * encl , unsigned long page_index ,
16
+ struct sgx_backing * backing );
17
+
15
18
#define PCMDS_PER_PAGE (PAGE_SIZE / sizeof(struct sgx_pcmd))
16
19
/*
17
20
* 32 PCMD entries share a PCMD page. PCMD_FIRST_MASK is used to
@@ -914,7 +917,7 @@ static struct page *sgx_encl_get_backing_page(struct sgx_encl *encl,
914
917
}
915
918
916
919
/**
917
- * sgx_encl_get_backing () - Pin the backing storage
920
+ * __sgx_encl_get_backing () - Pin the backing storage
918
921
* @encl: an enclave pointer
919
922
* @page_index: enclave page index
920
923
* @backing: data for accessing backing storage for the page
@@ -926,7 +929,7 @@ static struct page *sgx_encl_get_backing_page(struct sgx_encl *encl,
926
929
* 0 on success,
927
930
* -errno otherwise.
928
931
*/
929
- static int sgx_encl_get_backing (struct sgx_encl * encl , unsigned long page_index ,
932
+ static int __sgx_encl_get_backing (struct sgx_encl * encl , unsigned long page_index ,
930
933
struct sgx_backing * backing )
931
934
{
932
935
pgoff_t page_pcmd_off = sgx_encl_get_backing_page_pcmd_offset (encl , page_index );
@@ -1001,15 +1004,17 @@ static struct mem_cgroup *sgx_encl_get_mem_cgroup(struct sgx_encl *encl)
1001
1004
}
1002
1005
1003
1006
/**
1004
- * sgx_encl_alloc_backing() - allocate a new backing storage page
1007
+ * sgx_encl_alloc_backing() - create a new backing storage page
1005
1008
* @encl: an enclave pointer
1006
1009
* @page_index: enclave page index
1007
1010
* @backing: data for accessing backing storage for the page
1008
1011
*
1009
1012
* When called from ksgxd, sets the active memcg from one of the
1010
1013
* mms in the enclave's mm_list prior to any backing page allocation,
1011
1014
* in order to ensure that shmem page allocations are charged to the
1012
- * enclave.
1015
+ * enclave. Create a backing page for loading data back into an EPC page with
1016
+ * ELDU. This function takes a reference on a new backing page which
1017
+ * must be dropped with a corresponding call to sgx_encl_put_backing().
1013
1018
*
1014
1019
* Return:
1015
1020
* 0 on success,
@@ -1022,7 +1027,7 @@ int sgx_encl_alloc_backing(struct sgx_encl *encl, unsigned long page_index,
1022
1027
struct mem_cgroup * memcg = set_active_memcg (encl_memcg );
1023
1028
int ret ;
1024
1029
1025
- ret = sgx_encl_get_backing (encl , page_index , backing );
1030
+ ret = __sgx_encl_get_backing (encl , page_index , backing );
1026
1031
1027
1032
set_active_memcg (memcg );
1028
1033
mem_cgroup_put (encl_memcg );
@@ -1040,15 +1045,17 @@ int sgx_encl_alloc_backing(struct sgx_encl *encl, unsigned long page_index,
1040
1045
* It is the caller's responsibility to ensure that it is appropriate to use
1041
1046
* sgx_encl_lookup_backing() rather than sgx_encl_alloc_backing(). If lookup is
1042
1047
* not used correctly, this will cause an allocation which is not accounted for.
1048
+ * This function takes a reference on an existing backing page which must be
1049
+ * dropped with a corresponding call to sgx_encl_put_backing().
1043
1050
*
1044
1051
* Return:
1045
1052
* 0 on success,
1046
1053
* -errno otherwise.
1047
1054
*/
1048
- int sgx_encl_lookup_backing (struct sgx_encl * encl , unsigned long page_index ,
1055
+ static int sgx_encl_lookup_backing (struct sgx_encl * encl , unsigned long page_index ,
1049
1056
struct sgx_backing * backing )
1050
1057
{
1051
- return sgx_encl_get_backing (encl , page_index , backing );
1058
+ return __sgx_encl_get_backing (encl , page_index , backing );
1052
1059
}
1053
1060
1054
1061
/**
0 commit comments