Re: [PATCH v2] PowerPC: kernel: compiling issue, make additional room in exception vector area

2013-04-27 Thread Chen Gang F T
On 2013年04月26日 11:54, Mike Qiu wrote:
> 于 2013/4/26 11:42, Chen Gang 写道:
>> On 2013年04月26日 11:25, Chen Gang wrote:
>>> On 2013年04月26日 11:08, Mike Qiu wrote:
 于 2013/4/26 10:06, Chen Gang 写道:
> On 2013年04月26日 10:03, Mike Qiu wrote:
>> �� 2013/4/26 9:36, Chen Gang �:
 On 2013��04��26�� 09:18, Chen Gang wrote:
>> On 2013��04��26�� 09:06, Chen Gang wrote:
>> CFAR is the Come From Register.  It saves the location of the
>> last
 branch and is hence overwritten by any branch.

 Do we process it just like others done (e.g. 0x300, 0xe00,
 0xe20 ...) ?
  . = 0x900
  .globl decrementer_pSeries
 decrementer_pSeries:
HMT_MEDIUM_PPR_DISCARD
  SET_SCRATCH0(r13)
  b decrementer_pSeries_0

  ...


 Oh, it seems EXCEPTION_PROLOG_1 will save the regesters which
 related
 with CFAR, so I think need move EXCEPTION_PROLOG_1 to near 0x900.
>> I will try your diff V2, to see if the machine can boot up
> OK, thanks. (hope it can work)
 It seems that the machine can be bootup in powernv mode, but I'm not
 sure if my machine call that module.

 At lease my machine can boot up
>> Please reference commit number: 1707dd161349e6c54170c88d94fed012e3d224e3
>> (1707dd1 powerpc: Save CFAR before branching in interrupt entry paths)
>>
>> What our diff v2 has done is just the fix for our patch v2 (just like
>> the commit 1707dd1 has done).
>>
>> Please check, thanks.
>>
>> :-)
> I will check this evening or tomorrow, I have something else to do this
> afteroon.

I think the diff v2 is correct, but is not the best one for this issue.

I prefer the Paul's patch for this issue which has better performance

:-)


Thanks.

-- 
Chen Gang

Flying Transformer
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2] PowerPC: kernel: compiling issue, make additional room in exception vector area

2013-04-27 Thread Mike Qiu

于 2013/4/27 17:28, Chen Gang F T 写道:

On 2013年04月26日 11:54, Mike Qiu wrote:

于 2013/4/26 11:42, Chen Gang 写道:

On 2013年04月26日 11:25, Chen Gang wrote:

On 2013年04月26日 11:08, Mike Qiu wrote:

于 2013/4/26 10:06, Chen Gang 写道:

On 2013年04月26日 10:03, Mike Qiu wrote:

�� 2013/4/26 9:36, Chen Gang �:

On 2013��04��26�� 09:18, Chen Gang wrote:

On 2013��04��26�� 09:06, Chen Gang wrote:

CFAR is the Come From Register.  It saves the location of the
last

branch and is hence overwritten by any branch.


Do we process it just like others done (e.g. 0x300, 0xe00,
0xe20 ...) ?
  . = 0x900
  .globl decrementer_pSeries
decrementer_pSeries:
HMT_MEDIUM_PPR_DISCARD
  SET_SCRATCH0(r13)
  b decrementer_pSeries_0

  ...



Oh, it seems EXCEPTION_PROLOG_1 will save the regesters which
related
with CFAR, so I think need move EXCEPTION_PROLOG_1 to near 0x900.

I will try your diff V2, to see if the machine can boot up

OK, thanks. (hope it can work)

It seems that the machine can be bootup in powernv mode, but I'm not
sure if my machine call that module.

At lease my machine can boot up

Please reference commit number: 1707dd161349e6c54170c88d94fed012e3d224e3
(1707dd1 powerpc: Save CFAR before branching in interrupt entry paths)

What our diff v2 has done is just the fix for our patch v2 (just like
the commit 1707dd1 has done).

Please check, thanks.

:-)

