From edd04dc2184607262c3931d8856146b9e03fd968 Mon Sep 17 00:00:00 2001 From: Yu Liao Date: Wed, 20 Dec 2023 12:42:58 +0800 Subject: [PATCH 1/2] timekeeping: Make CLOCKSOURCE_VALIDATE_LAST_CYCLE configurable hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8QEV8 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 bae8f11070be..5e0d37461b93 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 @@ -209,5 +204,13 @@ config CLOCKSOURCE_WATCHDOG_MAX_SKEW_US per million. If the clocksource is good enough for NTP, it is good enough for the clocksource watchdog! +# 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 e8c1d9d505ba0eaf93f43ccfab54207effeb0eae Mon Sep 17 00:00:00 2001 From: Yu Liao Date: Wed, 20 Dec 2023 12:42:59 +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/I8QEV8 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 33ba39711884..cca59d8d5183 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -71,6 +71,7 @@ CONFIG_CONTEXT_TRACKING_USER=y # CONFIG_CONTEXT_TRACKING_USER_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_BPF=y -- Gitee