Skip to content

Commit ee053e0

Browse files
jgoulyctmarinas
authored andcommitted
KVM: selftests: get-reg-list: support ID register features
This stops the test complaining about missing registers, when running on an older kernel that does not support newer features. Signed-off-by: Joey Gouly <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Oliver Upton <[email protected]> Cc: Mark Brown <[email protected]> Cc: Shuah Khan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 6c792b7 commit ee053e0

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ struct reg_sublist {
4848
__u64 rejects_set_n;
4949
};
5050

51+
struct feature_id_reg {
52+
__u64 reg;
53+
__u64 id_reg;
54+
__u64 feat_shift;
55+
__u64 feat_min;
56+
};
57+
58+
static struct feature_id_reg feat_id_regs[] = {
59+
};
60+
5161
struct vcpu_config {
5262
char *name;
5363
struct reg_sublist sublists[];
@@ -68,7 +78,8 @@ static int vcpu_configs_n;
6878

6979
#define for_each_missing_reg(i) \
7080
for ((i) = 0; (i) < blessed_n; ++(i)) \
71-
if (!find_reg(reg_list->reg, reg_list->n, blessed_reg[i]))
81+
if (!find_reg(reg_list->reg, reg_list->n, blessed_reg[i])) \
82+
if (check_supported_feat_reg(vcpu, blessed_reg[i]))
7283

7384
#define for_each_new_reg(i) \
7485
for_each_reg_filtered(i) \
@@ -132,6 +143,25 @@ static bool find_reg(__u64 regs[], __u64 nr_regs, __u64 reg)
132143
return false;
133144
}
134145

146+
static bool check_supported_feat_reg(struct kvm_vcpu *vcpu, __u64 reg)
147+
{
148+
int i, ret;
149+
__u64 data, feat_val;
150+
151+
for (i = 0; i < ARRAY_SIZE(feat_id_regs); i++) {
152+
if (feat_id_regs[i].reg == reg) {
153+
ret = __vcpu_get_reg(vcpu, feat_id_regs[i].id_reg, &data);
154+
if (ret < 0)
155+
return false;
156+
157+
feat_val = ((data >> feat_id_regs[i].feat_shift) & 0xf);
158+
return feat_val >= feat_id_regs[i].feat_min;
159+
}
160+
}
161+
162+
return true;
163+
}
164+
135165
static const char *str_with_index(const char *template, __u64 index)
136166
{
137167
char *str, *p;

0 commit comments

Comments
 (0)