From nobody Mon Sep 2 09:12:36 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 4Wy31c6lLFz5MqYS; Mon, 02 Sep 2024 09:12:36 +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 4Wy31c3FHSz4C9l; Mon, 2 Sep 2024 09:12:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725268356; 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=ynrU2FS91694aEVc1Q3rn0QXsOlZ3jsibjjRJYaENw4=; b=scmZwIa2F/NI79yHOtWxvCQiJfSR7qeVhP7TzLwAkQjmOixFhNbvQaKoDkUVOXVmTG2bNT s2djZ7iZJHhmrZBfU8okP40AvgsEUrNPBZm39Ld4XzHArmGYcXivyVfdIdFVXDx0dCw44g hJRUEb7q66d1g5ZqqZnmadaZQ5NEq4qHu9pNlgDwFX5xgwJWl2dzuEu4+vqr4bu+vPI+Tw E0XWupQRWbj/U4F2lLmxhNjMBH3bBjJj+FDRpATwrzmtR/y6GHu/yxLhTnl+d9zU/4fR1o lVV+HhjR/twkMyfOmd5Vu0aT0VYIRnw//IulT3Imcm/aR2L2/ogslD/4NMTOHQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725268356; a=rsa-sha256; cv=none; b=FU+iB32trgBb6vprWe8A7j/+wLJVwLPrJszRf8tMrCv4JsJgefUdwEJsGnEl+dL94PmiOs tToMCbUbVIM8f9mqlWKhslYguFfMlrBtCzUJ75cGw2cv4wzPeDY7qf7RgkPVFkcm4fJ3SV t0AroFezRo/dnIkDvc8k2V8mh4N9RyDrqjJ7xEaMoAya18OnfUDBpRNpi6eNGVot9n9CNW iDaVSUg+/QvfaA+k2KLevgulinMrn+DNnr4qRmzWVwGG74sNiu7NY3keBKA4qXr84MQ1rY 4g2ejUf6DFFW9557uCYx5GGLLtyfCBDteqTXJBV9NsL0N63YfhHZFZJUwaFbwA== 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=1725268356; 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=ynrU2FS91694aEVc1Q3rn0QXsOlZ3jsibjjRJYaENw4=; b=WqxpbGakwBkS7psXmHki5H3YLGyTivKr2sv2l/pYFnvmgBYNfJjlmwxqUTFUZeRnDXcG51 XriIBtzYYRYpzL1lWA1nVw83EW9Qtf9IpRmAgikNskolrdrNMc+W6se73ZoJfZZxi9Oqh0 aNHMu5rjFM+CqbChqYb8KhdLcsRfuLjb5s/E8rN7NzKsI8t2UuOwX28n4jG2TcEkQBwZ28 TrDfIwc/Jo5dH9WvRgwr/Aj7kZK2ENM9w3Dc4MMuLtEogGo07NfYzDoVAF0oBlDsG2qhXS sZT2rIBX8oYJ9Mim7GwRPQZSFzcCFPXcFTP6b3gDhNHgYDMgJTRUcpKmf8Of7g== 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 4Wy31c2sYTz16GZ; Mon, 2 Sep 2024 09:12:36 +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 4829CaCQ049489; Mon, 2 Sep 2024 09:12:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4829Cait049486; Mon, 2 Sep 2024 09:12:36 GMT (envelope-from git) Date: Mon, 2 Sep 2024 09:12:36 GMT Message-Id: <202409020912.4829Cait049486@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: 10595e9b2f65 - stable/13 - arm64: Support counter access with E2H 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/13 X-Git-Reftype: branch X-Git-Commit: 10595e9b2f659693c4e3d486a577c18f1d2e7efe Auto-Submitted: auto-generated The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=10595e9b2f659693c4e3d486a577c18f1d2e7efe commit 10595e9b2f659693c4e3d486a577c18f1d2e7efe Author: Andrew Turner AuthorDate: 2024-07-23 09:18:00 +0000 Commit: Andrew Turner CommitDate: 2024-09-02 09:11:57 +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 4bde1df945cb..007ffdcae513 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -273,8 +273,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 ff6aff00e226..0ed21bf311c7 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 */ #define CPTR_RES0 0x7fefc800