Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp523939rdb; Fri, 6 Oct 2023 10:07:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEuCBW9gn1uT54r2s1tMWDvmjMHvNyLqRapjonkKHCqUTdZAU6cEIVRs1Ul+Fm2F5s/lYwY X-Received: by 2002:a05:6a00:1403:b0:68f:a92a:8509 with SMTP id l3-20020a056a00140300b0068fa92a8509mr7089983pfu.7.1696612071766; Fri, 06 Oct 2023 10:07:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696612071; cv=none; d=google.com; s=arc-20160816; b=nyhJPE70wqw/38AF0dMkDEPdG1c+HjkazRfB+CWmI6Fn4Zj1i6AqcXPHb/N5cm0KNW HMmZUeRHQB8xMrLl258c8ETNRZaCMJudwSRbG5pA1VhuVg0VMLpkEZsx7dKgBa2rqGXZ e/XKPfj5/EFUs7ISI6NEodY+EbDYB2wQjkq7pylx6prq6R22nCdN6gzOxZ5MWN0eBxsg zrR/fP8dW38E1nVa7nwzU+qlAjYwEZ8RfTZyqNa9S6gUjZlV5eXM5mM8LpZtmJmo7v5+ URuz5nvdNuslagPMSMQJ6nQVgpaH//Mm1QFOVYWXupZES+BBiNErT99jBGbZXqx4e7mQ kVGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=QnlDtjxOkF0rM7zIuBEIhztTIzHhCHt7pEN9j5SC+FI=; fh=YRcRVoscLGqDtMiHiMjRFdT/YN/bRhXs9TgNnGhGcuM=; b=Xuq+FQJV2dUaikWP1JK9dzgnbZu9PThFuAtxgZvOg6/rWzeq4uL4cJoi3t9RcAr4Qk HDTjnf+8NpB0tFshWAHnlUGpi31OQhbLTkORiOsHgAQnl02Azn9UfBfupG50PAveL1BS /+5/4xTb9sV3tZQyLFEE24xgV48hDCG3gl87VRPC3N1/jDjYuacNg2R7TwwNXOjR965K sTBwqSZMtPpsTxUhPJpml7kkt0nK5q1ZbnM2L6d9hQor3fSf37xyvDUeYkypKRZhCOsp Y4cvpfWMgAaxYhkOz5TxoPclOwmT4yVCj6E0Ef+GGEXDLLC82MKnAH/RKzoz4gyLEiRE raGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WK5G4ObC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id k7-20020a056a00168700b0068fa57cc15bsi1937502pfc.124.2023.10.06.10.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 10:07:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WK5G4ObC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 40F73811AD8C; Fri, 6 Oct 2023 10:07:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232198AbjJFRHh (ORCPT + 99 others); Fri, 6 Oct 2023 13:07:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232877AbjJFRHg (ORCPT ); Fri, 6 Oct 2023 13:07:36 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6339DBF for ; Fri, 6 Oct 2023 10:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696612006; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QnlDtjxOkF0rM7zIuBEIhztTIzHhCHt7pEN9j5SC+FI=; b=WK5G4ObCyD4c5CEo98PgYKtu7Im2kNd7Rol0Q6a8vggsxPF/ADL1DhFyuCHBL5DLUa/1HK L0D8WlM7D9vwdchJuzlUfg99Nx2OVgzMVsESLuQzX4je85vnCitm/oJfl7VRW/D9JONOpQ zjBUmKvydMuqeVjkiCOVMcfvCI64A54= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-426-4kbiZlmrPeS0nQxTfD5PLA-1; Fri, 06 Oct 2023 13:06:44 -0400 X-MC-Unique: 4kbiZlmrPeS0nQxTfD5PLA-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-534543af820so2126734a12.2 for ; Fri, 06 Oct 2023 10:06:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696612003; x=1697216803; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QnlDtjxOkF0rM7zIuBEIhztTIzHhCHt7pEN9j5SC+FI=; b=CYSTGjGJ/kHOdJGus9PubP7zFHcfJkLrpaIGaevfWI+FFkHjNi2SoQ4bv9d9u/YupV tfNTQLF+TmnyCGyV40PjzRJtNhgoPT1ce0r4lMh+DVyr5+y+nShVpJXGyNlVYjh/A23o 76M0i0Hir7B4D8QJ8XYuUvBPoMxDZ/CBDDPGQo1HUnJuaOHc4osY/nGYaiR5mGgWBkFP nP4DAcAI/tvA3QSZeGkrIEB0UwYzpRNlOwWgVZKavitHhwm3igvIPZq11qUrm+XTiAu/ LzqBRSWE4WaV/7Q+adghT7z578f16on9f3UpMFQYLgYs7FmS8u1kF6cR7HZaZNKd+hFb pa2A== X-Gm-Message-State: AOJu0YywUWlxAXgC0lnFzHicQSBAuCdLd482M5Q7xmHjBG7e5iCyNDnz idG4jkrDLRjhTgomaucJYFNMTv3s8kILimeAxaUwUXW1Wv1fonhWE1XMcbBD4tqFQ9jCt6KiFI4 F2542rqbq+rzY2dO+Hxp+X1Ab X-Received: by 2002:a50:ef0d:0:b0:522:2782:537 with SMTP id m13-20020a50ef0d000000b0052227820537mr7746165eds.15.1696612003040; Fri, 06 Oct 2023 10:06:43 -0700 (PDT) X-Received: by 2002:a50:ef0d:0:b0:522:2782:537 with SMTP id m13-20020a50ef0d000000b0052227820537mr7746148eds.15.1696612002793; Fri, 06 Oct 2023 10:06:42 -0700 (PDT) Received: from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec? (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id n24-20020aa7d058000000b0053331f9094dsm2841348edo.52.2023.10.06.10.06.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Oct 2023 10:06:42 -0700 (PDT) Message-ID: <4d40eacb-382a-f0e9-2dcd-9f9e8c7ca9fd@redhat.com> Date: Fri, 6 Oct 2023 19:06:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v1 1/1] platform/mellanox: mlxbf-tmfifo: Fix a warning message Content-Language: en-US, nl To: Liming Sun , Vadim Pasternak , David Thompson , Mark Gross , Dan Carpenter Cc: "platform-driver-x86@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <35467b21-941f-c829-1ad8-b4e7319dbc04@redhat.com> From: Hans de Goede In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 06 Oct 2023 10:07:49 -0700 (PDT) Hi Liming, On 10/6/23 17:50, Liming Sun wrote: > Thanks Hans. > > Below is the logic: > > IS_VRING_DROP() is ONLY set to TRUE for Rx, which is done in two places: > Line 696: *desc = &vring->drop_desc; > Line 742: desc = &vring->drop_desc; > > So line 634 below will never happen when IS_VRING_DROP() is TRUE due the checking of line 633. > 633 if (!is_rx) > 634 writeq(data, fifo->tx.data); > > Please correct me if it's my misunderstanding. If IS_VRING_DROP() is ONLY set to TRUE for Rx, then it should simply *not* be checked *at all* in the tx paths. Just setting data = 0 is simply papering over the warning without actually fixing anything. Regards, Hans >> -----Original Message----- >> From: Hans de Goede >> Sent: Friday, October 6, 2023 8:54 AM >> To: Liming Sun ; Vadim Pasternak >> ; David Thompson ; Mark >> Gross ; Dan Carpenter >> Cc: platform-driver-x86@vger.kernel.org; linux-kernel@vger.kernel.org >> Subject: Re: [PATCH v1 1/1] platform/mellanox: mlxbf-tmfifo: Fix a warning >> message >> >> Hi Liming, >> >> On 10/5/23 14:18, Liming Sun wrote: >>> This commit fixes the smatch static checker warning in >>> mlxbf_tmfifo_rxtx_word() which complains data not initialized at >>> line 634 when IS_VRING_DROP() is TRUE. This is not a real bug since >>> line 634 is for Tx while IS_VRING_DROP() is only set for Rx. So there >>> is no case that line 634 is executed when IS_VRING_DROP() is TRUE. >>> >>> This commit initializes the local data variable to avoid unnecessary >>> confusion to those static analyzing tools. >>> >>> Signed-off-by: Liming Sun >>> --- >>> drivers/platform/mellanox/mlxbf-tmfifo.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c >> b/drivers/platform/mellanox/mlxbf-tmfifo.c >>> index f3696a54a2bd..ccc4b51d3379 100644 >>> --- a/drivers/platform/mellanox/mlxbf-tmfifo.c >>> +++ b/drivers/platform/mellanox/mlxbf-tmfifo.c >>> @@ -595,8 +595,8 @@ static void mlxbf_tmfifo_rxtx_word(struct >> mlxbf_tmfifo_vring *vring, >>> { >>> struct virtio_device *vdev = vring->vq->vdev; >>> struct mlxbf_tmfifo *fifo = vring->fifo; >>> + u64 data = 0; >>> void *addr; >>> - u64 data; >>> >>> /* Get the buffer address of this desc. */ >>> addr = phys_to_virt(virtio64_to_cpu(vdev, desc->addr)); >> >> >> This will fix the warning but not the issue at hand. As Dan pointed >> out in his original bug report, the issue is that after: >> >> 78034cbece79 ("platform/mellanox: mlxbf-tmfifo: Drop the Rx packet if no >> descriptors") >> >> We now have this IS_VRING_DROP() check in the path, which despite >> the subject writeq(data, fifo->tx.data);is currently being applied to both rx and >> tx vring-s >> and when this returns true the memcpy from the ring to &data >> will not happen, but the code will still do: >> >> writeq(data, fifo->tx.data); >> >> So you may have silenced the warning now, but you will still write >> data not coming from the vring to transmit. The only difference >> is you are now guaranteed to write all zeroes. >> >> Note another older issue is that if you hit the not enough space >> path: >> >> } else { >> /* Leftover bytes. */ >> if (!IS_VRING_DROP(vring)) { >> if (is_rx) >> memcpy(addr + vring->cur_len, &data, >> len - vring->cur_len); >> else >> memcpy(&data, addr + vring->cur_len, >> len - vring->cur_len); >> } >> vring->cur_len = len; >> } >> >> Then even if IS_VRING_DROP() returns true you are only initializing some bytes >> of the 8 bytes data variable and the other bytes will stay at whatever random >> value they had before and you end up writing this random bytes when doing: >> >> writeq(data, fifo->tx.data); >> >> Regards, >> >> Hans >> >> >> >