• Michael Ellerman's avatar
    powerpc/64s: Don't init FSCR_DSCR in __init_FSCR() · f81b1d34
    Michael Ellerman authored
    commit 0828137e upstream.
    
    __init_FSCR() was added originally in commit 2468dcf6 ("powerpc:
    Add support for context switching the TAR register") (Feb 2013), and
    only set FSCR_TAR.
    
    At that point FSCR (Facility Status and Control Register) was not
    context switched, so the setting was permanent after boot.
    
    Later we added initialisation of FSCR_DSCR to __init_FSCR(), in commit
    54c9b225 ("powerpc: Set DSCR bit in FSCR setup") (Mar 2013), again
    that was permanent after boot.
    
    Then commit 2517617e ("powerpc: Fix context switch DSCR on
    POWER8") (Aug 2013) added a limited context switch of FSCR, just the
    FSCR_DSCR bit was context switched based on thread.dscr_inherit. That
    commit said "This clears the H/FSCR DSCR bit initially", but it
    didn't, it left the initialisation of FSCR_DSCR in __init_FSCR().
    However the initial context switch from init_task to pid 1 would clear
    FSCR_DSCR because thread.dscr_inherit was 0.
    
    That commit also introduced the requirement that FSCR_DSCR be clear
    for user processes, so that we can take the facility unavailable
    interrupt in order to manage dscr_inherit.
    
    Then in commit 152d523e ("powerpc: Create context switch helpers
    save_sprs() and restore_sprs()") (Dec 2015) FSCR was added to
    thread_struct. However it still wasn't fully context switched, we just
    took the existing value and set FSCR_DSCR if the new thread had
    dscr_inherit set. FSCR was still initialised at boot to FSCR_DSCR |
    FSCR_TAR, but that value was not propagated into the thread_struct, so
    the initial context switch set FSCR_DSCR back to 0.
    
    Finally commit b57bd2de ("powerpc: Improve FSCR init and context
    switching") (Jun 2016) added a full context switch of the FSCR, and
    added an initialisation of init_task.thread.fscr to FSCR_TAR |
    FSCR_EBB, but omitted FSCR_DSCR.
    
    The end result is that swapper runs with FSCR_DSCR set because of the
    initialisation in __init_FSCR(), but no other processes do, they use
    the value from init_task.thread.fscr.
    
    Having FSCR_DSCR set for swapper allows it to access SPR 3 from
    userspace, but swapper never runs userspace, so it has no useful
    effect. It's also confusing to have the value initialised in two
    places to two different values.
    
    So remove FSCR_DSCR from __init_FSCR(), this at least gets us to the
    point where there's a single value of FSCR, even if it's still set in
    two places.
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Tested-by: default avatarAlistair Popple <alistair@popple.id.au>
    Link: https://lore.kernel.org/r/20200527145843.2761782-1-mpe@ellerman.id.au
    Cc: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    f81b1d34
cpu_setup_power.S 4.16 KB