From patchwork Thu Dec 5 21:34:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13896036 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 4AD52E77173 for ; Thu, 5 Dec 2024 21:35:19 +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:Cc:To:Message-Id:MIME-Version:Subject: Date: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=LkYsUK3dyYuX72lCJkTuKngVUTAYRjcYPQMb229lYqs=; b=U009tewTrrQjLB 8NTHncnuujayOUhNlfPk9/Jh/I1K1aA/xOKvQMIcllQXLftsY7vgot9zp/8kl1W2t74uopbRAkcN9 rMKmmmOV1GIN5HZi3JLrTiLsi4T5jTOBg0T9/6EIBA446OWHGwAhDGPxWRC4mTUruhbHkM3iNImW7 hYEBCS4Q4kCzroxYTcMXx9t5scXeiAKL9U2mLEjB6EViKWPsPjm7k8Ew3rN4O00k/WjKoemLAJU5c wRudNI+qovFenu5FmEwrulgAKuQZdsHSJ8SJij6CkWEsttLCxlmDGZx1WHDpN7Igyp01gXKk1yEPz JbI0j+GMFe6Z0iHSZBDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJJVC-0000000HPcA-3Xws; Thu, 05 Dec 2024 21:35:14 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJJVA-0000000HPb2-167F for linux-riscv@lists.infradead.org; Thu, 05 Dec 2024 21:35:13 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-215a0390925so14814515ad.0 for ; Thu, 05 Dec 2024 13:35:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1733434511; x=1734039311; darn=lists.infradead.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=pwsdH+QfnICBuJ92pYJftuHgr7/FjfSggIF1Mo3ejbQ=; b=0kabb610sNOuLZm+6Jp5pp2/f1vGgXnxAVgqelhd1B6c67LY2mjQMzleJHJQM3sUMH uJo+qLIb3dcH2uxkTXPkBH4epnRtE+AFSFRXVvKJLfokciM9KJdylJqan4kpQpVyibsh m+QvmjCPo+Ji4VVw8JUfdIPtecfyg56m3jXWKXaHqG1hFYWXS7A9+LYF/q2h2GwaBEmi GOBu1QTwO5XYxHTm2g31At6a434gmuLsAuvBXHer+CBR6D+G3C4+RnZDSTpq5lTPYohw BWyGSYkhEXmZkgQH/iFToyZnEGvVRQVPvy1S5yqj3/67v5J6LutMacLBTR3ZTJvfad+U KCCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733434511; x=1734039311; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pwsdH+QfnICBuJ92pYJftuHgr7/FjfSggIF1Mo3ejbQ=; b=au36+Zi8msTlJFy1asqkDt0gXweSRZ7hRSAO2MAHoHmy0kLZAxADFevh0w7B32Zfj8 ejuxY4GTFcQXxqOvfRZ+eX+K29uwtTqKwGSUzg+XrxayLG1W7r1d7lsyBU4RKtGWewUW zHi0kGKsUAcqLYMKLaKIV7gtwyDRIN78us+XfpN+Ftp04lQKu9c2+HBEyQ223UoiPgNJ 2yAbWeFP+G/c/3vxkKKY6JLxSExjrmyOznDBmGFRctE2pobCP2zPbpdziu6z0qqH6ni3 nTibZggS8nExcyR6ck2mQG+Lq2jfZx8fNTVFO5VCk0FlRfjqyc3COMSsFbapu/3xaY3Z bYYg== X-Forwarded-Encrypted: i=1; AJvYcCWY1XIiGCRBjAkBhwUIHqGEs4vs98xefNrWnkOeIA9XZ47qmn2F7Xd18J/yUz0QsDv5rzLPGJXjH1+hmw==@lists.infradead.org X-Gm-Message-State: AOJu0YypVCC/HdvnIv2bC8rqRwqeukzhxXFFugI//uOxqvHTH+DrGNYi Vx8onAjEvElGpQ3/m9GxNhrWG7hEGT+xBkBZV3eGinrSgfvpsqmq5kja6KA4E+0= X-Gm-Gg: ASbGnctK8tVQoFBXdMhxcwS6JmX+mqqwzEVLuzRL9h28kdS955zgN73q95nyLOTcqd2 OuNVEh/Lx6QA72RGbbFl7dTiOYrP04moYss1OQFvfpT8jkLLmw+B0JPQIkRHILCCg+gdidgK2Uz NbEjAGsqJDvPMbQQiIkef8sT7RbRW3n3tXwMybm8PUg5Nce5HRVIwu5k0X/eeSnVv5xJ0UBz8ws 7rqqIwZTtoYnfJKNpqCIhP/SkHt9fb6TzCuP+BRK8oF0QUu+jnmmhEV3EG2G5MiHA== X-Google-Smtp-Source: AGHT+IGw0B69pcIiyWd5mzMp+7QZEvAdzKCqvYC84V0ko8+KVSirsXGLwn19nZI7HpRamxqVkm4+8A== X-Received: by 2002:a17:903:110c:b0:215:6f9b:e447 with SMTP id d9443c01a7336-21614db3f47mr6536815ad.30.1733434511348; Thu, 05 Dec 2024 13:35:11 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8e3e414sm16857975ad.56.2024.12.05.13.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 13:35:10 -0800 (PST) From: Charlie Jenkins Date: Thu, 05 Dec 2024 13:34:43 -0800 Subject: [PATCH v3] riscv: selftests: Fix warnings pointer masking test MIME-Version: 1.0 Message-Id: <20241205-fix_warnings_pointer_masking_tests-v3-1-5c28b0f9640d@rivosinc.com> X-B4-Tracking: v=1; b=H4sIAHIcUmcC/5WNwQ6CMBAFf8X0bE1bKIIn/8MYUusCG0NLuk3VE P7dwtEbx3nJm5kZQUAgdjnMLEBCQu8yFMcDs4NxPXB8ZmZKqFIqUfIOP+3bBIeup3by6CKEdjT 0ykMbgSLxoq4ElF2hS9WwLJoC5NcWud0zD0jRh+/WTHJdd+mT5JKDkdBUlbZwNteAyRM6e7J+Z Gshqf1Wla3y0QmrRaM7Xf9Zl2X5AUDmzdUtAQAA To: Shuah Khan , Paul Walmsley , Palmer Dabbelt , Samuel Holland , Andrew Jones , Alexandre Ghiti Cc: linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Charlie Jenkins X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2769; i=charlie@rivosinc.com; h=from:subject:message-id; bh=wdD8jAZRCjMd3Gu+Lv3upW2aM9UHvcVExGMABP3l5PM=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ3qQTFPQcfty272Tki0Tp9hVqomnGGX7rOyL86y7/yaNf fN5Hq2OUhYGMQ4GWTFFFp5rDcytd/TLjoqWTYCZw8oEMoSBi1MAJmIgzMiwOLJj3XaT6aty+7UK Hu/M+srF3f3i2TzBPw5xLmF8UWd7GP7XRf/XLcy/e0Dgwf7+0zbnVmu8eVK56/itfR/y7CYxVp/ jBwA= X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241205_133512_319991_ABFE9F24 X-CRM114-Status: GOOD ( 10.40 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org When compiling the pointer masking tests with -Wall this warning is present: pointer_masking.c: In function ‘test_tagged_addr_abi_sysctl’: pointer_masking.c:203:9: warning: ignoring return value of ‘pwrite’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 203 | pwrite(fd, &value, 1, 0); | ^~~~~~~~~~~~~~~~~~~~~~~~ pointer_masking.c:208:9: warning: ignoring return value of ‘pwrite’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 208 | pwrite(fd, &value, 1, 0); I came across this on riscv64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04). Fix this by checking that the number of bytes written equal the expected number of bytes written. Fixes: 7470b5afd150 ("riscv: selftests: Add a pointer masking test") Signed-off-by: Charlie Jenkins --- Changes in v3: - Fix sysctl enabled test case (Drew/Alex) - Move pwrite err condition into goto (Drew) - Link to v2: https://lore.kernel.org/r/20241204-fix_warnings_pointer_masking_tests-v2-1-1bf0c5095f58@rivosinc.com Changes in v2: - I had ret != 2 for testing, I changed it to be ret != 1. - Link to v1: https://lore.kernel.org/r/20241204-fix_warnings_pointer_masking_tests-v1-1-ea1e9665ce7a@rivosinc.com --- tools/testing/selftests/riscv/abi/pointer_masking.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) --- base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37 change-id: 20241204-fix_warnings_pointer_masking_tests-3860e4f35429 diff --git a/tools/testing/selftests/riscv/abi/pointer_masking.c b/tools/testing/selftests/riscv/abi/pointer_masking.c index dee41b7ee3e3..2367b24a2b4e 100644 --- a/tools/testing/selftests/riscv/abi/pointer_masking.c +++ b/tools/testing/selftests/riscv/abi/pointer_masking.c @@ -189,6 +189,7 @@ static void test_tagged_addr_abi_sysctl(void) { char value; int fd; + int ret; ksft_print_msg("Testing tagged address ABI sysctl\n"); @@ -200,18 +201,30 @@ static void test_tagged_addr_abi_sysctl(void) } value = '1'; - pwrite(fd, &value, 1, 0); + ret = pwrite(fd, &value, 1, 0); + if (ret != 1) + goto err_pwrite; + ksft_test_result(set_tagged_addr_ctrl(min_pmlen, true) == -EINVAL, "sysctl disabled\n"); value = '0'; - pwrite(fd, &value, 1, 0); + ret = pwrite(fd, &value, 1, 0); + if (ret != 1) + goto err_pwrite; + ksft_test_result(set_tagged_addr_ctrl(min_pmlen, true) == 0, "sysctl enabled\n"); set_tagged_addr_ctrl(0, false); close(fd); + + return; + +err_pwrite: + close(fd); + ksft_test_result_fail("failed to write to /proc/sys/abi/tagged_addr_disabled\n"); } static void test_tagged_addr_abi_pmlen(int pmlen)