From patchwork Mon Aug 7 22:00:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13345151 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 CF3F4C04A94 for ; Mon, 7 Aug 2023 22:04:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 684FC8D0009; Mon, 7 Aug 2023 18:04:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60E488D0001; Mon, 7 Aug 2023 18:04:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 439818D0009; Mon, 7 Aug 2023 18:04:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 32E698D0001 for ; Mon, 7 Aug 2023 18:04:36 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 15742160B67 for ; Mon, 7 Aug 2023 22:04:36 +0000 (UTC) X-FDA: 81098688552.03.CAA3860 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 271F54000C for ; Mon, 7 Aug 2023 22:04:33 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rN8ckZmr; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.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=1691445874; 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=r1885eCqfQ+xuvuXV/NIBfDRZKljtsGP97mr4oFQ/KO1nfLoL/I2XlnxTdPVDIUzSmHiBr sNsOeZ6CmacFtFcDfqxj78iowlM9mjtpBvwHRcTaNaNYYCi0TzzHEGCn4tz4z4ORn9uLt1 6fFGq/0oPVONNELXSOAeWCsYQTiJF7I= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rN8ckZmr; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.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=1691445874; a=rsa-sha256; cv=none; b=e9eMdpV7jVA8lMz1umg9oNj2DUjsonnSN7xej5D1bpx13whPwb8mMbg/XivPXdduJBJOoX 25d33EpyFyeqc6UEw/Y5t0U+iQq6uwtN5npXDDpEtPNDKxBG+TknNNAgAyadAjJxurmwZn MzjMu43BeSmoKjO97bxmKkSgtXNwB/Y= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6599A62290; Mon, 7 Aug 2023 22:04:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CE1AC433D9; Mon, 7 Aug 2023 22:04:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691445873; bh=JCh6BoCIOxePO8zZIr/FO/CERnc7ZRYHEz9dpM/Qpg4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rN8ckZmrZF6DP3DK1z17DQ4UborvhLXmgwp7RrVi8uGDap3g8szsq50Rygvctk4qs 6H7VCOahw2VukqHOypigyE2FBB3kyVXySW5qZZTDz0mjJpmM+skJU+keh+xObcRMFg lMJVp6BPDBl7ZavFsN96Z/9wCnZUCCx5tGuOvD/jrPe+IBHftICjQwpsP942jd/p/G RUBXdVM8m1+18B/u7IOhLk6JIgh2A5I+xiPF+d2uA2va9EVlqVMx+ydohM0jj0ZcC0 pfEHorYN+PE6oaON5Cz+lJ9LNMu+s7qegjXwVBmjWaxMih4nc/V4pNxYIuzVcWbZrM YD7BfTXH+0Ybg== From: Mark Brown Date: Mon, 07 Aug 2023 23:00:34 +0100 Subject: [PATCH v4 29/36] kselftest/arm64: Allow signals tests to specify an expected si_code MIME-Version: 1.0 Message-Id: <20230807-arm64-gcs-v4-29-68cfa37f9069@kernel.org> References: <20230807-arm64-gcs-v4-0-68cfa37f9069@kernel.org> In-Reply-To: <20230807-arm64-gcs-v4-0-68cfa37f9069@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 , 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-034f2 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/pANAwAKASTWi3JdVIfQAcsmYgBk0Wmvgj7+0Dl3dBMUzy5osqtFltpvLjCBs0jiIIcl T/WAIVWJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZNFprwAKCRAk1otyXVSH0HLzB/ 9aj1GvMDbc50DdhzBKgei7+9lJmBts7z3e55GSTyEGh7mW2QSHPeDZmHTd2vMR2pspdUwkQEenPJdi uuAUCeC8uv79EFoE33H8M17We3UnjGGZlekCrS+H2q/tLk6UOEOa5tN2H+EsEEt2391WwHlUPdmRc7 raOxBtWEZp4sSUFS6YpHns7d5kWppmv7WZEVTQd6osLBGQ/OWVH1DJngsg2F4U/AQYqmx87GHLtChe 65A/7/WOFjXvjbU7ShL/aoNHl3HJaZCEX7fMYJ1Wv+XVrM3LbHqJ3o/1czI3tACsmA55jjBJ5SiK6G erIVmi7Hb353T0gVoFU6xOZK5hAU/W X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 271F54000C X-Stat-Signature: ui68ftu1u83rennsx5kmdgxpx15mkh4j X-Rspam-User: X-HE-Tag: 1691445873-902402 X-HE-Meta: U2FsdGVkX183LQ5vcD4W40QAjAZ9kSHKw8ibKUg+4ga5bnjpxWo4pEXoI0eBuG9kjIAg8P8rYm3t2m9FfPw6GH0hEuMo5TW+rLEJHnCtq3WxvnnUmHNBfqs7oUXfG6mCXF2PR2enjGGO8tpEbaWK1hdwhwK0leEf4rfZHaaa8MM7VrwxMPYqZ3G/haocvyXV1L+vL1By037gMvHKa4pbJAW6z/Em6bNE6+GRbpL5/heumANZAIzmCUB8LfwiORnE6x/3pt8/w0tCmB1KanVr0UI5n/pCDbsSvGtuS32ZXbd/qX+KRFP21vg07B47/dMTPaVxp2shzM7OAty/mnllj7+lHxO5ZlMnffg5TR2D8xOWaZ8LtmYN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jxKR8tDbRaTE04AM+fjv8fBSQNK9DpdhjXVSALBiHoU0vmSwxwWRKmZ5WfBHOCJ7TQ8/5LdI 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: 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; /*