Skip to contentSkip to conversation

x86/corruption-check: Remove the BIOS memory corruption check feature

PATCH Applied Luiz Capitulino (Red Hat) 2 participants 2 messages Nov 12

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 x86/corruption-check: Remove the BIOS memory corruption check feature

By default, the BIOS memory corruption check works by reserving the first 64 KiB physical area from memblock, zeroing it and then scanning it periodically.

However, in its default configuration it has been broken since v5.13 by two commits:

- Commit a799c2bd29d1 ("x86/setup: Consolidate early memory reservations"). Moved trim_low_memory_range() into early_reserve_memory(), which runs earlier in setup_arch(), causing the first 64 KiB to be reserved before setup_bios_corruption_check() runs

- Commit f1d4d47c5851 ("x86/setup: Always reserve the first 1M of RAM"). Hardcodes the reservation of the first 64 KiB early in early_reserve_memory()

This has been broken for years and nobody reported it, which suggests the feature might have no users.

It may be possible to fix this by running setup_bios_corruption_check() earlier, but that's not worth doing: the feature was intended to detect corruption in the first 64 KiB but the kernel will never access that range anyway.

Note that one case still "works", which is passing memory_corruption_check_size= to scan a larger region. But this is not useful either: the parameter takes a size, not an address range, so what gets scanned is whatever memblock happens to have free below that size.

Remove the feature.

---

Notes:
- I'm now sending from [email protected]
- Kept hpa's ack as the diff is unchanged

v4
- Improved changelog to state clearly that the feature should be removed rather than fixed (Borislav)

v3
- Updated changelog to emphasize that the default configuration is broken (Thorsten)
- Improved subject prefix
- Resending on top of latest Linus tree

v2
- Rebased against latest Linus tree (v7.2-rc4)
- Improved changelog

 .../admin-guide/kernel-parameters.txt         |  23 ---
 arch/x86/Kconfig                              |  30 ---
 arch/x86/configs/i386_defconfig               |   1 -
 arch/x86/configs/x86_64_defconfig             |   1 -
 arch/x86/include/asm/bios_ebda.h              |  17 --
 arch/x86/include/asm/setup.h                  |   1 -
 arch/x86/kernel/Makefile                      |   2 -
 arch/x86/kernel/check.c                       | 187 ------------------
 arch/x86/kernel/setup.c                       |   4 -
 9 files changed, 266 deletions(-)
 delete mode 100644 arch/x86/kernel/check.c
Documentation/admin-guide/kernel-parameters.txt +0 -23
index 0b3c140babd9..05086660b07f 100644
@@ -3998,29 +3998,6 @@ Kernel parameters
 			specified as e820 types, e.g., 1 = RAM, 2 = reserved,
 			3 = ACPI, 12 = PRAM.
 
-	memory_corruption_check=0/1 [X86,EARLY]
-			Some BIOSes seem to corrupt the first 64k of
-			memory when doing things like suspend/resume.
-			Setting this option will scan the memory
-			looking for corruption.  Enabling this will
-			both detect corruption and prevent the kernel
-			from using the memory being corrupted.
-			However, it's intended as a diagnostic tool; if
-			repeatable BIOS-originated corruption always
-			affects the same memory, you can use memmap=
-			to prevent the kernel from using that memory.
-
-	memory_corruption_check_size=size [X86,EARLY]
-			By default it checks for corruption in the low
-			64k, making this memory unavailable for normal
-			use.  Use this parameter to scan for
-			corruption in more or less memory.
-
-	memory_corruption_check_period=seconds [X86,EARLY]
-			By default it checks for corruption every 60
-			seconds.  Use this parameter to check at some
-			other rate.  0 disables periodic checking.
-
 	memory_hotplug.memmap_on_memory
 			[KNL,X86,ARM] Boolean flag to enable this feature.
 			Format: {on | off (default)}
arch/x86/Kconfig +0 -30
index 58dce0b66179..7ba002d1a201 100644
@@ -1602,36 +1602,6 @@ config X86_PMEM_LEGACY
 
 	  Say Y if unsure.
 
