x86/fault: Dump RMP table information when RMP page faults occur
authorMichael Roth <michael.roth@amd.com>
Fri, 26 Jan 2024 04:11:09 +0000 (22:11 -0600)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 29 Jan 2024 16:27:25 +0000 (17:27 +0100)
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

index 8805e2e20df6ee5b68855d7a1f36d576194d11ad..859adcd123c9c89214fb180540b1eceb53751127 100644 (file)
@@ -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