From nobody Tue Feb 22 16:40:20 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 B0FAD19E0A38; Tue, 22 Feb 2022 16:40:21 +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 4K34fF1mt0z3KXb; Tue, 22 Feb 2022 16:40:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645548021; 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=uHjYwTSBH4YFOFDhXDw4tK/6kx90qTriWx3kcDEvJGE=; b=fHZ2IoahwVyf8f3nLMRgHPOQvCQfKj75v9uy65L2CszDH9h7WWmCaVETiKTvSuSb+05VvN VUyMDzZNcV2rpEthvkM5MRTkrRztrmVLmKLTRRpqqagbn75wakouI++UgYU0X5gBBH1EJb G8GNM5Tllh0DLPgBkCPV5JT8UeXkVPBAt7fmj1GtScNgbXdQbMTtetNziREaW/IL4SmSOR tgxuQpXnslWv10lkugtsr3Ha48vgc3ubcULA0KhL7QZfzCrVUfWpg435GVmZV9en+cMUQk h7AGL2nTtUWxl4f5glosDq9A87osuTWt2yFaqSQXy4fPAwqm7gIgL9FIAa6OKg== 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 E071527659; Tue, 22 Feb 2022 16:40:20 +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 21MGeKeu063136; Tue, 22 Feb 2022 16:40:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21MGeK9b063130; Tue, 22 Feb 2022 16:40:20 GMT (envelope-from git) Date: Tue, 22 Feb 2022 16:40:20 GMT Message-Id: <202202221640.21MGeK9b063130@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: 61a7ad35bb20 - stable/13 - Teach DTrace about BTI on arm64 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: 61a7ad35bb20b00755515e484583b92b07c1923d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645548021; 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=uHjYwTSBH4YFOFDhXDw4tK/6kx90qTriWx3kcDEvJGE=; b=u2LZexni35HbtFup2I0BT4w+iru/hQ/nrN7MvtLQfkDoAH1T/zpW2fDEH8j3l+8S0eRO8q inuuxmAJE/0sau7b9LKXo+/tUjJcp99fXAHWKSurWBBrfDVdQSqRfX4dUi1PSEiZfF4MBh xDoof2QNyUvCNea67XwQF56O8QD5CZHbUqCqt3bExU1i58zjcT3tZyg8dISohxxCr/aknn 0xjHWVggN9NaZVjGBwEMmhoBHCEgWCAhbGnnzw+Qj6VrWXkrCnIVSIB8EX+cg57LqOVP7T PkHKnMAuG7ZfrBqub/0dkA48R4Q4dN5Pjvh0wCEWtxfNVImXFoJxh/WmZosYmw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645548021; a=rsa-sha256; cv=none; b=ELWpGegTInC/8yZ3zItPnPBHF+c4sPlnyAUzCCJlxF1aCWrcsRNRH1Q1nvYTrtJZQIhDhl c3TMo7k91hI8r45bosjSxlklgQ/OvEBaG5sv90+CU9cyIdCjeOEJTWIdkW87SJmV1vbxuD LsWcQRb69rSMH7SINffDC42619aAB4roxIFsWmwiGuZsIqVGItCcsBwMSYYE3BtMtY6FSH YuN2ps93911XnWVCqjWyQEFUT4Evoi7dlIJTZY7pv17ahqoMbVmQGeBsqc1hVX2flEiiEb CoSXJe73NSICnU/prlTGNREzWfGdncJGFkf1OqXucNQUeXy6EUu0DEkaXZ6EEQ== 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=61a7ad35bb20b00755515e484583b92b07c1923d commit 61a7ad35bb20b00755515e484583b92b07c1923d Author: Andrew Turner AuthorDate: 2021-12-22 17:26:33 +0000 Commit: Andrew Turner CommitDate: 2022-02-22 16:23:07 +0000 Teach DTrace about BTI on arm64 The Branch Target Identification (BTI) Armv8-A extension adds new instructions that can be placed where we may indirrectly branch to, e.g. at the start of a function called via a function pointer. We can't emulate these in DTrace as the kernel will have raised a different exception before the DTrace handler has run. Skip over the BTI instruction if it's used as the first instruction in a function. Sponsored by: The FreeBSD Foundation (cherry picked from commit b5876847acfeae2dd3a655cde8cdf6145aed16d8) --- sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h | 3 +++ sys/cddl/dev/fbt/aarch64/fbt_isa.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h index f15a971f12be..c15cc39189b1 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h +++ b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h @@ -2466,6 +2466,9 @@ extern void dtrace_helpers_destroy(proc_t *); #define B_DATA_MASK 0x00ffffff #define B_INSTR 0x14000000 +#define BTI_MASK 0xffffff3f +#define BTI_INSTR 0xd503241f + #define NOP_INSTR 0xd503201f #define RET_INSTR 0xd65f03c0 diff --git a/sys/cddl/dev/fbt/aarch64/fbt_isa.c b/sys/cddl/dev/fbt/aarch64/fbt_isa.c index d00aabf0cc81..07f02e2edb72 100644 --- a/sys/cddl/dev/fbt/aarch64/fbt_isa.c +++ b/sys/cddl/dev/fbt/aarch64/fbt_isa.c @@ -118,6 +118,14 @@ fbt_provide_module_function(linker_file_t lf, int symindx, instr = (uint32_t *)(symval->value); limit = (uint32_t *)(symval->value + symval->size); + /* + * Ignore any bti instruction at the start of the function + * we need to keep it there for any indirect branches calling + * the function on Armv8.5+ + */ + if ((*instr & BTI_MASK) == BTI_INSTR) + instr++; + /* Look for stp (pre-indexed) operation */ found = false; /*