Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751264AbcJJIwu (ORCPT ); Mon, 10 Oct 2016 04:52:50 -0400 Received: from mail-lf0-f50.google.com ([209.85.215.50]:35821 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750764AbcJJIwq (ORCPT ); Mon, 10 Oct 2016 04:52:46 -0400 To: Jeff Kirsher , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Chris Healy From: Nikita Yushchenko Subject: igb driver can cause cache invalidation of non-owned memory? X-Enigmail-Draft-Status: N1110 Message-ID: <0b57cbe2-84f7-6c0a-904a-d166571234b5@cogentembedded.com> Date: Mon, 10 Oct 2016 11:52:06 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1258 Lines: 30 Hi DMA mapping scheme introduced in commit cbc8e55f6fda ('igb: Map entire page and sync half instead of mapping and unmapping half pages') back in 2012, and used up to now, can probably cause breakage of unrelated code on archs with non-coherent caches. With this scheme, page used for Rx is completely dma_map()ed at allocation time, split into two buffers, and individual buffer is sync_to_cpu()ed AND PASSED TO NETWORK STACK via skb_add_rx_frag() - while driver driver still uses other buffer. Later, when driver decides to no longer use this page, it will dma_unmap() it completely - which on archs with non-coherent caches means cache invalidation. This cache invalidation will include area that is already passed elsewhere. If external code has performed any writes to that area and writes still are in cache only, cache invalidation will cause writes to be lost. I'm not sure if this breakage is indeed possible. I did not face it, just found while checking how things work. Code in question is in kernel already for 4 years. However, since (1) igb is mostly used on x86 where caches are coherent, and (2) Rx buffers are normally not written to, it could stay unnoticed all that time. Could somebody please comment on this? Nikita Yushchenko