linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc, ocxl: Fix extraction of struct xive_irq_data
@ 2025-10-08  8:13 Nam Cao
  2025-10-08 20:33 ` Ganesh G R
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Nam Cao @ 2025-10-08  8:13 UTC (permalink / raw)
  To: Madhavan Srinivasan, Nicholas Piggin, Michael Ellerman,
	Christophe Leroy, Frederic Barrat, Andrew Donnellan
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Nam Cao, Thomas Gleixner,
	linuxppc-dev, kvm, linux-kernel, Ritesh Harjani (IBM)

Commit cc0cc23babc9 ("powerpc/xive: Untangle xive from child interrupt
controller drivers") changed xive_irq_data to be stashed to chip_data
instead of handler_data. However, multiple places are still attempting to
read xive_irq_data from handler_data and get a NULL pointer deference bug.

Update them to read xive_irq_data from chip_data.

Non-XIVE files which touch xive_irq_data seem quite strange to me,
especially the ocxl driver. I think there ought to be an alternative
platform-independent solution, instead of touching XIVE's data directly.
Therefore, I think this whole thing should be cleaned up. But perhaps I
just misunderstand something. In any case, this cleanup would not be
trivial; for now, just get things working again.

Fixes: cc0cc23babc9 ("powerpc/xive: Untangle xive from child interrupt controller drivers")
Reported-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Closes: https://lore.kernel.org/linuxppc-dev/68e48df8.170a0220.4b4b0.217d@mx.google.com/
Signed-off-by: Nam Cao <namcao@linutronix.de>
---
VAS and OCXL has not been tested. I noticed them while grepping.
---
 arch/powerpc/kvm/book3s_xive.c       | 12 ++++--------
 arch/powerpc/platforms/powernv/vas.c |  2 +-
 arch/powerpc/sysdev/xive/common.c    |  2 +-
 drivers/misc/ocxl/afu_irq.c          |  2 +-
 4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
index 1302b5ac5672..89a1b8c21ab4 100644
--- a/arch/powerpc/kvm/book3s_xive.c
+++ b/arch/powerpc/kvm/book3s_xive.c
@@ -916,8 +916,7 @@ int kvmppc_xive_attach_escalation(struct kvm_vcpu *vcpu, u8 prio,
 	 * it fires once.
 	 */
 	if (single_escalation) {
-		struct irq_data *d = irq_get_irq_data(xc->esc_virq[prio]);
-		struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
+		struct xive_irq_data *xd = irq_get_chip_data(xc->esc_virq[prio]);
 
 		xive_vm_esb_load(xd, XIVE_ESB_SET_PQ_01);
 		vcpu->arch.xive_esc_raddr = xd->eoi_page;
@@ -1612,7 +1611,7 @@ int kvmppc_xive_set_mapped(struct kvm *kvm, unsigned long guest_irq,
 
 	/* Grab info about irq */
 	state->pt_number = hw_irq;
-	state->pt_data = irq_data_get_irq_handler_data(host_data);
+	state->pt_data = irq_data_get_irq_chip_data(host_data);
 
 	/*
 	 * Configure the IRQ to match the existing configuration of
@@ -1787,8 +1786,7 @@ void kvmppc_xive_disable_vcpu_interrupts(struct kvm_vcpu *vcpu)
  */
 void xive_cleanup_single_escalation(struct kvm_vcpu *vcpu, int irq)
 {
-	struct irq_data *d = irq_get_irq_data(irq);
-	struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
+	struct xive_irq_data *xd = irq_get_chip_data(irq);
 
 	/*
 	 * This slightly odd sequence gives the right result
@@ -2827,9 +2825,7 @@ int kvmppc_xive_debug_show_queues(struct seq_file *m, struct kvm_vcpu *vcpu)
 				   i0, i1);
 		}
 		if (xc->esc_virq[i]) {
-			struct irq_data *d = irq_get_irq_data(xc->esc_virq[i]);
-			struct xive_irq_data *xd =
-				irq_data_get_irq_handler_data(d);
+			struct xive_irq_data *xd = irq_get_chip_data(xc->esc_virq[i]);
 			u64 pq = xive_vm_esb_load(xd, XIVE_ESB_GET);
 
 			seq_printf(m, "    ESC %d %c%c EOI @%llx",
diff --git a/arch/powerpc/platforms/powernv/vas.c b/arch/powerpc/platforms/powernv/vas.c
index b65256a63e87..9c9650319f3b 100644
--- a/arch/powerpc/platforms/powernv/vas.c
+++ b/arch/powerpc/platforms/powernv/vas.c
@@ -121,7 +121,7 @@ static int init_vas_instance(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	xd = irq_get_handler_data(vinst->virq);
+	xd = irq_get_chip_data(vinst->virq);
 	if (!xd) {
 		pr_err("Inst%d: Invalid virq %d\n",
 				vinst->vas_id, vinst->virq);
diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
index 625361a15424..8d0123b0ae84 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -1580,7 +1580,7 @@ static void xive_flush_cpu_queue(unsigned int cpu, struct xive_cpu *xc)
 			cpu, irq);
 #endif
 		raw_spin_lock(&desc->lock);
-		xd = irq_desc_get_handler_data(desc);
+		xd = irq_desc_get_chip_data(desc);
 
 		/*
 		 * Clear saved_p to indicate that it's no longer pending
diff --git a/drivers/misc/ocxl/afu_irq.c b/drivers/misc/ocxl/afu_irq.c
index 36f7379b8e2d..f6b821fc274c 100644
--- a/drivers/misc/ocxl/afu_irq.c
+++ b/drivers/misc/ocxl/afu_irq.c
@@ -203,7 +203,7 @@ u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, int irq_id)
 	mutex_lock(&ctx->irq_lock);
 	irq = idr_find(&ctx->irq_idr, irq_id);
 	if (irq) {
-		xd = irq_get_handler_data(irq->virq);
+		xd = irq_get_chip_data(irq->virq);
 		addr = xd ? xd->trig_page : 0;
 	}
 	mutex_unlock(&ctx->irq_lock);
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] powerpc, ocxl: Fix extraction of struct xive_irq_data
  2025-10-08  8:13 [PATCH] powerpc, ocxl: Fix extraction of struct xive_irq_data Nam Cao
@ 2025-10-08 20:33 ` Ganesh G R
  2025-10-09  0:40 ` Andrew Donnellan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ganesh G R @ 2025-10-08 20:33 UTC (permalink / raw)
  To: Nam Cao, Madhavan Srinivasan, Christophe Leroy, Frederic Barrat
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Thomas Gleixner, linuxppc-dev,
	kvm, linux-kernel, Ritesh Harjani (IBM), Michael Ellerman,
	Nicholas Piggin, Andrew Donnellan

On 10/8/25 1:43 PM, Nam Cao wrote:
> Commit cc0cc23babc9 ("powerpc/xive: Untangle xive from child interrupt
> controller drivers") changed xive_irq_data to be stashed to chip_data
> instead of handler_data. However, multiple places are still attempting to
> read xive_irq_data from handler_data and get a NULL pointer deference bug.
> 
> Update them to read xive_irq_data from chip_data.
> 
> Non-XIVE files which touch xive_irq_data seem quite strange to me,
> especially the ocxl driver. I think there ought to be an alternative
> platform-independent solution, instead of touching XIVE's data directly.
> Therefore, I think this whole thing should be cleaned up. But perhaps I
> just misunderstand something. In any case, this cleanup would not be
> trivial; for now, just get things working again.
> 
> Fixes: cc0cc23babc9 ("powerpc/xive: Untangle xive from child interrupt controller drivers")
> Reported-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> Closes: https://lore.kernel.org/linuxppc-dev/68e48df8.170a0220.4b4b0.217d@mx.google.com/
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> ---
> VAS and OCXL has not been tested. I noticed them while grepping.
> ---

Looks good to me.
Reviewed-by: Ganesh Goudar <ganeshgr@linux.ibm.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] powerpc, ocxl: Fix extraction of struct xive_irq_data
  2025-10-08  8:13 [PATCH] powerpc, ocxl: Fix extraction of struct xive_irq_data Nam Cao
  2025-10-08 20:33 ` Ganesh G R
@ 2025-10-09  0:40 ` Andrew Donnellan
  2025-10-13 16:46 ` Ritesh Harjani
  2025-10-18  5:33 ` Madhavan Srinivasan
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Donnellan @ 2025-10-09  0:40 UTC (permalink / raw)
  To: Nam Cao, Madhavan Srinivasan, Nicholas Piggin, Michael Ellerman,
	Christophe Leroy, Frederic Barrat
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Thomas Gleixner, linuxppc-dev,
	kvm, linux-kernel, Ritesh Harjani (IBM)

On Wed, 2025-10-08 at 08:13 +0000, Nam Cao wrote:
> Commit cc0cc23babc9 ("powerpc/xive: Untangle xive from child interrupt
> controller drivers") changed xive_irq_data to be stashed to chip_data
> instead of handler_data. However, multiple places are still attempting to
> read xive_irq_data from handler_data and get a NULL pointer deference bug.
> 
> Update them to read xive_irq_data from chip_data.
> 
> Non-XIVE files which touch xive_irq_data seem quite strange to me,
> especially the ocxl driver. I think there ought to be an alternative
> platform-independent solution, instead of touching XIVE's data directly.
> Therefore, I think this whole thing should be cleaned up. But perhaps I
> just misunderstand something. In any case, this cleanup would not be
> trivial; for now, just get things working again.

ocxl has always done quite a few weird things...

> 
> Fixes: cc0cc23babc9 ("powerpc/xive: Untangle xive from child interrupt
> controller drivers")
> Reported-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> Closes:
> https://lore.kernel.org/linuxppc-dev/68e48df8.170a0220.4b4b0.217d@mx.google.com/
> Signed-off-by: Nam Cao <namcao@linutronix.de>

Acked-by: Andrew Donnellan <ajd@linux.ibm.com>  # ocxl

> ---
> VAS and OCXL has not been tested. I noticed them while grepping.

Unfortunately I don't have convenient ocxl hardware on hand to test with any
more (I'm sure the cards are floating around *somewhere* in the company...), but
this looks like a straightforward change.

-- 
Andrew Donnellan    OzLabs, ADL Canberra
ajd@linux.ibm.com   IBM Australia Limited


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] powerpc, ocxl: Fix extraction of struct xive_irq_data
  2025-10-08  8:13 [PATCH] powerpc, ocxl: Fix extraction of struct xive_irq_data Nam Cao
  2025-10-08 20:33 ` Ganesh G R
  2025-10-09  0:40 ` Andrew Donnellan
@ 2025-10-13 16:46 ` Ritesh Harjani
  2025-10-18  5:33 ` Madhavan Srinivasan
  3 siblings, 0 replies; 5+ messages in thread
From: Ritesh Harjani @ 2025-10-13 16:46 UTC (permalink / raw)
  To: Nam Cao, Madhavan Srinivasan, Nicholas Piggin, Michael Ellerman,
	Christophe Leroy, Frederic Barrat, Andrew Donnellan
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Nam Cao, Thomas Gleixner,
	linuxppc-dev, kvm, linux-kernel

Nam Cao <namcao@linutronix.de> writes:

> Commit cc0cc23babc9 ("powerpc/xive: Untangle xive from child interrupt
> controller drivers") changed xive_irq_data to be stashed to chip_data
> instead of handler_data. However, multiple places are still attempting to
> read xive_irq_data from handler_data and get a NULL pointer deference bug.
>
> Update them to read xive_irq_data from chip_data.
>
> Non-XIVE files which touch xive_irq_data seem quite strange to me,
> especially the ocxl driver. I think there ought to be an alternative
> platform-independent solution, instead of touching XIVE's data directly.
> Therefore, I think this whole thing should be cleaned up. But perhaps I
> just misunderstand something. In any case, this cleanup would not be
> trivial; for now, just get things working again.
>
> Fixes: cc0cc23babc9 ("powerpc/xive: Untangle xive from child interrupt controller drivers")
> Reported-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> Closes: https://lore.kernel.org/linuxppc-dev/68e48df8.170a0220.4b4b0.217d@mx.google.com/
> Signed-off-by: Nam Cao <namcao@linutronix.de>


Thanks Nam for the fix. I validated this with KVM on my POWER9 hardware and
this patch fixes the previosly reported problem at my end.

Feel free to add:
Tested-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> # KVM

-ritesh


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] powerpc, ocxl: Fix extraction of struct xive_irq_data
  2025-10-08  8:13 [PATCH] powerpc, ocxl: Fix extraction of struct xive_irq_data Nam Cao
                   ` (2 preceding siblings ...)
  2025-10-13 16:46 ` Ritesh Harjani
@ 2025-10-18  5:33 ` Madhavan Srinivasan
  3 siblings, 0 replies; 5+ messages in thread
From: Madhavan Srinivasan @ 2025-10-18  5:33 UTC (permalink / raw)
  To: Nicholas Piggin, Michael Ellerman, Christophe Leroy,
	Frederic Barrat, Andrew Donnellan, Nam Cao
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Thomas Gleixner, linuxppc-dev,
	kvm, linux-kernel, Ritesh Harjani (IBM)

On Wed, 08 Oct 2025 08:13:59 +0000, Nam Cao wrote:
> Commit cc0cc23babc9 ("powerpc/xive: Untangle xive from child interrupt
> controller drivers") changed xive_irq_data to be stashed to chip_data
> instead of handler_data. However, multiple places are still attempting to
> read xive_irq_data from handler_data and get a NULL pointer deference bug.
> 
> Update them to read xive_irq_data from chip_data.
> 
> [...]

Applied to powerpc/fixes.

[1/1] powerpc, ocxl: Fix extraction of struct xive_irq_data
      https://git.kernel.org/powerpc/c/2743cf75f7c92d2a0a4acabd7aef1c17d98fe123

Thanks


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-10-18  5:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-08  8:13 [PATCH] powerpc, ocxl: Fix extraction of struct xive_irq_data Nam Cao
2025-10-08 20:33 ` Ganesh G R
2025-10-09  0:40 ` Andrew Donnellan
2025-10-13 16:46 ` Ritesh Harjani
2025-10-18  5:33 ` Madhavan Srinivasan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).