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 7227EC6FD18 for ; Tue, 18 Apr 2023 14:30:43 +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:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZTUaO7Y/QaK26Vw8LMH2Oxnt2SazEX/oWa2agH2Uicg=; b=Bs9Vkpf/afBVH4 bMQizQFhTlF1JJuEBxqvyQTuXdU+U/8xji4C8ht/6KlFP57Qmhz+z3O6HcTRATKM6MR3PCAGShm6K oYIDrZeexJnk0StZ+V1GvVgVpFQjTeAaAh5q5Ai34frNgvF0sapYk/RCOUbDYdnQGwYGTLivrr8ju i7pH/OtxOS3fRjpXaY7rw49q8YpKZAdfzAA32cVs/5A/yEYhh+4lpAus6iNlu+MzrFfjKio/fO78J XqMfqZEeBJfV6Rv+JTM+4cY8MtFqWPYhbOKruFMOH9UI2rT7X4lWxCOeX97/QrLNzUS6tUyoSuB7J of6Bg9VrjXPtk4cv1JTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pomLD-002RSd-0f; Tue, 18 Apr 2023 14:29:55 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pomLA-002RRt-0M for linux-arm-kernel@lists.infradead.org; Tue, 18 Apr 2023 14:29:53 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 65F971684; Tue, 18 Apr 2023 07:30:32 -0700 (PDT) Received: from [10.1.27.157] (C02CF1NRLVDN.cambridge.arm.com [10.1.27.157]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 86F483F587; Tue, 18 Apr 2023 07:29:47 -0700 (PDT) Message-ID: Date: Tue, 18 Apr 2023 15:29:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH v3 55/60] arm64: kvm: avoid CONFIG_PGTABLE_LEVELS for runtime levels Content-Language: en-US To: Ard Biesheuvel , linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Anshuman Khandual , Kees Cook References: <20230307140522.2311461-1-ardb@kernel.org> <20230307140522.2311461-56-ardb@kernel.org> From: Ryan Roberts In-Reply-To: <20230307140522.2311461-56-ardb@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230418_072952_195281_0C10BD94 X-CRM114-Status: GOOD ( 17.49 ) 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 07/03/2023 14:05, Ard Biesheuvel wrote: > get_user_mapping_size() uses vabits_actual and CONFIG_PGTABLE_LEVELS to > provide the starting point for a table walk. This is fine for LVA, as > the number of translation levels is the same regardless of whether LVA > is enabled. However, with LPA2, this will no longer be the case, so > let's derive the number of levels from the number of VA bits directly. > > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/kvm/mmu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index d64be7b5f6692e8b..4e7c0f9a9c286c09 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -663,7 +663,7 @@ static int get_user_mapping_size(struct kvm *kvm, u64 addr) > .pgd = (kvm_pteref_t)kvm->mm->pgd, > .ia_bits = vabits_actual, > .start_level = (KVM_PGTABLE_MAX_LEVELS - > - CONFIG_PGTABLE_LEVELS), > + ARM64_HW_PGTABLE_LEVELS(pgt.ia_bits)), > .mm_ops = &kvm_user_mm_ops, > }; > kvm_pte_t pte = 0; /* Keep GCC quiet... */ You have the problem here that the KVM library (which isn't LPA2 aware) is walking a kernel page table, which may now be in LPA2 format. I think this works out ok as long as there are no physical addresses above 48 bits in the page table. But otherwise, I doubt it works out very well... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel