From patchwork Mon Mar 15 14:24:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 401114 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A419DC4332B for ; Mon, 15 Mar 2021 14:25:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83E8C64F80 for ; Mon, 15 Mar 2021 14:25:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234130AbhCOOZ2 (ORCPT ); Mon, 15 Mar 2021 10:25:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:48308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234160AbhCOOYn (ORCPT ); Mon, 15 Mar 2021 10:24:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 97E9165034; Mon, 15 Mar 2021 14:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615818282; bh=jybnSoroDpQIksoHUrxyeI85+0ptC0keTTMH2Tab5to=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e2ZPJUbbLwcAZYgvDcEEBtyadRJWSNa4Htb1QRr05RZFSVSui1G//lJSdTDN+VB/7 pnDtryfwyh3Fg8c/5D1aCb/GbvyvV5FvYfWkZOcaIekg7zeo3U+3fPeD4LdjCRX6WN 2MIet4A7KipBcT+9DX0krfqWHdZha8fpJsnVcRKk= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Howard Zhang , Will Deacon , Jia He , Marc Zyngier , Paolo Bonzini Subject: [PATCH 5.11 295/306] KVM: arm64: Fix range alignment when walking page tables Date: Mon, 15 Mar 2021 15:24:20 +0100 Message-Id: <20210315135517.664453431@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135517.556638562@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> <20210315135517.556638562@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Greg Kroah-Hartman From: Jia He commit 357ad203d45c0f9d76a8feadbd5a1c5d460c638b upstream. When walking the page tables at a given level, and if the start address for the range isn't aligned for that level, we propagate the misalignment on each iteration at that level. This results in the walker ignoring a number of entries (depending on the original misalignment) on each subsequent iteration. Properly aligning the address before the next iteration addresses this issue. Cc: stable@vger.kernel.org Reported-by: Howard Zhang Acked-by: Will Deacon Signed-off-by: Jia He Fixes: b1e57de62cfb ("KVM: arm64: Add stand-alone page-table walker infrastructure") [maz: rewrite commit message] Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20210303024225.2591-1-justin.he@arm.com Message-Id: <20210305185254.3730990-9-maz@kernel.org> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/hyp/pgtable.c | 1 + 1 file changed, 1 insertion(+) --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -225,6 +225,7 @@ static inline int __kvm_pgtable_visit(st goto out; if (!table) { + data->addr = ALIGN_DOWN(data->addr, kvm_granule_size(level)); data->addr += kvm_granule_size(level); goto out; }