RE: [PATCH v10 2/2] x86/tdx: Support vmalloc() for tdx_enc_status_changed()

From: Dexuan Cui
Date: Tue Sep 05 2023 - 14:49:44 EST


> From: Edgecombe, Rick P <rick.p.edgecombe@xxxxxxxxx>
> Sent: Tuesday, September 5, 2023 9:25 AM
> [...]
> On Fri, 2023-08-11 at 14:48 -0700, Dexuan Cui wrote:
> > When a TDX guest runs on Hyper-V, the hv_netvsc driver's
> > netvsc_init_buf()
> > allocates buffers using vzalloc(), and needs to share the buffers
> > with the
> > host OS by calling set_memory_decrypted(), which is not working for
> > vmalloc() yet. Add the support by handling the pages one by one.
> >
> > Co-developed-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
> > Reviewed-by: Michael Kelley <mikelley@xxxxxxxxxxxxx>
> > Reviewed-by: Kuppuswamy Sathyanarayanan
> > <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
> > Signed-off-by: Dexuan Cui <decui@xxxxxxxxxxxxx>
> > ---
> >  arch/x86/coco/tdx/tdx.c | 36 ++++++++++++++++++++++++++++++------
> >  1 file changed, 30 insertions(+), 6 deletions(-)
>
> Reviewed-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
Thanks!

> Only small comment, it is possible to have huge vmalloc's now, which
> would mean this would do 512 TDVMCALL_MAP_GPA calls instead of 1 when
> encountering a huge vmalloc mapping. If this used lookup_address()
> directly instead of slow_virt_to_phys(), it could catch this case. I
> don't think there are any cases of huge vmallocs today that would get
> passed into set_memory_en/decrypted(), so would only be future
> proofing.
Thanks for the suggestion! So I think let's keep the code as-is for
simplicity. We can enhance the code in future when it's necessary.