Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5928938rwd; Wed, 24 May 2023 08:33:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7v7v4rMgwH31nNsliHUL7Bo3V/smLH9RJzTcYCX+/abm9wbTjm1RQf0lPtHAmcq2u71+el X-Received: by 2002:a05:6a00:1a13:b0:643:4d69:efb8 with SMTP id g19-20020a056a001a1300b006434d69efb8mr3952884pfv.6.1684942414120; Wed, 24 May 2023 08:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684942414; cv=none; d=google.com; s=arc-20160816; b=O88f8I4i1LfVO42Q3+qsIuNm+xaNSU73oK2KN+U7VLwqLrbU/PFUHIVHvgcgGOwDnu 9f5yrRTzNqbqIIJ2Rrfzjn0C6SzysTYU+fhkdTjDckLQcyLc/yYxDqK02aoIszI9zwW4 j2bbR+7qw9gI0Rzv/9In88FUpIpZzWllj8rtSg8EK2LZfPolnoaRcOqHumCWdr7CEYpq 8kHPJghTk0NukKmZNTB7ReezZdG0v4huhX6e4MnnWbojvI5x3MdxI2Dy7hWsJUIcS3m9 3wlCz79KAeV4g3f1eFwRvx2a1lRQbouu7wa1vjV49z3UBdQhzs8SyCHDafiap312XIsK 6tQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2fK/FaNL8tdqPMr1dJgjjCH4zFpVshe/EqSIVKSH4MI=; b=RNTZ7DzsQSD8OPZg6fy3fTAEBdMm+R3DymSEBzcS1s9wCXFcYQQ0lsrZK7MsI53V6d THzHYbz3DSTyGZ/zsQNK9pvc32yl8gGymqzxDHVfsqSv27LuqCgocvL2d86akYMzv983 kLY7jNhK5DwUDy6ROWXBuahrwXmQRwayrpNjuV6F6DlK2dBI0/UEN7EGsGivSI5QwLcS bNPQwcH4nH+QAYKSTdelb4wfn7vL/HD9KusW+gmCRCTKtIgRGDvIh0tHUgjoHrSc4UX+ dUDvR3kijoLVLA356T3F6US51sPNaNAmvpfMHR22imRzpQM/PrXHXb/KI15vwNgIPRLz vaBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=VUgJ0nXp; 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=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h185-20020a6383c2000000b00533fce755a8si1182889pge.471.2023.05.24.08.33.19; Wed, 24 May 2023 08:33:34 -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=@gmx.de header.s=s31663417 header.b=VUgJ0nXp; 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=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235746AbjEXP1A (ORCPT + 99 others); Wed, 24 May 2023 11:27:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235805AbjEXP06 (ORCPT ); Wed, 24 May 2023 11:26:58 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09D3D10B; Wed, 24 May 2023 08:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1684941998; i=deller@gmx.de; bh=+7ESBTMnHGzg+BKexPIHQjMLlUGjKMaqw4IK8630UvE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=VUgJ0nXppL2cSoQPfPaZ9sFoxXNPq3sAWnlS2eRSnwHoGM5lbpghuqTKcBqWr9TDX RUsG/RFliWFIYSrqEI05t/eIeRWNPqVyrZAwx7GxnoLF3fVr6lvlCthH4DJZ/Jhb16 669t/7BzI8s69lwdGSilAdF6c/JFoe+j3AmbP7hUwxdxd3hJMkd932eketQdzP9NY5 GTWCklCGS+Wuiu3nbXe4y25H6BVN8GkQXkvVxr8sgJXYEQXm8cgWhNN2AIpbAYEotr HjdIl7dnTtbp8S72+y+7QGsAZt2Czp3J9+AE0y2dMQFVN+NHtJBvFPjvDKmU77XqSi HYRkvFP580uLA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from p100.fritz.box ([94.134.145.4]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mlw7f-1qS4a526J1-00j47c; Wed, 24 May 2023 17:26:38 +0200 From: Helge Deller To: linux@armlinux.org.uk, dinguyen@kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Helge Deller , Arnd Bergmann , linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] arm: Fix flush_dcache_page() for usage from irq context Date: Wed, 24 May 2023 17:26:31 +0200 Message-Id: <20230524152633.203927-2-deller@gmx.de> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230524152633.203927-1-deller@gmx.de> References: <20230524152633.203927-1-deller@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:tUOwkAD2Hwce0F7HpGXdFvczL1Vky+pJRPAudFb5SqpMeggqADn B/fQ3hYtCFp2le+aYewHIkulKDk774tIryq4+2qkyw3mjaF0HIG659O24ZDTrNfPlyMck6t dO6+9pQO60addIt/pr8QsTme9dFEhBQBJSZ3/xQRt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BNzn82UH+cn1smT46PEofvVmM= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, 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 Since at least kernel 6.1, flush_dcache_page() is called with IRQs disabled, e.g. from aio_complete(). But the current implementation for flush_dcache_page() on ARM unintentionally re-enables IRQs, which may lead to deadlocks. Fix it by using xa_lock_irqsave() and xa_unlock_irqrestore() for the flush_dcache_mmap_*lock() macros instead. Cc: Russell King (Oracle) Cc: Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Helge Deller =2D-- arch/arm/include/asm/cacheflush.h | 4 ++++ arch/arm/mm/flush.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cach= eflush.h index a094f964c869..5b8a1ef0dc50 100644 =2D-- a/arch/arm/include/asm/cacheflush.h +++ b/arch/arm/include/asm/cacheflush.h @@ -315,6 +315,10 @@ static inline void flush_anon_page(struct vm_area_str= uct *vma, #define flush_dcache_mmap_lock(mapping) xa_lock_irq(&mapping->i_pages) #define flush_dcache_mmap_unlock(mapping) xa_unlock_irq(&mapping->i_pages= ) +#define flush_dcache_mmap_lock_irqsave(mapping, flags) \ + xa_lock_irqsave(&mapping->i_pages, flags) +#define flush_dcache_mmap_unlock_irqrestore(mapping, flags) \ + xa_unlock_irqrestore(&mapping->i_pages, flags) /* * We don't appear to need to do anything here. In fact, if we did, we'd diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c index 7ff9feea13a6..d57ec9165520 100644 =2D-- a/arch/arm/mm/flush.c +++ b/arch/arm/mm/flush.c @@ -238,6 +238,7 @@ static void __flush_dcache_aliases(struct address_spac= e *mapping, struct page *p { struct mm_struct *mm =3D current->active_mm; struct vm_area_struct *mpnt; + unsigned long flags; pgoff_t pgoff; /* @@ -248,7 +249,7 @@ static void __flush_dcache_aliases(struct address_spac= e *mapping, struct page *p */ pgoff =3D page->index; - flush_dcache_mmap_lock(mapping); + flush_dcache_mmap_lock_irqsave(mapping, flags); vma_interval_tree_foreach(mpnt, &mapping->i_mmap, pgoff, pgoff) { unsigned long offset; @@ -262,7 +263,7 @@ static void __flush_dcache_aliases(struct address_spac= e *mapping, struct page *p offset =3D (pgoff - mpnt->vm_pgoff) << PAGE_SHIFT; flush_cache_page(mpnt, mpnt->vm_start + offset, page_to_pfn(page)); } - flush_dcache_mmap_unlock(mapping); + flush_dcache_mmap_unlock_irqrestore(mapping, flags); } #if __LINUX_ARM_ARCH__ >=3D 6 =2D- 2.38.1