All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Mark Brown <broonie@kernel.org>
Cc: Oliver Upton <oliver.upton@linux.dev>,
	James Morse <james.morse@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <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
Subject: Re: [PATCH] KVM: selftests: Add coverage of MTE system registers
Date: Sun, 12 Mar 2023 10:29:11 +0000	[thread overview]
Message-ID: <87edpu5klk.wl-maz@kernel.org> (raw)
In-Reply-To: <20230308-kvm-arm64-test-mte-regs-v1-1-f92a377e486f@kernel.org>

On Wed, 08 Mar 2023 17:12:26 +0000,
Mark Brown <broonie@kernel.org> 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 <broonie@kernel.org>
> ---
>  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.

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Mark Brown <broonie@kernel.org>
Cc: Oliver Upton <oliver.upton@linux.dev>,
	James Morse <james.morse@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <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
Subject: Re: [PATCH] KVM: selftests: Add coverage of MTE system registers
Date: Sun, 12 Mar 2023 10:29:11 +0000	[thread overview]
Message-ID: <87edpu5klk.wl-maz@kernel.org> (raw)
In-Reply-To: <20230308-kvm-arm64-test-mte-regs-v1-1-f92a377e486f@kernel.org>

On Wed, 08 Mar 2023 17:12:26 +0000,
Mark Brown <broonie@kernel.org> 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 <broonie@kernel.org>
> ---
>  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.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-03-12 10:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08 17:12 [PATCH] KVM: selftests: Add coverage of MTE system registers Mark Brown
2023-03-08 17:12 ` Mark Brown
2023-03-09  9:07 ` Cornelia Huck
2023-03-09  9:07   ` Cornelia Huck
2023-03-12 10:29 ` Marc Zyngier [this message]
2023-03-12 10:29   ` Marc Zyngier
2023-03-12 14:35   ` Mark Brown
2023-03-12 14:35     ` Mark Brown
2023-03-12 15:37     ` Marc Zyngier
2023-03-12 15:37       ` Marc Zyngier
2023-03-12 19:35       ` Mark Brown
2023-03-12 19:35         ` Mark Brown

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=87edpu5klk.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=broonie@kernel.org \
    --cc=james.morse@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=yuzenghui@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.