Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/virt/tdx: Define TDX supported page sizes as macros

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>
Signed-off-by: Dave Hansen <dave.hansen@linux.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>
Link: https://lore.kernel.org/all/20231208170740.53979-2-dave.hansen%40intel.com

authored by

Kai Huang and committed by
Dave Hansen
d623704b 765a0542

+8 -3
+3 -3
arch/x86/coco/tdx/tdx-shared.c
··· 22 22 */ 23 23 switch (pg_level) { 24 24 case PG_LEVEL_4K: 25 - page_size = 0; 25 + page_size = TDX_PS_4K; 26 26 break; 27 27 case PG_LEVEL_2M: 28 - page_size = 1; 28 + page_size = TDX_PS_2M; 29 29 break; 30 30 case PG_LEVEL_1G: 31 - page_size = 2; 31 + page_size = TDX_PS_1G; 32 32 break; 33 33 default: 34 34 return 0;
+5
arch/x86/include/asm/shared/tdx.h
··· 55 55 (TDX_RDX | TDX_RBX | TDX_RSI | TDX_RDI | TDX_R8 | TDX_R9 | \ 56 56 TDX_R10 | TDX_R11 | TDX_R12 | TDX_R13 | TDX_R14 | TDX_R15) 57 57 58 + /* TDX supported page sizes from the TDX module ABI. */ 59 + #define TDX_PS_4K 0 60 + #define TDX_PS_2M 1 61 + #define TDX_PS_1G 2 62 + 58 63 #ifndef __ASSEMBLY__ 59 64 60 65 #include <linux/compiler_attributes.h>