Re: [PATCH v5 09/18] x86/sgx: Store struct sgx_encl when allocating new VA pages

Huang, Kai
2023-10-02T11:05:27Z

On Fri, 2023-09-29 at 10:06 -0500, Haitao Huang wrote:
> On Wed, 27 Sep 2023 16:21:19 -0500, Huang, Kai <kai.huang@intel.com> wrote:
>
> > On Wed, 2023-09-27 at 10:35 -0500, Haitao Huang wrote:
> > > > > +
> > > > > + /* Possible owner types */
> > > > > + union {
> > > > > + struct sgx_encl_page *encl_page;
> > > > > + struct sgx_encl *encl;
> > > > > + };
> > > >
> > > > Sadly for virtual EPC page the owner is set to the 'sgx_vepc'
> > > instance it
> > > > belongs to.
> > > >
> > > > Given how sgx_{alloc|free}_epc_page() arbitrarily uses encl_page,>
> > > perhaps we
> > > > should do below?
> > > >
> > > > union {
> > > > struct sgx_encl_page *encl_page;
> > > > struct sgx_encl *encl;
> > > > struct sgx_vepc *vepc;
> > > > void *owner;
> > > > };
> > > >
> > > > And in sgx_{alloc|free}_epc_page() we can use 'owner' instead.
> > > >
> > >
> > > As I mentioned in cover letter and change log in 11/18, this series does
> > > not track virtual EPC.
> >
> > It's not about how does the cover letter says. We cannot ignore the
> > fact that
> > currently virtual EPC uses owner too.
> >
> > But given the virtual EPC code currently doesn't use the owner, I can
> > live with
> > not having the 'vepc' member in the union now.
>
> Ah, I forgot even though we don't use the owner field assigned by vepc, it
> is still passed into sgx_alloc/free_epc_page().
>
> Will add back "void* owner" and use it for assignment inside
> sgx_alloc/free_epc_page().
>
>

And also sgx_setup_epc_section().