From mboxrd@z Thu Jan 1 00:00:00 1970 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 9E200C77B6E for ; Wed, 12 Apr 2023 17:07:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AUxCN+i6pu8dozv1f3lnmRvlSED+hu9g092cqzzaElE=; b=D3NafOI6GWbYAO kSAfHKn0r/A8eOJP1l70G3Ux90GLouNYXoTuh1OH76/fQyODCnyUaBI0bFUsq46uiQ2A8PJkDUTNy 26D3fD3isuzJ7cAybyaPYk13/E13xNIzYYxzW8tNN+NZd91NXTgsPy4eT2ANSTk4z5s+6YN2oyv8J 1LzYRpnyfK2PAZwkcmMAkzUm7Qdh6HLZcCOuWqVyt0lxXPBV9R2lMllUEeCVRPEhYkhzCcp46vbm6 SXnatJ7HrcskO4D6BEOJDD9h5ldxKm3GAS0j1CDEimIf0Vv79927UXTTqDhZkKV93l8RjBA4a9bIi WWvquAkCtpDXFZMFOESg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pmdvG-003ubV-25; Wed, 12 Apr 2023 17:06:18 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pmdvD-003ub1-3C for linux-arm-kernel@lists.infradead.org; Wed, 12 Apr 2023 17:06:17 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C382C63792; Wed, 12 Apr 2023 17:06:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEA4EC433D2; Wed, 12 Apr 2023 17:06:12 +0000 (UTC) Date: Wed, 12 Apr 2023 18:06:09 +0100 From: Catalin Marinas To: Ryan Roberts Cc: Will Deacon , Marc Zyngier , Oliver Upton , Suzuki K Poulose , Ard Biesheuvel , Anshuman Khandual , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Subject: Re: [PATCH v2 06/12] KVM: arm64: Use LPA2 page-tables for hyp stage1 if HW supports it Message-ID: References: <20230306195438.1557851-1-ryan.roberts@arm.com> <20230306195438.1557851-7-ryan.roberts@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230306195438.1557851-7-ryan.roberts@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230412_100616_070737_A16604FD X-CRM114-Status: GOOD ( 20.00 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Mar 06, 2023 at 07:54:32PM +0000, Ryan Roberts wrote: > Implement a simple policy whereby if the HW supports FEAT_LPA2 for the > page size we are using, always use LPA2-style page-tables for hyp stage > 1, regardless of the IPA or PA size requirements. When in use we can now > support up to 52-bit IPA and PA sizes. > > Signed-off-by: Ryan Roberts > --- > arch/arm64/kvm/arm.c | 2 ++ > arch/arm64/kvm/hyp/pgtable.c | 3 ++- > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 3bd732eaf087..bef73c484162 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -1548,6 +1548,8 @@ static void __init cpu_prepare_hyp_mode(int cpu, u32 hyp_va_bits) > tcr = (read_sysreg(tcr_el1) & TCR_EL2_MASK) | TCR_EL2_RES1; > tcr &= ~TCR_T0SZ_MASK; > tcr |= TCR_T0SZ(hyp_va_bits); > + if (system_supports_lpa2()) > + tcr |= TCR_EL2_DS; > params->tcr_el2 = tcr; > > params->pgd_pa = kvm_mmu_get_httbr(); > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > index 414a5dbf233d..bb481d6c7f2d 100644 > --- a/arch/arm64/kvm/hyp/pgtable.c > +++ b/arch/arm64/kvm/hyp/pgtable.c > @@ -379,7 +379,8 @@ static int hyp_set_prot_attr(enum kvm_pgtable_prot prot, kvm_pte_t *ptep) > } > > attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S1_AP, ap); > - attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S1_SH, sh); > + if (!system_supports_lpa2()) > + attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S1_SH, sh); > attr |= KVM_PTE_LEAF_ATTR_LO_S1_AF; > attr |= prot & KVM_PTE_LEAF_ATTR_HI_SW; > *ptep = attr; Isn't LPA2 at stage 1 more involved than just not setting the SH field? Does kvm_phys_to_pte() need changing as well? If that's not strictly needed for stage 2, I'd rather keep the two stages separate and add the stage 1 hyp together with Ard's series for LPA2 at stage 1. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel