On Tue, Apr 25, 2017 at 05:21:26PM +0800, QIN, Jingjie wrote: > > Hello, I'm very intreasted in the patchwork of vmx-EPTP-switching(https://patchwork.kernel.org/patch/7619141/), and I have tried to add the patch in my linux kernel. Then I tried to test the vmfunc in guest with the code below: > #define VMX_VMFUNC ".byte 0x0f,0x01,0xd4" > static void vmfunc(unsigned int nr, unsigned int ept) > { > asm volatile(VMX_VMFUNC > : > : "a"(nr), "c"(ept) > : "memory"); > } > My guest cpu is Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz and the code worked in the guest. > Then I tried to run this code in kvm by adding a new command in qemu and using vmfunc instruction in kvm via ioctl. I added a function in arch/x86/include/asm/vmx.h: > static inline u8 __vmx_vmfunc(u32 eptp, u32 func) > { > u8 error; > __asm __volatile(ASM_VMX_VMFUNC "; setna %0" > : "=q" (error) : "c" (eptp), "a" (func) > : "cc"); > return error; > } > > Then in kvm_vm_ioctl(Kvm_main.c) add codes: > case KVM_USE_VMFUNC_INSTRUCTION: > r = kvm_vm_use_vmfunc(kvm); > printk(KERN_ERR " kvm_vm_use_vmfunc result: %d \n",r); > break; > With some function calling, the ioctl can reach to __vmx_vmfunc. But there is some running errors in the code. I'm wandering whether could I use vmfunc in kvm, or did I make some mistake in the code? The log about this error is in the attachment file. > Hoping for your reply. > > Best Wishes, > Jingjie Qin AFAIK vmfunc only works within guest. -- MST