From patchwork Mon Nov 19 12:28:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Murzin X-Patchwork-Id: 10688627 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FD9C13BF for ; Mon, 19 Nov 2018 12:29:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F421429C27 for ; Mon, 19 Nov 2018 12:29:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E869C29C37; Mon, 19 Nov 2018 12:29:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8663729C27 for ; Mon, 19 Nov 2018 12:29:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=91edDaJ/wi5IM7GOciipBeLkh/vKoAhJsg8ujJHKXYI=; b=PaJ VpsVQgZshafzVvwIMvUoFfVJ4ZMKi6v/ZOLkHxeyxtprJUIQ106mTliTdXs/4Rqv6kbDEUCgwgSwB DW6/xVTR1WUR00Oim7h0NmwlUzgLERwhmNpCp/SbRm9QEir8KSikkDbGfP3raojYPnJHKtFFqOpyU LW82dthoNlwn1q447gZlDo97T4CIyysvU+0bAtlp2wOPnjstiM4k9jv6T7K4aE0jRZTI3ObbesMba Z5F1dJiLApTdHRr4pSLuiY4Xro/7TNdPl5AFdp5k77u6KjhNGRFb16j0Ho3D+AKkTqpiMDqVY/ond QSzv9Pm5RaWnsJCnnNS1r73eioa8aEw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gOifn-0007o6-6o; Mon, 19 Nov 2018 12:29:03 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gOifm-0007o0-0A for linux-arm-kernel@bombadil.infradead.org; Mon, 19 Nov 2018 12:29:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rpfwYfAbOJe6KdW+KN22p3X/ahpLVpIw6r2eSWE4jPA=; b=STdjMZuFIm1tHMScA98YCyJSc 6y8orYMQG8x54jaL01hKcstuwH3kowkxwj8F+DLtBthIsQDwyeMk1A7mjmCkYWJP2xINI0jhEJdil PBpkUJjAuwx+B54AjvKs+CgOV4BwlzUgZ3zXJukzu20K5Uy3jH8ykJBgfAKpHYlGaF2ZclQPwyhTq ZXb7dB+QzHtsCU/yU52bBQF20XRyvpwnqe87HzlZD3iXrubOkVdVOPcjxjOuXkpWzSRt9RIUnroQO G+nN8hQrW7mYZCJBhRNHLgAduhwj5kYX2Colsq5t3PELxU+aXI8blEv+I2kyRRQi1VonyGgZpUXRc +mlSvf25Q==; Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gOifi-0007u9-VT for linux-arm-kernel@lists.infradead.org; Mon, 19 Nov 2018 12:29:00 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 10E7B80D; Mon, 19 Nov 2018 04:28:48 -0800 (PST) Received: from login2.euhpc.arm.com (login2.euhpc.arm.com [10.6.27.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 00C133F5AF; Mon, 19 Nov 2018 04:28:46 -0800 (PST) From: Vladimir Murzin To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: V7M: align v7m_dma_inv_range() with v7 counterpart Date: Mon, 19 Nov 2018 12:28:28 +0000 Message-Id: <1542630508-10325-1-git-send-email-vladimir.murzin@arm.com> X-Mailer: git-send-email 2.0.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181119_122859_179841_61E48E37 X-CRM114-Status: GOOD ( 10.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sza@esh.hu, kbuild-all@01.org, Chris Cole , alexandre.torgue@st.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Chris has discovered and reported that v7_dma_inv_range() may corrupt memory if address range is not aligned to cache line size. Since the whole cache-v7m.S was lifted form cache-v7.S the same observation applies to v7m_dma_inv_range(). So the fix just mirrors what has been done for v7 with a little specific of M-class. Cc: Chris Cole Signed-off-by: Vladimir Murzin --- arch/arm/mm/cache-v7m.S | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/arm/mm/cache-v7m.S b/arch/arm/mm/cache-v7m.S index 788486e8..1059d5e 100644 --- a/arch/arm/mm/cache-v7m.S +++ b/arch/arm/mm/cache-v7m.S @@ -73,9 +73,11 @@ /* * dcimvac: Invalidate data cache line by MVA to PoC */ -.macro dcimvac, rt, tmp - v7m_cacheop \rt, \tmp, V7M_SCB_DCIMVAC +.irp c,,eq,ne,cs,cc,mi,pl,vs,vc,hi,ls,ge,lt,gt,le,hs,lo +.macro dcimvac\c, rt, tmp + v7m_cacheop \rt, \tmp, V7M_SCB_DCIMVAC, \c .endm +.endr /* * dccmvau: Clean data cache line by MVA to PoU @@ -369,14 +371,15 @@ v7m_dma_inv_range: tst r0, r3 bic r0, r0, r3 dccimvacne r0, r3 + addne r0, r0, r2 subne r3, r2, #1 @ restore r3, corrupted by v7m's dccimvac tst r1, r3 bic r1, r1, r3 dccimvacne r1, r3 1: - dcimvac r0, r3 - add r0, r0, r2 - cmp r0, r1 + dcimvaclo r0, r3 + addlo r0, r0, r2 + cmplo r0, r1 blo 1b dsb st ret lr