This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Enter Hypervisor Mode on ARMv7 through Kernel Module

I am trying to write a kernel module in C to bring the system in the hypervisor mode. The module is for a router, which is running OpenWrt. The architecture is ARMv7.

When I load my module with insmod I get this error when the module comes to the hvc #0 instruction:

Internal Error: Oops - undefined instruction: 0 [#1] SMP ARM

I am new to ARM and virtualization but so far I have understood that I have to do the following things before calling hvc #0

  1. I have to be in PL1(SVC) mode. Is this given when I load a kernel module instead of a normal C Program?

  2. I have to set the SCR.NS bit to 1.

  3. I have to set the SCR.HCE bit to 1.

I have not understood how to set these bits. I have read that the CPU needs to be in monitor mode for setting these bits, is this true? And how can I do this?

Can someone give me please an example in C or assembly how to prepare the system that I can execute hvc #0.