Software Archive
Read-only legacy content
17061 Discussions

vmwrite error when writing to EPTP_LIST_ADDRESS and VM_FUNCTION_CONTROL

Zihan_Y_
Beginner
516 Views

Enrvironment:

Kernel Version: 4.18.19 (compiled from source)

Processor: Intel i7-7700k

OS: Ubuntu 16.04

I am trying to play with VMFUNC, and I need to enable and prepare eptp list in kvm. However, I find that writing to EPTP_LIST_ADDRESS(which is offset 2024) and VM_FUNCTION_CONTROL(which is 2018) will (almost) always cause a vmwrite error.

For example, the following line

vmcs_write64(EPTP_LIST_ADDRESS, 0);

will give this error in dmesg

[167.780855] vmwirte error: reg 2024 value 0 (err 1)

And if I write the actual physical address of a page into it, I get 

[167.786527] vmwrite error: reg 2024 value 68cbd15ff840 (err -782239680)

Note that -782239680 seems to be 0xd15ff840

 

There is similar error when writing to VM_FUNCTION_CONTROL field, but not other fileds. I am sure that my cpu has VMFUNC by the following 2 functions

static inline bool cpu_has_vmx_vmfunc(void)
{
    return vmcs_config_cpu_based_2nd_exec_ctrl & 
        SECONDARY_EXEC_ENABLE_VMFUNC;
}

static inline bool cpu_has_vmx_eptp_switching(void)
{
    u64 vmx_msr;
    rdmsrl(MSR_IA32_VMX_VMFUNC, vmx_msr);

    return vmx_msr & 0x1;
}

Both functions return true, so I think my process do support such features.

Why is problem happening, am I missing anything? Thanks.

0 Kudos
1 Reply
Software__Tgf
Beginner
516 Views

Hey Zihan.Y, for what you are doing I need a bit more information to help you. Are you writing your code in kernel space or user space?

0 Kudos
Reply