From patchwork Wed Oct 9 19:00:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13829195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E847DCEE346 for ; Wed, 9 Oct 2024 20:10:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=i5zrpriG+ysNnRNxGtbIIOBcRzUqHQRe3VxNTdWDdyo=; b=tQmHOup3vl4I8SYT9RBciQpg5o 7i0569sIwDitiK8rKgfujxcSLzXpWbHJfMeJrwkRE0dguwwB2ZhqKFi/x8Zl58d+7ghZKjhUVOsfj d+N0UcHH+/PrV7G4MepBHmB1SsTSBoMuc4d+0YkLtiFGw2Ofz3iLWw1ERMf7ZxQUf6q18JQWn+/CL u2FGVtQzxkdcIolot3YWig9znXlnE8l0x/oT/hUoD8UmZ4azeCLaDMI9HCkB86COn+SJ7ONP/wSXn y8l3SXSOV/+cNY5H0ZMlwIileks1ivBDTOyKmzCXPGycS6h1wYIcsXTYjv9//gJO+qN1zV5NCKxNV ktFFBzsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syd0u-0000000AaDi-2Zac; Wed, 09 Oct 2024 20:10:28 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sybvf-0000000ARS0-2SHj for linux-arm-kernel@bombadil.infradead.org; Wed, 09 Oct 2024 19:00:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=i5zrpriG+ysNnRNxGtbIIOBcRzUqHQRe3VxNTdWDdyo=; b=U75kE90NrWNq6rNISkR3KH7Idk G1rZzLhy2MkJzhkaamoJpbQ0lgKGSmtopP+Hf8bFyB/RN1afFjNcN0MAl6a0fTQUVLpF5BMCeVIkY hwBCPGrjAp/1aZ97/F/rz1vkGpVsHstFOncbbFCWaqDvPOU2mSZLoYFtx/MkcZlARcpvB2w8fU8I/ QLK4cQoezNbI4P/u+vyN3QeqIqPEJ94uyOJ7symNaMAhOVikEJgwILii5HFmw3tAEeawPa1EU83IS 45+CAlJOGPexPRi5GkIi5JllAaq9jII/BwT9dFN9pcUBDdFngWueOIQ0AnZp+Yw4tX1Fe4wRlzfw9 O1xRtw+Q==; Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sybvb-000000055o7-3oLV for linux-arm-kernel@lists.infradead.org; Wed, 09 Oct 2024 19:00:58 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 895B45C5D56; Wed, 9 Oct 2024 19:00:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59D58C4CECC; Wed, 9 Oct 2024 19:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728500449; bh=V1xKLMdx1CEKIaDPkTkjz5EYFw+JZUJEYia7tstoCfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hyH4lb82+thyIiIeTe9F8okEOZjdEwYKmt6gkjMYbIOh5oqVtkCBEYCuY8q5btZDC lcHU/LP26hxw9XroFU+qZAgE0EyTZHvgrkmr1gh1KNYN2wuFfg/iAteEnx6IiQO8UV emZtFercWylVCEosb/3A6MpG2rg777LKVYkwfTN5Yj5EYCX6AQu9fLrsBoPAeyeQFj J06T9iJkMkykP80iLaYyLc8q1IiN4Id8wJ+ARafsuu4I+MyNhmr+LHPSporE/CQlou KACehXEhebnK8JVdo6JYJ9P5y/wB+8OCMz65rYCEd7Z1exFJcqZ8IPCT/Dur0g4Ksg doAnYsBds9sdA== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sybvT-001wcY-Dc; Wed, 09 Oct 2024 20:00:47 +0100 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Alexandru Elisei , Mark Brown Subject: [PATCH v4 32/36] KVM: arm64: Add POE save/restore for AT emulation fast-path Date: Wed, 9 Oct 2024 20:00:15 +0100 Message-Id: <20241009190019.3222687-33-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241009190019.3222687-1-maz@kernel.org> References: <20241009190019.3222687-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, alexandru.elisei@arm.com, broonie@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241009_200056_406486_96491529 X-CRM114-Status: GOOD ( 11.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Just like the other extensions affecting address translation, we must save/restore POE so that an out-of-context translation context can be restored and used with the AT instructions. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/at.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm64/kvm/at.c b/arch/arm64/kvm/at.c index 3d93ed1795603..4921284eeedff 100644 --- a/arch/arm64/kvm/at.c +++ b/arch/arm64/kvm/at.c @@ -440,6 +440,8 @@ struct mmu_config { u64 tcr2; u64 pir; u64 pire0; + u64 por_el0; + u64 por_el1; u64 sctlr; u64 vttbr; u64 vtcr; @@ -458,6 +460,10 @@ static void __mmu_config_save(struct mmu_config *config) config->pir = read_sysreg_el1(SYS_PIR); config->pire0 = read_sysreg_el1(SYS_PIRE0); } + if (system_supports_poe()) { + config->por_el1 = read_sysreg_el1(SYS_POR); + config->por_el0 = read_sysreg_s(SYS_POR_EL0); + } } config->sctlr = read_sysreg_el1(SYS_SCTLR); config->vttbr = read_sysreg(vttbr_el2); @@ -485,6 +491,10 @@ static void __mmu_config_restore(struct mmu_config *config) write_sysreg_el1(config->pir, SYS_PIR); write_sysreg_el1(config->pire0, SYS_PIRE0); } + if (system_supports_poe()) { + write_sysreg_el1(config->por_el1, SYS_POR); + write_sysreg_s(config->por_el0, SYS_POR_EL0); + } } write_sysreg_el1(config->sctlr, SYS_SCTLR); write_sysreg(config->vttbr, vttbr_el2); @@ -1105,6 +1115,10 @@ static u64 __kvm_at_s1e01_fast(struct kvm_vcpu *vcpu, u32 op, u64 vaddr) write_sysreg_el1(vcpu_read_sys_reg(vcpu, PIR_EL1), SYS_PIR); write_sysreg_el1(vcpu_read_sys_reg(vcpu, PIRE0_EL1), SYS_PIRE0); } + if (kvm_has_feat(vcpu->kvm, ID_AA64MMFR3_EL1, S1POE, IMP)) { + write_sysreg_el1(vcpu_read_sys_reg(vcpu, POR_EL1), SYS_POR); + write_sysreg_s(vcpu_read_sys_reg(vcpu, POR_EL0), SYS_POR_EL0); + } } write_sysreg_el1(vcpu_read_sys_reg(vcpu, SCTLR_EL1), SYS_SCTLR); __load_stage2(mmu, mmu->arch);