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"
231db8af5cSRichard Henderson #include "internal.h"
24cc8eae8aSDavid Gibson
ppc_cpu_record_sigsegv(CPUState * cs,vaddr address,MMUAccessType access_type,bool maperr,uintptr_t retaddr)251db8af5cSRichard Henderson void ppc_cpu_record_sigsegv(CPUState *cs, vaddr address,
261db8af5cSRichard Henderson MMUAccessType access_type,
271db8af5cSRichard Henderson bool maperr, uintptr_t retaddr)
28cc8eae8aSDavid Gibson {
29*794511bcSPhilippe Mathieu-Daudé CPUPPCState *env = cpu_env(cs);
30cc8eae8aSDavid Gibson int exception, error_code;
31cc8eae8aSDavid Gibson
321db8af5cSRichard Henderson /*
331db8af5cSRichard Henderson * Both DSISR and the "trap number" (exception vector offset,
341db8af5cSRichard Henderson * looked up from exception_index) are present in the linux-user
351db8af5cSRichard Henderson * signal frame.
361db8af5cSRichard Henderson * FIXME: we don't actually populate the trap number properly.
371db8af5cSRichard Henderson * It would be easiest to fill in an env->trap value now.
381db8af5cSRichard Henderson */
39351bc97eSRichard Henderson if (access_type == MMU_INST_FETCH) {
40cc8eae8aSDavid Gibson exception = POWERPC_EXCP_ISI;
41cc8eae8aSDavid Gibson error_code = 0x40000000;
42cc8eae8aSDavid Gibson } else {
43cc8eae8aSDavid Gibson exception = POWERPC_EXCP_DSI;
44cc8eae8aSDavid Gibson error_code = 0x40000000;
45351bc97eSRichard Henderson if (access_type == MMU_DATA_STORE) {
46cc8eae8aSDavid Gibson error_code |= 0x02000000;
47cc8eae8aSDavid Gibson }
48cc8eae8aSDavid Gibson env->spr[SPR_DAR] = address;
49cc8eae8aSDavid Gibson env->spr[SPR_DSISR] = error_code;
50cc8eae8aSDavid Gibson }
5127103424SAndreas Färber cs->exception_index = exception;
52cc8eae8aSDavid Gibson env->error_code = error_code;
53351bc97eSRichard Henderson cpu_loop_exit_restore(cs, retaddr);
54cc8eae8aSDavid Gibson }
55