From nobody Tue Jun 25 09:31:28 2024 X-Original-To: dev-commits-src-main@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 4W7fjF3F16z5P9gb; Tue, 25 Jun 2024 09:31:29 +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 4W7fjF0hmsz4KvB; Tue, 25 Jun 2024 09:31:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719307889; 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=XNz0Am3oN7sMznN8dakPKx+NS60Ed/yf9UCH3P65dFY=; b=cAhp6WGu/IE9ZxCwyhugDQnqRRyqGawjJRrxemCE9bdzPhCiBzKdRYYxQx8xX1XEJL8EWC VMTwStD+CiBfrahyF7b6vEo6YpuHnbUchhUcg6JxlGAQM2BLSKP9E3wBH8RFwa4HGido6X fJNfgkeFjfvRLzofqYcKp4tY8ljWMxqJV/mA1wd5CVG82hK9ylJcT3J3Lw3/2eyf0E2KEf qhhFfXJXJtdDbOLh2BwaoyBA5z3a1y43actPVFqp3P/JRT22gbLuM9kZsaaYHvnx8hmM/2 8wbIl3D/mJ+id80cvrXRT1jK7JDPoeGqC4Ws/HQY36EU+6a9h+m9Mt1UVXVlqg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719307889; a=rsa-sha256; cv=none; b=lmKw5arB+vYiewezZqJcwft0RSScrzFMvc4Cb333zxYvLZwH08sbPR3PwFCRMX9VyjbmZb Z/jVYUU7ydpsG/aQwfb9zTmFF2aTsA40niX/GNdRUOb0B9/r54gIJVeSrC4VUQ3EalpWri 3IPTtkm838WjnrhKyyGzC2vI8HW8Erwr4A0touWO23QgHqVkTN2maOxBidwZyDlbD4+ZUa RdXPBgJmtINA664NBG3SMpH9hdzo3QZJ+yyQ7fbIc4eaKzqbuFghd5P8dNzMh8PI31fVkp Jr7scXy3IZhEsPhA2EoeX4aIZCPFg+P13iClBaDmE3FOAi91mPT077Fb9/Om1A== 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=1719307889; 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=XNz0Am3oN7sMznN8dakPKx+NS60Ed/yf9UCH3P65dFY=; b=wX8Pn91jbV0GCaONkD1t/m/iKQyBrz1mUIbiV57XT/p4D8F3sRxF2tSRJYlIn3EtPc4EsS A5mgok4T0wnGKYkEyX+vK3KPtVFj7trw7K2UvClRahBt46Vkc2U5tcEaurTm6odo0ZqXmJ s33dUJ1ItAN4oZlf5ixsrs+vsBF/zUB4Z6keWs9lCDiKigLm5MnqoXtMsAYDfK224F6tCv gnfbOqgBc/Mwb1Xw+9W+mTu+JWY6Z54I1x7QKA30k8Y/f2ho9eEqR+cSAAxhqon1iQ2BrV 9MKmgvh659J2LKqZh5Qavt2VmcFrpWEqFfjuSjBM/qR6wY4q1/rKxe8GH2ML4w== 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 4W7fjF0KChzwsB; Tue, 25 Jun 2024 09:31:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45P9VSne006960; Tue, 25 Jun 2024 09:31:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45P9VSge006957; Tue, 25 Jun 2024 09:31:28 GMT (envelope-from git) Date: Tue, 25 Jun 2024 09:31:28 GMT Message-Id: <202406250931.45P9VSge006957@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: c36fa8d5022d - main - hwpmc/arm64: Support the kernel booting to VHE List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: c36fa8d5022db8b4cca01b391d9d82f26c632234 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=c36fa8d5022db8b4cca01b391d9d82f26c632234 commit c36fa8d5022db8b4cca01b391d9d82f26c632234 Author: Andrew Turner AuthorDate: 2024-06-25 08:41:50 +0000 Commit: Andrew Turner CommitDate: 2024-06-25 09:07:19 +0000 hwpmc/arm64: Support the kernel booting to VHE When booting to VHE we need to handle using the PMU at either EL1 or EL2. WE already support EL1 so add support for EL2. Reviewed by: mhorne Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D45527 --- sys/dev/hwpmc/hwpmc_arm64.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c index 4b2fd5cc746f..5d221c738c2f 100644 --- a/sys/dev/hwpmc/hwpmc_arm64.c +++ b/sys/dev/hwpmc/hwpmc_arm64.c @@ -34,6 +34,7 @@ #include #include +#include #include "opt_acpi.h" @@ -186,10 +187,18 @@ arm64_allocate_pmc(int cpu, int ri, struct pmc *pm, switch (a->pm_caps & (PMC_CAP_SYSTEM | PMC_CAP_USER)) { case PMC_CAP_SYSTEM: + /* Exclude EL0 */ config |= PMEVTYPER_U; + if (in_vhe()) { + /* If in VHE we need to include EL2 and exclude EL1 */ + config |= PMEVTYPER_NSH | PMEVTYPER_P; + } break; case PMC_CAP_USER: + /* Exclude EL1 */ config |= PMEVTYPER_P; + /* Exclude EL2 */ + config &= ~PMEVTYPER_NSH; break; default: /* @@ -197,6 +206,10 @@ arm64_allocate_pmc(int cpu, int ri, struct pmc *pm, * (default setting) or if both flags are specified * (user explicitly requested both qualifiers). */ + if (in_vhe()) { + /* If in VHE we need to include EL2 */ + config |= PMEVTYPER_NSH; + } break; }