Messages in this thread | | | Date | Tue, 28 Jun 2022 10:03:57 -0700 | Subject | Re: [PATCH v5 15/22] x86/virt/tdx: Allocate and set up PAMTs for TDMRs | From | Dave Hansen <> |
| |
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.
| |