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 7001FC4708C for ; Mon, 5 Dec 2022 13:50:54 +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=YCcmwjcxPgdw6qgNbgh1yL0LbZ0tWhz0cQ4ANi3l2rw=; b=ymndgukz7TtJH0 Q2Y5gbtd1bJWUUet/x0lEvHr5qdXW90II4Dz8El1RRteodkMlrXPS/ZmxuuB7g4vKAY34WdeAamrU 223M6Z8bfAqBicy/AFT1KwSOX+kTblkbXmKuzzmyy0mxLx1KERDIhHv7xIdDidw9MX+/WVJTbct5m DDU+Z70tyTr66OnTYN/KQvLOfBZdoH/Bzp+003u/carorE3qADOP11yCw+PBL5uBB/PwhFbTyDkfw /AfMo/ejv0gknMlZxibGr2P5bktBjLUAvs/Wgoa/6i6SekAhGBRGFSni4p93GgizwiRXz4CRerIGy Xz7UdLBxyfx1Uv99p45w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2Bqf-003fK9-Hm; Mon, 05 Dec 2022 13:49:33 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2BqZ-003fEL-UY for linux-arm-kernel@lists.infradead.org; Mon, 05 Dec 2022 13:49:29 +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 ams.source.kernel.org (Postfix) with ESMTPS id 81996B80F79; Mon, 5 Dec 2022 13:49:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 299E5C433D7; Mon, 5 Dec 2022 13:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670248165; bh=w7AMNnJFgjXrzhImJ28QNp8Vu0Hu+fA7lx0Jlo7L0dI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=a4Doa8wbsnYPuFezIz2B2cJV2xAwxYpAccKL5ig/LBpIWIGej2f3YVO4ge4QQMqH+ 6Y0v/KL0l0BdcRBpt6Y5nZT2tU7HGxsm4vbCMMhZwqdD2DFrutVO+NCA8veJ7tkNMQ mU2DI7H6w5nrjuQZYcso/rhtK+4s8lZsyHiI14vZpjhmgVqABpZbrtSlDMoKpHjLvY zymZsB5OF4EJYzwiNfFxKqaYyDqvxIU59PxAm2TNhbYS4JcWRb2CP0CnZ3g4HMMVDj aBSkRwa8e17K81HLqHoRfurBDopmbWVX0vch3XR83rin9NXVmaH4zo3RRPNOGDz8dF W+HMAmCUMl4DQ== 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 1p2BqU-00AaGq-Nr; Mon, 05 Dec 2022 13:49:22 +0000 Date: Mon, 05 Dec 2022 13:49:22 +0000 Message-ID: <86y1rmkljx.wl-maz@kernel.org> From: Marc Zyngier To: Ryan Roberts Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu Subject: Re: [PATCH v1] KVM: arm64: Fix benign bug with incorrect use of VA_BITS. In-Reply-To: <20221205114031.3972780-1-ryan.roberts@arm.com> References: <20221205114031.3972780-1-ryan.roberts@arm.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/27.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: ryan.roberts@arm.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu 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-20221205_054928_311664_465B3FB7 X-CRM114-Status: GOOD ( 29.63 ) 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 Hi Ryan, Thanks for that. On Mon, 05 Dec 2022 11:40:31 +0000, Ryan Roberts wrote: > > get_user_mapping_size() uses kvm's pgtable library to walk a user space > page table created by the kernel, and in doing so, fakes up the metadata > that the library needs, including ia_bits, which defines the size of the > input address. It isn't supposed to "fake" anything. It simply provides the information that the walker needs to correctly parse the page tables. > > For the case where the kernel is compiled for 52 VA bits but runs on HW > that does not support LVA, it will fall back to 48 VA bits at runtime. > Therefore we must use vabits_actual rather than VA_BITS to get the true > address size. > > This is benign in the current code base because the pgtable library only > uses it for error checking. > > Fixes: 6011cf68c885 ("KVM: arm64: Walk userspace page tables to compute > the THP mapping size") nit: this should appear on a single line, without a line-break in the middle [1]... > ... without a blank line between Fixes: and the rest of the tags. And while I'm on the "trivial remarks" train, drop the full stop at the end of the subject line. > Signed-off-by: Ryan Roberts > --- > 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 4efb983cff43..1ef0704420d9 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -641,7 +641,7 @@ static int get_user_mapping_size(struct kvm *kvm, u64 addr) > { > struct kvm_pgtable pgt = { > .pgd = (kvm_pte_t *)kvm->mm->pgd, > - .ia_bits = VA_BITS, > + .ia_bits = vabits_actual, > .start_level = (KVM_PGTABLE_MAX_LEVELS - > CONFIG_PGTABLE_LEVELS), > .mm_ops = &kvm_user_mm_ops, > -- > 2.25.1 > > Other than the above nits, this is well spotted. I need to regenerate the kvmarm/next branch after the sysreg attack from James, so I'll try and fold that in. Thanks, M. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst#n139 -- 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