From nobody Sun Apr 23 17:56:07 2023 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 4Q4GCX5ZdZz46FCB; Sun, 23 Apr 2023 17:56:08 +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 4Q4GCW6rjTz42Gn; Sun, 23 Apr 2023 17:56:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682272568; 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=8KbV0XCcS32Ki+y633Kco14/1Laf4bKEwEExBF0nkew=; b=E5Zu5Pt7AsYa3tXMB2RRdh5cZ2LjE8Mqxv5zEIAqKGCPPE1qNLq/1OHcWDAZx+aJ7V4GKN Xlo+fiyr2LV8NPLjM1GbpqPv91fJveO0pBmHAIec6wW4JV9oeMuX4ffcF3pKMVHIYL1HO0 44cWItI0lIYb9CZkpb07JlEDLbAhWiJib6H8xNfcae6Dv5F+Azi8JdJrM6aUTyPHOgZ43d YVEkq6x7IuiG7ROlIA/Tw/gUK8CD0fTPfLYJYeHQOeKQ7cGWEJP5VTnARwwUMrginLCaiZ mg9QJiDpKN18VYOw86+nZAahZOB1PNoTpy0ZVVm3ciJLpNAxf0CA0TAeMm5iAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682272568; 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=8KbV0XCcS32Ki+y633Kco14/1Laf4bKEwEExBF0nkew=; b=Sr2O2Y8hUk+Jx9QkBixsPnIVtOlKq4QfVoYXYn8nElsJHmFCClNeXqI/ouD9ODaV92JVXb v2NRHPBcKn8kL9w95gmZSG7UnDSwKV0qr0d9ZpxAT0O1YIevKrLV4ebD+Y+LdkzYU0iq0F xxNKAWEG09L0KMUrb20vqiFb5Hwsb7z88KGTmv32fGSjZjGbTiGoeNQvk4R4EvwyfPLza6 hyYIcstGHq85UXPSVrX0oYyo2KCsOyhL9ZsrO7YGreHgV8O0BQBxVLT9UrsWry96bDR0Zh ahR36BXSf2uJ1qVvk3zLbEj49kl6RBoye+H/vmwXae+z6uDWNySOXpmHbz94Ig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682272568; a=rsa-sha256; cv=none; b=BmavIGPovukg7gkLpMcr8LUg6mBViL5wUSVTjoNJnNI3KA8T9Jw4Vh1PwoGNxqNUIG7J2i 5NYS6F3c333wklHEB1SPy5Vv8v0Z5bsr3GPn1Ba7ZP5ZkxhkjA7ScqmcQBnkenv0ytrl7j up2Gwm0LBkVp4BJWkQ3WDbeCzwWAF5HJ9prH3WRY+36R54jB1rLuIaxyyfYg3ijJJRN/mD iCfHgzFe8M7EKt0fb1PwQz64b1qetpUj/bfYyTYUfiln+TEZ1w6dafzfOlF66FWfCoRSQC RUGeFgh7oKqnVCb/7wUza5XkS3CbFGBEHo9aedg3o8SjTHnQlxutF7cdif8vqg== 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 4Q4GCW5vp8zsRB; Sun, 23 Apr 2023 17:56:07 +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 33NHu7RV026471; Sun, 23 Apr 2023 17:56:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33NHu7lv026470; Sun, 23 Apr 2023 17:56:07 GMT (envelope-from git) Date: Sun, 23 Apr 2023 17:56:07 GMT Message-Id: <202304231756.33NHu7lv026470@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4b39a12830fe - main - arm64: Disable PAC when booting on a Windows Dev Kit 2023 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4b39a12830feaf2ac49b157ed079c04114b1a3ca Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4b39a12830feaf2ac49b157ed079c04114b1a3ca commit 4b39a12830feaf2ac49b157ed079c04114b1a3ca Author: Mark Johnston AuthorDate: 2023-04-23 17:32:45 +0000 Commit: Mark Johnston CommitDate: 2023-04-23 17:55:57 +0000 arm64: Disable PAC when booting on a Windows Dev Kit 2023 It appears that PAC registers are configured to trap upon access, but since the kernel starts in EL1 on this platform it has no ability to inspect or modify this configuration. Simply disable PAC on this platform for now, since the kernel otherwise hangs during boot. PR: 270472 Reviewed by: andrew, emaste MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D39748 --- sys/arm64/arm64/ptrauth.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/sys/arm64/arm64/ptrauth.c b/sys/arm64/arm64/ptrauth.c index 5c129820cd37..f7bba82ab9d1 100644 --- a/sys/arm64/arm64/ptrauth.c +++ b/sys/arm64/arm64/ptrauth.c @@ -59,6 +59,31 @@ struct thread *ptrauth_switch(struct thread *); void ptrauth_exit_el0(struct thread *); void ptrauth_enter_el0(struct thread *); +static bool +ptrauth_disable(void) +{ + const char *family, *maker, *product; + + family = kern_getenv("smbios.system.family"); + maker = kern_getenv("smbios.system.maker"); + product = kern_getenv("smbios.system.product"); + if (family == NULL || maker == NULL || product == NULL) + return (false); + + /* + * The Dev Kit appears to be configured to trap upon access to PAC + * registers, but the kernel boots at EL1 and so we have no way to + * inspect or change this configuration. As a workaround, simply + * disable PAC on this platform. + */ + if (strcmp(maker, "Microsoft Corporation") == 0 && + strcmp(family, "Surface") == 0 && + strcmp(product, "Windows Dev Kit 2023") == 0) + return (true); + + return (false); +} + void ptrauth_init(void) { @@ -77,7 +102,11 @@ ptrauth_init(void) return; } - get_kernel_reg(ID_AA64ISAR1_EL1, &isar1); + if (!get_kernel_reg(ID_AA64ISAR1_EL1, &isar1)) + return; + + if (ptrauth_disable()) + return; /* * This assumes if there is pointer authentication on the boot CPU