* [PATCH] MIPS: SB1250: Validate and update IRQ affinity
@ 2026-11-03 21:50 Florian Fainelli
2026-11-05 15:44 ` Thomas Bogendoerfer
0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2026-11-03 21:50 UTC (permalink / raw)
To: linux-mips
Cc: macro, Florian Fainelli, Thomas Bogendoerfer, Thomas Gleixner, open list
sb1250_set_affinity() selects the first online CPU in the requested
affinity mask without checking whether such a CPU exists. If the
intersection is empty, the resulting CPU index is invalid and must
not be passed to cpu_logical_map().
Reject affinity masks containing no online CPU with -EINVAL before
accessing the CPU mapping or interrupt mapper registers.
Also update the effective affinity mask to reflect the single logical
CPU selected as the interrupt target.
Fixes: 421d1563c662 ("mips: Validate online cpus in irq_set_affinity() callbacks")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
arch/mips/sibyte/sb1250/irq.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/mips/sibyte/sb1250/irq.c b/arch/mips/sibyte/sb1250/irq.c
index 2f08ad267a11..d7a656cd7ec0 100644
--- a/arch/mips/sibyte/sb1250/irq.c
+++ b/arch/mips/sibyte/sb1250/irq.c
@@ -76,6 +76,8 @@ static int sb1250_set_affinity(struct irq_data *d, const struct cpumask *mask,
unsigned long flags;
i = cpumask_first_and(mask, cpu_online_mask);
+ if (i >= nr_cpu_ids)
+ return -EINVAL;
/* Convert logical CPU to physical CPU */
cpu = cpu_logical_map(i);
@@ -103,6 +105,7 @@ static int sb1250_set_affinity(struct irq_data *d, const struct cpumask *mask,
____raw_writeq(cur_ints, IOADDR(A_IMR_MAPPER(cpu) +
R_IMR_INTERRUPT_MASK));
}
+ irq_data_update_effective_affinity(d, cpumask_of(i));
raw_spin_unlock_irqrestore(&sb1250_imr_lock, flags);
return 0;
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] MIPS: SB1250: Validate and update IRQ affinity
2026-11-03 21:50 [PATCH] MIPS: SB1250: Validate and update IRQ affinity Florian Fainelli
@ 2026-11-05 15:44 ` Thomas Bogendoerfer
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Bogendoerfer @ 2026-11-05 15:44 UTC (permalink / raw)
To: Florian Fainelli; +Cc: linux-mips, macro, Thomas Gleixner, open list
On Tue, Nov 03, 2026 at 01:50:40PM -0800, Florian Fainelli wrote:
> sb1250_set_affinity() selects the first online CPU in the requested
> affinity mask without checking whether such a CPU exists. If the
> intersection is empty, the resulting CPU index is invalid and must
> not be passed to cpu_logical_map().
>
> Reject affinity masks containing no online CPU with -EINVAL before
> accessing the CPU mapping or interrupt mapper registers.
>
> Also update the effective affinity mask to reflect the single logical
> CPU selected as the interrupt target.
>
> Fixes: 421d1563c662 ("mips: Validate online cpus in irq_set_affinity() callbacks")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> arch/mips/sibyte/sb1250/irq.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/mips/sibyte/sb1250/irq.c b/arch/mips/sibyte/sb1250/irq.c
> index 2f08ad267a11..d7a656cd7ec0 100644
> --- a/arch/mips/sibyte/sb1250/irq.c
> +++ b/arch/mips/sibyte/sb1250/irq.c
> @@ -76,6 +76,8 @@ static int sb1250_set_affinity(struct irq_data *d, const struct cpumask *mask,
> unsigned long flags;
>
> i = cpumask_first_and(mask, cpu_online_mask);
> + if (i >= nr_cpu_ids)
> + return -EINVAL;
>
> /* Convert logical CPU to physical CPU */
> cpu = cpu_logical_map(i);
> @@ -103,6 +105,7 @@ static int sb1250_set_affinity(struct irq_data *d, const struct cpumask *mask,
> ____raw_writeq(cur_ints, IOADDR(A_IMR_MAPPER(cpu) +
> R_IMR_INTERRUPT_MASK));
> }
> + irq_data_update_effective_affinity(d, cpumask_of(i));
> raw_spin_unlock_irqrestore(&sb1250_imr_lock, flags);
>
> return 0;
> --
> 2.53.0
applied to mips-fixes
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-05 15:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 21:50 [PATCH] MIPS: SB1250: Validate and update IRQ affinity Florian Fainelli
2026-11-05 15:44 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®