lapic.c (03e075b38e6cd25267c8d6e2797fa4537ca3348d) | lapic.c (520040146a0af36f7875ec06b58f44b19a0edf53) |
---|---|
1 2/* 3 * Local APIC virtualization 4 * 5 * Copyright (C) 2006 Qumranet, Inc. 6 * Copyright (C) 2007 Novell 7 * Copyright (C) 2007 Intel 8 * Copyright 2009 Red Hat, Inc. and/or its affiliates. --- 661 unchanged lines hidden (view full) --- 670 return target != source; 671 default: 672 apic_debug("kvm: apic: Bad dest shorthand value %x\n", 673 short_hand); 674 return false; 675 } 676} 677 | 1 2/* 3 * Local APIC virtualization 4 * 5 * Copyright (C) 2006 Qumranet, Inc. 6 * Copyright (C) 2007 Novell 7 * Copyright (C) 2007 Intel 8 * Copyright 2009 Red Hat, Inc. and/or its affiliates. --- 661 unchanged lines hidden (view full) --- 670 return target != source; 671 default: 672 apic_debug("kvm: apic: Bad dest shorthand value %x\n", 673 short_hand); 674 return false; 675 } 676} 677 |
678int kvm_vector_to_index(u32 vector, u32 dest_vcpus, 679 const unsigned long *bitmap, u32 bitmap_size) 680{ 681 u32 mod; 682 int i, idx = -1; 683 684 mod = vector % dest_vcpus; 685 686 for (i = 0; i <= mod; i++) { 687 idx = find_next_bit(bitmap, bitmap_size, idx + 1); 688 BUG_ON(idx == bitmap_size); 689 } 690 691 return idx; 692} 693 |
|
678bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src, 679 struct kvm_lapic_irq *irq, int *r, unsigned long *dest_map) 680{ 681 struct kvm_apic_map *map; 682 unsigned long bitmap = 1; 683 struct kvm_lapic **dst; 684 int i; 685 bool ret, x2apic_ipi; --- 36 unchanged lines hidden (view full) --- 722 723 apic_logical_id(map, irq->dest_id, &cid, (u16 *)&bitmap); 724 725 if (cid >= ARRAY_SIZE(map->logical_map)) 726 goto out; 727 728 dst = map->logical_map[cid]; 729 | 694bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src, 695 struct kvm_lapic_irq *irq, int *r, unsigned long *dest_map) 696{ 697 struct kvm_apic_map *map; 698 unsigned long bitmap = 1; 699 struct kvm_lapic **dst; 700 int i; 701 bool ret, x2apic_ipi; --- 36 unchanged lines hidden (view full) --- 738 739 apic_logical_id(map, irq->dest_id, &cid, (u16 *)&bitmap); 740 741 if (cid >= ARRAY_SIZE(map->logical_map)) 742 goto out; 743 744 dst = map->logical_map[cid]; 745 |
730 if (kvm_lowest_prio_delivery(irq)) { | 746 if (!kvm_lowest_prio_delivery(irq)) 747 goto set_irq; 748 749 if (!kvm_vector_hashing_enabled()) { |
731 int l = -1; 732 for_each_set_bit(i, &bitmap, 16) { 733 if (!dst[i]) 734 continue; 735 if (l < 0) 736 l = i; | 750 int l = -1; 751 for_each_set_bit(i, &bitmap, 16) { 752 if (!dst[i]) 753 continue; 754 if (l < 0) 755 l = i; |
737 else if (kvm_apic_compare_prio(dst[i]->vcpu, dst[l]->vcpu) < 0) | 756 else if (kvm_apic_compare_prio(dst[i]->vcpu, 757 dst[l]->vcpu) < 0) |
738 l = i; 739 } | 758 l = i; 759 } |
740 | |
741 bitmap = (l >= 0) ? 1 << l : 0; | 760 bitmap = (l >= 0) ? 1 << l : 0; |
761 } else { 762 int idx; 763 unsigned int dest_vcpus; 764 765 dest_vcpus = hweight16(bitmap); 766 if (dest_vcpus == 0) 767 goto out; 768 769 idx = kvm_vector_to_index(irq->vector, 770 dest_vcpus, &bitmap, 16); 771 772 /* 773 * We may find a hardware disabled LAPIC here, if that 774 * is the case, print out a error message once for each 775 * guest and return. 776 */ 777 if (!dst[idx] && !kvm->arch.disabled_lapic_found) { 778 kvm->arch.disabled_lapic_found = true; 779 printk(KERN_INFO 780 "Disabled LAPIC found during irq injection\n"); 781 goto out; 782 } 783 784 bitmap = (idx >= 0) ? 1 << idx : 0; |
|
742 } 743 } 744 | 785 } 786 } 787 |
788set_irq: |
|
745 for_each_set_bit(i, &bitmap, 16) { 746 if (!dst[i]) 747 continue; 748 if (*r < 0) 749 *r = 0; 750 *r += kvm_apic_set_irq(dst[i]->vcpu, irq, dest_map); 751 } 752out: --- 1443 unchanged lines hidden --- | 789 for_each_set_bit(i, &bitmap, 16) { 790 if (!dst[i]) 791 continue; 792 if (*r < 0) 793 *r = 0; 794 *r += kvm_apic_set_irq(dst[i]->vcpu, irq, dest_map); 795 } 796out: --- 1443 unchanged lines hidden --- |