Skip to content

Commit bf09ee9

Browse files
benhor01ctmarinas
authored andcommitted
KVM: arm64: selftests: Remove ARM64_FEATURE_FIELD_BITS and its last user
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> Acked-by: Marc Zyngier <maz@kernel.org> Acked-by: Oliver Upton <oupton@kernel.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent a04fbfb commit bf09ee9

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

tools/arch/arm64/include/asm/sysreg.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,8 +1078,6 @@
10781078
#define GCS_CAP(x) ((((unsigned long)x) & GCS_CAP_ADDR_MASK) | \
10791079
GCS_CAP_VALID_TOKEN)
10801080

1081-
#define ARM64_FEATURE_FIELD_BITS 4
1082-
10831081
#ifdef __ASSEMBLY__
10841082

10851083
.macro mrs_s, rt, sreg

tools/testing/selftests/kvm/arm64/set_id_regs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ static void guest_code(void)
265265
/* Return a safe value to a given ftr_bits an ftr value */
266266
uint64_t get_safe_value(const struct reg_ftr_bits *ftr_bits, uint64_t ftr)
267267
{
268-
uint64_t ftr_max = GENMASK_ULL(ARM64_FEATURE_FIELD_BITS - 1, 0);
268+
uint64_t ftr_max = ftr_bits->mask >> ftr_bits->shift;
269+
270+
TEST_ASSERT(ftr_max > 1, "This test doesn't support single bit features");
269271

270272
if (ftr_bits->sign == FTR_UNSIGNED) {
271273
switch (ftr_bits->type) {
@@ -317,7 +319,9 @@ uint64_t get_safe_value(const struct reg_ftr_bits *ftr_bits, uint64_t ftr)
317319
/* Return an invalid value to a given ftr_bits an ftr value */
318320
uint64_t get_invalid_value(const struct reg_ftr_bits *ftr_bits, uint64_t ftr)
319321
{
320-
uint64_t ftr_max = GENMASK_ULL(ARM64_FEATURE_FIELD_BITS - 1, 0);
322+
uint64_t ftr_max = ftr_bits->mask >> ftr_bits->shift;
323+
324+
TEST_ASSERT(ftr_max > 1, "This test doesn't support single bit features");
321325

322326
if (ftr_bits->sign == FTR_UNSIGNED) {
323327
switch (ftr_bits->type) {

0 commit comments

Comments
 (0)