From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8155C74A4B for ; Sun, 12 Mar 2023 10:29:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbjCLK3Y (ORCPT ); Sun, 12 Mar 2023 06:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbjCLK3U (ORCPT ); Sun, 12 Mar 2023 06:29:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97FA837577; Sun, 12 Mar 2023 03:29:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 49D13B8074D; Sun, 12 Mar 2023 10:29:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D83A3C433D2; Sun, 12 Mar 2023 10:29:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678616956; bh=aSQAHnGftmgjvVgaTHrVDh6VUtyePFdAf7NI0ZkUpFE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=A1hM2L72FEiLsJdNdKRTCnVOURRRH/9zZF9irtqvQpEkX01wEH+6If3trtpJu7+Hl Pe4gW2xNJk2bLCWr05319WycfTg5fY7SphFt3vgqXsFm+ozWSipiw46UBxfix4JAev YVMkryuxVlI2A3K+g8L8wqzEQMVYiBIEPRw+jVJctfQc/4Ek5kslu/o3A4M0o7pqR0 pGcq2Kg3VqE2GYAcZswKhXP/NTX3wv/A787HUJ9VMR126zJRAkX4VOiptOV3odEhO5 VeY2ANQesQ8N7ZQYdp0t+uBg3A2hDeFEk/13/NkFd/HqoIf07IVXWhc6jpNDCr1o15 NUjUpolPf4FrA== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pbIwy-00GyR2-D6; Sun, 12 Mar 2023 10:29:14 +0000 Date: Sun, 12 Mar 2023 10:29:11 +0000 Message-ID: <87edpu5klk.wl-maz@kernel.org> From: Marc Zyngier To: Mark Brown Cc: Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Paolo Bonzini , Shuah Khan , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: selftests: Add coverage of MTE system registers In-Reply-To: <20230308-kvm-arm64-test-mte-regs-v1-1-f92a377e486f@kernel.org> References: <20230308-kvm-arm64-test-mte-regs-v1-1-f92a377e486f@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: broonie@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, pbonzini@redhat.com, shuah@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 08 Mar 2023 17:12:26 +0000, Mark Brown wrote: > > Verify that a guest with MTE has access to the MTE registers. Since MTE is > enabled as a VM wide capability we need to add support for doing that in > the process. > > Signed-off-by: Mark Brown > --- > tools/testing/selftests/kvm/aarch64/get-reg-list.c | 33 ++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c > index d287dd2cac0a..63d6a9046702 100644 > --- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c > +++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c > @@ -42,6 +42,7 @@ struct reg_sublist { > long capability; > int feature; > bool finalize; > + bool enable_capability; > __u64 *regs; > __u64 regs_n; > __u64 *rejects_set; > @@ -404,6 +405,18 @@ static void check_supported(struct vcpu_config *c) > } > } > > +static void enable_capabilities(struct kvm_vm *vm, struct vcpu_config *c) > +{ > + struct reg_sublist *s; > + > + for_each_sublist(c, s) { > + if (!s->enable_capability) > + continue; > + > + vm_enable_cap(vm, s->capability, 1); > + } > +} > + > static bool print_list; > static bool print_filtered; > static bool fixup_core_regs; > @@ -420,6 +433,7 @@ static void run_test(struct vcpu_config *c) > check_supported(c); > > vm = vm_create_barebones(); > + enable_capabilities(vm, c); > prepare_vcpu_init(c, &init); > vcpu = __vm_vcpu_add(vm, 0); > aarch64_vcpu_setup(vcpu, &init); > @@ -1049,6 +1063,13 @@ static __u64 pauth_generic_regs[] = { > ARM64_SYS_REG(3, 0, 2, 3, 1), /* APGAKEYHI_EL1 */ > }; > > +static __u64 mte_regs[] = { > + ARM64_SYS_REG(3, 0, 1, 0, 5), /* RGSR_EL1 */ > + ARM64_SYS_REG(3, 0, 1, 0, 6), /* GCR_EL1 */ > + ARM64_SYS_REG(3, 0, 5, 6, 0), /* TFSR_EL1 */ > + ARM64_SYS_REG(3, 0, 5, 6, 1), /* TFSRE0_EL1 */ > +}; > + > #define BASE_SUBLIST \ > { "base", .regs = base_regs, .regs_n = ARRAY_SIZE(base_regs), } > #define VREGS_SUBLIST \ > @@ -1075,6 +1096,9 @@ static __u64 pauth_generic_regs[] = { > .regs = pauth_generic_regs, \ > .regs_n = ARRAY_SIZE(pauth_generic_regs), \ > } > +#define MTE_SUBLIST \ > + { "mte", .capability = KVM_CAP_ARM_MTE, .enable_capability = true, \ > + .regs = mte_regs, .regs_n = ARRAY_SIZE(mte_regs), } > > static struct vcpu_config vregs_config = { > .sublists = { > @@ -1123,6 +1147,14 @@ static struct vcpu_config pauth_pmu_config = { > {0}, > }, > }; > +static struct vcpu_config mte_config = { > + .sublists = { > + BASE_SUBLIST, > + VREGS_SUBLIST, > + MTE_SUBLIST, > + {0}, > + }, > +}; > > static struct vcpu_config *vcpu_configs[] = { > &vregs_config, > @@ -1131,5 +1163,6 @@ static struct vcpu_config *vcpu_configs[] = { > &sve_pmu_config, > &pauth_config, > &pauth_pmu_config, > + &mte_config, > }; > static int vcpu_configs_n = ARRAY_SIZE(vcpu_configs); > Is there any reason why we sidestep the combinations of MTE with PAuth and PMU? I know this leads to an exponential set growth, but this is the very purpose of this test, and we found bugs related to this in the past. A good first step would be to be able to build these combinations dynamically, and only then add new sublists to the mix. Thanks, M. -- Without deviation from the norm, progress is not possible.