From patchwork Mon Oct 9 12:09:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13413532 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 32E1EE95A96 for ; Mon, 9 Oct 2023 12:14:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C42608D006A; Mon, 9 Oct 2023 08:14:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF1DB8D0031; Mon, 9 Oct 2023 08:14:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6C698D006A; Mon, 9 Oct 2023 08:14:17 -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 8F1C38D0031 for ; Mon, 9 Oct 2023 08:14:17 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6372FC022F for ; Mon, 9 Oct 2023 12:14:17 +0000 (UTC) X-FDA: 81325815354.23.3DD488B Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf13.hostedemail.com (Postfix) with ESMTP id 5906D20008 for ; Mon, 9 Oct 2023 12:14:15 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QqdXYEHv; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of broonie@kernel.org designates 145.40.68.75 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=1696853655; 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=aFhelSxkapiNuoPHsFkCIGhZ7FdJU5ILaA54Bs9N7oRM7h3tVGc6+eqot7VtrfUDdW1d+f u9TGmz6UnwKURSAVIkbYqcOzOz0miLI8HUK8VDVH7Y9jZVk4Z2TyaNETgocj+fbDxXW9zA lLJY5MNdnQSxryLec59yRvr1zxMKyws= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QqdXYEHv; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of broonie@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696853655; a=rsa-sha256; cv=none; b=RJ4iM2RSnLI35cjqakwxc771DV4Igr2HZfafJLImjv9sxeQBGN2VGokcxvrnk+jT/yODJZ PbaqOcoqMYpbAMY+NS7O1aFOGQtV164pcFNOig2wLI1e1HY50om1rTfPafV8gd5ic4RB3G /Mj7y1ONz/9lODp3vhydXurQhUGkOfc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id F1196B8117E; Mon, 9 Oct 2023 12:14:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2050BC433CA; Mon, 9 Oct 2023 12:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696853653; bh=JCh6BoCIOxePO8zZIr/FO/CERnc7ZRYHEz9dpM/Qpg4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QqdXYEHvz3FTUT3Np9Qa0P6bHjgBrWxF6k+IAbQRqvtWpL8f6b+VeSy4m8x2oqy71 ADwkVHK0JFtJgVJ5MDSiHXkPXaq+hz4ZoRNtnQckXdlxuenDWIAYNqzUj2udq8xmWv oqmTU5Xq0li9wHBGqSBQ9sbmY68Wy9ELc94DNATmv5qg1tuxaqe14CnmERaNXDshN3 YGMpDNvjMxKOu7vCPbagRBZXjN7AxL5vq6Dr75uspEg6TvefipEPwHbAiexRXLz0us 4piL/W6e/otK64TWJnoDDkE96YS9XRVE2WxPCrqYCLcrgnmfnfelhep/y3yXK/EPoy GOyBlVw4eSQGw== From: Mark Brown Date: Mon, 09 Oct 2023 13:09:05 +0100 Subject: [PATCH v6 31/38] kselftest/arm64: Allow signals tests to specify an expected si_code MIME-Version: 1.0 Message-Id: <20231009-arm64-gcs-v6-31-78e55deaa4dd@kernel.org> References: <20231009-arm64-gcs-v6-0-78e55deaa4dd@kernel.org> In-Reply-To: <20231009-arm64-gcs-v6-0-78e55deaa4dd@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 , 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-0438c 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/pANAwAKASTWi3JdVIfQAcsmYgBlI+2pduXLA8Gjeg0HRP3GD5uX7WzcCSjwA/7BD3Ya AfDkNXOJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZSPtqQAKCRAk1otyXVSH0A4rB/ 9GhG9VGix0tl/HuVXdlcFfNVXuRxD5QJ/rim/BQuE9TdegqTB4Wa2IPeR/UkMT+d56/JEjvZOzEQ5M mvpXoA6JburaUxhI8T0E4Yc+9WN6ZN72KU53GP7ixO51ZHtnuzYJ+axiuZMHjHJmnOvyTrHsuaFlRa pKqWLEU8GFt7IoIyqmpj21zg4HhmbtMQ7IWGy+3YdPAj5r4hLtJBHVPBhZkLoMRt+ZoNg2YUxhLDvI KEnc7LR1GkFwfDUfbZBnLtErAFDiafdmn1l/24451Gi4FrVLEenZJhWKLdQUG86uJWwoG4Ni//UTnF eICANpkRccnJT0BR2Nuleg4KrbUqsy X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5906D20008 X-Stat-Signature: hixrjajwhs7pe41kin13zang7ru3bmth X-HE-Tag: 1696853655-521719 X-HE-Meta: U2FsdGVkX1/rqqyBNJMJ1k1NKihXLILFlMhX4dukjqrWDQ1xMI+Am091jeJs6sWrrclT7LIG1at7Y5NmZudkzon9e1w3+3+NDXCa554hBOFH9mc66iLRLUjXoQqFAMjdorWFrgsUHDOgALH8PMvshq4VN+2YDh4QOyKASDRqvT28Rj6rsfF1gWSbKUgnsERsjl40/LbpjMf9wBxjWN6qjka249BJSZSuHuGe9yPVz2gh8i1j3CLKRZZ8EFKh6AcZAMgy63jk7YlHz/z152A3qM4GhK2IHwE6f1uJI3pK11n+jivIYYupAWJjtdJJ406wMhgK81b35TtIDpMORfSx8h/rVfrbI2k9vvO0frtG3hglHzCai42meWles/NeoHK0nP3m39VnRQDH585gTvsOaTUzdbToYmJZjw3fjsaUGwjT1TrDtnst4QtqAIlzP5l94NfujEKktXo1CqdW1HjtqO4hFbXf7EzXHhfGDfuYKBSmhuVitP0Zsw3tVq+P6IcLKW94RdsWeKgAAuAarXqLs5hc1Wy1nPMfIw7ZcStRSbRa/DeVAEqeHMFNWC6feJHgtb0Ugxu5KOamlojyWF3zIP4VSC3eX+xZoy9H9RofVrei8fCqzzGDwUQBws/kJ8t5yDyyY7YQ+hEHqg4z+pIqDEcuZ/tkuSpVO8NbV7DEM9u6do0T5p9rpcoVnztwiS785w2Ts4JKe85o0SEA/nku0bDPQUCCmDQ3HNlyfByVC9NWjDULQMHnjaD+FaSW1AuxqnMAo8QkyPOu8Hw055Riv0edO4CxOb+arHwaP02JLBCyz86WQaeKGTrgVJ9R1ySp/X6EW7/zBCHShpXfo99OdEWzykiIRkqKHOm0InWwoXaAvoLKsEvMUAafSKH/vsp700RRHQvd4J9QsBex99/ARSTOoXMuSKWvbUSx/l/htN9lE0Afu/t0J27ibRxuE86qr9q950OAXbywN7BpCed JV7BRX2M sogWaxuuxTJhp7Xm0P38Uc05SGiU2oE0Q1ppkdEyHd/yHBZBSvB/qlvfb9FQGdIb3OH3xO6XU9JiESUgR+//Z1Np2qj9Bff0hb7Vbv7XE7H2eIz7R+M2+yQjkglV3G4CKEhqmYv9bszEn9TzKFZ0vjcL6lyubuiZiPTQthT62HHIP06XmI0KhsPO65a6QB2eBukXiwEhLeGTHQdHLfl9MnEKrAkCZ6QjZhkWeefSQKuBdfXcNr1RXMAhRaAaGU4Frhp7B2+7WFc2d5MnKMAabxwQ345r/EXR3K7oD/t36oLDfe77HkUQuN6l2N9kpbZZOWVd9iuH0g2GMoA4p+TExv4uV1RJn0o11uFzolUjbr2PAVieVZwodOQrxLA== 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; /*