From patchwork Thu Jan 29 22:38:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iyappan Subramanian X-Patchwork-Id: 5745661 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E890F9F38B for ; Thu, 29 Jan 2015 22:37:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2410E20221 for ; Thu, 29 Jan 2015 22:37:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 32C0D2013A for ; Thu, 29 Jan 2015 22:37:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YGxgZ-00076Y-FB; Thu, 29 Jan 2015 22:35:39 +0000 Received: from exprod5og111.obsmtp.com ([64.18.0.22] helo=mail-pa0-f44.google.com) by bombadil.infradead.org with smtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YGxgW-0006vZ-Nv for linux-arm-kernel@lists.infradead.org; Thu, 29 Jan 2015 22:35:37 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) (using TLSv1) by exprod5ob111.postini.com ([64.18.4.12]) with SMTP ID DSNKVMq1oYCMV29yzsrVmwwqaFCW603Dzgl+@postini.com; Thu, 29 Jan 2015 14:35:36 PST Received: by mail-pa0-f44.google.com with SMTP id rd3so43996222pab.3 for ; Thu, 29 Jan 2015 14:35:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dWdthJl00ADUER336i4f1znpNHX0kp1g3rxiP/DZshE=; b=WqppT7fnozUA3qgES+uYMJYnPBtC/RXMgWrmG2kjrahPrnppA/8377ErB9pZ9crWNw u1y8oQpJY2z9PJ7en5kXqmJ8MY7WqEL8L0d5Pupbu+rol2tjLeI3GVW+eoMZeV+e/X0+ u1urTYhxMCqd1ITQDpySJ+JBAXA+4IxA1YdarlE5pra9tvHMlqsINsLgqkxY5/RU6nhh uVtoic2ZvdyOk2plZ6eKqlg7qRqbVJoISI6fTOC+umIVe58jwYNxl1hfhVNE6Rf9xouE qhctHc+UtQuWV1fu+W8BHHTgN41jrFu/EF/LQVxFKIIc4JslRFfUsA7Do47V1xIWG5KP boZw== X-Gm-Message-State: ALoCoQljJ3jUJP4ObNeIyuDKngVuwnacEJ6hduQJOST9+50Oko5qgV45GpaitK+C5mCZ6MSPp9A9pMDzHBD7vqpqirSVf0vSUcTYLutmmVOGRXvf35JxWYTt9AkeMS0rLm5M/bnzXEEdAKVOY35Z3AQwdPJ86Ol4Cmalt8BLjMQbCK7tDjnJ0+c= X-Received: by 10.70.123.10 with SMTP id lw10mr3890813pdb.161.1422570913093; Thu, 29 Jan 2015 14:35:13 -0800 (PST) X-Received: by 10.70.123.10 with SMTP id lw10mr3890794pdb.161.1422570912951; Thu, 29 Jan 2015 14:35:12 -0800 (PST) Received: from svdclab-13-11.amcc.com (67-207-112-226.static.wiline.com. [67.207.112.226]) by mx.google.com with ESMTPSA id b15sm6132174pbu.24.2015.01.29.14.35.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 14:35:11 -0800 (PST) From: Iyappan Subramanian To: davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH v2] drivers: net: xgene: fix: Out of order descriptor bytes read Date: Thu, 29 Jan 2015 14:38:23 -0800 Message-Id: <1422571103-17497-1-git-send-email-isubramanian@apm.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150129_143536_820584_F8112F39 X-CRM114-Status: UNSURE ( 9.32 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) Cc: mlangsdo@redhat.com, eric.dumazet@gmail.com, patches@apm.com, linux-kernel@vger.kernel.org, Iyappan Subramanian , Keyur Chudgar , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes the following kernel crash, WARNING: CPU: 2 PID: 0 at net/ipv4/tcp_input.c:3079 tcp_clean_rtx_queue+0x658/0x80c() Call trace: [] dump_backtrace+0x0/0x184 [] show_stack+0x10/0x1c [] dump_stack+0x74/0x98 [] warn_slowpath_common+0x88/0xb0 [] warn_slowpath_null+0x14/0x20 [] tcp_clean_rtx_queue+0x654/0x80c [] tcp_ack+0x454/0x688 [] tcp_rcv_established+0x4a4/0x62c [] tcp_v4_do_rcv+0x16c/0x350 [] tcp_v4_rcv+0x8e8/0x904 [] ip_local_deliver_finish+0x100/0x26c [] ip_local_deliver+0xac/0xc4 [] ip_rcv_finish+0xe8/0x328 [] ip_rcv+0x24c/0x38c [] __netif_receive_skb_core+0x29c/0x7c8 [] __netif_receive_skb+0x28/0x7c [] netif_receive_skb_internal+0x5c/0xe0 [] napi_gro_receive+0xb4/0x110 [] xgene_enet_process_ring+0x144/0x338 [] xgene_enet_napi+0x1c/0x50 [] net_rx_action+0x154/0x228 [] __do_softirq+0x110/0x28c [] irq_exit+0x8c/0xc0 [] handle_IRQ+0x44/0xa8 [] gic_handle_irq+0x38/0x7c [...] Software writes poison data into the descriptor bytes[15:8] and upon receiving the interrupt, if those bytes are overwritten by the hardware with the valid data, software also reads bytes[7:0] and executes receive/tx completion logic. If the CPU executes the above two reads in out of order fashion, then the bytes[7:0] will have older data and causing the kernel panic. We have to force the order of the reads and thus this patch introduces read memory barrier between these reads. Signed-off-by: Iyappan Subramanian Signed-off-by: Keyur Chudgar --- v2: Address comments from v1 * replaced smp_rmb() with dma_rmb() --- drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c index 83a5028..793f3b7 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c @@ -369,6 +369,8 @@ static int xgene_enet_process_ring(struct xgene_enet_desc_ring *ring, if (unlikely(xgene_enet_is_desc_slot_empty(raw_desc))) break; + /* read fpqnum field after dataaddr field */ + dma_rmb(); if (is_rx_desc(raw_desc)) ret = xgene_enet_rx_frame(ring, raw_desc); else