LinuxPPC-Dev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/3] powerpc/xmon: Fix dump of XIVE interrupt under pseries
@ 2019-08-14 15:47 Cédric Le Goater
  2019-08-14 15:47 ` [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL Cédric Le Goater
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Cédric Le Goater @ 2019-08-14 15:47 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linuxppc-dev, Paul Mackerras, Cédric Le Goater, Nicholas Piggin

Hello,

The xmon 'dx*' commands call OPAL to query information on XIVE but
this can only be done on baremetal (PowerNV) and it crashes a pseries
machine. This little series fixes support on pseries and extend the
'dxi' command.

Thanks,

C.

Cédric Le Goater (3):
  powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL
  powerpc/xive: Fix dump of XIVE interrupt under pseries
  powerpc/xmon: Add a dump of all XIVE interrupts

 arch/powerpc/include/asm/xive.h          |  2 +
 arch/powerpc/sysdev/xive/xive-internal.h |  2 +
 arch/powerpc/sysdev/xive/common.c        |  7 ++++
 arch/powerpc/sysdev/xive/native.c        | 15 +++++++
 arch/powerpc/sysdev/xive/spapr.c         | 51 ++++++++++++++++++++++++
 arch/powerpc/xmon/xmon.c                 | 50 +++++++++++++++++------
 6 files changed, 114 insertions(+), 13 deletions(-)

-- 
2.21.0


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

* [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL
  2019-08-14 15:47 [PATCH 0/3] powerpc/xmon: Fix dump of XIVE interrupt under pseries Cédric Le Goater
@ 2019-08-14 15:47 ` Cédric Le Goater
  2019-08-15  7:30   ` Jordan Niethe
  2019-08-22 13:09   ` Michael Ellerman
  2019-08-14 15:47 ` [PATCH 2/3] powerpc/xive: Fix dump of XIVE interrupt under pseries Cédric Le Goater
  2019-08-14 15:47 ` [PATCH 3/3] powerpc/xmon: Add a dump of all XIVE interrupts Cédric Le Goater
  2 siblings, 2 replies; 8+ messages in thread
From: Cédric Le Goater @ 2019-08-14 15:47 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linuxppc-dev, Paul Mackerras, Cédric Le Goater, Nicholas Piggin

