lkml.org 
[lkml]   [2022]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH 22/23] x86/hreset: Configure history reset
    Date
    Configure the MSR that controls the behavior of HRESET on each logical
    processor.

    Cc: Ben Segall <bsegall@google.com>
    Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
    Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
    Cc: Len Brown <len.brown@intel.com>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Cc: Tim C. Chen <tim.c.chen@intel.com>
    Cc: Valentin Schneider <vschneid@redhat.com>
    Cc: x86@kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
    ---
    arch/x86/kernel/cpu/common.c | 25 ++++++++++++++++++++++++-
    1 file changed, 24 insertions(+), 1 deletion(-)

    diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
    index 3e508f239098..108642fe6761 100644
    --- a/arch/x86/kernel/cpu/common.c
    +++ b/arch/x86/kernel/cpu/common.c
    @@ -411,6 +411,28 @@ static __always_inline void setup_umip(struct cpuinfo_x86 *c)
    cr4_clear_bits(X86_CR4_UMIP);
    }

    +static u32 hardware_history_features __read_mostly;
    +
    +static __always_inline void setup_hreset(struct cpuinfo_x86 *c)
    +{
    + if (!cpu_feature_enabled(X86_FEATURE_HRESET))
    + return;
    +
    + /*
    + * Use on all CPUs the hardware history features that the boot
    + * CPU supports.
    + */
    + if (c == &boot_cpu_data)
    + hardware_history_features = cpuid_ebx(0x20);
    +
    + if (!hardware_history_features)
    + return;
    +
    + wrmsrl(MSR_IA32_HW_HRESET_ENABLE, hardware_history_features);
    +
    + pr_info_once("x86/cpu: Intel History Reset (HRESET) activated\n");
    +}
    +
    /* These bits should not change their value after CPU init is finished. */
    static const unsigned long cr4_pinned_mask =
    X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP |
    @@ -1823,10 +1845,11 @@ static void identify_cpu(struct cpuinfo_x86 *c)
    /* Disable the PN if appropriate */
    squash_the_stupid_serial_number(c);

    - /* Set up SMEP/SMAP/UMIP */
    + /* Set up SMEP/SMAP/UMIP/HRESET */
    setup_smep(c);
    setup_smap(c);
    setup_umip(c);
    + setup_hreset(c);

    /* Enable FSGSBASE instructions if available. */
    if (cpu_has(c, X86_FEATURE_FSGSBASE)) {
    --
    2.25.1
    \
     
     \ /
      Last update: 2022-09-10 01:08    [W:4.402 / U:0.064 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site