diff options
Diffstat (limited to 'arch/x86/kvm/lapic.c')
-rw-r--r-- | arch/x86/kvm/lapic.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 77d8c0f4817..413f8973a85 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Copyright (C) 2006 Qumranet, Inc. | 5 | * Copyright (C) 2006 Qumranet, Inc. |
6 | * Copyright (C) 2007 Novell | 6 | * Copyright (C) 2007 Novell |
7 | * Copyright (C) 2007 Intel | 7 | * Copyright (C) 2007 Intel |
8 | * Copyright 2009 Red Hat, Inc. and/or its affilates. | 8 | * Copyright 2009 Red Hat, Inc. and/or its affiliates. |
9 | * | 9 | * |
10 | * Authors: | 10 | * Authors: |
11 | * Dor Laor <dor.laor@qumranet.com> | 11 | * Dor Laor <dor.laor@qumranet.com> |
@@ -259,9 +259,10 @@ static inline int apic_find_highest_isr(struct kvm_lapic *apic) | |||
259 | 259 | ||
260 | static void apic_update_ppr(struct kvm_lapic *apic) | 260 | static void apic_update_ppr(struct kvm_lapic *apic) |
261 | { | 261 | { |
262 | u32 tpr, isrv, ppr; | 262 | u32 tpr, isrv, ppr, old_ppr; |
263 | int isr; | 263 | int isr; |
264 | 264 | ||
265 | old_ppr = apic_get_reg(apic, APIC_PROCPRI); | ||
265 | tpr = apic_get_reg(apic, APIC_TASKPRI); | 266 | tpr = apic_get_reg(apic, APIC_TASKPRI); |
266 | isr = apic_find_highest_isr(apic); | 267 | isr = apic_find_highest_isr(apic); |
267 | isrv = (isr != -1) ? isr : 0; | 268 | isrv = (isr != -1) ? isr : 0; |
@@ -274,7 +275,10 @@ static void apic_update_ppr(struct kvm_lapic *apic) | |||
274 | apic_debug("vlapic %p, ppr 0x%x, isr 0x%x, isrv 0x%x", | 275 | apic_debug("vlapic %p, ppr 0x%x, isr 0x%x, isrv 0x%x", |
275 | apic, ppr, isr, isrv); | 276 | apic, ppr, isr, isrv); |
276 | 277 | ||
277 | apic_set_reg(apic, APIC_PROCPRI, ppr); | 278 | if (old_ppr != ppr) { |
279 | apic_set_reg(apic, APIC_PROCPRI, ppr); | ||
280 | kvm_make_request(KVM_REQ_EVENT, apic->vcpu); | ||
281 | } | ||
278 | } | 282 | } |
279 | 283 | ||
280 | static void apic_set_tpr(struct kvm_lapic *apic, u32 tpr) | 284 | static void apic_set_tpr(struct kvm_lapic *apic, u32 tpr) |
@@ -391,6 +395,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, | |||
391 | break; | 395 | break; |
392 | } | 396 | } |
393 | 397 | ||
398 | kvm_make_request(KVM_REQ_EVENT, vcpu); | ||
394 | kvm_vcpu_kick(vcpu); | 399 | kvm_vcpu_kick(vcpu); |
395 | break; | 400 | break; |
396 | 401 | ||
@@ -416,6 +421,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, | |||
416 | "INIT on a runnable vcpu %d\n", | 421 | "INIT on a runnable vcpu %d\n", |
417 | vcpu->vcpu_id); | 422 | vcpu->vcpu_id); |
418 | vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED; | 423 | vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED; |
424 | kvm_make_request(KVM_REQ_EVENT, vcpu); | ||
419 | kvm_vcpu_kick(vcpu); | 425 | kvm_vcpu_kick(vcpu); |
420 | } else { | 426 | } else { |
421 | apic_debug("Ignoring de-assert INIT to vcpu %d\n", | 427 | apic_debug("Ignoring de-assert INIT to vcpu %d\n", |
@@ -430,6 +436,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, | |||
430 | result = 1; | 436 | result = 1; |
431 | vcpu->arch.sipi_vector = vector; | 437 | vcpu->arch.sipi_vector = vector; |
432 | vcpu->arch.mp_state = KVM_MP_STATE_SIPI_RECEIVED; | 438 | vcpu->arch.mp_state = KVM_MP_STATE_SIPI_RECEIVED; |
439 | kvm_make_request(KVM_REQ_EVENT, vcpu); | ||
433 | kvm_vcpu_kick(vcpu); | 440 | kvm_vcpu_kick(vcpu); |
434 | } | 441 | } |
435 | break; | 442 | break; |
@@ -475,6 +482,7 @@ static void apic_set_eoi(struct kvm_lapic *apic) | |||
475 | trigger_mode = IOAPIC_EDGE_TRIG; | 482 | trigger_mode = IOAPIC_EDGE_TRIG; |
476 | if (!(apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI)) | 483 | if (!(apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI)) |
477 | kvm_ioapic_update_eoi(apic->vcpu->kvm, vector, trigger_mode); | 484 | kvm_ioapic_update_eoi(apic->vcpu->kvm, vector, trigger_mode); |
485 | kvm_make_request(KVM_REQ_EVENT, apic->vcpu); | ||
478 | } | 486 | } |
479 | 487 | ||
480 | static void apic_send_ipi(struct kvm_lapic *apic) | 488 | static void apic_send_ipi(struct kvm_lapic *apic) |
@@ -1056,14 +1064,13 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu) | |||
1056 | 1064 | ||
1057 | vcpu->arch.apic = apic; | 1065 | vcpu->arch.apic = apic; |
1058 | 1066 | ||
1059 | apic->regs_page = alloc_page(GFP_KERNEL); | 1067 | apic->regs_page = alloc_page(GFP_KERNEL|__GFP_ZERO); |
1060 | if (apic->regs_page == NULL) { | 1068 | if (apic->regs_page == NULL) { |
1061 | printk(KERN_ERR "malloc apic regs error for vcpu %x\n", | 1069 | printk(KERN_ERR "malloc apic regs error for vcpu %x\n", |
1062 | vcpu->vcpu_id); | 1070 | vcpu->vcpu_id); |
1063 | goto nomem_free_apic; | 1071 | goto nomem_free_apic; |
1064 | } | 1072 | } |
1065 | apic->regs = page_address(apic->regs_page); | 1073 | apic->regs = page_address(apic->regs_page); |
1066 | memset(apic->regs, 0, PAGE_SIZE); | ||
1067 | apic->vcpu = vcpu; | 1074 | apic->vcpu = vcpu; |
1068 | 1075 | ||
1069 | hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC, | 1076 | hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC, |
@@ -1152,6 +1159,7 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu) | |||
1152 | update_divide_count(apic); | 1159 | update_divide_count(apic); |
1153 | start_apic_timer(apic); | 1160 | start_apic_timer(apic); |
1154 | apic->irr_pending = true; | 1161 | apic->irr_pending = true; |
1162 | kvm_make_request(KVM_REQ_EVENT, vcpu); | ||
1155 | } | 1163 | } |
1156 | 1164 | ||
1157 | void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu) | 1165 | void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu) |