Skip to content

Commit 3f7fbd9

Browse files
npigginmpe
authored andcommitted
powerpc/64s/exception: Clean up SRR specifiers
Remove more magic numbers and replace with nicely named bools. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200225173541.1549955-19-npiggin@gmail.com
1 parent 689e732 commit 3f7fbd9

1 file changed

Lines changed: 32 additions & 36 deletions

File tree

‎arch/powerpc/kernel/exceptions-64s.S‎

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,6 @@ name:
105105
ori reg,reg,(ABS_ADDR(label))@l; \
106106
addis reg,reg,(ABS_ADDR(label))@h
107107

108-
/* Exception register prefixes */
109-
#define EXC_HV_OR_STD 2 /* depends on HVMODE */
110-
#define EXC_HV 1
111-
#define EXC_STD 0
112-
113108
/*
114109
* Branch to label using its 0xC000 address. This results in instruction
115110
* address suitable for MSR[IR]=0 or 1, which allows relocation to be turned
@@ -128,6 +123,7 @@ name:
128123
*/
129124
#define IVEC .L_IVEC_\name\()
130125
#define IHSRR .L_IHSRR_\name\()
126+
#define IHSRR_IF_HVMODE .L_IHSRR_IF_HVMODE_\name\()
131127
#define IAREA .L_IAREA_\name\()
132128
#define IVIRT .L_IVIRT_\name\()
133129
#define IISIDE .L_IISIDE_\name\()
@@ -159,7 +155,10 @@ do_define_int n
159155
.error "IVEC not defined"
160156
.endif
161157
.ifndef IHSRR
162-
IHSRR=EXC_STD
158+
IHSRR=0
159+
.endif
160+
.ifndef IHSRR_IF_HVMODE
161+
IHSRR_IF_HVMODE=0
163162
.endif
164163
.ifndef IAREA
165164
IAREA=PACA_EXGEN
@@ -257,7 +256,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
257256
ld r9,IAREA+EX_R9(r13)
258257
ld r10,IAREA+EX_R10(r13)
259258
/* HSRR variants have the 0x2 bit added to their trap number */
260-
.if IHSRR == EXC_HV_OR_STD
259+
.if IHSRR_IF_HVMODE
261260
BEGIN_FTR_SECTION
262261
ori r12,r12,(IVEC + 0x2)
263262
FTR_SECTION_ELSE
@@ -278,7 +277,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
278277
ld r10,IAREA+EX_R10(r13)
279278
ld r11,IAREA+EX_R11(r13)
280279
ld r12,IAREA+EX_R12(r13)
281-
.if IHSRR == EXC_HV_OR_STD
280+
.if IHSRR_IF_HVMODE
282281
BEGIN_FTR_SECTION
283282
b kvmppc_skip_Hinterrupt
284283
FTR_SECTION_ELSE
@@ -403,7 +402,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
403402
stw r10,IAREA+EX_DSISR(r13)
404403
.endif
405404

406-
.if IHSRR == EXC_HV_OR_STD
405+
.if IHSRR_IF_HVMODE
407406
BEGIN_FTR_SECTION
408407
mfspr r11,SPRN_HSRR0 /* save HSRR0 */
409408
mfspr r12,SPRN_HSRR1 /* and HSRR1 */
@@ -499,7 +498,7 @@ DEFINE_FIXED_SYMBOL(\name\()_common_real)
499498
.abort "Bad maskable vector"
500499
.endif
501500

502-
.if IHSRR == EXC_HV_OR_STD
501+
.if IHSRR_IF_HVMODE
503502
BEGIN_FTR_SECTION
504503
bne masked_Hinterrupt
505504
FTR_SECTION_ELSE
@@ -632,12 +631,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
632631
* Restore all registers including H/SRR0/1 saved in a stack frame of a
633632
* standard exception.
634633
*/
635-
.macro EXCEPTION_RESTORE_REGS hsrr
634+
.macro EXCEPTION_RESTORE_REGS hsrr=0
636635
/* Move original SRR0 and SRR1 into the respective regs */
637636
ld r9,_MSR(r1)
638-
.if \hsrr == EXC_HV_OR_STD
639-
.error "EXC_HV_OR_STD Not implemented for EXCEPTION_RESTORE_REGS"
640-
.endif
641637
.if \hsrr
642638
mtspr SPRN_HSRR1,r9
643639
.else
@@ -912,7 +908,7 @@ EXC_COMMON_BEGIN(system_reset_common)
912908
ld r10,SOFTE(r1)
913909
stb r10,PACAIRQSOFTMASK(r13)
914910

