From patchwork Fri May 3 13:01:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652807 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 DD512C4345F for ; Fri, 3 May 2024 13:03:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C3A86B00C7; Fri, 3 May 2024 09:03:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64E456B00C9; Fri, 3 May 2024 09:03:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C7AD6B00CA; Fri, 3 May 2024 09:03:31 -0400 (EDT) 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 1EAD76B00C7 for ; Fri, 3 May 2024 09:03:31 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C05EA1210CC for ; Fri, 3 May 2024 13:03:30 +0000 (UTC) X-FDA: 82077100980.07.29CDD08 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf22.hostedemail.com (Postfix) with ESMTP id 1E8A8C0003 for ; Fri, 3 May 2024 13:03:28 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf22.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=1714741409; 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=4CEAfIaeEBfWG28tM/+Z+JU6dETZKCB1H0URWPlfLto=; b=1Mnc3nGmdbMAJ7K8znaK03qGnMUyt8NfqqUFeqlzlrEwNP5pFYIFfBniL/Od/tkmVB96np pcG4UaXNqIAWl3YEJJIwJ7Jnx1eIqxcnTBEFUWos5yRBV6oHE9KoGCCAztukszthmMGDG7 3jgedztFsydjafAckwlfCNlHbuj3Yn0= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf22.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=1714741409; a=rsa-sha256; cv=none; b=Jiq1zlXpnGasDMYakcDfCA96+mTsmxBiUNSo1RO7YeCaoUYMLkt6YN0ErPVZNr1D+AFuId bZfz0uANW1JNWQbgMjsnl/6oH9D2/JoIYgvtAhKJlwmMOZE2KSCva9xv8JYSQz8BMO0eLh j6hgUi3KZCqollLz/fGG1Qcd9Qo2RXc= 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 A16001762; Fri, 3 May 2024 06:03:53 -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 503FB3F881; Fri, 3 May 2024 06:03:25 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.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, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 28/29] kselftest/arm64: Add test case for POR_EL0 signal frame records Date: Fri, 3 May 2024 14:01:46 +0100 Message-Id: <20240503130147.1154804-29-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: 8gz8rxngjyc1p4qn8ruaap4ipczaqkup X-Rspamd-Queue-Id: 1E8A8C0003 X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1714741408-377573 X-HE-Meta: U2FsdGVkX1+ela8wBOk/ulw0QHXAS5LHMJ/dMXed8FH7+nkiyDLUOay0omxsedVVlWFHp2xH2jz2h09569Eq1FJWlvOSq4DCStWleZhx+8BRX81Ueq9vM8xt+pl9XMDgzQGecNSdjVcODtjLwQAjbkpKMmj3fgJtzqXJaFGO7f6DOsGf4hOGDmR0wWynkFeO6xq8bKOubGh1nziPreVZOQTlS6+3WuaJPl7oyA2Pyml2SQuGT2HVo1sUADxI6IwjlQn0bjJaeINWCXhId2YRSW4wPd6d29911efvMwA1Kn2p6dgEBWEjv9bcOMu8fIHmpcrvsHNRbLNJ4dZNqRu9jzer4K+Ol15ezvSkjYPMEoiO+5jVDEkYfCFxOZ4aiqo2CY7RfUqHUz0lYl71yZkXKkDGaRqNbBeUajXhH6WZQvYW4xCS6LxKbJBXbi3b7D/4aV7Jnyou3ABsHbv/0xyPq8N1v23lrpA+YvRuo5K4XqfjaaOVa6QI3drGj5KFvpkJ5QUaTdC5NKcE4wCnQZr4VKoF4Yh9l7JX9IpTzKhaV/AUEc7IpGqqRDe1FvDX1T0eH4SdtA3JbOgaHWpxMcCZejbCUkAboW4PTXp0o3B0xbZFDD4T+U2VO7TjtL/7+RxdVbuniG48oh8GrlbplrJ2WK6maNv6jp4aF1RGd7AhpljSmi47TZ4OIbrpbx1okFh01UqlaKKaLQ8qmtQD6CO8v/sYW58qtXiC0d3aSuCkKxDvdJ/GtfpgC1Kq+mLK+RZsEa6ZLFoWYggeS8APnEQCoPJe+fggskn4lFsRvlB1sBjTNiQnHm6Ml5dyRB3oHiyADgcWSf47LZZDoPpaHAMcHXIbl4A5zRrAwAkV/tc6MU5m2r2kVm4jKkCP2QfIhNi3k7E/ewtL1gp6QDsAErr8WSWs/DBtsWgoYZ4rdpZlYMEnrMrta2k2e4LbE+VfYC+bH0wXM7q+ATQgRtsyuqK Ek90FaY2 6Va6HQGVRrVFN1DyUPI6KKYkKi81uqOpzhks+rtD/wA9xX28SobApgoD/v198XSEcm4w+E8dphj1vC/SNAewRVUng+stIMBr9JuTDpGiWgn1TurifG83rUt4sSo0Gyuph+FzHtY+qL2TpPiA8suN3uXq9wlFbr/VpC82fgIFQmspRr6XGUIrsCyYSElM1n3Ic8S4VtEDgMldogSjAcBwd2VBLuZwjf2XlIJjGAM/9UU6UzU+AxbKKwXcyMjq2fP4hiy47B1iGYbrkyko= 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 a/tools/testing/selftests/arm64/signal/.gitignore b/tools/testing/selftests/arm64/signal/.gitignore index 1ce5b5eac386..b2f2bfd5c6aa 100644 --- a/tools/testing/selftests/arm64/signal/.gitignore +++ b/tools/testing/selftests/arm64/signal/.gitignore @@ -2,6 +2,7 @@ mangle_* fake_sigreturn_* fpmr_* +poe_* sme_* ssve_* sve_* 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, +};