patch-2.3.23 linux/arch/i386/mm/fault.c

Next file: linux/arch/i386/mm/init.c
Previous file: linux/arch/i386/mm/bigmem.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.22/linux/arch/i386/mm/fault.c linux/arch/i386/mm/fault.c
@@ -76,6 +76,31 @@
 	return 0;
 }
 
+static inline void handle_wp_test (void)
+{
+	const unsigned long vaddr = PAGE_OFFSET;
+	pgd_t *pgd;
+	pmd_t *pmd;
+	pte_t *pte;
+
+	/*
+	 * make it read/writable temporarily, so that the fault
+	 * can be handled.
+	 */
+	pgd = swapper_pg_dir + __pgd_offset(vaddr);
+	pmd = pmd_offset(pgd, vaddr);
+	pte = pte_offset(pmd, vaddr);
+	*pte = mk_pte_phys(0, PAGE_KERNEL);
+	local_flush_tlb();
+
+	boot_cpu_data.wp_works_ok = 1;
+	/*
+	 * Beware: Black magic here. The printk is needed here to flush
+	 * CPU state on certain buggy processors.
+	 */
+	printk("Ok");
+}
+
 asmlinkage void do_invalid_op(struct pt_regs *, unsigned long);
 extern unsigned long idt;
 
@@ -226,15 +251,8 @@
  * First we check if it was the bootup rw-test, though..
  */
 	if (boot_cpu_data.wp_works_ok < 0 &&
-	    address == PAGE_OFFSET && (error_code & 1)) {
-		boot_cpu_data.wp_works_ok = 1;
-		pg0[0] = pte_val(mk_pte(PAGE_OFFSET, PAGE_KERNEL));
-		local_flush_tlb();
-		/*
-		 * Beware: Black magic here. The printk is needed here to flush
-		 * CPU state on certain buggy processors.
-		 */
-		printk("Ok");
+			address == PAGE_OFFSET && (error_code & 1)) {
+		handle_wp_test();
 		return;
 	}
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)