Re: [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL

2019-08-22 Thread Michael Ellerman
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 

Series applied to powerpc next, thanks.

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

cheers


Re: [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL

2019-08-15 Thread Cédric Le Goater
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 
>>> ---
>>>  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();



Re: [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL

2019-08-15 Thread Cédric Le Goater
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 
>> ---
>>  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.


Re: [PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL

2019-08-15 Thread Jordan Niethe
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 
> ---
>  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?



[PATCH 1/3] powerpc/xmon: Check for HV mode when dumping XIVE info from OPAL

2019-08-14 Thread Cédric Le Goater
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 
---
 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