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 0C1F5C25B45 for ; Mon, 23 Oct 2023 18:42:56 +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:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NLLNBoz8tMekg6AQj3g7hJGQzfRcUUsODdKIoB0l/GE=; b=Vce6J/wGbOOZdl D6MWopomUM4I4VrvabsurIZ1eKQ0HwG3rGZ7LC4kL/SnwzRwjtbD75LhISttx3OqlKKY4f7DS2pTt z2GH8AhAzLk0VaJAVfUF+SNAtKnjFazIY8Vy92bcLSJ50LDLnNzjK8cZEAC1JSGe19ya332pIrnHf gxLHmENtaWlt9XGFsDowLrRzFmIDYLVaNOGfcIFBGKtfG3Zo1JvjIEd7RtaIPZgS9Pk+3rtrYwT3r vHCuE4duAbDGMsbGt1Uyrtw4uQeJyHAE5I2pK9XtVh+8y+LKxTvnMAwm2/jRgDczgRcODSE4ZksOA lDxdpj93EjC4G9VGMPQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1quzsm-0086XJ-2a; Mon, 23 Oct 2023 18:42:32 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1quzsj-0086Ww-1W for linux-arm-kernel@lists.infradead.org; Mon, 23 Oct 2023 18:42:30 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id ECD67B81FDB; Mon, 23 Oct 2023 18:42:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AFF2C433C8; Mon, 23 Oct 2023 18:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698086547; bh=e0zzXxdyzm2IXNydOSxUJa6OeLIrqPpAQ6TBofsuwKg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=H6nFLT9vWd5OkJE8VnDgMfzElDKotKCgnXuKIHk4rGyMKfIr7fmJgjctTf8dWA3JD ouulv3cm2UNBMcMHtp3nWDuwlseWbw13OJWepcri12wskeXZsuxPZnzzzsIA2Fi92T mbTwOGGsCuHh+DNeMhLTdfcpEOs07v1pBYGGAMRkeUTr0fg8Pq/x9jPbY/Z3N9ktue RPuoN3lr43VeJLzNOEgfoyKpCQEsoaneAS1YxStoUmjf2EANJ2BngKpH48HLqimuWm PLOCiHZHfqaG6zRQ9ZcTrvqZIUpPW83IWzJ8y8LhRGSFcjiqb1K8AUXqK/azOyFgFo qA1ywv2GjhU3A== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1quzse-006xII-Vt; Mon, 23 Oct 2023 19:42:25 +0100 Date: Mon, 23 Oct 2023 19:42:24 +0100 Message-ID: <86pm1541v3.wl-maz@kernel.org> From: Marc Zyngier To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Catalin Marinas , Will Deacon , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook , Joey Gouly Subject: Re: [PATCH v4 56/61] arm64: kvm: avoid CONFIG_PGTABLE_LEVELS for runtime levels In-Reply-To: <20230912141549.278777-119-ardb@google.com> References: <20230912141549.278777-63-ardb@google.com> <20230912141549.278777-119-ardb@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: ardb@google.com, linux-arm-kernel@lists.infradead.org, ardb@kernel.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, ryan.roberts@arm.com, anshuman.khandual@arm.com, keescook@chromium.org, joey.gouly@arm.com 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-20231023_114229_661952_3B7A7407 X-CRM114-Status: GOOD ( 21.08 ) 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 Tue, 12 Sep 2023 15:16:46 +0100, Ard Biesheuvel wrote: > > From: Ard Biesheuvel > > 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 beee6408534d..a4c5d7f44e32 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -802,7 +802,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, > }; > unsigned long flags; Note: this walker is going away in 6.7 and we will rely on the folio infrastructure to avoid the userspace walk. Acked-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel