linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] set_id_regs cleanup
@ 2025-11-25 10:12 Ben Horgan
  2025-11-25 10:12 ` [PATCH v2 1/2] KVM: arm64: selftests: Remove ARM64_FEATURE_FIELD_BITS and its last user Ben Horgan
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Ben Horgan @ 2025-11-25 10:12 UTC (permalink / raw)
  To: catalin.marinas, will, maz, oliver.upton, joey.gouly,
	suzuki.poulose, yuzenghui, linux-arm-kernel, kvmarm, shuah
  Cc: Ben Horgan

For this v2 I've dropped the ksft_test accounting fix. Mark Brown has
more extensive changes [1] and looks to be a user of the set_id_regs
test rather than someone just doing some cleanup. The other change in
this series is to remove ARM64_FEATURE_FIELD_BITS from the tools
sysreg.h header rather than the kernel version. I'll send a separate
patch to remove the kernel version.

Tidies up a few small things in set_id_regs. The removal of
ARM64_FEATURE_FIELD_BITS touches other code only so much as it removes
the define but set_id_regs.c is the only place its used.

Based on v6.18-rc4

Link to v1: https://lore.kernel.org/kvmarm/20251114-kvm-arm64-set-id-regs-aarch64-v2-0-672f214f41bf@kernel.org/

[1] https://lore.kernel.org/kvmarm/20251114-kvm-arm64-set-id-regs-aarch64-v2-0-672f214f41bf@kernel.org/

Ben Horgan (2):
  KVM: arm64: selftests: Remove ARM64_FEATURE_FIELD_BITS and its last
    user
  KVM: arm64: selftests: Consider all 7 possible levels of cache

 tools/arch/arm64/include/asm/sysreg.h           |  2 --
 tools/testing/selftests/kvm/arm64/set_id_regs.c | 10 +++++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] KVM: arm64: selftests: Remove ARM64_FEATURE_FIELD_BITS and its last user
  2025-11-25 10:12 [PATCH v2 0/2] set_id_regs cleanup Ben Horgan
@ 2025-11-25 10:12 ` Ben Horgan
  2025-11-25 10:12 ` [PATCH v2 2/2] KVM: arm64: selftests: Consider all 7 possible levels of cache Ben Horgan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Ben Horgan @ 2025-11-25 10:12 UTC (permalink / raw)
  To: catalin.marinas, will, maz, oliver.upton, joey.gouly,
	suzuki.poulose, yuzenghui, linux-arm-kernel, kvmarm, shuah
  Cc: Ben Horgan

ARM64_FEATURE_FIELD_BITS is set to 4 but not all ID register fields are 4
bits. See for instance ID_AA64SMFR0_EL1. The last user of this define,
ARM64_FEATURE_FIELD_BITS, is the set_id_regs selftest. Its logic assumes
the fields aren't a single bits; assert that's the case and stop using the
define. As there are no more users, ARM64_FEATURE_FIELD_BITS is removed
from the arm64 tools sysreg.h header. A separate commit removes this from
the kernel version of the header.

Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since v1:
Remove ARM64_FEATURE_FIELD_BITS from tools header instead of the kernel
header
---
 tools/arch/arm64/include/asm/sysreg.h           | 2 --
 tools/testing/selftests/kvm/arm64/set_id_regs.c | 8 ++++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/arch/arm64/include/asm/sysreg.h b/tools/arch/arm64/include/asm/sysreg.h
index 65f2759ea27a..0f60b68eac1b 100644
--- a/tools/arch/arm64/include/asm/sysreg.h
+++ b/tools/arch/arm64/include/asm/sysreg.h
@@ -1078,8 +1078,6 @@
 #define GCS_CAP(x)	((((unsigned long)x) & GCS_CAP_ADDR_MASK) | \
 					       GCS_CAP_VALID_TOKEN)
 
-#define ARM64_FEATURE_FIELD_BITS	4
-
 #ifdef __ASSEMBLY__
 
 	.macro	mrs_s, rt, sreg
diff --git a/tools/testing/selftests/kvm/arm64/set_id_regs.c b/tools/testing/selftests/kvm/arm64/set_id_regs.c
index 5e24f77868b5..5fbcf5d1f168 100644
--- a/tools/testing/selftests/kvm/arm64/set_id_regs.c
+++ b/tools/testing/selftests/kvm/arm64/set_id_regs.c
@@ -268,7 +268,9 @@ static void guest_code(void)
 /* Return a safe value to a given ftr_bits an ftr value */
 uint64_t get_safe_value(const struct reg_ftr_bits *ftr_bits, uint64_t ftr)
 {
-	uint64_t ftr_max = GENMASK_ULL(ARM64_FEATURE_FIELD_BITS - 1, 0);
+	uint64_t ftr_max = ftr_bits->mask >> ftr_bits->shift;
+
+	TEST_ASSERT(ftr_max > 1, "This test doesn't support single bit features");
 
 	if (ftr_bits->sign == FTR_UNSIGNED) {
 		switch (ftr_bits->type) {
@@ -320,7 +322,9 @@ uint64_t get_safe_value(const struct reg_ftr_bits *ftr_bits, uint64_t ftr)
 /* Return an invalid value to a given ftr_bits an ftr value */
 uint64_t get_invalid_value(const struct reg_ftr_bits *ftr_bits, uint64_t ftr)
 {
-	uint64_t ftr_max = GENMASK_ULL(ARM64_FEATURE_FIELD_BITS - 1, 0);
+	uint64_t ftr_max = ftr_bits->mask >> ftr_bits->shift;
+
+	TEST_ASSERT(ftr_max > 1, "This test doesn't support single bit features");
 
 	if (ftr_bits->sign == FTR_UNSIGNED) {
 		switch (ftr_bits->type) {
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] KVM: arm64: selftests: Consider all 7 possible levels of cache
  2025-11-25 10:12 [PATCH v2 0/2] set_id_regs cleanup Ben Horgan
  2025-11-25 10:12 ` [PATCH v2 1/2] KVM: arm64: selftests: Remove ARM64_FEATURE_FIELD_BITS and its last user Ben Horgan
@ 2025-11-25 10:12 ` Ben Horgan
  2025-11-25 15:27 ` [PATCH v2 0/2] set_id_regs cleanup Marc Zyngier
  2025-11-27 19:16 ` Catalin Marinas
  3 siblings, 0 replies; 8+ messages in thread
From: Ben Horgan @ 2025-11-25 10:12 UTC (permalink / raw)
  To: catalin.marinas, will, maz, oliver.upton, joey.gouly,
	suzuki.poulose, yuzenghui, linux-arm-kernel, kvmarm, shuah
  Cc: Ben Horgan

In test_clidr() if an empty cache level is not found then the TEST_ASSERT
will not fire. Fix this by considering all 7 possible levels when iterating
through the hierarchy. Found by inspection.

Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
 tools/testing/selftests/kvm/arm64/set_id_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/arm64/set_id_regs.c b/tools/testing/selftests/kvm/arm64/set_id_regs.c
index 5fbcf5d1f168..c4815d365816 100644
--- a/tools/testing/selftests/kvm/arm64/set_id_regs.c
+++ b/tools/testing/selftests/kvm/arm64/set_id_regs.c
@@ -676,7 +676,7 @@ static void test_clidr(struct kvm_vcpu *vcpu)
 	clidr = vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_CLIDR_EL1));
 
 	/* find the first empty level in the cache hierarchy */
-	for (level = 1; level < 7; level++) {
+	for (level = 1; level <= 7; level++) {
 		if (!CLIDR_CTYPE(clidr, level))
 			break;
 	}
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] set_id_regs cleanup
  2025-11-25 10:12 [PATCH v2 0/2] set_id_regs cleanup Ben Horgan
  2025-11-25 10:12 ` [PATCH v2 1/2] KVM: arm64: selftests: Remove ARM64_FEATURE_FIELD_BITS and its last user Ben Horgan
  2025-11-25 10:12 ` [PATCH v2 2/2] KVM: arm64: selftests: Consider all 7 possible levels of cache Ben Horgan
@ 2025-11-25 15:27 ` Marc Zyngier
  2025-11-25 18:31   ` Catalin Marinas
  2025-11-27 19:16 ` Catalin Marinas
  3 siblings, 1 reply; 8+ messages in thread
From: Marc Zyngier @ 2025-11-25 15:27 UTC (permalink / raw)
  To: Ben Horgan
  Cc: catalin.marinas, will, oliver.upton, joey.gouly, suzuki.poulose,
	yuzenghui, linux-arm-kernel, kvmarm, shuah

On Tue, 25 Nov 2025 10:12:05 +0000,
Ben Horgan <ben.horgan@arm.com> wrote:
> 
> For this v2 I've dropped the ksft_test accounting fix. Mark Brown has
> more extensive changes [1] and looks to be a user of the set_id_regs
> test rather than someone just doing some cleanup. The other change in
> this series is to remove ARM64_FEATURE_FIELD_BITS from the tools
> sysreg.h header rather than the kernel version. I'll send a separate
> patch to remove the kernel version.
> 
> Tidies up a few small things in set_id_regs. The removal of
> ARM64_FEATURE_FIELD_BITS touches other code only so much as it removes
> the define but set_id_regs.c is the only place its used.

Acked-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] set_id_regs cleanup
  2025-11-25 15:27 ` [PATCH v2 0/2] set_id_regs cleanup Marc Zyngier
@ 2025-11-25 18:31   ` Catalin Marinas
  2025-11-25 19:45     ` Marc Zyngier
  0 siblings, 1 reply; 8+ messages in thread
From: Catalin Marinas @ 2025-11-25 18:31 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Ben Horgan, will, oliver.upton, joey.gouly, suzuki.poulose,
	yuzenghui, linux-arm-kernel, kvmarm, shuah

On Tue, Nov 25, 2025 at 03:27:48PM +0000, Marc Zyngier wrote:
> On Tue, 25 Nov 2025 10:12:05 +0000,
> Ben Horgan <ben.horgan@arm.com> wrote:
> > 
> > For this v2 I've dropped the ksft_test accounting fix. Mark Brown has
> > more extensive changes [1] and looks to be a user of the set_id_regs
> > test rather than someone just doing some cleanup. The other change in
> > this series is to remove ARM64_FEATURE_FIELD_BITS from the tools
> > sysreg.h header rather than the kernel version. I'll send a separate
> > patch to remove the kernel version.
> > 
> > Tidies up a few small things in set_id_regs. The removal of
> > ARM64_FEATURE_FIELD_BITS touches other code only so much as it removes
> > the define but set_id_regs.c is the only place its used.
> 
> Acked-by: Marc Zyngier <maz@kernel.org>

Thanks Marc. Shall I take these through the arm64 tree, together with
the removal of the macro? They should have probably been a single
series.

-- 
Catalin


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] set_id_regs cleanup
  2025-11-25 18:31   ` Catalin Marinas
@ 2025-11-25 19:45     ` Marc Zyngier
  2025-11-25 21:28       ` Oliver Upton
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Zyngier @ 2025-11-25 19:45 UTC (permalink / raw)
  To: Catalin Marinas, Oliver Upton
  Cc: Ben Horgan, will, joey.gouly, suzuki.poulose, yuzenghui,
	linux-arm-kernel, kvmarm, shuah

On Tue, 25 Nov 2025 18:31:37 +0000,
Catalin Marinas <catalin.marinas@arm.com> wrote:
> 
> On Tue, Nov 25, 2025 at 03:27:48PM +0000, Marc Zyngier wrote:
> > On Tue, 25 Nov 2025 10:12:05 +0000,
> > Ben Horgan <ben.horgan@arm.com> wrote:
> > > 
> > > For this v2 I've dropped the ksft_test accounting fix. Mark Brown has
> > > more extensive changes [1] and looks to be a user of the set_id_regs
> > > test rather than someone just doing some cleanup. The other change in
> > > this series is to remove ARM64_FEATURE_FIELD_BITS from the tools
> > > sysreg.h header rather than the kernel version. I'll send a separate
> > > patch to remove the kernel version.
> > > 
> > > Tidies up a few small things in set_id_regs. The removal of
> > > ARM64_FEATURE_FIELD_BITS touches other code only so much as it removes
> > > the define but set_id_regs.c is the only place its used.
> > 
> > Acked-by: Marc Zyngier <maz@kernel.org>
> 
> Thanks Marc. Shall I take these through the arm64 tree, together with
> the removal of the macro? They should have probably been a single
> series.

Oliver is in charge of the merge window this time around, so I'll
defer to him, but that's absolutely fine from my PoV.

Thanks,

	M.

-- 
Jazz isn't dead. It just smells funny.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] set_id_regs cleanup
  2025-11-25 19:45     ` Marc Zyngier
@ 2025-11-25 21:28       ` Oliver Upton
  0 siblings, 0 replies; 8+ messages in thread
From: Oliver Upton @ 2025-11-25 21:28 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Catalin Marinas, Ben Horgan, will, joey.gouly, suzuki.poulose,
	yuzenghui, linux-arm-kernel, kvmarm, shuah

On Tue, Nov 25, 2025 at 07:45:22PM +0000, Marc Zyngier wrote:
> On Tue, 25 Nov 2025 18:31:37 +0000,
> Catalin Marinas <catalin.marinas@arm.com> wrote:
> > 
> > On Tue, Nov 25, 2025 at 03:27:48PM +0000, Marc Zyngier wrote:
> > > On Tue, 25 Nov 2025 10:12:05 +0000,
> > > Ben Horgan <ben.horgan@arm.com> wrote:
> > > > 
> > > > For this v2 I've dropped the ksft_test accounting fix. Mark Brown has
> > > > more extensive changes [1] and looks to be a user of the set_id_regs
> > > > test rather than someone just doing some cleanup. The other change in
> > > > this series is to remove ARM64_FEATURE_FIELD_BITS from the tools
> > > > sysreg.h header rather than the kernel version. I'll send a separate
> > > > patch to remove the kernel version.
> > > > 
> > > > Tidies up a few small things in set_id_regs. The removal of
> > > > ARM64_FEATURE_FIELD_BITS touches other code only so much as it removes
> > > > the define but set_id_regs.c is the only place its used.
> > > 
> > > Acked-by: Marc Zyngier <maz@kernel.org>
> > 
> > Thanks Marc. Shall I take these through the arm64 tree, together with
> > the removal of the macro? They should have probably been a single
> > series.
> 
> Oliver is in charge of the merge window this time around, so I'll
> defer to him, but that's absolutely fine from my PoV.

Catalin, please go ahead and apply. I don't believe I have anything that
will conflict.

Acked-by: Oliver Upton <oupton@kernel.org>

Thanks,
Oliver


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] set_id_regs cleanup
  2025-11-25 10:12 [PATCH v2 0/2] set_id_regs cleanup Ben Horgan
                   ` (2 preceding siblings ...)
  2025-11-25 15:27 ` [PATCH v2 0/2] set_id_regs cleanup Marc Zyngier
@ 2025-11-27 19:16 ` Catalin Marinas
  3 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2025-11-27 19:16 UTC (permalink / raw)
  To: will, maz, joey.gouly, suzuki.poulose, yuzenghui,
	linux-arm-kernel, kvmarm, shuah, Oliver Upton, Ben Horgan

On Tue, 25 Nov 2025 10:12:05 +0000, Ben Horgan wrote:
> For this v2 I've dropped the ksft_test accounting fix. Mark Brown has
> more extensive changes [1] and looks to be a user of the set_id_regs
> test rather than someone just doing some cleanup. The other change in
> this series is to remove ARM64_FEATURE_FIELD_BITS from the tools
> sysreg.h header rather than the kernel version. I'll send a separate
> patch to remove the kernel version.
> 
> [...]

Applied to arm64 (for-next/sysreg), thanks!

[1/2] KVM: arm64: selftests: Remove ARM64_FEATURE_FIELD_BITS and its last user
      https://git.kernel.org/arm64/c/bf09ee918053
[2/2] KVM: arm64: selftests: Consider all 7 possible levels of cache
      https://git.kernel.org/arm64/c/4138cc63d3ef

-- 
Catalin


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-11-27 19:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-25 10:12 [PATCH v2 0/2] set_id_regs cleanup Ben Horgan
2025-11-25 10:12 ` [PATCH v2 1/2] KVM: arm64: selftests: Remove ARM64_FEATURE_FIELD_BITS and its last user Ben Horgan
2025-11-25 10:12 ` [PATCH v2 2/2] KVM: arm64: selftests: Consider all 7 possible levels of cache Ben Horgan
2025-11-25 15:27 ` [PATCH v2 0/2] set_id_regs cleanup Marc Zyngier
2025-11-25 18:31   ` Catalin Marinas
2025-11-25 19:45     ` Marc Zyngier
2025-11-25 21:28       ` Oliver Upton
2025-11-27 19:16 ` Catalin Marinas

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).