|
| 1 | +/****************************************************************************/ |
| 2 | +/* the diy toolsuite */ |
| 3 | +/* */ |
| 4 | +/* Jade Alglave, University College London, UK. */ |
| 5 | +/* Luc Maranget, INRIA Paris-Rocquencourt, France. */ |
| 6 | +/* */ |
| 7 | +/* Copyright 2026-present Institut National de Recherche en Informatique et */ |
| 8 | +/* en Automatique and the authors. All rights reserved. */ |
| 9 | +/* */ |
| 10 | +/* This software is governed by the CeCILL-B license under French law and */ |
| 11 | +/* abiding by the rules of distribution of free software. You can use, */ |
| 12 | +/* modify and/ or redistribute the software under the terms of the CeCILL-B */ |
| 13 | +/* license as circulated by CEA, CNRS and INRIA at the following URL */ |
| 14 | +/* "http://www.cecill.info". We also give a copy in LICENSE.txt. */ |
| 15 | +/****************************************************************************/ |
| 16 | +#include "kvm-headers.h" |
| 17 | +#include "exs.h" |
| 18 | + |
| 19 | +#define MMFR0_EXS_SHIFT 44 |
| 20 | +#define MMFR0_EXS_MASK 0xf |
| 21 | + |
| 22 | +int check_exs(const char *tname) { |
| 23 | + uint64_t mmfr0; |
| 24 | + asm volatile("mrs %0, ID_AA64MMFR0_EL1" : "=r" (mmfr0)); |
| 25 | + int exs = (mmfr0 >> MMFR0_EXS_SHIFT) & MMFR0_EXS_MASK; |
| 26 | + if (exs == 0) { |
| 27 | + printf("Test %s, ExS not supported on this system\n", tname); |
| 28 | + return 0; |
| 29 | + } |
| 30 | + return 1; |
| 31 | +} |
| 32 | + |
| 33 | +void init_exs(int eis_val, int eos_val) { |
| 34 | + uint64_t sctlr; |
| 35 | + asm volatile("mrs %0, SCTLR_EL1" : "=r" (sctlr)); |
| 36 | + sctlr = eis_val ? (sctlr | SCTLR_EL1_EIS) : (sctlr & ~SCTLR_EL1_EIS); |
| 37 | + sctlr = eos_val ? (sctlr | SCTLR_EL1_EOS) : (sctlr & ~SCTLR_EL1_EOS); |
| 38 | + asm volatile("msr SCTLR_EL1, %0" :: "r" (sctlr)); |
| 39 | + asm volatile("isb"); |
| 40 | +} |
0 commit comments