Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp681546pxb; Tue, 5 Apr 2022 18:33:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8A1mw7v2579lZi2Q0MUvvU/p4yO8TQWxzW43xjXMYw9Zw4FG0txpSEys8xg4FoRo5o4np X-Received: by 2002:a17:903:4052:b0:156:229d:ffed with SMTP id n18-20020a170903405200b00156229dffedmr6143751pla.98.1649208836805; Tue, 05 Apr 2022 18:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649208836; cv=none; d=google.com; s=arc-20160816; b=obMv/abLeREJthtpTzpU6V+/Gm7BFcZg0jE++DBmcCG3fr4QA+wcMi7OBqhOgahhO8 M16YpZrYe8mdu7Zgw6Dgdd1FmWGtJm8ArcAIsdxwdQZrRTutxjABhUxsg9HiVXPJiH2Z 6vnrdm7x4MbTAricMJwNSdhGn+ojLDLZ6P12T6yAZQiTMLwm7kGGgY9codRlbHSDYESU lismpM6rm5oQYBTFppwz1M1JrX0+iR4k1vdNkY0xILf+cnFUAiRkLtkxAHC8ghe3gd8f 4YDYpnqS2+applHLprNqAwAsTMyu6EX/N+jXLJ82iaCyDardIqIlhnzGjfnas/JRgrmC idAg== 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=xDnuAOmrIsAhYrilauqskSuUtR3f+6BeDPVGOIsNZEE=; b=ULdy68itu1V2Lya3sus5Or3HCkRvSLEWGJazhCTaXSd4Sdz9AH7kMXYmRaqC0fl6mo uo3H/rN1eADwxjsLCFDDCawVPnY8G9+8Gj/h96+z8pXTpKFOEvVn4EabhncQb9QK+FVt 3vPyKhUTvMEqDfXXH+LjGzUkrr7+aG1I2K4IC4n8NBrbWnssjWA1GIIUK3M4J22EHLAK 6yoNbIwFgVeFwvC/Nt1nbL8JaAg/4T33VPs4wvMQxwvXkDSQOP2mvxaQXcR6GJHMEhMw 2cHDDyAjJuvJ5G0rE36qCvOYloZ4qcZjIunPKCTwmm1ZwNgjcC9XlvZyYU65pE71Aufi +GKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N+d4YF2n; 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 bg12-20020a056a02010c00b003816043eff0si10584495pgb.485.2022.04.05.18.33.42; Tue, 05 Apr 2022 18:33:56 -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=N+d4YF2n; 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 S1344034AbiDENQx (ORCPT + 99 others); Tue, 5 Apr 2022 09:16:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344275AbiDEJTD (ORCPT ); Tue, 5 Apr 2022 05:19:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FC02DC9; Tue, 5 Apr 2022 02:06:59 -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 ams.source.kernel.org (Postfix) with ESMTPS id B9AE8B81BBF; Tue, 5 Apr 2022 09:06:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12AD5C385A0; Tue, 5 Apr 2022 09:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149616; bh=TzN9S2c1jJpI9v8G0EpdcxObJsrqJKiqIfBV48VR++4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N+d4YF2nTX/oV7e0RKqfS67JUVC1eGPgcYBTu4mAN4aHu3/0SrYQeB6avua4bufT9 1bBfSWipP87m740iP3/zpVLKnehPP7Tln9PI++n9EoXE+so1K5EbQCraDQQtu82P6G zc2BmMCO7huiYvwXWMmckN1JMN/UoxoN6tB9WLqA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John David Anglin , Helge Deller , Sasha Levin Subject: [PATCH 5.16 0779/1017] parisc: Fix non-access data TLB cache flush faults Date: Tue, 5 Apr 2022 09:28:12 +0200 Message-Id: <20220405070417.381378238@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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.1 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: John David Anglin [ Upstream commit f839e5f1cef36ce268950c387129b1bfefdaebc9 ] When a page is not present, we get non-access data TLB faults from the fdc and fic instructions in flush_user_dcache_range_asm and flush_user_icache_range_asm. When these occur, the cache line is not invalidated and potentially we get memory corruption. The problem was hidden by the nullification of the flush instructions. These faults also affect performance. With pa8800/pa8900 processors, there will be 32 faults per 4 KB page since the cache line is 128 bytes. There will be more faults with earlier processors. The problem is fixed by using flush_cache_pages(). It does the flush using a tmp alias mapping. The flush_cache_pages() call in flush_cache_range() flushed too large a range. V2: Remove unnecessary preempt_disable() and preempt_enable() calls. Signed-off-by: John David Anglin Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- arch/parisc/kernel/cache.c | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c index 94150b91c96f..bce71cefe572 100644 --- a/arch/parisc/kernel/cache.c +++ b/arch/parisc/kernel/cache.c @@ -558,15 +558,6 @@ static void flush_cache_pages(struct vm_area_struct *vma, struct mm_struct *mm, } } -static void flush_user_cache_tlb(struct vm_area_struct *vma, - unsigned long start, unsigned long end) -{ - flush_user_dcache_range_asm(start, end); - if (vma->vm_flags & VM_EXEC) - flush_user_icache_range_asm(start, end); - flush_tlb_range(vma, start, end); -} - void flush_cache_mm(struct mm_struct *mm) { struct vm_area_struct *vma; @@ -581,17 +572,8 @@ void flush_cache_mm(struct mm_struct *mm) return; } - preempt_disable(); - if (mm->context == mfsp(3)) { - for (vma = mm->mmap; vma; vma = vma->vm_next) - flush_user_cache_tlb(vma, vma->vm_start, vma->vm_end); - preempt_enable(); - return; - } - for (vma = mm->mmap; vma; vma = vma->vm_next) flush_cache_pages(vma, mm, vma->vm_start, vma->vm_end); - preempt_enable(); } void flush_cache_range(struct vm_area_struct *vma, @@ -605,15 +587,7 @@ void flush_cache_range(struct vm_area_struct *vma, return; } - preempt_disable(); - if (vma->vm_mm->context == mfsp(3)) { - flush_user_cache_tlb(vma, start, end); - preempt_enable(); - return; - } - - flush_cache_pages(vma, vma->vm_mm, vma->vm_start, vma->vm_end); - preempt_enable(); + flush_cache_pages(vma, vma->vm_mm, start, end); } void -- 2.34.1