I will check this evening or tomorrow, I have something else to do this
afteroon.

I think the diff v2 is correct, but is not the best one for this issue.

I prefer the Paul's patch for this issue which has better performance

:-)

yes, I use your patch and it can work, also Paul's patch can work too.


Thanks.



___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2] PowerPC: kernel: compiling issue, make additional room in exception vector area

2013-04-27 Thread Chen Gang
On 2013年04月27日 17:32, Mike Qiu wrote:
>>>
>> I think the diff v2 is correct, but is not the best one for this issue.
>>
>> I prefer the Paul's patch for this issue which has better performance
>>
>> :-)
> yes, I use your patch and it can work, also Paul's patch can work too.

Good news.

Bye !

:-)

-- 
Chen Gang

Asianux Corporation
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc: Fix "attempt to move .org backwards" error

2013-04-27 Thread Mike Qiu

于 2013/4/26 11:51, Paul Mackerras 写道:

Building a 64-bit powerpc kernel with PR KVM enabled currently gives
this error:

   AS  arch/powerpc/kernel/head_64.o
arch/powerpc/kernel/exceptions-64s.S: Assembler messages:
arch/powerpc/kernel/exceptions-64s.S:258: Error: attempt to move .org backwards
make[2]: *** [arch/powerpc/kernel/head_64.o] Error 1

This happens because the MASKABLE_EXCEPTION_PSERIES macro turns into
33 instructions, but we only have space for 32 at the decrementer
interrupt vector (from 0x900 to 0x980).

In the code generated by the MASKABLE_EXCEPTION_PSERIES macro, we
currently have two instances of the HMT_MEDIUM macro, which has the
effect of setting the SMT thread priority to medium.  One is the
first instruction, and is overwritten by a no-op on processors where
we save the PPR (processor priority register), that is, POWER7 or
later.  The other is after we have saved the PPR.

In order to reduce the code at 0x900 by one instruction, we omit the
first HMT_MEDIUM.  On processors without SMT this will have no effect
since HMT_MEDIUM is a no-op there.  On POWER5 and RS64 machines this
will mean that the first few instructions take a little longer in the
case where a decrementer interrupt occurs when the hardware thread is
running at low SMT priority.  On POWER6 and later machines, the
hardware automatically boosts the thread priority when a decrementer
interrupt is taken if the thread priority was below medium, so this
change won't make any difference.

The alternative would be to branch out of line after saving the CFAR.
However, that would incur an extra overhead on all processors, whereas
the approach adopted here only adds overhead on older threaded processors.

Signed-off-by: Paul Mackerras 
---
  arch/powerpc/include/asm/exception-64s.h |2 +-
  arch/powerpc/kernel/exceptions-64s.S |7 ++-
  2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/exception-64s.h 
b/arch/powerpc/include/asm/exception-64s.h
index 05e6d2e..8e5fae8 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -414,7 +414,6 @@ label##_relon_hv:   
\
  #define SOFTEN_NOTEST_HV(vec) _SOFTEN_TEST(EXC_HV, vec)

  #define __MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra)\
-   HMT_MEDIUM_PPR_DISCARD; \
SET_SCRATCH0(r13);/* save r13 */\
EXCEPTION_PROLOG_0(PACA_EXGEN); \
__EXCEPTION_PROLOG_1(PACA_EXGEN, extra, vec);   \
@@ -427,6 +426,7 @@ label##_relon_hv:   
\
. = loc;\
.globl label##_pSeries; \
  label##_pSeries:  \
+   HMT_MEDIUM_PPR_DISCARD; \
_MASKABLE_EXCEPTION_PSERIES(vec, label, \
EXC_STD, SOFTEN_TEST_PR)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 56bd923..574db3f 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -235,6 +235,7 @@ instruction_access_slb_pSeries:
.globl hardware_interrupt_hv;
  hardware_interrupt_pSeries:
  hardware_interrupt_hv:
