Re: [PATCH v11 4/5] x86/sgx: Implement ENCLS[EUPDATESVN]

From: Huang, Kai
Date: Sun Aug 10 2025 - 19:28:54 EST


On Fri, 2025-08-08 at 10:59 +0000, Reshetova, Elena wrote:
> > > + /*
> > > + * EPC is guaranteed to be empty when there are no users.
> > > + * Ensure we are on our first user before proceeding further.
> > > + */
> > > + WARN(sgx_usage_count != 1, "Elevated usage count when calling
> > EUPDATESVN\n");
> >
> > I am not sure whether this is needed.  Wouldn't the ENCLS_WARN() at the
> > end catch this case and the user is able to figure out what went wrong
> > from the error code?
>
> Dave has made a suggestion to include this check, so I have added it.

Sorry I didn't read careful enough and missed that.

>
> >
> > Besides that, in _this_ patch, what prevents sgx_usage_count from being
> > concurrently updated is still unknown.  It's kinda weird to just use it
> > here w/o seeing the actual mutex.
>
> In this patch it is fully useless, because sgx_usage_count is never incremented
> from zero and this function is also never called. But I didn’t want to move this
> addition to the following patch since it would look as one-add to this function.

Sure np.