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[1]: 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[2]: *** [/home/sbhtwr/Desktop/hypervisor/vmx.o] Error 1
Makefile:1420: recipe for target '_module_/home/sbhtwr/Desktop/hypervisor' failed
make[1]: *** [_module_/home/sbhtwr/Desktop/hypervisor] Error 2
make[1]: 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.

NOTE: 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 ex_handler_rdmsr_unsafe).

The tutorial page can be found here.


It seems that the definitions for _ASM_EXTABLE_HANDLE and ex_handler_rdmsr_unsafe are included in the linux headers 4.15.0-72-generic. Previously I was running Ubuntu 16.04 LTS with linux headers 4.4.0-81-generic. Upgrading to Ubuntu 18.04 LTS (which also upgraded the linux headers to 4.15.0-72-generic) fixed the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.