aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2012-04-19 07:06:29 -0400
committerAvi Kivity <avi@redhat.com>2012-04-24 09:36:18 -0400
commit413837714232b3a4c0705e915d8af75ad521d083 (patch)
tree8caabcc3565c5482e6d8da921ed2b166c0c1a230 /arch
parent07975ad3b30579ca27d880491ad992326b930c63 (diff)
KVM: Introduce bitmask for apic attention reasons
The patch introduces a bitmap that will hold reasons apic should be checked during vmexit. This is in a preparation for vp eoi patch that will add one more check on vmexit. With the bitmap we can do if(apic_attention) to check everything simultaneously which will add zero overhead on the fast path. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/kvm_host.h4
-rw-r--r--arch/x86/kvm/lapic.c12
2 files changed, 11 insertions, 5 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index f624ca72ea24..69e39bc7e36f 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -172,6 +172,9 @@ enum {
172#define DR7_FIXED_1 0x00000400 172#define DR7_FIXED_1 0x00000400
173#define DR7_VOLATILE 0xffff23ff 173#define DR7_VOLATILE 0xffff23ff
174 174
175/* apic attention bits */
176#define KVM_APIC_CHECK_VAPIC 0
177
175/* 178/*
176 * We don't want allocation failures within the mmu code, so we preallocate 179 * We don't want allocation failures within the mmu code, so we preallocate
177 * enough memory for a single page fault in a cache. 180 * enough memory for a single page fault in a cache.
@@ -337,6 +340,7 @@ struct kvm_vcpu_arch {
337 u64 efer; 340 u64 efer;
338 u64 apic_base; 341 u64 apic_base;
339 struct kvm_lapic *apic; /* kernel irqchip context */ 342 struct kvm_lapic *apic; /* kernel irqchip context */
343 unsigned long apic_attention;
340 int32_t apic_arb_prio; 344 int32_t apic_arb_prio;
341 int mp_state; 345 int mp_state;
342 int sipi_vector; 346 int sipi_vector;
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 992b4eaae684..93c15743f1ee 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1088,6 +1088,7 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu)
1088 apic_update_ppr(apic); 1088 apic_update_ppr(apic);
1089 1089
1090 vcpu->arch.apic_arb_prio = 0; 1090 vcpu->arch.apic_arb_prio = 0;
1091 vcpu->arch.apic_attention = 0;
1091 1092
1092 apic_debug(KERN_INFO "%s: vcpu=%p, id=%d, base_msr=" 1093 apic_debug(KERN_INFO "%s: vcpu=%p, id=%d, base_msr="
1093 "0x%016" PRIx64 ", base_address=0x%0lx.\n", __func__, 1094 "0x%016" PRIx64 ", base_address=0x%0lx.\n", __func__,
@@ -1287,7 +1288,7 @@ void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu)
1287 u32 data; 1288 u32 data;
1288 void *vapic; 1289 void *vapic;
1289 1290
1290 if (!irqchip_in_kernel(vcpu->kvm) || !vcpu->arch.apic->vapic_addr) 1291 if (!test_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention))
1291 return; 1292 return;
1292 1293
1293 vapic = kmap_atomic(vcpu->arch.apic->vapic_page); 1294 vapic = kmap_atomic(vcpu->arch.apic->vapic_page);
@@ -1304,7 +1305,7 @@ void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu)
1304 struct kvm_lapic *apic; 1305 struct kvm_lapic *apic;
1305 void *vapic; 1306 void *vapic;
1306 1307
1307 if (!irqchip_in_kernel(vcpu->kvm) || !vcpu->arch.apic->vapic_addr) 1308 if (!test_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention))
1308 return; 1309 return;
1309 1310
1310 apic = vcpu->arch.apic; 1311 apic = vcpu->arch.apic;
@@ -1324,10 +1325,11 @@ void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu)
1324 1325
1325void kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr) 1326void kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr)
1326{ 1327{
1327 if (!irqchip_in_kernel(vcpu->kvm))
1328 return;
1329
1330 vcpu->arch.apic->vapic_addr = vapic_addr; 1328 vcpu->arch.apic->vapic_addr = vapic_addr;
1329 if (vapic_addr)
1330 __set_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention);
1331 else
1332 __clear_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention);
1331} 1333}
1332 1334
1333int kvm_x2apic_msr_write(struct kvm_vcpu *vcpu, u32 msr, u64 data) 1335int kvm_x2apic_msr_write(struct kvm_vcpu *vcpu, u32 msr, u64 data)