Skip to content

Commit

Permalink
KVM: x86: Fix bit shifting in update_intel_pt_cfg
Browse files Browse the repository at this point in the history
ctl_bitmask in pt_desc is of type u64. When an integer like 0xf is
being left shifted more than 32 bits, the behavior is undefined.

Fix this by adding suffix ULL to integer 0xf.

Addresses-Coverity-ID: 1476095 ("Bad bit shift operation")
Fixes: 6c0f0bb ("KVM: x86: Introduce a function to initialize the PT configuration")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Luwei Kang <luwei.kang@intel.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
  • Loading branch information
Gustavo A. R. Silva authored and Radim Krčmář committed Jan 11, 2019
1 parent bfeffd1 commit d14eff1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/x86/kvm/vmx/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -7044,7 +7044,7 @@ static void update_intel_pt_cfg(struct kvm_vcpu *vcpu)

/* unmask address range configure area */
for (i = 0; i < vmx->pt_desc.addr_range; i++)
vmx->pt_desc.ctl_bitmask &= ~(0xf << (32 + i * 4));
vmx->pt_desc.ctl_bitmask &= ~(0xfULL << (32 + i * 4));
}

static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
Expand Down

0 comments on commit d14eff1

Please sign in to comment.