Re: [PATCH 06/28] powerpc/64s/exception: remove the "extra" macro parameter

2019-06-19 Thread Michael Ellerman
Nicholas Piggin  writes:
> Nicholas Piggin's on June 12, 2019 12:30 am:
>> @@ -265,7 +275,7 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
>>  EXC_REAL_END(machine_check, 0x200, 0x100)
>>  EXC_VIRT_NONE(0x4200, 0x100)
>>  TRAMP_REAL_BEGIN(machine_check_common_early)
>> -EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
>> +EXCEPTION_PROLOG_1 EXC_HV, PACA_EXMC, 0, 0x200
>>  /*
>>   * Register contents:
>>   * R13  = PACA
>
> This is a little bug here, machine check is an EXC_STD exception. It
> does not show up as generated code problem because EXCEPTION_PROLOG_1
> does not actually do anything with this parameter if KVM is false,
> which it is here.
>
> Still, it's wrong. I may just resend the series, because it caused a
> few conflicts in subsequent patches, and I have a few more to add to
> the end.

OK. I'll pull the series out for now.

cheers


Re: [PATCH 06/28] powerpc/64s/exception: remove the "extra" macro parameter

2019-06-19 Thread Nicholas Piggin
Nicholas Piggin's on June 12, 2019 12:30 am:
> @@ -265,7 +275,7 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
>  EXC_REAL_END(machine_check, 0x200, 0x100)
>  EXC_VIRT_NONE(0x4200, 0x100)
>  TRAMP_REAL_BEGIN(machine_check_common_early)
> - EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
> + EXCEPTION_PROLOG_1 EXC_HV, PACA_EXMC, 0, 0x200
>   /*
>* Register contents:
>* R13  = PACA

This is a little bug here, machine check is an EXC_STD exception. It
does not show up as generated code problem because EXCEPTION_PROLOG_1
does not actually do anything with this parameter if KVM is false,
which it is here.

Still, it's wrong. I may just resend the series, because it caused a
few conflicts in subsequent patches, and I have a few more to add to
the end.

Thanks,
Nick



[PATCH 06/28] powerpc/64s/exception: remove the "extra" macro parameter

2019-06-11 Thread Nicholas Piggin
Rather than pass in the soft-masking and KVM tests via macro that is
passed to another macro to expand it, switch to usig gas macros and
conditionally expand the soft-masking and KVM tests.

The system reset with its idle test is open coded as it is a one-off.

No generated code change.

Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/include/asm/exception-64s.h | 158 ++-
 arch/powerpc/kernel/exceptions-64s.S |  78 ++-
 2 files changed, 114 insertions(+), 122 deletions(-)

diff --git a/arch/powerpc/include/asm/exception-64s.h 
b/arch/powerpc/include/asm/exception-64s.h
index 4aef70defcdd..e1b449e2c9ea 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -231,10 +231,10 @@
  * rfid. Save CTR in case we're CONFIG_RELOCATABLE, in which case
  * EXCEPTION_PROLOG_2_VIRT will be using CTR.
  */
-#define EXCEPTION_RELON_PROLOG(area, label, hsrr, extra, vec)  \
+#define EXCEPTION_RELON_PROLOG(area, label, hsrr, kvm, vec)\
SET_SCRATCH0(r13);  /* save r13 */  \
EXCEPTION_PROLOG_0(area);   \
-   EXCEPTION_PROLOG_1(area, extra, vec);   \
+   EXCEPTION_PROLOG_1 hsrr, area, kvm, vec ;   \
EXCEPTION_PROLOG_2_VIRT label, hsrr
 
 /* Exception register prefixes */
@@ -321,31 +321,58 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
 /*
  * This version of the EXCEPTION_PROLOG_1 will carry
  * addition parameter called "bitmask" to support
- * checking of the interrupt maskable level in the SOFTEN_TEST.
+ * checking of the interrupt maskable level.
  * Intended to be used in MASKABLE_EXCPETION_* macros.
  */
-#define MASKABLE_EXCEPTION_PROLOG_1(area, extra, vec, bitmask) 
\
-   __EXCEPTION_PROLOG_1_PRE(area); \
-   extra(vec, bitmask);\
-   __EXCEPTION_PROLOG_1_POST(area)
+.macro MASKABLE_EXCEPTION_PROLOG_1 hsrr, area, kvm, vec, bitmask
+   __EXCEPTION_PROLOG_1_PRE(\area\())
+   .if \kvm
+   KVMTEST \hsrr \vec
+   .endif
+
+   lbz r10,PACAIRQSOFTMASK(r13)
+   andi.   r10,r10,\bitmask
+   /* This associates vector numbers with bits in paca->irq_happened */
+   .if \vec == 0x500 || \vec == 0xea0
+   li  r10,PACA_IRQ_EE
+   .elseif \vec == 0x900 || \vec == 0xea0
+   li  r10,PACA_IRQ_DEC
+   .elseif \vec == 0xa00 || \vec == 0xe80
+   li  r10,PACA_IRQ_DBELL
+   .elseif \vec == 0xe60
+   li  r10,PACA_IRQ_HMI
+   .elseif \vec == 0xf00
+   li  r10,PACA_IRQ_PMI
+   .else
+   .abort "Bad maskable vector"
+   .endif
+
+   .if \hsrr
+   bne masked_Hinterrupt
+   .else
+   bne masked_interrupt
+   .endif
+
+   __EXCEPTION_PROLOG_1_POST(\area\())
+.endm
 
 /*
  * This version of the EXCEPTION_PROLOG_1 is intended
  * to be used in STD_EXCEPTION* macros
  */
-#define _EXCEPTION_PROLOG_1(area, extra, vec)  \
-   __EXCEPTION_PROLOG_1_PRE(area); \
-   extra(vec); \
-   __EXCEPTION_PROLOG_1_POST(area)
-
-#define EXCEPTION_PROLOG_1(area, extra, vec)   \
-   _EXCEPTION_PROLOG_1(area, extra, vec)
+.macro EXCEPTION_PROLOG_1 hsrr, area, kvm, vec
+   __EXCEPTION_PROLOG_1_PRE(\area\())
+   .if \kvm
+   KVMTEST \hsrr \vec
+   .endif
+   __EXCEPTION_PROLOG_1_POST(\area\())
+.endm
 
-#define EXCEPTION_PROLOG(area, label, h, extra, vec)   \
+#define EXCEPTION_PROLOG(area, label, hsrr, kvm, vec)  \
SET_SCRATCH0(r13);  /* save r13 */  \
EXCEPTION_PROLOG_0(area);   \
-   EXCEPTION_PROLOG_1(area, extra, vec);   \
-   EXCEPTION_PROLOG_2_REAL label, h, 1
+   EXCEPTION_PROLOG_1 hsrr, area, kvm, vec ;   \
+   EXCEPTION_PROLOG_2_REAL label, hsrr, 1
 
 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
 /*
@@ -411,10 +438,10 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
 #endif
 
 /* Do not enable RI */
-#define EXCEPTION_PROLOG_NORI(area, label, h, extra, vec)  \
+#define EXCEPTION_PROLOG_NORI(area, label, hsrr, kvm, vec) \
EXCEPTION_PROLOG_0(area);   \
-   EXCEPTION_PROLOG_1(area, extra, vec);   \
-   EXCEPTION_PROLOG_2_REAL label, h, 0
+   EXCEPTION_PROLOG_1 hsrr, area, kvm, vec ;   \
+   EXCEPTION_PROLOG_2_REAL label, hsrr, 0
 
 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
 .macro KVMTEST hsrr, n
@@ -476,8 +503,6 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
 .endm
 #endif
 
-#define NOTEST(n)
-
 #define EXCEPTION_PROLOG_COMMON_1()