lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240822095122.736522-1-kirill.shutemov@linux.intel.com>
Date: Thu, 22 Aug 2024 12:51:22 +0300
From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
To: Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	Borislav Petkov <bp@...en8.de>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	x86@...nel.org,
	"H. Peter Anvin" <hpa@...or.com>
Cc: Kevin Loughlin <kevinloughlin@...gle.com>,
	linux-kernel@...r.kernel.org,
	"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
	Rick Edgecombe <rick.p.edgecombe@...el.com>,
	Isaku Yamahata <isaku.yamahata@...el.com>
Subject: [PATCH] x86/tdx: Fix crash on kexec with CONFIG_EISA

TDX has concept of private and shared memory. Private memory is
protected from VMM and shared is used for communication between guest
and host. Shared memory is mapped into guest with shared bit set in the
page table entry.

Normally memory got converted from private to shared with MapGPA
TDVMCALL before it got accessed. However, what is supposed to happen
when private memory is accessed via shared mapping is not defined.
It is left up to the VMM to decide.

This is problematic. Currently, KVM implicitly converts memory to shared
and removes the page from the secure EPT, so subsequent access via private
mapping leads to a crash.

This issue causes real problems:

1. If the kernel is compiled with EISA support, it will attempt to probe
   EISA by reading 4 bytes from the 0x0FFFD9 address (see eisa_bus_probe()).
   The kernel treats this read as MMIO and accesses this memory via
   shared mapping as we do for MMIO.

   KVM converts memory to shared upon such access.

2. The same memory range (0xF0000-0x100000) is scanned to look for the MP
   table (see mpparse_find_mptable()). However, this is not MMIO and it
   is accessed via private mapping.

   This will cause a crash if the memory is not private.

During normal boot, the kernel scans for SMP information before probing
for EISA, and it boots fine. However, the memory becomes shared and causes
issues on kexec when the second kernel attempts to scan for SMP information.

TDX behaviour on access of private memory via shared mapping has to be
clarified to avoid such crashes in the future. It takes time.

In meanwhile, avoid probing EISA for TDX guest.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
Cc: Kevin Loughlin <kevinloughlin@...gle.com>
Cc: Rick Edgecombe <rick.p.edgecombe@...el.com>
Cc: Isaku Yamahata <isaku.yamahata@...el.com>
---
 arch/x86/kernel/eisa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/eisa.c b/arch/x86/kernel/eisa.c
index 53935b4d62e3..678244d178b6 100644
--- a/arch/x86/kernel/eisa.c
+++ b/arch/x86/kernel/eisa.c
@@ -13,7 +13,9 @@ static __init int eisa_bus_probe(void)
 {
 	void __iomem *p;
 
-	if ((xen_pv_domain() && !xen_initial_domain()) || cc_platform_has(CC_ATTR_GUEST_SEV_SNP))
+	if ((xen_pv_domain() && !xen_initial_domain()) ||
+	    cc_platform_has(CC_ATTR_GUEST_SEV_SNP) ||
+	    cpu_feature_enabled(X86_FEATURE_TDX_GUEST))
 		return 0;
 
 	p = ioremap(0x0FFFD9, 4);
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