From patchwork Tue Jan 23 21:58:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 191207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp626204dyi; Tue, 23 Jan 2024 13:58:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0gBHJ2OYaz21vLY0TdBEiOJ//Ys31bBIn7PzD4BYP4a01lcMpwol1I8KSKtGFjHj+oWUe X-Received: by 2002:ac2:514c:0:b0:510:527:631f with SMTP id q12-20020ac2514c000000b005100527631fmr1006565lfd.84.1706047122812; Tue, 23 Jan 2024 13:58:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706047122; cv=pass; d=google.com; s=arc-20160816; b=WJNvb7zp0FwutHs9/jnC1nbfIMUIyHnsW6BkcjbQi/WXnd85HfZh6hEVqy8Y5Q6avl UrUF0IcX1wVQr5kHraImkrNoX6onoOlym7I/y9ZZNHFKqVWo3zV5FYgQ5OsSrqCu4af5 PQ7RHN0a44buC6yOX7AnfweI5DogJOWhsuf7Z9TA4o37rod3/nrd8OHZe4JdIBTM64hx LRl2TQyjg1TSHbntoUMMaUN83T+vI8ha+0U8i31NLNwjLAB8e3njNh+W4G2tK8uSGbsN cpxvJH51BylTM2fTHbPUxrjQgPWK0k2foBhIbUUt39DBsL92S7unXNJf0cdjKAeINuCW 86sg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=8ynZXq3hbnTIt8pJLL68IBYX2Qlu6g0sPaImPdjw3z4=; fh=1UJ9YLOeZam3XpJXPQZc4x+IqAa3Mkq1/Sk9OkIJWPw=; b=WcZPjW52ytDTrXdKHGG+tdiuMcbDuJBbaQpUZcubSY+5AZcLNCtYuSNRJYBQJQITeb kstRPQAeSHm+Wp1gfqAtNExCzEKz+Chd/TWcCQ62F3aYycM7nE4NAfctLQQZ2VVXXAn4 AdscOSGfGvMqxte1/3cToG2jWOc0jQ9vUijQa8rjKaX2WQq/qnbYI87ZHM6z5X1VH91F EJ+RyUoQWRSbcL1AFIea6NyVWgxHrII5mSTb0lmB2CFPMcc/SgbJWLcxIpG8UBID0xbA s4y/w/S1cx/1TYSs/7tkGDOdc/xEpcHsRd5B5lykKygaTS+2nWuHLp9GZHu91Q9ddL3Y 0dGA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=0XiTIqTj; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-36100-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36100-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c14-20020a170906694e00b00a2e988c3fabsi7237719ejs.946.2024.01.23.13.58.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:58:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36100-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=0XiTIqTj; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-36100-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36100-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 38D1E1F247FB for ; Tue, 23 Jan 2024 21:58:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B9F34F5F1; Tue, 23 Jan 2024 21:58:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="0XiTIqTj" Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9E224643B for ; Tue, 23 Jan 2024 21:58:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047091; cv=none; b=s8J5rSpmXI3Ed0KKmmkmlj6HAZsI1prHqK/gOd6YHMqIjqNte5eMvk0jSdCMUXm9S6wm+tZgUCaK5n2v84hkynUf9VcY8NUNfp3iTdON6Kj5p/JOCdSJeME2sQcCEqzj0NOEDQAOe2MIEqaIEs49LXlGGVPW7mXSXdswTrzevSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047091; c=relaxed/simple; bh=vtaithEKdlnR6rNf+kxSTk35iDBBx0caxMmfVcvyUEU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N/NA+PHOWONyOxoxFi2QYfhnUcyJBKqkCcPqvIfIxbMOLOReoBtgYGZ+fchkl+WYSgcPc/yra4iRHBuCzjtkfNb7tYD672b7q0VKFmE0Erpq1qaZbwEOYZQH3bjj1s/9iHKv3zZwKZ1KecD7SAJRwTRcASi7GW+N6lYGB9tix+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=0XiTIqTj; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1d731314e67so14701865ad.1 for ; Tue, 23 Jan 2024 13:58:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1706047088; x=1706651888; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=8ynZXq3hbnTIt8pJLL68IBYX2Qlu6g0sPaImPdjw3z4=; b=0XiTIqTjY8LDYX0bZfZ0FX6YzZHnAsgme8BTdKH0hNUO6QDu2crBLQJuz0IUx1TX7N exud5TXeX4of93Yu5c5+aJSnXDgTMRP5HkTJveVquo4Zu35CJDLuAKAMZLVoZRIYpks0 JN8pKtrVJJShrsEK1L5p/ccXcBMDEjEBCUdypneceN3IAKgw+/kH78BrrPT7xZPI+SME kZ4fL5daGychEQHewPUBsKqDFTxzENBpk5gqtI9kfbtTpCosg2aXzLWgZjLe9JcRhtgf mQf9xyb2KhCP/8bDL+5g0SW8tQK9lAWMIMH05oDx+3pqnpRfkl3tyjX9GJSvoEzymoz9 8Myg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706047088; x=1706651888; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8ynZXq3hbnTIt8pJLL68IBYX2Qlu6g0sPaImPdjw3z4=; b=YP6SwqJfFAvFTaUZLfM3w93bVCFaC50bPfGY058oC3ZYx2qkX0N0LRPYXEaCUyENK2 NaIt7ZBfrUKu6lCo1uMa0QX1hNgrGtsTHmnjjz3cenbowItFmrrqFbuom4l7LHKsGSuX veN34htRR+tBrp2g2ZU+Tm1qpCKsRZxXLr7T4NnZiy+yRgtoefk9sSAtk5xgbemR5vD6 TGtQjWG+1R6V+rI4DrNUl4DpxZWVdqdHzqSTj1BOxLdG0+yGxLG2QsGrBz+R7sooFUBM 8KTDUZG7hFWbiiFROtiyC4kWD7ZKlGyIt5LP6ahDlLzG/q3N8TXNbI0Nys1PC8mKnXOm Y2wg== X-Gm-Message-State: AOJu0Yz8+Y/x/8zYkV1oo+nc0WbLAmJcz8zNT2mcj+PwlQA/gNHaLboB PuNcVC/11Rs1Q94TTFp6mnu+OKAoHMF3ErzOT5zOrX1kD/4Mvl1o7JoRP9quhf6Z0bpB42rEY/S m X-Received: by 2002:a17:902:ce86:b0:1d7:3f26:535a with SMTP id f6-20020a170902ce8600b001d73f26535amr3701645plg.71.1706047087981; Tue, 23 Jan 2024 13:58:07 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id ju22-20020a170903429600b001d755b10448sm3661429plb.199.2024.01.23.13.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:58:07 -0800 (PST) From: Charlie Jenkins Date: Tue, 23 Jan 2024 13:58:05 -0800 Subject: [PATCH v2 1/2] lib: checksum: Fix type casting in checksum kunits Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240123-fix_sparse_errors_checksum_tests-v2-1-b306b6ce7da5@rivosinc.com> References: <20240123-fix_sparse_errors_checksum_tests-v2-0-b306b6ce7da5@rivosinc.com> In-Reply-To: <20240123-fix_sparse_errors_checksum_tests-v2-0-b306b6ce7da5@rivosinc.com> To: Guenter Roeck , David Laight , Palmer Dabbelt Cc: linux-kernel@vger.kernel.org, Charlie Jenkins , kernel test robot X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706047086; l=2402; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=vtaithEKdlnR6rNf+kxSTk35iDBBx0caxMmfVcvyUEU=; b=t1uxIjq9p8s9LTH+gsbuEP1u9nLUyg+rfwEUSBAxG7YVJ3Hk5ICT/BnhaKq0yy8or3c/d4AnY MUAZUe2o9pRAp5I5AaCC1RSXFg49Wqjne8xGFcIn8IWGTazz3dZYWsW X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788920067486668620 X-GMAIL-MSGID: 1788920067486668620 The checksum functions use the types __wsum and __sum16. These need to be explicitly casted to. Signed-off-by: Charlie Jenkins Fixes: 6f4c45cbcb00 ("kunit: Add tests for csum_ipv6_magic and ip_fast_csum") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202401200106.PMTn6g56-lkp@intel.com/ --- lib/checksum_kunit.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/checksum_kunit.c b/lib/checksum_kunit.c index 225bb7701460..776ad3d6d5a1 100644 --- a/lib/checksum_kunit.c +++ b/lib/checksum_kunit.c @@ -215,7 +215,7 @@ static const u32 init_sums_no_overflow[] = { 0xffff0000, 0xfffffffb, }; -static const __sum16 expected_csum_ipv6_magic[] = { +static const u16 expected_csum_ipv6_magic[] = { 0x18d4, 0x3085, 0x2e4b, 0xd9f4, 0xbdc8, 0x78f, 0x1034, 0x8422, 0x6fc0, 0xd2f6, 0xbeb5, 0x9d3, 0x7e2a, 0x312e, 0x778e, 0xc1bb, 0x7cf2, 0x9d1e, 0xca21, 0xf3ff, 0x7569, 0xb02e, 0xca86, 0x7e76, 0x4539, 0x45e3, 0xf28d, @@ -241,7 +241,7 @@ static const __sum16 expected_csum_ipv6_magic[] = { 0x3845, 0x1014 }; -static const __sum16 expected_fast_csum[] = { +static const u16 expected_fast_csum[] = { 0xda83, 0x45da, 0x4f46, 0x4e4f, 0x34e, 0xe902, 0xa5e9, 0x87a5, 0x7187, 0x5671, 0xf556, 0x6df5, 0x816d, 0x8f81, 0xbb8f, 0xfbba, 0x5afb, 0xbe5a, 0xedbe, 0xabee, 0x6aac, 0xe6b, 0xea0d, 0x67ea, 0x7e68, 0x8a7e, 0x6f8a, @@ -582,7 +582,7 @@ static void test_ip_fast_csum(struct kunit *test) for (int len = IPv4_MIN_WORDS; len < IPv4_MAX_WORDS; len++) { for (int index = 0; index < NUM_IP_FAST_CSUM_TESTS; index++) { csum_result = ip_fast_csum(random_buf + index, len); - expected = + expected = (__force __sum16) expected_fast_csum[(len - IPv4_MIN_WORDS) * NUM_IP_FAST_CSUM_TESTS + index]; @@ -614,8 +614,9 @@ static void test_csum_ipv6_magic(struct kunit *test) len = *(unsigned int *)(random_buf + i + len_offset); proto = *(random_buf + i + proto_offset); csum = *(unsigned int *)(random_buf + i + csum_offset); - CHECK_EQ(expected_csum_ipv6_magic[i], - csum_ipv6_magic(saddr, daddr, len, proto, csum)); + CHECK_EQ((__force __sum16)expected_csum_ipv6_magic[i], + csum_ipv6_magic(saddr, daddr, len, proto, + (__force __wsum)csum)); } #endif /* !CONFIG_NET */ }