1cc8eae8aSDavid Gibson /* 2cc8eae8aSDavid Gibson * PowerPC MMU stub handling for user mode emulation 3cc8eae8aSDavid Gibson * 4cc8eae8aSDavid Gibson * Copyright (c) 2003-2007 Jocelyn Mayer 5cc8eae8aSDavid Gibson * Copyright (c) 2013 David Gibson, IBM Corporation. 6cc8eae8aSDavid Gibson * 7cc8eae8aSDavid Gibson * This library is free software; you can redistribute it and/or 8cc8eae8aSDavid Gibson * modify it under the terms of the GNU Lesser General Public 9cc8eae8aSDavid Gibson * License as published by the Free Software Foundation; either 106bd039cdSChetan Pant * version 2.1 of the License, or (at your option) any later version. 11cc8eae8aSDavid Gibson * 12cc8eae8aSDavid Gibson * This library is distributed in the hope that it will be useful, 13cc8eae8aSDavid Gibson * but WITHOUT ANY WARRANTY; without even the implied warranty of 14cc8eae8aSDavid Gibson * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15cc8eae8aSDavid Gibson * Lesser General Public License for more details. 16cc8eae8aSDavid Gibson * 17cc8eae8aSDavid Gibson * You should have received a copy of the GNU Lesser General Public 18cc8eae8aSDavid Gibson * License along with this library; if not, see <http://www.gnu.org/licenses/>. 19cc8eae8aSDavid Gibson */ 20cc8eae8aSDavid Gibson 210d75590dSPeter Maydell #include "qemu/osdep.h" 22cc8eae8aSDavid Gibson #include "cpu.h" 23351bc97eSRichard Henderson #include "exec/exec-all.h" 24*1db8af5cSRichard Henderson #include "internal.h" 25cc8eae8aSDavid Gibson 26*1db8af5cSRichard Henderson void ppc_cpu_record_sigsegv(CPUState *cs, vaddr address, 27*1db8af5cSRichard Henderson MMUAccessType access_type, 28*1db8af5cSRichard Henderson bool maperr, uintptr_t retaddr) 29cc8eae8aSDavid Gibson { 307510454eSAndreas Färber PowerPCCPU *cpu = POWERPC_CPU(cs); 317510454eSAndreas Färber CPUPPCState *env = &cpu->env; 32cc8eae8aSDavid Gibson int exception, error_code; 33cc8eae8aSDavid Gibson 34*1db8af5cSRichard Henderson /* 35*1db8af5cSRichard Henderson * Both DSISR and the "trap number" (exception vector offset, 36*1db8af5cSRichard Henderson * looked up from exception_index) are present in the linux-user 37*1db8af5cSRichard Henderson * signal frame. 38*1db8af5cSRichard Henderson * FIXME: we don't actually populate the trap number properly. 39*1db8af5cSRichard Henderson * It would be easiest to fill in an env->trap value now. 40*1db8af5cSRichard Henderson */ 41351bc97eSRichard Henderson if (access_type == MMU_INST_FETCH) { 42cc8eae8aSDavid Gibson exception = POWERPC_EXCP_ISI; 43cc8eae8aSDavid Gibson error_code = 0x40000000; 44cc8eae8aSDavid Gibson } else { 45cc8eae8aSDavid Gibson exception = POWERPC_EXCP_DSI; 46cc8eae8aSDavid Gibson error_code = 0x40000000; 47351bc97eSRichard Henderson if (access_type == MMU_DATA_STORE) { 48cc8eae8aSDavid Gibson error_code |= 0x02000000; 49cc8eae8aSDavid Gibson } 50cc8eae8aSDavid Gibson env->spr[SPR_DAR] = address; 51cc8eae8aSDavid Gibson env->spr[SPR_DSISR] = error_code; 52cc8eae8aSDavid Gibson } 5327103424SAndreas Färber cs->exception_index = exception; 54cc8eae8aSDavid Gibson env->error_code = error_code; 55351bc97eSRichard Henderson cpu_loop_exit_restore(cs, retaddr); 56cc8eae8aSDavid Gibson } 57