From 1e93244124e66c5d6454ce58957a2807526bccb0 Mon Sep 17 00:00:00 2001 From: Yu Liao Date: Tue, 16 May 2023 18:38:07 +0800 Subject: [PATCH 1/2] timekeeping: Make CLOCKSOURCE_VALIDATE_LAST_CYCLE configurable hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7393E CVE: NA ------------------------------- Currently, only x86 architecture supports the CLOCKSOURCE_VALIDATE_LAST_CYCLE option. This option ensures that the timestamps returned by the clocksource are monotonically increasing, and helps avoid issues caused by hardware failures. This commit makes CLOCKSOURCE_VALIDATE_LAST_CYCLE configurable on the arm64 architecture, helps increase system stability and reliability. Signed-off-by: Yu Liao --- kernel/time/Kconfig | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig index a09b1d61df6a..0572a2fb6b12 100644 --- a/kernel/time/Kconfig +++ b/kernel/time/Kconfig @@ -17,11 +17,6 @@ config ARCH_CLOCKSOURCE_DATA config ARCH_CLOCKSOURCE_INIT bool -# Clocksources require validation of the clocksource against the last -# cycle update - x86/TSC misfeature -config CLOCKSOURCE_VALIDATE_LAST_CYCLE - bool - # Timekeeping vsyscall support config GENERIC_TIME_VSYSCALL bool @@ -173,5 +168,13 @@ config HIGH_RES_TIMERS hardware is not capable then this option only increases the size of the kernel image. +# Clocksources require validation of the clocksource against the last +# cycle update - x86/TSC misfeature +config CLOCKSOURCE_VALIDATE_LAST_CYCLE + bool "Validate last cycle of clocksource" + help + Enable this option to validate the last cycle to prevent issues + caused by clocksource going backwards. + endmenu endif -- Gitee From c4178985274c73bfae7e1016749b8582cfd49f32 Mon Sep 17 00:00:00 2001 From: Yu Liao Date: Wed, 17 May 2023 10:20:31 +0800 Subject: [PATCH 2/2] config: make CLOCKSOURCE_VALIDATE_LAST_CYCLE not set by default openeuler inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7393E CVE: NA ------------------------------- The ARM ARM states the following (where a CPU is a device): The system counter must provide a uniform view of system time. More precisely, it must be impossible for the following sequence of events to show system time going backwards: 1) Device A reads the time from the system counter. 2) Device A communicates with another agent in the system, Device B. 3) After recognizing the communication from Device A, Device B reads the time from the system counter. So make CLOCKSOURCE_VALIDATE_LAST_CYCLE unset by default. Signed-off-by: Yu Liao --- arch/arm64/configs/openeuler_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index f6cc13c8971d..e0a7bc1f940c 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -69,6 +69,7 @@ CONFIG_CONTEXT_TRACKING=y # CONFIG_CONTEXT_TRACKING_FORCE is not set CONFIG_NO_HZ=y CONFIG_HIGH_RES_TIMERS=y +# CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE is not set # end of Timers subsystem CONFIG_PREEMPT_NONE=y -- Gitee