From nobody Tue Aug 20 09:02:23 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 4Wp3Pq4Knzz5Sj4T; Tue, 20 Aug 2024 09:02:23 +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 4Wp3Pq2d9Sz4vcx; Tue, 20 Aug 2024 09:02:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724144543; 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=e/AiDUEFWM6woieuiyZxSn11hFoqQcMCDCJzwe7ElLk=; b=qYl6+BhKj3M7V1oakk16+AQhh1Ba8sJlo+tSGvGW3s3rDtYJknJApD777NWi/1r88f9N3l ufyEcpC4fhTO5BmGLO+v0GR8e7NVct71PnZdSkpFILCMglpP3m8IL5ErNCQJFreSwA3GOi we7Ei5BI11nKF3By8DuTesXZywqCqynGi1Nz7IudDIz4cOGi+txZnkDcQcNchTycdFTsBq 96nbMW8D3n3sCOZTn0zLU5ZIkgVWs5PbEc/FfR2c3W+pxGu7e3rjRBgqtdO9rbS6ti3Fki IZ96mbBg4z7Jm2odP9NCGndM/dqzHQX2aO5VIAV0qnB66LwhaLuSRIGOBdQ9Jw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724144543; a=rsa-sha256; cv=none; b=UkbGMAj7yk5ALiio0eEHU7OgD4mnTufOtoapUpmdHyuGqXDUGxkWrwHlZb2Jk6d7BcMspm NYDuPdh1prlBM+ViofRKsYAJVkfxvAiI8wtFOHOTfwyDwT07U91Oyc5KjJuB2nGPwhuzGM 23PvM4taEvflg4sV7K4dt22rC6TLj+1dg5sTmlJ/LZeMc2EfxMWK7JypVXDzkz0an3gexz 3sEbq3dbv1z86A0PGPMAby7i3cMsEz+fK/76Ryn6UtORbtU+i6LUywWToriz0izALNu/hz hfJfvEbMyf4c7s+Lw/Khl69aUFMbyvYHNa+Nr0xr++STdnMyRLh+fhDQ48xhlA== 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=1724144543; 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=e/AiDUEFWM6woieuiyZxSn11hFoqQcMCDCJzwe7ElLk=; b=fVyQNTlcZ/d11ChQ/E6CzeWa0DvXVlTh81FW7opIe0zl/nT0AUbqoKp1GAa+T5yhRPLW4a /4Q+7p3n1rCkcmU/znYcDYqQUk3T/a1nMlkBjoIOxPLsQYyuPQiv+6t0LlWr+v6eqhbuAB jadEJXfVjGfR8F67jYir1ux+OHF2LyOCgI4ufX8tt5PsCzTqz0c3N1RN42OoUnpNb5DwSN 2EgX9GH2BvqfrruXZzTNYz8jggkQA1csCDYJsXPKm2KdbPo+l7y+EfEfnTVbI8qUL8kK+t UI8dhEScfeC2Tg3Of6Cd0THy1M2kdmCFBEKrxBdB+BmIxxr7iHtAKHNn8BHRBg== 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 4Wp3Pq21Vjztnn; Tue, 20 Aug 2024 09:02:23 +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 47K92NCF081743; Tue, 20 Aug 2024 09:02:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47K92NcI081740; Tue, 20 Aug 2024 09:02:23 GMT (envelope-from git) Date: Tue, 20 Aug 2024 09:02:23 GMT Message-Id: <202408200902.47K92NcI081740@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: 5577bb2f67ff - main - arm64/vmm: Support tlbi from VHE 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: 5577bb2f67ff442a92a3c0edb133e03bc28bb9d6 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=5577bb2f67ff442a92a3c0edb133e03bc28bb9d6 commit 5577bb2f67ff442a92a3c0edb133e03bc28bb9d6 Author: Andrew Turner AuthorDate: 2024-08-19 12:44:11 +0000 Commit: Andrew Turner CommitDate: 2024-08-20 08:49:16 +0000 arm64/vmm: Support tlbi from VHE When invalidating the stage 2 TLB we need to ensure page tables updates have completed and for tlbi vmalle1is the HCR_EL2 TGE flag needs to be clear. To fix the former add a data barrier before the tlbi instructions. On non-VHE this will happen as part of the exception entry, so is only needed for VHE. The tlbi vmalle1is instruction operates on the EL2 & 0 regime when HCR_EL2 E2H and TGE flags are both set. By clearing the TGE flag it will stop this and operate on the EL1 & 0 regime we are expecting. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46080 --- sys/arm64/vmm/vmm_hyp.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/sys/arm64/vmm/vmm_hyp.c b/sys/arm64/vmm/vmm_hyp.c index 9c84bb4b294e..bd119c80139b 100644 --- a/sys/arm64/vmm/vmm_hyp.c +++ b/sys/arm64/vmm/vmm_hyp.c @@ -619,6 +619,13 @@ VMM_HYP_FUNC(s2_tlbi_range)(uint64_t vttbr, vm_offset_t sva, vm_offset_t eva, { uint64_t end, r, start; uint64_t host_vttbr; +#ifdef VMM_VHE + uint64_t host_tcr; +#endif + +#ifdef VMM_VHE + dsb(ishst); +#endif #define TLBI_VA_SHIFT 12 #define TLBI_VA_MASK ((1ul << 44) - 1) @@ -631,6 +638,12 @@ VMM_HYP_FUNC(s2_tlbi_range)(uint64_t vttbr, vm_offset_t sva, vm_offset_t eva, WRITE_SPECIALREG(vttbr_el2, vttbr); isb(); +#ifdef VMM_VHE + host_tcr = READ_SPECIALREG(tcr_el2); + WRITE_SPECIALREG(tcr_el2, host_tcr & ~HCR_TGE); + isb(); +#endif + /* * The CPU can cache the stage 1 + 2 combination so we need to ensure * the stage 2 is invalidated first, then when this has completed we @@ -655,7 +668,12 @@ VMM_HYP_FUNC(s2_tlbi_range)(uint64_t vttbr, vm_offset_t sva, vm_offset_t eva, dsb(ish); isb(); - /* Switch back t othe host vttbr */ +#ifdef VMM_VHE + WRITE_SPECIALREG(tcr_el2, host_tcr); + isb(); +#endif + + /* Switch back to the host vttbr */ WRITE_SPECIALREG(vttbr_el2, host_vttbr); isb(); } @@ -665,6 +683,10 @@ VMM_HYP_FUNC(s2_tlbi_all)(uint64_t vttbr) { uint64_t host_vttbr; +#ifdef VMM_VHE + dsb(ishst); +#endif + /* Switch to the guest vttbr */ /* TODO: Handle Cortex-A57/A72 erratum 131936 */ host_vttbr = READ_SPECIALREG(vttbr_el2);