Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6765260rwn; Tue, 13 Sep 2022 08:43:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR7IUkStyabafkXXJmkKaBeeQ4NGbxCmtYq9JwVJ8OE+NJNNHf4MHZy2mO4R4q9yjSb2fyRn X-Received: by 2002:a17:906:cc4b:b0:772:3844:6ab2 with SMTP id mm11-20020a170906cc4b00b0077238446ab2mr19350938ejb.211.1663083837458; Tue, 13 Sep 2022 08:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663083837; cv=none; d=google.com; s=arc-20160816; b=npeeFnWcu0YbgdNALEsXEdEI15Fzm2Exl/vyy1s0Z3w1tLQbdunujPzBkLNa6et4Vv M5VAriiqWSaVAXqjCee7Z4Y/tj3d7b67W0evQKYVrTedYU5RB0pN2pZgg8y++cRKMaKA M93BOVDz4DK8teluyuPlLg9v/D9ecDHBXvrYlezeOAsd2jE70kLwNMqShCsYz8W6hHds /3npR877+oi92V/5ZyYAlxh0tq6fvcX8ky0WSyNx8qfsOGwUNbuSPd1o89JHfjhNPfYi 4+AiQmjmQxs+7Lfh5YoUFA0wWm2R3lP0FTf1PhymC2pHDi+3Rmf3ICmgIvDVQUyqQsig Ylbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hqj8C8Sh11u50T+CHB1aXQkPYX0YkuptXkbLv1ypH3I=; b=cOcD2pjdXtnl0eYoV1WxZj6dZcFCUZ3SWtLF2SqGtDkgZ/3hLsznBgGVIeF2D8Y10A I2sUw+gORoPJVv3qZrkJckPYgOR5Pi2Wh1d8qUZDHYlVBO4Ard9wGi1dh2xBKXBUfP37 pkSXDytiEgebxFkW68iCmjTMxxIEb4ihZRWHQq4+GNVJaosBphkHD/jHpwY4ZopTV2/8 N7+BFS2v31aDFuv1bJdZWYXuuS+n2rDaiNg0WDsoe6VCS+AXuDAScZ15H/SK2937FLy7 Ul9wKyHuVfs4BpfIC34v/Z4Qm2oPGs9zRlTKzh+zJ38/WyRf7yLhjnuR7FRc79c619b5 vZ3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="fac/cf63"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb10-20020a0564020d0a00b00448b72be304si10180399edb.64.2022.09.13.08.43.29; Tue, 13 Sep 2022 08:43:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="fac/cf63"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235137AbiIMPFN (ORCPT + 99 others); Tue, 13 Sep 2022 11:05:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235057AbiIMPDQ (ORCPT ); Tue, 13 Sep 2022 11:03:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D36B73B0; Tue, 13 Sep 2022 07:29:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2927DB80FBC; Tue, 13 Sep 2022 14:29:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7288DC433C1; Tue, 13 Sep 2022 14:29:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079351; bh=00iZ6bvz/69wZ0JiR2KqD0rgb6QaCmzy1HgetsWSBL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fac/cf63quVNOnsQ+uwyhKSuvl/0fLJniJsVlsU3FIIoZPkhMpm8YIPHw42V4SUbu ki9A5TxkdkOe1hpBSw9XYWGed1QeGXTHrBM1c0FUisNRBGCfgMvR39Pm/rOp/l7NfT k6J7/jbDVYRnOz/A852chuMUm40TiQ7H5hlPhl3E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, linux-rdma@vger.kernel.org, Linus Walleij , Leon Romanovsky , Sasha Levin Subject: [PATCH 5.4 101/108] RDMA/siw: Pass a pointer to virt_to_page() Date: Tue, 13 Sep 2022 16:07:12 +0200 Message-Id: <20220913140357.957720068@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140353.549108748@linuxfoundation.org> References: <20220913140353.549108748@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Walleij [ Upstream commit 0d1b756acf60da5004c1e20ca4462f0c257bf6e1 ] Functions that work on a pointer to virtual memory such as virt_to_pfn() and users of that function such as virt_to_page() are supposed to pass a pointer to virtual memory, ideally a (void *) or other pointer. However since many architectures implement virt_to_pfn() as a macro, this function becomes polymorphic and accepts both a (unsigned long) and a (void *). If we instead implement a proper virt_to_pfn(void *addr) function the following happens (occurred on arch/arm): drivers/infiniband/sw/siw/siw_qp_tx.c:32:23: warning: incompatible integer to pointer conversion passing 'dma_addr_t' (aka 'unsigned int') to parameter of type 'const void *' [-Wint-conversion] drivers/infiniband/sw/siw/siw_qp_tx.c:32:37: warning: passing argument 1 of 'virt_to_pfn' makes pointer from integer without a cast [-Wint-conversion] drivers/infiniband/sw/siw/siw_qp_tx.c:538:36: warning: incompatible integer to pointer conversion passing 'unsigned long long' to parameter of type 'const void *' [-Wint-conversion] Fix this with an explicit cast. In one case where the SIW SGE uses an unaligned u64 we need a double cast modifying the virtual address (va) to a platform-specific uintptr_t before casting to a (void *). Fixes: b9be6f18cf9e ("rdma/siw: transmit path") Cc: linux-rdma@vger.kernel.org Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20220902215918.603761-1-linus.walleij@linaro.org Signed-off-by: Leon Romanovsky Signed-off-by: Sasha Levin --- drivers/infiniband/sw/siw/siw_qp_tx.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_qp_tx.c b/drivers/infiniband/sw/siw/siw_qp_tx.c index 424918eb1cd4a..5e6d96bd2eb12 100644 --- a/drivers/infiniband/sw/siw/siw_qp_tx.c +++ b/drivers/infiniband/sw/siw/siw_qp_tx.c @@ -29,7 +29,7 @@ static struct page *siw_get_pblpage(struct siw_mem *mem, u64 addr, int *idx) dma_addr_t paddr = siw_pbl_get_buffer(pbl, offset, NULL, idx); if (paddr) - return virt_to_page(paddr); + return virt_to_page((void *)paddr); return NULL; } @@ -523,13 +523,23 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx, struct socket *s) kunmap(p); } } else { - u64 va = sge->laddr + sge_off; + /* + * Cast to an uintptr_t to preserve all 64 bits + * in sge->laddr. + */ + uintptr_t va = (uintptr_t)(sge->laddr + sge_off); - page_array[seg] = virt_to_page(va & PAGE_MASK); + /* + * virt_to_page() takes a (void *) pointer + * so cast to a (void *) meaning it will be 64 + * bits on a 64 bit platform and 32 bits on a + * 32 bit platform. + */ + page_array[seg] = virt_to_page((void *)(va & PAGE_MASK)); if (do_crc) crypto_shash_update( c_tx->mpa_crc_hd, - (void *)(uintptr_t)va, + (void *)va, plen); } -- 2.35.1