xref: /openbmc/qemu/hw/intc/kvm_irqcount.c (revision d27532e4)
1 /*
2  * KVM PIC functions for counting the delivered IRQs.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, see <http://www.gnu.org/licenses/>
16  */
17 
18 #include "qemu/osdep.h"
19 #include "hw/intc/kvm_irqcount.h"
20 #include "trace.h"
21 
22 static int kvm_irq_delivered;
23 
24 void kvm_report_irq_delivered(int delivered)
25 {
26     kvm_irq_delivered += delivered;
27 
28     trace_kvm_report_irq_delivered(kvm_irq_delivered);
29 }
30 
31 void kvm_reset_irq_delivered(void)
32 {
33     /*
34      * Copy this into a local variable to encourage gcc to emit a plain
35      * register for a sys/sdt.h marker.  For details on this workaround, see:
36      * https://sourceware.org/bugzilla/show_bug.cgi?id=13296
37      */
38     volatile int k_i_d = kvm_irq_delivered;
39     trace_kvm_reset_irq_delivered(k_i_d);
40 
41     kvm_irq_delivered = 0;
42 }
43 
44 int kvm_get_irq_delivered(void)
45 {
46     trace_kvm_get_irq_delivered(kvm_irq_delivered);
47 
48     return kvm_irq_delivered;
49 }
50