From 98d544ad4bde77edd4a1d7502a8cd67062986284 Mon Sep 17 00:00:00 2001 From: Boris Ostrovsky Date: Tue, 9 Jan 2018 19:08:44 -0500 Subject: [PATCH] x86/IBRS/IBPB: Set sysctl_ibrs/ibpb_enabled properly init_scattered_cpuid_features() is called twice, first time from early_cpu_init(), before 'noibrs' or 'noibpb' option are parsed. This results in setting of sysctl_* variables. When we call init_scattered_cpuid_features() the second time, after the boot options have been parsed, init_scattered_cpuid_features() will leave sysctl_* parameters unchanged (i.e. already set). To avoid this, always set those variables based on ibrs/pb_inuse. Orabug: 27382723 Reviewed-by: Daniel Kiper Signed-off-by: Boris Ostrovsky Reviewed-by: Konrad Rzeszutek Wilk Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Brian Maly Signed-off-by: Kirtikar Kashyap --- arch/x86/kernel/cpu/scattered.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index 1dd9a5b09e01..887580fdbc0f 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -97,17 +97,14 @@ void init_scattered_cpuid_features(struct cpuinfo_x86 *c) return; set_ibrs_supported(); set_ibpb_supported(); - if (ibrs_inuse) - sysctl_ibrs_enabled = 1; - if (ibpb_inuse) - sysctl_ibpb_enabled = 1; + sysctl_ibrs_enabled = ibrs_inuse ? 1 : 0; + sysctl_ibpb_enabled = ibpb_inuse ? 1 : 0; } else if (boot_cpu_has(X86_FEATURE_IBPB)) { printk_once(KERN_INFO "FEATURE IBPB Present%s\n", ignore ? " but ignored (Xen)": ""); if (ignore) return; set_ibpb_supported(); - if (ibpb_inuse) - sysctl_ibpb_enabled = 1; + sysctl_ibpb_enabled = ibpb_inuse ? 1 : 0; } else { printk(KERN_INFO "FEATURE SPEC_CTRL Not Present\n"); } -- 2.50.1