From 4b2d8ca9208be636b30e924b1cbcb267b0740c93 Mon Sep 17 00:00:00 2001 From: Heiner Kallweit Date: Tue, 1 Dec 2020 12:39:57 +0100 Subject: x86/reboot: Add Zotac ZBOX CI327 nano PCI reboot quirk On this system the M.2 PCIe WiFi card isn't detected after reboot, only after cold boot. reboot=pci fixes this behavior. In [0] the same issue is described, although on another system and with another Intel WiFi card. In case it's relevant, both systems have Celeron CPUs. Add a PCI reboot quirk on affected systems until a more generic fix is available. [0] https://bugzilla.kernel.org/show_bug.cgi?id=202399 [ bp: Massage commit message. ] Signed-off-by: Heiner Kallweit Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/1524eafd-f89c-cfa4-ed70-0bde9e45eec9@gmail.com --- arch/x86/kernel/reboot.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index db115943e8bd..9991c5920aac 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -477,6 +477,15 @@ static const struct dmi_system_id reboot_dmi_table[] __initconst = { }, }, + { /* PCIe Wifi card isn't detected after reboot otherwise */ + .callback = set_pci_reboot, + .ident = "Zotac ZBOX CI327 nano", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "NA"), + DMI_MATCH(DMI_PRODUCT_NAME, "ZBOX-CI327NANO-GS-01"), + }, + }, + /* Sony */ { /* Handle problems with rebooting on Sony VGN-Z540N */ .callback = set_bios_reboot, -- cgit v1.2.3 From 9297e602adf8d5587d83941c48e4dbae46c8df5f Mon Sep 17 00:00:00 2001 From: Andy Lutomirski Date: Mon, 2 Nov 2020 11:54:02 -0800 Subject: selftests/x86: Use __builtin_ia32_read/writeeflags The asm to read and write EFLAGS from userspace is horrible. The compiler builtins are now available on all supported compilers, so use them instead. (The compiler builtins are also unnecessarily ugly, but that's a more manageable level of ugliness.) Signed-off-by: Andy Lutomirski Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/aee4b1cdfc56083eb779ce927b7d3459aad2af76.1604346818.git.luto@kernel.org --- tools/testing/selftests/x86/helpers.h | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/x86/helpers.h b/tools/testing/selftests/x86/helpers.h index f5ff2a2615df..4ef42c4559a9 100644 --- a/tools/testing/selftests/x86/helpers.h +++ b/tools/testing/selftests/x86/helpers.h @@ -6,36 +6,20 @@ static inline unsigned long get_eflags(void) { - unsigned long eflags; - - asm volatile ( #ifdef __x86_64__ - "subq $128, %%rsp\n\t" - "pushfq\n\t" - "popq %0\n\t" - "addq $128, %%rsp" + return __builtin_ia32_readeflags_u64(); #else - "pushfl\n\t" - "popl %0" + return __builtin_ia32_readeflags_u32(); #endif - : "=r" (eflags) :: "memory"); - - return eflags; } static inline void set_eflags(unsigned long eflags) { - asm volatile ( #ifdef __x86_64__ - "subq $128, %%rsp\n\t" - "pushq %0\n\t" - "popfq\n\t" - "addq $128, %%rsp" + __builtin_ia32_writeeflags_u64(eflags); #else - "pushl %0\n\t" - "popfl" + __builtin_ia32_writeeflags_u32(eflags); #endif - :: "r" (eflags) : "flags", "memory"); } #endif /* __SELFTESTS_X86_HELPERS_H */ -- cgit v1.2.3 From 443121b3ebb9025fd99ff11851d3537cb756d456 Mon Sep 17 00:00:00 2001 From: kernel test robot Date: Sun, 25 Oct 2020 11:20:04 +0100 Subject: selftests/fpu: Fix debugfs_simple_attr.cocci warning lib/test_fpu.c:66:0-23: WARNING: test_fpu_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE for debugfs files. Semantic patch information: Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file() imposes some significant overhead as compared to DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe(). In order to protect against file removal races, debugfs files created via debugfs_create_file() now get wrapped by a struct file_operations at their opening. If the original struct file_operations are known to be safe against removal races by themselves already, the proxy creation may be bypassed by creating the files through debugfs_create_file_unsafe(). In order to help debugfs users who use the common DEFINE_SIMPLE_ATTRIBUTE() + debugfs_create_file() idiom to transition to removal safe struct file_operations, the helper macro DEFINE_DEBUGFS_ATTRIBUTE() has been introduced. Thus, the preferred strategy is to use DEFINE_DEBUGFS_ATTRIBUTE() + debugfs_create_file_unsafe() now. Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci Fixes: 4185b3b92792 ("selftests/fpu: Add an FPU selftest") Signed-off-by: kernel test robot Signed-off-by: Julia Lawall Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/alpine.DEB.2.22.394.2010251117180.2714@hadrien --- lib/test_fpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/test_fpu.c b/lib/test_fpu.c index c33764aa3eb8..e82db19fed84 100644 --- a/lib/test_fpu.c +++ b/lib/test_fpu.c @@ -63,7 +63,7 @@ static int test_fpu_get(void *data, u64 *val) return status; } -DEFINE_SIMPLE_ATTRIBUTE(test_fpu_fops, test_fpu_get, NULL, "%lld\n"); +DEFINE_DEBUGFS_ATTRIBUTE(test_fpu_fops, test_fpu_get, NULL, "%lld\n"); static struct dentry *selftest_dir; static int __init test_fpu_init(void) @@ -72,8 +72,8 @@ static int __init test_fpu_init(void) if (!selftest_dir) return -ENOMEM; - debugfs_create_file("test_fpu", 0444, selftest_dir, NULL, - &test_fpu_fops); + debugfs_create_file_unsafe("test_fpu", 0444, selftest_dir, NULL, + &test_fpu_fops); return 0; } -- cgit v1.2.3 From 02a16aa13574c8526beadfc9ae8cc9b66315fa2d Mon Sep 17 00:00:00 2001 From: Misono Tomohiro Date: Wed, 27 Jan 2021 21:24:56 +0900 Subject: x86/MSR: Filter MSR writes through X86_IOC_WRMSR_REGS ioctl too Commit a7e1f67ed29f ("x86/msr: Filter MSR writes") introduced a module parameter to disable writing to the MSR device file and tainted the kernel upon writing. As MSR registers can be written by the X86_IOC_WRMSR_REGS ioctl too, the same filtering and tainting should be applied to the ioctl as well. [ bp: Massage commit message and space out statements. ] Fixes: a7e1f67ed29f ("x86/msr: Filter MSR writes") Signed-off-by: Misono Tomohiro Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20210127122456.13939-1-misono.tomohiro@jp.fujitsu.com --- arch/x86/kernel/msr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index 8a67d1fa8dc5..ed8ac6bcbafb 100644 --- a/arch/x86/kernel/msr.c +++ b/arch/x86/kernel/msr.c @@ -182,6 +182,13 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) err = security_locked_down(LOCKDOWN_MSR); if (err) break; + + err = filter_write(regs[1]); + if (err) + return err; + + add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK); + err = wrmsr_safe_regs_on_cpu(cpu, regs); if (err) break; -- cgit v1.2.3