~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/kvm/irq.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/x86/kvm/irq.c (Version linux-6.12-rc7) and /arch/sparc/kvm/irq.c (Version linux-4.11.12)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  * irq.c: API for in kernel interrupt controll    
  4  * Copyright (c) 2007, Intel Corporation.         
  5  * Copyright 2009 Red Hat, Inc. and/or its aff    
  6  *                                                
  7  * Authors:                                       
  8  *   Yaozu (Eddie) Dong <Eddie.dong@intel.com>    
  9  */                                               
 10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt       
 11                                                   
 12 #include <linux/export.h>                         
 13 #include <linux/kvm_host.h>                       
 14                                                   
 15 #include "irq.h"                                  
 16 #include "i8254.h"                                
 17 #include "x86.h"                                  
 18 #include "xen.h"                                  
 19                                                   
 20 /*                                                
 21  * check if there are pending timer events        
 22  * to be processed.                               
 23  */                                               
 24 int kvm_cpu_has_pending_timer(struct kvm_vcpu     
 25 {                                                 
 26         int r = 0;                                
 27                                                   
 28         if (lapic_in_kernel(vcpu))                
 29                 r = apic_has_pending_timer(vcp    
 30         if (kvm_xen_timer_enabled(vcpu))          
 31                 r += kvm_xen_has_pending_timer    
 32                                                   
 33         return r;                                 
 34 }                                                 
 35                                                   
 36 /*                                                
 37  * check if there is a pending userspace exter    
 38  */                                               
 39 static int pending_userspace_extint(struct kvm    
 40 {                                                 
 41         return v->arch.pending_external_vector    
 42 }                                                 
 43                                                   
 44 /*                                                
 45  * check if there is pending interrupt from       
 46  * non-APIC source without intack.                
 47  */                                               
 48 int kvm_cpu_has_extint(struct kvm_vcpu *v)        
 49 {                                                 
 50         /*                                        
 51          * FIXME: interrupt.injected represent    
 52          * side-effects have already been appl    
 53          * already moved to ISR). Therefore, i    
 54          * on interrupt.injected to know if th    
 55          * interrupt in the user-mode LAPIC.      
 56          * This leads to nVMX/nSVM not be able    
 57          * if it should exit from L2 to L1 on     
 58          * pending interrupt or should re-inje    
 59          * interrupt.                             
 60          */                                       
 61         if (!lapic_in_kernel(v))                  
 62                 return v->arch.interrupt.injec    
 63                                                   
 64         if (kvm_xen_has_interrupt(v))             
 65                 return 1;                         
 66                                                   
 67         if (!kvm_apic_accept_pic_intr(v))         
 68                 return 0;                         
 69                                                   
 70         if (irqchip_split(v->kvm))                
 71                 return pending_userspace_extin    
 72         else                                      
 73                 return v->kvm->arch.vpic->outp    
 74 }                                                 
 75                                                   
 76 /*                                                
 77  * check if there is injectable interrupt:        
 78  * when virtual interrupt delivery enabled,       
 79  * interrupt from apic will handled by hardwar    
 80  * we don't need to check it here.                
 81  */                                               
 82 int kvm_cpu_has_injectable_intr(struct kvm_vcp    
 83 {                                                 
 84         if (kvm_cpu_has_extint(v))                
 85                 return 1;                         
 86                                                   
 87         if (!is_guest_mode(v) && kvm_vcpu_apic    
 88                 return 0;                         
 89                                                   
 90         return kvm_apic_has_interrupt(v) != -1    
 91 }                                                 
 92 EXPORT_SYMBOL_GPL(kvm_cpu_has_injectable_intr)    
 93                                                   
 94 /*                                                
 95  * check if there is pending interrupt without    
 96  * intack.                                        
 97  */                                               
 98 int kvm_cpu_has_interrupt(struct kvm_vcpu *v)     
 99 {                                                 
100         if (kvm_cpu_has_extint(v))                
101                 return 1;                         
102                                                   
103         return kvm_apic_has_interrupt(v) != -1    
104 }                                                 
105 EXPORT_SYMBOL_GPL(kvm_cpu_has_interrupt);         
106                                                   
107 /*                                                
108  * Read pending interrupt(from non-APIC source    
109  * vector and intack.                             
110  */                                               
111 int kvm_cpu_get_extint(struct kvm_vcpu *v)        
112 {                                                 
113         if (!kvm_cpu_has_extint(v)) {             
114                 WARN_ON(!lapic_in_kernel(v));     
115                 return -1;                        
116         }                                         
117                                                   
118         if (!lapic_in_kernel(v))                  
119                 return v->arch.interrupt.nr;      
120                                                   
121 #ifdef CONFIG_KVM_XEN                             
122         if (kvm_xen_has_interrupt(v))             
123                 return v->kvm->arch.xen.upcall    
124 #endif                                            
125                                                   
126         if (irqchip_split(v->kvm)) {              
127                 int vector = v->arch.pending_e    
128                                                   
129                 v->arch.pending_external_vecto    
130                 return vector;                    
131         } else                                    
132                 return kvm_pic_read_irq(v->kvm    
133 }                                                 
134 EXPORT_SYMBOL_GPL(kvm_cpu_get_extint);            
135                                                   
136 /*                                                
137  * Read pending interrupt vector and intack.      
138  */                                               
139 int kvm_cpu_get_interrupt(struct kvm_vcpu *v)     
140 {                                                 
141         int vector = kvm_cpu_get_extint(v);       
142         if (vector != -1)                         
143                 return vector;                    
144                                                   
145         vector = kvm_apic_has_interrupt(v);       
146         if (vector != -1)                         
147                 kvm_apic_ack_interrupt(v, vect    
148                                                   
149         return vector;                            
150 }                                                 
151                                                   
152 void kvm_inject_pending_timer_irqs(struct kvm_    
153 {                                                 
154         if (lapic_in_kernel(vcpu))                
155                 kvm_inject_apic_timer_irqs(vcp    
156         if (kvm_xen_timer_enabled(vcpu))          
157                 kvm_xen_inject_timer_irqs(vcpu    
158 }                                                 
159                                                   
160 void __kvm_migrate_timers(struct kvm_vcpu *vcp    
161 {                                                 
162         __kvm_migrate_apic_timer(vcpu);           
163         __kvm_migrate_pit_timer(vcpu);            
164         kvm_x86_call(migrate_timers)(vcpu);       
165 }                                                 
166                                                   
167 bool kvm_arch_irqfd_allowed(struct kvm *kvm, s    
168 {                                                 
169         bool resample = args->flags & KVM_IRQF    
170                                                   
171         return resample ? irqchip_kernel(kvm)     
172 }                                                 
173                                                   
174 bool kvm_arch_irqchip_in_kernel(struct kvm *kv    
175 {                                                 
176         return irqchip_in_kernel(kvm);            
177 }                                                 
178                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php