From nobody Tue Feb 22 16:40:19 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2AE2F19E0B8D; Tue, 22 Feb 2022 16:40:20 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K34fD08M4z3KN6; Tue, 22 Feb 2022 16:40:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645548020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=c5gCnvGPYX53Ve/eNBB2qL5CQBHRPXotI8s9adtaAso=; b=jef6IlAfniSMFqdUN+iI32KxYQ9mFekNgd72kosmid+01Xjkj14b8wKPWiRZy/jJaRFnYk aYVgtTG+VJyKwiki3W+dciJClHjUd/AaGReQfEIuRgiN70A4LLcXFY9TkaxKF6RJMkKEny 9pZIha2KVm0NN8zKLICqEJJZPivSgmEFqQGbKxSkhGHxYqJzwy+lT3TjAh6J6olwc5l9Gs o2PhijF0PfT3MXvcWOFXwnu53gwgAY+O266n2qT+7ZLU8RKRAiNbr+1uNdqM72BhKiCRxg SF+4DU5xmc/oTWKRy3wL3cJUVfTHmlI+0GrtpfQOpWVukQaT++Q7Bm4jP20JXg== 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 CBCAC275DF; Tue, 22 Feb 2022 16:40:19 +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 21MGeJN6062620; Tue, 22 Feb 2022 16:40:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21MGeJDh062614; Tue, 22 Feb 2022 16:40:19 GMT (envelope-from git) Date: Tue, 22 Feb 2022 16:40:19 GMT Message-Id: <202202221640.21MGeJDh062614@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: efe35aecb801 - stable/13 - Handle functions that use a nop in the arm64 fbt List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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/stable/13 X-Git-Reftype: branch X-Git-Commit: efe35aecb801d5f361ab1adb159a65ac141c3435 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645548020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=c5gCnvGPYX53Ve/eNBB2qL5CQBHRPXotI8s9adtaAso=; b=XRQB4v4AUo3dCGzkL8gna569RQN20geprSF94M1u7f5C9WLvLYxpKT9Dr0heqH+9PstLyJ +pBzsgZJIFBBzlaeEIHuhQLYJqliOMP00ulE3NzBD3FAnpDPuRG1uvL37wMA4COpydyPTt qdLWkHcSOeXQxCCEjWWr/bx9+sDWVIYTJ/+c9Jl1+8hP+yxu2yyva00SvNIPe233oLbu+t MNnx9FJ9co0jh7L87xXqJKEZ94fWFKMW/QJX3u4jG7Mn5j5fstoj0SzIvk+M9C3kA8ODxk +YUT0YEn1djlK9vOTs9GzSqnuGJcljZE4WklOMV5jYcphrsF7qjgula0WCv7aw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645548020; a=rsa-sha256; cv=none; b=CZXCZ4YAjxQtwxRDu3tHk/GEpHuYCyRFHDfPwoR2PhDjXtXjTUeFUiHEBBzTgGn81180EL Xy0pXh1T4ej9ph0Im5xA+uNKCNm9ZFC/4hJ1rSijPykb5hAiDz95qsytrJFLHecqwOoYi9 POneuIJOd6CnL5+YZs0NH9IU3kb5VTZUMlMGtVnVK9QWkq1kwFUkDqWzNU7o2xoMHhHbPk g/bT9uMigYgKtEEmoEVzKxmFQ3ppFLPwiq5urHlXTPKt39LzkmOKYujeJmPLnZN7necZjd lBqUkMYZUrL2D4TcezowBfgQGPMrZVisvZ/AmWjO/35iwyzrSlYttwfkVaycpQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=efe35aecb801d5f361ab1adb159a65ac141c3435 commit efe35aecb801d5f361ab1adb159a65ac141c3435 Author: Andrew Turner AuthorDate: 2021-01-13 11:08:19 +0000 Commit: Andrew Turner CommitDate: 2022-02-22 16:23:07 +0000 Handle functions that use a nop in the arm64 fbt To trace leaf asm functions we can insert a single nop instruction as the first instruction in a function and trigger off this. Reviewed by: gnn Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D28132 (cherry picked from commit 28d945204ea1014d7de6906af8470ed8b3311335) --- sys/arm64/include/asm.h | 8 +++- .../contrib/opensolaris/uts/common/sys/dtrace.h | 2 + sys/cddl/dev/dtrace/aarch64/dtrace_subr.c | 5 +++ sys/cddl/dev/fbt/aarch64/fbt_isa.c | 51 ++++++++++++++-------- 4 files changed, 46 insertions(+), 20 deletions(-) diff --git a/sys/arm64/include/asm.h b/sys/arm64/include/asm.h index 05e618500e59..32b79d256e80 100644 --- a/sys/arm64/include/asm.h +++ b/sys/arm64/include/asm.h @@ -38,9 +38,15 @@ #define _C_LABEL(x) x +#ifdef KDTRACE_HOOKS +#define DTRACE_NOP nop +#else +#define DTRACE_NOP +#endif + #define LENTRY(sym) \ .text; .align 2; .type sym,#function; sym: \ - .cfi_startproc + .cfi_startproc; DTRACE_NOP #define ENTRY(sym) \ .globl sym; LENTRY(sym) #define EENTRY(sym) \ diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h index 2bedd01cf3e7..f15a971f12be 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h +++ b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h @@ -2466,6 +2466,8 @@ extern void dtrace_helpers_destroy(proc_t *); #define B_DATA_MASK 0x00ffffff #define B_INSTR 0x14000000 +#define NOP_INSTR 0xd503201f + #define RET_INSTR 0xd65f03c0 #define SUB_MASK 0xffc00000 diff --git a/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c b/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c index ede6353a803f..74b3bf7ed7d1 100644 --- a/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c +++ b/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c @@ -314,6 +314,11 @@ dtrace_invop_start(struct trapframe *frame) return (0); } + if (invop == NOP_INSTR) { + 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 adc355e3296b..d00aabf0cc81 100644 --- a/sys/cddl/dev/fbt/aarch64/fbt_isa.c +++ b/sys/cddl/dev/fbt/aarch64/fbt_isa.c @@ -120,28 +120,41 @@ fbt_provide_module_function(linker_file_t lf, int symindx, /* Look for stp (pre-indexed) operation */ found = false; - for (; instr < limit; instr++) { - /* Some functions start with "stp xt1, xt2, [xn, ]!" */ - if ((*instr & LDP_STP_MASK) == STP_64) { + /* + * If the first instruction is a nop it's a specially marked + * asm function. We only support a nop first as it's not a normal + * part of the function prologue. + */ + if (*instr == NOP_INSTR) + found = true; + if (!found) { + for (; instr < limit; instr++) { /* - * Assume any other store of this type means we - * are past the function prolog. + * Some functions start with + * "stp xt1, xt2, [xn, ]!" */ - if (((*instr >> ADDR_SHIFT) & ADDR_MASK) == 31) - found = true; - break; - } + if ((*instr & LDP_STP_MASK) == STP_64) { + /* + * Assume any other store of this type means we + * are past the function prolog. + */ + if (((*instr >> ADDR_SHIFT) & ADDR_MASK) == 31) + 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; + /* + * 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; + } } }