From: Boris Ostrovsky Date: Tue, 23 Jan 2018 16:02:42 +0000 (-0500) Subject: x86/IBRS: Don't try to change IBRS mode if IBRS is not available X-Git-Tag: v4.1.12-124.31.3~1239 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=550dd697bc302d3598542a284be4986c75f1d95f;p=users%2Fjedix%2Flinux-maple.git x86/IBRS: Don't try to change IBRS mode if IBRS is not available sysctl_ibrs_enabled is set properly when IBRS support is discovered in init_scattered_cpuid_features(). We should simply return an error when attempt is made to change IBRS mode when the feature is not supoorted. There is also no need to call set_ibrs_inuse() when changing mode to 1: this is already done by clear_ibrs_disabled(). Orabug: 27448280 Signed-off-by: Boris Ostrovsky Reviewed-by: Krish Sadhukhan Reviewed-by: Konrad Rzeszutek Wilk Signed-off-by: Konrad Rzeszutek Wilk --- diff --git a/arch/x86/kernel/cpu/spec_ctrl.c b/arch/x86/kernel/cpu/spec_ctrl.c index fab5d6d8fdf5..e74e500eb45e 100644 --- a/arch/x86/kernel/cpu/spec_ctrl.c +++ b/arch/x86/kernel/cpu/spec_ctrl.c @@ -51,6 +51,9 @@ static ssize_t ibrs_enabled_write(struct file *file, ssize_t len; unsigned int enable; + if (!ibrs_supported) + return -ENODEV; + len = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, len)) return -EFAULT; @@ -74,11 +77,6 @@ static ssize_t ibrs_enabled_write(struct file *file, spec_ctrl_flush_all_cpus(MSR_IA32_SPEC_CTRL, SPEC_CTRL_FEATURE_DISABLE_IBRS); } else { clear_ibrs_disabled(); - if (use_ibrs & SPEC_CTRL_IBRS_SUPPORTED) - set_ibrs_inuse(); - else - /* Platform don't support IBRS */ - enable = 0; } sysctl_ibrs_enabled = enable;