Received: by 10.213.65.68 with SMTP id h4csp477808imn; Fri, 16 Mar 2018 08:59:04 -0700 (PDT) X-Google-Smtp-Source: AG47ELvObDQiA6xyoCyHQ9CRSXWGE7RP015twqMhpxtnyrr3loxacCjS9nSrDScVitSH4p2ziORG X-Received: by 2002:a17:902:367:: with SMTP id 94-v6mr2749866pld.140.1521215944575; Fri, 16 Mar 2018 08:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521215944; cv=none; d=google.com; s=arc-20160816; b=M4IJJYmfCmpisneJa30dXI1jzf1BTwj/A6Wrs5dbHSkN50Nr4KlalPN/jjTxA2QJsL bi7q6fUCwxRFjHEpWB9D+dd1ZwCM9ZuwFuAged25e6TYDGUmjnYLYWX73eA/uLd8m74i HOL+UnDpku25xXy3zkR1ioJ1avhcK43XhoIs8pJU+6xeApWQmFDkIfTHlxllZArmwPMX KWY29OGiZME+2BU3sJEFe0sXenjXPmR2qOzN9ek+lk7/XjTB10mTOyHAFRL9q/cZJe4t YdybZLqJHp+icBiKVt/4nCLqVv5jWUMTllj6/svp8NHpwVsJXUWQKuJyCM4MVNxtA/R0 NpFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=OAlCoW8W/Ve+D8InqicWZIyeE1DdJEAMWdU3IsuvYyg=; b=kBNwu8GGDpwUSrruRa0Je2DLRuPm6B5mW4Cbjw2/nodamzCctiO+a7Fs8byc+nxpnN lTkstRivknzXgfXjD93fEdV1cWt0HFT/XNLH2DIUJb1KBMXxHh0sWKijljXHG6hLFzHp QvoISEoIlfBDzWUBX3jccn0Rdgp54vr1wP0zwr137NKoDgY90cOVtrUkO7PTJGbuxyP1 EST63wghRShx5YGeSPgLeUeYeicKv6Fucg8h17TOSQH5nHxo8zYbIgPXYoZJ3m2eLLSP CtG9fqd9Y7LsCcrI1b1sj0tlojxSEdAytmHA0ib1V/WbPiiiVVSfGynlaScXGuxoLGRt Yjhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si5078565pgo.625.2018.03.16.08.58.48; Fri, 16 Mar 2018 08:59:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965045AbeCPP5N (ORCPT + 99 others); Fri, 16 Mar 2018 11:57:13 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45732 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965331AbeCPPnv (ORCPT ); Fri, 16 Mar 2018 11:43:51 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A6286D13; Fri, 16 Mar 2018 15:43:50 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ioana Radulescu , Sasha Levin Subject: [PATCH 4.15 103/128] staging: fsl-dpaa2/eth: Fix access to FAS field Date: Fri, 16 Mar 2018 16:24:04 +0100 Message-Id: <20180316152341.680666406@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ioana Radulescu [ Upstream commit 54ce891779888e85a2db04942dbaadd3f40fe223 ] Commit 4b2d9fe87950 ("staging: fsl-dpaa2/eth: Extra headroom in RX buffers") removes the software annotation (SWA) area from the RX buffer layout, as it's not used by anyone, but fails to update the macros for accessing hardware annotation (HWA) fields, which is right after the SWA in the buffer headroom. This may lead to some frame annotation status fields (e.g. indication if L3/L4 checksum is valid) to be read incorrectly. Turn the accessor macros into inline functions and add a bool param to specify if SWA is present or not. Fixes: 4b2d9fe87950 ("staging: fsl-dpaa2/eth: Extra headroom in RX buffers") Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 8 ++++---- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -249,7 +249,7 @@ static void dpaa2_eth_rx(struct dpaa2_et vaddr = dpaa2_iova_to_virt(priv->iommu_domain, addr); dma_unmap_single(dev, addr, DPAA2_ETH_RX_BUF_SIZE, DMA_FROM_DEVICE); - fas = dpaa2_get_fas(vaddr); + fas = dpaa2_get_fas(vaddr, false); prefetch(fas); buf_data = vaddr + dpaa2_fd_get_offset(fd); prefetch(buf_data); @@ -385,7 +385,7 @@ static int build_sg_fd(struct dpaa2_eth_ * on TX confirmation. We are clearing FAS (Frame Annotation Status) * field from the hardware annotation area */ - fas = dpaa2_get_fas(sgt_buf); + fas = dpaa2_get_fas(sgt_buf, true); memset(fas, 0, DPAA2_FAS_SIZE); sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset); @@ -458,7 +458,7 @@ static int build_single_fd(struct dpaa2_ * on TX confirmation. We are clearing FAS (Frame Annotation Status) * field from the hardware annotation area */ - fas = dpaa2_get_fas(buffer_start); + fas = dpaa2_get_fas(buffer_start, true); memset(fas, 0, DPAA2_FAS_SIZE); /* Store a backpointer to the skb at the beginning of the buffer @@ -510,7 +510,7 @@ static void free_tx_fd(const struct dpaa fd_addr = dpaa2_fd_get_addr(fd); skbh = dpaa2_iova_to_virt(priv->iommu_domain, fd_addr); - fas = dpaa2_get_fas(skbh); + fas = dpaa2_get_fas(skbh, true); if (fd_format == dpaa2_fd_single) { skb = *skbh; --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h @@ -153,10 +153,15 @@ struct dpaa2_fas { #define DPAA2_FAS_SIZE (sizeof(struct dpaa2_fas)) /* Accessors for the hardware annotation fields that we use */ -#define dpaa2_get_hwa(buf_addr) \ - ((void *)(buf_addr) + DPAA2_ETH_SWA_SIZE) -#define dpaa2_get_fas(buf_addr) \ - (struct dpaa2_fas *)(dpaa2_get_hwa(buf_addr) + DPAA2_FAS_OFFSET) +static inline void *dpaa2_get_hwa(void *buf_addr, bool swa) +{ + return buf_addr + (swa ? DPAA2_ETH_SWA_SIZE : 0); +} + +static inline struct dpaa2_fas *dpaa2_get_fas(void *buf_addr, bool swa) +{ + return dpaa2_get_hwa(buf_addr, swa) + DPAA2_FAS_OFFSET; +} /* Error and status bits in the frame annotation status word */ /* Debug frame, otherwise supposed to be discarded */