Re: [PATCH] kvm: nVMX: Remove superfluous VMX instruction fault checks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jim,

[auto build test ERROR on kvm/linux-next]
[also build test ERROR on v4.11-rc7 next-20170421]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jim-Mattson/kvm-nVMX-Remove-superfluous-VMX-instruction-fault-checks/20170422-073002
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next
config: i386-randconfig-x073-201716 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   arch/x86//kvm/vmx.c: In function 'handle_vmon':
>> arch/x86//kvm/vmx.c:7099:13: error: invalid storage class for function 'nested_vmx_check_permission'
    static bool nested_vmx_check_permission(struct kvm_vcpu *vcpu)
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7099:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
    static bool nested_vmx_check_permission(struct kvm_vcpu *vcpu)
    ^~~~~~
>> arch/x86//kvm/vmx.c:7110:20: error: invalid storage class for function 'nested_release_vmcs12'
    static inline void nested_release_vmcs12(struct vcpu_vmx *vmx)
                       ^~~~~~~~~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7144:13: error: invalid storage class for function 'free_nested'
    static void free_nested(struct vcpu_vmx *vmx)
                ^~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7182:12: error: invalid storage class for function 'handle_vmoff'
    static int handle_vmoff(struct kvm_vcpu *vcpu)
               ^~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7192:12: error: invalid storage class for function 'handle_vmclear'
    static int handle_vmclear(struct kvm_vcpu *vcpu)
               ^~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7217:12: error: invalid storage class for function 'nested_vmx_run'
    static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch);
               ^~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7220:12: error: invalid storage class for function 'handle_vmlaunch'
    static int handle_vmlaunch(struct kvm_vcpu *vcpu)
               ^~~~~~~~~~~~~~~
   arch/x86//kvm/vmx.c: In function 'handle_vmlaunch':
>> arch/x86//kvm/vmx.c:7222:9: error: implicit declaration of function 'nested_vmx_run' [-Werror=implicit-function-declaration]
     return nested_vmx_run(vcpu, true);
            ^~~~~~~~~~~~~~
   arch/x86//kvm/vmx.c: In function 'handle_vmon':
>> arch/x86//kvm/vmx.c:7226:12: error: invalid storage class for function 'handle_vmresume'
    static int handle_vmresume(struct kvm_vcpu *vcpu)
               ^~~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7239:19: error: invalid storage class for function 'vmcs_field_type'
    static inline int vmcs_field_type(unsigned long field)
                      ^~~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7246:19: error: invalid storage class for function 'vmcs_field_readonly'
    static inline int vmcs_field_readonly(unsigned long field)
                      ^~~~~~~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7258:19: error: invalid storage class for function 'vmcs12_read_any'
    static inline int vmcs12_read_any(struct kvm_vcpu *vcpu,
                      ^~~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7289:19: error: invalid storage class for function 'vmcs12_write_any'
    static inline int vmcs12_write_any(struct kvm_vcpu *vcpu,
                      ^~~~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7316:13: error: invalid storage class for function 'copy_shadow_to_vmcs12'
    static void copy_shadow_to_vmcs12(struct vcpu_vmx *vmx)
                ^~~~~~~~~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7357:13: error: invalid storage class for function 'copy_vmcs12_to_shadow'
    static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx)
                ^~~~~~~~~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7407:12: error: invalid storage class for function 'nested_vmx_check_vmcs12'
    static int nested_vmx_check_vmcs12(struct kvm_vcpu *vcpu)
               ^~~~~~~~~~~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7417:12: error: invalid storage class for function 'handle_vmread'
    static int handle_vmread(struct kvm_vcpu *vcpu)
               ^~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7460:12: error: invalid storage class for function 'handle_vmwrite'
    static int handle_vmwrite(struct kvm_vcpu *vcpu)
               ^~~~~~~~~~~~~~
>> arch/x86//kvm/vmx.c:7512:13: error: invalid storage class for function 'set_current_vmptr'
    static void set_current_vmptr(struct vcpu_vmx *vmx, gpa_t vmptr)
                ^~~~~~~~~~~~~~~~~

vim +/nested_vmx_check_permission +7099 arch/x86//kvm/vmx.c

  7093	 * Intel's VMX Instruction Reference specifies a common set of prerequisites
  7094	 * for running VMX instructions (except VMXON, whose prerequisites are
  7095	 * slightly different). It also specifies what exception to inject otherwise.
  7096	 * Note that many of these exceptions have priority over VM exits, so they
  7097	 * don't have to be checked again here.
  7098	 */
> 7099	static bool nested_vmx_check_permission(struct kvm_vcpu *vcpu)
  7100	{
  7101		if (!to_vmx(vcpu)->nested.vmxon ||
  7102		    (!enable_unrestricted_guest &&
  7103		     !kvm_read_cr0_bits(vcpu, X86_CR0_PE))) {
  7104			kvm_queue_exception(vcpu, UD_VECTOR);
  7105			return false;
  7106		}
  7107		return true;
  7108	}
  7109	
> 7110	static inline void nested_release_vmcs12(struct vcpu_vmx *vmx)
  7111	{
  7112		if (vmx->nested.current_vmptr == -1ull)
  7113			return;
  7114	
  7115		/* current_vmptr and current_vmcs12 are always set/reset together */
  7116		if (WARN_ON(vmx->nested.current_vmcs12 == NULL))
  7117			return;
  7118	
  7119		if (enable_shadow_vmcs) {
  7120			/* copy to memory all shadowed fields in case
  7121			   they were modified */
  7122			copy_shadow_to_vmcs12(vmx);
  7123			vmx->nested.sync_shadow_vmcs = false;
  7124			vmcs_clear_bits(SECONDARY_VM_EXEC_CONTROL,
  7125					SECONDARY_EXEC_SHADOW_VMCS);
  7126			vmcs_write64(VMCS_LINK_POINTER, -1ull);
  7127		}
  7128		vmx->nested.posted_intr_nv = -1;
  7129	
  7130		/* Flush VMCS12 to guest memory */
  7131		memcpy(vmx->nested.current_vmcs12, vmx->nested.cached_vmcs12,
  7132		       VMCS12_SIZE);
  7133	
  7134		kunmap(vmx->nested.current_vmcs12_page);
  7135		nested_release_page(vmx->nested.current_vmcs12_page);
  7136		vmx->nested.current_vmptr = -1ull;
  7137		vmx->nested.current_vmcs12 = NULL;
  7138	}
  7139	
  7140	/*
  7141	 * Free whatever needs to be freed from vmx->nested when L1 goes down, or
  7142	 * just stops using VMX.
  7143	 */
> 7144	static void free_nested(struct vcpu_vmx *vmx)
  7145	{
  7146		if (!vmx->nested.vmxon)
  7147			return;
  7148	
  7149		vmx->nested.vmxon = false;
  7150		free_vpid(vmx->nested.vpid02);
  7151		nested_release_vmcs12(vmx);
  7152		if (vmx->nested.msr_bitmap) {
  7153			free_page((unsigned long)vmx->nested.msr_bitmap);
  7154			vmx->nested.msr_bitmap = NULL;
  7155		}
  7156		if (enable_shadow_vmcs) {
  7157			vmcs_clear(vmx->vmcs01.shadow_vmcs);
  7158			free_vmcs(vmx->vmcs01.shadow_vmcs);
  7159			vmx->vmcs01.shadow_vmcs = NULL;
  7160		}
  7161		kfree(vmx->nested.cached_vmcs12);
  7162		/* Unpin physical memory we referred to in current vmcs02 */
  7163		if (vmx->nested.apic_access_page) {
  7164			nested_release_page(vmx->nested.apic_access_page);
  7165			vmx->nested.apic_access_page = NULL;
  7166		}
  7167		if (vmx->nested.virtual_apic_page) {
  7168			nested_release_page(vmx->nested.virtual_apic_page);
  7169			vmx->nested.virtual_apic_page = NULL;
  7170		}
  7171		if (vmx->nested.pi_desc_page) {
  7172			kunmap(vmx->nested.pi_desc_page);
  7173			nested_release_page(vmx->nested.pi_desc_page);
  7174			vmx->nested.pi_desc_page = NULL;
  7175			vmx->nested.pi_desc = NULL;
  7176		}
  7177	
  7178		nested_free_all_saved_vmcss(vmx);
  7179	}
  7180	
  7181	/* Emulate the VMXOFF instruction */
> 7182	static int handle_vmoff(struct kvm_vcpu *vcpu)
  7183	{
  7184		if (!nested_vmx_check_permission(vcpu))
  7185			return 1;
  7186		free_nested(to_vmx(vcpu));
  7187		nested_vmx_succeed(vcpu);
  7188		return kvm_skip_emulated_instruction(vcpu);
  7189	}
  7190	
  7191	/* Emulate the VMCLEAR instruction */
> 7192	static int handle_vmclear(struct kvm_vcpu *vcpu)
  7193	{
  7194		struct vcpu_vmx *vmx = to_vmx(vcpu);
  7195		u32 zero = 0;
  7196		gpa_t vmptr;
  7197	
  7198		if (!nested_vmx_check_permission(vcpu))
  7199			return 1;
  7200	
  7201		if (nested_vmx_check_vmptr(vcpu, EXIT_REASON_VMCLEAR, &vmptr))
  7202			return 1;
  7203	
  7204		if (vmptr == vmx->nested.current_vmptr)
  7205			nested_release_vmcs12(vmx);
  7206	
  7207		kvm_vcpu_write_guest(vcpu,
  7208				vmptr + offsetof(struct vmcs12, launch_state),
  7209				&zero, sizeof(zero));
  7210	
  7211		nested_free_vmcs02(vmx, vmptr);
  7212	
  7213		nested_vmx_succeed(vcpu);
  7214		return kvm_skip_emulated_instruction(vcpu);
  7215	}
  7216	
> 7217	static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch);
  7218	
  7219	/* Emulate the VMLAUNCH instruction */
