[bug report] x86: vmx: Comprehensive max VMCS field search

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

 



Hello Nadav Amit,

Commit 2b0418e4adf6 ("x86: vmx: Comprehensive max VMCS field search")
from Dec 19, 2019 (linux-next), leads to the following Smatch static
checker warning:

	x86/vmx.c:346 find_vmcs_max_index()
	warn: always true condition '(idx >= 0) => (0-u32max >= 0)'

x86/vmx.c
    339 static u32 find_vmcs_max_index(void)
    340 {
    341         u32 idx, width, type, enc;
    342         u64 actual;
    343         int ret;
    344 
    345         /* scan backwards and stop when found */
--> 346         for (idx = (1 << 9) - 1; idx >= 0; idx--) {
                                         ^^^^^^^^
idx is u32 so this is an endless loop.

    347 
    348                 /* try all combinations of width and type */
    349                 for (type = 0; type < (1 << 2); type++) {
    350                         for (width = 0; width < (1 << 2) ; width++) {
    351                                 enc = (idx << VMCS_FIELD_INDEX_SHIFT) |
    352                                       (type << VMCS_FIELD_TYPE_SHIFT) |
    353                                       (width << VMCS_FIELD_WIDTH_SHIFT);
    354 
    355                                 ret = vmcs_read_safe(enc, &actual);
    356                                 assert(!(ret & X86_EFLAGS_CF));
    357                                 if (!(ret & X86_EFLAGS_ZF))
    358                                         return idx;
    359                         }
    360                 }
    361         }
    362         /* some VMCS fields should exist */
    363         assert(0);
    364         return 0;
    365 }

regards,
dan carpenter




[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