aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index ae4db0185bb2..f4778d1aef69 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -266,6 +266,7 @@ struct runqueue {
266 unsigned long ttwu_cnt; 266 unsigned long ttwu_cnt;
267 unsigned long ttwu_local; 267 unsigned long ttwu_local;
268#endif 268#endif
269 struct lock_class_key rq_lock_key;
269}; 270};
270 271
271static DEFINE_PER_CPU(struct runqueue, runqueues); 272static DEFINE_PER_CPU(struct runqueue, runqueues);
@@ -6656,6 +6657,7 @@ void __init sched_init(void)
6656 6657
6657 rq = cpu_rq(i); 6658 rq = cpu_rq(i);
6658 spin_lock_init(&rq->lock); 6659 spin_lock_init(&rq->lock);
6660 lockdep_set_class(&rq->lock, &rq->rq_lock_key);
6659 rq->nr_running = 0; 6661 rq->nr_running = 0;
6660 rq->active = rq->arrays; 6662 rq->active = rq->arrays;
6661 rq->expired = rq->arrays + 1; 6663 rq->expired = rq->arrays + 1;
6eb6c8c0566e52d184aa16755d890f'>58c2dde17d6
e1035715ef8
343f94fe4d1

58c2dde17d6



116191b69b6

4925663a079
1a6e4a8c276
79950e10731
58c2dde17d6
79950e10731
1a6e4a8c276


1000ff8d893

58c2dde17d6
116191b69b6
58c2dde17d6
116191b69b6
58c2dde17d6




116191b69b6

58c2dde17d6
79950e10731

680b3648ba8
4925663a079




46e624b95c3
3de42dc094e
eba0226bdff

46e624b95c3

79950e10731
ae8c1c4025c
229456fc34b
3de42dc094e



e42bba90bfe

46e624b95c3
eba0226bdff

e42bba90bfe
eba0226bdff









4925663a079
3de42dc094e

44882eed2eb
3de42dc094e


3e71f88bc90
44882eed2eb
229456fc34b

e42bba90bfe

3e71f88bc90
280aa177dcd

3e71f88bc90

280aa177dcd
3de42dc094e




fa40a8214bb
280aa177dcd
fa40a8214bb
3de42dc094e

fa40a8214bb

3de42dc094e
fa40a8214bb
280aa177dcd
fa40a8214bb
280aa177dcd
3de42dc094e
5550af4df17
5550af4df17


fa40a8214bb


cd5a2685de4
61552367b2c
cd5a2685de4
5550af4df17
0c6ddcebd83

61552367b2c



0c6ddcebd83
fa40a8214bb
61552367b2c
5550af4df17






61552367b2c

fa40a8214bb
61552367b2c
cd5a2685de4
5550af4df17
0c6ddcebd83
5550af4df17
e50212bb513



1a6e4a8c276







0c6ddcebd83
fa40a8214bb
5550af4df17
75858a84a62



fa40a8214bb
75858a84a62
280aa177dcd
fa40a8214bb
75858a84a62




fa40a8214bb
280aa177dcd
fa40a8214bb
280aa177dcd
75858a84a62

4a994358b91

75858a84a62


4a994358b91
75858a84a62
280aa177dcd
4a994358b91




280aa177dcd
75858a84a62

399ec807ddc

e42bba90bfe

46e624b95c3
399ec807ddc

46e624b95c3

cded19f396b
399ec807ddc


d72118cecab
46e624b95c3










399ec807ddc

5116d8f6b97
399ec807ddc





d72118cecab
399ec807ddc

4925663a079
d72118cecab
399ec807ddc


d72118cecab
efbc100c20f
399ec807ddc





d72118cecab
3e71f88bc90

399ec807ddc
79950e10731





399ec807ddc


46e624b95c3

399ec807ddc










46e624b95c3
3e71f88bc90
399ec807ddc


46e624b95c3
















3e71f88bc90


46e624b95c3

399ec807ddc
399ec807ddc

46e624b95c3
399ec807ddc


399ec807ddc

fa40a8214bb
46e624b95c3
e42bba90bfe
fa40a8214bb
e42bba90bfe
399ec807ddc
46e624b95c3
399ec807ddc


46e624b95c3
399ec807ddc








399ec807ddc











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473


















                                                                               
                                                     


                           
                       
                             
 
                       


                        
 



                   











                                                                  
                                                                  
                                                                         

                 



                                                                    

                  


      
                                                                     
                                                                            
 




                                                                       

 
                                                                   
 






                                                                    
 







                                                                    

                                                                                

                                            

                                 

                                                                      

                                 



                                                         
                                                     



                                                                         
                 

         



                                                  

 
                                                              
                                                                     
 
                                 
 


                          

                                                              
                                          
                                                                         
                                   
                                                                       




                                                                            

                                                          
                                                         

 
  




                                                                           
                                                                       
 

                                                                         

                                             
 
                                                     
 



                                                                  

                                                   
                                        

                                                                   
                          









                                                                           
                   

 
                                                                          


                                          
                
 

                                        

                                                                    
                      

                                                                              

                                                      
                          




                                                                     
                                   
                                                                     
                                     

 

                                                                      
 
                                   
                                        
                                     
                          
 
 


                                                              


                                   
                                                                   
 
                                             
                                                                               

                                        



                                                             
       
                                     
 






                                                               

                                                             
                                   
                                
                                             
                                                                      
                            
         



                                                                







                                                                            
       
                                     
 



                                                                       
                                   
                        
                                                                  
                                     




                                                                         
                                   
                                   
                                     
                          

 

                                                                             


                                           
                
 
                        




                                                                                 
                          

 

                                          

                                                                        
                                

 

                                                                      
                                                                      


                        
                         










                                                                            

                         
                           





                                                 
                                     

                                           
                                                 
                                     


                                        
                                                      
                                                    





                                                           
                                              

                                                                          
                      





                                                         


                         

                                                   










                                                               
                                                
                                    


                                  
















                                                                                


                                                         

                                  
                            

                                 
                                                                      


                                 

         
                                   
                               
                                                  
                                     
                          
 
                  


              
                   








                                                                           











































                                                                            
/*
 * irq_comm.c: Common API for in kernel interrupt controller
 * Copyright (c) 2007, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307 USA.
 * Authors:
 *   Yaozu (Eddie) Dong <Eddie.dong@intel.com>
 *
 * Copyright 2010 Red Hat, Inc. and/or its affilates.
 */

#include <linux/kvm_host.h>
#include <linux/slab.h>
#include <trace/events/kvm.h>

#include <asm/msidef.h>
#ifdef CONFIG_IA64
#include <asm/iosapic.h>
#endif

#include "irq.h"

#include "ioapic.h"

static inline int kvm_irq_line_state(unsigned long *irq_state,
				     int irq_source_id, int level)
{
	/* Logical OR for level trig interrupt */
	if (level)
		set_bit(irq_source_id, irq_state);
	else
		clear_bit(irq_source_id, irq_state);

	return !!(*irq_state);
}

static int kvm_set_pic_irq(struct kvm_kernel_irq_routing_entry *e,
			   struct kvm *kvm, int irq_source_id, int level)
{
#ifdef CONFIG_X86
	struct kvm_pic *pic = pic_irqchip(kvm);
	level = kvm_irq_line_state(&pic->irq_states[e->irqchip.pin],
				   irq_source_id, level);
	return kvm_pic_set_irq(pic, e->irqchip.pin, level);
#else
	return -1;
#endif
}

static int kvm_set_ioapic_irq(struct kvm_kernel_irq_routing_entry *e,
			      struct kvm *kvm, int irq_source_id, int level)
{
	struct kvm_ioapic *ioapic = kvm->arch.vioapic;
	level = kvm_irq_line_state(&ioapic->irq_states[e->irqchip.pin],
				   irq_source_id, level);

	return kvm_ioapic_set_irq(ioapic, e->irqchip.pin, level);
}

inline static bool kvm_is_dm_lowest_prio(struct kvm_lapic_irq *irq)
{
#ifdef CONFIG_IA64
	return irq->delivery_mode ==
		(IOSAPIC_LOWEST_PRIORITY << IOSAPIC_DELIVERY_SHIFT);
#else
	return irq->delivery_mode == APIC_DM_LOWEST;
#endif
}

int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
		struct kvm_lapic_irq *irq)
{
	int i, r = -1;
	struct kvm_vcpu *vcpu, *lowest = NULL;

	if (irq->dest_mode == 0 && irq->dest_id == 0xff &&
			kvm_is_dm_lowest_prio(irq))
		printk(KERN_INFO "kvm: apic: phys broadcast and lowest prio\n");

	kvm_for_each_vcpu(i, vcpu, kvm) {
		if (!kvm_apic_present(vcpu))
			continue;

		if (!kvm_apic_match_dest(vcpu, src, irq->shorthand,
					irq->dest_id, irq->dest_mode))
			continue;

		if (!kvm_is_dm_lowest_prio(irq)) {
			if (r < 0)
				r = 0;
			r += kvm_apic_set_irq(vcpu, irq);
		} else if (kvm_lapic_enabled(vcpu)) {
			if (!lowest)
				lowest = vcpu;
			else if (kvm_apic_compare_prio(vcpu, lowest) < 0)
				lowest = vcpu;
		}
	}

	if (lowest)
		r = kvm_apic_set_irq(lowest, irq);

	return r;
}

static int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
		       struct kvm *kvm, int irq_source_id, int level)
{
	struct kvm_lapic_irq irq;

	if (!level)
		return -1;

	trace_kvm_msi_set_irq(e->msi.address_lo, e->msi.data);

	irq.dest_id = (e->msi.address_lo &
			MSI_ADDR_DEST_ID_MASK) >> MSI_ADDR_DEST_ID_SHIFT;
	irq.vector = (e->msi.data &
			MSI_DATA_VECTOR_MASK) >> MSI_DATA_VECTOR_SHIFT;
	irq.dest_mode = (1 << MSI_ADDR_DEST_MODE_SHIFT) & e->msi.address_lo;
	irq.trig_mode = (1 << MSI_DATA_TRIGGER_SHIFT) & e->msi.data;
	irq.delivery_mode = e->msi.data & 0x700;
	irq.level = 1;
	irq.shorthand = 0;

	/* TODO Deal with RH bit of MSI message address */
	return kvm_irq_delivery_to_apic(kvm, NULL, &irq);
}

/*
 * Return value:
 *  < 0   Interrupt was ignored (masked or not delivered for other reasons)
 *  = 0   Interrupt was coalesced (previous irq is still pending)
 *  > 0   Number of CPUs interrupt was delivered to
 */
int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level)
{
	struct kvm_kernel_irq_routing_entry *e, irq_set[KVM_NR_IRQCHIPS];
	int ret = -1, i = 0;
	struct kvm_irq_routing_table *irq_rt;
	struct hlist_node *n;

	trace_kvm_set_irq(irq, level, irq_source_id);

	/* Not possible to detect if the guest uses the PIC or the
	 * IOAPIC.  So set the bit in both. The guest will ignore
	 * writes to the unused one.
	 */
	rcu_read_lock();
	irq_rt = rcu_dereference(kvm->irq_routing);
	if (irq < irq_rt->nr_rt_entries)
		hlist_for_each_entry(e, n, &irq_rt->map[irq], link)
			irq_set[i++] = *e;
	rcu_read_unlock();