From: Cristian Marussi <cristian.marussi@arm.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>,
linux-kselftest@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, shuah@kernel.org
Cc: amit.kachhap@arm.com, andreyknvl@google.com, dave.martin@arm.com
Subject: Re: [PATCH v9 02/12] kselftest: arm64: mangle_pstate_invalid_compat_toggle and common utils
Date: Fri, 25 Oct 2019 10:56:39 +0100 [thread overview]
Message-ID: <d098f030-f3b7-82b6-8489-fa8985870237@arm.com> (raw)
In-Reply-To: <dde06d83-4c3b-0be4-db98-e740a1dd327e@arm.com>
On 24/10/2019 23:41, Suzuki K Poulose wrote:
> Hi Cristian,
>
> On 10/09/2019 01:04 PM, Cristian Marussi wrote:
>> Add some arm64/signal specific boilerplate and utility code to help
>> further testcases' development.
>>
>> Introduce also one simple testcase mangle_pstate_invalid_compat_toggle
>> and some related helpers: it is a simple mangle testcase which messes
>> with the ucontext_t from within the signal handler, trying to toggle
>> PSTATE state bits to switch the system between 32bit/64bit execution
>> state. Expects SIGSEGV on test PASS.
>>
>> Reviewed-by: Dave Martin <Dave.Martin@arm.com>
>> Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
>
> [...]
>
>> +
>> +#define get_regval(regname, out) \
>> +{ \
>> + asm volatile("mrs %0, " __stringify(regname) \
>> + : "=r" (out) \
>> + : \
>> + : "memory"); \
>> +}
>> +
>> +/* Regs encoding and masks naming copied in from sysreg.h */
>> +#define SYS_ID_AA64MMFR1_EL1 S3_0_C0_C7_1 /* MRS Emulated */
>> +#define SYS_ID_AA64MMFR2_EL1 S3_0_C0_C7_2 /* MRS Emulated */
>> +#define ID_AA64MMFR1_PAN_SHIFT 20
>> +#define ID_AA64MMFR2_UAO_SHIFT 4
>> +
>> +/* Local Helpers */
>> +#define ID_AA64MMFR1_EL1_PAN_SUPPORTED(val) \
>> + (!!((val) & (0xfUL << ID_AA64MMFR1_PAN_SHIFT)))
>> +#define ID_AA64MMFR2_EL1_UAO_SUPPORTED(val) \
>> + (!!((val) & (0xfUL << ID_AA64MMFR2_UAO_SHIFT)))
>> +
>> +/*
>> + * Feature flags used in tdescr.feats_required to specify
>> + * any feature by the test
>> + */
>> +enum {
>> + FSSBS_BIT,
>> + FPAN_BIT,
>> + FUAO_BIT,
>> + FMAX_END
>> +};
>> +
>> +#define FEAT_SSBS (1UL << FSSBS_BIT)
>> +#define FEAT_PAN (1UL << FPAN_BIT)
>> +#define FEAT_UAO (1UL << FUAO_BIT)
>> +
>
> [...]
>
>> +static int test_init(struct tdescr *td)
>> +{
>> + td->minsigstksz = getauxval(AT_MINSIGSTKSZ);
>> + if (!td->minsigstksz)
>> + td->minsigstksz = MINSIGSTKSZ;
>> + fprintf(stderr, "Detected MINSTKSIGSZ:%d\n", td->minsigstksz);
>> +
>> + if (td->feats_required) {
>> + td->feats_supported = 0;
>> + /*
>> + * Checking for CPU required features using both the
>> + * auxval and the arm64 MRS Emulation to read sysregs.
>> + */
>> + if (getauxval(AT_HWCAP) & HWCAP_SSBS)
>> + td->feats_supported |= FEAT_SSBS;
>> + if (getauxval(AT_HWCAP) & HWCAP_CPUID) {
>> + uint64_t val = 0;
>> +
>> + /* Uses MRS emulation to check capability */
>> + get_regval(SYS_ID_AA64MMFR1_EL1, val);
>> + if (ID_AA64MMFR1_EL1_PAN_SUPPORTED(val))
>> + td->feats_supported |= FEAT_PAN;
>> + /* Uses MRS emulation to check capability */
>> + get_regval(SYS_ID_AA64MMFR2_EL1, val);
>> + if (ID_AA64MMFR2_EL1_UAO_SUPPORTED(val))
>> + td->feats_supported |= FEAT_UAO;
>
> As discussed, these fields are never exposed to userspace via mrs. So
> you may as well drop these features.
>
Yes I'm going to drop this code in v10 (which is also un-needed in fact by the current testcases)
Thanks
Cristian
> Cheers
> Suzuki
>
next prev parent reply other threads:[~2019-10-25 9:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 12:04 [PATCH v9 00/12] Add arm64/signal initial kselftest support Cristian Marussi
2019-10-09 12:04 ` [PATCH v9 01/12] kselftest: arm64: extend toplevel skeleton Makefile Cristian Marussi
2019-10-09 12:04 ` [PATCH v9 02/12] kselftest: arm64: mangle_pstate_invalid_compat_toggle and common utils Cristian Marussi
2019-10-24 22:41 ` Suzuki K Poulose
2019-10-25 9:56 ` Cristian Marussi [this message]
2019-10-09 12:04 ` [PATCH v9 03/12] kselftest: arm64: mangle_pstate_invalid_daif_bits Cristian Marussi
2019-10-09 12:04 ` [PATCH v9 04/12] kselftest: arm64: mangle_pstate_invalid_mode_el[123][ht] Cristian Marussi
2019-10-09 12:04 ` [PATCH v9 05/12] kselftest: arm64: extend test_init functionalities Cristian Marussi
2019-10-09 12:04 ` [PATCH v9 06/12] kselftest: arm64: add helper get_current_context Cristian Marussi
2019-10-09 12:04 ` [PATCH v9 07/12] kselftest: arm64: fake_sigreturn_bad_magic Cristian Marussi
2019-10-09 12:04 ` [PATCH v9 08/12] kselftest: arm64: fake_sigreturn_bad_size_for_magic0 Cristian Marussi
2019-10-09 12:04 ` [PATCH v9 09/12] kselftest: arm64: fake_sigreturn_missing_fpsimd Cristian Marussi
2019-10-09 12:04 ` [PATCH v9 10/12] kselftest: arm64: fake_sigreturn_duplicated_fpsimd Cristian Marussi
2019-10-09 12:04 ` [PATCH v9 11/12] kselftest: arm64: fake_sigreturn_bad_size Cristian Marussi
2019-10-09 12:04 ` [PATCH v9 12/12] kselftest: arm64: fake_sigreturn_misaligned_sp Cristian Marussi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d098f030-f3b7-82b6-8489-fa8985870237@arm.com \
--to=cristian.marussi@arm.com \
--cc=amit.kachhap@arm.com \
--cc=andreyknvl@google.com \
--cc=dave.martin@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=suzuki.poulose@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).