Re: [RFC v1 22/26] x86/tdx: Exclude Shared bit from __PHYSICAL_MASK

From: Kirill A. Shutemov
Date: Tue Apr 06 2021 - 11:54:43 EST


On Thu, Apr 01, 2021 at 01:13:16PM -0700, Dave Hansen wrote:
> > @@ -56,6 +61,9 @@ static void tdx_get_info(void)
> >
> > td_info.gpa_width = rcx & GENMASK(5, 0);
> > td_info.attributes = rdx;
> > +
> > + /* Exclude Shared bit from the __PHYSICAL_MASK */
> > + physical_mask &= ~tdx_shared_mask();
> > }
>
> I wish we had all of these 'physical_mask' manipulations in a single
> spot. Can we consolidate these instead of having TDX and SME poke at
> them individually?

SME has to do it very early -- from __startup_64() -- as it sets the bit
on all memory, except what used for communication. TDX can postpone as we
don't need any shared mapping in very early boot.

Basically, to make it done from the same place we would need to move TDX
enumeration earlier into boot. It's risky: everything is more fragile
there.

I would rather keep it as is. We should be fine as long as we only allow
to clear bits from the mask.

--
Kirill A. Shutemov