Re: [PATCH 4/5] KVM: x86: Use __try_cmpxchg_user() to emulate atomic accesses

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

 



Hi Sean,

I love your patch! Yet something to improve:

[auto build test ERROR on 26291c54e111ff6ba87a164d85d4a4e134b7315c]

url:    https://github.com/0day-ci/linux/commits/Sean-Christopherson/x86-uaccess-CMPXCHG-KVM-bug-fixes/20220201-091001
base:   26291c54e111ff6ba87a164d85d4a4e134b7315c
config: i386-randconfig-a002 (https://download.01.org/0day-ci/archive/20220201/202202011753.zksthphR-lkp@xxxxxxxxx/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 6b1e844b69f15bb7dffaf9365cd2b355d2eb7579)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/5387711f4b49675e162ca30b05a3b2435326e5f9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Sean-Christopherson/x86-uaccess-CMPXCHG-KVM-bug-fixes/20220201-091001
        git checkout 5387711f4b49675e162ca30b05a3b2435326e5f9
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

>> arch/x86/kvm/x86.c:7213:7: error: invalid output size for constraint '+a'
                   r = emulator_try_cmpxchg_user(u64, hva, old, new);
                       ^
   arch/x86/kvm/x86.c:7159:3: note: expanded from macro 'emulator_try_cmpxchg_user'
           (__try_cmpxchg_user((t *)(ptr), (t *)(old), *(t *)(new), efault ## t))
            ^
   arch/x86/include/asm/uaccess.h:629:11: note: expanded from macro '__try_cmpxchg_user'
           __ret = !unsafe_try_cmpxchg_user(_ptr, _oldp, _nval, _label);   \
                    ^
   arch/x86/include/asm/uaccess.h:606:18: note: expanded from macro 'unsafe_try_cmpxchg_user'
           case 1: __ret = __try_cmpxchg_user_asm("b", "q",                \
                           ^
   arch/x86/include/asm/uaccess.h:467:22: note: expanded from macro '__try_cmpxchg_user_asm'
                          [old] "+a" (__old)                               \
                                      ^
>> arch/x86/kvm/x86.c:7213:7: error: invalid output size for constraint '+a'
   arch/x86/kvm/x86.c:7159:3: note: expanded from macro 'emulator_try_cmpxchg_user'
           (__try_cmpxchg_user((t *)(ptr), (t *)(old), *(t *)(new), efault ## t))
            ^
   arch/x86/include/asm/uaccess.h:629:11: note: expanded from macro '__try_cmpxchg_user'
           __ret = !unsafe_try_cmpxchg_user(_ptr, _oldp, _nval, _label);   \
                    ^
   arch/x86/include/asm/uaccess.h:610:18: note: expanded from macro 'unsafe_try_cmpxchg_user'
           case 2: __ret = __try_cmpxchg_user_asm("w", "r",                \
                           ^
   arch/x86/include/asm/uaccess.h:467:22: note: expanded from macro '__try_cmpxchg_user_asm'
                          [old] "+a" (__old)                               \
                                      ^
>> arch/x86/kvm/x86.c:7213:7: error: invalid output size for constraint '+a'
   arch/x86/kvm/x86.c:7159:3: note: expanded from macro 'emulator_try_cmpxchg_user'
           (__try_cmpxchg_user((t *)(ptr), (t *)(old), *(t *)(new), efault ## t))
            ^
   arch/x86/include/asm/uaccess.h:629:11: note: expanded from macro '__try_cmpxchg_user'
           __ret = !unsafe_try_cmpxchg_user(_ptr, _oldp, _nval, _label);   \
                    ^
   arch/x86/include/asm/uaccess.h:614:18: note: expanded from macro 'unsafe_try_cmpxchg_user'
           case 4: __ret = __try_cmpxchg_user_asm("l", "r",                \
                           ^
   arch/x86/include/asm/uaccess.h:467:22: note: expanded from macro '__try_cmpxchg_user_asm'
                          [old] "+a" (__old)                               \
                                      ^
   3 errors generated.


vim +7213 arch/x86/kvm/x86.c

  7157	
  7158	#define emulator_try_cmpxchg_user(t, ptr, old, new) \
  7159		(__try_cmpxchg_user((t *)(ptr), (t *)(old), *(t *)(new), efault ## t))
  7160	
  7161	static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt,
  7162					     unsigned long addr,
  7163					     const void *old,
  7164					     const void *new,
  7165					     unsigned int bytes,
  7166					     struct x86_exception *exception)
  7167	{
  7168		struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
  7169		u64 page_line_mask;
  7170		unsigned long hva;
  7171		gpa_t gpa;
  7172		int r;
  7173	
  7174		/* guests cmpxchg8b have to be emulated atomically */
  7175		if (bytes > 8 || (bytes & (bytes - 1)))
  7176			goto emul_write;
  7177	
  7178		gpa = kvm_mmu_gva_to_gpa_write(vcpu, addr, NULL);
  7179	
  7180		if (gpa == UNMAPPED_GVA ||
  7181		    (gpa & PAGE_MASK) == APIC_DEFAULT_PHYS_BASE)
  7182			goto emul_write;
  7183	
  7184		/*
  7185		 * Emulate the atomic as a straight write to avoid #AC if SLD is
  7186		 * enabled in the host and the access splits a cache line.
  7187		 */
  7188		if (boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT))
  7189			page_line_mask = ~(cache_line_size() - 1);
  7190		else
  7191			page_line_mask = PAGE_MASK;
  7192	
  7193		if (((gpa + bytes - 1) & page_line_mask) != (gpa & page_line_mask))
  7194			goto emul_write;
  7195	
  7196		hva = kvm_vcpu_gfn_to_hva(vcpu, gpa_to_gfn(gpa));
  7197		if (kvm_is_error_hva(addr))
  7198			goto emul_write;
  7199	
  7200		hva += offset_in_page(gpa);
  7201	
  7202		switch (bytes) {
  7203		case 1:
  7204			r = emulator_try_cmpxchg_user(u8, hva, old, new);
  7205			break;
  7206		case 2:
  7207			r = emulator_try_cmpxchg_user(u16, hva, old, new);
  7208			break;
  7209		case 4:
  7210			r = emulator_try_cmpxchg_user(u32, hva, old, new);
  7211			break;
  7212		case 8:
> 7213			r = emulator_try_cmpxchg_user(u64, hva, old, new);
  7214			break;
  7215		default:
  7216			BUG();
  7217		}
  7218	
  7219		if (r < 0)
  7220			goto emul_write;
  7221		if (r)
  7222			return X86EMUL_CMPXCHG_FAILED;
  7223	
  7224		kvm_page_track_write(vcpu, gpa, new, bytes);
  7225	
  7226		return X86EMUL_CONTINUE;
  7227	
  7228	emul_write:
  7229		printk_once(KERN_WARNING "kvm: emulating exchange as write\n");
  7230	
  7231		return emulator_write_emulated(ctxt, addr, new, bytes, exception);
  7232	}
  7233	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx



[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