From patchwork Fri Sep 18 14:18:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 11785185 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF19259D for ; Fri, 18 Sep 2020 14:26:26 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8BDFC20848 for ; Fri, 18 Sep 2020 14:26:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="D2lJv+cb"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="etyuSs3O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8BDFC20848 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject: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=hA+2y+JoNM6+NLbKWt6tiPxexfjp6s46PcTH2bm7MWU=; b=D2lJv+cb2WSH+OMsgjLiMMEoiG 6ECK1EqVH26akgG9dpE5VyibVgQ/OowxT4uKhrptnFHeyNvkKGADpsELnRSbEiPoQtF653rRdpDVd A1dMaZkbvjcai50QuccCO9OZWSM6gd08HUzO8FXbVWWYmPIC6ZnmAzIhCwS48HNDQxectIEvizinp U1iXQ0pw7fuyzukIGAbe33z76TTlsUKD0k25eHA39+plqhAmnvgGaaHq/Bn7L3AhMnLvbTh4kJrGT UYI6HbZQlsBslEzufUfgdhjqOHstmnbUsVOvGoB6tnic+Mb9FfgP3EVDE5nZQRxm+B87D2/vKEIgx ProOJNHQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJHJX-0001RW-GG; Fri, 18 Sep 2020 14:24:39 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJHJV-0001R6-2x for linux-arm-kernel@lists.infradead.org; Fri, 18 Sep 2020 14:24:38 +0000 Received: by mail-wr1-x442.google.com with SMTP id s12so5818658wrw.11 for ; Fri, 18 Sep 2020 07:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=na8GpyYv85aOpBP11Jf6WZFgTxl3Aw/L6OpSLjetFwg=; b=etyuSs3OVyjL99gzmzOYa6/wAPbebA1BYrwwkxCK9XKe1A6IVQ0v2SXgDjNoLKezuc ck0VEzaRB3HzkLRbjLyAnAECc6n9M8kQwDWCA35xzibRYmiDyAcJ90ws7gSyxFZk2e70 i88u8jYGcB3H6hdRp5+hJspEoLe7CGaxjLng1XBzzOwA1H5An6X7BHvO7VEoxY+cHoiS O4l6dCGu2t28LBxwAazoFAxYD/Y1vmfSR7QClV6+vQ8VPM0MpcgW1eWpGYgZajon9EP/ vkjSgUtw1vq7SnLJ/7ZFSU0/QfdskCKwtA36Q85GP386hKsqbT5gSSXfAdFARo+Wbpx1 2cvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=na8GpyYv85aOpBP11Jf6WZFgTxl3Aw/L6OpSLjetFwg=; b=TrnQrlmk6qf9jtNzkx3FHq0Gw2WfSAoTqHWK4/3S1FtrzFzSCw39IBLi1p7jgwLTH3 PQaZI3DkNJibXH/Qf/E8leEKGbuv7CJVwzsDJ0BcuGBoHbSxV+f7kQ9ErxFpqEI563ZO pDuLCcMeMh96Up92mInu5LpEw2zgvsSr65YDLLusoEqNAbMO4ACIU9zzAKoRHqp+kYNi NPXTxpNTmp4fdaJ0H3H11vGReXQMgryAb8etkaP4mCDdiW70OXGtGbhZ/JjHuEi8tDnG bypV97QP8ycW7aG26ko5xNRDedHxBpcHgOFazChLZsvtsHVD5Zmd8MTpme3wXZHezweP g2FQ== X-Gm-Message-State: AOAM530SvhC40imrcEp7j93+AoyHZ7s3eJL4ifknBlFTZGI2siNm15w4 RxFRHI406jNGEhBLN1vCPhPckg== X-Google-Smtp-Source: ABdhPJxhb/XdGI5twiyu6Et5QnvfDr3z2mqQ/PgX8GXAydmlCfw1sUFl/ffh4Zyvvz+7vVjvbKPM4Q== X-Received: by 2002:adf:dcd1:: with SMTP id x17mr40672714wrm.150.1600439075299; Fri, 18 Sep 2020 07:24:35 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id c25sm5231151wml.31.2020.09.18.07.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 07:24:34 -0700 (PDT) From: Jean-Philippe Brucker To: will@kernel.org, robin.murphy@arm.com Subject: [PATCH] iommu/arm-smmu-v3: Fix endianness annotations Date: Fri, 18 Sep 2020 16:18:57 +0200 Message-Id: <20200918141856.629722-1-jean-philippe@linaro.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200918_102437_249007_8A414A49 X-CRM114-Status: GOOD ( 13.82 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:442 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jean-Philippe Brucker , joro@8bytes.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When building with C=1, sparse reports some issues regarding endianness annotations: arm-smmu-v3.c:221:26: warning: cast to restricted __le64 arm-smmu-v3.c:221:24: warning: incorrect type in assignment (different base types) arm-smmu-v3.c:221:24: expected restricted __le64 [usertype] arm-smmu-v3.c:221:24: got unsigned long long [usertype] arm-smmu-v3.c:229:20: warning: incorrect type in argument 1 (different base types) arm-smmu-v3.c:229:20: expected restricted __le64 [usertype] *[assigned] dst arm-smmu-v3.c:229:20: got unsigned long long [usertype] *ent arm-smmu-v3.c:229:25: warning: incorrect type in argument 2 (different base types) arm-smmu-v3.c:229:25: expected unsigned long long [usertype] *[assigned] src arm-smmu-v3.c:229:25: got restricted __le64 [usertype] * arm-smmu-v3.c:396:20: warning: incorrect type in argument 1 (different base types) arm-smmu-v3.c:396:20: expected restricted __le64 [usertype] *[assigned] dst arm-smmu-v3.c:396:20: got unsigned long long * arm-smmu-v3.c:396:25: warning: incorrect type in argument 2 (different base types) arm-smmu-v3.c:396:25: expected unsigned long long [usertype] *[assigned] src arm-smmu-v3.c:396:25: got restricted __le64 [usertype] * arm-smmu-v3.c:1349:32: warning: invalid assignment: |= arm-smmu-v3.c:1349:32: left side has type restricted __le64 arm-smmu-v3.c:1349:32: right side has type unsigned long arm-smmu-v3.c:1396:53: warning: incorrect type in argument 3 (different base types) arm-smmu-v3.c:1396:53: expected restricted __le64 [usertype] *dst arm-smmu-v3.c:1396:53: got unsigned long long [usertype] *strtab arm-smmu-v3.c:1424:39: warning: incorrect type in argument 1 (different base types) arm-smmu-v3.c:1424:39: expected unsigned long long [usertype] *[assigned] strtab arm-smmu-v3.c:1424:39: got restricted __le64 [usertype] *l2ptr While harmless, they are incorrect and could hide actual errors during development. Fix them. Signed-off-by: Jean-Philippe Brucker Reviewed-by: Robin Murphy --- There is another false positive due to passing INT_MIN to cmpxchg, and __cmpxchg* to truncate them to u8 and u16: arch/arm64/include/asm/cmpxchg.h:172:1: warning: cast truncates bits from constant value (ffffffff80000000 becomes 0) arch/arm64/include/asm/cmpxchg.h:172:1: warning: cast truncates bits from constant value (ffffffff80000000 becomes 0) I haven't found a satisfying fix so far, except adding __force to __cmpxchg_case* which could hide actual bugs. --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index c192544e874b..83acc1e5888e 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -867,7 +867,7 @@ static void queue_write(__le64 *dst, u64 *src, size_t n_dwords) *dst++ = cpu_to_le64(*src++); } -static void queue_read(__le64 *dst, u64 *src, size_t n_dwords) +static void queue_read(u64 *dst, __le64 *src, size_t n_dwords) { int i; @@ -1939,7 +1939,7 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid, arm_smmu_cmdq_issue_cmd(smmu, &prefetch_cmd); } -static void arm_smmu_init_bypass_stes(u64 *strtab, unsigned int nent) +static void arm_smmu_init_bypass_stes(__le64 *strtab, unsigned int nent) { unsigned int i;