Skip to content

Commit a4ebad6

Browse files
committed
Merge tag 'x86_sgx_for_6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 SGX updates from Dave Hansen: "These fix a deadlock in the SGX NUMA allocator. It's probably only triggerable today on servers with buggy BIOSes, but it's theoretically possible it can happen on less goofy systems" * tag 'x86_sgx_for_6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/sgx: Log information when a node lacks an EPC section x86/sgx: Fix deadlock in SGX NUMA node search
2 parents 963d0d6 + c8ddc99 commit a4ebad6

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

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

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -475,24 +475,25 @@ struct sgx_epc_page *__sgx_alloc_epc_page(void)
475475
{
476476
struct sgx_epc_page *page;
477477
int nid_of_current = numa_node_id();
478-
int nid = nid_of_current;
478+
int nid_start, nid;
479479

480-
if (node_isset(nid_of_current, sgx_numa_mask)) {
481-
page = __sgx_alloc_epc_page_from_node(nid_of_current);
482-
if (page)
483-
return page;
484-
}
485-
486-
/* Fall back to the non-local NUMA nodes: */
487-
while (true) {
488-
nid = next_node_in(nid, sgx_numa_mask);
489-
if (nid == nid_of_current)
490-
break;
480+
/*
481+
* Try local node first. If it doesn't have an EPC section,
482+
* fall back to the non-local NUMA nodes.
483+
*/
484+
if (node_isset(nid_of_current, sgx_numa_mask))
485+
nid_start = nid_of_current;
486+
else
487+
nid_start = next_node_in(nid_of_current, sgx_numa_mask);
491488

489+
nid = nid_start;
490+
do {
492491
page = __sgx_alloc_epc_page_from_node(nid);
493492
if (page)
494493
return page;
495-
}
494+
495+
nid = next_node_in(nid, sgx_numa_mask);
496+
} while (nid != nid_start);
496497

497498
return ERR_PTR(-ENOMEM);
498499
}
@@ -847,6 +848,13 @@ static bool __init sgx_page_cache_init(void)
847848
return false;
848849
}
849850

851+
for_each_online_node(nid) {
852+
if (!node_isset(nid, sgx_numa_mask) &&
853+
node_state(nid, N_MEMORY) && node_state(nid, N_CPU))
854+
pr_info("node%d has both CPUs and memory but doesn't have an EPC section\n",
855+
nid);
856+
}
857+
850858
return true;
851859
}
852860

0 commit comments

Comments
 (0)