[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cff391af-9523-46d6-97c8-ac9917097d96@intel.com>
Date: Tue, 28 Jun 2022 10:03:57 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: Xiaoyao Li <xiaoyao.li@...el.com>, Kai Huang <kai.huang@...el.com>,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Cc: seanjc@...gle.com, pbonzini@...hat.com, len.brown@...el.com,
tony.luck@...el.com, rafael.j.wysocki@...el.com,
reinette.chatre@...el.com, dan.j.williams@...el.com,
peterz@...radead.org, ak@...ux.intel.com,
kirill.shutemov@...ux.intel.com,
sathyanarayanan.kuppuswamy@...ux.intel.com,
isaku.yamahata@...el.com
Subject: Re: [PATCH v5 15/22] x86/virt/tdx: Allocate and set up PAMTs for
TDMRs
On 6/27/22 17:48, Xiaoyao Li wrote:
>>
>> I meant this:
>>
>> + switch (level) {
>> + case PG_LEVEL_4K:
>> + page_size = 0;
>> + break;
>>
>> Because TDX_PG_4K==page_size==0, and for this:
>>
>> + case PG_LEVEL_2M:
>> + page_size = 1;
>
> here we can just do
>
> page_size = level - 1;
>
> or
>
> tdx_page_level = level - 1;
>
> yes, TDX's page level definition is one level smaller of Linux's
> definition.
Uhh. No.
The 'page_size' is in the kernel/TDX-module ABI. It can't change.
PG_LEVEL_* is just some random internal Linux enum. It *CAN* change.
There's a *MASSIVE* difference between the two. What you suggest will
probably actually work. But, it will work accidentally and may break in
horribly confusing ways in the future.
It's the difference between hacking something together and actually
writing code that will keep working for a long time. Please, take a
minute and reflect on this. Please.
Powered by blists - more mailing lists