Message ID | ca5d11744de083812ba121f1b8cc0576a8691342.1678111292.git.kai.huang@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | TDX host kernel support | expand |
On 06.03.23 15:13, Kai Huang wrote: > TDX supports 4K, 2M and 1G page sizes. The corresponding values are > defined by the TDX module spec and used as TDX module ABI. Currently, > they are used in try_accept_one() when the TDX guest tries to accept a > page. However currently try_accept_one() uses hard-coded magic values. > > Define TDX supported page sizes as macros and get rid of the hard-coded > values in try_accept_one(). TDX host support will need to use them too. > > Signed-off-by: Kai Huang <kai.huang@intel.com> > Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> > Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com> > --- Reviewed-by: David Hildenbrand <david@redhat.com>
On Thu, 2023-03-16 at 13:37 +0100, David Hildenbrand wrote: > On 06.03.23 15:13, Kai Huang wrote: > > TDX supports 4K, 2M and 1G page sizes. The corresponding values are > > defined by the TDX module spec and used as TDX module ABI. Currently, > > they are used in try_accept_one() when the TDX guest tries to accept a > > page. However currently try_accept_one() uses hard-coded magic values. > > > > Define TDX supported page sizes as macros and get rid of the hard-coded > > values in try_accept_one(). TDX host support will need to use them too. > > > > Signed-off-by: Kai Huang <kai.huang@intel.com> > > Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> > > Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com> > > --- > > Reviewed-by: David Hildenbrand <david@redhat.com> > > Thanks!
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index b593009b30ab..e27c3cd97fcb 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -777,13 +777,13 @@ static bool try_accept_one(phys_addr_t *start, unsigned long len, */ switch (pg_level) { case PG_LEVEL_4K: - page_size = 0; + page_size = TDX_PS_4K; break; case PG_LEVEL_2M: - page_size = 1; + page_size = TDX_PS_2M; break; case PG_LEVEL_1G: - page_size = 2; + page_size = TDX_PS_1G; break; default: return false; diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h index 28d889c9aa16..25fd6070dc0b 100644 --- a/arch/x86/include/asm/tdx.h +++ b/arch/x86/include/asm/tdx.h @@ -20,6 +20,11 @@ #ifndef __ASSEMBLY__ +/* TDX supported page sizes from the TDX module ABI. */ +#define TDX_PS_4K 0 +#define TDX_PS_2M 1 +#define TDX_PS_1G 2 + /* * Used to gather the output registers values of the TDCALL and SEAMCALL * instructions when requesting services from the TDX module.