From nobody Tue Jul 23 09:52:08 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 4WSsr8664zz5Rf2G; Tue, 23 Jul 2024 09:52: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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WSsr85Cxsz4v4N; Tue, 23 Jul 2024 09:52:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721728328; 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=m3WpA17tKKkJw5T8BcMRm3EK2EsTdKf2pvGeNxdWNzo=; b=laFTlWHlrt9e2hXpyxBew/ok1K8mVI4G9sj00L8rbsftB2ZQ/2mYjOEkzLu/Dey8PIyyq1 sWfGpCNzaywIyOi/Lxk7y4c4txaHiDhUC1/Hr2an+A8zAgVScHU+qJrZs6gFSfBnP1PmZM fB404n3JZ/GllCqRA3IzTkRiKEfWFaAKkiPcCMgoZRFk/1foKnBArJXP+OqEpuRPs8EmLp 4cKqqLvlaUR7BuViCvSMJ7IEC7pwnDK7N6U//spkGanYHdZUY5SntAfe2o3tws4tcngdfb EpZEw9fnNwOmzNoU76IvpQQyOId200KhElA2zkMp0y8Jb2HWDpFJ3vM6q97pOg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721728328; a=rsa-sha256; cv=none; b=TFYzKhF3HdmraRvd/L9TjTtel86f2u6UgNOTUtkYrxQd/Rkt06lI3HmG+5hWIXhFHzFfo3 3QW+HPJkoHBVXXa8fzIbXMzWlDJC6KO44rneRc9PxvM1H73D3ez065nH0jwZRWzxcRK27S 7QfYHx6xphwYZQ+dFQ6utLbQflkvIRy/AVhQymZBU/9mRxXbL5TYOaS/hfdPEErD5dCM8i hrk6ZjkdzoxBNE0YadPD/aBzCfX0g4UkPz3nSqxMsqTfqMsNbaPZlELZZ6UIuhzmp4ekxc QaQGeSRL3HVuSclSAMbt8A0xayQyJhv7kpj2yF2l8fYuTXDkmioONgEVNCPPNg== 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=1721728328; 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=m3WpA17tKKkJw5T8BcMRm3EK2EsTdKf2pvGeNxdWNzo=; b=WS9DqV/PCXtbB+gwIfsMkPwwA6EUfimMRncPWrtmiNKIobVyEZmRqN81yvzsigukH+ivKv 7heZiDBIeABBY3NnUtVNTSSKAgaHz7cLY+Fa8Mo/3P78duVZCtiPEdE80gvDnppKUiAzy1 a4SSVOqAJYc6JHjujcYLf2FNfrLxMzoDKBauJrSAAMC9ifAv1LSJw2ZGt2pwofXGq0rVj8 o43ISXjz3pQupLpDXa2c40XXb3SyL6HXAWgXfEKBMbuVIFlMgUNIDLipsxBf4xVCfi631i 8yLOg6E5/A4KEH7nyBt9A9LVuN8VX7OZBNi3tRbW2wu7Hs8M3vpykpLwtMDZIA== 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 4WSsr84qCkzPFR; Tue, 23 Jul 2024 09:52:08 +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 46N9q8qS061032; Tue, 23 Jul 2024 09:52:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46N9q8ex061029; Tue, 23 Jul 2024 09:52:08 GMT (envelope-from git) Date: Tue, 23 Jul 2024 09:52:08 GMT Message-Id: <202407230952.46N9q8ex061029@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: 997511dffe65 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 997511dffe651e1d2d708f37f2ced430a6ab3349 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=997511dffe651e1d2d708f37f2ced430a6ab3349 commit 997511dffe651e1d2d708f37f2ced430a6ab3349 Author: Andrew Turner AuthorDate: 2024-07-23 09:18:00 +0000 Commit: Andrew Turner CommitDate: 2024-07-23 09:25:05 +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 --- 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 d1120e0476a2..2680669c61f8 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -365,8 +365,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 */