aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorRadim Krčmář <rkrcmar@redhat.com>2015-01-29 16:48:49 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2015-01-30 06:26:45 -0500
commit9368b5676265304702419eb090deffc9faf9b08f (patch)
tree87d69645aab869d4cd161716bef3e4245b50770f /arch/x86/kvm
parent52c233a4405eef4f4dbbe2984e308871866db007 (diff)
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: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/lapic.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 62f624656549..caf5a8d82c18 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -591,42 +591,34 @@ static bool kvm_apic_match_physical_addr(struct kvm_lapic *apic, u32 dest)
591 591
592static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda) 592static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
593{ 593{
594 int result = 0;
595 u32 logical_id; 594 u32 logical_id;
596 595
597 if (kvm_apic_broadcast(apic, mda)) 596 if (kvm_apic_broadcast(apic, mda))
598 return 1; 597 return true;
599 598
600 if (apic_x2apic_mode(apic)) { 599 logical_id = kvm_apic_get_reg(apic, APIC_LDR);
601 logical_id = kvm_apic_get_reg(apic, APIC_LDR);
602 return logical_id & mda;
603 }
604 600
605 logical_id = GET_APIC_LOGICAL_ID(kvm_apic_get_reg(apic, APIC_LDR)); 601 if (apic_x2apic_mode(apic))
602 return (logical_id & mda) != 0;
603
604 logical_id = GET_APIC_LOGICAL_ID(logical_id);
606 605
607 switch (kvm_apic_get_reg(apic, APIC_DFR)) { 606 switch (kvm_apic_get_reg(apic, APIC_DFR)) {
608 case APIC_DFR_FLAT: 607 case APIC_DFR_FLAT:
609 if (logical_id & mda) 608 return (logical_id & mda) != 0;
610 result = 1;
611 break;
612 case APIC_DFR_CLUSTER: 609 case APIC_DFR_CLUSTER:
613 if (((logical_id >> 4) == (mda >> 0x4)) 610 return ((logical_id >> 4) == (mda >> 4))
614 && (logical_id & mda & 0xf)) 611 && (logical_id & mda & 0xf) != 0;
615 result = 1;
616 break;
617 default: 612 default:
618 apic_debug("Bad DFR vcpu %d: %08x\n", 613 apic_debug("Bad DFR vcpu %d: %08x\n",
619 apic->vcpu->vcpu_id, kvm_apic_get_reg(apic, APIC_DFR)); 614 apic->vcpu->vcpu_id, kvm_apic_get_reg(apic, APIC_DFR));
620 break; 615 return false;
621 } 616 }
622
623 return result;
624} 617}
625 618
626bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source, 619bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source,
627 int short_hand, unsigned int dest, int dest_mode) 620 int short_hand, unsigned int dest, int dest_mode)
628{ 621{
629 int result = 0;
630 struct kvm_lapic *target = vcpu->arch.apic; 622 struct kvm_lapic *target = vcpu->arch.apic;
631 623
632 apic_debug("target %p, source %p, dest 0x%x, " 624 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 case APIC_DEST_NOSHORT: 630 case APIC_DEST_NOSHORT:
639 if (dest_mode == 0) 631 if (dest_mode == 0)
640 /* Physical mode. */ 632 /* Physical mode. */
641 result = kvm_apic_match_physical_addr(target, dest); 633 return kvm_apic_match_physical_addr(target, dest);
642 else 634 else
643 /* Logical mode. */ 635 /* Logical mode. */
644 result = kvm_apic_match_logical_addr(target, dest); 636 return kvm_apic_match_logical_addr(target, dest);
645 break;
646 case APIC_DEST_SELF: 637 case APIC_DEST_SELF:
647 result = (target == source); 638 return target == source;
648 break;
649 case APIC_DEST_ALLINC: 639 case APIC_DEST_ALLINC:
650 result = 1; 640 return true;
651 break;
652 case APIC_DEST_ALLBUT: 641 case APIC_DEST_ALLBUT:
653 result = (target != source); 642 return target != source;
654 break;
655 default: 643 default:
656 apic_debug("kvm: apic: Bad dest shorthand value %x\n", 644 apic_debug("kvm: apic: Bad dest shorthand value %x\n",
657 short_hand); 645 short_hand);
658 break; 646 return false;
659 } 647 }
660
661 return result;
662} 648}
663 649
664bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src, 650bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,