Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3125314pxf; Mon, 15 Mar 2021 01:56:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/uqcxVq09ry71mQrX/PYLfwEc1dRrt+6cbdZtgvUdbQa8D4d7R+pNxjPogRboUx2VycWe X-Received: by 2002:a05:6402:5255:: with SMTP id t21mr28831474edd.91.1615798577008; Mon, 15 Mar 2021 01:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615798577; cv=none; d=google.com; s=arc-20160816; b=vh6DGd5m6mqIXmb85JDAh83dmxE8DBASclpH+17A6ApYBrDtUSqINDByyLlWJOLlWR KegR1Cyau2vbMYPGEhCnpoxl2nCng6qDjKKCSJFdp2eFG3A1YtAOB/Y6sKc2pZ0WzMdB uC7OQXRm4i3LKGtxUZjgTvy5cZ0Bhdmwap9u9aaqmcsmYgkd6E1ktGF4HpJMWgIuFWQ4 JdFOHQohmva22UM9X0YfoO6rjPthEs9GwerJRM2DbQj+XNwP9a0PbgM4MG90apU9E5vg Zfep8+qCJypZ6epL9v04lMrcMil4GX2fVFJVXzz0MFUCDOoX53vwnWo5bru4fsjFSYVY 0uaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=sKi/aZi0Vzn9ivgnpSoTWCqc0BOiLGaGeaOXe2aupjM=; b=b0Ja/Y3DJc8m3ChEBizTUo0wn2CJHM274UhSMZfnSOrO+JutPuqHHntJE8WAbZpe6Q FewNHGnGzizL9YKGLlw/PRK7ZhCJoh5Qy6MCDlL0rmTVbjtKEfT89aCfcMaVGeZeApBj pvaQT1G7J1wUefJuJBRMQG+ObGhAoOyhmSHdpkFqzRW9m0Os2B/ef5pEZHrpMDVYXNO/ 9WWHJkF4TSxhkr9Vq9g+xASVqWZaieMWjoqmR9/evm4D0ppGood9yTIFjDYcNgkBL/bU jTt6XfzvYuaszFxzKZ7lHgzfdK1V/2YvioB7k06ZN4pL7XGmrTZngOLHMWx/Sw0bUota UNbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si10422811ejz.607.2021.03.15.01.55.55; Mon, 15 Mar 2021 01:56:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229623AbhCOIwp (ORCPT + 99 others); Mon, 15 Mar 2021 04:52:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:35480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbhCOIwl (ORCPT ); Mon, 15 Mar 2021 04:52:41 -0400 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 2CEDE64E3F; Mon, 15 Mar 2021 08:52:41 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lLixq-001bx8-Vf; Mon, 15 Mar 2021 08:52:39 +0000 Date: Mon, 15 Mar 2021 08:52:38 +0000 Message-ID: <87eeggg5nt.wl-maz@kernel.org> From: Marc Zyngier To: Gavin Shan Cc: kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, will@kernel.org, alexandru.elisei@arm.com, shan.gavin@gmail.com Subject: Re: [PATCH 2/4] KVM: arm64: Use find_vma_intersection() In-Reply-To: <20210315041844.64915-3-gshan@redhat.com> References: <20210315041844.64915-1-gshan@redhat.com> <20210315041844.64915-3-gshan@redhat.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 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: gshan@redhat.com, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, will@kernel.org, alexandru.elisei@arm.com, shan.gavin@gmail.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 15 Mar 2021 04:18:42 +0000, Gavin Shan wrote: > > find_vma_intersection() has been existing to search the intersected > vma. This uses the function where it's applicable, to simplify the > code. > > Signed-off-by: Gavin Shan > --- > arch/arm64/kvm/mmu.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 84e70f953de6..286b603ed0d3 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -421,10 +421,11 @@ static void stage2_unmap_memslot(struct kvm *kvm, > * +--------------------------------------------+ > */ > do { > - struct vm_area_struct *vma = find_vma(current->mm, hva); > + struct vm_area_struct *vma; > hva_t vm_start, vm_end; > > - if (!vma || vma->vm_start >= reg_end) > + vma = find_vma_intersection(current->mm, hva, reg_end); For context, here's the definition of find_vma_intersection(): static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr) { struct vm_area_struct * vma = find_vma(mm,start_addr); if (vma && end_addr <= vma->vm_start) vma = NULL; return vma; } It seems that there is a boundary issue in either the old code or the new one in the case where (reg_end == vma->start). Which one is which? M. -- Without deviation from the norm, progress is not possible.