Re: [PATCHv2 23/29] x86/tdx: Add helper to convert memory between shared and private

Kirill A. Shutemov
2022-02-09T23:21:43Z

On Tue, Feb 08, 2022 at 01:12:45PM +0100, Borislav Petkov wrote:
> On Mon, Jan 24, 2022 at 06:02:09PM +0300, Kirill A. Shutemov wrote:
> > + if (ret)
> > + ret = -EIO;
> > +
> > + if (ret || !enc)
>
> Is the second case here after the "||" the conversion-to-shared where it
> only needs to notify with MapGPA and return?

Right. Memory accepting is required on the way to private.

I will rewrite and comment this code to make it more readable.

> > + return ret;
> > +
> > + /*
> > + * For shared->private conversion, accept the page using
> > + * TDX_ACCEPT_PAGE TDX module call.
> > + */
> > + while (start < end) {
> > + /* Try 2M page accept first if possible */
> > + if (!(start & ~PMD_MASK) && end - start >= PMD_SIZE &&
> > + !tdx_accept_page(start, PG_LEVEL_2M)) {
>
> What happens here if the module doesn't accept the page? No error
> reporting, no error handling, no warning, nada?

If it fails we fallback to 4k accept below.

We only report error if 4k accept fails.

--
Kirill A. Shutemov