Skip to content

Commit 0ace6bd

Browse files
jones-drewavpatel
authored andcommitted
KVM: arm64: selftests: Delete core_reg_fixup
core_reg_fixup() complicates sharing the get-reg-list test with other architectures. Rather than work at keeping it, with plenty of #ifdeffery, just delete it, as it's unlikely to test a kernel based on anything older than v5.2 with the get-reg-list test, which is a test meant to check for regressions in new kernels. (And, an older version of the test can still be used for older kernels if necessary.) Signed-off-by: Andrew Jones <[email protected]> Signed-off-by: Haibo Xu <[email protected]> Signed-off-by: Anup Patel <[email protected]>
1 parent 9177b71 commit 0ace6bd

File tree

1 file changed

+10
-73
lines changed

1 file changed

+10
-73
lines changed

tools/testing/selftests/kvm/aarch64/get-reg-list.c

Lines changed: 10 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@
1717
* by running the test with the --list command line argument.
1818
*
1919
* Note, the blessed list should be created from the oldest possible
20-
* kernel. We can't go older than v4.15, though, because that's the first
21-
* release to expose the ID system registers in KVM_GET_REG_LIST, see
22-
* commit 93390c0a1b20 ("arm64: KVM: Hide unsupported AArch64 CPU features
23-
* from guests"). Also, one must use the --core-reg-fixup command line
24-
* option when running on an older kernel that doesn't include df205b5c6328
25-
* ("KVM: arm64: Filter out invalid core register IDs in KVM_GET_REG_LIST")
20+
* kernel. We can't go older than v5.2, though, because that's the first
21+
* release which includes df205b5c6328 ("KVM: arm64: Filter out invalid
22+
* core register IDs in KVM_GET_REG_LIST"). Without that commit the core
23+
* registers won't match expectations.
2624
*/
2725
#include <stdio.h>
2826
#include <stdlib.h>
@@ -317,63 +315,6 @@ static void print_reg(const char *prefix, __u64 id)
317315
}
318316
}
319317

320-
/*
321-
* Older kernels listed each 32-bit word of CORE registers separately.
322-
* For 64 and 128-bit registers we need to ignore the extra words. We
323-
* also need to fixup the sizes, because the older kernels stated all
324-
* registers were 64-bit, even when they weren't.
325-
*/
326-
static void core_reg_fixup(void)
327-
{
328-
struct kvm_reg_list *tmp;
329-
__u64 id, core_off;
330-
int i;
331-
332-
tmp = calloc(1, sizeof(*tmp) + reg_list->n * sizeof(__u64));
333-
334-
for (i = 0; i < reg_list->n; ++i) {
335-
id = reg_list->reg[i];
336-
337-
if ((id & KVM_REG_ARM_COPROC_MASK) != KVM_REG_ARM_CORE) {
338-
tmp->reg[tmp->n++] = id;
339-
continue;
340-
}
341-
342-
core_off = id & ~REG_MASK;
343-
344-
switch (core_off) {
345-
case 0x52: case 0xd2: case 0xd6:
346-
/*
347-
* These offsets are pointing at padding.
348-
* We need to ignore them too.
349-
*/
350-
continue;
351-
case KVM_REG_ARM_CORE_REG(fp_regs.vregs[0]) ...
352-
KVM_REG_ARM_CORE_REG(fp_regs.vregs[31]):
353-
if (core_off & 3)
354-
continue;
355-
id &= ~KVM_REG_SIZE_MASK;
356-
id |= KVM_REG_SIZE_U128;
357-
tmp->reg[tmp->n++] = id;
358-
continue;
359-
case KVM_REG_ARM_CORE_REG(fp_regs.fpsr):
360-
case KVM_REG_ARM_CORE_REG(fp_regs.fpcr):
361-
id &= ~KVM_REG_SIZE_MASK;
362-
id |= KVM_REG_SIZE_U32;
363-
tmp->reg[tmp->n++] = id;
364-
continue;
365-
default:
366-
if (core_off & 1)
367-
continue;
368-
tmp->reg[tmp->n++] = id;
369-
break;
370-
}
371-
}
372-
373-
free(reg_list);
374-
reg_list = tmp;
375-
}
376-
377318
static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init)
378319
{
379320
struct vcpu_reg_sublist *s;
@@ -412,7 +353,6 @@ static void check_supported(struct vcpu_reg_list *c)
412353

413354
static bool print_list;
414355
static bool print_filtered;
415-
static bool fixup_core_regs;
416356

417357
static void run_test(struct vcpu_reg_list *c)
418358
{
@@ -433,9 +373,6 @@ static void run_test(struct vcpu_reg_list *c)
433373

434374
reg_list = vcpu_get_reg_list(vcpu);
435375

436-
if (fixup_core_regs)
437-
core_reg_fixup();
438-
439376
if (print_list || print_filtered) {
440377
putchar('\n');
441378
for_each_reg(i) {
@@ -563,7 +500,7 @@ static void help(void)
563500

564501
printf(
565502
"\n"
566-
"usage: get-reg-list [--config=<selection>] [--list] [--list-filtered] [--core-reg-fixup]\n\n"
503+
"usage: get-reg-list [--config=<selection>] [--list] [--list-filtered]\n\n"
567504
" --config=<selection> Used to select a specific vcpu configuration for the test/listing\n"
568505
" '<selection>' may be\n");
569506

@@ -577,7 +514,6 @@ static void help(void)
577514
"\n"
578515
" --list Print the register list rather than test it (requires --config)\n"
579516
" --list-filtered Print registers that would normally be filtered out (requires --config)\n"
580-
" --core-reg-fixup Needed when running on old kernels with broken core reg listings\n"
581517
"\n"
582518
);
583519
}
@@ -609,9 +545,7 @@ int main(int ac, char **av)
609545
pid_t pid;
610546

611547
for (i = 1; i < ac; ++i) {
612-
if (strcmp(av[i], "--core-reg-fixup") == 0)
613-
fixup_core_regs = true;
614-
else if (strncmp(av[i], "--config", 8) == 0)
548+
if (strncmp(av[i], "--config", 8) == 0)
615549
sel = parse_config(av[i]);
616550
else if (strcmp(av[i], "--list") == 0)
617551
print_list = true;
@@ -654,8 +588,11 @@ int main(int ac, char **av)
654588
}
655589

656590
/*
657-
* The current blessed list was primed with the output of kernel version
591+
* The original blessed list was primed with the output of kernel version
658592
* v4.15 with --core-reg-fixup and then later updated with new registers.
593+
* (The --core-reg-fixup option and it's fixup function have been removed
594+
* from the test, as it's unlikely to use this type of test on a kernel
595+
* older than v5.2.)
659596
*
660597
* The blessed list is up to date with kernel version v6.4 (or so we hope)
661598
*/

0 commit comments

Comments
 (0)