lkml.org 
[lkml]   [2020]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v3 24/75] x86/boot/compressed/64: Unmap GHCB page before booting the kernel
On Tue, Apr 28, 2020 at 05:16:34PM +0200, Joerg Roedel wrote:
> @@ -302,9 +313,13 @@ void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code)
> * - User faults
> * - Reserved bits set
> */
> - if (error_code & (X86_PF_PROT | X86_PF_USER | X86_PF_RSVD)) {
> + if (ghcb_fault ||
> + error_code & (X86_PF_PROT | X86_PF_USER | X86_PF_RSVD)) {
> /* Print some information for debugging */
> - error_putstr("Unexpected page-fault:");
> + if (ghcb_fault)
> + error_putstr("Page-fault on GHCB page:");
> + else
> + error_putstr("Unexpected page-fault:");

You could carve out the info dumping into a separate function to
unclutter this if-statement (diff ontop):

diff --git a/arch/x86/boot/compressed/ident_map_64.c b/arch/x86/boot/compressed/ident_map_64.c
index d3771d455249..c1979fc0f853 100644
--- a/arch/x86/boot/compressed/ident_map_64.c
+++ b/arch/x86/boot/compressed/ident_map_64.c
@@ -296,6 +296,22 @@ int set_page_non_present(unsigned long address)
return set_clr_page_flags(&mapping_info, address, 0, _PAGE_PRESENT);
}

+static void do_pf_error(const char *msg, unsigned long error_code,
+ unsigned long address, unsigned long ip)
+{
+ error_putstr(msg);
+
+ error_putstr("\nError Code: ");
+ error_puthex(error_code);
+ error_putstr("\nCR2: 0x");
+ error_puthex(address);
+ error_putstr("\nRIP relative to _head: 0x");
+ error_puthex(ip - (unsigned long)_head);
+ error_putstr("\n");
+
+ error("Stopping.\n");
+}
+
void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code)
{
unsigned long address = native_read_cr2();
@@ -309,27 +325,15 @@ void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code)

/*
* Check for unexpected error codes. Unexpected are:
+ * - Faults on the GHCB page due to unexpected #VCs
* - Faults on present pages
* - User faults
* - Reserved bits set
*/
- if (ghcb_fault ||
- error_code & (X86_PF_PROT | X86_PF_USER | X86_PF_RSVD)) {
- /* Print some information for debugging */
- if (ghcb_fault)
- error_putstr("Page-fault on GHCB page:");
- else
- error_putstr("Unexpected page-fault:");
- error_putstr("\nError Code: ");
- error_puthex(error_code);
- error_putstr("\nCR2: 0x");
- error_puthex(address);
- error_putstr("\nRIP relative to _head: 0x");
- error_puthex(regs->ip - (unsigned long)_head);
- error_putstr("\n");
-
- error("Stopping.\n");
- }
+ if (ghcb_fault)
+ do_pf_error("Page-fault on GHCB page:", error_code, address, regs->ip);
+ else if (error_code & (X86_PF_PROT | X86_PF_USER | X86_PF_RSVD))
+ do_pf_error("Unexpected page-fault:", error_code, address, regs->ip);

/*
* Error code is sane - now identity map the 2M region around
--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

\
 
 \ /
  Last update: 2020-05-13 13:14    [W:0.844 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site