Re: [PATCH v5 2/2] x86/sgx: Add an attribute for the amount of SGX memory in a NUMA node

From: Jarkko Sakkinen
Date: Mon Sep 27 2021 - 23:01:44 EST


On Thu, 2021-09-23 at 13:39 -0700, Reinette Chatre wrote:
> Hi Jarkko,
>
> On 9/23/2021 1:30 PM, Jarkko Sakkinen wrote:
> > So cat you pick these patches to your patch set, and squash
> > this fix to it?
>
> My patch set is focused on SGX selftests while this series target the
> x86 tree. I assumed that this series would go into x86 separately and
> after they land we can proceed with the SGX selftest work.

But now your series has no chance to be applied, given that
it contains patches which have discarded given a superior
approach.

Anyway, node fields are initialized here:

if (!node_isset(nid, sgx_numa_mask)) {
spin_lock_init(&sgx_numa_nodes[nid].lock);
INIT_LIST_HEAD(&sgx_numa_nodes[nid].free_page_list);
node_set(nid, sgx_numa_mask);
}

The correct way to fix the issue is to add

sgx_numa_nodes[nid].size = 0;

Using kcalloc() would not be very sound, since you would wastefully
initialize the pre-existing fields of the struct two times: first
with zeros, and then with "real" values.

/Jarkko