2009-04-03 08:49:22 +07:00
|
|
|
/*
|
2005-04-17 05:20:36 +07:00
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995, 1996, 1997, 1998 by Ralf Baechle
|
|
|
|
* Copyright 1999 SuSE GmbH (Philipp Rumpf, prumpf@tux.org)
|
|
|
|
* Copyright 1999 Hewlett Packard Co.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/interrupt.h>
|
2016-09-20 05:04:51 +07:00
|
|
|
#include <linux/extable.h>
|
2015-05-11 22:52:11 +07:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#include <asm/traps.h>
|
|
|
|
|
|
|
|
/* Various important other fields */
|
|
|
|
#define bit22set(x) (x & 0x00000200)
|
|
|
|
#define bits23_25set(x) (x & 0x000001c0)
|
|
|
|
#define isGraphicsFlushRead(x) ((x & 0xfc003fdf) == 0x04001a80)
|
|
|
|
/* extended opcode is 0x6a */
|
|
|
|
|
|
|
|
#define BITSSET 0x1c0 /* for identifying LDCW */
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_PER_CPU(struct exception_data, exception_data);
|
|
|
|
|
2014-05-05 23:07:12 +07:00
|
|
|
int show_unhandled_signals = 1;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* parisc_acctyp(unsigned int inst) --
|
|
|
|
* Given a PA-RISC memory access instruction, determine if the
|
|
|
|
* the instruction would perform a memory read or memory write
|
|
|
|
* operation.
|
|
|
|
*
|
|
|
|
* This function assumes that the given instruction is a memory access
|
|
|
|
* instruction (i.e. you should really only call it if you know that
|
|
|
|
* the instruction has generated some sort of a memory access fault).
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* VM_READ if read operation
|
|
|
|
* VM_WRITE if write operation
|
|
|
|
* VM_EXEC if execute operation
|
|
|
|
*/
|
|
|
|
static unsigned long
|
|
|
|
parisc_acctyp(unsigned long code, unsigned int inst)
|
|
|
|
{
|
|
|
|
if (code == 6 || code == 16)
|
|
|
|
return VM_EXEC;
|
|
|
|
|
|
|
|
switch (inst & 0xf0000000) {
|
|
|
|
case 0x40000000: /* load */
|
|
|
|
case 0x50000000: /* new load */
|
|
|
|
return VM_READ;
|
|
|
|
|
|
|
|
case 0x60000000: /* store */
|
|
|
|
case 0x70000000: /* new store */
|
|
|
|
return VM_WRITE;
|
|
|
|
|
|
|
|
case 0x20000000: /* coproc */
|
|
|
|
case 0x30000000: /* coproc2 */
|
|
|
|
if (bit22set(inst))
|
|
|
|
return VM_WRITE;
|
|
|
|
|
|
|
|
case 0x0: /* indexed/memory management */
|
|
|
|
if (bit22set(inst)) {
|
|
|
|
/*
|
|
|
|
* Check for the 'Graphics Flush Read' instruction.
|
|
|
|
* It resembles an FDC instruction, except for bits
|
|
|
|
* 20 and 21. Any combination other than zero will
|
|
|
|
* utilize the block mover functionality on some
|
|
|
|
* older PA-RISC platforms. The case where a block
|
|
|
|
* move is performed from VM to graphics IO space
|
|
|
|
* should be treated as a READ.
|
|
|
|
*
|
|
|
|
* The significance of bits 20,21 in the FDC
|
|
|
|
* instruction is:
|
|
|
|
*
|
|
|
|
* 00 Flush data cache (normal instruction behavior)
|
|
|
|
* 01 Graphics flush write (IO space -> VM)
|
|
|
|
* 10 Graphics flush read (VM -> IO space)
|
|
|
|
* 11 Graphics flush read/write (VM <-> IO space)
|
|
|
|
*/
|
|
|
|
if (isGraphicsFlushRead(inst))
|
|
|
|
return VM_READ;
|
|
|
|
return VM_WRITE;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Check for LDCWX and LDCWS (semaphore instructions).
|
|
|
|
* If bits 23 through 25 are all 1's it is one of
|
|
|
|
* the above two instructions and is a write.
|
|
|
|
*
|
|
|
|
* Note: With the limited bits we are looking at,
|
|
|
|
* this will also catch PROBEW and PROBEWI. However,
|
|
|
|
* these should never get in here because they don't
|
|
|
|
* generate exceptions of the type:
|
|
|
|
* Data TLB miss fault/data page fault
|
|
|
|
* Data memory protection trap
|
|
|
|
*/
|
|
|
|
if (bits23_25set(inst) == BITSSET)
|
|
|
|
return VM_WRITE;
|
|
|
|
}
|
|
|
|
return VM_READ; /* Default */
|
|
|
|
}
|
|
|
|
return VM_READ; /* Default */
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef bit22set
|
|
|
|
#undef bits23_25set
|
|
|
|
#undef isGraphicsFlushRead
|
|
|
|
#undef BITSSET
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* This is the treewalk to find a vma which is the highest that has
|
|
|
|
* a start < addr. We're using find_vma_prev instead right now, but
|
|
|
|
* we might want to use this at some point in the future. Probably
|
|
|
|
* not, but I want it committed to CVS so I don't lose it :-)
|
|
|
|
*/
|
|
|
|
while (tree != vm_avl_empty) {
|
|
|
|
if (tree->vm_start > addr) {
|
|
|
|
tree = tree->vm_avl_left;
|
|
|
|
} else {
|
|
|
|
prev = tree;
|
|
|
|
if (prev->vm_next == NULL)
|
|
|
|
break;
|
|
|
|
if (prev->vm_next->vm_start > addr)
|
|
|
|
break;
|
|
|
|
tree = tree->vm_avl_right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
parisc: fix kernel crash (protection id trap) when compiling ruby1.9
On Wed, Dec 17, 2008 at 11:46:05PM +0100, Helge Deller wrote:
>
Honestly, I can't decide whether to apply this. It really should never
happen in the kernel, since the kernel can guarantee it won't get the
access rights failure (highest privilege level, and can set %sr and
%protid to whatever it wants.)
It really genuinely is a bug that probably should panic the kernel. The
only precedent I can easily see is x86 fixing up a bad iret with a
general protection fault, which is more or less analogous to code 27
here.
On the other hand, taking the exception on a userspace access really
isn't all that critical, and there's fundamentally little reason for the
kernel not to SIGSEGV the process, and continue...
Argh.
(btw, I've instrumented my do_sys_poll with a pile of assertions that
%cr8 << 1 == %sr3 == current->mm.context... let's see if where we're
getting corrupted is deterministic, though, I would guess that it won't
be.)
Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>
2008-12-20 09:29:06 +07:00
|
|
|
int fixup_exception(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
const struct exception_table_entry *fix;
|
|
|
|
|
|
|
|
fix = search_exception_tables(regs->iaoq[0]);
|
|
|
|
if (fix) {
|
|
|
|
struct exception_data *d;
|
2014-02-15 03:18:56 +07:00
|
|
|
d = this_cpu_ptr(&exception_data);
|
parisc: fix kernel crash (protection id trap) when compiling ruby1.9
On Wed, Dec 17, 2008 at 11:46:05PM +0100, Helge Deller wrote:
>
Honestly, I can't decide whether to apply this. It really should never
happen in the kernel, since the kernel can guarantee it won't get the
access rights failure (highest privilege level, and can set %sr and
%protid to whatever it wants.)
It really genuinely is a bug that probably should panic the kernel. The
only precedent I can easily see is x86 fixing up a bad iret with a
general protection fault, which is more or less analogous to code 27
here.
On the other hand, taking the exception on a userspace access really
isn't all that critical, and there's fundamentally little reason for the
kernel not to SIGSEGV the process, and continue...
Argh.
(btw, I've instrumented my do_sys_poll with a pile of assertions that
%cr8 << 1 == %sr3 == current->mm.context... let's see if where we're
getting corrupted is deterministic, though, I would guess that it won't
be.)
Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>
2008-12-20 09:29:06 +07:00
|
|
|
d->fault_ip = regs->iaoq[0];
|
2016-04-08 23:32:52 +07:00
|
|
|
d->fault_gp = regs->gr[27];
|
parisc: fix kernel crash (protection id trap) when compiling ruby1.9
On Wed, Dec 17, 2008 at 11:46:05PM +0100, Helge Deller wrote:
>
Honestly, I can't decide whether to apply this. It really should never
happen in the kernel, since the kernel can guarantee it won't get the
access rights failure (highest privilege level, and can set %sr and
%protid to whatever it wants.)
It really genuinely is a bug that probably should panic the kernel. The
only precedent I can easily see is x86 fixing up a bad iret with a
general protection fault, which is more or less analogous to code 27
here.
On the other hand, taking the exception on a userspace access really
isn't all that critical, and there's fundamentally little reason for the
kernel not to SIGSEGV the process, and continue...
Argh.
(btw, I've instrumented my do_sys_poll with a pile of assertions that
%cr8 << 1 == %sr3 == current->mm.context... let's see if where we're
getting corrupted is deterministic, though, I would guess that it won't
be.)
Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>
2008-12-20 09:29:06 +07:00
|
|
|
d->fault_space = regs->isr;
|
|
|
|
d->fault_addr = regs->ior;
|
|
|
|
|
2016-03-23 22:00:46 +07:00
|
|
|
regs->iaoq[0] = (unsigned long)&fix->fixup + fix->fixup;
|
|
|
|
regs->iaoq[0] &= ~3;
|
parisc: fix kernel crash (protection id trap) when compiling ruby1.9
On Wed, Dec 17, 2008 at 11:46:05PM +0100, Helge Deller wrote:
>
Honestly, I can't decide whether to apply this. It really should never
happen in the kernel, since the kernel can guarantee it won't get the
access rights failure (highest privilege level, and can set %sr and
%protid to whatever it wants.)
It really genuinely is a bug that probably should panic the kernel. The
only precedent I can easily see is x86 fixing up a bad iret with a
general protection fault, which is more or less analogous to code 27
here.
On the other hand, taking the exception on a userspace access really
isn't all that critical, and there's fundamentally little reason for the
kernel not to SIGSEGV the process, and continue...
Argh.
(btw, I've instrumented my do_sys_poll with a pile of assertions that
%cr8 << 1 == %sr3 == current->mm.context... let's see if where we're
getting corrupted is deterministic, though, I would guess that it won't
be.)
Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>
2008-12-20 09:29:06 +07:00
|
|
|
/*
|
|
|
|
* NOTE: In some cases the faulting instruction
|
|
|
|
* may be in the delay slot of a branch. We
|
|
|
|
* don't want to take the branch, so we don't
|
|
|
|
* increment iaoq[1], instead we set it to be
|
|
|
|
* iaoq[0]+4, and clear the B bit in the PSW
|
|
|
|
*/
|
|
|
|
regs->iaoq[1] = regs->iaoq[0] + 4;
|
|
|
|
regs->gr[0] &= ~PSW_B; /* IPSW in gr[0] */
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-09-25 02:45:46 +07:00
|
|
|
/*
|
|
|
|
* parisc hardware trap list
|
|
|
|
*
|
|
|
|
* Documented in section 3 "Addressing and Access Control" of the
|
|
|
|
* "PA-RISC 1.1 Architecture and Instruction Set Reference Manual"
|
|
|
|
* https://parisc.wiki.kernel.org/index.php/File:Pa11_acd.pdf
|
|
|
|
*
|
|
|
|
* For implementation see handle_interruption() in traps.c
|
|
|
|
*/
|
|
|
|
static const char * const trap_description[] = {
|
|
|
|
[1] "High-priority machine check (HPMC)",
|
|
|
|
[2] "Power failure interrupt",
|
|
|
|
[3] "Recovery counter trap",
|
|
|
|
[5] "Low-priority machine check",
|
|
|
|
[6] "Instruction TLB miss fault",
|
|
|
|
[7] "Instruction access rights / protection trap",
|
|
|
|
[8] "Illegal instruction trap",
|
|
|
|
[9] "Break instruction trap",
|
|
|
|
[10] "Privileged operation trap",
|
|
|
|
[11] "Privileged register trap",
|
|
|
|
[12] "Overflow trap",
|
|
|
|
[13] "Conditional trap",
|
|
|
|
[14] "FP Assist Exception trap",
|
|
|
|
[15] "Data TLB miss fault",
|
|
|
|
[16] "Non-access ITLB miss fault",
|
|
|
|
[17] "Non-access DTLB miss fault",
|
|
|
|
[18] "Data memory protection/unaligned access trap",
|
|
|
|
[19] "Data memory break trap",
|
|
|
|
[20] "TLB dirty bit trap",
|
|
|
|
[21] "Page reference trap",
|
|
|
|
[22] "Assist emulation trap",
|
|
|
|
[25] "Taken branch trap",
|
|
|
|
[26] "Data memory access rights trap",
|
|
|
|
[27] "Data memory protection ID trap",
|
|
|
|
[28] "Unaligned data reference trap",
|
|
|
|
};
|
|
|
|
|
2016-10-12 01:49:42 +07:00
|
|
|
const char *trap_name(unsigned long code)
|
|
|
|
{
|
|
|
|
const char *t = NULL;
|
|
|
|
|
|
|
|
if (code < ARRAY_SIZE(trap_description))
|
|
|
|
t = trap_description[code];
|
|
|
|
|
|
|
|
return t ? t : "Unknown trap";
|
|
|
|
}
|
|
|
|
|
2014-05-05 23:07:12 +07:00
|
|
|
/*
|
|
|
|
* Print out info about fatal segfaults, if the show_unhandled_signals
|
|
|
|
* sysctl is set:
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
show_signal_msg(struct pt_regs *regs, unsigned long code,
|
|
|
|
unsigned long address, struct task_struct *tsk,
|
|
|
|
struct vm_area_struct *vma)
|
|
|
|
{
|
|
|
|
if (!unhandled_signal(tsk, SIGSEGV))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!printk_ratelimit())
|
|
|
|
return;
|
|
|
|
|
|
|
|
pr_warn("\n");
|
|
|
|
pr_warn("do_page_fault() command='%s' type=%lu address=0x%08lx",
|
|
|
|
tsk->comm, code, address);
|
|
|
|
print_vma_addr(KERN_CONT " in ", regs->iaoq[0]);
|
2016-09-25 02:45:46 +07:00
|
|
|
|
2016-10-12 01:49:42 +07:00
|
|
|
pr_cont(" trap #%lu: %s%c", code, trap_name(code),
|
2016-09-25 02:45:46 +07:00
|
|
|
vma ? ',':'\n');
|
|
|
|
|
2014-05-05 23:07:12 +07:00
|
|
|
if (vma)
|
2016-09-25 02:45:46 +07:00
|
|
|
pr_warn(KERN_CONT " vm_start = 0x%08lx, vm_end = 0x%08lx\n",
|
2014-05-05 23:07:12 +07:00
|
|
|
vma->vm_start, vma->vm_end);
|
|
|
|
|
|
|
|
show_regs(regs);
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
void do_page_fault(struct pt_regs *regs, unsigned long code,
|
|
|
|
unsigned long address)
|
|
|
|
{
|
|
|
|
struct vm_area_struct *vma, *prev_vma;
|
2013-10-05 21:55:36 +07:00
|
|
|
struct task_struct *tsk;
|
|
|
|
struct mm_struct *mm;
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long acc_type;
|
2007-07-19 15:47:05 +07:00
|
|
|
int fault;
|
2013-10-05 21:55:36 +07:00
|
|
|
unsigned int flags;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2015-09-02 23:18:48 +07:00
|
|
|
if (faulthandler_disabled())
|
2005-04-17 05:20:36 +07:00
|
|
|
goto no_context;
|
|
|
|
|
2013-10-05 21:55:36 +07:00
|
|
|
tsk = current;
|
|
|
|
mm = tsk->mm;
|
|
|
|
if (!mm)
|
|
|
|
goto no_context;
|
|
|
|
|
|
|
|
flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
|
2013-09-13 05:13:39 +07:00
|
|
|
if (user_mode(regs))
|
|
|
|
flags |= FAULT_FLAG_USER;
|
2013-10-01 03:45:14 +07:00
|
|
|
|
|
|
|
acc_type = parisc_acctyp(code, regs->iir);
|
2013-09-13 05:13:39 +07:00
|
|
|
if (acc_type & VM_WRITE)
|
|
|
|
flags |= FAULT_FLAG_WRITE;
|
2012-03-20 20:26:53 +07:00
|
|
|
retry:
|
2005-04-17 05:20:36 +07:00
|
|
|
down_read(&mm->mmap_sem);
|
|
|
|
vma = find_vma_prev(mm, address, &prev_vma);
|
|
|
|
if (!vma || address < vma->vm_start)
|
|
|
|
goto check_expansion;
|
|
|
|
/*
|
|
|
|
* Ok, we have a good vm_area for this memory access. We still need to
|
|
|
|
* check the access permissions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
good_area:
|
|
|
|
|
|
|
|
if ((vma->vm_flags & acc_type) != acc_type)
|
|
|
|
goto bad_area;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If for any reason at all we couldn't handle the fault, make
|
|
|
|
* sure we exit gracefully rather than endlessly redo the
|
|
|
|
* fault.
|
|
|
|
*/
|
|
|
|
|
2016-07-27 05:25:18 +07:00
|
|
|
fault = handle_mm_fault(vma, address, flags);
|
2012-03-20 20:26:53 +07:00
|
|
|
|
|
|
|
if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
|
|
|
|
return;
|
|
|
|
|
2007-07-19 15:47:05 +07:00
|
|
|
if (unlikely(fault & VM_FAULT_ERROR)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
2006-03-28 02:52:14 +07:00
|
|
|
* We hit a shared mapping outside of the file, or some
|
2005-08-04 22:33:38 +07:00
|
|
|
* other thing happened to us that made us unable to
|
|
|
|
* handle the page fault gracefully.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2007-07-19 15:47:05 +07:00
|
|
|
if (fault & VM_FAULT_OOM)
|
|
|
|
goto out_of_memory;
|
vm: add VM_FAULT_SIGSEGV handling support
The core VM already knows about VM_FAULT_SIGBUS, but cannot return a
"you should SIGSEGV" error, because the SIGSEGV case was generally
handled by the caller - usually the architecture fault handler.
That results in lots of duplication - all the architecture fault
handlers end up doing very similar "look up vma, check permissions, do
retries etc" - but it generally works. However, there are cases where
the VM actually wants to SIGSEGV, and applications _expect_ SIGSEGV.
In particular, when accessing the stack guard page, libsigsegv expects a
SIGSEGV. And it usually got one, because the stack growth is handled by
that duplicated architecture fault handler.
However, when the generic VM layer started propagating the error return
from the stack expansion in commit fee7e49d4514 ("mm: propagate error
from stack expansion even for guard page"), that now exposed the
existing VM_FAULT_SIGBUS result to user space. And user space really
expected SIGSEGV, not SIGBUS.
To fix that case, we need to add a VM_FAULT_SIGSEGV, and teach all those
duplicate architecture fault handlers about it. They all already have
the code to handle SIGSEGV, so it's about just tying that new return
value to the existing code, but it's all a bit annoying.
This is the mindless minimal patch to do this. A more extensive patch
would be to try to gather up the mostly shared fault handling logic into
one generic helper routine, and long-term we really should do that
cleanup.
Just from this patch, you can generally see that most architectures just
copied (directly or indirectly) the old x86 way of doing things, but in
the meantime that original x86 model has been improved to hold the VM
semaphore for shorter times etc and to handle VM_FAULT_RETRY and other
"newer" things, so it would be a good idea to bring all those
improvements to the generic case and teach other architectures about
them too.
Reported-and-tested-by: Takashi Iwai <tiwai@suse.de>
Tested-by: Jan Engelhardt <jengelh@inai.de>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> # "s390 still compiles and boots"
Cc: linux-arch@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-01-30 01:51:32 +07:00
|
|
|
else if (fault & VM_FAULT_SIGSEGV)
|
|
|
|
goto bad_area;
|
2007-07-19 15:47:05 +07:00
|
|
|
else if (fault & VM_FAULT_SIGBUS)
|
|
|
|
goto bad_area;
|
|
|
|
BUG();
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2012-03-20 20:26:53 +07:00
|
|
|
if (flags & FAULT_FLAG_ALLOW_RETRY) {
|
|
|
|
if (fault & VM_FAULT_MAJOR)
|
|
|
|
current->maj_flt++;
|
|
|
|
else
|
|
|
|
current->min_flt++;
|
|
|
|
if (fault & VM_FAULT_RETRY) {
|
|
|
|
flags &= ~FAULT_FLAG_ALLOW_RETRY;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* No need to up_read(&mm->mmap_sem) as we would
|
|
|
|
* have already released it in __lock_page_or_retry
|
|
|
|
* in mm/filemap.c.
|
|
|
|
*/
|
|
|
|
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
up_read(&mm->mmap_sem);
|
|
|
|
return;
|
|
|
|
|
|
|
|
check_expansion:
|
|
|
|
vma = prev_vma;
|
|
|
|
if (vma && (expand_stack(vma, address) == 0))
|
|
|
|
goto good_area;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Something tried to access memory that isn't in our memory map..
|
|
|
|
*/
|
|
|
|
bad_area:
|
|
|
|
up_read(&mm->mmap_sem);
|
|
|
|
|
|
|
|
if (user_mode(regs)) {
|
|
|
|
struct siginfo si;
|
|
|
|
|
2014-05-05 23:07:12 +07:00
|
|
|
show_signal_msg(regs, code, address, tsk, vma);
|
|
|
|
|
2013-11-07 23:08:36 +07:00
|
|
|
switch (code) {
|
|
|
|
case 15: /* Data TLB miss fault/Data page fault */
|
2013-11-19 04:12:11 +07:00
|
|
|
/* send SIGSEGV when outside of vma */
|
|
|
|
if (!vma ||
|
|
|
|
address < vma->vm_start || address > vma->vm_end) {
|
|
|
|
si.si_signo = SIGSEGV;
|
|
|
|
si.si_code = SEGV_MAPERR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send SIGSEGV for wrong permissions */
|
|
|
|
if ((vma->vm_flags & acc_type) != acc_type) {
|
|
|
|
si.si_signo = SIGSEGV;
|
|
|
|
si.si_code = SEGV_ACCERR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* probably address is outside of mapped file */
|
|
|
|
/* fall through */
|
2013-11-07 23:08:36 +07:00
|
|
|
case 17: /* NA data TLB miss / page fault */
|
|
|
|
case 18: /* Unaligned access - PCXS only */
|
|
|
|
si.si_signo = SIGBUS;
|
2013-11-19 04:12:11 +07:00
|
|
|
si.si_code = (code == 18) ? BUS_ADRALN : BUS_ADRERR;
|
2013-11-07 23:08:36 +07:00
|
|
|
break;
|
|
|
|
case 16: /* Non-access instruction TLB miss fault */
|
|
|
|
case 26: /* PCXL: Data memory access rights trap */
|
|
|
|
default:
|
|
|
|
si.si_signo = SIGSEGV;
|
2013-11-19 04:12:11 +07:00
|
|
|
si.si_code = (code == 26) ? SEGV_ACCERR : SEGV_MAPERR;
|
|
|
|
break;
|
2013-11-07 23:08:36 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
si.si_errno = 0;
|
|
|
|
si.si_addr = (void __user *) address;
|
2013-11-07 23:08:36 +07:00
|
|
|
force_sig_info(si.si_signo, &si, current);
|
2005-04-17 05:20:36 +07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
no_context:
|
|
|
|
|
parisc: fix kernel crash (protection id trap) when compiling ruby1.9
On Wed, Dec 17, 2008 at 11:46:05PM +0100, Helge Deller wrote:
>
Honestly, I can't decide whether to apply this. It really should never
happen in the kernel, since the kernel can guarantee it won't get the
access rights failure (highest privilege level, and can set %sr and
%protid to whatever it wants.)
It really genuinely is a bug that probably should panic the kernel. The
only precedent I can easily see is x86 fixing up a bad iret with a
general protection fault, which is more or less analogous to code 27
here.
On the other hand, taking the exception on a userspace access really
isn't all that critical, and there's fundamentally little reason for the
kernel not to SIGSEGV the process, and continue...
Argh.
(btw, I've instrumented my do_sys_poll with a pile of assertions that
%cr8 << 1 == %sr3 == current->mm.context... let's see if where we're
getting corrupted is deterministic, though, I would guess that it won't
be.)
Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>
2008-12-20 09:29:06 +07:00
|
|
|
if (!user_mode(regs) && fixup_exception(regs)) {
|
|
|
|
return;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
parisc_terminate("Bad Address (null pointer deref?)", regs, code, address);
|
|
|
|
|
|
|
|
out_of_memory:
|
|
|
|
up_read(&mm->mmap_sem);
|
2010-04-22 23:06:23 +07:00
|
|
|
if (!user_mode(regs))
|
|
|
|
goto no_context;
|
|
|
|
pagefault_out_of_memory();
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|