From patchwork Wed Nov 22 09:42:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13464425 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 800B7C61D9B for ; Wed, 22 Nov 2023 09:47:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26DA86B05C8; Wed, 22 Nov 2023 04:47:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 21E486B05C9; Wed, 22 Nov 2023 04:47:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10D526B05CA; Wed, 22 Nov 2023 04:47:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 01C296B05C8 for ; Wed, 22 Nov 2023 04:47:03 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CBA5DC0580 for ; Wed, 22 Nov 2023 09:47:03 +0000 (UTC) X-FDA: 81485111526.06.70AF0C8 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id F3AEC20027 for ; Wed, 22 Nov 2023 09:47:01 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=syOMsnFW; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.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=1700646422; 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=2ozZbRaYs/+0MGSubF2558RGu/iy7kUlYOSh8sIY7uI=; b=h8SortpNejjIfZLMUrkHfqZZWpT1jgZ40LNKRIf1/y3c5yatmWZbHi8gHBy8xFR1EMHJC1 2sX7H6jwBSmM87UAaiQV+L9mlpPYVHSAqkCiMKLbsRYbgwDD6/yqvHoiaRvEMmBEtH8awF TJydRb/EQTQxZvSJ8ftNyd2BWx8fFoY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=syOMsnFW; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.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=1700646422; a=rsa-sha256; cv=none; b=nKSV/LVpn9DGDY08rzwKqQAykyyMa6ItX4XCWqbigT5vSj/zipg+LX5hLNsKnx2SjMVN4n jZ4lXmRxRVrwx6Vs7HwYi0MHzvMi0Gxdfy/W+dpJ3shhlSV3nERQSONa1VsZpFITc6qvL8 sAQhpT/hvqTZpzBs9g/cGqRjC6tJCzk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3817D61CCB; Wed, 22 Nov 2023 09:47:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C568C4167D; Wed, 22 Nov 2023 09:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700646421; bh=qxIqlAUMc2bBTJ1O51B6Tb6fnmxFBkD4x3sOYOI7QNE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=syOMsnFWzOG+xmHUkIsaKs6NTpc6AaYK4nG1MDHbqXgrSkOqjN7up45LrEl5p7Kj8 Ym73t13eE56T+NFw9qfvMT6cKIN/58qjCmJqzZxAJ1kGvbKFLul5nd9dC6SQUz1jrA EXxSfZQgZcLsl/twjdlg0vE6CSiRLXxi/NK/28aJYlwlXlwyWmtSXRBJT/xwFsHoxv cnjdJbcrEHQku+7vy1h9M37JgKh9Q68/onZlKJEqYCHDVnv0PkCs/RRlNmSkgV+RF4 oOhzEu7XmVtkSX4RB82dUstRQ0AKsXe8scyUjoFXpHdqZZGidv6d7sY3xjsf23P0T0 9QQcGPMdtp0aw== From: Mark Brown Date: Wed, 22 Nov 2023 09:42:41 +0000 Subject: [PATCH v7 31/39] kselftest/arm64: Allow signals tests to specify an expected si_code MIME-Version: 1.0 Message-Id: <20231122-arm64-gcs-v7-31-201c483bd775@kernel.org> References: <20231122-arm64-gcs-v7-0-201c483bd775@kernel.org> In-Reply-To: <20231122-arm64-gcs-v7-0-201c483bd775@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-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=2627; i=broonie@kernel.org; h=from:subject:message-id; bh=qxIqlAUMc2bBTJ1O51B6Tb6fnmxFBkD4x3sOYOI7QNE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlXc0OiKQHWj96U6Iv+vrEb7owlLDF7A+UeVAJW s3BN30QZ7mJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZV3NDgAKCRAk1otyXVSH 0Cj/B/4v4VwoMeU53pDf1fNeG//YL1WSnuk6c3A7i2dDESTIut5NK5DCoQTU6va5PSrNx6bHcHQ U209ci3F/Zr+o/E5MK0xtlUtuT0eeijo8MCPj04SF2s9C7Dh86AMZ5nTAvggAIsFDYLgQgOmNM+ XlQhib+aoBQStnNJmu+VdxLsNvBqIxdMk0E5RP7S8lMT9FNHmPXIsAfuYt4IpvN/kglnDyFWP2g AlBAMocbBXbx6N9D+rWLO3KOz7hiQ9AVkz/OUwp5hFzfb6hy96kQW529H3py/8jX/rxRH/DfOlw srt4yM6xjmvQ1TSj6Nvsge/pgI2bILXYvrzKkwYSC4BlkQsu X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: F3AEC20027 X-Stat-Signature: oem6hb4rj1tgxxerdaaauswbth5qoy41 X-Rspam-User: X-HE-Tag: 1700646421-963693 X-HE-Meta: U2FsdGVkX192YjwJ2g2/hI8tmCQYUOKM6NdjWK3BgD6YUN6GHvNiQ6RRteQCFKPFVjGeSj6vdbCrfqFpjGJZMeK0X+w+YWM3tIZzacViwbZwLorkqLgYF6Llh9eGaRBX5aG6JGj2281TyUU6+Dutu9boSdQqnamXgg/oqFNBJ1+vLZ322TiYTxdfQLrTLemTcS533VnM0Ky7MCPaPq47SsyJjhpCYDH/wGfrI/KeC86fN5B0Pu776Nz5CirvGBo5zp2+Z60cvs1TbFGLxfomkBxDO3AnpgMfXvSctOKZSm4lGZXj5BRC0+QI7c1CKvq9zCXHrP6MRqQz+QecORebbCO2qwM2mz62XoYN4WTQRuC677lGZ1QuzRcQccv7+nmZ/M2AxJcghm5mjcx9F9GWh4RfnAHxlJldmmy3VKLaG6lq3orxrl7HrMHc2ufU9Cp9aUBM+FRYNArDiertUu595jeWBr0GVxcTtKytIBsmx2N4Fgbkd5QSVJIPQ/llbShAm00aJldBsxQ2GJCBO0eFbd0Hk8sQNhMKkqPS3iVKMXh3bYz7iGYQhSdMPq5pjbmWR034EVKUzPD+ni9NCafh8oGhGxVhjObB8e1AiiAWM75sNV4vYMYvxLnI88rzZw1jzsgXaiWgT2J7LW6/RldWDgGEU/3zLvToIARHFHFmceDt6Kd5WZO03fEdldS81biOdjGEM+SV3p7onfx26lf6Prqiu8bchKT6q6d0v0ej7BA51LgAiOREvniAzWO9u1bHPOPEmM8amUUeZn2oRcSsvF32X6UinhFBYC81qopF5e5XWHrDwtNsH6q2YMXUEDh4f91WPjSsviddUrbXkZHoFGWo2TbFhBUOMGI1/r8kx+layNQikOKB6RVkCUgH/uP4hPvN59d2xQnYf4SG2DLbjXgYJ/GvlugCCgIQ6pRgBS1mmnTjZ+lSq2KY91tEKGROMyNFMOcvEYNsUPMnwMP UnGXiW0F zbq2kFxTamjOjln7T2F6Md8ISMKjKpwolXnj2+pZ/XyQBoLQgO7Tgh8IxVpgm28Rq9hf1EGvRVQC+FW+fZloHH7RtNq9pp54VAMNDU+kgUnPxaZSBdFbTveoyVlSttFmone2ocrGeUyI4XYIrSk1kEWEgJclbluDqfVvknoPeEbtX7SHq6CDlDq/Bub+7IduqsgoOu8KT4hSzASWtPBk2Eeg8lLkjh0XVZ6aAWyStsQ5otU1DdBQO0R9c1Q+wJAfh46uI3KGpXqeh4EBB+AI6PvuOzUgwP4YeOCgSUzDduGiwLZvwKqc53rLiilNIUwcss8Nb929E3xIe0Uormw6dqR/pbnnNuPOKRh3y4snoDg+ogR6c50cD6jRFTA== 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; /*