915-
EXCEPTION_RESTORE_REGS EXC_STD
911+
EXCEPTION_RESTORE_REGS
916912
RFI_TO_USER_OR_KERNEL
917913

918914
GEN_KVM system_reset
@@ -966,7 +962,7 @@ TRAMP_REAL_BEGIN(machine_check_fwnmi)
966962
lhz r12,PACA_IN_MCE(r13); \
967963
subi r12,r12,1; \
968964
sth r12,PACA_IN_MCE(r13); \
969-
EXCEPTION_RESTORE_REGS EXC_STD
965+
EXCEPTION_RESTORE_REGS
970966

971967
EXC_COMMON_BEGIN(machine_check_early_common)
972968
__GEN_REALMODE_COMMON_ENTRY machine_check_early
@@ -1337,7 +1333,7 @@ ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
13371333

13381334
INT_DEFINE_BEGIN(hardware_interrupt)
13391335
IVEC=0x500
1340-
IHSRR=EXC_HV_OR_STD
1336+
IHSRR_IF_HVMODE=1
13411337
IMASK=IRQS_DISABLED
13421338
IKVM_REAL=1
13431339
IKVM_VIRT=1
@@ -1506,7 +1502,7 @@ EXC_COMMON_BEGIN(decrementer_common)
15061502

15071503
INT_DEFINE_BEGIN(hdecrementer)
15081504
IVEC=0x980
1509-
IHSRR=EXC_HV
1505+
IHSRR=1
15101506
ISTACK=0
15111507
IRECONCILE=0
15121508
IKVM_REAL=1
@@ -1735,7 +1731,7 @@ EXC_COMMON_BEGIN(single_step_common)
17351731

17361732
INT_DEFINE_BEGIN(h_data_storage)
17371733
IVEC=0xe00
1738-
IHSRR=EXC_HV
1734+
IHSRR=1
17391735
IDAR=1
17401736
IDSISR=1
17411737
IKVM_SKIP=1
@@ -1767,7 +1763,7 @@ ALT_MMU_FTR_SECTION_END_IFSET(MMU_FTR_TYPE_RADIX)
17671763

17681764
INT_DEFINE_BEGIN(h_instr_storage)
17691765
IVEC=0xe20
1770-
IHSRR=EXC_HV
1766+
IHSRR=1
17711767
IKVM_REAL=1
17721768
IKVM_VIRT=1
17731769
INT_DEFINE_END(h_instr_storage)
@@ -1790,7 +1786,7 @@ EXC_COMMON_BEGIN(h_instr_storage_common)
17901786

17911787
INT_DEFINE_BEGIN(emulation_assist)
17921788
IVEC=0xe40
1793-
IHSRR=EXC_HV
1789+
IHSRR=1
17941790
IKVM_REAL=1
17951791
IKVM_VIRT=1
17961792
INT_DEFINE_END(emulation_assist)
@@ -1818,7 +1814,7 @@ EXC_COMMON_BEGIN(emulation_assist_common)
18181814
*/
18191815
INT_DEFINE_BEGIN(hmi_exception_early)
18201816
IVEC=0xe60
1821-
IHSRR=EXC_HV
1817+
IHSRR=1
18221818
IREALMODE_COMMON=1
18231819
ISTACK=0
18241820
IRECONCILE=0
@@ -1828,7 +1824,7 @@ INT_DEFINE_END(hmi_exception_early)
18281824

18291825
INT_DEFINE_BEGIN(hmi_exception)
18301826
IVEC=0xe60
1831-
IHSRR=EXC_HV
1827+
IHSRR=1
18321828
IMASK=IRQS_DISABLED
18331829
IKVM_REAL=1
18341830
INT_DEFINE_END(hmi_exception)
@@ -1852,15 +1848,15 @@ EXC_COMMON_BEGIN(hmi_exception_early_common)
18521848
cmpdi cr0,r3,0
18531849
bne 1f
18541850

1855-
EXCEPTION_RESTORE_REGS EXC_HV
1851+
EXCEPTION_RESTORE_REGS hsrr=1
18561852
HRFI_TO_USER_OR_KERNEL
18571853

18581854
1:
18591855
/*
18601856
* Go to virtual mode and pull the HMI event information from
18611857
* firmware.
18621858
*/
1863-
EXCEPTION_RESTORE_REGS EXC_HV
1859+
EXCEPTION_RESTORE_REGS hsrr=1
18641860
GEN_INT_ENTRY hmi_exception, virt=0
18651861

