Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2864101pxb; Mon, 18 Apr 2022 09:49:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxC66BpUMdTZBT7yzKWr4+RbNBS+Vwtiaen2vR/not+DGcNxgUNAJNrP6CgX+pewacEH1Mj X-Received: by 2002:a17:907:3f04:b0:6e8:4b0e:438d with SMTP id hq4-20020a1709073f0400b006e84b0e438dmr9859672ejc.391.1650300585924; Mon, 18 Apr 2022 09:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650300585; cv=none; d=google.com; s=arc-20160816; b=WOrKfiilinffv+oiVhGAPntvPB5/KfMZlJkKqSszAmFGUwwzbnWyDveb+kDanzkrr+ 7u/6Aihb1/v2oWTObt7t1WCRw+JmTiOxLd+hr+zfU+FqAoHf7Jhg+ntPeLt3A4oP4mmj +tIqmASvtFA8uFBsd9VkcXLAOkPpsAZdBBAqWcoDD833ntqmpgPtRKCMh77QSyFYyLUa z8hu7Y3CnWy2+HFj1d46HecUEpXbwq6nH7qJ7B96bfcOiiFsbETtEfADkH6LKzwam54t t8K1Pf6G4TVNQ5WdPw5G5hiboDAlUidUMWVDc2eFgeI2sqHgmfksCrswNk+oRI9nbldR xfeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j61+XXpAoz0jz3CY8lpujPvacfE0M3C8ByBt7q7S9O4=; b=elHPtrszYtTScRoMXZoemRw7imttByfyqFOZ7Wwph54bwuI1lHlvSkaZdSM5pa/rUv pKHrg/6NROi/DEDSSeWFuhbFjHh44zXDb+rX5COHCAfYER/T4BbY9nIKk+CZpeqpNORn QaEZzih5IVhF0RB2jjj0y7cvYKxdK+fvJI1K5SHyqxfVfx9ny72zfKajQ/WGdT3qxp3e f4zyaWDU8BiC+kX8IZahULAqIKICjbg/r6dfZRKc0x9PK9Fv6O83Pr/2H9UnA33tAeDT MFgTnKJhKxfJUJs5jUjVcaW2ioXyMys0WkHIGavQwAIrRNu18Il7k9ohB6WZBsWfu8xf G8/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ka0mtetC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z20-20020a056402275400b00418c2b5bdd3si7200189edd.181.2022.04.18.09.49.20; Mon, 18 Apr 2022 09:49:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ka0mtetC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239672AbiDRMdU (ORCPT + 99 others); Mon, 18 Apr 2022 08:33:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239866AbiDRM3G (ORCPT ); Mon, 18 Apr 2022 08:29:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E367422B20; Mon, 18 Apr 2022 05:22:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6E6CB60F01; Mon, 18 Apr 2022 12:22:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 602ECC385A1; Mon, 18 Apr 2022 12:22:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284564; bh=k0wSfYR0ig7xQ4rb/4er1kpUOZcttmdGmeX4lBcM9V8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ka0mtetC+Gt9mujAUWqefhBFET7MGnXYoNuESNnx/6AGmE6FuLbHEzxl8OSq8riq3 Ef/NZQsYdymeS7NGsVB0cYCRmrIPOOTiljsbYP4GdDt2j4YUX6KkbnGCggdKwTXFjq DGxmX7gc7r7UINlMhtkveCEy2GEco0/5iaZ6xUns= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Hildenbrand , "Peter Zijlstra (Intel)" , Anshuman Khandual , Catalin Marinas , Will Deacon , Steve Capper , Sasha Levin Subject: [PATCH 5.17 156/219] tlb: hugetlb: Add more sizes to tlb_remove_huge_tlb_entry Date: Mon, 18 Apr 2022 14:12:05 +0200 Message-Id: <20220418121211.251947230@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steve Capper [ Upstream commit 697a1d44af8ba0477ee729e632f4ade37999249a ] tlb_remove_huge_tlb_entry only considers PMD_SIZE and PUD_SIZE when updating the mmu_gather structure. Unfortunately on arm64 there are two additional huge page sizes that need to be covered: CONT_PTE_SIZE and CONT_PMD_SIZE. Where an end-user attempts to employ contiguous huge pages, a VM_BUG_ON can be experienced due to the fact that the tlb structure hasn't been correctly updated by the relevant tlb_flush_p.._range() call from tlb_remove_huge_tlb_entry. This patch adds inequality logic to the generic implementation of tlb_remove_huge_tlb_entry s.t. CONT_PTE_SIZE and CONT_PMD_SIZE are effectively covered on arm64. Also, as well as ptes, pmds and puds; p4ds are now considered too. Reported-by: David Hildenbrand Suggested-by: Peter Zijlstra (Intel) Cc: Anshuman Khandual Cc: Catalin Marinas Cc: Will Deacon Link: https://lore.kernel.org/linux-mm/811c5c8e-b3a2-85d2-049c-717f17c3a03a@redhat.com/ Signed-off-by: Steve Capper Acked-by: David Hildenbrand Reviewed-by: Anshuman Khandual Reviewed-by: Catalin Marinas Acked-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20220330112543.863-1-steve.capper@arm.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- include/asm-generic/tlb.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 2c68a545ffa7..71942a1c642d 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -565,10 +565,14 @@ static inline void tlb_flush_p4d_range(struct mmu_gather *tlb, #define tlb_remove_huge_tlb_entry(h, tlb, ptep, address) \ do { \ unsigned long _sz = huge_page_size(h); \ - if (_sz == PMD_SIZE) \ - tlb_flush_pmd_range(tlb, address, _sz); \ - else if (_sz == PUD_SIZE) \ + if (_sz >= P4D_SIZE) \ + tlb_flush_p4d_range(tlb, address, _sz); \ + else if (_sz >= PUD_SIZE) \ tlb_flush_pud_range(tlb, address, _sz); \ + else if (_sz >= PMD_SIZE) \ + tlb_flush_pmd_range(tlb, address, _sz); \ + else \ + tlb_flush_pte_range(tlb, address, _sz); \ __tlb_remove_tlb_entry(tlb, ptep, address); \ } while (0) -- 2.35.1