Skip to content

Commit 6415813

Browse files
minipliKAGA-KOKO
authored andcommitted
x86/cpu: Drop wp_works_ok member of struct cpuinfo_x86
Remove the wp_works_ok member of struct cpuinfo_x86. It's an optimization back from Linux v0.99 times where we had no fixup support yet and did the CR0.WP test via special code in the page fault handler. The < 0 test was an optimization to not do the special casing for each NULL ptr access violation but just for the first one doing the WP test. Today it serves no real purpose as the test no longer needs special code in the page fault handler and the only call side -- mem_init() -- calls it just once, anyway. However, Xen pre-initializes it to 1, to skip the test. Doing the test again for Xen should be no issue at all, as even the commit introducing skipping the test (commit d560bc6 ("x86, xen: Suppress WP test on Xen")) mentioned it being ban aid only. And, in fact, testing the patch on Xen showed nothing breaks. The pre-fixup times are long gone and with the removal of the fallback handling code in commit a5c2a89 ("x86, 386 removal: Remove CONFIG_X86_WP_WORKS_OK") the kernel requires a working CR0.WP anyway. So just get rid of the "optimization" and do the test unconditionally. Signed-off-by: Mathias Krause <minipli@googlemail.com> Acked-by: Borislav Petkov <bp@alien8.de> Cc: Jesper Nilsson <jesper.nilsson@axis.com> Cc: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Cc: Arnd Hannemann <hannemann@nets.rwth-aachen.de> Cc: Mikael Starvik <starvik@axis.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: "David S. Miller" <davem@davemloft.net> Link: http://lkml.kernel.org/r/1486933932-585-3-git-send-email-minipli@googlemail.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 0440211 commit 6415813

File tree

5 files changed

+12
-18
lines changed

5 files changed

+12
-18
lines changed

arch/x86/include/asm/processor.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ struct cpuinfo_x86 {
8989
__u8 x86_vendor; /* CPU vendor */
9090
__u8 x86_model;
9191
__u8 x86_mask;
92-
#ifdef CONFIG_X86_32
93-
char wp_works_ok; /* It doesn't on 386's */
94-
#else
92+
#ifdef CONFIG_X86_64
9593
/* Number of 4K pages in DTLB/ITLB combined(in pages): */
9694
int x86_tlbsize;
9795
#endif

arch/x86/kernel/cpu/proc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)
3131
"fpu\t\t: %s\n"
3232
"fpu_exception\t: %s\n"
3333
"cpuid level\t: %d\n"
34-
"wp\t\t: %s\n",
34+
"wp\t\t: yes\n",
3535
static_cpu_has_bug(X86_BUG_FDIV) ? "yes" : "no",
3636
static_cpu_has_bug(X86_BUG_F00F) ? "yes" : "no",
3737
static_cpu_has_bug(X86_BUG_COMA) ? "yes" : "no",
3838
static_cpu_has(X86_FEATURE_FPU) ? "yes" : "no",
3939
static_cpu_has(X86_FEATURE_FPU) ? "yes" : "no",
40-
c->cpuid_level,
41-
c->wp_works_ok ? "yes" : "no");
40+
c->cpuid_level);
4241
}
4342
#else
4443
static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)

arch/x86/kernel/setup.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,11 @@ static struct resource bss_resource = {
173173

174174

175175
#ifdef CONFIG_X86_32
176-
/* cpu data as detected by the assembly code in head.S */
177-
struct cpuinfo_x86 new_cpu_data = {
178-
.wp_works_ok = -1,
179-
};
176+
/* cpu data as detected by the assembly code in head_32.S */
177+
struct cpuinfo_x86 new_cpu_data;
178+
180179
/* common cpu data for all cpus */
181-
struct cpuinfo_x86 boot_cpu_data __read_mostly = {
182-
.wp_works_ok = -1,
183-
};
180+
struct cpuinfo_x86 boot_cpu_data __read_mostly;
184181
EXPORT_SYMBOL(boot_cpu_data);
185182

186183
unsigned int def_to_bigsmp;

arch/x86/mm/init_32.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,15 +716,17 @@ void __init paging_init(void)
716716
*/
717717
static void __init test_wp_bit(void)
718718
{
719+
int wp_works_ok;
720+
719721
printk(KERN_INFO
720722
"Checking if this processor honours the WP bit even in supervisor mode...");
721723

722724
/* Any page-aligned address will do, the test is non-destructive */
723725
__set_fixmap(FIX_WP_TEST, __pa(&swapper_pg_dir), PAGE_KERNEL_RO);
724-
boot_cpu_data.wp_works_ok = do_test_wp_bit();
726+
wp_works_ok = do_test_wp_bit();
725727
clear_fixmap(FIX_WP_TEST);
726728

727-
if (!boot_cpu_data.wp_works_ok) {
729+
if (!wp_works_ok) {
728730
printk(KERN_CONT "No.\n");
729731
panic("Linux doesn't support CPUs with broken WP.");
730732
} else {
@@ -811,8 +813,7 @@ void __init mem_init(void)
811813
BUG_ON(VMALLOC_START >= VMALLOC_END);
812814
BUG_ON((unsigned long)high_memory > VMALLOC_START);
813815

814-
if (boot_cpu_data.wp_works_ok < 0)
815-
test_wp_bit();
816+
test_wp_bit();
816817
}
817818

818819
#ifdef CONFIG_MEMORY_HOTPLUG

arch/x86/xen/enlighten.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
15951595
/* set up basic CPUID stuff */
15961596
cpu_detect(&new_cpu_data);
15971597
set_cpu_cap(&new_cpu_data, X86_FEATURE_FPU);
1598-
new_cpu_data.wp_works_ok = 1;
15991598
new_cpu_data.x86_capability[CPUID_1_EDX] = cpuid_edx(1);
16001599
#endif
16011600

0 commit comments

Comments
 (0)