Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jan 2008 06:43:46 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 132677 for review
Message-ID:  <200801070643.m076hknC015268@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=132677

Change 132677 by kmacy@pandemonium:kmacy:xen31 on 2008/01/07 06:42:48

	map kernel text R/O
	re-map R/W in kdb_enter

Affected files ...

.. //depot/projects/xen31/sys/i386/xen/xen_machdep.c#14 edit
.. //depot/projects/xen31/sys/kern/subr_kdb.c#3 edit

Differences ...

==== //depot/projects/xen31/sys/i386/xen/xen_machdep.c#14 (text+ko) ====

@@ -691,7 +691,7 @@
 void
 initvalues(start_info_t *startinfo)
 { 
-	int i, l3_pages, l2_pages, l1_pages, offset;
+	int l3_pages, l2_pages, l1_pages, offset;
 	vm_offset_t cur_space;
 	struct physdev_set_iopl set_iopl;
 	
@@ -705,7 +705,8 @@
 	pd_entry_t *IdlePDPTnew, *IdlePTDnew;
 #else
 	vm_paddr_t pdir_shadow_ma;
-#endif	
+#endif
+	unsigned long i;
 
 #ifdef WRITABLE_PAGETABLES
 	printk("using writable pagetables\n");
@@ -934,6 +935,14 @@
 		xen_flush_queue();
 	}
 #endif
+	/*
+	 * re-map kernel text read-only
+	 *
+	 */
+	for (i = (((vm_offset_t)&btext) & ~PAGE_MASK);
+	     i < (((vm_offset_t)&etext) & ~PAGE_MASK); i += PAGE_SIZE)
+		PT_SET_MA(i, xpmap_ptom(VTOP(i)) | PG_V | PG_A);
+	
 	printk("#7\n");
 	physfree = VTOP(cur_space);
 	init_first = physfree >> PAGE_SHIFT;

==== //depot/projects/xen31/sys/kern/subr_kdb.c#3 (text+ko) ====

@@ -304,10 +304,22 @@
  * string than 'msg', and is relied upon by DDB scripting to identify the
  * reason for entering the debugger so that the right script can be run.
  */
+#ifdef XEN
+#include <machine/cpu.h> /* needed for btext/etext */
+#endif
 void
 kdb_enter(const char *why, const char *msg)
 {
-
+#ifdef XEN
+	unsigned long i;
+	
+	/*
+	 * re-map kernel text R/W
+	 */
+	for (i = (((vm_offset_t)&btext) & ~PAGE_MASK);
+	     i < (((vm_offset_t)&etext) & ~PAGE_MASK); i += PAGE_SIZE)
+		PT_SET_MA(i, xpmap_ptom(VTOP(i)) | PG_V | PG_A | PG_RW);	
+#endif	
 	if (kdb_dbbe != NULL && kdb_active == 0) {
 		if (msg != NULL)
 			printf("KDB: enter: %s\n", msg);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801070643.m076hknC015268>