From patchwork Sat Feb 3 12:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13544156 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C113C4828D for ; Sat, 3 Feb 2024 12:33:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC1FD6B00BD; Sat, 3 Feb 2024 07:33:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E71996B00BF; Sat, 3 Feb 2024 07:33:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D12B06B00C0; Sat, 3 Feb 2024 07:33:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BDBC96B00BD for ; Sat, 3 Feb 2024 07:33:06 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8A466C0757 for ; Sat, 3 Feb 2024 12:33:06 +0000 (UTC) X-FDA: 81750432372.20.CF1FFB1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 9370F1C001A for ; Sat, 3 Feb 2024 12:33:04 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kqkNRTd3; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706963584; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TaUp99b44iUnlMtvSudETccqnnb9sSnSJn4v5t3dhRw=; b=bkDO96yecx+uogR0o4Ken6BB652dXR4PoFDodk6+u373iczez9SqbTmhmo7fkaoV9YcyqH dTohTinSyIUvk6Eb7ODb9+gBM8417NRoRokQb4kEHQBuzIsYjmWe4D9jN2oVbXAFd/PWWR 6H2ghxQm1PolkF1hIVIQCk58Ac4Ct5U= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kqkNRTd3; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706963584; a=rsa-sha256; cv=none; b=1Oh46GxIjMyiL028je/H+DSGCe3vFN2VJoicDOtGlJ3G/uO5QDnWzUqFiSgxIykFJDnMnf VxVAzQMAIf8JQsf+Is6JM+d32E5nQyvBzifX3vA1OFSKyu+qa997XFVlsgG/eWnMcjZTtP fy1iJmRQ+Hz/Acaf4Y8gp+2T3N+wGQA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D4BF460A67; Sat, 3 Feb 2024 12:33:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CF52C43390; Sat, 3 Feb 2024 12:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706963583; bh=JCh6BoCIOxePO8zZIr/FO/CERnc7ZRYHEz9dpM/Qpg4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kqkNRTd3I3lO3QHFD5UjLkvOmXQImqFY3hWHEUllrYLLdpP6+BXaYy4YzYJpIQfiI 2kHLBae1c3Xq/sQpeqs2cTCFeqKAzm2GWG98antWcjX06gw7CwAcB8sGoWImSmbV/w wyflXPYe7lInBio/hiz7dnB6MaDG5vFzEnie76b+PFqOpjJwi04lDvhCirR0sYEstt Osi7TWKazNTZlnXlSoBwbArXQxLqLF+EcZfBxzWRLpsvG2QYf3yRTP1bdczvlPmBcF FWwLyJCk+HVbPq+4OqXrI/U2oQFk8+dEj1kiPmSnxfaxgaNatAxo25FP09LCxaN/sf Dd2IR+IMxzJ5g== From: Mark Brown Date: Sat, 03 Feb 2024 12:25:56 +0000 Subject: [PATCH v8 30/38] kselftest/arm64: Allow signals tests to specify an expected si_code MIME-Version: 1.0 Message-Id: <20240203-arm64-gcs-v8-30-c9fec77673ef@kernel.org> References: <20240203-arm64-gcs-v8-0-c9fec77673ef@kernel.org> In-Reply-To: <20240203-arm64-gcs-v8-0-c9fec77673ef@kernel.org> To: Catalin Marinas , Will Deacon , Jonathan Corbet , Andrew Morton , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Arnd Bergmann , Oleg Nesterov , Eric Biederman , Kees Cook , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy Cc: "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , Thiago Jung Bauermann , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Brown X-Mailer: b4 0.13-dev-a684c X-Developer-Signature: v=1; a=openpgp-sha256; l=2627; i=broonie@kernel.org; h=from:subject:message-id; bh=JCh6BoCIOxePO8zZIr/FO/CERnc7ZRYHEz9dpM/Qpg4=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlvjDo38gIcK9LJf7YTIjfUSjpLDV2o1lpaAkCiIJC kt2+aTiJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZb4w6AAKCRAk1otyXVSH0ALzB/ 4mRIohJMqHEtEnxH9wC0dGcy1NF3GJGVuohQBQ1SeayArCc3f3SjqKV52kokunFJEEUuSE49WPF9fJ i1lvqhrAg971iuSllKwjK15OdqSMq8uAVlbyXSeh1UpRu978IpinABVAJmFzVeBhsxRlAdH9j88WBx kAF5vqmLYu3dBH1x0Lf2hMVMye0R21jtWPC2adssJAG5oI2lzq7kPZH0P2HbAvcBqegDeN0fHuVdA2 55NxduDCGp22NvYO4Jj4QstU5qHqGmFAw/t1E7RoLgStYY9aKRX0ItbjaUV03z2h4aOqP+0Wy4Puax E6I7vX3cLSpZLvELwVpM5UmmmNf1rV X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 9370F1C001A X-Stat-Signature: 4fc6p7nm7itqj6deboefetdmdxsnyf7f X-HE-Tag: 1706963584-965075 X-HE-Meta: U2FsdGVkX19RMKvdAcqViiLI0Cp8eQPhLUW5tNzKu5g8eSBZf+6Q0rpCcrx5b0bqhxS39O1iH6kEmvWXONsB5YJQlWp5zUhR9l2CbLhVmg8EZI9fAPyFnNKHYTboimPx9GbkQTwJ5tr0PrX1IFeGIp0i/tBWSexbVnC0BlIw1Hoxq5TdykIJ4xp4NC/0C/tjKBieVqGf8lbEecc+FxItj+7UII6KR/plnFQbiHz1aS9pSsPYbqxILiYRKLfX1TNsvY/gTASoyU2g0hK9oh1tJ9smVt8pJ/LjlZXvW33ZGmbKOX3Il3Y9UuVZwrLLno200lGNeUSOaZAlVblyA6biAEl9bMPcsN2g0gtCzkJynTfuarCZPXPRVg22aMu+XzB/Em+2qZRWojMo5fN8NHemTPppi76+nm3ZtmCVXTKqfPODYj/aBT5gGCCeqZk5n86+PshUIY7Cq/PemAw3SLk/++/9TdHn+AExijIjME8d7nQUq5o+wSJBse+MF+S/OUnMrSVVeFzYPxpMljOzCUqCbOBEUjW7UbCvgORcaurmukYGcENSIvjEIwL+EmKNXlnprvJzfrnFLdu1A7H5gliEtXC4/nueUfRVSFbNqMhc3AEaisxhjlzjZXLLs3+DSNkFeNMo2X082OL40n1w4v3NxLKr58k4MfyxbJQmmOveDjCUY4Vj9P7Lokz2yaQalQJpOOF2qW371e4uEx/lxBRkNZitH6Hs/MjNSsqKNbzbjxQDwJ0iudoe2kB1kD0fPuL/Z2/zKUXiSmHckRHk8sxuXlZMl7zX5+2x1/fEwje6fqc7yKXF829fldOrsHUr1l8lndeA5zn8XpoGJmjVNsMh/OnMO+cFOzE9jIy4yWzEDznHqY+21g0IK5Pm4C7fxXCEjwNxsc6/fRRiZ6jZCQJcgzdayGijiv6Qdl4rjZTjue9mKMEBoBf/y1QvaP/MVnePGOwn4mr15DK03KZCtoj 1dQCPXw7 RFWeRZ3x9+9Rb7e6PWsimlMmzZicF0FN1B53uI+1ZwZlDG5wSaCZ6DbFPCFoeki/8+WddhHnOKfK5taoX3cSdD2LMDQv+EEW6j790ZTkFTbnMCy7PainHqFfQXsNnVdneo3pPHEQe0TjyDY/168UFmpawAn6E+sagv3tsMQI9TuLqLgngKlHzpCo2mRt4uGw9ilR/09uooC3vvHIpLMG/PXRTuL8hD4lHPXAnEn4n2UpL7g6BtgL2O3dTXfvNJlNm5NrQuCHAscbYvNKsTBSaqpFmHPuoOpZuY8SKaD50zyOTqjoUCTRdBzgX61qSM94GiEUn/a7Yo8EBpe9xvPA3ZK3plN2toerUYWWVLUyRJMJ3azSB7UaowT+yWw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently we ignore si_code unless the expected signal is a SIGSEGV, in which case we enforce it being SEGV_ACCERR. Allow test cases to specify exactly which si_code should be generated so we can validate this, and test for other segfault codes. Signed-off-by: Mark Brown --- .../testing/selftests/arm64/signal/test_signals.h | 4 +++ .../selftests/arm64/signal/test_signals_utils.c | 29 ++++++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/arm64/signal/test_signals.h b/tools/testing/selftests/arm64/signal/test_signals.h index 7ada43688c02..ee75a2c25ce7 100644 --- a/tools/testing/selftests/arm64/signal/test_signals.h +++ b/tools/testing/selftests/arm64/signal/test_signals.h @@ -71,6 +71,10 @@ struct tdescr { * Zero when no signal is expected on success */ int sig_ok; + /* + * expected si_code for sig_ok, or 0 to not check + */ + int sig_ok_code; /* signum expected on unsupported CPU features. */ int sig_unsupp; /* a timeout in second for test completion */ diff --git a/tools/testing/selftests/arm64/signal/test_signals_utils.c b/tools/testing/selftests/arm64/signal/test_signals_utils.c index 89ef95c1af0e..63deca32b0df 100644 --- a/tools/testing/selftests/arm64/signal/test_signals_utils.c +++ b/tools/testing/selftests/arm64/signal/test_signals_utils.c @@ -143,16 +143,25 @@ static bool handle_signal_ok(struct tdescr *td, "current->token ZEROED...test is probably broken!\n"); abort(); } - /* - * Trying to narrow down the SEGV to the ones generated by Kernel itself - * via arm64_notify_segfault(). This is a best-effort check anyway, and - * the si_code check may need to change if this aspect of the kernel - * ABI changes. - */ - if (td->sig_ok == SIGSEGV && si->si_code != SEGV_ACCERR) { - fprintf(stdout, - "si_code != SEGV_ACCERR...test is probably broken!\n"); - abort(); + if (td->sig_ok_code) { + if (si->si_code != td->sig_ok_code) { + fprintf(stdout, "si_code is %d not %d\n", + si->si_code, td->sig_ok_code); + abort(); + } + } else { + /* + * Trying to narrow down the SEGV to the ones + * generated by Kernel itself via + * arm64_notify_segfault(). This is a best-effort + * check anyway, and the si_code check may need to + * change if this aspect of the kernel ABI changes. + */ + if (td->sig_ok == SIGSEGV && si->si_code != SEGV_ACCERR) { + fprintf(stdout, + "si_code != SEGV_ACCERR...test is probably broken!\n"); + abort(); + } } td->pass = 1; /*