From owner-svn-src-projects@FreeBSD.ORG Sat Aug 23 17:19:19 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 36FB2CE2; Sat, 23 Aug 2014 17:19:19 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 192B038C0; Sat, 23 Aug 2014 17:19:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7NHJIeu032294; Sat, 23 Aug 2014 17:19:18 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7NHJIIT032293; Sat, 23 Aug 2014 17:19:18 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201408231719.s7NHJIIT032293@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Sat, 23 Aug 2014 17:19:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r270421 - projects/arm64/sys/arm64/arm64 X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Aug 2014 17:19:19 -0000 Author: andrew Date: Sat Aug 23 17:19:18 2014 New Revision: 270421 URL: http://svnweb.freebsd.org/changeset/base/270421 Log: Start to handle data/instruction aborts Modified: projects/arm64/sys/arm64/arm64/trap.c Modified: projects/arm64/sys/arm64/arm64/trap.c ============================================================================== --- projects/arm64/sys/arm64/arm64/trap.c Sat Aug 23 17:19:15 2014 (r270420) +++ projects/arm64/sys/arm64/arm64/trap.c Sat Aug 23 17:19:18 2014 (r270421) @@ -30,10 +30,21 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include +#include +#include +#include +#include +#include + #include +/* Called from exception.S */ +void do_el1h_sync(struct trapframe *); + int cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa) { @@ -41,8 +52,64 @@ cpu_fetch_syscall_args(struct thread *td panic("cpu_fetch_syscall_args"); } -void do_el1h_sync(struct trapframe *frame); -void do_el1h_sync(struct trapframe *frame) +static void +data_abort(struct trapframe *frame, uint64_t esr, int lower) +{ + struct vm_map *map; + struct thread *td; + struct proc *p; + vm_prot_t ftype; + vm_offset_t va; + uint64_t far; + int error; + + __asm __volatile("mrs %x0, far_el1" : "=r"(far)); + + td = curthread; + p = td->td_proc; + + if (lower) + map = &td->td_proc->p_vmspace->vm_map; + else { + /* The top bit tells us which range to use */ + if ((far >> 63) == 1) + map = kernel_map; + else + map = &td->td_proc->p_vmspace->vm_map; + } + + va = trunc_page(far); + ftype = ((esr >> 6) & 1) ? VM_PROT_READ | VM_PROT_WRITE : VM_PROT_READ; + + if (map != kernel_map) { + /* + * Keep swapout from messing with us during this + * critical time. + */ + PROC_LOCK(p); + ++p->p_lock; + PROC_UNLOCK(p); + + /* Fault in the user page: */ + error = vm_fault(map, va, ftype, VM_FAULT_NORMAL); + + PROC_LOCK(p); + --p->p_lock; + PROC_UNLOCK(p); + } else { + /* + * Don't have to worry about process locking or stacks in the + * kernel. + */ + error = vm_fault(map, va, ftype, VM_FAULT_NORMAL); + } + + if (error != 0) + panic("vm_fault failed"); +} + +void +do_el1h_sync(struct trapframe *frame) { uint32_t exception; uint64_t esr; @@ -66,7 +133,7 @@ void do_el1h_sync(struct trapframe *fram printf("spsr: %llx\n", frame->tf_spsr); switch(exception) { case 0x25: - panic("Data abort at %#llx", frame->tf_elr); + data_abort(frame, esr, 0); break; case 0x3c: printf("Breakpoint %x\n", (uint32_t)(esr & 0xffffff)); @@ -75,6 +142,6 @@ void do_el1h_sync(struct trapframe *fram default: panic("Unknown exception %x\n", exception); } - frame->tf_elr += 4; + printf("Done do_el1h_sync\n"); }