Currently, the xmon 'dx' command calls OPAL to dump the XIVE state in
the OPAL logs and also outputs some of the fields of the internal XIVE
structures in Linux. The OPAL calls can only be done on baremetal
(PowerNV) and they crash a pseries machine. Fix by checking the
hypervisor feature of the CPU.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 arch/powerpc/xmon/xmon.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 14e56c25879f..25d4adccf750 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2534,13 +2534,16 @@ static void dump_pacas(void)
 static void dump_one_xive(int cpu)
 {
 	unsigned int hwid = get_hard_smp_processor_id(cpu);
-
-	opal_xive_dump(XIVE_DUMP_TM_HYP, hwid);
-	opal_xive_dump(XIVE_DUMP_TM_POOL, hwid);
-	opal_xive_dump(XIVE_DUMP_TM_OS, hwid);
-	opal_xive_dump(XIVE_DUMP_TM_USER, hwid);
-	opal_xive_dump(XIVE_DUMP_VP, hwid);
-	opal_xive_dump(XIVE_DUMP_EMU_STATE, hwid);
+	bool hv = cpu_has_feature(CPU_FTR_HVMODE);
+
+	if (hv) {
+		opal_xive_dump(XIVE_DUMP_TM_HYP, hwid);
+		opal_xive_dump(XIVE_DUMP_TM_POOL, hwid);
+		opal_xive_dump(XIVE_DUMP_TM_OS, hwid);
+		opal_xive_dump(XIVE_DUMP_TM_USER, hwid);
+		opal_xive_dump(XIVE_DUMP_VP, hwid);
+		opal_xive_dump(XIVE_DUMP_EMU_STATE, hwid);
+	}
 
 	if (setjmp(bus_error_jmp) != 0) {
 		catch_memory_errors = 0;
-- 
2.21.0


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

* [PATCH 2/3] powerpc/xive: Fix dump of XIVE interrupt under pseries
  2019-08-14 15:47 [PATCH 0/3] powerpc/xmon: Fix dump of XIVE interrupt under pseries Cédric Le Goater
  2019-08-14 15:47 ` [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL Cédric Le Goater
@ 2019-08-14 15:47 ` Cédric Le Goater
  2019-08-14 15:47 ` [PATCH 3/3] powerpc/xmon: Add a dump of all XIVE interrupts Cédric Le Goater
  2 siblings, 0 replies; 8+ messages in thread
From: Cédric Le Goater @ 2019-08-14 15:47 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linuxppc-dev, Paul Mackerras, Cédric Le Goater, Nicholas Piggin

The xmon 'dxi' command calls OPAL to query the XIVE configuration of a
interrupt. This can only be done on baremetal (PowerNV) and it will
crash a pseries machine.

Introduce a new XIVE get_irq_config() operation which implements a
different query depending on the platform, PowerNV or pseries, and
modify xmon to use a top level wrapper.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 arch/powerpc/include/asm/xive.h          |  2 +
 arch/powerpc/sysdev/xive/xive-internal.h |  2 +
 arch/powerpc/sysdev/xive/common.c        |  7 ++++
 arch/powerpc/sysdev/xive/native.c        | 15 +++++++
 arch/powerpc/sysdev/xive/spapr.c         | 51 ++++++++++++++++++++++++
 arch/powerpc/xmon/xmon.c                 | 12 +++---
 6 files changed, 83 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/xive.h b/arch/powerpc/include/asm/xive.h
index efb0e597b272..967d6ab3c977 100644
--- a/arch/powerpc/include/asm/xive.h
+++ b/arch/powerpc/include/asm/xive.h
@@ -99,6 +99,8 @@ extern void xive_flush_interrupt(void);
 
 /* xmon hook */
 extern void xmon_xive_do_dump(int cpu);
+extern int xmon_xive_get_irq_config(u32 irq, u32 *target, u8 *prio,
+				    u32 *sw_irq);
 
 /* APIs used by KVM */
 extern u32 xive_native_default_eq_shift(void);
diff --git a/arch/powerpc/sysdev/xive/xive-internal.h b/arch/powerpc/sysdev/xive/xive-internal.h
index 211725dbf364..59cd366e7933 100644
--- a/arch/powerpc/sysdev/xive/xive-internal.h
+++ b/arch/powerpc/sysdev/xive/xive-internal.h
@@ -33,6 +33,8 @@ struct xive_cpu {
 struct xive_ops {
 	int	(*populate_irq_data)(u32 hw_irq, struct xive_irq_data *data);
 	int 	(*configure_irq)(u32 hw_irq, u32 target, u8 prio, u32 sw_irq);
+	int	(*get_irq_config)(u32 hw_irq, u32 *target, u8 *prio,
+				  u32 *sw_irq);
 	int	(*setup_queue)(unsigned int cpu, struct xive_cpu *xc, u8 prio);
 	void	(*cleanup_queue)(unsigned int cpu, struct xive_cpu *xc, u8 prio);
 	void	(*setup_cpu)(unsigned int cpu, struct xive_cpu *xc);
diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
index be86fce1a84e..ed4561e71951 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -257,6 +257,13 @@ notrace void xmon_xive_do_dump(int cpu)
 	}
 #endif
 }
+
+int xmon_xive_get_irq_config(u32 irq, u32 *target, u8 *prio,
+			     u32 *sw_irq)
+{
+	return xive_ops->get_irq_config(irq, target, prio, sw_irq);
+}
+
 #endif /* CONFIG_XMON */
 
 static unsigned int xive_get_irq(void)
diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c
index 2f26b74f6cfa..4b61e44f0171 100644
--- a/arch/powerpc/sysdev/xive/native.c
+++ b/arch/powerpc/sysdev/xive/native.c
@@ -111,6 +111,20 @@ int xive_native_configure_irq(u32 hw_irq, u32 target, u8 prio, u32 sw_irq)
 }
 EXPORT_SYMBOL_GPL(xive_native_configure_irq);
 
+static int xive_native_get_irq_config(u32 hw_irq, u32 *target, u8 *prio,
+				      u32 *sw_irq)
+{
+	s64 rc;
+	__be64 vp;
+	__be32 lirq;
+
+	rc = opal_xive_get_irq_config(hw_irq, &vp, prio, &lirq);
+
+	*target = be64_to_cpu(vp);
+	*sw_irq = be32_to_cpu(lirq);
+
+	return rc == 0 ? 0 : -ENXIO;
+}
 
 /* This can be called multiple time to change a queue configuration */
 int xive_native_configure_queue(u32 vp_id, struct xive_q *q, u8 prio,
@@ -442,6 +456,7 @@ EXPORT_SYMBOL_GPL(xive_native_sync_queue);
 static const struct xive_ops xive_native_ops = {
 	.populate_irq_data	= xive_native_populate_irq_data,
 	.configure_irq		= xive_native_configure_irq,
+	.get_irq_config		= xive_native_get_irq_config,
 	.setup_queue		= xive_native_setup_queue,
 	.cleanup_queue		= xive_native_cleanup_queue,
 	.match			= xive_native_match,
diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c
index 8ef9cf4ebb1c..2a2d209336f7 100644
--- a/arch/powerpc/sysdev/xive/spapr.c
+++ b/arch/powerpc/sysdev/xive/spapr.c
@@ -211,6 +211,38 @@ static long plpar_int_set_source_config(unsigned long flags,
 	return 0;
 }
 
+static long plpar_int_get_source_config(unsigned long flags,
+					unsigned long lisn,
+					unsigned long *target,
+					unsigned long *prio,
+					unsigned long *sw_irq)
+{
+	unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
+	long rc;
+
+	pr_devel("H_INT_GET_SOURCE_CONFIG flags=%lx lisn=%lx\n", flags, lisn);
+
+	do {
+		rc = plpar_hcall(H_INT_GET_SOURCE_CONFIG, retbuf, flags, lisn,
+				 target, prio, sw_irq);
+	} while (plpar_busy_delay(rc));
+
+	if (rc) {
+		pr_err("H_INT_GET_SOURCE_CONFIG lisn=%ld failed %ld\n",
+		       lisn, rc);
+		return rc;
+	}
+
+	*target = retbuf[0];
+	*prio   = retbuf[1];
+	*sw_irq = retbuf[2];
+
+	pr_devel("H_INT_GET_SOURCE_CONFIG target=%lx prio=%lx sw_irq=%lx\n",
+		retbuf[0], retbuf[1], retbuf[2]);
+
+	return 0;
+}
+
 static long plpar_int_get_queue_info(unsigned long flags,
 				     unsigned long target,
 				     unsigned long priority,
@@ -394,6 +426,24 @@ static int xive_spapr_configure_irq(u32 hw_irq, u32 target, u8 prio, u32 sw_irq)
 	return rc == 0 ? 0 : -ENXIO;
 }
 
+static int xive_spapr_get_irq_config(u32 hw_irq, u32 *target, u8 *prio,
+				     u32 *sw_irq)
+{
+	long rc;
+	unsigned long h_target;
+	unsigned long h_prio;
+	unsigned long h_sw_irq;
+
+	rc = plpar_int_get_source_config(0, hw_irq, &h_target, &h_prio,
+					 &h_sw_irq);
+
+	*target = h_target;
+	*prio = h_prio;
+	*sw_irq = h_sw_irq;
+
+	return rc == 0 ? 0 : -ENXIO;
+}
+
 /* This can be called multiple time to change a queue configuration */
 static int xive_spapr_configure_queue(u32 target, struct xive_q *q, u8 prio,
 				   __be32 *qpage, u32 order)
@@ -586,6 +636,7 @@ static void xive_spapr_sync_source(u32 hw_irq)
 static const struct xive_ops xive_spapr_ops = {
 	.populate_irq_data	= xive_spapr_populate_irq_data,
 	.configure_irq		= xive_spapr_configure_irq,
+	.get_irq_config		= xive_spapr_get_irq_config,
 	.setup_queue		= xive_spapr_setup_queue,
 	.cleanup_queue		= xive_spapr_cleanup_queue,
 	.match			= xive_spapr_match,
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 25d4adccf750..4ea53e05053f 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2574,14 +2574,14 @@ static void dump_all_xives(void)
 
 static void dump_one_xive_irq(u32 num)
 {
-	s64 rc;
-	__be64 vp;
+	int rc;
+	u32 target;
 	u8 prio;
-	__be32 lirq;
+	u32 lirq;
 
-	rc = opal_xive_get_irq_config(num, &vp, &prio, &lirq);
-	xmon_printf("IRQ 0x%x config: vp=0x%llx prio=%d lirq=0x%x (rc=%lld)\n",
-		    num, be64_to_cpu(vp), prio, be32_to_cpu(lirq), rc);
+	rc = xmon_xive_get_irq_config(num, &target, &prio, &lirq);
+	xmon_printf("IRQ 0x%08x : target=0x%x prio=%d lirq=0x%x (rc=%d)\n",
+		    num, target, prio, lirq, rc);
 }
 
 static void dump_xives(void)
-- 
2.21.0


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

* [PATCH 3/3] powerpc/xmon: Add a dump of all XIVE interrupts
  2019-08-14 15:47 [PATCH 0/3] powerpc/xmon: Fix dump of XIVE interrupt under pseries Cédric Le Goater
  2019-08-14 15:47 ` [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL Cédric Le Goater
  2019-08-14 15:47 ` [PATCH 2/3] powerpc/xive: Fix dump of XIVE interrupt under pseries Cédric Le Goater
@ 2019-08-14 15:47 ` Cédric Le Goater
  2 siblings, 0 replies; 8+ messages in thread
From: Cédric Le Goater @ 2019-08-14 15:47 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linuxppc-dev, Paul Mackerras, Cédric Le Goater, Nicholas Piggin

Modify the xmon 'dxi' command to query all interrupts if no IRQ number
is specified.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 arch/powerpc/xmon/xmon.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 4ea53e05053f..dc9832e06256 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2584,6 +2584,25 @@ static void dump_one_xive_irq(u32 num)
 		    num, target, prio, lirq, rc);
 }
 
+static void dump_all_xive_irq(void)
+{
+	unsigned int i;
+	struct irq_desc *desc;
+
+	for_each_irq_desc(i, desc) {
+		struct irq_data *d = irq_desc_get_irq_data(desc);
+		unsigned int hwirq;
+
+		if (!d)
+			continue;
+
+		hwirq = (unsigned int)irqd_to_hwirq(d);
+		/* IPIs are special (HW number 0) */
+		if (hwirq)
+			dump_one_xive_irq(hwirq);
+	}
+}
+
 static void dump_xives(void)
 {
 	unsigned long num;
@@ -2601,6 +2620,8 @@ static void dump_xives(void)
 	} else if (c == 'i') {
 		if (scanhex(&num))
 			dump_one_xive_irq(num);
+		else
+			dump_all_xive_irq();
 		return;
 	}
 
-- 
2.21.0


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

* Re: [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL
  2019-08-14 15:47 ` [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL Cédric Le Goater
@ 2019-08-15  7:30   ` Jordan Niethe
  2019-08-15  8:15     ` Cédric Le Goater
  2019-08-22 13:09   ` Michael Ellerman
  1 sibling, 1 reply; 8+ messages in thread
From: Jordan Niethe @ 2019-08-15  7:30 UTC (permalink / raw)
  To: Cédric Le Goater, Michael Ellerman
  Cc: Paul Mackerras, linuxppc-dev, Nicholas Piggin

On Wed, 2019-08-14 at 17:47 +0200, Cédric Le Goater wrote:
> Currently, the xmon 'dx' command calls OPAL to dump the XIVE state in
> the OPAL logs and also outputs some of the fields of the internal
> XIVE
> structures in Linux. The OPAL calls can only be done on baremetal
> (PowerNV) and they crash a pseries machine. Fix by checking the
> hypervisor feature of the CPU.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  arch/powerpc/xmon/xmon.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> index 14e56c25879f..25d4adccf750 100644
> --- a/arch/powerpc/xmon/xmon.c
> +++ b/arch/powerpc/xmon/xmon.c
> @@ -2534,13 +2534,16 @@ static void dump_pacas(void)
>  static void dump_one_xive(int cpu)
>  {
>  	unsigned int hwid = get_hard_smp_processor_id(cpu);
> -
> -	opal_xive_dump(XIVE_DUMP_TM_HYP, hwid);
> -	opal_xive_dump(XIVE_DUMP_TM_POOL, hwid);
> -	opal_xive_dump(XIVE_DUMP_TM_OS, hwid);
> -	opal_xive_dump(XIVE_DUMP_TM_USER, hwid);
> -	opal_xive_dump(XIVE_DUMP_VP, hwid);
> -	opal_xive_dump(XIVE_DUMP_EMU_STATE, hwid);
> +	bool hv = cpu_has_feature(CPU_FTR_HVMODE);
> +
> +	if (hv) {
> +		opal_xive_dump(XIVE_DUMP_TM_HYP, hwid);
> +		opal_xive_dump(XIVE_DUMP_TM_POOL, hwid);
> +		opal_xive_dump(XIVE_DUMP_TM_OS, hwid);
> +		opal_xive_dump(XIVE_DUMP_TM_USER, hwid);
> +		opal_xive_dump(XIVE_DUMP_VP, hwid);
> +		opal_xive_dump(XIVE_DUMP_EMU_STATE, hwid);
> +	}
>  
>  	if (setjmp(bus_error_jmp) != 0) {
>  		catch_memory_errors = 0;
dump_one_xive() / other xive functions are guarded by #ifdef
CONFIG_PPC_POWERNV in xmon.c aren't they? With this series would it be
that these guards can be removed?


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

* Re: [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL
  2019-08-15  7:30   ` Jordan Niethe
@ 2019-08-15  8:15     ` Cédric Le Goater
  2019-08-15 16:44       ` Cédric Le Goater
  0 siblings, 1 reply; 8+ messages in thread
From: Cédric Le Goater @ 2019-08-15  8:15 UTC (permalink / raw)
  To: Jordan Niethe, Michael Ellerman
  Cc: Paul Mackerras, linuxppc-dev, Nicholas Piggin

On 15/08/2019 09:30, Jordan Niethe wrote:
> On Wed, 2019-08-14 at 17:47 +0200, Cédric Le Goater wrote:
>> Currently, the xmon 'dx' command calls OPAL to dump the XIVE state in
>> the OPAL logs and also outputs some of the fields of the internal
>> XIVE
>> structures in Linux. The OPAL calls can only be done on baremetal
>> (PowerNV) and they crash a pseries machine. Fix by checking the
>> hypervisor feature of the CPU.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>  arch/powerpc/xmon/xmon.c | 17 ++++++++++-------
>>  1 file changed, 10 insertions(+), 7 deletions(-)
>>
>> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
>> index 14e56c25879f..25d4adccf750 100644
>> --- a/arch/powerpc/xmon/xmon.c
>> +++ b/arch/powerpc/xmon/xmon.c
>> @@ -2534,13 +2534,16 @@ static void dump_pacas(void)
>>  static void dump_one_xive(int cpu)
>>  {
>>  	unsigned int hwid = get_hard_smp_processor_id(cpu);
>> -
>> -	opal_xive_dump(XIVE_DUMP_TM_HYP, hwid);
>> -	opal_xive_dump(XIVE_DUMP_TM_POOL, hwid);
>> -	opal_xive_dump(XIVE_DUMP_TM_OS, hwid);
>> -	opal_xive_dump(XIVE_DUMP_TM_USER, hwid);
>> -	opal_xive_dump(XIVE_DUMP_VP, hwid);
>> -	opal_xive_dump(XIVE_DUMP_EMU_STATE, hwid);
>> +	bool hv = cpu_has_feature(CPU_FTR_HVMODE);
>> +
>> +	if (hv) {
>> +		opal_xive_dump(XIVE_DUMP_TM_HYP, hwid);
>> +		opal_xive_dump(XIVE_DUMP_TM_POOL, hwid);
>> +		opal_xive_dump(XIVE_DUMP_TM_OS, hwid);
>> +		opal_xive_dump(XIVE_DUMP_TM_USER, hwid);
>> +		opal_xive_dump(XIVE_DUMP_VP, hwid);
>> +		opal_xive_dump(XIVE_DUMP_EMU_STATE, hwid);
>> +	}
>>  
>>  	if (setjmp(bus_error_jmp) != 0) {
>>  		catch_memory_errors = 0;
> dump_one_xive() / other xive functions are guarded by #ifdef
> CONFIG_PPC_POWERNV in xmon.c aren't they? With this series would it be
> that these guards can be removed?

One could compile without CONFIG_PPC_POWERNV but we would still want 
these commands to be available for pseries. I missed that.

I think we should move the opal_xive_dump calls to some other command, 
dxo for 'dump_xive_opal' may be, as they only output in the OPAL logs.

This needs some rework.

Thanks,

C.

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

* Re: [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL
  2019-08-15  8:15     ` Cédric Le Goater
@ 2019-08-15 16:44       ` Cédric Le Goater
  0 siblings, 0 replies; 8+ messages in thread
From: Cédric Le Goater @ 2019-08-15 16:44 UTC (permalink / raw)
  To: Jordan Niethe, Michael Ellerman
  Cc: Paul Mackerras, linuxppc-dev, Nicholas Piggin

On 15/08/2019 10:15, Cédric Le Goater wrote:
> On 15/08/2019 09:30, Jordan Niethe wrote:
>> On Wed, 2019-08-14 at 17:47 +0200, Cédric Le Goater wrote:
>>> Currently, the xmon 'dx' command calls OPAL to dump the XIVE state in
>>> the OPAL logs and also outputs some of the fields of the internal
>>> XIVE
>>> structures in Linux. The OPAL calls can only be done on baremetal
>>> (PowerNV) and they crash a pseries machine. Fix by checking the
>>> hypervisor feature of the CPU.
>>>
>>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>>> ---
>>>  arch/powerpc/xmon/xmon.c | 17 ++++++++++-------
>>>  1 file changed, 10 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
>>> index 14e56c25879f..25d4adccf750 100644
>>> --- a/arch/powerpc/xmon/xmon.c
>>> +++ b/arch/powerpc/xmon/xmon.c
>>> @@ -2534,13 +2534,16 @@ static void dump_pacas(void)
>>>  static void dump_one_xive(int cpu)
>>>  {
>>>  	unsigned int hwid = get_hard_smp_processor_id(cpu);
>>> -
>>> -	opal_xive_dump(XIVE_DUMP_TM_HYP, hwid);
>>> -	opal_xive_dump(XIVE_DUMP_TM_POOL, hwid);
>>> -	opal_xive_dump(XIVE_DUMP_TM_OS, hwid);
>>> -	opal_xive_dump(XIVE_DUMP_TM_USER, hwid);
>>> -	opal_xive_dump(XIVE_DUMP_VP, hwid);
>>> -	opal_xive_dump(XIVE_DUMP_EMU_STATE, hwid);
>>> +	bool hv = cpu_has_feature(CPU_FTR_HVMODE);
>>> +
>>> +	if (hv) {
>>> +		opal_xive_dump(XIVE_DUMP_TM_HYP, hwid);
>>> +		opal_xive_dump(XIVE_DUMP_TM_POOL, hwid);
>>> +		opal_xive_dump(XIVE_DUMP_TM_OS, hwid);
>>> +		opal_xive_dump(XIVE_DUMP_TM_USER, hwid);
>>> +		opal_xive_dump(XIVE_DUMP_VP, hwid);
>>> +		opal_xive_dump(XIVE_DUMP_EMU_STATE, hwid);
>>> +	}
>>>  
>>>  	if (setjmp(bus_error_jmp) != 0) {
>>>  		catch_memory_errors = 0;
>> dump_one_xive() / other xive functions are guarded by #ifdef
>> CONFIG_PPC_POWERNV in xmon.c aren't they? With this series would it be
>> that these guards can be removed?
> 
> One could compile without CONFIG_PPC_POWERNV but we would still want 
> these commands to be available for pseries. I missed that.


The changes below should be enough to activate support for the xive 
commands on pseries and powernv. The patch can come as a follow up.

Cheers,

C. 

--- linux.git.orig/arch/powerpc/xmon/xmon.c
+++ linux.git/arch/powerpc/xmon/xmon.c
@@ -238,7 +238,7 @@ Commands:\n\
   dt	dump the tracing buffers (uses printk)\n\
   dtc	dump the tracing buffers for current CPU (uses printk)\n\
 "
-#ifdef CONFIG_PPC_POWERNV
+#ifdef CONFIG_PPC_BOOK3S_64
 "  dx#   dump xive on CPU #\n\
   dxi#  dump xive irq state #\n\
   dxa   dump xive on all CPUs\n"
@@ -2530,7 +2530,7 @@ static void dump_pacas(void)
 }
 #endif
 
-#ifdef CONFIG_PPC_POWERNV
+#ifdef CONFIG_PPC_BOOK3S_64
 static void dump_one_xive(int cpu)
 {
 	unsigned int hwid = get_hard_smp_processor_id(cpu);
@@ -2632,7 +2632,7 @@ static void dump_xives(void)
 	else
 		dump_one_xive(xmon_owner);
 }
-#endif /* CONFIG_PPC_POWERNV */
+#endif /* CONFIG_PPC_BOOK3S_64 */
 
 static void dump_by_size(unsigned long addr, long count, int size)
 {
@@ -2682,7 +2682,7 @@ dump(void)
 		return;
 	}
 #endif
-#ifdef CONFIG_PPC_POWERNV
+#ifdef CONFIG_PPC_BOOK3S_64
 	if (c == 'x') {
 		xmon_start_pagination();
 		dump_xives();


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

* Re: [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL
  2019-08-14 15:47 ` [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL Cédric Le Goater
  2019-08-15  7:30   ` Jordan Niethe
@ 2019-08-22 13:09   ` Michael Ellerman
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2019-08-22 13:09 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Paul Mackerras, linuxppc-dev, Cédric Le Goater, Nicholas Piggin

[-- Warning: decoded text below may be mangled --]
[-- Attachment #0: Type: text/plain, Size: 570 bytes --]

On Wed, 2019-08-14 at 15:47:52 UTC, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= wrote:
> Currently, the xmon 'dx' command calls OPAL to dump the XIVE state in
> the OPAL logs and also outputs some of the fields of the internal XIVE
> structures in Linux. The OPAL calls can only be done on baremetal
> (PowerNV) and they crash a pseries machine. Fix by checking the
> hypervisor feature of the CPU.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/c3e0dbd7f780a58c4695f1cd8fc8afde80376737

cheers

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

end of thread, back to index

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14 15:47 [PATCH 0/3] powerpc/xmon: Fix dump of XIVE interrupt under pseries Cédric Le Goater
2019-08-14 15:47 ` [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL Cédric Le Goater
2019-08-15  7:30   ` Jordan Niethe
2019-08-15  8:15     ` Cédric Le Goater
2019-08-15 16:44       ` Cédric Le Goater
2019-08-22 13:09   ` Michael Ellerman
2019-08-14 15:47 ` [PATCH 2/3] powerpc/xive: Fix dump of XIVE interrupt under pseries Cédric Le Goater
2019-08-14 15:47 ` [PATCH 3/3] powerpc/xmon: Add a dump of all XIVE interrupts Cédric Le Goater

LinuxPPC-Dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linuxppc-dev/0 linuxppc-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linuxppc-dev linuxppc-dev/ https://lore.kernel.org/linuxppc-dev \
		linuxppc-dev@lists.ozlabs.org linuxppc-dev@ozlabs.org linuxppc-dev@archiver.kernel.org
	public-inbox-index linuxppc-dev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.ozlabs.lists.linuxppc-dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox