|
25 | 25 |
|
26 | 26 | #define LITMUS_PAGE_SIZE PAGE_SIZE |
27 | 27 |
|
| 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 | + |
28 | 61 | static inline pteval_t *litmus_tr_pte(void *p) { |
29 | 62 | return follow_pte(mmu_idmap, (uintptr_t)p); |
30 | 63 | } |
|
0 commit comments