From owner-svn-src-all@freebsd.org Mon Oct 19 12:46:04 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6346E44EF69; Mon, 19 Oct 2020 12:46:04 +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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 4CFGhX1xD2z4YRL; Mon, 19 Oct 2020 12:46:04 +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 25AD023D31; Mon, 19 Oct 2020 12:46:04 +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 09JCk4YV088269; Mon, 19 Oct 2020 12:46:04 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09JCk4YY088268; Mon, 19 Oct 2020 12:46:04 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <202010191246.09JCk4YY088268@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Mon, 19 Oct 2020 12:46:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366832 - 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: 366832 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2020 12:46:04 -0000 Author: andrew Date: Mon Oct 19 12:46:03 2020 New Revision: 366832 URL: https://svnweb.freebsd.org/changeset/base/366832 Log: Split the common arm64 fu* and su* asm to a macro As these are mostly identical split out the common code to a macro. Sponsored by: Innovate UK Modified: head/sys/arm64/arm64/support.S Modified: head/sys/arm64/arm64/support.S ============================================================================== --- head/sys/arm64/arm64/support.S Mon Oct 19 12:06:16 2020 (r366831) +++ head/sys/arm64/arm64/support.S Mon Oct 19 12:46:03 2020 (r366832) @@ -95,15 +95,19 @@ ENTRY(casueword) ret /* Return */ END(casueword) +.macro fsudata insn, ret_reg, user_arg + adr x7, fsu_fault /* Load the fault handler */ + SET_FAULT_HANDLER(x7, x6) /* And set it */ + \insn \ret_reg, [x\user_arg] /* Try accessing the data */ + SET_FAULT_HANDLER(xzr, x6) /* Reset the fault handler */ +.endm + /* * int fubyte(volatile const void *) */ ENTRY(fubyte) check_user_access 0, (VM_MAXUSER_ADDRESS), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x1) /* And set it */ - ldtrb w0, [x0] /* Try loading the data */ - SET_FAULT_HANDLER(xzr, x1) /* Reset the fault handler */ + fsudata ldtrb, w0, 0 ret /* Return */ END(fubyte) @@ -112,10 +116,7 @@ END(fubyte) */ ENTRY(fuword16) check_user_access 0, (VM_MAXUSER_ADDRESS-1), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x1) /* And set it */ - ldtrh w0, [x0] /* Try loading the data */ - SET_FAULT_HANDLER(xzr, x1) /* Reset the fault handler */ + fsudata ldtrh, w0, 0 ret /* Return */ END(fuword16) @@ -124,10 +125,7 @@ END(fuword16) */ ENTRY(fueword32) check_user_access 0, (VM_MAXUSER_ADDRESS-3), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x2) /* And set it */ - ldtr w0, [x0] /* Try loading the data */ - SET_FAULT_HANDLER(xzr, x2) /* Reset the fault handler */ + fsudata ldtr, w0, 0 str w0, [x1] /* Save the data in kernel space */ mov w0, #0 /* Success */ ret /* Return */ @@ -140,10 +138,7 @@ END(fueword32) ENTRY(fueword) EENTRY(fueword64) check_user_access 0, (VM_MAXUSER_ADDRESS-7), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x2) /* And set it */ - ldtr x0, [x0] /* Try loading the data */ - SET_FAULT_HANDLER(xzr, x2) /* Reset the fault handler */ + fsudata ldtr, x0, 0 str x0, [x1] /* Save the data in kernel space */ mov x0, #0 /* Success */ ret /* Return */ @@ -155,10 +150,7 @@ END(fueword) */ ENTRY(subyte) check_user_access 0, (VM_MAXUSER_ADDRESS), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x2) /* And set it */ - sttrb w1, [x0] /* Try storing the data */ - SET_FAULT_HANDLER(xzr, x2) /* Reset the fault handler */ + fsudata sttrb, w1, 0 mov x0, #0 /* Success */ ret /* Return */ END(subyte) @@ -168,10 +160,7 @@ END(subyte) */ ENTRY(suword16) check_user_access 0, (VM_MAXUSER_ADDRESS-1), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x2) /* And set it */ - sttrh w1, [x0] /* Try storing the data */ - SET_FAULT_HANDLER(xzr, x2) /* Reset the fault handler */ + fsudata sttrh, w1, 0 mov x0, #0 /* Success */ ret /* Return */ END(suword16) @@ -181,10 +170,7 @@ END(suword16) */ ENTRY(suword32) check_user_access 0, (VM_MAXUSER_ADDRESS-3), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x2) /* And set it */ - sttr w1, [x0] /* Try storing the data */ - SET_FAULT_HANDLER(xzr, x2) /* Reset the fault handler */ + fsudata sttr, w1, 0 mov x0, #0 /* Success */ ret /* Return */ END(suword32) @@ -195,10 +181,7 @@ END(suword32) ENTRY(suword) EENTRY(suword64) check_user_access 0, (VM_MAXUSER_ADDRESS-7), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x2) /* And set it */ - sttr x1, [x0] /* Try storing the data */ - SET_FAULT_HANDLER(xzr, x2) /* Reset the fault handler */ + fsudata sttr, x1, 0 mov x0, #0 /* Success */ ret /* Return */ EEND(suword64)