18661862
GEN_KVM hmi_exception_early
@@ -1879,7 +1875,7 @@ EXC_COMMON_BEGIN(hmi_exception_common)
18791875

18801876
INT_DEFINE_BEGIN(h_doorbell)
18811877
IVEC=0xe80
1882-
IHSRR=EXC_HV
1878+
IHSRR=1
18831879
IMASK=IRQS_DISABLED
18841880
IKVM_REAL=1
18851881
IKVM_VIRT=1
@@ -1908,7 +1904,7 @@ EXC_COMMON_BEGIN(h_doorbell_common)
19081904

19091905
INT_DEFINE_BEGIN(h_virt_irq)
19101906
IVEC=0xea0
1911-
IHSRR=EXC_HV
1907+
IHSRR=1
19121908
IMASK=IRQS_DISABLED
19131909
IKVM_REAL=1
19141910
IKVM_VIRT=1
@@ -2078,7 +2074,7 @@ EXC_COMMON_BEGIN(facility_unavailable_common)
20782074

20792075
INT_DEFINE_BEGIN(h_facility_unavailable)
20802076
IVEC=0xf80
2081-
IHSRR=EXC_HV
2077+
IHSRR=1
20822078
IKVM_REAL=1
20832079
IKVM_VIRT=1
20842080
INT_DEFINE_END(h_facility_unavailable)
@@ -2114,7 +2110,7 @@ EXC_VIRT_NONE(0x5100, 0x100)
21142110
#ifdef CONFIG_CBE_RAS
21152111
INT_DEFINE_BEGIN(cbe_system_error)
21162112
IVEC=0x1200
2117-
IHSRR=EXC_HV
2113+
IHSRR=1
21182114
IKVM_SKIP=1
21192115
IKVM_REAL=1
21202116
INT_DEFINE_END(cbe_system_error)
@@ -2165,8 +2161,8 @@ EXC_VIRT_NONE(0x5400, 0x100)
21652161

21662162
INT_DEFINE_BEGIN(denorm_exception)
21672163
IVEC=0x1500
2168-
IHSRR=EXC_HV
2169-
IBRANCH_TO_COMMON=0
2164+
IHSRR=1
2165+
IBRANCH_COMMON=0
21702166
IKVM_REAL=1
21712167
INT_DEFINE_END(denorm_exception)
21722168

@@ -2274,7 +2270,7 @@ EXC_COMMON_BEGIN(denorm_exception_common)
22742270
#ifdef CONFIG_CBE_RAS
22752271
INT_DEFINE_BEGIN(cbe_maintenance)
22762272
IVEC=0x1600
2277-
IHSRR=EXC_HV
2273+
IHSRR=1
22782274
IKVM_SKIP=1
22792275
IKVM_REAL=1
22802276
INT_DEFINE_END(cbe_maintenance)
@@ -2326,7 +2322,7 @@ EXC_COMMON_BEGIN(altivec_assist_common)
23262322
#ifdef CONFIG_CBE_RAS
23272323
INT_DEFINE_BEGIN(cbe_thermal)
23282324
IVEC=0x1800
2329-
IHSRR=EXC_HV
2325+
IHSRR=1
23302326
IKVM_SKIP=1
23312327
IKVM_REAL=1
23322328
INT_DEFINE_END(cbe_thermal)
@@ -2389,7 +2385,7 @@ EXC_COMMON_BEGIN(soft_nmi_common)
23892385
* - Else it is one of PACA_IRQ_MUST_HARD_MASK, so hard disable and return.
23902386
* This is called with r10 containing the value to OR to the paca field.
23912387
*/
2392-
.macro MASKED_INTERRUPT hsrr
2388+
.macro MASKED_INTERRUPT hsrr=0
23932389
.if \hsrr
23942390
masked_Hinterrupt:
23952391
.else
@@ -2536,8 +2532,8 @@ TRAMP_REAL_BEGIN(hrfi_flush_fallback)
25362532
hrfid
25372533

25382534
USE_TEXT_SECTION()
2539-
MASKED_INTERRUPT EXC_STD
2540-
MASKED_INTERRUPT EXC_HV
2535+
MASKED_INTERRUPT
2536+
MASKED_INTERRUPT hsrr=1
25412537

25422538
#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
25432539
kvmppc_skip_interrupt:

0 commit comments

Comments
 (0)