[PATCH] kvm: vmx: Silence a shift wrap warning

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

 



This code generates a Smatch warning:

arch/x86/kvm/vmx/nested.c:4828 handle_vmfunc() warn: should '(1 << function)' be a 64 bit type?

The warning is generated because "vmcs12->vm_function_control" is a u64
but the shift can only test the lower 32 bits.  This doesn't cause a
problem in the current code because we only use BIT(0).  This patch just
silences the static checker warning.

Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
---
 arch/x86/kvm/vmx/nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index f24a2c225070..1f4398246bd9 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -4825,7 +4825,7 @@ static int handle_vmfunc(struct kvm_vcpu *vcpu)
 	}
 
 	vmcs12 = get_vmcs12(vcpu);
-	if ((vmcs12->vm_function_control & (1 << function)) == 0)
+	if ((vmcs12->vm_function_control & (1ULL << function)) == 0)
 		goto fail;
 
 	switch (function) {
-- 
2.17.1




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux