lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87v7kf17xq.ffs@tglx>
Date: Thu, 16 Oct 2025 12:01:53 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: Samuel Holland <samuel.holland@...ive.com>, Anup Patel
 <anup@...infault.org>
Cc: Palmer Dabbelt <palmer@...belt.com>, linux-kernel@...r.kernel.org,
 Alexandre Ghiti <alex@...ti.fr>, linux-riscv@...ts.infradead.org, Paul
 Walmsley <pjw@...nel.org>, Samuel Holland <samuel.holland@...ive.com>,
 Albert Ou <aou@...s.berkeley.edu>
Subject: Re: [PATCH 4/4] irqchip/riscv-imsic: Remove irq_desc lookup from
 hot path

On Wed, Oct 15 2025 at 12:55, Samuel Holland wrote:
> The IMSIC driver uses the IRQ matrix allocator, so there is an arbitrary
> mapping from the per-CPU interrupt identity to the global irq number. As
> a result, the driver maintains a table of vectors so it can look up the
> virq number during interrupt handling. The driver uses the virq for one
> main purpose: it gets passed to generic_handle_irq(), which then uses it
> to look up the irq_desc in the sparse_irqs tree.
>
> Taking inspiration from the loongarch AVEC irqchip driver, skip the tree

which got the idea from x86 :)

> -struct imsic_vector *imsic_vector_alloc(unsigned int irq, const struct cpumask *mask)
> +struct imsic_vector *imsic_vector_alloc(struct irq_desc *desc, const struct cpumask *mask)
>  {
>  	struct imsic_vector *vec = NULL;
>  	struct imsic_local_priv *lpriv;
> @@ -450,7 +451,7 @@ struct imsic_vector *imsic_vector_alloc(unsigned int irq, const struct cpumask *
>  
>  	lpriv = per_cpu_ptr(imsic->lpriv, cpu);
>  	vec = &lpriv->vectors[local_id];
> -	vec->irq = irq;
> +	vec->desc = desc;
>  	vec->enable = false;
>  	vec->move_next = NULL;
>  	vec->move_prev = NULL;
> @@ -463,7 +464,7 @@ void imsic_vector_free(struct imsic_vector *vec)
>  	unsigned long flags;
>  
>  	raw_spin_lock_irqsave(&imsic->matrix_lock, flags);
> -	vec->irq = 0;
> +	vec->desc = NULL;
>  	irq_matrix_free(imsic->matrix, vec->cpu, vec->local_id, false);
>  	raw_spin_unlock_irqrestore(&imsic->matrix_lock, flags);

This is only correct when it is guaranteed that the interrupt can't be
raised in the CPU _before_ a interrupt allocation completed throughout
the hierarchy and _after_ the freeing hierarchy walk started. Otherwise
this might end up accessing a half initialized or half torn down
descriptor.

If it is, then please add a comment describing it. If not then you need
to implement the activate/deactivate callbacks for your interrupt domain
and do the store/clear of vec->desc there.

Thanks,

        tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