powerpc: Fix "attempt to move .org backwards" error
PATCH 1/1 powerpc: Fix "attempt to move .org backwards" error
Building a 64-bit powerpc kernel with PR KVM enabled currently gives this error:
AS arch/powerpc/kernel/head_64.oarch/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.
--- arch/powerpc/include/asm/exception-64s.h | 2 +- arch/powerpc/kernel/exceptions-64s.S | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/exception-64s.h +1 -1
@@ -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 )
arch/powerpc/kernel/exceptions-64s.S +6 -1
@@ -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)
Signature · 1 line
1.7.10.4
Quoted 29 lines · Paul Mackerras
Building a 64-bit powerpc kernel with PR KVM enabled currently gives this error:
AS
arch/powerpc/kernel/head_64.oarch/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 1This happens because the
MASKABLE_EXCEPTION_PSERIESmacro turns into 33 instructions, but we only have space for 32 at the decrementer interrupt vector (from0x900to0x980).In the code generated by the
MASKABLE_EXCEPTION_PSERIESmacro, we currently have two instances of theHMT_MEDIUMmacro, 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
0x900by one instruction, we omit the firstHMT_MEDIUM. On processors without SMT this will have no effect sinceHMT_MEDIUMis 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.
Quoted 6 lines
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 <[email protected]>---
Hello Mike:
Please try Paul's patch, firstly.
:-)
Thanks.
Quoted 50 lines
arch/powerpc/include/asm/exception-64s.h | 2 +- arch/powerpc/kernel/exceptions-64s.S | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-)arch/powerpc/include/asm/exception-64s.h +1
-1@@ -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 )arch/powerpc/kernel/exceptions-64s.S +6
-1@@ -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)
Signature · 3 lines
Chen Gang Asianux Corporation
Quoted 74 lines · Paul Mackerras
Building a 64-bit powerpc kernel with PR KVM enabled currently gives this error:
AS
arch/powerpc/kernel/head_64.oarch/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 1This happens because the
MASKABLE_EXCEPTION_PSERIESmacro turns into 33 instructions, but we only have space for 32 at the decrementer interrupt vector (from0x900to0x980).In the code generated by the
MASKABLE_EXCEPTION_PSERIESmacro, we currently have two instances of theHMT_MEDIUMmacro, 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
0x900by one instruction, we omit the firstHMT_MEDIUM. On processors without SMT this will have no effect sinceHMT_MEDIUMis 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 <[email protected]>--- arch/powerpc/include/asm/exception-64s.h | 2 +- arch/powerpc/kernel/exceptions-64s.S | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-)arch/powerpc/include/asm/exception-64s.h +1
-1@@ -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 )arch/powerpc/kernel/exceptions-64s.S +1
-0@@ -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)
arch/powerpc/kernel/exceptions-64s.S hardware_interrupt_hv: · line 265
Quoted 10 lines
arch/powerpc/kernel/exceptions-64s.S +5
-1- 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)
It's workable for me. but I just use this patch to compile and boot up the machine. not do any performance test:)