From: "Kirill A. Shutemov" <kirill.shute...@linux.intel.com>
tdx_shared_mask() returns the mask that has to be set in page table entry to make page shared with VMM. Signed-off-by: Kirill A. Shutemov <kirill.shute...@linux.intel.com> Reviewed-by: Andi Kleen <a...@linux.intel.com> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppusw...@linux.intel.com> --- arch/x86/Kconfig | 1 + arch/x86/include/asm/tdx.h | 1 + arch/x86/kernel/tdx.c | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 8fa654d61ac2..f10a00c4ad7f 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -875,6 +875,7 @@ config INTEL_TDX_GUEST select PARAVIRT_XL select X86_X2APIC select SECURITY_LOCKDOWN_LSM + select X86_MEM_ENCRYPT_COMMON help Provide support for running in a trusted domain on Intel processors equipped with Trusted Domain eXtenstions. TDX is an new Intel diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h index b46ae140e39b..9bbfe6520ea4 100644 --- a/arch/x86/include/asm/tdx.h +++ b/arch/x86/include/asm/tdx.h @@ -104,5 +104,6 @@ long tdx_kvm_hypercall3(unsigned int nr, unsigned long p1, unsigned long p2, long tdx_kvm_hypercall4(unsigned int nr, unsigned long p1, unsigned long p2, unsigned long p3, unsigned long p4); +phys_addr_t tdx_shared_mask(void); #endif #endif /* _ASM_X86_TDX_H */ diff --git a/arch/x86/kernel/tdx.c b/arch/x86/kernel/tdx.c index ae37498df981..9681f4a0b4e0 100644 --- a/arch/x86/kernel/tdx.c +++ b/arch/x86/kernel/tdx.c @@ -41,6 +41,11 @@ bool is_tdx_guest(void) } EXPORT_SYMBOL_GPL(is_tdx_guest); +phys_addr_t tdx_shared_mask(void) +{ + return 1ULL << (td_info.gpa_width - 1); +} + static void tdx_get_info(void) { register long rcx asm("rcx"); @@ -56,6 +61,9 @@ static void tdx_get_info(void) td_info.gpa_width = rcx & GENMASK(5, 0); td_info.attributes = rdx; + + /* Exclude Shared bit from the __PHYSICAL_MASK */ + physical_mask &= ~tdx_shared_mask(); } static __cpuidle void tdx_halt(void) -- 2.25.1