From patchwork Thu Dec 5 21:49:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13896039 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 22109E7716E for ; Thu, 5 Dec 2024 21:49:49 +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=6NjNj/CCafExLzJLFOSLGpIQdIPQKisyby0JBYmpGI8=; b=b9bKl+5Jeqc5se O7JRwnmQ7pgDut19xsGmaZGnkIZjuRNASVy0M5/g0oIxbeWyA6B4X/aC1G/ifSCjrvG1Gaz4VzKEf GqiL32hR6Pr5x3BoFUBbNxE0pVYbk9urqVwbcGpWT4XWaM06OZDpqVzOm6yoWPaYRNypm9WQpJbVI /drBJFLTnAgAcLiUFrEg44rzfgeaI5uBSODnH4AxjTfin7nqUNnR4RMRzYg3UUYWPPg7AM0HEYzKk sik/+jZ8K37XF3EPjVhcTtQlzL5+7rkGmN8q6Rg4kgIkxQGGQhostQfkr+OOX5YNVjbpA/x5x/xlj KBUbiH5oAuyur8RoSw8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJJjD-0000000HQms-2Dbz; Thu, 05 Dec 2024 21:49:43 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJJjB-0000000HQmP-0Pfa for linux-riscv@lists.infradead.org; Thu, 05 Dec 2024 21:49:42 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-215b9a754fbso14148815ad.1 for ; Thu, 05 Dec 2024 13:49:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1733435380; x=1734040180; 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=ylsolAa24KJioSknE/TsKey3hUL/pRTv+tYnTAIOBOU=; b=TW7t++jN6hr9jC06Te9Ph3A/p3H4mhbkPOe1kzDST/bzAi+3oWlKG4MDbtsuV1rlk+ Pkr+QRKd5x1Hc3QlVtxfWszAo31NpI5QGqWmAIOWBPOQYdp8v0IcubkZzV+qO/+wtuV0 j+9FbAGPZkbGN0X9QxA3R9XzTlHRWmh3Qwg2n71HnRxb5FTSLTEy84JmQvvhVG10UdSH qitoVwZRlOLna0+65ylYItKkmCeHvyqedhDKdHazkAjq2NSlNdG7iaihJqiwqK07OZGo U0oAbqmHAUi7n5QIE6+TYyMcbaxhKYuP2bjsMW++n3jPcGapbxorELckKTj3fitnn2Rc CsBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733435380; x=1734040180; 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=ylsolAa24KJioSknE/TsKey3hUL/pRTv+tYnTAIOBOU=; b=Qtfxccu/aFto1PbGRp2tt3DhSt6enQIPI8KaFtW1gR8mEc9pb34R8b8Tl9+sXJuVX5 P+kXhq4MPcPz8yX7qTyiqQA+CgWmz4cztWKErF4TS60urG3hE9GLnFU4Lj0+YvZ5fOMt JERDYLFAjWoiw5GIMceif0W6O1onaBKz7zHeeOab/4BAWPpf4eh9K/7QpXfRHMbXC53X qiWrT5RcIE15yvPShkTuc0IcuJe6jx7Xd7ZCkcj/MA5wZEkH5CGjM0g/z/eneovVF3G2 xwQjqYMPWFYS3abpsemAL1otNrd5V6/BNlMCs8j2Fa/cWPxr0Kzm9pubr3aZtBEn+qUo PEhw== X-Forwarded-Encrypted: i=1; AJvYcCVck739jFZDLs8nguSG2PzCxM4wiS91UJv81xLkVGM76yqCQZ6FfYxAZAES/YYP++aocAXVK19dPKDWnQ==@lists.infradead.org X-Gm-Message-State: AOJu0YzGcHm4shaEErcJYKSit2SlF/3VCxLhEshtIQQP7+eIVtRfRVnU oOEnISq0WATrMK3jj4unmiD/pDeuZBQ+4CcSwW9QBnpRFkJx9PJJb7LefkXKSelf9egszOlWDd3 Q X-Gm-Gg: ASbGncvekY1jKcfDocevE/K7sIkfs+zeuCrwXHA4RCONBMK81v6H36qrzb5uRNtj+6g PhDB24n5Uy8aYRjdHS1Yj49hDjhJH9xlV3IfqZm0HHEulLM7NdWiPPv0EtrFHdKO3nldLCbosRh 0xjuUxvSF/zUSKYT63SP2fRF90XWnlyColzA0OtTsalGRehScUrlvdWC+LlytHITcGQDj+WWVB9 tlw4vS8nTNGK/E/pTdN9rMhdkD2Zi10HpK1TCCtHCTgR2M/ax947WsViJhwkAhKIA== X-Google-Smtp-Source: AGHT+IFTb2VVc0pKxcp/N8wkyZ083cyONyg4oc637ROCo07u90M4wR/yDH/PPfe8ZbpGqnrUUyfdNA== X-Received: by 2002:a17:902:d4ca:b0:215:96bc:b670 with SMTP id d9443c01a7336-21614d3ac68mr5579825ad.18.1733435379862; Thu, 05 Dec 2024 13:49:39 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8ef9dafsm16496085ad.120.2024.12.05.13.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 13:49:38 -0800 (PST) From: Charlie Jenkins Date: Thu, 05 Dec 2024 13:49:31 -0800 Subject: [PATCH v4] riscv: selftests: Fix warnings pointer masking test MIME-Version: 1.0 Message-Id: <20241205-fix_warnings_pointer_masking_tests-v4-1-0c77eb725486@rivosinc.com> X-B4-Tracking: v=1; b=H4sIAOofUmcC/5XNQQrCMBQE0KtI1kaSNKmtK+8hUtL4ox8xKfklK qV3N7oScaHLGZg3EyNICMQ2i4klyEgYQwl6uWDuZMMROB5KZkooLZXQ3OOtu9oUMBypGyKGEVJ 3sXQuRTcCjcSrphagfWW0almBhgRl9TrZ7Us+IY0x3V+fWT7bv/gsueRgJbR1bRys7TZhjoTBr Vy8sOdDVv+rqqiy98IZ0Rpvmi9q9a6an9SqqMapphe+rbU4fKjzPD8AG0LWz4MBAAA= 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=3049; i=charlie@rivosinc.com; h=from:subject:message-id; bh=8FnRi21KlrzOAiYqaiv4ehq3t7YDIRIjKXA+qmcuaUE=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ3qQ/JtKlok/ngWsEnDPXCFRfe2C1zl5v6oHFxLMZS1EJ md/yEjsKGVhEONgkBVTZOG51sDceke/7Kho2QSYOaxMIEMYuDgFYCL5RQx/xVd1fP3e1uLwcYuO oUAil+CKPN/D6+qKZ7NY3vhl4hSmzPBPT8vkr5TN5waVDWVTp9ZNZ5h/Z+ZCTuPjs+wUJnvabDz KDQA= 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_134941_189281_56692060 X-CRM114-Status: GOOD ( 11.33 ) 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 v4: - Skip sysctl_enabled test if first pwrite failed - Link to v3: https://lore.kernel.org/r/20241205-fix_warnings_pointer_masking_tests-v3-1-5c28b0f9640d@rivosinc.com 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 | 20 ++++++++++++++++++-- 1 file changed, 18 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..759445d5f265 100644 --- a/tools/testing/selftests/riscv/abi/pointer_masking.c +++ b/tools/testing/selftests/riscv/abi/pointer_masking.c @@ -189,6 +189,8 @@ static void test_tagged_addr_abi_sysctl(void) { char value; int fd; + int ret; + char *err_pwrite_msg = "failed to write to /proc/sys/abi/tagged_addr_disabled\n"; ksft_print_msg("Testing tagged address ABI sysctl\n"); @@ -200,18 +202,32 @@ static void test_tagged_addr_abi_sysctl(void) } value = '1'; - pwrite(fd, &value, 1, 0); + ret = pwrite(fd, &value, 1, 0); + if (ret != 1) { + ksft_test_result_skip(err_pwrite_msg); + 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(err_pwrite_msg); } static void test_tagged_addr_abi_pmlen(int pmlen)