arm: Make sure not to shift off of the end of a uint32_t in KVM.
The methods which set or get an attribute from the virtual GIC use a shift constant which is 32, but they store their result in a 32 bit variable and, according to clang, are used to shift 32 bit inputs. This is undefined behavior in terms of the shift, and will truncate off the value regardless. Change-Id: Ie9543ab9e6e1d5f86317a9210d220928b23ffaf8 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23129 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Ciro Santilli <ciro.santilli@arm.com> Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
This commit is contained in:
@@ -115,8 +115,8 @@ KvmKernelGicV2::getGicReg(unsigned group, unsigned vcpu, unsigned offset)
|
||||
uint64_t reg;
|
||||
|
||||
assert(vcpu <= KVM_ARM_IRQ_VCPU_MASK);
|
||||
const uint32_t attr(
|
||||
(vcpu << KVM_DEV_ARM_VGIC_CPUID_SHIFT) |
|
||||
const uint64_t attr(
|
||||
((uint64_t)vcpu << KVM_DEV_ARM_VGIC_CPUID_SHIFT) |
|
||||
(offset << KVM_DEV_ARM_VGIC_OFFSET_SHIFT));
|
||||
|
||||
kdev.getAttrPtr(group, attr, ®);
|
||||
@@ -130,8 +130,8 @@ KvmKernelGicV2::setGicReg(unsigned group, unsigned vcpu, unsigned offset,
|
||||
uint64_t reg = value;
|
||||
|
||||
assert(vcpu <= KVM_ARM_IRQ_VCPU_MASK);
|
||||
const uint32_t attr(
|
||||
(vcpu << KVM_DEV_ARM_VGIC_CPUID_SHIFT) |
|
||||
const uint64_t attr(
|
||||
((uint64_t)vcpu << KVM_DEV_ARM_VGIC_CPUID_SHIFT) |
|
||||
(offset << KVM_DEV_ARM_VGIC_OFFSET_SHIFT));
|
||||
|
||||
kdev.setAttrPtr(group, attr, ®);
|
||||
|
||||
Reference in New Issue
Block a user