From nobody Mon Jul 15 12:38:24 2024 X-Original-To: dev-commits-src-branches@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 4WN1vj1yLtz5Qrnc; Mon, 15 Jul 2024 12:38:25 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WN1vj0LC2z4Hpd; Mon, 15 Jul 2024 12:38:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721047105; 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=+9ewlpC9HgAm8eUKgy12+8gtMbehKT0lgH+fMe6L2yg=; b=fgYxPXPNH62b+NNsoA1y04Dov58jq4RvLSOseIr1thbcvgcFLsDTXokSfcIHZJm2AqJ3Ig M7gk+ea8FbaTv0LjlcwNcxhl8F21ZwCEAJXCn5K9XLv47jz4rcBFoi9AWhq34UtM6Of9Vo plaVhW+dSMsQDe2N/b9SmlnLuaWDuSDJ8hEYAC4rQ20+6NsZrzwa84TK5lfFv2u+Q64qkM LeV2q2pQQ4NKbTkan034HijVKn/AXtHBtZAPbjDoM1XpNrKb4DjRPuFXlr2XUpufUrY9/E jNaRF8BqOisDUGsfwgKGTomuLRyxBrqlPoHjTHg6aA6eQo2CFpR1gm7Zsm+urA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721047105; a=rsa-sha256; cv=none; b=Be0m93CylmpDz//gsE5FtXU6xfqRPsuPo6+H/cpmSGRrf6K6F8LoO+QJGuQ23u0+hes/Gr Pyj6WRRJdh+ozToN9srPzIR11B30cm44hFS16aDq0jzBnKO7w/lREdAi6qqgWNgRp6gkvZ kr4lUBQa6z4ztc+1KeVp5r4FOhcATaScIDCsjNnOpMOwMMBkWr+g8vnqZYYe3L/0J6Q4YY saAQ6ArftWz4jbt1MM3RNipchW2lkl6vA1vjmmvYTtPjEnO0PNX4A4wCXOott+kyQoMjOV yLd9g4zKubr0uBVGoQ6ADSN/ERiQEDAenK0eDkGXIU4XDhXCZtCcq8yr3nYzyQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721047105; 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=+9ewlpC9HgAm8eUKgy12+8gtMbehKT0lgH+fMe6L2yg=; b=s6wsfIkCTTSaBZAffNcv6WSB8MshB6H2dQejkLySa78Hdkl8uZb3vcaRrK0xxBrpQqNwOc do/bzKeRxni32a4Rq03vPRvUka+O9l9xiS3tF9+raub+wtlA40xWTCXxxXsZ0dtdAVbmcJ oLaHJZUrOCoSW6guh7g0qoyrjqsVvJsrUVmZyiRAo0FRV8l1TsY1tb0hSarxN7V2PXRJ1b 62yxq2pwWw9Jm4FE72mWpGXbkV/9RFjedJZ35Q8TH4zy4Ym5OES9CulowabX86yhVBMDAa XjCmYrudAdnfYANs1qPC1MqR7UlDnTqaNZibR9Ah2wshzdRSk+lrkEWPkC3ecg== 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 4WN1vh74RPzt5j; Mon, 15 Jul 2024 12:38:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46FCcOPl061230; Mon, 15 Jul 2024 12:38:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46FCcOhv061227; Mon, 15 Jul 2024 12:38:24 GMT (envelope-from git) Date: Mon, 15 Jul 2024 12:38:24 GMT Message-Id: <202407151238.46FCcOhv061227@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: 81e973eaf95e - stable/14 - arm64: Use the pointer auth register defines List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/14 X-Git-Reftype: branch X-Git-Commit: 81e973eaf95ee62d83129eea83f610ba829229f8 Auto-Submitted: auto-generated The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=81e973eaf95ee62d83129eea83f610ba829229f8 commit 81e973eaf95ee62d83129eea83f610ba829229f8 Author: Andrew Turner AuthorDate: 2024-05-22 08:19:06 +0000 Commit: Andrew Turner CommitDate: 2024-07-15 12:27:23 +0000 arm64: Use the pointer auth register defines When building with gcc it complains the pointer authentication registers aren't valid with the architecture level we are targeting. Fix this by using the alternative spelling of these registers accesses through MRS_REG_ALT_NAME. Reviewed by: jhb Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D45263 (cherry picked from commit 73c200447361a649e00cdb1693a0ae7f3291914e) --- sys/arm64/arm64/ptrauth.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/sys/arm64/arm64/ptrauth.c b/sys/arm64/arm64/ptrauth.c index 03610e9313f5..c7cf47f8a6cd 100644 --- a/sys/arm64/arm64/ptrauth.c +++ b/sys/arm64/arm64/ptrauth.c @@ -170,13 +170,11 @@ ptrauth_thread_alloc(struct thread *td) * Load the userspace keys. We can't use WRITE_SPECIALREG as we need * to set the architecture extension. */ -#define LOAD_KEY(space, name) \ -__asm __volatile( \ - ".arch_extension pauth \n" \ - "msr "#name"keylo_el1, %0 \n" \ - "msr "#name"keyhi_el1, %1 \n" \ - ".arch_extension nopauth \n" \ - :: "r"(td->td_md.md_ptrauth_##space.name.pa_key_lo), \ +#define LOAD_KEY(space, name, reg) \ +__asm __volatile( \ + "msr "__XSTRING(MRS_REG_ALT_NAME(reg ## KeyLo_EL1))", %0 \n" \ + "msr "__XSTRING(MRS_REG_ALT_NAME(reg ## KeyHi_EL1))", %1 \n" \ + :: "r"(td->td_md.md_ptrauth_##space.name.pa_key_lo), \ "r"(td->td_md.md_ptrauth_##space.name.pa_key_hi)) void @@ -188,7 +186,7 @@ ptrauth_thread0(struct thread *td) /* TODO: Generate a random number here */ memset(&td->td_md.md_ptrauth_kern, 0, sizeof(td->td_md.md_ptrauth_kern)); - LOAD_KEY(kern, apia); + LOAD_KEY(kern, apia, APIA); /* * No isb as this is called before ptrauth_start so can rely on * the instruction barrier there. @@ -241,8 +239,8 @@ ptrauth_mp_start(uint64_t cpu) __asm __volatile( ".arch_extension pauth \n" - "msr apiakeylo_el1, %0 \n" - "msr apiakeyhi_el1, %1 \n" + "msr "__XSTRING(APIAKeyLo_EL1_REG)", %0 \n" + "msr "__XSTRING(APIAKeyHi_EL1_REG)", %1 \n" ".arch_extension nopauth \n" :: "r"(start_key.pa_key_lo), "r"(start_key.pa_key_hi)); @@ -258,7 +256,7 @@ struct thread * ptrauth_switch(struct thread *td) { if (enable_ptrauth) { - LOAD_KEY(kern, apia); + LOAD_KEY(kern, apia, APIA); isb(); } @@ -272,7 +270,7 @@ ptrauth_exit_el0(struct thread *td) if (!enable_ptrauth) return; - LOAD_KEY(kern, apia); + LOAD_KEY(kern, apia, APIA); isb(); } @@ -283,11 +281,11 @@ ptrauth_enter_el0(struct thread *td) if (!enable_ptrauth) return; - LOAD_KEY(user, apia); - LOAD_KEY(user, apib); - LOAD_KEY(user, apda); - LOAD_KEY(user, apdb); - LOAD_KEY(user, apga); + LOAD_KEY(user, apia, APIA); + LOAD_KEY(user, apib, APIB); + LOAD_KEY(user, apda, APDA); + LOAD_KEY(user, apdb, APDB); + LOAD_KEY(user, apga, APGA); /* * No isb as this is called from the exception handler so can rely * on the eret instruction to be the needed context synchronizing event.