Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1246419ybt; Thu, 25 Jun 2020 01:04:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwft6WS9CLdodaid5rgekB578ZIq3ruW6pswqSWxvJOBc4iRNl11ErKvPizuAa/c6ohg9pI X-Received: by 2002:a50:9f22:: with SMTP id b31mr6333729edf.24.1593072270447; Thu, 25 Jun 2020 01:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593072270; cv=none; d=google.com; s=arc-20160816; b=FpFCjSsHZlapaQXmd8q0ovzcQX9T6pePjY6Hbkbc++ardFYOdJ4eFbeJzrtS6ZvMfI RbakvjUhnWpTadDV0aQKt20z7TPjE7UKyt/RJWsMZ6hh19ZVqxyIm1X1rU5kbwlhGzAF xbaCwd0M2LCUNgv7xYG7z2nBYd2GyEBZ4UygVxXW3vdpmWfHMcLdWMf4R4eekyDQR8qB noJ5L1vnvTYohpzVn6gw5/5a1j7CG52BZjtqXJMWM2jZRXx8C4eKfZa8hHKHZSokydMi 2AIclGGJsXM37kfvdLuN/QqH4q6VGobZZzwTnJOBysCdGbUwHljvgyfWHRJN/jGCR+n5 lV1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=FuNZPcvp+cUt0p4CBcTO2ZHTP6kL648BshrgU2c/XZg=; b=JlFpvFoJsB3pNWXZ12fnbks+EId9H08moUzRfg+b0qWL/PPWYn8h8R2CN2GA4SdcGS DYDvN3s3QxlDQ5ZwTzXlOVIs0xxEQ6e+BS+Msx3D4kvswZLvSbVT+ZVmjHdYypgWKfoS qirJF62LKQkesuxMFiADg+6xpmLFN4npLxEhze1HLx6SNJPTlVHGxYNAvQ5KJeKrZEsR q6NC32AKrqMLqdQJRCQWKh7hWUKkblD20wy+iuXH9kF9mBKaLcBP41+HmcuAkbXk0eaw ZK8KkCdSA1WfQyIYN/LWftM7vH7vctrQKl4b+sjZRSNy+IjkqhgNyIxL6z8/6RQ+QbIr J6+w== 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 o24si14630965edz.484.2020.06.25.01.04.07; Thu, 25 Jun 2020 01:04:30 -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 S2390617AbgFYIDq (ORCPT + 99 others); Thu, 25 Jun 2020 04:03:46 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:44914 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390554AbgFYIDl (ORCPT ); Thu, 25 Jun 2020 04:03:41 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 39FC1AC7532E7DDE53DA; Thu, 25 Jun 2020 16:03:37 +0800 (CST) Received: from DESKTOP-KKJBAGG.china.huawei.com (10.173.220.25) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Thu, 25 Jun 2020 16:03:29 +0800 From: Zhenyu Ye To: , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [RESEND PATCH v5 5/6] arm64: tlb: Set the TTL field in flush_tlb_range Date: Thu, 25 Jun 2020 16:03:13 +0800 Message-ID: <20200625080314.230-6-yezhenyu2@huawei.com> X-Mailer: git-send-email 2.22.0.windows.1 In-Reply-To: <20200625080314.230-1-yezhenyu2@huawei.com> References: <20200625080314.230-1-yezhenyu2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.173.220.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch uses the cleared_* in struct mmu_gather to set the TTL field in flush_tlb_range(). Signed-off-by: Zhenyu Ye Reviewed-by: Catalin Marinas --- arch/arm64/include/asm/tlb.h | 29 ++++++++++++++++++++++++++++- arch/arm64/include/asm/tlbflush.h | 14 ++++++++------ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h index b76df828e6b7..61c97d3b58c7 100644 --- a/arch/arm64/include/asm/tlb.h +++ b/arch/arm64/include/asm/tlb.h @@ -21,11 +21,37 @@ static void tlb_flush(struct mmu_gather *tlb); #include +/* + * get the tlbi levels in arm64. Default value is 0 if more than one + * of cleared_* is set or neither is set. + * Arm64 doesn't support p4ds now. + */ +static inline int tlb_get_level(struct mmu_gather *tlb) +{ + if (tlb->cleared_ptes && !(tlb->cleared_pmds || + tlb->cleared_puds || + tlb->cleared_p4ds)) + return 3; + + if (tlb->cleared_pmds && !(tlb->cleared_ptes || + tlb->cleared_puds || + tlb->cleared_p4ds)) + return 2; + + if (tlb->cleared_puds && !(tlb->cleared_ptes || + tlb->cleared_pmds || + tlb->cleared_p4ds)) + return 1; + + return 0; +} + static inline void tlb_flush(struct mmu_gather *tlb) { struct vm_area_struct vma = TLB_FLUSH_VMA(tlb->mm, 0); bool last_level = !tlb->freed_tables; unsigned long stride = tlb_get_unmap_size(tlb); + int tlb_level = tlb_get_level(tlb); /* * If we're tearing down the address space then we only care about @@ -38,7 +64,8 @@ static inline void tlb_flush(struct mmu_gather *tlb) return; } - __flush_tlb_range(&vma, tlb->start, tlb->end, stride, last_level); + __flush_tlb_range(&vma, tlb->start, tlb->end, stride, + last_level, tlb_level); } static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h index bfb58e62c127..84cb98b60b7b 100644 --- a/arch/arm64/include/asm/tlbflush.h +++ b/arch/arm64/include/asm/tlbflush.h @@ -215,7 +215,8 @@ static inline void flush_tlb_page(struct vm_area_struct *vma, static inline void __flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end, - unsigned long stride, bool last_level) + unsigned long stride, bool last_level, + int tlb_level) { unsigned long asid = ASID(vma->vm_mm); unsigned long addr; @@ -237,11 +238,11 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma, dsb(ishst); for (addr = start; addr < end; addr += stride) { if (last_level) { - __tlbi_level(vale1is, addr, 0); - __tlbi_user_level(vale1is, addr, 0); + __tlbi_level(vale1is, addr, tlb_level); + __tlbi_user_level(vale1is, addr, tlb_level); } else { - __tlbi_level(vae1is, addr, 0); - __tlbi_user_level(vae1is, addr, 0); + __tlbi_level(vae1is, addr, tlb_level); + __tlbi_user_level(vae1is, addr, tlb_level); } } dsb(ish); @@ -253,8 +254,9 @@ static inline void flush_tlb_range(struct vm_area_struct *vma, /* * We cannot use leaf-only invalidation here, since we may be invalidating * table entries as part of collapsing hugepages or moving page tables. + * Set the tlb_level to 0 because we can not get enough information here. */ - __flush_tlb_range(vma, start, end, PAGE_SIZE, false); + __flush_tlb_range(vma, start, end, PAGE_SIZE, false, 0); } static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end) -- 2.26.2