X86 MCE: Prevent malicious guest access broken page again
authorKeir Fraser <keir@xen.org>
Fri, 30 Sep 2011 20:16:43 +0000 (21:16 +0100)
committerKeir Fraser <keir@xen.org>
Fri, 30 Sep 2011 20:16:43 +0000 (21:16 +0100)
To avoid recursive mce.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
Committed-by: Keir Fraser <keir@xen.org>
xen/arch/x86/cpu/mcheck/mce_intel.c
xen/common/page_alloc.c
xen/include/public/sysctl.h

index bf75f6714c8f3a6a845432c98feb0dc4d670e437..86191ac2d5ebe8543e8d1b604da38ec15a0a2e9e 100644 (file)
@@ -657,6 +657,8 @@ static void intel_memerr_dhandler(
     /* This is free page */
     if (status & PG_OFFLINE_OFFLINED)
         *result = MCER_RECOVERED;
+    else if (status & PG_OFFLINE_AGAIN)
+        *result = MCER_CONTINUE;
     else if (status & PG_OFFLINE_PENDING) {
         /* This page has owner */
         if (status & PG_OFFLINE_OWNED) {
index f38d1ff986eebedbd4cc595833b18f4323bcd67b..3ce34af4407e2e538d13970516539a6cd3a54eb4 100644 (file)
@@ -38,6 +38,7 @@
 #include <xen/tmem.h>
 #include <xen/tmem_xen.h>
 #include <public/sysctl.h>
+#include <public/sched.h>
 #include <asm/page.h>
 #include <asm/numa.h>
 #include <asm/flushtlb.h>
@@ -708,6 +709,19 @@ int offline_page(unsigned long mfn, int broken, uint32_t *status)
         return -EINVAL;
     }
 
+    /*
+     * NB. When broken page belong to guest, usually hypervisor will
+     * notify the guest to handle the broken page. However, hypervisor
+     * need to prevent malicious guest access the broken page again.
+     * Under such case, hypervisor shutdown guest, preventing recursive mce.
+     */
+    if ( (pg->count_info & PGC_broken) && (owner = page_get_owner(pg)) )
+    {
+        *status = PG_OFFLINE_AGAIN;
+        domain_shutdown(owner, SHUTDOWN_crash);
+        return 0;
+    }
+
     spin_lock(&heap_lock);
 
     old_info = mark_page_offline(pg, broken);
index c10a85d1f8a5921be90201a3c494d9a7679312c1..88648c428632b49fbfc9b59e3889b7e7522ab46b 100644 (file)
@@ -399,6 +399,7 @@ struct xen_sysctl_page_offline_op {
 #define PG_OFFLINE_OFFLINED  (0x1UL << 1)
 #define PG_OFFLINE_PENDING   (0x1UL << 2)
 #define PG_OFFLINE_FAILED    (0x1UL << 3)
+#define PG_OFFLINE_AGAIN     (0x1UL << 4)
 
 #define PG_ONLINE_FAILED     PG_OFFLINE_FAILED
 #define PG_ONLINE_ONLINED    PG_OFFLINE_OFFLINED