Commit 9368b567 authored by Radim Krčmář's avatar Radim Krčmář Committed by Paolo Bonzini

KVM: x86: cleanup kvm_apic_match_*()

The majority of this patch turns
  result = 0; if (CODE) result = 1; return result;
into
  return CODE;
because we return bool now.
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 52c233a4
...@@ -591,42 +591,34 @@ static bool kvm_apic_match_physical_addr(struct kvm_lapic *apic, u32 dest) ...@@ -591,42 +591,34 @@ static bool kvm_apic_match_physical_addr(struct kvm_lapic *apic, u32 dest)
static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda) static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
{ {
int result = 0;
u32 logical_id; u32 logical_id;
if (kvm_apic_broadcast(apic, mda)) if (kvm_apic_broadcast(apic, mda))
return 1; return true;
if (apic_x2apic_mode(apic)) {
logical_id = kvm_apic_get_reg(apic, APIC_LDR); logical_id = kvm_apic_get_reg(apic, APIC_LDR);
return logical_id & mda;
}
logical_id = GET_APIC_LOGICAL_ID(kvm_apic_get_reg(apic, APIC_LDR)); if (apic_x2apic_mode(apic))
return (logical_id & mda) != 0;
logical_id = GET_APIC_LOGICAL_ID(logical_id);
switch (kvm_apic_get_reg(apic, APIC_DFR)) { switch (kvm_apic_get_reg(apic, APIC_DFR)) {
case APIC_DFR_FLAT: case APIC_DFR_FLAT:
if (logical_id & mda) return (logical_id & mda) != 0;
result = 1;
break;
case APIC_DFR_CLUSTER: case APIC_DFR_CLUSTER:
if (((logical_id >> 4) == (mda >> 0x4)) return ((logical_id >> 4) == (mda >> 4))
&& (logical_id & mda & 0xf)) && (logical_id & mda & 0xf) != 0;
result = 1;
break;
default: default:
apic_debug("Bad DFR vcpu %d: %08x\n", apic_debug("Bad DFR vcpu %d: %08x\n",
apic->vcpu->vcpu_id, kvm_apic_get_reg(apic, APIC_DFR)); apic->vcpu->vcpu_id, kvm_apic_get_reg(apic, APIC_DFR));
break; return false;
} }
return result;
} }
bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source, bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source,
int short_hand, unsigned int dest, int dest_mode) int short_hand, unsigned int dest, int dest_mode)
{ {
int result = 0;
struct kvm_lapic *target = vcpu->arch.apic; struct kvm_lapic *target = vcpu->arch.apic;
apic_debug("target %p, source %p, dest 0x%x, " apic_debug("target %p, source %p, dest 0x%x, "
...@@ -638,27 +630,21 @@ bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source, ...@@ -638,27 +630,21 @@ bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source,
case APIC_DEST_NOSHORT: case APIC_DEST_NOSHORT:
if (dest_mode == 0) if (dest_mode == 0)
/* Physical mode. */ /* Physical mode. */
result = kvm_apic_match_physical_addr(target, dest); return kvm_apic_match_physical_addr(target, dest);
else else
/* Logical mode. */ /* Logical mode. */
result = kvm_apic_match_logical_addr(target, dest); return kvm_apic_match_logical_addr(target, dest);
break;
case APIC_DEST_SELF: case APIC_DEST_SELF:
result = (target == source); return target == source;
break;
case APIC_DEST_ALLINC: case APIC_DEST_ALLINC:
result = 1; return true;
break;
case APIC_DEST_ALLBUT: case APIC_DEST_ALLBUT:
result = (target != source); return target != source;
break;
default: default:
apic_debug("kvm: apic: Bad dest shorthand value %x\n", apic_debug("kvm: apic: Bad dest shorthand value %x\n",
short_hand); short_hand);
break; return false;
} }
return result;
} }
bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src, bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment