[PATCH] x86/hpet: Mark boot-time variables as __ro_after_init

From: Habil Eren Türker

Date: Tue Nov 17 2026 - 07:29:59 EST


The following variables are only written during early boot or __init
functions and remain read-only at runtime:

- hpet_blockid: set once in acpi_parse_hpet() (__init)
- hpet_msi_disable: set only in force_disable_hpet_msi() (early PCI quirk)
- hpet_freq: set only in hpet_enable() (__init)
- boot_hpet_disable: set only in force_disable_hpet() (early-quirks.c)
and __init setup functions (hpet_setup(), disable_hpet(),
hpet_is_pc10_damaged())

Mark them as __ro_after_init to protect them against unintended runtime
modifications.

Signed-off-by: Habil Eren Türker <habilerenturker@xxxxxxxxxxx>
---
arch/x86/kernel/hpet.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 0edf0fe0ac2b..681660b8e548 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -51,8 +51,8 @@ struct hpet_base {
* HPET address is set in acpi/boot.c, when an ACPI entry exists
*/
unsigned long hpet_address;
-u8 hpet_blockid; /* OS timer block num */
-bool hpet_msi_disable;
+u8 hpet_blockid __ro_after_init; /* OS timer block num */
+bool hpet_msi_disable __ro_after_init;

#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_GENERIC_MSI_IRQ)
static DEFINE_PER_CPU(struct hpet_channel *, cpu_hpet_channel);
@@ -64,9 +64,9 @@ static void __iomem *hpet_virt_address;
static struct hpet_base hpet_base;

static bool hpet_legacy_int_enabled;
-static unsigned long hpet_freq;
+static unsigned long hpet_freq __ro_after_init;

-bool boot_hpet_disable;
+bool boot_hpet_disable __ro_after_init;
bool hpet_force_user;
static bool hpet_verbose;

--
2.47.3