LIST_HEAD(dirty);
int ret;
- while (!list_empty(§ion->laundry_list)) {
+ /* init_laundry_list is thread-local, no need for a lock: */
+ while (!list_empty(§ion->init_laundry_list)) {
if (kthread_should_stop())
return;
+ /* needed for access to ->page_list: */
spin_lock(§ion->lock);
- page = list_first_entry(§ion->laundry_list,
+ page = list_first_entry(§ion->init_laundry_list,
struct sgx_epc_page, list);
ret = __eremove(sgx_get_epc_virt_addr(page));
cond_resched();
}
- list_splice(&dirty, §ion->laundry_list);
+ list_splice(&dirty, §ion->init_laundry_list);
}
static bool sgx_reclaimer_age(struct sgx_epc_page *epc_page)
sgx_sanitize_section(&sgx_epc_sections[i]);
/* Should never happen. */
- if (!list_empty(&sgx_epc_sections[i].laundry_list))
+ if (!list_empty(&sgx_epc_sections[i].init_laundry_list))
WARN(1, "EPC section %d has unsanitized pages.\n", i);
}
section->phys_addr = phys_addr;
spin_lock_init(§ion->lock);
INIT_LIST_HEAD(§ion->page_list);
- INIT_LIST_HEAD(§ion->laundry_list);
+ INIT_LIST_HEAD(§ion->init_laundry_list);
for (i = 0; i < nr_pages; i++) {
section->pages[i].section = index;
section->pages[i].flags = 0;
section->pages[i].owner = NULL;
- list_add_tail(§ion->pages[i].list, §ion->laundry_list);
+ list_add_tail(§ion->pages[i].list, §ion->init_laundry_list);
}
section->free_cnt = nr_pages;
* physical memory e.g. for memory areas of the each node. This structure is
* used to store EPC pages for one EPC section and virtual memory area where
* the pages have been mapped.
+ *
+ * 'lock' must be held before accessing 'page_list' or 'free_cnt'.
*/
struct sgx_epc_section {
unsigned long phys_addr;
void *virt_addr;
- struct list_head page_list;
- struct list_head laundry_list;
struct sgx_epc_page *pages;
- unsigned long free_cnt;
+
spinlock_t lock;
+ struct list_head page_list;
+ unsigned long free_cnt;
+
+ /*
+ * Pages which need EREMOVE run on them before they can be
+ * used. Only safe to be accessed in ksgxd and init code.
+ * Not protected by locks.
+ */
+ struct list_head init_laundry_list;
};
extern struct sgx_epc_section sgx_epc_sections[SGX_MAX_EPC_SECTIONS];