* [bug report] x86: vmx: Comprehensive max VMCS field search
@ 2025-05-02 13:06 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2025-05-02 13:06 UTC (permalink / raw)
To: Nadav Amit; +Cc: kvm
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-05-02 13:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-02 13:06 [bug report] x86: vmx: Comprehensive max VMCS field search Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox