lkml.org 
[lkml]   [2018]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH RFC 7/8] powerpc/64s: barrier_nospec: Add hcall triggerr
    Date
    Copypasta from rfi implementation

    Signed-off-by: Michal Suchanek <msuchanek@suse.de>
    ---
    arch/powerpc/platforms/pseries/setup.c | 38 ++++++++++++++++++++++------------
    1 file changed, 25 insertions(+), 13 deletions(-)

    diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
    index 1a527625acf7..b779ddb8e250 100644
    --- a/arch/powerpc/platforms/pseries/setup.c
    +++ b/arch/powerpc/platforms/pseries/setup.c
    @@ -459,38 +459,50 @@ static void __init find_and_init_phbs(void)
    of_pci_check_probe_only();
    }

    -static void pseries_setup_rfi_flush(void)
    +static void pseries_setup_rfi_nospec(void)
    {
    struct h_cpu_char_result result;
    - enum l1d_flush_type types;
    - bool enable;
    + enum l1d_flush_type flush_types;
    + enum spec_barrier_type barrier_type;
    + bool flush_enable;
    + bool barrier_enable;
    long rc;

    /* Enable by default */
    - enable = true;
    + flush_enable = true;
    + barrier_enable = true;
    + /* no fallback if the firmware does not tell us */
    + barrier_type = SPEC_BARRIER_NONE;

    rc = plpar_get_cpu_characteristics(&result);
    if (rc == H_SUCCESS) {
    - types = L1D_FLUSH_NONE;
    + flush_types = L1D_FLUSH_NONE;

    if (result.character & H_CPU_CHAR_L1D_FLUSH_TRIG2)
    - types |= L1D_FLUSH_MTTRIG;
    + flush_types |= L1D_FLUSH_MTTRIG;
    if (result.character & H_CPU_CHAR_L1D_FLUSH_ORI30)
    - types |= L1D_FLUSH_ORI;
    + flush_types |= L1D_FLUSH_ORI;
    + if (result.character & H_CPU_CHAR_SPEC_BAR_ORI31)
    + barrier_type |= SPEC_BARRIER_ORI;

    /* Use fallback if nothing set in hcall */
    - if (types == L1D_FLUSH_NONE)
    - types = L1D_FLUSH_FALLBACK;
    + if (flush_types == L1D_FLUSH_NONE)
    + flush_types = L1D_FLUSH_FALLBACK;

    if ((!(result.behaviour & H_CPU_BEHAV_L1D_FLUSH_PR)) ||
    (!(result.behaviour & H_CPU_BEHAV_FAVOUR_SECURITY)))
    - enable = false;
    + flush_enable = false;
    +
    + if ((!(result.behaviour & H_CPU_BEHAV_BNDS_CHK_SPEC_BAR)) ||
    + (!(result.behaviour & H_CPU_BEHAV_FAVOUR_SECURITY)))
    + barrier_enable = false;
    } else {
    /* Default to fallback if case hcall is not available */
    - types = L1D_FLUSH_FALLBACK;
    + flush_types = L1D_FLUSH_FALLBACK;
    }

    - setup_rfi_flush(types, enable);
    + setup_barrier_nospec(barrier_type, barrier_enable);
    + setup_rfi_flush(flush_types, flush_enable);
    }

    #ifdef CONFIG_PCI_IOV
    @@ -666,7 +678,7 @@ static void __init pSeries_setup_arch(void)

    fwnmi_init();

    - pseries_setup_rfi_flush();
    + pseries_setup_rfi_nospec();

    /* By default, only probe PCI (can be overridden by rtas_pci) */
    pci_add_flags(PCI_PROBE_ONLY);
    --
    2.13.6
    \
     
     \ /
      Last update: 2018-03-13 19:34    [W:3.816 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site