From owner-svn-src-head@freebsd.org Thu Dec 27 14:14:42 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6B4371360827; Thu, 27 Dec 2018 14:14:42 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0C9E27587F; Thu, 27 Dec 2018 14:14:42 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0004ECB85; Thu, 27 Dec 2018 14:14:41 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBREEfwe022471; Thu, 27 Dec 2018 14:14:41 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBREEfCG022470; Thu, 27 Dec 2018 14:14:41 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201812271414.wBREEfCG022470@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Thu, 27 Dec 2018 14:14:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r342552 - head/sys/arm64/arm64 X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: head/sys/arm64/arm64 X-SVN-Commit-Revision: 342552 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0C9E27587F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Dec 2018 14:14:42 -0000 Author: andrew Date: Thu Dec 27 14:14:41 2018 New Revision: 342552 URL: https://svnweb.freebsd.org/changeset/base/342552 Log: Pass VM_PROT_EXECUTE to vm_fault for instruction faults. We need to tell vm_fault the reason for the fault was because we tried to execute from the memory location. Without this it may return with success as we only request read-only memory, then we return to the same location and try to execute from the same memory address. This leads to an infinite loop raising the same fault and returning to the same invalid location. MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D18511 Modified: head/sys/arm64/arm64/trap.c Modified: head/sys/arm64/arm64/trap.c ============================================================================== --- head/sys/arm64/arm64/trap.c Thu Dec 27 13:02:15 2018 (r342551) +++ head/sys/arm64/arm64/trap.c Thu Dec 27 14:14:41 2018 (r342552) @@ -149,7 +149,7 @@ svc_handler(struct thread *td, struct trapframe *frame static void data_abort(struct thread *td, struct trapframe *frame, uint64_t esr, - uint64_t far, int lower) + uint64_t far, int lower, int exec) { struct vm_map *map; struct proc *p; @@ -229,6 +229,8 @@ no_pmap_fault: va = trunc_page(far); ftype = ((esr >> 6) & 1) ? VM_PROT_READ | VM_PROT_WRITE : VM_PROT_READ; + if (exec) + ftype |= VM_PROT_EXECUTE; /* Fault in the page. */ error = vm_fault(map, va, ftype, VM_FAULT_NORMAL); @@ -336,7 +338,8 @@ do_el1h_sync(struct thread *td, struct trapframe *fram case EXCP_DATA_ABORT: far = READ_SPECIALREG(far_el1); intr_enable(); - data_abort(td, frame, esr, far, 0); + data_abort(td, frame, esr, far, 0, + exception == EXCP_INSN_ABORT); break; case EXCP_BRK: #ifdef KDTRACE_HOOKS @@ -433,7 +436,8 @@ do_el0_sync(struct thread *td, struct trapframe *frame case EXCP_INSN_ABORT_L: case EXCP_DATA_ABORT_L: case EXCP_DATA_ABORT: - data_abort(td, frame, esr, far, 1); + data_abort(td, frame, esr, far, 1, + exception == EXCP_INSN_ABORT_L); break; case EXCP_UNKNOWN: if (!undef_insn(0, frame))