From 0156338a18eba7ee229e59c8928c7056e9753c61 Mon Sep 17 00:00:00 2001 From: Thorsten Blum Date: Sun, 9 Feb 2025 22:03:32 +0100 Subject: [PATCH 1/7] x86/apic: Use str_disabled_enabled() helper in print_ipi_mode() Remove hard-coded strings by using the str_disabled_enabled() helper. No change in functionality intended. Signed-off-by: Thorsten Blum Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20250209210333.5666-2-thorsten.blum@linux.dev --- arch/x86/kernel/apic/ipi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/apic/ipi.c b/arch/x86/kernel/apic/ipi.c index 5da693d633b78..942168da71953 100644 --- a/arch/x86/kernel/apic/ipi.c +++ b/arch/x86/kernel/apic/ipi.c @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -23,7 +24,7 @@ __setup("no_ipi_broadcast=", apic_ipi_shorthand); static int __init print_ipi_mode(void) { pr_info("IPI shorthand broadcast: %s\n", - apic_ipi_shorthand_off ? "disabled" : "enabled"); + str_disabled_enabled(apic_ipi_shorthand_off)); return 0; } late_initcall(print_ipi_mode); From 51184c3c96a19b5143710ef91426e311f4364bac Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Fri, 10 Jan 2025 22:33:33 -0800 Subject: [PATCH 2/7] x86/usercopy: Fix kernel-doc func param name in clean_cache_range()'s description Use @addr instead of @vaddr in the kernel-doc comment for clean_cache_range() to eliminate warnings: arch/x86/lib/usercopy_64.c:29: warning: Function parameter or struct member 'addr' not described in 'clean_cache_range' arch/x86/lib/usercopy_64.c:29: warning: Excess function parameter 'vaddr' description in 'clean_cache_range' Fixes: 0aed55af8834 ("x86, uaccess: introduce copy_from_iter_flushcache for pmem / cache-bypass operations") Signed-off-by: Randy Dunlap Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20250111063333.911084-1-rdunlap@infradead.org --- arch/x86/lib/usercopy_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c index e9251b89a9e93..654280aaa3e9e 100644 --- a/arch/x86/lib/usercopy_64.c +++ b/arch/x86/lib/usercopy_64.c @@ -18,7 +18,7 @@ #ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE /** * clean_cache_range - write back a cache range with CLWB - * @vaddr: virtual start address + * @addr: virtual start address * @size: number of bytes to write back * * Write back a cache range using the CLWB (cache line write back) From b8ffd979356e33a3af0854d47375bba611126f3b Mon Sep 17 00:00:00 2001 From: Zhang Kunbo Date: Tue, 26 Nov 2024 02:05:11 +0000 Subject: [PATCH 3/7] x86/irq: Fix missing declaration of 'io_apic_irqs' Fix this sparse warning: arch/x86/kernel/i8259.c:57:15: warning: symbol 'io_apic_irqs' was not declared. Should it be static? Signed-off-by: Zhang Kunbo Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20241126020511.3464664-1-zhangkunbo@huawei.com --- arch/x86/kernel/i8259.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c index c20d1832c4812..2bade73f49e33 100644 --- a/arch/x86/kernel/i8259.c +++ b/arch/x86/kernel/i8259.c @@ -23,6 +23,7 @@ #include #include #include +#include /* * This is the 'legacy' 8259A Programmable Interrupt Controller, From e008eeec7868a9ca6e159726aeb9bdbf2ab86647 Mon Sep 17 00:00:00 2001 From: Zhang Kunbo Date: Tue, 26 Nov 2024 01:54:57 +0000 Subject: [PATCH 4/7] x86/platform: Fix missing declaration of 'x86_apple_machine' Fix this sparse warning: arch/x86/kernel/quirks.c:662:6: warning: symbol 'x86_apple_machine' was not declared. Should it be static? Signed-off-by: Zhang Kunbo Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20241126015636.3463994-1-zhangkunbo@huawei.com --- arch/x86/kernel/quirks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c index 6d0df6a58873d..a92f18db96100 100644 --- a/arch/x86/kernel/quirks.c +++ b/arch/x86/kernel/quirks.c @@ -10,6 +10,8 @@ #include #include +#include + #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) && defined(CONFIG_PCI) static void quirk_intel_irqbalance(struct pci_dev *dev) From 40fc7561013914ec08c200bb7a0805643a23e070 Mon Sep 17 00:00:00 2001 From: Mirsad Todorovac Date: Fri, 1 Nov 2024 12:15:23 +0100 Subject: [PATCH 5/7] selftests/x86/syscall: Fix coccinelle WARNING recommending the use of ARRAY_SIZE() Coccinelle gives WARNING recommending the use of ARRAY_SIZE() macro definition to improve the code readability: ./tools/testing/selftests/x86/syscall_numbering.c:316:35-36: WARNING: Use ARRAY_SIZE Fixes: 15c82d98a0f78 ("selftests/x86/syscall: Update and extend syscall_numbering_64") Signed-off-by: Mirsad Todorovac Signed-off-by: Ingo Molnar Reviewed-by: Muhammad Usama Anjum Link: https://lore.kernel.org/r/20241101111523.1293193-2-mtodorovac69@gmail.com --- tools/testing/selftests/x86/syscall_numbering.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/x86/syscall_numbering.c b/tools/testing/selftests/x86/syscall_numbering.c index 991591718bb0a..41c42b7b54a6c 100644 --- a/tools/testing/selftests/x86/syscall_numbering.c +++ b/tools/testing/selftests/x86/syscall_numbering.c @@ -25,6 +25,7 @@ #include #include +#include "../kselftest.h" /* Common system call numbers */ #define SYS_READ 0 @@ -313,7 +314,7 @@ static void test_syscall_numbering(void) * The MSB is supposed to be ignored, so we loop over a few * to test that out. */ - for (size_t i = 0; i < sizeof(msbs)/sizeof(msbs[0]); i++) { + for (size_t i = 0; i < ARRAY_SIZE(msbs); i++) { int msb = msbs[i]; run("Checking system calls with msb = %d (0x%x)\n", msb, msb); From f739365158a33549cf1827968b12a370ab75589e Mon Sep 17 00:00:00 2001 From: Charles Han Date: Wed, 5 Mar 2025 14:35:14 +0800 Subject: [PATCH 6/7] x86/delay: Fix inconsistent whitespace Smatch warns about this whitespace damage: arch/x86/lib/delay.c:134 delay_halt_mwaitx() warn: inconsistent indenting Signed-off-by: Charles Han Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20250305063515.3951-1-hanchunchao@inspur.com --- arch/x86/lib/delay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c index 23f81ca3f06b4..e86eda2c0b040 100644 --- a/arch/x86/lib/delay.c +++ b/arch/x86/lib/delay.c @@ -131,7 +131,7 @@ static void delay_halt_mwaitx(u64 unused, u64 cycles) * Use cpu_tss_rw as a cacheline-aligned, seldom accessed per-cpu * variable as the monitor target. */ - __monitorx(raw_cpu_ptr(&cpu_tss_rw), 0, 0); + __monitorx(raw_cpu_ptr(&cpu_tss_rw), 0, 0); /* * AMD, like Intel, supports the EAX hint and EAX=0xf means, do not From ec73859d76db768da97ee799a91eb9c7d28974fe Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 10 Mar 2025 14:10:59 +0100 Subject: [PATCH 7/7] x86/coco: Replace 'static const cc_mask' with the newly introduced cc_get_mask() function When extra warnings are enabled, the cc_mask definition in causes a build failure with GCC: arch/x86/include/asm/coco.h:28:18: error: 'cc_mask' defined but not used [-Werror=unused-const-variable=] 28 | static const u64 cc_mask = 0; Add a cc_get_mask() function mirroring cc_set_mask() for the one user of the variable outside of the CoCo implementation. Fixes: a0a8d15a798b ("x86/tdx: Preserve shared bit on mprotect()") Signed-off-by: Arnd Bergmann Signed-off-by: Ingo Molnar Cc: Linus Torvalds Link: https://lore.kernel.org/r/20250310131114.2635497-1-arnd@kernel.org -- v2: use an inline helper instead of a __maybe_unused annotaiton. --- arch/x86/include/asm/coco.h | 10 +++++++++- arch/x86/include/asm/pgtable_types.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/coco.h b/arch/x86/include/asm/coco.h index aa6c8f8ca9588..e7225452963f0 100644 --- a/arch/x86/include/asm/coco.h +++ b/arch/x86/include/asm/coco.h @@ -15,6 +15,11 @@ enum cc_vendor { extern enum cc_vendor cc_vendor; extern u64 cc_mask; +static inline u64 cc_get_mask(void) +{ + return cc_mask; +} + static inline void cc_set_mask(u64 mask) { RIP_REL_REF(cc_mask) = mask; @@ -25,7 +30,10 @@ u64 cc_mkdec(u64 val); void cc_random_init(void); #else #define cc_vendor (CC_VENDOR_NONE) -static const u64 cc_mask = 0; +static inline u64 cc_get_mask(void) +{ + return 0; +} static inline u64 cc_mkenc(u64 val) { diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index 4b804531b03c3..9c4d9fafe0105 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -177,7 +177,7 @@ enum page_cache_mode { }; #endif -#define _PAGE_CC (_AT(pteval_t, cc_mask)) +#define _PAGE_CC (_AT(pteval_t, cc_get_mask())) #define _PAGE_ENC (_AT(pteval_t, sme_me_mask)) #define _PAGE_CACHE_MASK (_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)