x86/boot/compressed/64: Unmap GHCB page before booting the kernel
[linux-2.6-microblaze.git] / arch / x86 / boot / compressed / sev-es.c
index fa62af7..1e1fab5 100644 (file)
@@ -121,6 +121,20 @@ void sev_es_shutdown_ghcb(void)
         */
        if (set_page_encrypted((unsigned long)&boot_ghcb_page))
                error("Can't map GHCB page encrypted");
+
+       /*
+        * GHCB page is mapped encrypted again and flushed from the cache.
+        * Mark it non-present now to catch bugs when #VC exceptions trigger
+        * after this point.
+        */
+       if (set_page_non_present((unsigned long)&boot_ghcb_page))
+               error("Can't unmap GHCB page");
+}
+
+bool sev_es_check_ghcb_fault(unsigned long address)
+{
+       /* Check whether the fault was on the GHCB page */
+       return ((address & PAGE_MASK) == (unsigned long)&boot_ghcb_page);
 }
 
 void do_boot_stage2_vc(struct pt_regs *regs, unsigned long exit_code)