WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [MINIOS] Fix the pagefault handler to detect recursive f

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [MINIOS] Fix the pagefault handler to detect recursive faults.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 May 2006 18:26:10 +0000
Delivery-date: Tue, 16 May 2006 11:27:46 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID aab3cd33d2ba65340d355ffbfc859ef6e7b64df3
# Parent  3dca5b4add2be8b6da2052aeddffc497920b9ce1
[MINIOS] Fix the pagefault handler to detect recursive faults.
Signed-off-by: Grzegorz Milos <gm281@xxxxxxxxx>
---
 extras/mini-os/console/console.c |   10 ++++++++--
 extras/mini-os/traps.c           |   15 +++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff -r 3dca5b4add2b -r aab3cd33d2ba extras/mini-os/console/console.c
--- a/extras/mini-os/console/console.c  Tue May 16 14:07:56 2006 +0100
+++ b/extras/mini-os/console/console.c  Tue May 16 16:34:27 2006 +0100
@@ -45,6 +45,10 @@
 #include <xen/io/console.h>
 
 
+/* Copies all print output to the Xen emergency console apart
+   of standard dom0 handled console */
+#define USE_XEN_CONSOLE
+
 /* Low level functions defined in xencons_ring.c */
 extern int xencons_ring_init(void);
 extern int xencons_ring_send(const char *data, unsigned len);
@@ -117,7 +121,9 @@ void print(int direct, const char *fmt, 
         (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(buf), buf);
         return;
     } else {
-        if(!console_initialised)
+#ifndef USE_XEN_CONSOLE
+    if(!console_initialised)
+#endif    
             (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(buf), buf);
         
         console_print(buf, strlen(buf));
@@ -128,7 +134,7 @@ void printk(const char *fmt, ...)
 {
     va_list       args;
     va_start(args, fmt);
-    print(1, fmt, args);
+    print(0, fmt, args);
     va_end(args);        
 }
 
diff -r 3dca5b4add2b -r aab3cd33d2ba extras/mini-os/traps.c
--- a/extras/mini-os/traps.c    Tue May 16 14:07:56 2006 +0100
+++ b/extras/mini-os/traps.c    Tue May 16 16:34:27 2006 +0100
@@ -120,9 +120,21 @@ void page_walk(unsigned long virt_addres
 #define read_cr2() \
         (HYPERVISOR_shared_info->vcpu_info[smp_processor_id()].arch.cr2)
 
+static int handling_pg_fault = 0;
+
 void do_page_fault(struct pt_regs *regs, unsigned long error_code)
 {
     unsigned long addr = read_cr2();
+    /* If we are already handling a page fault, and got another one
+       that means we faulted in pagetable walk. Continuing here would cause
+       a recursive fault */       
+    if(handling_pg_fault) 
+    {
+        printk("Page fault in pagetable walk (access to invalid memory?).\n"); 
+        do_exit();
+    }
+    handling_pg_fault = 1;
+
 #if defined(__x86_64__)
     printk("Page fault at linear address %p, rip %p, code %lx\n",
            addr, regs->rip, error_code);
@@ -130,9 +142,12 @@ void do_page_fault(struct pt_regs *regs,
     printk("Page fault at linear address %p, eip %p, code %lx\n",
            addr, regs->eip, error_code);
 #endif
+
     dump_regs(regs);
     page_walk(addr);
     do_exit();
+    /* We should never get here ... but still */
+    handling_pg_fault = 0;
 }
 
 void do_general_protection(struct pt_regs *regs, long error_code)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [MINIOS] Fix the pagefault handler to detect recursive faults., Xen patchbot-unstable <=