Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * KVM/MIPS: Interrupt delivery
0007  *
0008  * Copyright (C) 2012  MIPS Technologies, Inc.  All rights reserved.
0009  * Authors: Sanjay Lal <sanjayl@kymasys.com>
0010  */
0011 
0012 #include <linux/errno.h>
0013 #include <linux/err.h>
0014 #include <linux/vmalloc.h>
0015 #include <linux/fs.h>
0016 #include <linux/memblock.h>
0017 #include <asm/page.h>
0018 #include <asm/cacheflush.h>
0019 
0020 #include <linux/kvm_host.h>
0021 
0022 #include "interrupt.h"
0023 
0024 void kvm_mips_deliver_interrupts(struct kvm_vcpu *vcpu, u32 cause)
0025 {
0026     unsigned long *pending = &vcpu->arch.pending_exceptions;
0027     unsigned long *pending_clr = &vcpu->arch.pending_exceptions_clr;
0028     unsigned int priority;
0029 
0030     if (!(*pending) && !(*pending_clr))
0031         return;
0032 
0033     priority = __ffs(*pending_clr);
0034     while (priority <= MIPS_EXC_MAX) {
0035         kvm_mips_callbacks->irq_clear(vcpu, priority, cause);
0036 
0037         priority = find_next_bit(pending_clr,
0038                      BITS_PER_BYTE * sizeof(*pending_clr),
0039                      priority + 1);
0040     }
0041 
0042     priority = __ffs(*pending);
0043     while (priority <= MIPS_EXC_MAX) {
0044         kvm_mips_callbacks->irq_deliver(vcpu, priority, cause);
0045 
0046         priority = find_next_bit(pending,
0047                      BITS_PER_BYTE * sizeof(*pending),
0048                      priority + 1);
0049     }
0050 
0051 }
0052 
0053 int kvm_mips_pending_timer(struct kvm_vcpu *vcpu)
0054 {
0055     return test_bit(MIPS_EXC_INT_TIMER, &vcpu->arch.pending_exceptions);
0056 }