+   HMT_MEDIUM_PPR_DISCARD
BEGIN_FTR_SECTION
_MASKABLE_EXCEPTION_PSERIES(0x502, hardware_interrupt,
EXC_HV, SOFTEN_TEST_HV)
@@ -254,7 +255,11 @@ hardware_interrupt_hv:
STD_EXCEPTION_PSERIES(0x800, 0x800, fp_unavailable)
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x800)

-   MASKABLE_EXCEPTION_PSERIES(0x900, 0x900, decrementer)
+   . = 0x900
+   .globl decrementer_pSeries
+decrementer_pSeries:
+   _MASKABLE_EXCEPTION_PSERIES(0x900, decrementer, EXC_STD, SOFTEN_TEST_PR)
+
STD_EXCEPTION_HV(0x980, 0x982, hdecrementer)

MASKABLE_EXCEPTION_PSERIES(0xa00, 0xa00, doorbell_super)

test-by: Mike Qiu 
It's workable for me. but I just use this patch to compile and boot up 
the machine. not do any performance test:)


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 2/2 V7] powerpc/85xx: Add machine check handler to fix PCIe erratum on mpc85xx

2013-04-27 Thread Segher Boessenkool

In former email you doubt whether we need A variant or not.
Any particular reason for that?
If not should I emulate all the A ARX AU AUX and AX variant?


A/AU/AX/AUX are just normal loads, sign-extended instead of
zero-extended (so assign -1 to the register loaded).

The ARX thing is load-locked, you do not want that one.


Segher
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


RE: [PATCH 2/2 V7] powerpc/85xx: Add machine check handler to fix PCIe erratum on mpc85xx

2013-04-27 Thread Jia Hongtao-B38951


> -Original Message-
> From: Segher Boessenkool [mailto:seg...@kernel.crashing.org]
> Sent: Saturday, April 27, 2013 9:32 PM
> To: Jia Hongtao-B38951
> Cc: Wood Scott-B07421; linuxppc-dev@lists.ozlabs.org;
> ga...@kernel.crashing.org
> Subject: Re: [PATCH 2/2 V7] powerpc/85xx: Add machine check handler to
> fix PCIe erratum on mpc85xx
> 
> > In former email you doubt whether we need A variant or not.
> > Any particular reason for that?
> > If not should I emulate all the A ARX AU AUX and AX variant?
> 
> A/AU/AX/AUX are just normal loads, sign-extended instead of zero-extended
> (so assign -1 to the register loaded).
> 
> The ARX thing is load-locked, you do not want that one.
> 
> 
> Segher

Thanks, very helpful.
-Hongtao

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/2 V2] powerpc: Move opcode definitions from kvm/emulate.c to asm/ppc-opcode.h

2013-04-27 Thread Jia Hongtao
Opcode and xopcode are useful definitions not just for KVM. Move these
definitions to asm/ppc-opcode.h for public use.

Signed-off-by: Jia Hongtao 
Signed-off-by: Li Yang 
---
V2:
* Add LHAUX definition.

 arch/powerpc/include/asm/ppc-opcode.h | 46 +++
 arch/powerpc/kvm/emulate.c| 44 +
 2 files changed, 47 insertions(+), 43 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
b/arch/powerpc/include/asm/ppc-opcode.h
index 8752bc8..79057f7 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -81,6 +81,52 @@
 #define__REGA0_R30 30
 #define__REGA0_R31 31
 
