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 X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 4662BC433DB for ; Thu, 4 Mar 2021 09:18:13 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB49764EED for ; Thu, 4 Mar 2021 09:18:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB49764EED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:Cc:To:From :Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=f8b9Se0n9iN+xMqM43T1xIm9Z73pM8FxvhAFonTJJmM=; b=jqiVtJ+vMkkwO2A3WR7S+36VR dK5qhvdwt3fBAxVn8Dim+qPM9DUEoVH6GqFpROgGjHBBwZcK6q8X7ZtpZaw/nUXtLHApzqE7Dfi+R 9qgyfYq8ttr7gYDpVr+1IyXy/sCm/qorFJ6ldcbjL4a9jN1kc2RfKevVhc2HiCOxnKdfWGREJ6Vyq WQpABVevYv0ck09u1O3k/aALlGRzorob0XBpPdJrmbvzD507CXdOJa012y7GC+jEEdrBBqQwBqyPy m6wcDC+hk1jrn5REFPz+4b2JSUJOQZxDElPcDbGBIG2nayP6WmM7wbR7sFnaRLgILhhe5USMQ3Lv5 toZDcbYlg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHk60-008GG0-1x; Thu, 04 Mar 2021 09:16:36 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHk5t-008GEO-2n for linux-arm-kernel@lists.infradead.org; Thu, 04 Mar 2021 09:16:31 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 94BE264EBB; Thu, 4 Mar 2021 09:16:27 +0000 (UTC) Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1lHk5p-00HDh3-Hy; Thu, 04 Mar 2021 09:16:25 +0000 MIME-Version: 1.0 Date: Thu, 04 Mar 2021 09:16:25 +0000 From: Marc Zyngier To: Justin He Cc: Will Deacon , kvmarm@lists.cs.columbia.edu, James Morse , Julien Thierry , Suzuki Poulose , Catalin Marinas , Gavin Shan , Yanan Wang , Quentin Perret , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: Fix unaligned addr case in mmu walking In-Reply-To: References: <20210303024225.2591-1-justin.he@arm.com> <20210303112934.GA18452@willie-the-truck> <87mtvkys1y.wl-maz@kernel.org> <20210303211325.GA20055@willie-the-truck> User-Agent: Roundcube Webmail/1.4.11 Message-ID: <5bd4fa0b0590e548288b8f6dc3659ea5@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: Justin.He@arm.com, will@kernel.org, kvmarm@lists.cs.columbia.edu, James.Morse@arm.com, julien.thierry.kdev@gmail.com, Suzuki.Poulose@arm.com, Catalin.Marinas@arm.com, gshan@redhat.com, wangyanan55@huawei.com, qperret@google.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2021-03-04 00:46, Justin He wrote: > Hi Marc > >> -----Original Message----- >> From: Will Deacon >> Sent: Thursday, March 4, 2021 5:13 AM >> To: Marc Zyngier >> Cc: Justin He ; kvmarm@lists.cs.columbia.edu; James >> Morse ; Julien Thierry >> ; >> Suzuki Poulose ; Catalin Marinas >> ; Gavin Shan ; Yanan Wang >> ; Quentin Perret ; >> linux-arm- >> kernel@lists.infradead.org; linux-kernel@vger.kernel.org >> Subject: Re: [PATCH] KVM: arm64: Fix unaligned addr case in mmu >> walking >> >> On Wed, Mar 03, 2021 at 07:07:37PM +0000, Marc Zyngier wrote: >> > From e0524b41a71e0f17d6dc8f197e421e677d584e72 Mon Sep 17 00:00:00 2001 >> > From: Jia He >> > Date: Wed, 3 Mar 2021 10:42:25 +0800 >> > Subject: [PATCH] KVM: arm64: Fix range alignment when walking page tables >> > >> > 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 at the before the next iteration >> >> "at the before the next" ??? >> >> > addresses the issue. >> > >> > Cc: stable@vger.kernel.org >> > Reported-by: Howard Zhang >> > 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 >> > --- >> > arch/arm64/kvm/hyp/pgtable.c | 2 +- >> > 1 file changed, 1 insertion(+), 1 deletion(-) >> > >> > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c >> > index 4d177ce1d536..124cd2f93020 100644 >> > --- a/arch/arm64/kvm/hyp/pgtable.c >> > +++ b/arch/arm64/kvm/hyp/pgtable.c >> > @@ -223,7 +223,7 @@ static inline int __kvm_pgtable_visit(struct >> kvm_pgtable_walk_data *data, >> > goto out; >> > >> > if (!table) { >> > - data->addr += kvm_granule_size(level); >> > + data->addr = ALIGN(data->addr, kvm_granule_size(level)); > > What if previous data->addr is already aligned with > kvm_granule_size(level)? > Hence a deadloop? Am I missing anything else? Indeed, well spotted. I'll revert to your original suggestion if everybody agrees... Thanks, M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel