Skip to content

Commit b57bd2d

Browse files
mikeympe
authored andcommitted
powerpc: Improve FSCR init and context switching
This fixes a few issues with FSCR init and switching. In commit 152d523 ("powerpc: Create context switch helpers save_sprs() and restore_sprs()") we moved the setting of the FSCR register from inside an CPU_FTR_ARCH_207S section to inside just a CPU_FTR_ARCH_DSCR section. Hence we are setting FSCR on POWER6/7 where the FSCR doesn't exist. This is harmless but we shouldn't do it. Also, we can simplify the FSCR context switch. We don't need to go through the calculation involving dscr_inherit. We can just restore what we saved last time. We also set an initial value in INIT_THREAD, so that pid 1 which is cloned from that gets a sane value. Based on patch by Jack Miller. Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 103b782 commit b57bd2d

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

arch/powerpc/include/asm/processor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ struct thread_struct {
347347
.fs = KERNEL_DS, \
348348
.fpexc_mode = 0, \
349349
.ppr = INIT_PPR, \
350+
.fscr = FSCR_TAR | FSCR_EBB \
350351
}
351352
#endif
352353

arch/powerpc/kernel/process.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,18 +1031,11 @@ static inline void restore_sprs(struct thread_struct *old_thread,
10311031
#ifdef CONFIG_PPC_BOOK3S_64
10321032
if (cpu_has_feature(CPU_FTR_DSCR)) {
10331033
u64 dscr = get_paca()->dscr_default;
1034-
u64 fscr = old_thread->fscr & ~FSCR_DSCR;
1035-
1036-
if (new_thread->dscr_inherit) {
1034+
if (new_thread->dscr_inherit)
10371035
dscr = new_thread->dscr;
1038-
fscr |= FSCR_DSCR;
1039-
}
10401036

10411037
if (old_thread->dscr != dscr)
10421038
mtspr(SPRN_DSCR, dscr);
1043-
1044-
if (old_thread->fscr != fscr)
1045-
mtspr(SPRN_FSCR, fscr);
10461039
}
10471040

10481041
if (cpu_has_feature(CPU_FTR_ARCH_207S)) {
@@ -1053,6 +1046,9 @@ static inline void restore_sprs(struct thread_struct *old_thread,
10531046
if (old_thread->ebbrr != new_thread->ebbrr)
10541047
mtspr(SPRN_EBBRR, new_thread->ebbrr);
10551048

1049+
if (old_thread->fscr != new_thread->fscr)
1050+
mtspr(SPRN_FSCR, new_thread->fscr);
1051+
10561052
if (old_thread->tar != new_thread->tar)
10571053
mtspr(SPRN_TAR, new_thread->tar);
10581054
}

arch/powerpc/kernel/traps.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,8 @@ void facility_unavailable_exception(struct pt_regs *regs)
14191419
rd = (instword >> 21) & 0x1f;
14201420
current->thread.dscr = regs->gpr[rd];
14211421
current->thread.dscr_inherit = 1;
1422-
mtspr(SPRN_FSCR, value | FSCR_DSCR);
1422+
current->thread.fscr |= FSCR_DSCR;
1423+
mtspr(SPRN_FSCR, current->thread.fscr);
14231424
}
14241425

14251426
/* Read from DSCR (mfspr RT, 0x03) */

0 commit comments

Comments
 (0)