Skip to content

Commit ba94a7a

Browse files
committed
Merge tag 'x86_sgx_for_v6.1_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 SGX update from Borislav Petkov: - Improve the documentation of a couple of SGX functions handling backing storage * tag 'x86_sgx_for_v6.1_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/sgx: Improve comments for sgx_encl_lookup/alloc_backing()
2 parents f8475a6 + ee56a28 commit ba94a7a

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

arch/x86/kernel/cpu/sgx/encl.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include "encls.h"
1313
#include "sgx.h"
1414

15+
static int sgx_encl_lookup_backing(struct sgx_encl *encl, unsigned long page_index,
16+
struct sgx_backing *backing);
17+
1518
#define PCMDS_PER_PAGE (PAGE_SIZE / sizeof(struct sgx_pcmd))
1619
/*
1720
* 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,
917920
}
918921

919922
/**
920-
* sgx_encl_get_backing() - Pin the backing storage
923+
* __sgx_encl_get_backing() - Pin the backing storage
921924
* @encl: an enclave pointer
922925
* @page_index: enclave page index
923926
* @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,
929932
* 0 on success,
930933
* -errno otherwise.
931934
*/
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,
933936
struct sgx_backing *backing)
934937
{
935938
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)
10041007
}
10051008

10061009
/**
1007-
* sgx_encl_alloc_backing() - allocate a new backing storage page
1010+
* sgx_encl_alloc_backing() - create a new backing storage page
10081011
* @encl: an enclave pointer
10091012
* @page_index: enclave page index
10101013
* @backing: data for accessing backing storage for the page
10111014
*
10121015
* When called from ksgxd, sets the active memcg from one of the
10131016
* mms in the enclave's mm_list prior to any backing page allocation,
10141017
* 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().
10161021
*
10171022
* Return:
10181023
* 0 on success,
@@ -1025,7 +1030,7 @@ int sgx_encl_alloc_backing(struct sgx_encl *encl, unsigned long page_index,
10251030
struct mem_cgroup *memcg = set_active_memcg(encl_memcg);
10261031
int ret;
10271032

1028-
ret = sgx_encl_get_backing(encl, page_index, backing);
1033+
ret = __sgx_encl_get_backing(encl, page_index, backing);
10291034

10301035
set_active_memcg(memcg);
10311036
mem_cgroup_put(encl_memcg);
@@ -1043,15 +1048,17 @@ int sgx_encl_alloc_backing(struct sgx_encl *encl, unsigned long page_index,
10431048
* It is the caller's responsibility to ensure that it is appropriate to use
10441049
* sgx_encl_lookup_backing() rather than sgx_encl_alloc_backing(). If lookup is
10451050
* 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().
10461053
*
10471054
* Return:
10481055
* 0 on success,
10491056
* -errno otherwise.
10501057
*/
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,
10521059
struct sgx_backing *backing)
10531060
{
1054-
return sgx_encl_get_backing(encl, page_index, backing);
1061+
return __sgx_encl_get_backing(encl, page_index, backing);
10551062
}
10561063

10571064
/**

arch/x86/kernel/cpu/sgx/encl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ bool current_is_ksgxd(void);
107107
void sgx_encl_release(struct kref *ref);
108108
int sgx_encl_mm_add(struct sgx_encl *encl, struct mm_struct *mm);
109109
const cpumask_t *sgx_encl_cpumask(struct sgx_encl *encl);
110-
int sgx_encl_lookup_backing(struct sgx_encl *encl, unsigned long page_index,
111-
struct sgx_backing *backing);
112110
int sgx_encl_alloc_backing(struct sgx_encl *encl, unsigned long page_index,
113111
struct sgx_backing *backing);
114112
void sgx_encl_put_backing(struct sgx_backing *backing);

0 commit comments

Comments
 (0)