Re: [PATCHv12 9/9] x86/tdx: Add unaccepted memory support

From: Kirill A. Shutemov
Date: Wed May 31 2023 - 08:25:26 EST


On Tue, May 30, 2023 at 05:58:37PM -0700, Isaku Yamahata wrote:
> On Fri, May 19, 2023 at 02:14:34AM +0300,
> "Kirill A. Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx> wrote:
>
> > Hookup TDX-specific code to accept memory.
> >
> > Accepting the memory is the same process as converting memory from
> > shared to private: kernel notifies VMM with MAP_GPA hypercall and then
> > accept pages with ACCEPT_PAGE module call.
> >
> > THE implementation in core kernel uses tdx_enc_status_changed(). It
> > already used for converting memory to shared and back for I/O
> > transactions.
>
> Because unaccepted memory reported in e820 means private[1], MAP_GPA isn't
> needed to accept memory. (Or are you seeing TDX KVM/qemu issue?)
>
> [1]TDX Virtual Firmware Design Guide.
> 7.2.1 Memroy Type in TD Resrouce HOB. Table 7-1: Mmeory Typein TD Resource HOB.

Okay. Fair enough. We can avoid a MAP_GPA and cut cost of memory
acceptance.

Here's an updated patch: