From patchwork Fri Nov 24 16:35:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13467939 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 D800FC636BD for ; Fri, 24 Nov 2023 16:36:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 356756B0401; Fri, 24 Nov 2023 11:36:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 302CA6B04E4; Fri, 24 Nov 2023 11:36:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A8406B050C; Fri, 24 Nov 2023 11:36:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id EE4A96B0401 for ; Fri, 24 Nov 2023 11:36:23 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D01E316081A for ; Fri, 24 Nov 2023 16:36:23 +0000 (UTC) X-FDA: 81493400646.24.1C8DADA Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf28.hostedemail.com (Postfix) with ESMTP id F33E5C0023 for ; Fri, 24 Nov 2023 16:36:21 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf28.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700843782; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YNkcXSgGRDymuV58X4qc061+QC02OLUecAIL1awl8EY=; b=iDP9S5vJcDNwV38ECOmls2T9MuEbFUVof5sREHJbuAVjW2TlgCtZAQj0id2Fes7ja9c+nT +XU02Asbu+ttOrx7WgcfyDSm5a3iHpXvhz9Vke8u36/5Xzzua/x5smXilMjrf8n055zUNJ 522vQ/9+s4YziTR4/G4FRhigLYjUrJg= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf28.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700843782; a=rsa-sha256; cv=none; b=ttRVOiAikjCYrLHNCrwWaEMc8ySaA8/bTobORfRCal7klGs4EghnZKnsxviQ3dqvQeLMo1 tYsG7ilnwYGy2cgLYjqbjMi51XXZeBRL3HYotOjBsNuw4DPtcRe9+2MIS4WhqYjoBN27EP x2Nbm8X80cYOPZyQrP1rb5GuUGL+cvQ= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D5AAD1BF7; Fri, 24 Nov 2023 08:37:07 -0800 (PST) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 323DC3F73F; Fri, 24 Nov 2023 08:36:19 -0800 (PST) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@linux.ibm.com, broonie@kernel.org, catalin.marinas@arm.com, dave.hansen@linux.intel.com, joey.gouly@arm.com, maz@kernel.org, oliver.upton@linux.dev, shuah@kernel.org, will@kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu Subject: [PATCH v3 24/25] kselftest/arm64: Add test case for POR_EL0 signal frame records Date: Fri, 24 Nov 2023 16:35:09 +0000 Message-Id: <20231124163510.1835740-25-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231124163510.1835740-1-joey.gouly@arm.com> References: <20231124163510.1835740-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: F33E5C0023 X-Stat-Signature: me91rh8siobqc8u6b8oigk6on1asos7t X-HE-Tag: 1700843781-866017 X-HE-Meta: U2FsdGVkX18OkfA+N09w8cqfO/m+DGzm2WkeQZqwOqGz/GpcBV6dELqnCfvBJerLjk7h/+4AiiTN2h6lB1VFMUI+O/t3kejbGFXAvst/CJRXfyn4AQ99mNQYOW7BZM/azNTMsKS+62hH1eFQcNCK1INSzrVJbvuVCWC34W6snRGoHBbIRJnoZHsHyBXcQ3O7+nNGPMVUH3kK2QDkt8YP2VXFDfknixEKYUJZwmzXLyUve2vNIPpiKUuWmWG6zJ+n411+JJ5qfE2xMuc0DX66LAVMTG3VTftUjzNdktTw9b5lVethOrhZq8z6I/3+Bk/3RTj1RvlmTf93iFpyZl/Ua8/Uz7upfqICVG3YNFz0MJO94rzW6cag3/FsFKHEfghu5WOvePqT6OJkWYlmFMvP2VEq+mXZoq+uJROWYrO5LPmYye+8/vAMmhpuFoyBKT7yAL6THUXXUnBJ/Y6TdRn+32h3EUupwWsx/vSsu1s4j+zgmk5ZzW5ooalMkLiWgCT51o5+GbkgDvtmMt/oJDG45mXlht9BbG1nWjVe8DX2azTt3TjFlFUYheVUvRGpfgOQnitCFLdYuuKFYZKS397AJCoonSPpGUS7mCD3aU9Y17isrPP+ZeiXbgV08ry29CYOu2vV2ePvNgFCJM+ZKEeiXsoRnD5cwIO55k2xoyiN9Z0Hus47u8OYE5QC9odyYyOKBPvWEStHLxx2K7ZAauPD/VARfAO6DP05+TL/HkuxwU3uXiT19dnwIyoy0ek+peS6dX6AjwFOpeT9K/mCf+xK5/HfEcAewkCq0ReEJaM/jTm4i3ORRgKrKtaTtXFrnXhHo3gd7janSdhFTYnJ2GejeIQ6WJHro7DIEAiOpSAzQPmMP/fvWB3Onn+CI8QVPHBkI10vh1HOMx3bFjTWsvUSMbskhX/v45oBub973eisqO3MKFys1PBeiLDSKJ3C0j+HlATC8qQDMkR59/Xt0mM 5DxOM3kr wYK5WUDuIulVYSvMcA5gY+/s0UJiTbXnAbQJtsYtoNPxMYyd783tDUVs/hvXwmA90bCcGTJMRA5h/mVqujmrQZEjhXcjFtrBBdC/LVOwrv3J94+ukX/dzxwiuMLEjx3lWQ/WsiWtuF+AJCpzpyVZ63rMN5tXaWMZzL2U+gCJ2/bQNkvuPn90GPx0HZruYDZ1kJBmcuDgeHB8p5cPK3tDb+pKLxq5mPHZKAiJbyvR3njxNS3raw9ebl67SHhf0bp7H566XUpm5fwAbLaU= 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: Ensure that we get signal context for POR_EL0 if and only if POE is present on the system. Copied from the TPIDR2 test. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown --- .../testing/selftests/arm64/signal/.gitignore | 1 + .../arm64/signal/testcases/poe_siginfo.c | 86 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 tools/testing/selftests/arm64/signal/testcases/poe_siginfo.c diff --git a/tools/testing/selftests/arm64/signal/.gitignore b/tools/testing/selftests/arm64/signal/.gitignore index 839e3a252629..6bcb27bd506b 100644 --- a/tools/testing/selftests/arm64/signal/.gitignore +++ b/tools/testing/selftests/arm64/signal/.gitignore @@ -5,6 +5,7 @@ sme_* ssve_* sve_* tpidr2_* +poe_siginfo za_* zt_* !*.[ch] diff --git a/tools/testing/selftests/arm64/signal/testcases/poe_siginfo.c b/tools/testing/selftests/arm64/signal/testcases/poe_siginfo.c new file mode 100644 index 000000000000..d890029304c4 --- /dev/null +++ b/tools/testing/selftests/arm64/signal/testcases/poe_siginfo.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 Arm Limited + * + * Verify that the POR_EL0 register context in signal frames is set up as + * expected. + */ + +#include +#include +#include +#include +#include +#include + +#include "test_signals_utils.h" +#include "testcases.h" + +static union { + ucontext_t uc; + char buf[1024 * 128]; +} context; + +#define SYS_POR_EL0 "S3_3_C10_C2_4" + +static uint64_t get_por_el0(void) +{ + uint64_t val; + + asm volatile ( + "mrs %0, " SYS_POR_EL0 "\n" + : "=r"(val) + : + : "cc"); + + return val; +} + +int poe_present(struct tdescr *td, siginfo_t *si, ucontext_t *uc) +{ + struct _aarch64_ctx *head = GET_BUF_RESV_HEAD(context); + struct poe_context *poe_ctx; + size_t offset; + bool in_sigframe; + bool have_poe; + __u64 orig_poe; + + have_poe = getauxval(AT_HWCAP2) & HWCAP2_POE; + if (have_poe) + orig_poe = get_por_el0(); + + if (!get_current_context(td, &context.uc, sizeof(context))) + return 1; + + poe_ctx = (struct poe_context *) + get_header(head, POE_MAGIC, td->live_sz, &offset); + + in_sigframe = poe_ctx != NULL; + + fprintf(stderr, "POR_EL0 sigframe %s on system %s POE\n", + in_sigframe ? "present" : "absent", + have_poe ? "with" : "without"); + + td->pass = (in_sigframe == have_poe); + + /* + * Check that the value we read back was the one present at + * the time that the signal was triggered. + */ + if (have_poe && poe_ctx) { + if (poe_ctx->por_el0 != orig_poe) { + fprintf(stderr, "POR_EL0 in frame is %llx, was %llx\n", + poe_ctx->por_el0, orig_poe); + td->pass = false; + } + } + + return 0; +} + +struct tdescr tde = { + .name = "POR_EL0", + .descr = "Validate that POR_EL0 is present as expected", + .timeout = 3, + .run = poe_present, +};