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.

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:
- call smc // to enter monitor mode
- set SRC.HCE to 1 // to enable the hvc instruction
- set SRC.NS to 1 // so that the system is not protected
- call hvc # 0 // call the hvc instruction to create a hypervisor exception
c arm virtualization hypervisor openwrt
Coder
source share