linux KVM error_code due to EPT violation VM-exit
Posted: Tue May 20, 2025 3:08 am
I would dig into some details on Linux kvm implementation for Intel Vt-x technology.
As you can see here https://github.com/torvalds/linux/blob/ ... mx.c#L5810, it defines the callback function "static int handle_ept_violation (struct kvm_vcpu *vcpu)" to handle VM-exits due to EPT violations.
I'm not expert, so I'm in trouble to fully understand the meaning of those error_code values.
For instance on my QEMU/kvm VM running on Linux 6.7.5 host with EPT enabled, I can see the following trace events:
here you can see some VM-exits for EPT violation with error_code 0x181, 0x182.
What do such error_codes actually refer to ? Thanks.
As you can see here https://github.com/torvalds/linux/blob/ ... mx.c#L5810, it defines the callback function "static int handle_ept_violation (struct kvm_vcpu *vcpu)" to handle VM-exits due to EPT violations.
I'm not expert, so I'm in trouble to fully understand the meaning of those error_code values.
For instance on my QEMU/kvm VM running on Linux 6.7.5 host with EPT enabled, I can see the following trace events:
Code: Select all
root@eve-ng62:~# trace-cmd record -e kvm_page_fault -P 1060614
Hit Ctrl^C to stop recording
<snip...>
root@eve-ng62:~# trace-cmd report
CPU 0 is empty
<snip...>
CPU 47 is empty
cpus=48
qemu-system-x86-1060614 [036] 2316032.840657: kvm_page_fault: vcpu 3 rip 0x7f80ed32638b address 0x00000003f7369712 error_code 0x181
qemu-system-x86-1060614 [036] 2316033.325844: kvm_page_fault: vcpu 3 rip 0x7f80ed32638b address 0x00000003f9ce5a12 error_code 0x181
qemu-system-x86-1060614 [036] 2316033.709713: kvm_page_fault: vcpu 3 rip 0x7f80ed3251d6 address 0x00000003f72089d0 error_code 0x182
root@eve-ng62:~#
What do such error_codes actually refer to ? Thanks.