i386 wp patch -- tester needed

Richard Henderson (rth@cygnus.com)
Sat, 16 Aug 1997 23:41:27 -0700


It occured to me with the do_page_fault thread that this wp
test could be done cleaner with the exception handling code.

I'd be grateful if someone that owns a 386/486 would test
this patch to make sure I havn't done anything foolish.

r~

--- arch/i386/mm/fault.c.orig Sat Aug 16 23:14:42 1997
+++ arch/i386/mm/fault.c Sat Aug 16 23:18:20 1997
@@ -186,16 +186,9 @@ bad_area:
*
* First we check if it was the bootup rw-test, though..
*/
- if (wp_works_ok < 0 && address == 0xc0000000 && (error_code & 1)) {
- wp_works_ok = 1;
- pg0[0] = pte_val(mk_pte(0, PAGE_SHARED));
- flush_tlb();
- goto out;
- }
- if (address < PAGE_SIZE) {
+ if (address < PAGE_SIZE)
printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
- pg0[0] = pte_val(mk_pte(0, PAGE_SHARED));
- } else
+ else
printk(KERN_ALERT "Unable to handle kernel paging request");
printk(" at virtual address %08lx\n",address);
__asm__("movl %%cr3,%0" : "=r" (page));
--- arch/i386/mm/init.c.orig Sat Aug 16 23:14:48 1997
+++ arch/i386/mm/init.c Sat Aug 16 23:39:34 1997
@@ -347,20 +347,15 @@ __initfunc(void mem_init(unsigned long s
pg0[0] = pte_val(mk_pte(PAGE_OFFSET, PAGE_READONLY));
local_flush_tlb();
current->mm->mmap->vm_start += PAGE_SIZE;
- __asm__ __volatile__(
- "movb %0,%1 ; movb %1,%0"
- :"=m" (*(char *) __va(0)),
- "=q" (tmp_reg)
- :/* no inputs */
- :"memory");
+
+ tmp_reg = *(char *)__va(0);
+ wp_works_ok = (__put_user(tmp_reg, (char *)__va(0)) != 0);
+
pg0[0] = old;
local_flush_tlb();
current->mm->mmap->vm_start -= PAGE_SIZE;
- if (wp_works_ok < 0) {
- wp_works_ok = 0;
- printk("No.\n");
- } else
- printk("Ok.\n");
+
+ printk(wp_works_ok ? "Ok.\n" : "No.\n");
}
return;
}