From patchwork Wed Oct 12 18:53:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13005366 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DBCDBC4332F for ; Wed, 12 Oct 2022 18:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=UmlJR8ri6BqM70wZIMzmCsaobxfNZkLqLrt1jP2w5f0=; b=W1GZ0lkDmSrKLl yKueU4lcuaorNzo4bety1y34tgO6uB7yFbrjkigy7ZsVb6/AQgo5PuQv9VSk4M9gZVbwHG18+GZsF pJc6GGGaJ0zM9RKiU04BHhA/hRNRBBHkXID5j0bApNSq46/G+sAQ+NF7D8TGP/8mz4BKR5TeQb7R0 XuDWR57IzS8WB8ZkBwtkMbkoil01dJu0yl1rjsEFUw/6lmHK/7nsqgbLsksAKGflZ+HlRxeaLz2lX eSk2BSQcZGNc2B8LWaU4XXZTHYskC6p6guP2LimpsoCvIcTZ/ibfROQSXbGh8u7WT6B2diZfURtNk 89s2FSCo/twrc2DC4D8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oigrN-00936c-8d; Wed, 12 Oct 2022 18:53:41 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oigr8-00930F-Nx for linux-amlogic@lists.infradead.org; Wed, 12 Oct 2022 18:53:30 +0000 Received: by mail-pj1-x102e.google.com with SMTP id b15so16069911pje.1 for ; Wed, 12 Oct 2022 11:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HUI2zzepOnCEU2KAh1PakPcQFkZcRivQX+cynj5FE/k=; b=G47NFXoBtILJJHsl1h9GdNIzukt6VCgb5/pFLeR7U3O5C4N4qiIoQW1NZPvUsa8st/ oPEm2Nx/P2qbHAMkKQd6lCihhUbjxai2CtXpicsaa4D5ZMIjuOiplNYvO747uR/eVsS3 qIYRG3YYLOh0QhkdC4Pj6EJGdWLkY13ZTg5uU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HUI2zzepOnCEU2KAh1PakPcQFkZcRivQX+cynj5FE/k=; b=JtLkDcQcqQbTgXJBpmw9GY7m8E0s6l0sOhGjfgQpv09v51IP5XPqm0uV3LEO9lNOP1 Fc613MYaRW9p78mNvtoNqfeTcjpVpL294dgFfeBFIiEIrpbcqeidzEXxlPLXEQpU6LzA OQhCecauinP+K2ju3FIFVms0kW0DNkFpareiqNZb11qdL6aw2CDmMG2k/OS4Ka3zYrSc Z4jpu6gazRCY0TslDsR7tcWP1GaokjCgc8wTTcVUehbGSd0tgz0IiJCClox9xMHImUSb F3njhZgq+94ZORKMflvcPMJ8wII3x322y0I2n1t7/4XTSkJMY15Y/UOZZQB9YfHb++KB +Lew== X-Gm-Message-State: ACrzQf3tSzYFOz8QvzuCI3qExc314DutBTfzYkoniDMavT30LjlUmfpv ipxN8LniBgW/ryOn5x4m/qefaYcCBamOig== X-Google-Smtp-Source: AMsMyM6tV4/PVbF4fBXiv77LdOk7IfPzalAhIVuB7YI1s3Hec2Euf7PJLzGzNvVQPMDGgGwcWHVGdQ== X-Received: by 2002:a17:90a:50:b0:20a:b146:e75e with SMTP id 16-20020a17090a005000b0020ab146e75emr6663558pjb.216.1665600803058; Wed, 12 Oct 2022 11:53:23 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id k15-20020aa7972f000000b00561578478f9sm194609pfg.134.2022.10.12.11.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 11:53:22 -0700 (PDT) From: Kees Cook To: Neil Armstrong Cc: Kees Cook , kernel test robot , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] firmware: meson_sm: Fix memcpy vs iomem type warnings Date: Wed, 12 Oct 2022 11:53:16 -0700 Message-Id: <20221012185234.never.936-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3429; h=from:subject:message-id; bh=4n3aQuAgsH9cCFaGFV2YF2qCSZt1D1FxI4ZpoSOMr4Y=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjRw0bGTY4oQVYR+ruKC+orN1r6Teh+Od53Fv9waOT HIZn6LuJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY0cNGwAKCRCJcvTf3G3AJu5FD/ wMubbkTAppw3VbhksSb2rvGtd2RwYLblLaevZVfdiIIxQKesFXrZQi/wS2Cwb6XxaSTXOEgSOffPOa zhEq33SvE4ENM7J5ZqIAPv9VqvtcX+fPBliGpBoGcWAnKCxR667DtFC9LZXMeLhmxjbPMgRAMZoOAU 4//ZxbyuL9UHpu800Xr/8nnEuJ3cMu4nHovmggaKixXK1N5GX1ZdcBWCo5RGdwh5n0Iif3o9HJJjmU s3UwoFQvJHoUqMH+FEZHmdFiJE/XGDbJ5JwNXNfpqU5x4d8xrvyJ3JbsiXmQeugU2GOZoc22W6FrwS NIN2b0hZ4FEl77gdRrWT/Vz2bTj6VuezL7QRwgolwQRuaVG6mAinZCwTnbWDttcvkNvuMy9R5MekK3 aVn0JOcp+BCMyv5VZ12X0equ31lB2Xs9L+eK9VgpfeHoIHN+RjohE6es2z0WiIfiYDtk/CG2t6vwGQ sd9WC3iTu9CgiV3pzaUDGybpycEYkapB5rMindsjvRaLBpSPcIGd89A6P06RRh5/vd72Wpe1tskKRU kYyAUVF5RAeskLkQHaDW3hXYoiW1iMipK+yGMKGoRyl7udlBJOde7Zhj8TDuPKp2KV6kuJmFZl6t/J fwr4H8dbXiTgXoSmQtZNB0kMV9isVsilNsltNeyV26+C8DN9xIJbWZO+Y/+g== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221012_115326_935989_3B9321E3 X-CRM114-Status: GOOD ( 11.74 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Use memcpy_{toio,fromio}() instead of memcpy(). Silences warnings from Sparse: drivers/firmware/meson/meson_sm.c:170:17: warning: incorrect type in argument 1 (different address spaces) drivers/firmware/meson/meson_sm.c:170:17: expected void const * drivers/firmware/meson/meson_sm.c:170:17: got void [noderef] __iomem *sm_shmem_out_base drivers/firmware/meson/meson_sm.c:170:17: warning: incorrect type in argument 2 (different address spaces) drivers/firmware/meson/meson_sm.c:170:17: expected void const * drivers/firmware/meson/meson_sm.c:170:17: got void [noderef] __iomem *sm_shmem_out_base drivers/firmware/meson/meson_sm.c:206:9: warning: incorrect type in argument 1 (different address spaces) drivers/firmware/meson/meson_sm.c:206:9: expected void const * drivers/firmware/meson/meson_sm.c:206:9: got void [noderef] __iomem *sm_shmem_in_base drivers/firmware/meson/meson_sm.c:206:9: warning: incorrect type in argument 1 (different address spaces) drivers/firmware/meson/meson_sm.c:206:9: expected void const * drivers/firmware/meson/meson_sm.c:206:9: got void [noderef] __iomem *sm_shmem_in_base drivers/firmware/meson/meson_sm.c:206:9: warning: incorrect type in argument 1 (different address spaces) drivers/firmware/meson/meson_sm.c:206:9: expected void const * drivers/firmware/meson/meson_sm.c:206:9: got void [noderef] __iomem *sm_shmem_in_base drivers/firmware/meson/meson_sm.c:206:9: warning: incorrect type in argument 1 (different address spaces) drivers/firmware/meson/meson_sm.c:206:9: expected void * drivers/firmware/meson/meson_sm.c:206:9: got void [noderef] __iomem *sm_shmem_in_base While here, fix this warning as well: drivers/firmware/meson/meson_sm.c:85:24: warning: Using plain integer as NULL pointer Reported-by: kernel test robot Link: https://lore.kernel.org/lkml/202210122023.zF56nCzM-lkp@intel.com Cc: Neil Armstrong Cc: Kevin Hilman Cc: Jerome Brunet Cc: Martin Blumenstingl Cc: linux-arm-kernel@lists.infradead.org Cc: linux-amlogic@lists.infradead.org Signed-off-by: Kees Cook Acked-by: Neil Armstrong --- drivers/firmware/meson/meson_sm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/meson/meson_sm.c b/drivers/firmware/meson/meson_sm.c index 77aa5c6398aa..4efde225a580 100644 --- a/drivers/firmware/meson/meson_sm.c +++ b/drivers/firmware/meson/meson_sm.c @@ -82,7 +82,7 @@ static void __iomem *meson_sm_map_shmem(u32 cmd_shmem, unsigned int size) sm_phy_base = __meson_sm_call(cmd_shmem, 0, 0, 0, 0, 0); if (!sm_phy_base) - return 0; + return NULL; return ioremap_cache(sm_phy_base, size); } @@ -167,7 +167,7 @@ int meson_sm_call_read(struct meson_sm_firmware *fw, void *buffer, size = bsize; if (buffer) - memcpy(buffer, fw->sm_shmem_out_base, size); + memcpy_fromio(buffer, fw->sm_shmem_out_base, size); return ret; } @@ -203,7 +203,7 @@ int meson_sm_call_write(struct meson_sm_firmware *fw, void *buffer, if (!fw->chip->cmd_shmem_in_base) return -EINVAL; - memcpy(fw->sm_shmem_in_base, buffer, size); + memcpy_toio(fw->sm_shmem_in_base, buffer, size); if (meson_sm_call(fw, cmd_index, &written, arg0, arg1, arg2, arg3, arg4) < 0) return -EINVAL;