From owner-dev-commits-src-main@freebsd.org Tue Jan 12 12:48:43 2021 Return-Path: Delivered-To: dev-commits-src-main@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 E1A714D703A; Tue, 12 Jan 2021 12:48:43 +0000 (UTC) (envelope-from git@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 4DFVkM5dkWz3Cj5; Tue, 12 Jan 2021 12:48:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B45982D19B; Tue, 12 Jan 2021 12:48:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 10CCmh7L075777; Tue, 12 Jan 2021 12:48:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10CCmhT2075776; Tue, 12 Jan 2021 12:48:43 GMT (envelope-from git) Date: Tue, 12 Jan 2021 12:48:43 GMT Message-Id: <202101121248.10CCmhT2075776@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: c00ec4dab276 - main - Handle using a sub instruction in the arm64 fbt MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c00ec4dab276414ccc8a0712dd2f836bb17349d7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jan 2021 12:48:43 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=c00ec4dab276414ccc8a0712dd2f836bb17349d7 commit c00ec4dab276414ccc8a0712dd2f836bb17349d7 Author: Andrew Turner AuthorDate: 2021-01-12 12:14:09 +0000 Commit: Andrew Turner CommitDate: 2021-01-12 12:42:23 +0000 Handle using a sub instruction in the arm64 fbt Some stack frames are too large for a store pair instruction we already detect in the arm64 fbt code. Add support for handling subtracting the stack pointer directly. Sponsored by: Innovate UK --- sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h | 9 +++++++++ sys/cddl/dev/dtrace/aarch64/dtrace_subr.c | 6 ++++++ sys/cddl/dev/fbt/aarch64/fbt_isa.c | 17 ++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h index 922c1a9bba9b..2bedd01cf3e7 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h +++ b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h @@ -2468,6 +2468,14 @@ extern void dtrace_helpers_destroy(proc_t *); #define RET_INSTR 0xd65f03c0 +#define SUB_MASK 0xffc00000 +#define SUB_INSTR 0xd1000000 +#define SUB_RD_SHIFT 0 +#define SUB_RN_SHIFT 5 +#define SUB_R_MASK 0x1f +#define SUB_IMM_SHIFT 10 +#define SUB_IMM_MASK 0xfff + #define LDP_STP_MASK 0xffc00000 #define STP_32 0x29800000 #define STP_64 0xa9800000 @@ -2488,6 +2496,7 @@ extern void dtrace_helpers_destroy(proc_t *); #define DTRACE_INVOP_STP 1 #define DTRACE_INVOP_RET 2 #define DTRACE_INVOP_B 3 +#define DTRACE_INVOP_SUB 4 #elif defined(__mips__) diff --git a/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c b/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c index 2d59b29b850b..6646e51fc191 100644 --- a/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c +++ b/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c @@ -305,6 +305,12 @@ dtrace_invop_start(struct trapframe *frame) return (0); } + if ((invop & SUB_MASK) == SUB_INSTR) { + frame->tf_sp -= (invop >> SUB_IMM_SHIFT) & SUB_IMM_MASK; + frame->tf_elr += INSN_SIZE; + return (0); + } + if ((invop & B_MASK) == B_INSTR) { data = (invop & B_DATA_MASK); /* The data is the number of 4-byte words to change the pc */ diff --git a/sys/cddl/dev/fbt/aarch64/fbt_isa.c b/sys/cddl/dev/fbt/aarch64/fbt_isa.c index 9235af1a4c65..f15bc12291d3 100644 --- a/sys/cddl/dev/fbt/aarch64/fbt_isa.c +++ b/sys/cddl/dev/fbt/aarch64/fbt_isa.c @@ -121,6 +121,18 @@ fbt_provide_module_function(linker_file_t lf, int symindx, found = true; break; } + + /* + * Some functions start with a "sub sp, sp, " + * Sometimes the compiler will have a sub instruction that + * is not of the above type so don't stop if we see one. + */ + if ((*instr & SUB_MASK) == SUB_INSTR && + ((*instr >> SUB_RD_SHIFT) & SUB_R_MASK) == 31 && + ((*instr >> SUB_RN_SHIFT) & SUB_R_MASK) == 31) { + found = true; + break; + } } if (!found) @@ -135,7 +147,10 @@ fbt_provide_module_function(linker_file_t lf, int symindx, fbt->fbtp_loadcnt = lf->loadcnt; fbt->fbtp_savedval = *instr; fbt->fbtp_patchval = FBT_PATCHVAL; - fbt->fbtp_rval = DTRACE_INVOP_STP; + if ((*instr & SUB_MASK) == SUB_INSTR) + fbt->fbtp_rval = DTRACE_INVOP_SUB; + else + fbt->fbtp_rval = DTRACE_INVOP_STP; fbt->fbtp_symindx = symindx; fbt->fbtp_hashnext = fbt_probetab[FBT_ADDR2NDX(instr)];