From patchwork Thu Aug 22 15:11:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13773699 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 39F00C3DA4A for ; Thu, 22 Aug 2024 15:13:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBA118003E; Thu, 22 Aug 2024 11:13:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B69C68001E; Thu, 22 Aug 2024 11:13:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A31AE8003E; Thu, 22 Aug 2024 11:13:32 -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 86BE18001E for ; Thu, 22 Aug 2024 11:13:32 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3070C141553 for ; Thu, 22 Aug 2024 15:13:32 +0000 (UTC) X-FDA: 82480225464.15.F91C99B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 63A3A1C001B for ; Thu, 22 Aug 2024 15:13:30 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724339502; 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=0v2110ndxTNPQPfCkNdnXDwPtBR9iCN3D470MJVMX2Y=; b=wdKSKf6UKF4wWhyYF93ZgLuC06+8x1hhaAqvW56sBhLsovtTrBhTMqJwhrrW5rOJypvEyQ 5OJbHVjDihqI0frV/Sw9N2kPEsL0kuWZIZuKEn9ncFb5Tz3MNs1YJ/pxPq0XuS1c7nBDAK pPgA8g4ByqO0nSZ8r5ebSNd53EE+NWg= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724339502; a=rsa-sha256; cv=none; b=JMS6ZLX5O7mgI2NNBjCtqLe2fUXeNqbPxkjI+UJFSHPQcpMFQPf8FCOW50+VBUxld6hxz5 UO/RmD+pZBSwUMy+hhBn/WrxW48tVG80m6YfAhRVG3+aSI9gA/8wOAniAGUgqgsM7F6vep 1E0EiiePuYSSOZl9CtFlTZfxCo/9U6o= 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 C52391691; Thu, 22 Aug 2024 08:13:55 -0700 (PDT) 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 A68193F58B; Thu, 22 Aug 2024 08:13:25 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: nd@arm.com, akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, anshuman.khandual@arm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, skhan@linuxfoundation.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org Subject: [PATCH v5 29/30] kselftest/arm64: Add test case for POR_EL0 signal frame records Date: Thu, 22 Aug 2024 16:11:12 +0100 Message-Id: <20240822151113.1479789-30-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240822151113.1479789-1-joey.gouly@arm.com> References: <20240822151113.1479789-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 63A3A1C001B X-Stat-Signature: erg64nm3t3trj1mjujdjzxx11eh6t8b7 X-Rspam-User: X-HE-Tag: 1724339610-511033 X-HE-Meta: U2FsdGVkX19z09wpn6saDtsXStZy6dAOv/htpnWPBNppuOeIP8IMceQGDOEnWza/Yy3Sxh6ECYNQNUfd1k/3ym8VYYiOewNt19YH0WTJnTnx4Yo4lDcV58E5Egp8sSKAyQBnwlyFbbywx3bNPrgRqMuA5gUO9sxKOFmglLbCrnmX3rHkwcscwQ1sxPBb/Cqots0DbOgKh9Tuj/ZyP9rZ8QZERMw7jaYoZ+7ntelal2tMaL7NUbWVMQZ26SnGCd3KjZwJIu33nCPiiqoi3C9DgpvXPfeeOK4QL4mQjBdGRN2H8r4AkK/Yy8BzyzHxWy5s7P1+TXH06faKqqq/NmWmPLz4/jcmsStbvWUT9zGOrO77g00mujoVtpPOzqFBSMsLRIh+D5EL3S2PUhd8Ks2ZDEvz3gr9bWuy4LnpM/ujOMmIpK9WsI3WQCzwxBJkOkEIkpNCDLoICCejudLcVprj/0lHoSIiZbYbc56qImNGBRD6fJvEsEPyO4b0cXvQ8tm7bf0V6Pl4ljOpkZE6ocCbj7kEM0Cg1IFTh1Az8vo9aTBMstcUXGgaOij8psKsHSbvtg4id2nreyXhakIEkwwL58aR34qbcDUwlYDwf4meDeCM4uuqzy0bpuDQHKaiQDOPF4FWrai4pnKVrn8o6+HXjYrGtjNO69nyq9gn48O49bd5wFSUZRtoA10kmyx8vw4khW3xs4Dl8MxCAPi9DWVUsevip/XSjfoD5za+YYLsqURZEKec1zs0WI7RximtBFC3MEGKDmv/628r6vH3GhUgaNnjRMs850JvPDVBy1sgZwoEIi9l3W5PCsof/C7ECuaZomxbZY74N2if6Dj9wLMnkWtlgLmzcHEHWqtmjqUHGRFoWOZWSxfik/EV96JogrCmNUCU9lA4LaKNgJ0c7NOcI5vPTMLUBtRH14EZ/BVXmlB0/CctS3qYeanUVGIXaWYq2RXFtAMy8eTO5Plo0ps vfDih6vI gMWo2MBjbSz/grXOOKc5kzgSHic+a0tvoIHqs206GEgfLA8GWDFz0vw3U7fVrxF6iMCkGH1wlG+ccfcW8PiYXa0QWVs+H15vKRX2P0+6N3Eq92gls2RuK/W24h5I92DZJmvVPxX2sgpOC7M3nHzRtRLHQQ6jfVnA10F6LrFpDdaKBl7sFZyGyqS2WElGP++Lz15ks/U50z+CPDnY5/W5wHco72YT2olC4J0J6OWfkyAZjyZ0sxgKRMOOB/2xJTYe/HMw5C8p7wE0V5eyNHj8RUnXdDe2ykltqDawjdNiDn64XFl1QdcCInDgOMp1+/rpff14R 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 Acked-by: Shuah Khan --- .../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 tools/testing/selftests/arm64/signal/.gitignore tools/testing/selftests/arm64/signal/.gitignore index 1ce5b5eac386..b2f2bfd5c6aa 100644 --- tools/testing/selftests/arm64/signal/.gitignore +++ tools/testing/selftests/arm64/signal/.gitignore @@ -2,6 +2,7 @@ mangle_* fake_sigreturn_* fpmr_* +poe_* sme_* ssve_* sve_* diff --git tools/testing/selftests/arm64/signal/testcases/poe_siginfo.c tools/testing/selftests/arm64/signal/testcases/poe_siginfo.c new file mode 100644 index 000000000000..36bd9940ee05 --- /dev/null +++ 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) + : + : ); + + 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, +};