Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3103858pxf; Mon, 15 Mar 2021 01:08:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7jl26R22k/VQnucME/m5ObgHGubvkh+sOr/fZ+ratBd5IuyO+pquyfGObWn6imLI+8UqW X-Received: by 2002:a17:906:bcc7:: with SMTP id lw7mr10575290ejb.209.1615795727291; Mon, 15 Mar 2021 01:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615795727; cv=none; d=google.com; s=arc-20160816; b=QJGxF3bT4aHwZ3/diAygWUePwEomTXjFpD42z6hK7CwK0Kjr2oil6hbHXewmPGTYOg skZH23fbVNrYsDq6sAnR11jeBuVnjg4FhDn+9mLKwgsn0INCYkp6XfFm1jFEVJxgY5IO KxzI8ME4ihSCBK15SfUqgyKCZCf4ovjaq7d9A5niTPcHZagDvGggAAZfo2RJi/HPQJZk tu79YuvAm9KLAbgeywlgSJaxUtTYgCL1jDEgpqTpAOTiHy8Lvg70AXbbIzLu0Apf0r/T aOT8iGoQUnRdJfNPCWnf5h8AIWbCj4qq62HO2OFaD8V8U0jbZC6u09pU2sDFaCvVH0uk JGog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=aY+XrLegBp00QGe8e0WMkxHFNvyC4+dOF3KsSe6QCAg=; b=H2ZvqWtEOPGZn+z38Z8SMLUFR6ypsR5yxf16dvjkEWuumqyPU6aDdiJy3tBy5MTSLI bj7LAMtgrw/Zgyb2uQkhBr3IQRm7vK4rptYz8YGLumOg56Npv322YQDw3TL6qyNkbIRa /BqVm7THKzDPaWqdz/kodSyKIAnoPHuqWJYoW7fmq0yiXpqaWSO8EUW+cU+I+A547Qby tFU5T2yfVuDP37LB+uaAg3KZP1bukio1YNO610g69lK3vMSjnIS3o8leLIER4Qps7rix yW49it4BmcII6djjyUsh+k0mantYLpTL/Qkz0GshHis7pQ9zuFmU8Fa3kRwHCJ5G7sOo 8sUQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s7si4661785eja.630.2021.03.15.01.08.24; Mon, 15 Mar 2021 01:08:47 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbhCOIFN (ORCPT + 99 others); Mon, 15 Mar 2021 04:05:13 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:14339 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229828AbhCOIEp (ORCPT ); Mon, 15 Mar 2021 04:04:45 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DzTRw1Y4nz8y3T; Mon, 15 Mar 2021 16:02:52 +0800 (CST) Received: from [10.174.184.42] (10.174.184.42) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Mon, 15 Mar 2021 16:04:40 +0800 Subject: Re: [PATCH 2/4] KVM: arm64: Use find_vma_intersection() To: Gavin Shan , References: <20210315041844.64915-1-gshan@redhat.com> <20210315041844.64915-3-gshan@redhat.com> CC: , , , From: Keqian Zhu Message-ID: <65dfdca3-af94-7d5a-86fe-24825301655b@huawei.com> Date: Mon, 15 Mar 2021 16:04:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20210315041844.64915-3-gshan@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gavin, On 2021/3/15 12:18, 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); Nit: Keep a same style may be better(Assign vma when declare it). Other looks good to me. Thank, Keqian > + if (!vma) > break; > > /* > @@ -1330,10 +1331,11 @@ int kvm_arch_prepare_memory_region(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); > + if (!vma) > break; > > /* >