I am following an online tutorial on how to enable VMX operations on x86 architecture. The tutorial has broken the procedure into steps and has posted the code assembled from all the parts into a kernel module. It has also provided a Makefile to compile it. Both of them can be viewed here. While compiling it I am getting the following error:
make -C /lib/modules/4.4.0-81-generic/build M=/home/sbhtwr/Desktop/hypervisor modules EXTRA_CFLAGS="-g -DDEBUG" make: Entering directory '/usr/src/linux-headers-4.4.0-81-generic' CC [M] /home/sbhtwr/Desktop/hypervisor/vmx.o /home/sbhtwr/Desktop/hypervisor/vmx.c: In function ‘__rdmsr1’: /home/sbhtwr/Desktop/hypervisor/vmx.c:82:8: error: expected ‘:’ or ‘)’ before ‘_ASM_EXTABLE_HANDLE’ _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_unsafe) ^ /home/sbhtwr/Desktop/hypervisor/vmx.c:82:28: error: invalid suffix "b" on integer constant _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_unsafe) ^ /home/sbhtwr/Desktop/hypervisor/vmx.c:82:32: error: invalid suffix "b" on integer constant _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_unsafe) ^ scripts/Makefile.build:264: recipe for target '/home/sbhtwr/Desktop/hypervisor/vmx.o' failed make: *** [/home/sbhtwr/Desktop/hypervisor/vmx.o] Error 1 Makefile:1420: recipe for target '_module_/home/sbhtwr/Desktop/hypervisor' failed make: *** [_module_/home/sbhtwr/Desktop/hypervisor] Error 2 make: Leaving directory '/usr/src/linux-headers-4.4.0-81-generic' Makefile:6: recipe for target 'modules' failed make: *** [modules] Error 2
I am unable to resolve the error. I feel that some definitions are missing from my copy of linux headers (Although compiler does not explicitly state that as the reason!). I maybe wrong though. Please see NOTE below.
I tried to search the header files on linux repository online for the definition of
_ASM_EXTABLE_HANDLE and found it here. I then tried to find
asm.h in my local copy of linux headers and found that the definition was missing. So I copy pasted the definition into the module and re-compiled it. There were no errors this time, but a warning:
WARNING: "ex_handler_rdmsr_unsafe" [/home/sbhtwr/Desktop/hypervisor/vmx.ko] undefined!
I found the definition of
ex_handler_rdmsr_unsafe here. So I copy pasted the definition of the function into the module, which lead to some more errors indicating missing definitions of functions (which are used in
The tutorial page can be found here.