+/* opcode and xopcode for instructions */
+#define OP_TRAP 3
+#define OP_TRAP_64 2
+
+#define OP_31_XOP_TRAP  4
+#define OP_31_XOP_LWZX  23
+#define OP_31_XOP_LWZUX 55
+#define OP_31_XOP_TRAP_64   68
+#define OP_31_XOP_DCBF  86
+#define OP_31_XOP_LBZX  87
+#define OP_31_XOP_STWX  151
+#define OP_31_XOP_STBX  215
+#define OP_31_XOP_LBZUX 119
+#define OP_31_XOP_STBUX 247
+#define OP_31_XOP_LHZX  279
+#define OP_31_XOP_LHZUX 311
+#define OP_31_XOP_MFSPR 339
+#define OP_31_XOP_LHAX  343
+#define OP_31_XOP_LHAUX 375
+#define OP_31_XOP_STHX  407
+#define OP_31_XOP_STHUX 439
+#define OP_31_XOP_MTSPR 467
+#define OP_31_XOP_DCBI  470
+#define OP_31_XOP_LWBRX 534
+#define OP_31_XOP_TLBSYNC   566
+#define OP_31_XOP_STWBRX662
+#define OP_31_XOP_LHBRX 790
+#define OP_31_XOP_STHBRX918
+
+#define OP_LWZ  32
+#define OP_LD   58
+#define OP_LWZU 33
+#define OP_LBZ  34
+#define OP_LBZU 35
+#define OP_STW  36
+#define OP_STWU 37
+#define OP_STD  62
+#define OP_STB  38
+#define OP_STBU 39
+#define OP_LHZ  40
+#define OP_LHZU 41
+#define OP_LHA  42
+#define OP_LHAU 43
+#define OP_STH  44
+#define OP_STHU 45
+
 /* sorted alphabetically */
 #define PPC_INST_DCBA  0x7c0005ec
 #define PPC_INST_DCBA_MASK 0xfc0007fe
diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index 7a73b6f..426d3f5 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -30,52 +30,10 @@
 #include 
 #include 
 #include 
+#include 
 #include "timing.h"
 #include "trace.h"
 
-#define OP_TRAP 3
-#define OP_TRAP_64 2
-
-#define OP_31_XOP_TRAP  4
-#define OP_31_XOP_LWZX  23
-#define OP_31_XOP_TRAP_64   68
-#define OP_31_XOP_DCBF  86
-#define OP_31_XOP_LBZX  87
-#define OP_31_XOP_STWX  151
-#define OP_31_XOP_STBX  215
-#define OP_31_XOP_LBZUX 119
-#define OP_31_XOP_STBUX 247
-#define OP_31_XOP_LHZX  279
-#define OP_31_XOP_LHZUX 311
-#define OP_31_XOP_MFSPR 339
-#define OP_31_XOP_LHAX  343
-#define OP_31_XOP_STHX  407
-#define OP_31_XOP_STHUX 439
-#define OP_31_XOP_MTSPR 467
-#define OP_31_XOP_DCBI  470
-#define OP_31_XOP_LWBRX 534
-#define OP_31_XOP_TLBSYNC   566
-#define OP_31_XOP_STWBRX662
-#define OP_31_XOP_LHBRX 790
-#define OP_31_XOP_STHBRX918
-
-#define OP_LWZ  32
-#define OP_LD   58
-#define OP_LWZU 33
-#define OP_LBZ  34
-#define OP_LBZU 35
-#define OP_STW  36
-#define OP_STWU 37
-#define OP_STD  62
-#define OP_STB  38
-#define OP_STBU 39
-#define OP_LHZ  40
-#define OP_LHZU 41
-#define OP_LHA  42
-#define OP_LHAU 43
-#define OP_STH  44
-#define OP_STHU 45
-
 void kvmppc_emulate_dec(struct kvm_vcpu *vcpu)
 {
unsigned long dec_nsec;
-- 
1.8.0


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 2/2 V8] powerpc/85xx: Add machine check handler to fix PCIe erratum on mpc85xx

2013-04-27 Thread Jia Hongtao
A PCIe erratum of mpc85xx may causes a core hang when a link of PCIe
goes down. when the link goes down, Non-posted transactions issued
via the ATMU requiring completion result in an instruction stall.
At the same time a machine-check exception is generated to the core
to allow further processing by the handler. We implements the handler
which skips the instruction caused the stall.

This patch depends on patch:
powerpc/85xx: Add platform_device declaration to fsl_pci.h

Signed-off-by: Zhao Chenhui 
Signed-off-by: Li Yang 
Signed-off-by: Liu Shuo 
Signed-off-by: Jia Hongtao 
---
V8:
* Add A variant load instruction emulation.

V7:
* Correct PCIe checking method (Using indirect_type member of pci_controller
  stucture).

