From: Dan Carpenter <dan.carpenter@linaro.org>
To: Nadav Amit <namit@vmware.com>
Cc: kvm@vger.kernel.org
Subject: [bug report] x86: vmx: Comprehensive max VMCS field search
Date: Fri, 2 May 2025 16:06:34 +0300 [thread overview]
Message-ID: <aBTDWoL-wE46-GZ6@stanley.mountain> (raw)
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
reply other threads:[~2025-05-02 13:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=aBTDWoL-wE46-GZ6@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=namit@vmware.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