All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] nVMX: Test Host Segment Registers and Descriptor Tables on vmentry of nested guests
@ 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: Krish Sadhukhan; +Cc: kvm

Hello Krish Sadhukhan,

Commit 95d6d2c32288 ("nVMX: Test Host Segment Registers and
Descriptor Tables on vmentry of nested guests") from Jun 28, 2019
(linux-next), leads to the following Smatch static checker warning:

	x86/vmx_tests.c:7583 test_vmcs_field()
	warn: maybe use && instead of &

x86/vmx_tests.c
    7561 static void test_vmcs_field(u64 field, const char *field_name, u32 bit_start,
    7562                             u32 bit_end, u64 val, bool valid_val, u32 error)
    7563 {
    7564         u64 field_saved = vmcs_read(field);
    7565         u32 i;
    7566         u64 tmp;
    7567         u32 bit_on;
    7568         u64 mask = ~0ull;
    7569 
    7570         mask = (mask >> bit_end) << bit_end;
    7571         mask = mask | ((1 << bit_start) - 1);
    7572         tmp = (field_saved & mask) | (val << bit_start);
    7573 
    7574         vmcs_write(field, tmp);
    7575         report_prefix_pushf("%s %lx", field_name, tmp);
    7576         if (valid_val)
    7577                 test_vmx_vmlaunch(0);
    7578         else
    7579                 test_vmx_vmlaunch(error);
    7580         report_prefix_pop();
    7581 
    7582         for (i = bit_start; i <= bit_end; i = i + 2) {
--> 7583                 bit_on = ((1ull < i) & (val << bit_start)) ? 0 : 1;
                                         ^
This quite looks like it's supposed to be << instead of <.

    7584                 if (bit_on)
    7585                         tmp = field_saved | (1ull << i);
    7586                 else
    7587                         tmp = field_saved & ~(1ull << i);
    7588                 vmcs_write(field, tmp);
    7589                 report_prefix_pushf("%s %lx", field_name, tmp);
    7590                 if (valid_val)
    7591                         test_vmx_vmlaunch(error);
    7592                 else
    7593                         test_vmx_vmlaunch(0);
    7594                 report_prefix_pop();
    7595         }
    7596 
    7597         vmcs_write(field, field_saved);
    7598 }

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] nVMX: Test Host Segment Registers and Descriptor Tables on vmentry of nested guests Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.