-config X86_CHECK_BIOS_CORRUPTION
-	bool "Check for low memory corruption"
-	help
-	  Periodically check for memory corruption in low memory, which
-	  is suspected to be caused by BIOS.  Even when enabled in the
-	  configuration, it is disabled at runtime.  Enable it by
-	  setting "memory_corruption_check=1" on the kernel command
-	  line.  By default it scans the low 64k of memory every 60
-	  seconds; see the memory_corruption_check_size and
-	  memory_corruption_check_period parameters in
-	  Documentation/admin-guide/kernel-parameters.rst to adjust this.
-
-	  When enabled with the default parameters, this option has
-	  almost no overhead, as it reserves a relatively small amount
-	  of memory and scans it infrequently.  It both detects corruption
-	  and prevents it from affecting the running system.
-
-	  It is, however, intended as a diagnostic tool; if repeatable
-	  BIOS-originated corruption always affects the same memory,
-	  you can use memmap= to prevent the kernel from using that
-	  memory.
-
-config X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK
-	bool "Set the default setting of memory_corruption_check"
-	depends on X86_CHECK_BIOS_CORRUPTION
-	default y
-	help
-	  Set whether the default state of memory_corruption_check is
-	  on or off.
-
 config MTRR
 	def_bool y
 	prompt "MTRR (Memory Type Range Register) support" if EXPERT
arch/x86/configs/i386_defconfig +0 -1
index 79fa38ca954d..848c2d924668 100644
@@ -36,7 +36,6 @@ CONFIG_PARAVIRT=y
 CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS=y
 CONFIG_X86_MSR=y
 CONFIG_X86_CPUID=y
-CONFIG_X86_CHECK_BIOS_CORRUPTION=y
 # CONFIG_MTRR_SANITIZER is not set
 CONFIG_EFI=y
 CONFIG_EFI_STUB=y
arch/x86/configs/x86_64_defconfig +0 -1
index e6896aeb77d8..7c76abee3f36 100644
@@ -35,7 +35,6 @@ CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS=y
 CONFIG_X86_MSR=y
 CONFIG_X86_CPUID=y
 CONFIG_NUMA=y
-CONFIG_X86_CHECK_BIOS_CORRUPTION=y
 # CONFIG_MTRR_SANITIZER is not set
 CONFIG_EFI=y
 CONFIG_EFI_STUB=y
arch/x86/include/asm/bios_ebda.h +0 -17
index 4d5a17e2febe..2f441fd9ebf8 100644
@@ -20,21 +20,4 @@ static inline unsigned int get_bios_ebda(void)
 
 void reserve_bios_regions(void);
 
-#ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
-/*
- * This is obviously not a great place for this, but we want to be
- * able to scatter it around anywhere in the kernel.
- */
-void check_for_bios_corruption(void);
-void start_periodic_check_for_corruption(void);
-#else
-static inline void check_for_bios_corruption(void)
-{
-}
-
-static inline void start_periodic_check_for_corruption(void)
-{
-}
-#endif
-
 #endif /* _ASM_X86_BIOS_EBDA_H */
arch/x86/include/asm/setup.h +0 -1
index 895d09faaf83..cd042752e6ce 100644
@@ -42,7 +42,6 @@ static inline void vsmp_init(void) { }
 
 struct pt_regs;
 
-void setup_bios_corruption_check(void);
 void early_platform_quirks(void);
 
 extern unsigned long saved_video_mode;
arch/x86/kernel/Makefile +0 -2
index 31f46fd00527..702536938433 100644
@@ -149,8 +149,6 @@ obj-$(CONFIG_JAILHOUSE_GUEST)	+= jailhouse.o
 obj-$(CONFIG_EISA)		+= eisa.o
 obj-$(CONFIG_PCSPKR_PLATFORM)	+= pcspeaker.o
 
-obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
-
 obj-$(CONFIG_OF)			+= devicetree.o
 obj-$(CONFIG_UPROBES)			+= uprobes.o
 
arch/x86/kernel/check.c deleted +0 -187

187 lines not on this page · raw message

arch/x86/kernel/setup.c +0 -4
index 19fc8e1714e6..8627eb7aa769 100644
@@ -1108,10 +1108,6 @@ void __init setup_arch(char **cmdline_p)
 	/* preallocate 4k for mptable mpc */
 	e820__memblock_alloc_reserved_mpc_new();
 
-#ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
-	setup_bios_corruption_check();
-#endif
-
 #ifdef CONFIG_X86_32
 	printk(KERN_DEBUG "initial memory mapped: [mem 0x00000000-%#010lx]\n",
 			(max_pfn_mapped<<PAGE_SHIFT) - 1);
Signature · 1 line
2.56.0
#1 lore raw

[tip: x86/cleanups] x86/setup: Remove the BIOS memory corruption check feature

The following commit has been merged into the x86/cleanups branch of tip:

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     57964216f9f6a61e4ce43f6826bb975c12cc3c87
Gitweb:        https://git.kernel.org/tip/57964216f9f6a61e4ce43f6826bb975c12cc3c87
Author:        Luiz Capitulino <[email protected]>
AuthorDate:    Wed, 11 Nov 2026 21:42:10 -05:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Thu, 12 Nov 2026 15:02:36 -08:00

x86/setup: Remove the BIOS memory corruption check feature

By default, the BIOS memory corruption check works by reserving the first 64 KiB physical area from memblock, zeroing it and then scanning it periodically.

However, in its default configuration it has been broken since v5.13 by two commits:

- Commit a799c2bd29d1 ("x86/setup: Consolidate early memory reservations"). Moved trim_low_memory_range() into early_reserve_memory(), which runs earlier in setup_arch(), causing the first 64 KiB to be reserved before setup_bios_corruption_check() runs

- Commit f1d4d47c5851 ("x86/setup: Always reserve the first 1M of RAM"). Hardcodes the reservation of the first 64 KiB early in early_reserve_memory()

This has been broken for years and nobody reported it, which suggests the feature might have no users.

It may be possible to fix this by running setup_bios_corruption_check() earlier, but that's not worth doing: the feature was intended to detect corruption in the first 64 KiB but the kernel will never access that range anyway.

Note that one case still "works", which is passing memory_corruption_check_size= to scan a larger region. But this is not useful either: the parameter takes a size, not an address range, so what gets scanned is whatever memblock happens to have free below that size.

Remove the feature.

---
 Documentation/admin-guide/kernel-parameters.txt |  23 +--
 arch/x86/Kconfig                                |  30 +--
 arch/x86/configs/i386_defconfig                 |   1 +-
 arch/x86/configs/x86_64_defconfig               |   1 +-
 arch/x86/include/asm/bios_ebda.h                |  17 +-
 arch/x86/include/asm/setup.h                    |   1 +-
 arch/x86/kernel/Makefile                        |   2 +-
 arch/x86/kernel/check.c                         | 187 +---------------
 arch/x86/kernel/setup.c                         |   4 +-
 9 files changed, 266 deletions(-)
 delete mode 100644 arch/x86/kernel/check.c
Documentation/admin-guide/kernel-parameters.txt +0 -23
index 0b3c140..0508666 100644
@@ -3998,29 +3998,6 @@ Kernel parameters
 			specified as e820 types, e.g., 1 = RAM, 2 = reserved,
 			3 = ACPI, 12 = PRAM.
 
-	memory_corruption_check=0/1 [X86,EARLY]
-			Some BIOSes seem to corrupt the first 64k of
-			memory when doing things like suspend/resume.
-			Setting this option will scan the memory
-			looking for corruption.  Enabling this will
-			both detect corruption and prevent the kernel
-			from using the memory being corrupted.
-			However, it's intended as a diagnostic tool; if
-			repeatable BIOS-originated corruption always
-			affects the same memory, you can use memmap=
-			to prevent the kernel from using that memory.
-
-	memory_corruption_check_size=size [X86,EARLY]
-			By default it checks for corruption in the low
-			64k, making this memory unavailable for normal
-			use.  Use this parameter to scan for
-			corruption in more or less memory.
-
-	memory_corruption_check_period=seconds [X86,EARLY]
-			By default it checks for corruption every 60
-			seconds.  Use this parameter to check at some
-			other rate.  0 disables periodic checking.
-
 	memory_hotplug.memmap_on_memory
 			[KNL,X86,ARM] Boolean flag to enable this feature.
 			Format: {on | off (default)}
arch/x86/Kconfig +0 -30
index 58dce0b..7ba002d 100644
@@ -1602,36 +1602,6 @@ config X86_PMEM_LEGACY
 
 	  Say Y if unsure.
 
