ARM: GIC: avoid routing interrupts to offline CPUs
The irq_set_affinity() method can be called with masks which include offline CPUs. This allows offline CPUs to have interrupts routed to them by writing to /proc/irq/*/smp_affinity after hotplug has taken a CPU offline. Fix this by ensuring that we select a target CPU present in both the required affinity and the online CPU mask. Ensure that we return IRQ_SET_MASK_OK (which happens to be 0) on success to ensure generic code copies the new mask into the irq_data structure. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
		
					parent
					
						
							
								2ef75701d1
							
						
					
				
			
			
				commit
				
					
						5dfc54e087
					
				
			
		
					 1 changed files with 3 additions and 3 deletions
				
			
		|  | @ -179,10 +179,10 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, | ||||||
| { | { | ||||||
| 	void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + (gic_irq(d) & ~3); | 	void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + (gic_irq(d) & ~3); | ||||||
| 	unsigned int shift = (d->irq % 4) * 8; | 	unsigned int shift = (d->irq % 4) * 8; | ||||||
| 	unsigned int cpu = cpumask_first(mask_val); | 	unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask); | ||||||
| 	u32 val, mask, bit; | 	u32 val, mask, bit; | ||||||
| 
 | 
 | ||||||
| 	if (cpu >= 8) | 	if (cpu >= 8 || cpu >= nr_cpu_ids) | ||||||
| 		return -EINVAL; | 		return -EINVAL; | ||||||
| 
 | 
 | ||||||
| 	mask = 0xff << shift; | 	mask = 0xff << shift; | ||||||
|  | @ -193,7 +193,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, | ||||||
| 	writel_relaxed(val | bit, reg); | 	writel_relaxed(val | bit, reg); | ||||||
| 	spin_unlock(&irq_controller_lock); | 	spin_unlock(&irq_controller_lock); | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return IRQ_SET_MASK_OK; | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Russell King
				Russell King