2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * KVM/MIPS: Interrupt delivery
8 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
9 * Authors: Sanjay Lal <sanjayl@kymasys.com>
12 #include <linux/errno.h>
13 #include <linux/err.h>
14 #include <linux/vmalloc.h>
16 #include <linux/memblock.h>
18 #include <asm/cacheflush.h>
20 #include <linux/kvm_host.h>
22 #include "interrupt.h"
24 void kvm_mips_deliver_interrupts(struct kvm_vcpu
*vcpu
, u32 cause
)
26 unsigned long *pending
= &vcpu
->arch
.pending_exceptions
;
27 unsigned long *pending_clr
= &vcpu
->arch
.pending_exceptions_clr
;
28 unsigned int priority
;
30 if (!(*pending
) && !(*pending_clr
))
33 priority
= __ffs(*pending_clr
);
34 while (priority
<= MIPS_EXC_MAX
) {
35 kvm_mips_callbacks
->irq_clear(vcpu
, priority
, cause
);
37 priority
= find_next_bit(pending_clr
,
38 BITS_PER_BYTE
* sizeof(*pending_clr
),
42 priority
= __ffs(*pending
);
43 while (priority
<= MIPS_EXC_MAX
) {
44 kvm_mips_callbacks
->irq_deliver(vcpu
, priority
, cause
);
46 priority
= find_next_bit(pending
,
47 BITS_PER_BYTE
* sizeof(*pending
),
53 int kvm_mips_pending_timer(struct kvm_vcpu
*vcpu
)
55 return test_bit(MIPS_EXC_INT_TIMER
, &vcpu
->arch
.pending_exceptions
);