V6:
* Move OP and XOP defines to a new header file: asm/ppc-disassemble.h
* Add X UX BRX variant of load instruction emulation
* Remove A variant of load instruction emulation

V5:
* Fill rd with all-Fs if the skipped instruction is load and emulate the
  instruction.
* Let KVM/QEMU deal with the exception if the machine check comes from KVM.

 arch/powerpc/kernel/cpu_setup_fsl_booke.S |   2 +-
 arch/powerpc/kernel/traps.c   |   3 +
 arch/powerpc/sysdev/fsl_pci.c | 158 ++
 arch/powerpc/sysdev/fsl_pci.h |   6 ++
 4 files changed, 168 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/cpu_setup_fsl_booke.S 
b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
index 0b9af01..bfb18c7 100644
--- a/arch/powerpc/kernel/cpu_setup_fsl_booke.S
+++ b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
@@ -75,7 +75,7 @@ _GLOBAL(__setup_cpu_e500v2)
bl  __e500_icache_setup
bl  __e500_dcache_setup
bl  __setup_e500_ivors
-#ifdef CONFIG_FSL_RIO
+#if defined(CONFIG_FSL_RIO) || defined(CONFIG_FSL_PCI)
/* Ensure that RFXE is set */
mfspr   r3,SPRN_HID1
orisr3,r3,HID1_RFXE@h
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 37cc40e..d15cfb5 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -60,6 +60,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
 int (*__debugger)(struct pt_regs *regs) __read_mostly;
@@ -565,6 +566,8 @@ int machine_check_e500(struct pt_regs *regs)
if (reason & MCSR_BUS_RBERR) {
if (fsl_rio_mcheck_exception(regs))
return 1;
+   if (fsl_pci_mcheck_exception(regs))
+   return 1;
}
 
printk("Machine check in kernel mode.\n");
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 40ffe29..5fa851a 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -26,11 +26,15 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -876,6 +880,160 @@ u64 fsl_pci_immrbar_base(struct pci_controller *hose)
return 0;
 }
 
+#ifdef CONFIG_E500
+static int mcheck_handle_load(struct pt_regs *regs, u32 inst)
+{
+   unsigned int rd, ra, rb, d;
+
+   rd = get_rt(inst);
+   ra = get_ra(inst);
+   rb = get_rb(inst);
+   d = get_d(inst);
+
+   switch (get_op(inst)) {
+   case 31:
+   switch (get_xop(inst)) {
+   case OP_31_XOP_LWZX:
+   case OP_31_XOP_LWBRX:
+   regs->gpr[rd] = 0x;
+   break;
+
+   case OP_31_XOP_LWZUX:
+   regs->gpr[rd] = 0x;
+   regs->gpr[ra] += regs->gpr[rb];
+   break;
+
+   case OP_31_XOP_LBZX:
+   regs->gpr[rd] = 0xff;
+   break;
+
+   case OP_31_XOP_LBZUX:
+   regs->gpr[rd] = 0xff;
+   regs->gpr[ra] += regs->gpr[rb];
+   break;
+
+   case OP_31_XOP_LHZX:
+   case OP_31_XOP_LHBRX:
+   regs->gpr[rd] = 0x;
+   break;
+
+   case OP_31_XOP_LHZUX:
+   regs->gpr[rd] = 0x;
+   regs->gpr[ra] += regs->gpr[rb];
+   break;
+
+   case OP_31_XOP_LHAX:
+   regs->gpr[rd] = ~0UL;
+   break;
+
+   case OP_31_XOP_LHAUX:
+   regs->gpr[rd] = ~0UL;
+   regs->gpr[ra] += regs->gpr[rb];
+   break;
+
+   default:
+   return 0;
+   }
+   break;
+
+   case OP_LWZ:
+   regs->gpr[rd] = 0x;
+   break;
+
+   case OP_LWZU:
+   regs->gpr[rd] = 0x;
+   regs->gpr[ra] += (s16)d;
+   break;
+
+   case OP_LBZ:
+   regs->gpr[rd] = 0xff