mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 02:24:24 +02:00
KVM: arm64: vgic-v5: Cast vgic_apr to u32 to avoid undefined behaviours
Passing a u64 to __builtin_ctz() is odd, and requires some digging to
figure out why this construct is indeed safe as long as the HW is
correct.
But it is much easier to make it clear to the compiler by casting
the u64 into an intermediate u32, and be done with the UD.
Reviewed-by: Sascha Bischoff <sascha.bischoff@arm.com>
Fixes: 933e5288fa ("KVM: arm64: gic-v5: Check for pending PPIs")
Link: https://sashiko.dev/#/patchset/20260319154937.3619520-1-sascha.bischoff%40arm.com
Link: https://patch.msgid.link/20260401103611.357092-9-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
This commit is contained in:
parent
170a77b418
commit
42d7eac829
|
|
@ -212,7 +212,7 @@ int vgic_v5_finalize_ppi_state(struct kvm *kvm)
|
|||
static u32 vgic_v5_get_effective_priority_mask(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
struct vgic_v5_cpu_if *cpu_if = &vcpu->arch.vgic_cpu.vgic_v5;
|
||||
u32 highest_ap, priority_mask;
|
||||
u32 highest_ap, priority_mask, apr;
|
||||
|
||||
/*
|
||||
* If the guest's CPU has not opted to receive interrupts, then the
|
||||
|
|
@ -227,7 +227,8 @@ static u32 vgic_v5_get_effective_priority_mask(struct kvm_vcpu *vcpu)
|
|||
* priority. Explicitly use the 32-bit version here as we have 32
|
||||
* priorities. 32 then means that there are no active priorities.
|
||||
*/
|
||||
highest_ap = cpu_if->vgic_apr ? __builtin_ctz(cpu_if->vgic_apr) : 32;
|
||||
apr = cpu_if->vgic_apr;
|
||||
highest_ap = apr ? __builtin_ctz(apr) : 32;
|
||||
|
||||
/*
|
||||
* An interrupt is of sufficient priority if it is equal to or
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user