From patchwork Tue Jun 25 14:58:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13711458 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 44FBDC3064D for ; Tue, 25 Jun 2024 15:04:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC4156B00C7; Tue, 25 Jun 2024 11:04:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B744F6B00C8; Tue, 25 Jun 2024 11:04:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9ED5F6B00C9; Tue, 25 Jun 2024 11:04:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7ECD06B00C7 for ; Tue, 25 Jun 2024 11:04:58 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D9B53160158 for ; Tue, 25 Jun 2024 15:04:57 +0000 (UTC) X-FDA: 82269733434.15.07A1DDB Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id 0C23D1C0061 for ; Tue, 25 Jun 2024 15:04:36 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="r8cjstF/"; spf=pass (imf18.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719327863; 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=WWCcnUoJjrrALxAjBZhPpvknZTOgZ9IOR5Q3O7LGZXc=; b=0xbSJGkzaLa2bCT1IkVQzeHPnaNzIIdNAyNZ3XQmHfkjSreyQ9eaE5qDfAvr+qBu0ZSMxI FRqdZJShvwn2ztYw6u2rxCFaB3AR4rWSGZNMYAat1cEMCikJtnwOov/0b5kga+Nl5dYMVz 1aeeu2YzlK+1am9flYjoXLGsWy70a2w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719327863; a=rsa-sha256; cv=none; b=6Qdzpr+udMaNCqNvYKdfVbqew6rRQHK2iNGXAYHy0vjO1kyEVP0URAyHsbMcdwtl9HXH8H Q869XZ2v2xp4z3ueZDMzcK62YCRE9gGdijt7JssP9xy3W+DEBZY6q291geCoI4cgD2T1aa 3cm5s75etEK+7/KdRb3yG7w3tl+pBwE= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="r8cjstF/"; spf=pass (imf18.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 363CFCE1B78; Tue, 25 Jun 2024 15:04:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFEFBC32781; Tue, 25 Jun 2024 15:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719327873; bh=+guAOBhRmIfgEVfzNIbxa5iAcbQBA9Aonxf7B+eDgYE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=r8cjstF/mgdTleo91qpC2f9tAA/APzDt3Ah/q506dJUs0NQK+MXiE8V/fP5BCNkd5 Uf4W1coDnlv9pX3xUikhGXVgudO0JzfOSomv7iOEJ9A8Gu60ZKHBcJI1xjPXhI/Rv0 1aYOm8OusCZ7nGtXfrq1fELmm40/kYT1qscr8JN+IebV+/6CIfBWCyck6Ldf59XR1A dRplzCv9+2bZFT/fYGD+/K4FqWmRHnGaN2vVZW/d1TDjjxuTXz3PZ2TT0SimG1H5HK uwW3uhXxbjDIpdhpxfs+8LIziAdfH4byOMVg+XXs6e6wCqsqe8P4MgCdOrfKci99YW 1aCO84B2UXtjQ== From: Mark Brown Date: Tue, 25 Jun 2024 15:58:00 +0100 Subject: [PATCH v9 32/39] kselftest/arm64: Allow signals tests to specify an expected si_code MIME-Version: 1.0 Message-Id: <20240625-arm64-gcs-v9-32-0f634469b8f0@kernel.org> References: <20240625-arm64-gcs-v9-0-0f634469b8f0@kernel.org> In-Reply-To: <20240625-arm64-gcs-v9-0-0f634469b8f0@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 , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy , Kees Cook Cc: "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , Thiago Jung Bauermann , Ross Burton , 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.14-dev-d4707 X-Developer-Signature: v=1; a=openpgp-sha256; l=2693; i=broonie@kernel.org; h=from:subject:message-id; bh=+guAOBhRmIfgEVfzNIbxa5iAcbQBA9Aonxf7B+eDgYE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmetuLHhc9eoiFwa2wgiNY9NyD96L8JKN8REd40ykS +Qp3x3SJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZnrbiwAKCRAk1otyXVSH0JywB/ 4xJOFMt9ir0tkNA9PxrFv9eJTeMLvSLxhqLsveF3LAyd3Uu/yVbBgFU+5FTFqGi+4sJ9m/NlnTFVx1 N5bIEo9e9/46Xb1lRUnO8Tl7P6bUAhlPC5QVqvWY3Rndee2MvV6APAc3Wjktm9tJiPAoCYYAEFKGHy N6hegX+FVqJZpNIav+9enZxpWZendOqihOSq/kI73pEBvUsE59IygNpO3oF1R2R1cW2nWrM367aaLJ oZKU663P9entBZ0rNz/KVgbW4BobG8tcdSbsFY4jz8lRZfeeNL8M1UBHH6E+SmacoLvWdwdI+/7sq4 QrdXN0MS7m2o3ZTNBuMEjofJd08Dsp X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0C23D1C0061 X-Stat-Signature: ytnai94xsrjuuq5om3n9dgpr9b19xxh5 X-HE-Tag: 1719327876-900723 X-HE-Meta: U2FsdGVkX1/wlZ+ig6B9HafxjIHnmxpifk/II9Lbyze4BKAoI1rlJayfykyGAGH7+xowENyOG1Wn22bKD2Ixa0+vcaFOTmuC5fCMHvLtk+Zp4igBL7xVrSAFEdTTIL1mKaBZo63Q57d+4rqevFI5VbUGPp7rkuRtJ4etKQn8deMcIzneRuord9RYhDF+vM1e1kQfJyN88gBRijNyT0DgMw400pDudSl1ZNPEzaCswqACptMJFZo604OWvbTF3D7ieg40bjnwUpe5RRV1607gIOD53z1CSSKnJxDh4+yeFbCM42LK0dhmnp1dKwrfHKV9T0v8v7zhZFobLJIWey3MQm7IVndDylkORrv6NePxsRxNRATajYCximy5nkEbqwLPgMFgg4dosHlp/kOOpFqjF8b611okG3bd6chFwFJfm70n8pmddQdd4nRSWBjG63AqACrpmrw8BoY8BWSKzpFHtHdIzCMl723q8AvYJlXJIY2bxCKNvGrC90rszD7awT5D5Eke6pY1ThhCGDLTOjJJxSmZdUctBuX5gK2HImMSkCHjOauEq23kOInNztdHAixqDhcJ4KTg2XCGzFhIISuvkA5uHJgUmY1is0VY5MdfxtK2nPqG1h3qcBo2Y6YbqRlUnJ/tbXd72py32ALkZFbwL+0QW1u1u0fhc88EJFRrCf0ugGTY24llQOSSbxvYB8EgsSwwPjiKsN1MwfzukmsadbeaQekt8umraoM1a3J811S9qpBmaVdbOgCvdlsAcMD9DqktS+iVw+6NObjUt1mqnSn4w1eDu++FJMEnpAmivHiSPchTjw3rKDVVbY0gVTbQyflqXmzS0uxfB0AiGB7UWXf2AkMru8EfLKuXk0LhH1eCWVc6cN1j2O/eEbzUI5XUfK+biO9uvy3oR6pozrZxtkbQ+kWYExsZEkJSyuzAzsByiZt+kqd5vdul5/L6YjVTvLtYBGzOv5Farbwaik/ F9UnlBwP 23vHP7Mo+nNjhDTOTjAgIyLAZm72Qt6IzbfKqJxbffI4DNx5Vc/SwA/OMicmcQMMnqnWi2GSHTuS3p6avyxIuaTjVz0/OE9gPsCrjr0Xw5Nm0LYOSrGMFlzMsopWXShmevS0NsPsyZn5hpWaDCVZlFI+1236tjYCaer4G+qPB9MBeNLMIhXDpv3veyC/M/iPEEChymC8Ngfjv5qEwA1+MvVukCnx6BCbiRWNM12dxzwOFnefQElE3EeIDtYuq2YdpbEH9hmpIc3mtBd4YbspS/nOHNCEGzRrhV9FiPzt+ktM/R81/wD/4W9z9UaBxAp58kCxIBOyo/mPYfT8+ybBR3H1R3JdDjNalfLJQV26TYQcntkXx49+OP1iNWotsMv2Ic4uHlvv2P1PwnxdqP6RXfPwHn75yKYOgluaWfAPmlTcroiQ= 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. Reviewed-by: Thiago Jung Bauermann 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; /*