interrupt.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  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
  4. * for more details.
  5. *
  6. * KVM/MIPS: Interrupt delivery
  7. *
  8. * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
  9. * Authors: Sanjay Lal <[email protected]>
  10. */
  11. #include <linux/errno.h>
  12. #include <linux/err.h>
  13. #include <linux/vmalloc.h>
  14. #include <linux/fs.h>
  15. #include <linux/memblock.h>
  16. #include <asm/page.h>
  17. #include <asm/cacheflush.h>
  18. #include <linux/kvm_host.h>
  19. #include "interrupt.h"
  20. void kvm_mips_deliver_interrupts(struct kvm_vcpu *vcpu, u32 cause)
  21. {
  22. unsigned long *pending = &vcpu->arch.pending_exceptions;
  23. unsigned long *pending_clr = &vcpu->arch.pending_exceptions_clr;
  24. unsigned int priority;
  25. if (!(*pending) && !(*pending_clr))
  26. return;
  27. priority = __ffs(*pending_clr);
  28. while (priority <= MIPS_EXC_MAX) {
  29. kvm_mips_callbacks->irq_clear(vcpu, priority, cause);
  30. priority = find_next_bit(pending_clr,
  31. BITS_PER_BYTE * sizeof(*pending_clr),
  32. priority + 1);
  33. }
  34. priority = __ffs(*pending);
  35. while (priority <= MIPS_EXC_MAX) {
  36. kvm_mips_callbacks->irq_deliver(vcpu, priority, cause);
  37. priority = find_next_bit(pending,
  38. BITS_PER_BYTE * sizeof(*pending),
  39. priority + 1);
  40. }
  41. }
  42. int kvm_mips_pending_timer(struct kvm_vcpu *vcpu)
  43. {
  44. return test_bit(MIPS_EXC_INT_TIMER, &vcpu->arch.pending_exceptions);
  45. }