From nobody Mon Sep 02 08:50:44 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 4Wy2XP12VMz5Mp6S; Mon, 02 Sep 2024 08:50:45 +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 4Wy2XN5sJWz429t; Mon, 2 Sep 2024 08:50:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725267044; 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=eV6CQl0VlKdI9NT4xTJ1rGq5g3zFe/FrM2aG96E0gt0=; b=pGOO2+FCtp1DH8fLMZueLR/CwFILZB1j5sEXLkm6hSlZSCL34k80Z+W+6ObeT0X+WZWPnM PzhNES9qIRDorwSIhRpLxiEprk998M1GBGHb51rW/Wv9aWWpcDcbkNQ4DWskE3WdDJcvw4 6DEDz4RwGZWaMiatQHPg6tNo4jCkzX8NFN0jSZY3SJf5rbgRSGTyYpIgCxjvxXMzqbXuNh 46/I2kwsPg24gPdlh6689Qfick9EPq3tBVCYmBJ1XwQG70trwMyKkGUuDWQF78exHtVus7 knReOxFLrdNjBhbw9IyPIENc4VF2CHYbHFuB+Lug/EzwfSTYpQOUfvjA1oCBow== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725267044; a=rsa-sha256; cv=none; b=LQF3gPjrBMoQ0XkYRyneZhZnzGIVncSWq4dSno0N5+qrrpfwrTVjCOw1lbrNwjY4RpRJjm qckT5o0F71ZvZSycKCJ20pq45t47KLDjjnkFCgXcQIBfWf5+aLa8E5oVlA2GTBOzSWkujC 1MMhN5xk9MHccEH8FNrkKmdR50KW1VuulRYNu6sn0wDKoT025CrU9xvyK8tEUUQMsqdv+A IrXeyQWjO1NGRktDfQ70631lcZY9aNIacwZfB9L3S5MZITq7jDoTgOczRIy/bjNQVUUuy6 XxvfGWZNG32USOMV/KdNeMZlTrSKq4THyrk3aAWXeVeFpkztUqjrHQ8jRP78HA== 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=1725267044; 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=eV6CQl0VlKdI9NT4xTJ1rGq5g3zFe/FrM2aG96E0gt0=; b=D+Mu98VL8U/zEaHuS1ATKJ3Q24DQImDLIU4UQJe6NRI3uRbutR2LEwSV96GGxboubl13u6 rumcT2fuagBce170yzD+/7+OATz5WVSy8hfgaWgmuao+3Kjh27zUAvlUh/BoAQ2JOy9Vp3 ZZu5PGn8NQHHRG5UWgYEPUy/zYYh5jQeensdCH6QtTp+/IrhE4czLFo9ywtyAed1Gm6arh IvzI0u/xwHmEHJ3NeMl+jm9cfUfpy7b+sjqLbWHv0wQkJkDtBKln5Dzdi7hAbDznjuZdOK qBupbrG0/8Y0BxvccWdM3W0DfZzQo/vJRrLAa2FydJrsoMWP6nJk5CztP7bT3w== 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 4Wy2XN5Bgqz153X; Mon, 2 Sep 2024 08:50:44 +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 4828oivR007199; Mon, 2 Sep 2024 08:50:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4828oioQ007196; Mon, 2 Sep 2024 08:50:44 GMT (envelope-from git) Date: Mon, 2 Sep 2024 08:50:44 GMT Message-Id: <202409020850.4828oioQ007196@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: 570fae59a8bf - stable/14 - arm64: Support counter access with E2H 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 570fae59a8bf9ded19c4de9bf001ee0fa2cf7229 Auto-Submitted: auto-generated The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=570fae59a8bf9ded19c4de9bf001ee0fa2cf7229 commit 570fae59a8bf9ded19c4de9bf001ee0fa2cf7229 Author: Andrew Turner AuthorDate: 2024-07-23 09:18:00 +0000 Commit: Andrew Turner CommitDate: 2024-09-02 08:48:25 +0000 arm64: Support counter access with E2H When entering the kernel with the E2H field set the layout of the cnthctl_el2 register changes. Use the correct field locations to enable access to the counter and timer registers from EL1. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D45529 (cherry picked from commit 997511dffe651e1d2d708f37f2ced430a6ab3349) --- sys/arm64/arm64/locore.S | 6 ++++-- sys/arm64/include/hypervisor.h | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S index 9f3739c85534..e637749b1321 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -317,8 +317,10 @@ LENTRY(enter_kernel_el) msr hstr_el2, xzr /* Enable access to the physical timers at EL1 */ - mrs x2, cnthctl_el2 - orr x2, x2, #(CNTHCTL_EL1PCTEN | CNTHCTL_EL1PCEN) + tst x4, #HCR_E2H + ldr x3, =(CNTHCTL_EL1PCTEN | CNTHCTL_EL1PCEN) + ldr x5, =(CNTHCTL_E2H_EL1PCTEN | CNTHCTL_E2H_EL1PTEN) + csel x2, x3, x5, eq msr cnthctl_el2, x2 /* Set the counter offset to a known value */ diff --git a/sys/arm64/include/hypervisor.h b/sys/arm64/include/hypervisor.h index 85ac5cda7037..418047cb22f2 100644 --- a/sys/arm64/include/hypervisor.h +++ b/sys/arm64/include/hypervisor.h @@ -37,10 +37,15 @@ /* CNTHCTL_EL2 - Counter-timer Hypervisor Control register */ #define CNTHCTL_EVNTI_MASK (0xf << 4) /* Bit to trigger event stream */ +/* Valid if HCR_EL2.E2H == 0 */ +#define CNTHCTL_EL1PCTEN (1 << 0) /* Allow physical counter access */ +#define CNTHCTL_EL1PCEN (1 << 1) /* Allow physical timer access */ +/* Valid if HCR_EL2.E2H == 1 */ +#define CNTHCTL_E2H_EL1PCTEN (1 << 10) /* Allow physical counter access */ +#define CNTHCTL_E2H_EL1PTEN (1 << 11) /* Allow physical timer access */ +/* Unconditionally valid */ #define CNTHCTL_EVNTDIR (1 << 3) /* Control transition trigger bit */ #define CNTHCTL_EVNTEN (1 << 2) /* Enable event stream */ -#define CNTHCTL_EL1PCEN (1 << 1) /* Allow EL0/1 physical timer access */ -#define CNTHCTL_EL1PCTEN (1 << 0) /*Allow EL0/1 physical counter access*/ /* CPTR_EL2 - Architecture feature trap register */ /* Valid if HCR_EL2.E2H == 0 */