> 7220	static int handle_vmlaunch(struct kvm_vcpu *vcpu)
  7221	{
> 7222		return nested_vmx_run(vcpu, true);
  7223	}
  7224	
  7225	/* Emulate the VMRESUME instruction */
> 7226	static int handle_vmresume(struct kvm_vcpu *vcpu)
  7227	{
  7228	
  7229		return nested_vmx_run(vcpu, false);
  7230	}
  7231	
  7232	enum vmcs_field_type {
  7233		VMCS_FIELD_TYPE_U16 = 0,
  7234		VMCS_FIELD_TYPE_U64 = 1,
  7235		VMCS_FIELD_TYPE_U32 = 2,
  7236		VMCS_FIELD_TYPE_NATURAL_WIDTH = 3
  7237	};
  7238	
> 7239	static inline int vmcs_field_type(unsigned long field)
  7240	{
  7241		if (0x1 & field)	/* the *_HIGH fields are all 32 bit */
  7242			return VMCS_FIELD_TYPE_U32;
  7243		return (field >> 13) & 0x3 ;
  7244	}
  7245	
> 7246	static inline int vmcs_field_readonly(unsigned long field)
  7247	{
  7248		return (((field >> 10) & 0x3) == 1);
  7249	}
  7250	
  7251	/*
  7252	 * Read a vmcs12 field. Since these can have varying lengths and we return
  7253	 * one type, we chose the biggest type (u64) and zero-extend the return value
  7254	 * to that size. Note that the caller, handle_vmread, might need to use only
  7255	 * some of the bits we return here (e.g., on 32-bit guests, only 32 bits of
  7256	 * 64-bit fields are to be returned).
  7257	 */
> 7258	static inline int vmcs12_read_any(struct kvm_vcpu *vcpu,
  7259					  unsigned long field, u64 *ret)
  7260	{
  7261		short offset = vmcs_field_to_offset(field);
  7262		char *p;
  7263	
  7264		if (offset < 0)
  7265			return offset;
  7266	
  7267		p = ((char *)(get_vmcs12(vcpu))) + offset;
  7268	
  7269		switch (vmcs_field_type(field)) {
  7270		case VMCS_FIELD_TYPE_NATURAL_WIDTH:
  7271			*ret = *((natural_width *)p);
  7272			return 0;
  7273		case VMCS_FIELD_TYPE_U16:
  7274			*ret = *((u16 *)p);
  7275			return 0;
  7276		case VMCS_FIELD_TYPE_U32:
  7277			*ret = *((u32 *)p);
  7278			return 0;
  7279		case VMCS_FIELD_TYPE_U64:
  7280			*ret = *((u64 *)p);
  7281			return 0;
  7282		default:
  7283			WARN_ON(1);
  7284			return -ENOENT;
  7285		}
  7286	}
  7287	
  7288	
> 7289	static inline int vmcs12_write_any(struct kvm_vcpu *vcpu,
  7290					   unsigned long field, u64 field_value){
  7291		short offset = vmcs_field_to_offset(field);
  7292		char *p = ((char *) get_vmcs12(vcpu)) + offset;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux