public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>
Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org,
	Sean Christopherson <seanjc@google.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	kvm@vger.kernel.org
Subject: Re: [PATCH 4/5] KVM: x86: Use __try_cmpxchg_user() to emulate atomic accesses
Date: Tue, 1 Feb 2022 17:25:00 +0800	[thread overview]
Message-ID: <202202011753.zksthphR-lkp@intel.com> (raw)
In-Reply-To: <20220201010838.1494405-5-seanjc@google.com>

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@intel.com/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@intel.com>

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@lists.01.org

  reply	other threads:[~2022-02-01  9:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01  1:08 [PATCH 0/5] x86: uaccess CMPXCHG + KVM bug fixes Sean Christopherson
2022-02-01  1:08 ` [PATCH 1/5] Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug Sean Christopherson
2022-02-01 20:16   ` Nick Desaulniers
2022-02-01 20:56     ` Sean Christopherson
2022-02-01 21:15       ` Nick Desaulniers
2022-02-01  1:08 ` [PATCH 2/5] x86/uaccess: Implement macros for CMPXCHG on user addresses Sean Christopherson
2022-02-01  1:08 ` [PATCH 3/5] KVM: x86: Use __try_cmpxchg_user() to update guest PTE A/D bits Sean Christopherson
2022-02-01  7:01   ` kernel test robot
2022-02-01 19:44     ` Sean Christopherson
2022-02-01 19:53       ` Nick Desaulniers
2022-02-01 13:25   ` kernel test robot
2022-02-01  1:08 ` [PATCH 4/5] KVM: x86: Use __try_cmpxchg_user() to emulate atomic accesses Sean Christopherson
2022-02-01  9:25   ` kernel test robot [this message]
2022-02-01  1:08 ` [PATCH 5/5] KVM: x86: Bail to userspace if emulation of atomic user access faults Sean Christopherson
2022-02-01 17:09 ` [PATCH 0/5] x86: uaccess CMPXCHG + KVM bug fixes Tadeusz Struk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202202011753.zksthphR-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kbuild-all@lists.01.org \
    --cc=kvm@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox