Re: [PATCH v3 3/4] virt: tdx-guest: Use a variable to store the Quote buffer size
From: Peter Fang
Date: Wed Sep 16 2026 - 05:46:04 EST
On Thu, Sep 03, 2026 at 06:28:12PM -0700, Peter Fang wrote:
> On Thu, Sep 03, 2026 at 01:59:25PM +0800, Xiaoyao Li wrote:
> > On 9/3/2026 7:15 AM, Peter Fang wrote:
> > > You are also dropping PAGE_ALIGN() in alloc and free calls. You can
> > > mention it in commit log.
> >
> > I think it's better to keep the PAGE_ALIGN() when assign quote_data_len,
> > although GET_QUOTE_BUF_SIZE is aligned already. This makes it super clear
> > we want to page size align the buffer.
> >
> > And in next patch, we can make it
> >
> > quote_data_len = PAGE_ALIGN(get_quote_buf_size());
>
> Hmm... Looking at this again actually makes me think it could be
> reworked a bit. There's a discrepancy in alloc_quote_buf() if for
> whatever reason @len is not page aligned. alloc_pages_exact() rounds it
> up internally but set_memory_decrypted() rounds it *down*, so we'd end
> up with a useless page at the end...
>
> What if alloc_quote_buf() took a @npages instead? Then the expectations
> would be pretty clear:
I took your suggestion in v4 [1]. The @npages approach was more work
than expected and made the series bigger. This is simpler.
[1] https://lore.kernel.org/all/20260915092632.2822169-5-peter.fang@xxxxxxxxx/
>
>