Skip to content

Commit 9a40718

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: selftests: get-reg-list: Simplify feature dependency
Describing the dependencies between registers and features is on the masochistic side of things, with hard-coded values that would be better taken from the existing description. Add a couple of helpers to that effect, and repaint the dependency array. More could be done to improve this test, but my interest is wearing thin... Signed-off-by: Marc Zyngier <[email protected]> Tested-by: Itaru Kitayama <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent a0aae0a commit 9a40718

File tree

1 file changed

+22
-30
lines changed

1 file changed

+22
-30
lines changed

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

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,36 @@
1515
#include "test_util.h"
1616
#include "processor.h"
1717

18+
#define SYS_REG(r) ARM64_SYS_REG(sys_reg_Op0(SYS_ ## r), \
19+
sys_reg_Op1(SYS_ ## r), \
20+
sys_reg_CRn(SYS_ ## r), \
21+
sys_reg_CRm(SYS_ ## r), \
22+
sys_reg_Op2(SYS_ ## r))
23+
1824
struct feature_id_reg {
1925
__u64 reg;
2026
__u64 id_reg;
2127
__u64 feat_shift;
2228
__u64 feat_min;
2329
};
2430

25-
static struct feature_id_reg feat_id_regs[] = {
26-
{
27-
ARM64_SYS_REG(3, 0, 2, 0, 3), /* TCR2_EL1 */
28-
ARM64_SYS_REG(3, 0, 0, 7, 3), /* ID_AA64MMFR3_EL1 */
29-
0,
30-
1
31-
},
32-
{
33-
ARM64_SYS_REG(3, 0, 10, 2, 2), /* PIRE0_EL1 */
34-
ARM64_SYS_REG(3, 0, 0, 7, 3), /* ID_AA64MMFR3_EL1 */
35-
8,
36-
1
37-
},
38-
{
39-
ARM64_SYS_REG(3, 0, 10, 2, 3), /* PIR_EL1 */
40-
ARM64_SYS_REG(3, 0, 0, 7, 3), /* ID_AA64MMFR3_EL1 */
41-
8,
42-
1
43-
},
44-
{
45-
ARM64_SYS_REG(3, 0, 10, 2, 4), /* POR_EL1 */
46-
ARM64_SYS_REG(3, 0, 0, 7, 3), /* ID_AA64MMFR3_EL1 */
47-
16,
48-
1
49-
},
50-
{
51-
ARM64_SYS_REG(3, 3, 10, 2, 4), /* POR_EL0 */
52-
ARM64_SYS_REG(3, 0, 0, 7, 3), /* ID_AA64MMFR3_EL1 */
53-
16,
54-
1
31+
#define FEAT(id, f, v) \
32+
.id_reg = SYS_REG(id), \
33+
.feat_shift = id ## _ ## f ## _SHIFT, \
34+
.feat_min = id ## _ ## f ## _ ## v
35+
36+
#define REG_FEAT(r, id, f, v) \
37+
{ \
38+
.reg = SYS_REG(r), \
39+
FEAT(id, f, v) \
5540
}
41+
42+
static struct feature_id_reg feat_id_regs[] = {
43+
REG_FEAT(TCR2_EL1, ID_AA64MMFR3_EL1, TCRX, IMP),
44+
REG_FEAT(PIRE0_EL1, ID_AA64MMFR3_EL1, S1PIE, IMP),
45+
REG_FEAT(PIR_EL1, ID_AA64MMFR3_EL1, S1PIE, IMP),
46+
REG_FEAT(POR_EL1, ID_AA64MMFR3_EL1, S1POE, IMP),
47+
REG_FEAT(POR_EL0, ID_AA64MMFR3_EL1, S1POE, IMP),
5648
};
5749

5850
bool filter_reg(__u64 reg)

0 commit comments

Comments
 (0)