Skip to content

Commit 7609707

Browse files
committed
[litmus] Introduce variant checks for exs, eis and eos
1 parent b5d0af4 commit 7609707

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

litmus/libdir/_aarch64/kvm-headers.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,39 @@
2525

2626
#define LITMUS_PAGE_SIZE PAGE_SIZE
2727

28+
static inline int check_exs(const char *tname, int need_exs, int need_eis, int need_eos) {
29+
uint64_t mmfr0;
30+
asm volatile("mrs %0, ID_AA64MMFR0_EL1" : "=r" (mmfr0));
31+
int exs = (mmfr0 >> 44) & 0xf;
32+
if (need_exs && exs == 0) {
33+
printf("Test %s, ExS not supported on this system\n", tname);
34+
return 0;
35+
}
36+
37+
uint64_t sctlr;
38+
asm volatile("mrs %0, SCTLR_EL1" : "=r" (sctlr));
39+
int eis = (sctlr >> 22) & 1;
40+
int eos = (sctlr >> 11) & 1;
41+
if (eis != need_eis || eos != need_eos) {
42+
uint64_t new_sctlr = sctlr;
43+
if (need_eis) new_sctlr |= 1ULL << 22;
44+
else new_sctlr &= ~(1ULL << 22);
45+
if (need_eos) new_sctlr |= 1ULL << 11;
46+
else new_sctlr &= ~(1ULL << 11);
47+
asm volatile("msr SCTLR_EL1, %0" :: "r" (new_sctlr));
48+
asm volatile("isb");
49+
asm volatile("mrs %0, SCTLR_EL1" : "=r" (sctlr));
50+
eis = (sctlr >> 22) & 1;
51+
eos = (sctlr >> 11) & 1;
52+
if (eis != need_eis || eos != need_eos) {
53+
printf("Test %s, cannot set ExS settings EIS=%d EOS=%d\n",
54+
tname, need_eis, need_eos);
55+
return 0;
56+
}
57+
}
58+
return 1;
59+
}
60+
2861
static inline pteval_t *litmus_tr_pte(void *p) {
2962
return follow_pte(mmu_idmap, (uintptr_t)p);
3063
}

litmus/preSi.ml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ module Make
8080
if Cfg.variant Variant_litmus.ConstPacField && not (Cfg.variant Variant_litmus.Pac) then
8181
Warn.user_error "\"const-pac-field\" variant require \"pac\" variant"
8282

83+
let () =
84+
if (Cfg.variant Variant_litmus.EIS || Cfg.variant Variant_litmus.EOS)
85+
&& not (Cfg.variant Variant_litmus.ExS) then
86+
Warn.user_error "\"eis\"/\"eos\" variants require \"exs\" variant"
87+
8388
module Insert =
8489
ObjUtil.Insert
8590
(struct
@@ -2329,6 +2334,15 @@ module Make
23292334
end ;
23302335
if Cfg.variant Variant_litmus.ConstPacField then
23312336
O.fi "if (!check_const_pac_field_variant(%S)) return 0;" doc.Name.name;
2337+
if Cfg.is_kvm &&
2338+
(Cfg.variant Variant_litmus.ExS ||
2339+
Cfg.variant Variant_litmus.EIS ||
2340+
Cfg.variant Variant_litmus.EOS) then
2341+
O.fi "if (!check_exs(%S,%d,%d,%d)) return 0;"
2342+
doc.Name.name
2343+
(if Cfg.variant Variant_litmus.ExS then 1 else 0)
2344+
(if Cfg.variant Variant_litmus.EIS then 1 else 0)
2345+
(if Cfg.variant Variant_litmus.EOS then 1 else 0) ;
23322346
if Cfg.is_kvm then begin
23332347
match db with
23342348
| None ->

0 commit comments

Comments
 (0)