Skip to content

Commit 53a712b

Browse files
committed
powerpc/powernv/idle: Restore AMR/UAMOR/AMOR after idle
In order to implement KUAP (Kernel Userspace Access Protection) on Power9 we will be using the AMR, and therefore indirectly the UAMOR/AMOR. So save/restore these regs in the idle code. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent a3f3072 commit 53a712b

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

Diff for: arch/powerpc/kernel/idle_book3s.S

+23-4
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,11 @@ core_idle_lock_held:
170170
bne- core_idle_lock_held
171171
blr
172172

173-
/* Reuse an unused pt_regs slot for IAMR */
173+
/* Reuse some unused pt_regs slots for AMR/IAMR/UAMOR/UAMOR */
174+
#define PNV_POWERSAVE_AMR _TRAP
174175
#define PNV_POWERSAVE_IAMR _DAR
176+
#define PNV_POWERSAVE_UAMOR _DSISR
177+
#define PNV_POWERSAVE_AMOR RESULT
175178

176179
/*
177180
* Pass requested state in r3:
@@ -205,8 +208,16 @@ pnv_powersave_common:
205208
SAVE_NVGPRS(r1)
206209

207210
BEGIN_FTR_SECTION
211+
mfspr r4, SPRN_AMR
208212
mfspr r5, SPRN_IAMR
213+
mfspr r6, SPRN_UAMOR
214+
std r4, PNV_POWERSAVE_AMR(r1)
209215
std r5, PNV_POWERSAVE_IAMR(r1)
216+
std r6, PNV_POWERSAVE_UAMOR(r1)
217+
BEGIN_FTR_SECTION_NESTED(42)
218+
mfspr r7, SPRN_AMOR
219+
std r7, PNV_POWERSAVE_AMOR(r1)
220+
END_FTR_SECTION_NESTED_IFSET(CPU_FTR_HVMODE, 42)
210221
END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
211222

212223
mfcr r5
@@ -935,12 +946,20 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
935946
REST_GPR(2, r1)
936947

937948
BEGIN_FTR_SECTION
938-
/* IAMR was saved in pnv_powersave_common() */
949+
/* These regs were saved in pnv_powersave_common() */
950+
ld r4, PNV_POWERSAVE_AMR(r1)
939951
ld r5, PNV_POWERSAVE_IAMR(r1)
952+
ld r6, PNV_POWERSAVE_UAMOR(r1)
953+
mtspr SPRN_AMR, r4
940954
mtspr SPRN_IAMR, r5
955+
mtspr SPRN_UAMOR, r6
956+
BEGIN_FTR_SECTION_NESTED(42)
957+
ld r7, PNV_POWERSAVE_AMOR(r1)
958+
mtspr SPRN_AMOR, r7
959+
END_FTR_SECTION_NESTED_IFSET(CPU_FTR_HVMODE, 42)
941960
/*
942-
* We don't need an isync here because the upcoming mtmsrd is
943-
* execution synchronizing.
961+
* We don't need an isync here after restoring IAMR because the upcoming
962+
* mtmsrd is execution synchronizing.
944963
*/
945964
END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
946965

0 commit comments

Comments
 (0)