Re: [PATCH v8 1/5] x86/sgx: Introduce a counter to count the sgx_(vepc_)open()

From: Dave Hansen
Date: Mon Jul 21 2025 - 12:48:01 EST


On 7/15/25 05:40, Elena Reshetova wrote:
> +int sgx_inc_usage_count(void)
> +{
> + sgx_usage_count++;
> + return 0;
> +}
> +
> +void sgx_dec_usage_count(void)
> +{
> + sgx_usage_count--;
> +}

Gah.

I know this gets fixed up later in the series with the mutex, but this
code is broken and racy until that point.

I'd rather this do _nothing_:

int sgx_inc_usage_count(void)
{
return 0;
}

than a foo++ which just plain doesn't work.