aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYang Zhang <yang.z.zhang@Intel.com>2013-04-06 20:25:18 -0400
committerGleb Natapov <gleb@redhat.com>2013-04-07 06:55:49 -0400
commit44944d4d28948c71b110b09a2e924e505cd39e8b (patch)
tree6d0b96165c11414c98edd14501f016627687d7dd
parent99437a2782730ec8c7e6cfebb6143d00b091e4a8 (diff)
KVM: Call kvm_apic_match_dest() to check destination vcpu
For a given vcpu, kvm_apic_match_dest() will tell you whether the vcpu in the destination list quickly. Drop kvm_calculate_eoi_exitmap() and use kvm_apic_match_dest() instead. Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com> Signed-off-by: Gleb Natapov <gleb@redhat.com>
-rw-r--r--arch/x86/kvm/lapic.c47
-rw-r--r--arch/x86/kvm/lapic.h4
-rw-r--r--virt/kvm/ioapic.c9
3 files changed, 3 insertions, 57 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index a8e9369f41c5..e2274745ab3d 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -145,53 +145,6 @@ static inline int kvm_apic_id(struct kvm_lapic *apic)
145 return (kvm_apic_get_reg(apic, APIC_ID) >> 24) & 0xff; 145 return (kvm_apic_get_reg(apic, APIC_ID) >> 24) & 0xff;
146} 146}
147 147
148void kvm_calculate_eoi_exitmap(struct kvm_vcpu *vcpu,
149 struct kvm_lapic_irq *irq,
150 u64 *eoi_exit_bitmap)
151{
152 struct kvm_lapic **dst;
153 struct kvm_apic_map *map;
154 unsigned long bitmap = 1;
155 int i;
156
157 rcu_read_lock();
158 map = rcu_dereference(vcpu->kvm->arch.apic_map);
159
160 if (unlikely(!map)) {
161 __set_bit(irq->vector, (unsigned long *)eoi_exit_bitmap);
162 goto out;
163 }
164
165 if (irq->dest_mode == 0) { /* physical mode */
166 if (irq->delivery_mode == APIC_DM_LOWEST ||
167 irq->dest_id == 0xff) {
168 __set_bit(irq->vector,
169 (unsigned long *)eoi_exit_bitmap);
170 goto out;
171 }
172 dst = &map->phys_map[irq->dest_id & 0xff];
173 } else {
174 u32 mda = irq->dest_id << (32 - map->ldr_bits);
175
176 dst = map->logical_map[apic_cluster_id(map, mda)];
177
178 bitmap = apic_logical_id(map, mda);
179 }
180
181 for_each_set_bit(i, &bitmap, 16) {
182 if (!dst[i])
183 continue;
184 if (dst[i]->vcpu == vcpu) {
185 __set_bit(irq->vector,
186 (unsigned long *)eoi_exit_bitmap);
187 break;
188 }
189 }
190
191out:
192 rcu_read_unlock();
193}
194
195static void recalculate_apic_map(struct kvm *kvm) 148static void recalculate_apic_map(struct kvm *kvm)
196{ 149{
197 struct kvm_apic_map *new, *old = NULL; 150 struct kvm_apic_map *new, *old = NULL;
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index 2c721b986eec..baa20cfb95ae 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
@@ -160,10 +160,6 @@ static inline u16 apic_logical_id(struct kvm_apic_map *map, u32 ldr)
160 return ldr & map->lid_mask; 160 return ldr & map->lid_mask;
161} 161}
162 162
163void kvm_calculate_eoi_exitmap(struct kvm_vcpu *vcpu,
164 struct kvm_lapic_irq *irq,
165 u64 *eoi_bitmap);
166
167static inline bool kvm_apic_has_events(struct kvm_vcpu *vcpu) 163static inline bool kvm_apic_has_events(struct kvm_vcpu *vcpu)
168{ 164{
169 return vcpu->arch.apic->pending_events; 165 return vcpu->arch.apic->pending_events;
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index 5ba005c00e2f..914cbe027d06 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -124,7 +124,6 @@ void kvm_ioapic_calculate_eoi_exitmap(struct kvm_vcpu *vcpu,
124{ 124{
125 struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic; 125 struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic;
126 union kvm_ioapic_redirect_entry *e; 126 union kvm_ioapic_redirect_entry *e;
127 struct kvm_lapic_irq irqe;
128 int index; 127 int index;
129 128
130 spin_lock(&ioapic->lock); 129 spin_lock(&ioapic->lock);
@@ -135,11 +134,9 @@ void kvm_ioapic_calculate_eoi_exitmap(struct kvm_vcpu *vcpu,
135 (e->fields.trig_mode == IOAPIC_LEVEL_TRIG || 134 (e->fields.trig_mode == IOAPIC_LEVEL_TRIG ||
136 kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC, 135 kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC,
137 index))) { 136 index))) {
138 irqe.dest_id = e->fields.dest_id; 137 if (kvm_apic_match_dest(vcpu, NULL, 0,
139 irqe.vector = e->fields.vector; 138 e->fields.dest_id, e->fields.dest_mode))
140 irqe.dest_mode = e->fields.dest_mode; 139 __set_bit(e->fields.vector, (unsigned long *)eoi_exit_bitmap);
141 irqe.delivery_mode = e->fields.delivery_mode << 8;
142 kvm_calculate_eoi_exitmap(vcpu, &irqe, eoi_exit_bitmap);
143 } 140 }
144 } 141 }
145 spin_unlock(&ioapic->lock); 142 spin_unlock(&ioapic->lock);