From patchwork Mon Feb 12 20:33:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 200026 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp154019dyb; Mon, 12 Feb 2024 12:33:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1KUNNJDIYcxA+rDv/TwBS9MTTvCzOIFarTYgxp0TLfDd16c2KGNZChFmal9OwJeRz3SkE X-Received: by 2002:a05:6830:22f6:b0:6dd:ed82:f46c with SMTP id t22-20020a05683022f600b006dded82f46cmr6762390otc.10.1707770039080; Mon, 12 Feb 2024 12:33:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707770039; cv=pass; d=google.com; s=arc-20160816; b=00DvWd4zb3moDBtLpwb4aMZhCOeokNzORMdiyXlL7thchBx4mcKb+ORrRZIA0eXH1u wLiKzjm1Di9eV1t6HpRinz8lLpBHZgZHjyV820lSvy91v1+lOKBXtJfIqg5Z7b1vJj4n YE/Esuy866kCJ+ZQY7RWl0wbZN7qzR9I+chySybVg0C4Ansc5y0gNj/3eHESn16/De8e fKsDunkLJMJNgqmzEyqL0svVzY+6EICxLVqLizAQFSOhOTk+AB7SJUeQYaHzrqHOP5fJ xQDHYo7AXjkky+Wz4Gk+gjf3sWEJpSW2XWYBSURiYjRLJirgGmyIoNs6xhOVUXf06xvU d+Sg== 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=Jd7l9FSzolv9UKodhUQRIn54HJ3vZVJiADf6xQSSoXk=; fh=J7s899OWyjGrb8p8p1P7a+NW6U4wyVAYsEA8fSj1F1k=; b=YAAnu0qoH82UzTx1Rz23zm1Su3xBUAoDOlAdZBfHFeJVJPz8+lhbHtJtc8h6qcY5yo bHZCn7GMQ5iaQgloCiWoAeoYCJPzf0pn/tSHxUtQdMSno4YBrzdCqvhsHiPy7tWvWGLV jUIsAh/82uw8rqfsPRJQZICQ97CLqnoWEtwjzX0pqXFYx2BEEi/bGUs/bYJzmKLZznJ1 RugQnNO3qiwjYOUPGkenk3HdgJ5OTF70r1Kff+wwVtvHaPXPZ6rOsTjgn5L6HXKAy5fT TyeGy3AidOImpi9Od/mKfoYHexIOyax3sZrNC+ouISxiWOsffisM4HVD/McLlyG1iEc7 gXwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=S30jdh2B; 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-62339-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62339-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCX8w+I5J62XaTs+09h6LGg7zmaS25ntnDYEZlP+z7TTlSoLJaB/XWL0aI6JQoGbVXlJIDNcqO+CMc/rp79XvLjq9MWJ3w== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e3-20020ac86703000000b0042c7c51f74asi1142310qtp.726.2024.02.12.12.33.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 12:33:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62339-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=S30jdh2B; 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-62339-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62339-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C7CFF1C2257C for ; Mon, 12 Feb 2024 20:33:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AF0F4CB47; Mon, 12 Feb 2024 20:33:18 +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="S30jdh2B" Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 31D851EB3D for ; Mon, 12 Feb 2024 20:33:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707769995; cv=none; b=k55S9eT2GigGgz0chVo2YDE1moYrFD+zCPUjfVXWX+04jZfBfS/e2Y2QSfsVuPuIuhpe2m/RkgNWcNwTLdLxNMSYS4E+auwEvT9aCeoBJmMkYX8KrUAl17ZIsH4kUF9Kgi51XN+eQcJWZqobRYVyFcvrpo2JIax4xt0av4EnLJk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707769995; c=relaxed/simple; bh=AzZ2wloxj6KDQAMdXrlf4AWIKCIwq2UD/2yzxCzqXlE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uisATU82ksRzXrwzlxV8ovN2gyT31skC5Xaty+jYdmQNFm+rmaXYRz/27G370LfMm7+L0oTZ9PPWXF/U0xYbvELjAt2dBYPwZXB5y+nyJN1/Pb5qoUp4AXCKAxwt0atjtY5allGMhirN1vQb4kZLudHhMK1c33pPHiHjuEUwQmQ= 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=S30jdh2B; arc=none smtp.client-ip=209.85.210.172 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-pf1-f172.google.com with SMTP id d2e1a72fcca58-6e096229192so2792625b3a.1 for ; Mon, 12 Feb 2024 12:33:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1707769992; x=1708374792; 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=Jd7l9FSzolv9UKodhUQRIn54HJ3vZVJiADf6xQSSoXk=; b=S30jdh2BgB5nQTVX4JbMBi2v7XNoexRwsC/Vu0drzlFAwpmA2mMzuyPj52uJKzAJqX fhPJf0TiVQD+c08jTXD6hww9p6mex+NEIX8yHSX2qEhoMALVW4RzFjLTTHToRzeL8b6J Ps3oiSKC/g8iv+AcIcIddFnlV3WT8ZAYT6XYpQ/uZDwIGd6u2/wLH44J22nH6J9iNJjZ QAHlnMKqTA1TMyJRvgY7bF6wQNcRDhLxoR3BXojbp0OAB8AjeeW1l/OS4Lcu6a1dd9kH +SXlIMTNW31iQRTPRZK4B0AmgyadkoND8DqF2p9yzIyTNrjCWZ1f5lT31k0M19KzoFHf /mew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707769992; x=1708374792; 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=Jd7l9FSzolv9UKodhUQRIn54HJ3vZVJiADf6xQSSoXk=; b=H/N2t0i8QdMEW9jHfdWeOvhLus9GIaipEH3CfQlRtOdzi4T+n7gdnmba7Bo1kBWhYX lDe2B/XPJY8E2DGSP+uoJHcGmMmzerxeX1zdWh+bKcBTPJ/ph9YkI6AAQV6SHX21GNho mRD8QeHgmXh3wfx70EEjgxaCvKWk3vRjsK8N1k4ZQ/ntfsmFmzGvriJtcyWuGapvFA1j yDevh24J4gAvZEMGsnXtHXlXRYwUQSb8IpbnmZlDeL3jS0xpZx7NuhAO4LCLycYlYCVI uKmVmbZkHjVXn7dvUFCjmFDCxoZuktIqrKQYyM5Ef41wUSrXFUURcGf0lAxHWQFamker xNCQ== X-Gm-Message-State: AOJu0YwGiVi5zieBXOIcw6VNdwgvUmC1r/n1S5S58ZXMPBQGlCiKnU1l +C+FVJGxHadSG17aXCBm2RxJHVF4qFN8J11mKr5V7V8XbzOeRr0y84hnVJRQOvxO3cfEK0A+fxG q X-Received: by 2002:a05:6a20:d39a:b0:19e:9b19:96c0 with SMTP id iq26-20020a056a20d39a00b0019e9b1996c0mr10544685pzb.7.1707769992443; Mon, 12 Feb 2024 12:33:12 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV0zWV+JXpELhaIcfRoduAeJRoKG1hMVNdySXTOP6VxqPVhVrZyK/HjBPjK4sH+1wkZjjownlb8i0odo00xE1qu77wTXjICD7mrOE1OXWWjkKPMvuEnbH9TIErofQs1RNeqegjOQmaVsY4rdA7r+YQSATW+dEZQ5cRkOZrPxpiyiJlvyUz1T6tB3sk3mkJPrC1WWX6DU4XwbUuUC0hOkw9jMT63Wy9Kue6ndWdufok7du8jZAk= Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id o15-20020a056a001b4f00b006e09e97b803sm5552506pfv.46.2024.02.12.12.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 12:33:12 -0800 (PST) From: Charlie Jenkins Date: Mon, 12 Feb 2024 12:33:04 -0800 Subject: [PATCH v7 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: <20240212-fix_sparse_errors_checksum_tests-v7-1-bbd3b8f64746@rivosinc.com> References: <20240212-fix_sparse_errors_checksum_tests-v7-0-bbd3b8f64746@rivosinc.com> In-Reply-To: <20240212-fix_sparse_errors_checksum_tests-v7-0-bbd3b8f64746@rivosinc.com> To: Guenter Roeck , David Laight , Palmer Dabbelt , Andrew Morton , Al Viro 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=1707769990; l=2446; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=AzZ2wloxj6KDQAMdXrlf4AWIKCIwq2UD/2yzxCzqXlE=; b=TZdgr3HUZz108GlWeS6WVeDd8q4kHcwAr+emkJBzljel2b25nXDG75cnJIXUgFbGvg5qL+xPN /QQgpcmSnx6D4anPg16Th2dOWSKXemjtTOSBqQQ+G8EzJ89sKChN/On X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790726676598390845 X-GMAIL-MSGID: 1790726676598390845 The checksum functions use the types __wsum and __sum16. These need to be explicitly casted to, because will cause sparse errors otherwise. 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/ Signed-off-by: Charlie Jenkins --- 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 */ }