-config X86_CHECK_BIOS_CORRUPTION
-	bool "Check for low memory corruption"
-	help
-	  Periodically check for memory corruption in low memory, which
-	  is suspected to be caused by BIOS.  Even when enabled in the
-	  configuration, it is disabled at runtime.  Enable it by
-	  setting "memory_corruption_check=1" on the kernel command
-	  line.  By default it scans the low 64k of memory every 60
-	  seconds; see the memory_corruption_check_size and
-	  memory_corruption_check_period parameters in
-	  Documentation/admin-guide/kernel-parameters.rst to adjust this.
-
-	  When enabled with the default parameters, this option has
-	  almost no overhead, as it reserves a relatively small amount
-	  of memory and scans it infrequently.  It both detects corruption
-	  and prevents it from affecting the running system.
-
-	  It is, however, intended as a diagnostic tool; if repeatable
-	  BIOS-originated corruption always affects the same memory,
-	  you can use memmap= to prevent the kernel from using that
-	  memory.
-
-config X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK
-	bool "Set the default setting of memory_corruption_check"
-	depends on X86_CHECK_BIOS_CORRUPTION
-	default y
-	help
-	  Set whether the default state of memory_corruption_check is
-	  on or off.
-
 config MTRR
 	def_bool y
 	prompt "MTRR (Memory Type Range Register) support" if EXPERT
arch/x86/configs/i386_defconfig +0 -1
index 79fa38c..848c2d9 100644
@@ -36,7 +36,6 @@ CONFIG_PARAVIRT=y
 CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS=y
 CONFIG_X86_MSR=y
 CONFIG_X86_CPUID=y
-CONFIG_X86_CHECK_BIOS_CORRUPTION=y
 # CONFIG_MTRR_SANITIZER is not set
 CONFIG_EFI=y
 CONFIG_EFI_STUB=y
arch/x86/configs/x86_64_defconfig +0 -1
index e6896ae..7c76abe 100644
@@ -35,7 +35,6 @@ CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS=y
 CONFIG_X86_MSR=y
 CONFIG_X86_CPUID=y
 CONFIG_NUMA=y
-CONFIG_X86_CHECK_BIOS_CORRUPTION=y
 # CONFIG_MTRR_SANITIZER is not set
 CONFIG_EFI=y
 CONFIG_EFI_STUB=y
arch/x86/include/asm/bios_ebda.h +0 -17
index 4d5a17e..2f441fd 100644
@@ -20,21 +20,4 @@ static inline unsigned int get_bios_ebda(void)
 
 void reserve_bios_regions(void);
 
-#ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
-/*
- * This is obviously not a great place for this, but we want to be
- * able to scatter it around anywhere in the kernel.
- */
-void check_for_bios_corruption(void);
-void start_periodic_check_for_corruption(void);
-#else
-static inline void check_for_bios_corruption(void)
-{
-}
-
-static inline void start_periodic_check_for_corruption(void)
-{
-}
-#endif
-
 #endif /* _ASM_X86_BIOS_EBDA_H */
arch/x86/include/asm/setup.h +0 -1
index 895d09f..cd04275 100644
@@ -42,7 +42,6 @@ static inline void vsmp_init(void) { }
 
 struct pt_regs;
 
-void setup_bios_corruption_check(void);
 void early_platform_quirks(void);
 
 extern unsigned long saved_video_mode;
arch/x86/kernel/Makefile +0 -2
index 31f46fd..7025369 100644
@@ -149,8 +149,6 @@ obj-$(CONFIG_JAILHOUSE_GUEST)	+= jailhouse.o
 obj-$(CONFIG_EISA)		+= eisa.o
 obj-$(CONFIG_PCSPKR_PLATFORM)	+= pcspeaker.o
 
-obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
-
 obj-$(CONFIG_OF)			+= devicetree.o
 obj-$(CONFIG_UPROBES)			+= uprobes.o
 
arch/x86/kernel/check.c deleted +0 -187

187 lines not on this page · raw message

arch/x86/kernel/setup.c +0 -4
index 19fc8e1..8627eb7 100644
@@ -1108,10 +1108,6 @@ void __init setup_arch(char **cmdline_p)
 	/* preallocate 4k for mptable mpc */
 	e820__memblock_alloc_reserved_mpc_new();
 
-#ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
-	setup_bios_corruption_check();
-#endif
-
 #ifdef CONFIG_X86_32
 	printk(KERN_DEBUG "initial memory mapped: [mem 0x00000000-%#010lx]\n",
 			(max_pfn_mapped<<PAGE_SHIFT) - 1);