Commit 9e4aabe2 authored by Joerg Roedel's avatar Joerg Roedel Committed by Paolo Bonzini

kvm: x86: Convert ioapic->rtc_status.dest_map to a struct

Currently this is a bitmap which tracks which CPUs we expect
an EOI from. Move this bitmap to a struct so that we can
track additional information there.
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 61ec84f1
...@@ -94,7 +94,7 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic, ...@@ -94,7 +94,7 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic) static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic)
{ {
ioapic->rtc_status.pending_eoi = 0; ioapic->rtc_status.pending_eoi = 0;
bitmap_zero(ioapic->rtc_status.dest_map, KVM_MAX_VCPUS); bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPUS);
} }
static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic); static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic);
...@@ -117,16 +117,16 @@ static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu *vcpu) ...@@ -117,16 +117,16 @@ static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu *vcpu)
return; return;
new_val = kvm_apic_pending_eoi(vcpu, e->fields.vector); new_val = kvm_apic_pending_eoi(vcpu, e->fields.vector);
old_val = test_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map); old_val = test_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map.map);
if (new_val == old_val) if (new_val == old_val)
return; return;
if (new_val) { if (new_val) {
__set_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map); __set_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map.map);
ioapic->rtc_status.pending_eoi++; ioapic->rtc_status.pending_eoi++;
} else { } else {
__clear_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map); __clear_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map.map);
ioapic->rtc_status.pending_eoi--; ioapic->rtc_status.pending_eoi--;
rtc_status_pending_eoi_check_valid(ioapic); rtc_status_pending_eoi_check_valid(ioapic);
} }
...@@ -156,7 +156,8 @@ static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic) ...@@ -156,7 +156,8 @@ static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic)
static void rtc_irq_eoi(struct kvm_ioapic *ioapic, struct kvm_vcpu *vcpu) static void rtc_irq_eoi(struct kvm_ioapic *ioapic, struct kvm_vcpu *vcpu)
{ {
if (test_and_clear_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map)) { if (test_and_clear_bit(vcpu->vcpu_id,
ioapic->rtc_status.dest_map.map)) {
--ioapic->rtc_status.pending_eoi; --ioapic->rtc_status.pending_eoi;
rtc_status_pending_eoi_check_valid(ioapic); rtc_status_pending_eoi_check_valid(ioapic);
} }
...@@ -346,7 +347,7 @@ static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status) ...@@ -346,7 +347,7 @@ static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status)
*/ */
BUG_ON(ioapic->rtc_status.pending_eoi != 0); BUG_ON(ioapic->rtc_status.pending_eoi != 0);
ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe,
ioapic->rtc_status.dest_map); &ioapic->rtc_status.dest_map);
ioapic->rtc_status.pending_eoi = (ret < 0 ? 0 : ret); ioapic->rtc_status.pending_eoi = (ret < 0 ? 0 : ret);
} else } else
ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, NULL); ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, NULL);
......
...@@ -40,9 +40,14 @@ struct kvm_vcpu; ...@@ -40,9 +40,14 @@ struct kvm_vcpu;
#define RTC_GSI -1U #define RTC_GSI -1U
#endif #endif
struct dest_map {
DECLARE_BITMAP(map, KVM_MAX_VCPUS);
};
struct rtc_status { struct rtc_status {
int pending_eoi; int pending_eoi;
DECLARE_BITMAP(dest_map, KVM_MAX_VCPUS); struct dest_map dest_map;
}; };
union kvm_ioapic_redirect_entry { union kvm_ioapic_redirect_entry {
...@@ -118,7 +123,8 @@ int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int irq_source_id, ...@@ -118,7 +123,8 @@ int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int irq_source_id,
int level, bool line_status); int level, bool line_status);
void kvm_ioapic_clear_all(struct kvm_ioapic *ioapic, int irq_source_id); void kvm_ioapic_clear_all(struct kvm_ioapic *ioapic, int irq_source_id);
int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
struct kvm_lapic_irq *irq, unsigned long *dest_map); struct kvm_lapic_irq *irq,
struct dest_map *dest_map);
int kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); int kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state);
int kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); int kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state);
void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu,
......
...@@ -54,7 +54,7 @@ static int kvm_set_ioapic_irq(struct kvm_kernel_irq_routing_entry *e, ...@@ -54,7 +54,7 @@ static int kvm_set_ioapic_irq(struct kvm_kernel_irq_routing_entry *e,
} }
int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
struct kvm_lapic_irq *irq, unsigned long *dest_map) struct kvm_lapic_irq *irq, struct dest_map *dest_map)
{ {
int i, r = -1; int i, r = -1;
struct kvm_vcpu *vcpu, *lowest = NULL; struct kvm_vcpu *vcpu, *lowest = NULL;
......
...@@ -485,10 +485,10 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu) ...@@ -485,10 +485,10 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu)
static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
int vector, int level, int trig_mode, int vector, int level, int trig_mode,
unsigned long *dest_map); struct dest_map *dest_map);
int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq, int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq,
unsigned long *dest_map) struct dest_map *dest_map)
{ {
struct kvm_lapic *apic = vcpu->arch.apic; struct kvm_lapic *apic = vcpu->arch.apic;
...@@ -695,7 +695,7 @@ static void kvm_apic_disabled_lapic_found(struct kvm *kvm) ...@@ -695,7 +695,7 @@ static void kvm_apic_disabled_lapic_found(struct kvm *kvm)
} }
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,
struct kvm_lapic_irq *irq, int *r, unsigned long *dest_map) struct kvm_lapic_irq *irq, int *r, struct dest_map *dest_map)
{ {
struct kvm_apic_map *map; struct kvm_apic_map *map;
unsigned long bitmap = 1; unsigned long bitmap = 1;
...@@ -894,7 +894,7 @@ bool kvm_intr_is_single_vcpu_fast(struct kvm *kvm, struct kvm_lapic_irq *irq, ...@@ -894,7 +894,7 @@ bool kvm_intr_is_single_vcpu_fast(struct kvm *kvm, struct kvm_lapic_irq *irq,
*/ */
static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
int vector, int level, int trig_mode, int vector, int level, int trig_mode,
unsigned long *dest_map) struct dest_map *dest_map)
{ {
int result = 0; int result = 0;
struct kvm_vcpu *vcpu = apic->vcpu; struct kvm_vcpu *vcpu = apic->vcpu;
...@@ -915,7 +915,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, ...@@ -915,7 +915,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
result = 1; result = 1;
if (dest_map) if (dest_map)
__set_bit(vcpu->vcpu_id, dest_map); __set_bit(vcpu->vcpu_id, dest_map->map);
if (apic_test_vector(vector, apic->regs + APIC_TMR) != !!trig_mode) { if (apic_test_vector(vector, apic->regs + APIC_TMR) != !!trig_mode) {
if (trig_mode) if (trig_mode)
......
...@@ -42,6 +42,9 @@ struct kvm_lapic { ...@@ -42,6 +42,9 @@ struct kvm_lapic {
unsigned long pending_events; unsigned long pending_events;
unsigned int sipi_vector; unsigned int sipi_vector;
}; };
struct dest_map;
int kvm_create_lapic(struct kvm_vcpu *vcpu); int kvm_create_lapic(struct kvm_vcpu *vcpu);
void kvm_free_lapic(struct kvm_vcpu *vcpu); void kvm_free_lapic(struct kvm_vcpu *vcpu);
...@@ -60,11 +63,11 @@ void kvm_apic_set_version(struct kvm_vcpu *vcpu); ...@@ -60,11 +63,11 @@ void kvm_apic_set_version(struct kvm_vcpu *vcpu);
void __kvm_apic_update_irr(u32 *pir, void *regs); void __kvm_apic_update_irr(u32 *pir, void *regs);
void kvm_apic_update_irr(struct kvm_vcpu *vcpu, u32 *pir); void kvm_apic_update_irr(struct kvm_vcpu *vcpu, u32 *pir);
int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq, int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq,
unsigned long *dest_map); struct dest_map *dest_map);
int kvm_apic_local_deliver(struct kvm_lapic *apic, int lvt_type); int kvm_apic_local_deliver(struct kvm_lapic *apic, int lvt_type);
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,
struct kvm_lapic_irq *irq, int *r, unsigned long *dest_map); struct kvm_lapic_irq *irq, int *r, struct dest_map *dest_map);
u64 kvm_get_apic_base(struct kvm_vcpu *vcpu); u64 kvm_get_apic_base(struct kvm_vcpu *vcpu);
int kvm_set_apic_base(struct kvm_vcpu *vcpu, struct msr_data *msr_info); int kvm_set_apic_base(struct kvm_vcpu *vcpu, struct msr_data *msr_info);
......
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