[tip:,x86/sev] x86/fault: Dump RMP table information when RMP page faults occur

Message ID 170663196762.398.11962253377329116323.tip-bot2@tip-bot2
State New
Headers
Series [tip:,x86/sev] x86/fault: Dump RMP table information when RMP page faults occur |

Commit Message

tip-bot2 for Thomas Gleixner Jan. 30, 2024, 4:26 p.m. UTC
  The following commit has been merged into the x86/sev branch of tip:

Commit-ID:     e8bbd303d7de3fb32be1434a5d5ce3e1cb182018
Gitweb:        https://git.kernel.org/tip/e8bbd303d7de3fb32be1434a5d5ce3e1cb182018
Author:        Michael Roth <michael.roth@amd.com>
AuthorDate:    Thu, 25 Jan 2024 22:11:09 -06:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 29 Jan 2024 17:27:25 +01:00

x86/fault: Dump RMP table information when RMP page faults occur

RMP faults on kernel addresses are fatal and should never happen in
practice. They indicate a bug in the host kernel somewhere. Userspace
RMP faults shouldn't occur either, since even for VMs the memory used
for private pages is handled by guest_memfd and by design is not
mappable by userspace.

Dump RMP table information about the PFN corresponding to the faulting
HVA to help diagnose any issues of this sort when show_fault_oops() is
triggered by an RMP fault.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20240126041126.1927228-10-michael.roth@amd.com
---
 arch/x86/mm/fault.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Patch

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 8805e2e..859adcd 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -34,6 +34,7 @@ 
 #include <asm/kvm_para.h>		/* kvm_handle_async_pf		*/
 #include <asm/vdso.h>			/* fixup_vdso_exception()	*/
 #include <asm/irq_stack.h>
+#include <asm/sev.h>			/* snp_dump_hva_rmpentry()	*/
 
 #define CREATE_TRACE_POINTS
 #include <asm/trace/exceptions.h>
@@ -580,6 +581,9 @@  show_fault_oops(struct pt_regs *regs, unsigned long error_code, unsigned long ad
 	}
 
 	dump_pagetable(address);
+
+	if (error_code & X86_PF_RMP)
+		snp_dump_hva_rmpentry(address);
 }
 
 static noinline void