vm fault code handling
Convert arch/sparc/mm/fault.c to symbolic fault codes, default to minor faults for unrecognized fault codes. Also treat VM_FAULT_OOM similarly to VM_FAULT_SIGBUS in force_user_fault(), thereby fixing a latent bug.
Index: sparc32-2.6.10-rc3/arch/sparc/mm/fault.c
=================================--- sparc32-2.6.10-rc3.orig/arch/sparc/mm/fault.c 2004-10-07 04:01:27.000000000 -0700
+++ sparc32-2.6.10-rc3/arch/sparc/mm/fault.c 2004-12-21 08:10:56.962777738 -0800
@@ -294,16 +294,17 @@
* the fault.
*/
switch (handle_mm_fault(mm, vma, address, write)) {
- case 1:
- current->min_flt++;
- break;
- case 2:
+ case VM_FAULT_SIGBUS:
+ goto do_sigbus;
+ case VM_FAULT_OOM:
+ goto out_of_memory;
+ case VM_FAULT_MAJOR:
current->maj_flt++;
break;
- case 0:
- goto do_sigbus;
+ case VM_FAULT_MINOR:
default:
- goto out_of_memory;
+ current->min_flt++;
+ break;
}
up_read(&mm->mmap_sem);
return;
@@ -535,8 +536,11 @@
if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
goto bad_area;
}
- if (!handle_mm_fault(mm, vma, address, write))
+ switch (handle_mm_fault(mm, vma, address, write)) {
+ case VM_FAULT_SIGBUS:
+ case VM_FAULT_OOM:
goto do_sigbus;
+ }
up_read(&mm->mmap_sem);
return;
bad_area:
Quoted 5 lines · William Lee Irwin III
Convert
arch/sparc/mm/fault.cto symbolic fault codes, default to minor faults for unrecognized fault codes. Also treatVM_FAULT_OOMsimilarly toVM_FAULT_SIGBUSinforce_user_fault(), thereby fixing a latent bug.[ ... snip patch ... ]
Hi.
Here's a slightly modified version of that patch which makes the sparc32 code more closely match the sparc64 code by setting the default branch of the case statement to BUG(). The rest of the patch matched what was posted above.
Art Haas
=== arch/sparc/mm/fault.c 1.19 vs edited ==--- 1.19/arch/sparc/mm/fault.c 2004-07-13 07:56:23 -05:00
+++ edited/arch/sparc/mm/fault.c 2004-12-22 17:24:37 -06:00
@@ -294,16 +294,18 @@
* the fault.
*/
switch (handle_mm_fault(mm, vma, address, write)) {
- case 1:
- current->min_flt++;
- break;
- case 2:
+ case VM_FAULT_SIGBUS:
+ goto do_sigbus;
+ case VM_FAULT_OOM:
+ goto out_of_memory;
+ case VM_FAULT_MAJOR:
current->maj_flt++;
break;
- case 0:
- goto do_sigbus;
+ case VM_FAULT_MINOR:
+ current->min_flt++;
+ break;
default:
- goto out_of_memory;
+ BUG();
}
up_read(&mm->mmap_sem);
return;
@@ -535,8 +537,11 @@
if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
goto bad_area;
}
- if (!handle_mm_fault(mm, vma, address, write))
+ switch (handle_mm_fault(mm, vma, address, write)) {
+ case VM_FAULT_SIGBUS:
+ case VM_FAULT_OOM:
goto do_sigbus;
+ }
up_read(&mm->mmap_sem);
return;
bad_area:
Signature · 4 lines
Man once surrendering his reason, has no remaining guard against absurdities the most monstrous, and like a ship without rudder, is the sport of every wind. -Thomas Jefferson to James Smith, 1822
Quoted 5 lines · William Lee Irwin III
Quoted 5 lines
Convert
arch/sparc/mm/fault.cto symbolic fault codes, default to minor faults for unrecognized fault codes. Also treatVM_FAULT_OOMsimilarly toVM_FAULT_SIGBUSinforce_user_fault(), thereby fixing a latent bug.[ ... snip patch ... ]
Quoted 4 lines · Art Haas
Here's a slightly modified version of that patch which makes the sparc32 code more closely match the sparc64 code by setting the default branch of the case statement to
BUG(). The rest of the patch matched what was posted above.
I considered that, flipped a coin, and went with defaulting to minor faults. Since someone has an opinion (though not necessarily strong) I'll switch it over to that way.
-- wli