CC: clang-built-linux(a)googlegroups.com CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Vitaly Kuznetsov CC: Paolo Bonzini tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 36a21d51725af2ce0700c6ebcb6b9594aac658a6 commit: 10d7bf1e46dc19d964f0f67d2a6d20df907742d1 KVM: x86: hyper-v: Cache guest CPUID leaves determining features availability date: 8 weeks ago :::::: branch date: 28 hours ago :::::: commit date: 8 weeks ago config: x86_64-randconfig-c001-20210806 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 42b9c2a17a0b63cccf3ac197a82f91b28e53e643) 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 # install x86_64 cross compiling tool for clang build # apt-get install binutils-x86-64-linux-gnu # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=10d7bf1e46dc19d964f0f67d2a6d20df907742d1 git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git fetch --no-tags linus master git checkout 10d7bf1e46dc19d964f0f67d2a6d20df907742d1 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot clang-analyzer warnings: (new ones prefixed by >>) arch/x86/kvm/hyperv.c:2031:13: note: Assuming the condition is true hc.fast = !!(hc.param & HV_HYPERCALL_FAST_BIT); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/hyperv.c:2034:14: note: Assuming field 'rep_cnt' is not equal to 0 hc.rep = !!(hc.rep_cnt || hc.rep_idx); ^~~~~~~~~~ arch/x86/kvm/hyperv.c:2034:25: note: Left side of '||' is true hc.rep = !!(hc.rep_cnt || hc.rep_idx); ^ arch/x86/kvm/hyperv.c:2036:9: note: Field 'fast' is false if (hc.fast && is_xmm_fast_hypercall(&hc)) ^ arch/x86/kvm/hyperv.c:2036:14: note: Left side of '&&' is false if (hc.fast && is_xmm_fast_hypercall(&hc)) ^ arch/x86/kvm/hyperv.c:2042:2: note: Control jumps to 'case 3:' at line 2073 switch (hc.code) { ^ arch/x86/kvm/hyperv.c:2074:20: note: Field 'rep_cnt' is not equal to 0 if (unlikely(!hc.rep_cnt || hc.rep_idx)) { ^ arch/x86/kvm/hyperv.c:2074:16: note: Left side of '||' is false if (unlikely(!hc.rep_cnt || hc.rep_idx)) { ^ arch/x86/kvm/hyperv.c:2074:7: note: Assuming the condition is true if (unlikely(!hc.rep_cnt || hc.rep_idx)) { ^ include/linux/compiler.h:78:40: note: expanded from macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^~~~ arch/x86/kvm/hyperv.c:2074:3: note: Taking false branch if (unlikely(!hc.rep_cnt || hc.rep_idx)) { ^ arch/x86/kvm/hyperv.c:2078:9: note: Calling 'kvm_hv_flush_tlb' ret = kvm_hv_flush_tlb(vcpu, &hc, false); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/hyperv.c:1658:7: note: 'ex' is false if (!ex) { ^~ arch/x86/kvm/hyperv.c:1658:2: note: Taking true branch if (!ex) { ^ arch/x86/kvm/hyperv.c:1659:11: note: Field 'fast' is false if (hc->fast) { ^ arch/x86/kvm/hyperv.c:1659:3: note: Taking false branch if (hc->fast) { ^ arch/x86/kvm/hyperv.c:1664:8: note: Assuming the condition is true if (unlikely(kvm_read_guest(kvm, hc->ingpa, ^ include/linux/compiler.h:78:40: note: expanded from macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^~~~ arch/x86/kvm/hyperv.c:1664:4: note: Taking false branch if (unlikely(kvm_read_guest(kvm, hc->ingpa, ^ arch/x86/kvm/hyperv.c:1682:15: note: Assuming the condition is false all_cpus = (flush.flags & HV_FLUSH_ALL_PROCESSORS) || ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/hyperv.c:1682:14: note: Left side of '||' is false all_cpus = (flush.flags & HV_FLUSH_ALL_PROCESSORS) || ^ arch/x86/kvm/hyperv.c:1683:4: note: Assuming field 'processor_mask' is not equal to 0 flush.processor_mask == 0; ^~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/hyperv.c:1731:14: note: 'all_cpus' is false vcpu_mask = all_cpus ? NULL : ^~~~~~~~ arch/x86/kvm/hyperv.c:1731:14: note: '?' condition is false arch/x86/kvm/hyperv.c:1732:3: note: Calling 'sparse_set_to_vcpu_mask' sparse_set_to_vcpu_mask(kvm, sparse_banks, valid_bank_mask, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/hyperv.c:1613:2: note: Assuming the condition is true for_each_set_bit(bank, (unsigned long *)&valid_bank_mask, ^ include/linux/bitops.h:36:7: note: expanded from macro 'for_each_set_bit' (bit) < (size); \ ^~~~~~~~~~~~~~ arch/x86/kvm/hyperv.c:1613:2: note: Loop condition is true. Entering loop body for_each_set_bit(bank, (unsigned long *)&valid_bank_mask, ^ include/linux/bitops.h:35:2: note: expanded from macro 'for_each_set_bit' for ((bit) = find_first_bit((addr), (size)); \ ^ arch/x86/kvm/hyperv.c:1613:2: note: Assuming the condition is true for_each_set_bit(bank, (unsigned long *)&valid_bank_mask, ^ include/linux/bitops.h:36:7: note: expanded from macro 'for_each_set_bit' (bit) < (size); \ ^~~~~~~~~~~~~~ arch/x86/kvm/hyperv.c:1613:2: note: Loop condition is true. Entering loop body for_each_set_bit(bank, (unsigned long *)&valid_bank_mask, ^ include/linux/bitops.h:35:2: note: expanded from macro 'for_each_set_bit' for ((bit) = find_first_bit((addr), (size)); \ ^ arch/x86/kvm/hyperv.c:1615:19: note: Assigned value is garbage or undefined vp_bitmap[bank] = sparse_banks[sbank++]; ^ ~~~~~~~~~~~~~~~~~~~~~ >> arch/x86/kvm/hyperv.c:1843:22: warning: Value stored to 'hv_vcpu' during its initialization is never read [clang-analyzer-deadcode.DeadStores] struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu); ^~~~~~~ ~~~~~~~~~~~~~~~~ arch/x86/kvm/hyperv.c:1843:22: note: Value stored to 'hv_vcpu' during its initialization is never read struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu); ^~~~~~~ ~~~~~~~~~~~~~~~~ Suppressed 5 warnings (5 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 3 warnings generated. drivers/base/power/main.c:469:3: warning: Value stored to 'usecs' is never read [clang-analyzer-deadcode.DeadStores] usecs = 1; ^ ~ drivers/base/power/main.c:469:3: note: Value stored to 'usecs' is never read usecs = 1; ^ ~ Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 8 warnings generated. Suppressed 8 warnings (8 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 3 warnings generated. drivers/thermal/thermal_hwmon.c:96:3: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy] strcpy(type, tz->type); ^~~~~~ drivers/thermal/thermal_hwmon.c:96:3: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 strcpy(type, tz->type); ^~~~~~ Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 3 warnings generated. drivers/i3c/master/mipi-i3c-hci/ext_caps.c:78:7: warning: Value stored to 'mode_entry' during its initialization is never read [clang-analyzer-deadcode.DeadStores] u32 mode_entry = readl(base); ^~~~~~~~~~ drivers/i3c/master/mipi-i3c-hci/ext_caps.c:78:7: note: Value stored to 'mode_entry' during its initialization is never read u32 mode_entry = readl(base); ^~~~~~~~~~ Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. drivers/i3c/master/mipi-i3c-hci/cmd_v2.c:293:3: warning: Value stored to 'pid' is never read [clang-analyzer-deadcode.DeadStores] pid = (pid << 32) | device_id[0]; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/i3c/master/mipi-i3c-hci/cmd_v2.c:293:3: note: Value stored to 'pid' is never read pid = (pid << 32) | device_id[0]; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/i3c/master/mipi-i3c-hci/cmd_v2.c:294:3: warning: Value stored to 'bcr' is never read [clang-analyzer-deadcode.DeadStores] bcr = FIELD_GET(W1_MASK(55, 48), device_id[1]); ^ drivers/i3c/master/mipi-i3c-hci/cmd_v2.c:294:3: note: Value stored to 'bcr' is never read drivers/i3c/master/mipi-i3c-hci/cmd_v2.c:295:3: warning: Value stored to 'dcr' is never read [clang-analyzer-deadcode.DeadStores] dcr = FIELD_GET(W1_MASK(63, 56), device_id[1]); ^ drivers/i3c/master/mipi-i3c-hci/cmd_v2.c:295:3: note: Value stored to 'dcr' is never read vim +/hv_vcpu +1843 arch/x86/kvm/hyperv.c 214ff83d4473a7 Vitaly Kuznetsov 2018-09-26 1839 8f014550dfb114 Vitaly Kuznetsov 2021-01-26 1840 void kvm_hv_set_cpuid(struct kvm_vcpu *vcpu) 8f014550dfb114 Vitaly Kuznetsov 2021-01-26 1841 { 8f014550dfb114 Vitaly Kuznetsov 2021-01-26 1842 struct kvm_cpuid_entry2 *entry; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 @1843 struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu); 8f014550dfb114 Vitaly Kuznetsov 2021-01-26 1844 8f014550dfb114 Vitaly Kuznetsov 2021-01-26 1845 entry = kvm_find_cpuid_entry(vcpu, HYPERV_CPUID_INTERFACE, 0); 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1846 if (entry && entry->eax == HYPERV_CPUID_SIGNATURE_EAX) { 8f014550dfb114 Vitaly Kuznetsov 2021-01-26 1847 vcpu->arch.hyperv_enabled = true; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1848 } else { 8f014550dfb114 Vitaly Kuznetsov 2021-01-26 1849 vcpu->arch.hyperv_enabled = false; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1850 return; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1851 } 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1852 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1853 if (!to_hv_vcpu(vcpu) && kvm_hv_vcpu_init(vcpu)) 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1854 return; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1855 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1856 hv_vcpu = to_hv_vcpu(vcpu); 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1857 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1858 entry = kvm_find_cpuid_entry(vcpu, HYPERV_CPUID_FEATURES, 0); 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1859 if (entry) { 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1860 hv_vcpu->cpuid_cache.features_eax = entry->eax; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1861 hv_vcpu->cpuid_cache.features_ebx = entry->ebx; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1862 hv_vcpu->cpuid_cache.features_edx = entry->edx; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1863 } else { 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1864 hv_vcpu->cpuid_cache.features_eax = 0; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1865 hv_vcpu->cpuid_cache.features_ebx = 0; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1866 hv_vcpu->cpuid_cache.features_edx = 0; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1867 } 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1868 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1869 entry = kvm_find_cpuid_entry(vcpu, HYPERV_CPUID_ENLIGHTMENT_INFO, 0); 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1870 if (entry) { 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1871 hv_vcpu->cpuid_cache.enlightenments_eax = entry->eax; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1872 hv_vcpu->cpuid_cache.enlightenments_ebx = entry->ebx; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1873 } else { 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1874 hv_vcpu->cpuid_cache.enlightenments_eax = 0; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1875 hv_vcpu->cpuid_cache.enlightenments_ebx = 0; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1876 } 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1877 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1878 entry = kvm_find_cpuid_entry(vcpu, HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES, 0); 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1879 if (entry) 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1880 hv_vcpu->cpuid_cache.syndbg_cap_eax = entry->eax; 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1881 else 10d7bf1e46dc19 Vitaly Kuznetsov 2021-05-21 1882 hv_vcpu->cpuid_cache.syndbg_cap_eax = 0; 8f014550dfb114 Vitaly Kuznetsov 2021-01-26 1883 } 8f014550dfb114 Vitaly Kuznetsov 2021-01-26 1884 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org