From nobody Thu Dec 12 18:19:00 2024 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 4Y8LMT0RLNz5gZn9; Thu, 12 Dec 2024 18:19:01 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y8LMS5bGvz3xP7; Thu, 12 Dec 2024 18:19:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734027540; 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=Em8S6LZnYx4CDFIAq94cf0OpV6l1yiG/Y/KzjlOsyAw=; b=ndPOeDbIMn17CLkubbMrPe4+PKsgk1fPA0qF9lOQ5lM74mWUTuWBvDj8ioButGz8zAfgS0 8X6A9BDFzlxfsDsPvbWeVJRCXBCelmZhbUFt3w36CsSZs+C1zqJpxDvXukCx8WXXQvKrAJ 4flyJbHlpDCrUvcFP5TfOHS6RnLHlL95pH4jNsFDz+U3HXKBBKR1T38H8ZQsqlQlVtGBpX Rw7KwT4WDI8gjWrMZDXTZ5DgHlgi1+xVywEBC1iAEkS1dAJyv8gZT9/d/kI80xSB9qQt1H E79rcBcPA5VJrYSNH80jpehulTbQQmCG5sXG78joX/wdx88lWr6dDFbIjRoAww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734027540; 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=Em8S6LZnYx4CDFIAq94cf0OpV6l1yiG/Y/KzjlOsyAw=; b=UBli5Q24qf6OzVfSRX7B8T8N162Ipsfn5khBQ6Q8GzWa12TDaAy6TVrq+gqBg0cftb60xV cZiugdYc05gmmXscJSyKl79W3ExNEhPETrEZ8iS9vxlzZZmsgV70Moq8y2zwcsGTB3whdq KrP/aFs0o8J58Uxr8zXO8p74lcFQUA6cJmWtp15jJWbY3ZX3Bhxt9tzNmJr2cF/P68PV1V DMZFm1Z/OyY7FDg5YWlZrTrfkQxnlA8mAHL7PKipyOnfozdIQF0boV+HzZE7EqxBwFQGbU az51QDJ1McpqqxT+wtg5Gk5z9JuE6GZaBmTI64TIfbxm8urCjU0zzx9allXrew== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734027540; a=rsa-sha256; cv=none; b=A5JHEhySzVMAsGq8J55EjfucyIS/UL3Yl/+tjzE0ijRzpPmHcgp+yieB4M0AvJRaXEF1mR SrBqylYnv71ROzIRPkG27RpLDyBqsyzI3rkSbwijgcFlrWPC6OYn24gnd0VZyXAisnNALa B5cfduwrE3XT9PvAmWQhrmxwRb+LNNcYyZu3VgZ+zbGBRVYYteWXOSGUPlad8tFaUVAIvW 4KK2d6DKPIDAbAA5yVf0J4/pm1fWKcH42bRNjqugKcyZPMRDlNX2SD4n6ze6YpXJnii9Np cCAR0W71euN6wkLQ/xotJt+zg9zQUvh+Ho5N4KOw2AxYLdMsguzXuaf4I6l72A== 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 4Y8LMS4j63z13Lw; Thu, 12 Dec 2024 18:19:00 +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 4BCIJ0Gq097124; Thu, 12 Dec 2024 18:19:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BCIJ0SF097121; Thu, 12 Dec 2024 18:19:00 GMT (envelope-from git) Date: Thu, 12 Dec 2024 18:19:00 GMT Message-Id: <202412121819.4BCIJ0SF097121@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: 938e4b131c48 - main - arm64: Use the PAN msr mnemonic rather than .inst 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/main X-Git-Reftype: branch X-Git-Commit: 938e4b131c483a05d5e5ea8f2bb44dfd1514868b Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=938e4b131c483a05d5e5ea8f2bb44dfd1514868b commit 938e4b131c483a05d5e5ea8f2bb44dfd1514868b Author: Andrew Turner AuthorDate: 2024-11-27 16:17:07 +0000 Commit: Andrew Turner CommitDate: 2024-12-12 18:00:22 +0000 arm64: Use the PAN msr mnemonic rather than .inst Switch from creating the msr instructions to manage PAN to use the "msr pan, #1" instruction directly. When this was added clang didn't have support to assemble the instructions. This appears to have been added to clang 13 which is sufficiently old enough. Binutils releases from around the same time appear to have added this instruction so any modern gcc should also support this instruction. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D47817 --- sys/arm64/arm64/machdep.c | 10 ++++------ sys/arm64/include/asm.h | 12 +++++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index b61fec3fdd11..03f041851c8f 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -187,11 +187,6 @@ pan_enable(void) { /* - * The LLVM integrated assembler doesn't understand the PAN - * PSTATE field. Because of this we need to manually create - * the instruction in an asm block. This is equivalent to: - * msr pan, #1 - * * This sets the PAN bit, stopping the kernel from accessing * memory when userspace can also access it unless the kernel * uses the userspace load/store instructions. @@ -199,7 +194,10 @@ pan_enable(void) if (has_pan) { WRITE_SPECIALREG(sctlr_el1, READ_SPECIALREG(sctlr_el1) & ~SCTLR_SPAN); - __asm __volatile(".inst 0xd500409f | (0x1 << 8)"); + __asm __volatile( + ".arch_extension pan \n" + "msr pan, #1 \n" + ".arch_extension nopan \n"); } } diff --git a/sys/arm64/include/asm.h b/sys/arm64/include/asm.h index 16be39b3eae4..cc0a7d8293c9 100644 --- a/sys/arm64/include/asm.h +++ b/sys/arm64/include/asm.h @@ -87,19 +87,25 @@ ldr tmp, =has_pan; /* Get the addr of has_pan */ \ ldr reg, [tmp]; /* Read it */ \ cbz reg, 997f; /* If no PAN skip */ \ - .inst 0xd500409f | (0 << 8); /* Clear PAN */ \ + .arch_extension pan; \ + msr pan, #0; /* Disable PAN checks */ \ + .arch_extension nopan; \ 997: #define EXIT_USER_ACCESS(reg) \ cbz reg, 998f; /* If no PAN skip */ \ - .inst 0xd500409f | (1 << 8); /* Set PAN */ \ + .arch_extension pan; \ + msr pan, #1; /* Enable PAN checks */ \ + .arch_extension nopan; \ 998: #define EXIT_USER_ACCESS_CHECK(reg, tmp) \ ldr tmp, =has_pan; /* Get the addr of has_pan */ \ ldr reg, [tmp]; /* Read it */ \ cbz reg, 999f; /* If no PAN skip */ \ - .inst 0xd500409f | (1 << 8); /* Set PAN */ \ + .arch_extension pan; \ + msr pan, #1; /* Enable PAN checks */ \ + .arch_extension nopan; \ 999: /*