Enter hypervisor mode on ARMv7 through the kernel module

I am working on a project where I have a router with an ARMv7 processor (Cortex A15) and an OpenWRT OS. I have a shell on the router, and I can load kernel modules using insmod .

My goal is to write a kernel module in C that changes the HVBAR register and then executes the hvc instruction to put the processor into hyp mode. This is a scientific project in which I want to check if I can install my own hypervisor on a working system. But before I start writing my own hypervisor, I want to check if it is possible and how to put the processor into Hyper mode.

In accordance with this figure, taken from armv7-a, manual B.9.3.4, the system should be in unsafe mode, not user mode, and the SCR.HCE bit should be set to 1.

enter image description here

My question is how to prepare a processor with a C core module and built-in assembly, and then execute the hvc instruction. I want to do this with the kernel module, because then I start in PL1. This pseudo code describes what I want to achieve:

  1. call smc // to enter monitor mode
  2. set SRC.HCE to 1 // to enable the hvc instruction
  3. set SRC.NS to 1 // so that the system is not protected
  4. call hvc # 0 // call the hvc instruction to create a hypervisor exception
+9
c arm virtualization hypervisor openwrt
source share

No one has answered this question yet.

See similar questions:

2
TrustZone and IFAR, IFSR, DFAR, DFSR monitoring mode

or similar:

7
Measure runtime on ARM Cortex-A8 using hardware counter
4
A simple way to determine the current processor mode on ARMv7-A
3
Interchangeability of compiled LKMs
2
ARM Cortex A7 returns PMCCNTR = 0 in kernel mode and illegal instruction in user mode (even after PMUSERENR = 1)
2
Problems with ARMv7-A bare metal call bar
one
The easiest way to access secure (TrustZone) instructions from a privileged context on the Cortex A8 / DM3730
one
Are there type 2 hypervisors like VirtualBox using shadow page tables for guests?
0
How to enter DOZE and SLEEP mode on iMX27 (ARM926)?
0
How to set default ARM processor state for kernel code?
0
how to switch back to svc mode from hyp mode using ELR_Hyp in armv7

All Articles