@@ -26,6 +26,8 @@
#define HCR_EL2_TGE (1 << 27)
#define HCR_EL2_E2H_SHIFT 34
#define HCR_EL2_E2H (UL(1) << 34)
+#define HCR_EL2_IMO (1 << 4)
+#define HCR_EL2_FMO (1 << 3)
#define SCTLR_EL2_RES1 (3 << 28 | 3 << 22 | 1 << 18 | \
1 << 16 | 1 << 11 | 3 << 4)
@@ -464,19 +464,34 @@ static void test_hptimer(void)
report_prefix_pop();
}
-static void test_init(void)
+static void test_init(bool without_vhe)
{
const struct fdt_property *prop;
const void *fdt = dt_fdt();
+ u64 hcr;
int node, len;
u32 *data;
+ if (without_vhe) {
+ disable_vhe();
+ hcr = read_sysreg(hcr_el2);
+ /* KVM doesn't support different IMO/FMO settings */
+ hcr |= HCR_EL2_IMO | HCR_EL2_FMO;
+ write_sysreg(hcr, hcr_el2);
+ isb();
+ }
+
if (current_el == CurrentEL_EL1) {
vtimer = &vtimer_info;
ptimer = &ptimer_info;
} else {
- vtimer = &vtimer_info_vhe;
- ptimer = &ptimer_info_vhe;
+ if (without_vhe) {
+ vtimer = &vtimer_info;
+ ptimer = &ptimer_info;
+ } else {
+ vtimer = &vtimer_info_vhe;
+ ptimer = &ptimer_info_vhe;
+ }
hvtimer = &hvtimer_info;
hptimer = &hptimer_info;
}
@@ -563,10 +578,20 @@ static void print_timer_info(void)
int main(int argc, char **argv)
{
int i;
+ bool without_vhe = false;
current_el = current_level();
- test_init();
+ if (argc > 1 && strcmp(argv[1], "nvhe") == 0) {
+ if (current_el == CurrentEL_EL1)
+ report_info("Skipping EL2 tests. Boot at EL2 to enable.");
+ else
+ without_vhe = true;
+ argv = &argv[1];
+ argc--;
+ }
+
+ test_init(without_vhe);
print_timer_info();
Disable VHE if first command line parameter is "nvhe" and then test the timers. Just like with VHE enabled, if no other parameter is given, all four timers are tested; otherwise, only the timers specified by the user. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> --- lib/arm64/asm/processor.h | 2 ++ arm/timer.c | 33 +++++++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-)