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
@@ -917,7 +920,7 @@ static struct page *sgx_encl_get_backing_page(struct sgx_encl *encl,
917
920
}
918
921
919
922
/**
920
- * sgx_encl_get_backing () - Pin the backing storage
923
+ * __sgx_encl_get_backing () - Pin the backing storage
921
924
* @encl: an enclave pointer
922
925
* @page_index: enclave page index
923
926
* @backing: data for accessing backing storage for the page
@@ -929,7 +932,7 @@ static struct page *sgx_encl_get_backing_page(struct sgx_encl *encl,
929
932
* 0 on success,
930
933
* -errno otherwise.
931
934
*/
932
- static int sgx_encl_get_backing (struct sgx_encl * encl , unsigned long page_index ,
935
+ static int __sgx_encl_get_backing (struct sgx_encl * encl , unsigned long page_index ,
933
936
struct sgx_backing * backing )
934
937
{
935
938
pgoff_t page_pcmd_off = sgx_encl_get_backing_page_pcmd_offset (encl , page_index );
@@ -1004,15 +1007,17 @@ static struct mem_cgroup *sgx_encl_get_mem_cgroup(struct sgx_encl *encl)
1004
1007
}
1005
1008
1006
1009
/**
1007
- * sgx_encl_alloc_backing() - allocate a new backing storage page
1010
+ * sgx_encl_alloc_backing() - create a new backing storage page
1008
1011
* @encl: an enclave pointer
1009
1012
* @page_index: enclave page index
1010
1013
* @backing: data for accessing backing storage for the page
1011
1014
*
1012
1015
* When called from ksgxd, sets the active memcg from one of the
1013
1016
* mms in the enclave's mm_list prior to any backing page allocation,
1014
1017
* in order to ensure that shmem page allocations are charged to the
1015
- * enclave.
1018
+ * enclave. Create a backing page for loading data back into an EPC page with
1019
+ * ELDU. This function takes a reference on a new backing page which
1020
+ * must be dropped with a corresponding call to sgx_encl_put_backing().
1016
1021
*
1017
1022
* Return:
1018
1023
* 0 on success,
@@ -1025,7 +1030,7 @@ int sgx_encl_alloc_backing(struct sgx_encl *encl, unsigned long page_index,
1025
1030
struct mem_cgroup * memcg = set_active_memcg (encl_memcg );
1026
1031
int ret ;
1027
1032
1028
- ret = sgx_encl_get_backing (encl , page_index , backing );
1033
+ ret = __sgx_encl_get_backing (encl , page_index , backing );
1029
1034
1030
1035
set_active_memcg (memcg );
1031
1036
mem_cgroup_put (encl_memcg );
@@ -1043,15 +1048,17 @@ int sgx_encl_alloc_backing(struct sgx_encl *encl, unsigned long page_index,
1043
1048
* It is the caller's responsibility to ensure that it is appropriate to use
1044
1049
* sgx_encl_lookup_backing() rather than sgx_encl_alloc_backing(). If lookup is
1045
1050
* not used correctly, this will cause an allocation which is not accounted for.
1051
+ * This function takes a reference on an existing backing page which must be
1052
+ * dropped with a corresponding call to sgx_encl_put_backing().
1046
1053
*
1047
1054
* Return:
1048
1055
* 0 on success,
1049
1056
* -errno otherwise.
1050
1057
*/
1051
- int sgx_encl_lookup_backing (struct sgx_encl * encl , unsigned long page_index ,
1058
+ static int sgx_encl_lookup_backing (struct sgx_encl * encl , unsigned long page_index ,
1052
1059
struct sgx_backing * backing )
1053
1060
{
1054
- return sgx_encl_get_backing (encl , page_index , backing );
1061
+ return __sgx_encl_get_backing (encl , page_index , backing );
1055
1062
}
1056
1063
1057
1064
/**
0 commit comments