arch/x86/kvm/hyperv.c:1843:22: warning: Value stored to 'hv_vcpu' during its initialization is never read [clang-analyzer-deadcode.DeadStores]

From: kernel test robot
Date: Mon Aug 09 2021 - 06:58:11 EST



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: 12 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 <lkp@xxxxxxxxx>


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.
3 warnings generated.
arch/x86/include/asm/xen/hypercall.h:358:9: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
return _hypercall2(int, event_channel_op, cmd, arg);
^
arch/x86/include/asm/xen/hypercall.h:169:2: note: expanded from macro '_hypercall2'
__HYPERCALL_DECLS; \
^
arch/x86/include/asm/xen/hypercall.h:113:2: note: expanded from macro '__HYPERCALL_DECLS'
register unsigned long __arg1 asm(__HYPERCALL_ARG1REG) = __arg1; \
^
drivers/xen/xenbus/xenbus_dev_backend.c:77:6: note: Assuming the condition is false
if (!capable(CAP_SYS_ADMIN))
^~~~~~~~~~~~~~~~~~~~~~~
drivers/xen/xenbus/xenbus_dev_backend.c:77:2: note: Taking false branch
if (!capable(CAP_SYS_ADMIN))
^
drivers/xen/xenbus/xenbus_dev_backend.c:80:2: note: Control jumps to 'case 16897:' at line 85
switch (cmd) {
^
drivers/xen/xenbus/xenbus_dev_backend.c:86:10: note: Calling 'xenbus_alloc'
return xenbus_alloc(data);
^~~~~~~~~~~~~~~~~~
drivers/xen/xenbus/xenbus_dev_backend.c:47:6: note: Assuming 'xenstored_ready' is 0
if (xenstored_ready)
^~~~~~~~~~~~~~~
drivers/xen/xenbus/xenbus_dev_backend.c:47:2: note: Taking false branch
if (xenstored_ready)
^
drivers/xen/xenbus/xenbus_dev_backend.c:56:8: note: Calling 'HYPERVISOR_event_channel_op'
err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &arg);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/x86/include/asm/xen/hypercall.h:358:9: note: Assigned value is garbage or undefined
return _hypercall2(int, event_channel_op, cmd, arg);
^
arch/x86/include/asm/xen/hypercall.h:169:2: note: expanded from macro '_hypercall2'
__HYPERCALL_DECLS; \
^~~~~~~~~~~~~~~~~
arch/x86/include/asm/xen/hypercall.h:113:2: note: expanded from macro '__HYPERCALL_DECLS'
register unsigned long __arg1 asm(__HYPERCALL_ARG1REG) = __arg1; \
^ ~~~~~~
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.
4 warnings generated.
drivers/mtd/lpddr/lpddr_cmds.c:441:24: warning: The left operand of '-' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
if (n > vec->iov_len - vec_seek)
^
drivers/mtd/lpddr/lpddr_cmds.c:641:9: note: Calling 'lpddr_writev'
return lpddr_writev(mtd, &vec, 1, to, retlen);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/mtd/lpddr/lpddr_cmds.c:656:2: note: Loop condition is true. Entering loop body
for (i = 0; i < count; i++)
^
drivers/mtd/lpddr/lpddr_cmds.c:656:2: note: Loop condition is false. Execution continues on line 659
drivers/mtd/lpddr/lpddr_cmds.c:659:6: note: Assuming 'len' is not equal to 0
if (!len)
^~~~
drivers/mtd/lpddr/lpddr_cmds.c:659:2: note: Taking false branch
if (!len)
^
drivers/mtd/lpddr/lpddr_cmds.c:671:7: note: Assuming 'size' is <= 'len'
if (size > len)
^~~~~~~~~~
drivers/mtd/lpddr/lpddr_cmds.c:671:3: note: Taking false branch
if (size > len)
^
drivers/mtd/lpddr/lpddr_cmds.c:674:9: note: Calling 'do_write_buffer'
ret = do_write_buffer(map, &lpddr->chips[chipnum],
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/mtd/lpddr/lpddr_cmds.c:418:6: note: Assuming 'ret' is 0
if (ret) {
^~~
drivers/mtd/lpddr/lpddr_cmds.c:418:2: note: Taking false branch
if (ret) {
^
drivers/mtd/lpddr/lpddr_cmds.c:425:6: note: Assuming 'word_gap' is 0
if (!word_gap) {
^~~~~~~~~
drivers/mtd/lpddr/lpddr_cmds.c:425:2: note: Taking true branch
if (!word_gap) {
^
drivers/mtd/lpddr/lpddr_cmds.c:441:7: note: Assuming the condition is false
if (n > vec->iov_len - vec_seek)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/mtd/lpddr/lpddr_cmds.c:441:3: note: Taking false branch
if (n > vec->iov_len - vec_seek)
^
drivers/mtd/lpddr/lpddr_cmds.c:443:7: note: Assuming 'n' is <= 'len'
if (n > len)
^~~~~~~
drivers/mtd/lpddr/lpddr_cmds.c:443:3: note: Taking false branch

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@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- kbuild@xxxxxxxxxxxx
To unsubscribe send an email to kbuild-leave@xxxxxxxxxxxx