/*1* irq.c: API for in kernel interrupt controller2* Copyright (c) 2007, Intel Corporation.3* Copyright 2009 Red Hat, Inc. and/or its affiliates.4*5* This program is free software; you can redistribute it and/or modify it6* under the terms and conditions of the GNU General Public License,7* version 2, as published by the Free Software Foundation.8*9* This program is distributed in the hope it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for12* more details.13*14* You should have received a copy of the GNU General Public License along with15* this program; if not, write to the Free Software Foundation, Inc., 59 Temple16* Place - Suite 330, Boston, MA 02111-1307 USA.17* Authors:18* Yaozu (Eddie) Dong <[email protected]>19*20*/2122#include <linux/module.h>23#include <linux/kvm_host.h>2425#include "irq.h"26#include "i8254.h"27#include "x86.h"2829/*30* check if there are pending timer events31* to be processed.32*/33int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)34{35return apic_has_pending_timer(vcpu);36}37EXPORT_SYMBOL(kvm_cpu_has_pending_timer);3839/*40* check if there is pending interrupt without41* intack.42*/43int kvm_cpu_has_interrupt(struct kvm_vcpu *v)44{45struct kvm_pic *s;4647if (!irqchip_in_kernel(v->kvm))48return v->arch.interrupt.pending;4950if (kvm_apic_has_interrupt(v) == -1) { /* LAPIC */51if (kvm_apic_accept_pic_intr(v)) {52s = pic_irqchip(v->kvm); /* PIC */53return s->output;54} else55return 0;56}57return 1;58}59EXPORT_SYMBOL_GPL(kvm_cpu_has_interrupt);6061/*62* Read pending interrupt vector and intack.63*/64int kvm_cpu_get_interrupt(struct kvm_vcpu *v)65{66struct kvm_pic *s;67int vector;6869if (!irqchip_in_kernel(v->kvm))70return v->arch.interrupt.nr;7172vector = kvm_get_apic_interrupt(v); /* APIC */73if (vector == -1) {74if (kvm_apic_accept_pic_intr(v)) {75s = pic_irqchip(v->kvm);76s->output = 0; /* PIC */77vector = kvm_pic_read_irq(v->kvm);78}79}80return vector;81}82EXPORT_SYMBOL_GPL(kvm_cpu_get_interrupt);8384void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu)85{86kvm_inject_apic_timer_irqs(vcpu);87/* TODO: PIT, RTC etc. */88}89EXPORT_SYMBOL_GPL(kvm_inject_pending_timer_irqs);9091void __kvm_migrate_timers(struct kvm_vcpu *vcpu)92{93__kvm_migrate_apic_timer(vcpu);94__kvm_migrate_pit_timer(vcpu);95}969798