Skip to content

Commit 6cbd217

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
x86/cpufeatures: Make CPU bugs sticky
There is currently no way to force CPU bug bits like CPU feature bits. That makes it impossible to set a bug bit once at boot and have it stick for all upcoming CPUs. Extend the force set/clear arrays to handle bug bits as well. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Boris Ostrovsky <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Laight <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: Eduardo Valentin <[email protected]> Cc: Greg KH <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 79cc741 commit 6cbd217

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

arch/x86/include/asm/cpufeature.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit);
135135
set_bit(bit, (unsigned long *)cpu_caps_set); \
136136
} while (0)
137137

138+
#define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit)
139+
138140
#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_X86_FAST_FEATURE_TESTS)
139141
/*
140142
* Static testing of CPU features. Used the same as boot_cpu_has().

arch/x86/include/asm/processor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ extern struct cpuinfo_x86 boot_cpu_data;
163163
extern struct cpuinfo_x86 new_cpu_data;
164164

165165
extern struct x86_hw_tss doublefault_tss;
166-
extern __u32 cpu_caps_cleared[NCAPINTS];
167-
extern __u32 cpu_caps_set[NCAPINTS];
166+
extern __u32 cpu_caps_cleared[NCAPINTS + NBUGINTS];
167+
extern __u32 cpu_caps_set[NCAPINTS + NBUGINTS];
168168

169169
#ifdef CONFIG_SMP
170170
DECLARE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);

arch/x86/kernel/cpu/common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ static const char *table_lookup_model(struct cpuinfo_x86 *c)
452452
return NULL; /* Not found */
453453
}
454454

455-
__u32 cpu_caps_cleared[NCAPINTS];
456-
__u32 cpu_caps_set[NCAPINTS];
455+
__u32 cpu_caps_cleared[NCAPINTS + NBUGINTS];
456+
__u32 cpu_caps_set[NCAPINTS + NBUGINTS];
457457

458458
void load_percpu_segment(int cpu)
459459
{
@@ -812,7 +812,7 @@ static void apply_forced_caps(struct cpuinfo_x86 *c)
812812
{
813813
int i;
814814

815-
for (i = 0; i < NCAPINTS; i++) {
815+
for (i = 0; i < NCAPINTS + NBUGINTS; i++) {
816816
c->x86_capability[i] &= ~cpu_caps_cleared[i];
817817
c->x86_capability[i] |= cpu_caps_set[i];
818818
}

0 commit comments

Comments
 (0)