[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <de38822919d93dd5074becc707d616022fad03c2.camel@intel.com>
Date: Thu, 24 Jul 2025 10:18:24 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "Reshetova, Elena" <elena.reshetova@...el.com>, "Hansen, Dave"
<dave.hansen@...el.com>
CC: "seanjc@...gle.com" <seanjc@...gle.com>, "mingo@...nel.org"
<mingo@...nel.org>, "Scarlata, Vincent R" <vincent.r.scarlata@...el.com>,
"x86@...nel.org" <x86@...nel.org>, "jarkko@...nel.org" <jarkko@...nel.org>,
"Annapurve, Vishal" <vannapurve@...gle.com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "Mallick, Asit K" <asit.k.mallick@...el.com>,
"Aktas, Erdem" <erdemaktas@...gle.com>, "Cai, Chong" <chongc@...gle.com>,
"Bondarevska, Nataliia" <bondarn@...gle.com>, "linux-sgx@...r.kernel.org"
<linux-sgx@...r.kernel.org>, "Raynor, Scott" <scott.raynor@...el.com>
Subject: Re: [PATCH v9 6/6] x86/sgx: Enable automatic SVN updates for SGX
enclaves
> /* Counter to count the active SGX users */
> static int __maybe_unused sgx_usage_count;
Seems you forgot to remove this __maybe_unused.
I think you can just introduce 'sgx_usage_count' in this patch.
>
> +/* Mutex to ensure no concurrent EPC accesses during EUPDATESVN */
> +static DEFINE_MUTEX(sgx_svn_lock);
> +
> /**
> * sgx_update_svn() - Attempt to call ENCLS[EUPDATESVN].
> * This instruction attempts to update CPUSVN to the
> @@ -937,7 +940,7 @@ static int __maybe_unused sgx_usage_count;
> * entropy in RNG.
> * -EIO: Unexpected error, retries are not advisable.
> */
> -static int __maybe_unused sgx_update_svn(void)
> +static int sgx_update_svn(void)
> {
> int ret;
>
> @@ -983,12 +986,17 @@ static int __maybe_unused sgx_update_svn(void)
>
> int sgx_inc_usage_count(void)
> {
> + guard(mutex)(&sgx_svn_lock);
> +
> + if (sgx_usage_count++ == 0)
> + return sgx_update_svn();
> +
> return 0;
> }
>
> void sgx_dec_usage_count(void)
> {
> - return;
> + sgx_usage_count--;
> }
>
> static int __init sgx_init(void)
> --
> 2.45.2
Powered by blists - more mailing lists