aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-08-24 04:10:17 -0400
committerAvi Kivity <avi@redhat.com>2009-12-03 02:32:06 -0500
commit851ba6922ac575b749f63dee0ae072808163ba6a (patch)
tree665111285e65fea316ce6614f1208261a255fb70 /arch/x86/kvm/x86.c
parentd8769fedd4e8323d8afea9a1b2bdebff4f1d2d37 (diff)
KVM: Don't pass kvm_run arguments
They're just copies of vcpu->run, which is readily accessible. Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index ae07d261527c..1687d12b122a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2757,13 +2757,13 @@ static void cache_all_regs(struct kvm_vcpu *vcpu)
2757} 2757}
2758 2758
2759int emulate_instruction(struct kvm_vcpu *vcpu, 2759int emulate_instruction(struct kvm_vcpu *vcpu,
2760 struct kvm_run *run,
2761 unsigned long cr2, 2760 unsigned long cr2,
2762 u16 error_code, 2761 u16 error_code,
2763 int emulation_type) 2762 int emulation_type)
2764{ 2763{
2765 int r, shadow_mask; 2764 int r, shadow_mask;
2766 struct decode_cache *c; 2765 struct decode_cache *c;
2766 struct kvm_run *run = vcpu->run;
2767 2767
2768 kvm_clear_exception_queue(vcpu); 2768 kvm_clear_exception_queue(vcpu);
2769 vcpu->arch.mmio_fault_cr2 = cr2; 2769 vcpu->arch.mmio_fault_cr2 = cr2;
@@ -2969,8 +2969,7 @@ static int pio_string_write(struct kvm_vcpu *vcpu)
2969 return r; 2969 return r;
2970} 2970}
2971 2971
2972int kvm_emulate_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in, 2972int kvm_emulate_pio(struct kvm_vcpu *vcpu, int in, int size, unsigned port)
2973 int size, unsigned port)
2974{ 2973{
2975 unsigned long val; 2974 unsigned long val;
2976 2975
@@ -2999,7 +2998,7 @@ int kvm_emulate_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in,
2999} 2998}
3000EXPORT_SYMBOL_GPL(kvm_emulate_pio); 2999EXPORT_SYMBOL_GPL(kvm_emulate_pio);
3001 3000
3002int kvm_emulate_pio_string(struct kvm_vcpu *vcpu, struct kvm_run *run, int in, 3001int kvm_emulate_pio_string(struct kvm_vcpu *vcpu, int in,
3003 int size, unsigned long count, int down, 3002 int size, unsigned long count, int down,
3004 gva_t address, int rep, unsigned port) 3003 gva_t address, int rep, unsigned port)
3005{ 3004{
@@ -3453,17 +3452,17 @@ EXPORT_SYMBOL_GPL(kvm_emulate_cpuid);
3453 * 3452 *
3454 * No need to exit to userspace if we already have an interrupt queued. 3453 * No need to exit to userspace if we already have an interrupt queued.
3455 */ 3454 */
3456static int dm_request_for_irq_injection(struct kvm_vcpu *vcpu, 3455static int dm_request_for_irq_injection(struct kvm_vcpu *vcpu)
3457 struct kvm_run *kvm_run)
3458{ 3456{
3459 return (!irqchip_in_kernel(vcpu->kvm) && !kvm_cpu_has_interrupt(vcpu) && 3457 return (!irqchip_in_kernel(vcpu->kvm) && !kvm_cpu_has_interrupt(vcpu) &&
3460 kvm_run->request_interrupt_window && 3458 vcpu->run->request_interrupt_window &&
3461 kvm_arch_interrupt_allowed(vcpu)); 3459 kvm_arch_interrupt_allowed(vcpu));
3462} 3460}
3463 3461
3464static void post_kvm_run_save(struct kvm_vcpu *vcpu, 3462static void post_kvm_run_save(struct kvm_vcpu *vcpu)
3465 struct kvm_run *kvm_run)
3466{ 3463{
3464 struct kvm_run *kvm_run = vcpu->run;
3465
3467 kvm_run->if_flag = (kvm_x86_ops->get_rflags(vcpu) & X86_EFLAGS_IF) != 0; 3466 kvm_run->if_flag = (kvm_x86_ops->get_rflags(vcpu) & X86_EFLAGS_IF) != 0;
3468 kvm_run->cr8 = kvm_get_cr8(vcpu); 3467 kvm_run->cr8 = kvm_get_cr8(vcpu);
3469 kvm_run->apic_base = kvm_get_apic_base(vcpu); 3468 kvm_run->apic_base = kvm_get_apic_base(vcpu);
@@ -3525,7 +3524,7 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu)
3525 kvm_x86_ops->update_cr8_intercept(vcpu, tpr, max_irr); 3524 kvm_x86_ops->update_cr8_intercept(vcpu, tpr, max_irr);
3526} 3525}
3527 3526
3528static void inject_pending_event(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 3527static void inject_pending_event(struct kvm_vcpu *vcpu)
3529{ 3528{
3530 /* try to reinject previous events if any */ 3529 /* try to reinject previous events if any */
3531 if (vcpu->arch.exception.pending) { 3530 if (vcpu->arch.exception.pending) {
@@ -3561,11 +3560,11 @@ static void inject_pending_event(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3561 } 3560 }
3562} 3561}
3563 3562
3564static int vcpu_enter_guest(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 3563static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
3565{ 3564{
3566 int r; 3565 int r;
3567 bool req_int_win = !irqchip_in_kernel(vcpu->kvm) && 3566 bool req_int_win = !irqchip_in_kernel(vcpu->kvm) &&
3568 kvm_run->request_interrupt_window; 3567 vcpu->run->request_interrupt_window;
3569 3568
3570 if (vcpu->requests) 3569 if (vcpu->requests)
3571 if (test_and_clear_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests)) 3570 if (test_and_clear_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests))
@@ -3586,12 +3585,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3586 kvm_x86_ops->tlb_flush(vcpu); 3585 kvm_x86_ops->tlb_flush(vcpu);
3587 if (test_and_clear_bit(KVM_REQ_REPORT_TPR_ACCESS, 3586 if (test_and_clear_bit(KVM_REQ_REPORT_TPR_ACCESS,
3588 &vcpu->requests)) { 3587 &vcpu->requests)) {
3589 kvm_run->exit_reason = KVM_EXIT_TPR_ACCESS; 3588 vcpu->run->exit_reason = KVM_EXIT_TPR_ACCESS;
3590 r = 0; 3589 r = 0;
3591 goto out; 3590 goto out;
3592 } 3591 }
3593 if (test_and_clear_bit(KVM_REQ_TRIPLE_FAULT, &vcpu->requests)) { 3592 if (test_and_clear_bit(KVM_REQ_TRIPLE_FAULT, &vcpu->requests)) {
3594 kvm_run->exit_reason = KVM_EXIT_SHUTDOWN; 3593 vcpu->run->exit_reason = KVM_EXIT_SHUTDOWN;
3595 r = 0; 3594 r = 0;
3596 goto out; 3595 goto out;
3597 } 3596 }
@@ -3615,7 +3614,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3615 goto out; 3614 goto out;
3616 } 3615 }
3617 3616
3618 inject_pending_event(vcpu, kvm_run); 3617 inject_pending_event(vcpu);
3619 3618
3620 /* enable NMI/IRQ window open exits if needed */ 3619 /* enable NMI/IRQ window open exits if needed */
3621 if (vcpu->arch.nmi_pending) 3620 if (vcpu->arch.nmi_pending)
@@ -3641,7 +3640,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3641 } 3640 }
3642 3641
3643 trace_kvm_entry(vcpu->vcpu_id); 3642 trace_kvm_entry(vcpu->vcpu_id);
3644 kvm_x86_ops->run(vcpu, kvm_run); 3643 kvm_x86_ops->run(vcpu);
3645 3644
3646 if (unlikely(vcpu->arch.switch_db_regs || test_thread_flag(TIF_DEBUG))) { 3645 if (unlikely(vcpu->arch.switch_db_regs || test_thread_flag(TIF_DEBUG))) {
3647 set_debugreg(current->thread.debugreg0, 0); 3646 set_debugreg(current->thread.debugreg0, 0);
@@ -3682,13 +3681,13 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3682 3681
3683 kvm_lapic_sync_from_vapic(vcpu); 3682 kvm_lapic_sync_from_vapic(vcpu);
3684 3683
3685 r = kvm_x86_ops->handle_exit(kvm_run, vcpu); 3684 r = kvm_x86_ops->handle_exit(vcpu);
3686out: 3685out:
3687 return r; 3686 return r;
3688} 3687}
3689 3688
3690 3689
3691static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 3690static int __vcpu_run(struct kvm_vcpu *vcpu)
3692{ 3691{
3693 int r; 3692 int r;
3694 3693
@@ -3708,7 +3707,7 @@ static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3708 r = 1; 3707 r = 1;
3709 while (r > 0) { 3708 while (r > 0) {
3710 if (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE) 3709 if (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE)
3711 r = vcpu_enter_guest(vcpu, kvm_run); 3710 r = vcpu_enter_guest(vcpu);
3712 else { 3711 else {
3713 up_read(&vcpu->kvm->slots_lock); 3712 up_read(&vcpu->kvm->slots_lock);
3714 kvm_vcpu_block(vcpu); 3713 kvm_vcpu_block(vcpu);
@@ -3736,14 +3735,14 @@ static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3736 if (kvm_cpu_has_pending_timer(vcpu)) 3735 if (kvm_cpu_has_pending_timer(vcpu))
3737 kvm_inject_pending_timer_irqs(vcpu); 3736 kvm_inject_pending_timer_irqs(vcpu);
3738 3737
3739 if (dm_request_for_irq_injection(vcpu, kvm_run)) { 3738 if (dm_request_for_irq_injection(vcpu)) {
3740 r = -EINTR; 3739 r = -EINTR;
3741 kvm_run->exit_reason = KVM_EXIT_INTR; 3740 vcpu->run->exit_reason = KVM_EXIT_INTR;
3742 ++vcpu->stat.request_irq_exits; 3741 ++vcpu->stat.request_irq_exits;
3743 } 3742 }
3744 if (signal_pending(current)) { 3743 if (signal_pending(current)) {
3745 r = -EINTR; 3744 r = -EINTR;
3746 kvm_run->exit_reason = KVM_EXIT_INTR; 3745 vcpu->run->exit_reason = KVM_EXIT_INTR;
3747 ++vcpu->stat.signal_exits; 3746 ++vcpu->stat.signal_exits;
3748 } 3747 }
3749 if (need_resched()) { 3748 if (need_resched()) {
@@ -3754,7 +3753,7 @@ static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3754 } 3753 }
3755 3754
3756 up_read(&vcpu->kvm->slots_lock); 3755 up_read(&vcpu->kvm->slots_lock);
3757 post_kvm_run_save(vcpu, kvm_run); 3756 post_kvm_run_save(vcpu);
3758 3757
3759 vapic_exit(vcpu); 3758 vapic_exit(vcpu);
3760 3759
@@ -3794,8 +3793,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3794 vcpu->mmio_needed = 0; 3793 vcpu->mmio_needed = 0;
3795 3794
3796 down_read(&vcpu->kvm->slots_lock); 3795 down_read(&vcpu->kvm->slots_lock);
3797 r = emulate_instruction(vcpu, kvm_run, 3796 r = emulate_instruction(vcpu, vcpu->arch.mmio_fault_cr2, 0,
3798 vcpu->arch.mmio_fault_cr2, 0,
3799 EMULTYPE_NO_DECODE); 3797 EMULTYPE_NO_DECODE);
3800 up_read(&vcpu->kvm->slots_lock); 3798 up_read(&vcpu->kvm->slots_lock);
3801 if (r == EMULATE_DO_MMIO) { 3799 if (r == EMULATE_DO_MMIO) {
@@ -3811,7 +3809,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3811 kvm_register_write(vcpu, VCPU_REGS_RAX, 3809 kvm_register_write(vcpu, VCPU_REGS_RAX,
3812 kvm_run->hypercall.ret); 3810 kvm_run->hypercall.ret);
3813 3811
3814 r = __vcpu_run(vcpu, kvm_run); 3812 r = __vcpu_run(vcpu);
3815 3813
3816out: 3814out:
3817 if (vcpu->sigset_active) 3815 if (vcpu->sigset_active)