RE: [PATCH 1/4] x86/sgx: Add total number of EPC pages

From: Reshetova, Elena
Date: Fri Mar 28 2025 - 05:36:17 EST



> On Fri, Mar 28, 2025 at 08:07:24AM +0000, Reshetova, Elena wrote:
> > > Yes but obviously I cannot promise that I'll accept this as it is
> > > until I see the final version
> >
> > Are you saying you prefer *this version with spinlock* vs.
> > simpler version that utilizes the fact that sgx_nr_free_pages is changed
> > into tracking of number of used pages?
>
> I don't know really what I do prefer.
>
> Maybe +1 version would make sense where you keep with the approach
> you've chosen (used pages) and better rationalize why it is mandatory,
> and why free pages would be worse?

Sure, let me send out v2 with the old approach, all suggestions and fixes
taken into account and better reasoning.

>
> >
> > >
> > > Also you probably should use mutex given the loop where we cannot
> > > temporarily exit the lock (like e.g. in keyrings gc we can).
> >
> > Not sure I understand this, could you please elaborate why do I need an
> > additional mutex here? Or are you suggesting switching spinlock to mutex?
>
> In your code example you had a loop inside spinlock, which was based on
> a return code of an opcode, i.e. potentially infinite loop.

Oh, this is a misunderstanding due to limited snippet posting.
The loop was bounded also by "retry" condition in while with the max number of
retires being 10. It only exists earlier if there is success.


>
> I'd like to remind you that the hardware I have is NUC7 from 2018 so
> you really have to nail how things will work semantically as I can
> only think these things only in theoretical level ;-) [1]

Sure, I understand.

Best Regards,
Elena.


>
>
> >
> > Best Regards,
> > Elena.
> >
>
> [1] https://social.kernel.org/notice/AsUbsYH0T4bTcUSdUW
>
> BR, Jarkko