[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0835f21a-c0b1-429c-a107-d7d0a2838194@redhat.com>
Date: Wed, 27 Nov 2024 19:15:59 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>,
"Hansen, Dave" <dave.hansen@...el.com>, "seanjc@...gle.com"
<seanjc@...gle.com>
Cc: "yuan.yao@...el.com" <yuan.yao@...el.com>,
"Huang, Kai" <kai.huang@...el.com>, "x86@...nel.org" <x86@...nel.org>,
"binbin.wu@...ux.intel.com" <binbin.wu@...ux.intel.com>,
"Li, Xiaoyao" <xiaoyao.li@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Zhao, Yan Y" <yan.y.zhao@...el.com>,
"tony.lindgren@...ux.intel.com" <tony.lindgren@...ux.intel.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"Yamahata, Isaku" <isaku.yamahata@...el.com>,
"isaku.yamahata@...il.com" <isaku.yamahata@...il.com>,
"Hunter, Adrian" <adrian.hunter@...el.com>
Subject: Re: [RFC PATCH 1/6] x86/virt/tdx: Add SEAMCALL wrappers for TDX KeyID
management
On 11/23/24 03:06, Edgecombe, Rick P wrote:
> On Fri, 2024-11-22 at 16:08 -0800, Dave Hansen wrote:
>> On 11/22/24 15:55, Sean Christopherson wrote:
>>> On Fri, Nov 22, 2024, Dave Hansen wrote:
>>> I don't know the full context, but working with "struct page" is a pain when every
>>> user just wants the physical address. KVM SVM had a few cases where pointers were
>>> tracked as "struct page", and it was generally unpleasant to read and work with.
>>
>> I'm not super convinced. page_to_phys(foo) is all it takes
>>
>>> I also don't like conflating the kernel's "struct page" with the architecture's
>>> definition of a 4KiB page.
>>
>> That's fair, although it's pervasively conflated across our entire
>> codebase. But 'struct page' is substantially better than a hpa_t,
>> phys_addr_t or u64 that can store a full 64-bits of address. Those
>> conflate a physical address with a physical page, which is *FAR* worse.
>
> In the case of tdh_mem_page_aug(), etc the caller only has a kvm_pfn_t passed
> from a TDP MMU callback, for the page to be mapped in the guest TD. It is
> probably not nice to assume that this kvm_pfn_t will have a struct page. So we
> shouldn't always use struct pages for the SEAMCALL wrappers in any case.
>
> What if we just move these members from hpa_t to pfn_t? It keeps us off struct
> page, but addresses some of Dave's concerns about hpa_t looking like a specific
> address.
For tdr I agree with Dave that you probably want a struct which stores
the struct page*. Currently the code is using __get_free_page(), but
it's a small change to have it use alloc_page() instead, and
__free_page() instead of free_page().
The only difference on the arch/x86/virt/ side is a bunch of added
page_to_phys().
Anyhow, whatever you post I'll take care of adjusting in the KVM patches.
Paolo
Powered by blists - more mailing lists