Skip to content

x86/init: Initialize wall clock in get_rtc_noop() - #163

Open
Naman Jain (namancse) wants to merge 1 commit into
product/hcl-main/6.18from
user/namjain/backportfix
Open

Naman Jain (namancse) wants to merge 1 commit into
product/hcl-main/6.18from
user/namjain/backportfix

Conversation

@namancse

Copy link
Copy Markdown
Contributor

get_rtc_noop() is used when an RTC is unavailable, but leaves its output argument untouched. When CONFIG_INIT_STACK_ALL_ZERO is not enabled, timekeeping_init() may therefore receive a nonzero invalid persistent clock value and warn:
"Persistent clock returned invalid value"

Initialize the output to zero, the documented representation of an unsupported persistent clock.

Fixes: c311ed6 ("x86/init: Allow DT configured systems to disable RTC at boot time")
Cc: stable@vger.kernel.org
Reviewed-by: Thomas Gleixner tglx@kernel.org
Reviewed-by: Roman Kisel vdso@mailbox.org
Reviewed-by: Dexuan Cui decui@microsoft.com
Reviewed-by: Hardik Garg hargar@linux.microsoft.com
Link: https://lore.kernel.org/all/20260831082528.1623843-1-namjain@linux.microsoft.com/
Reviewed, but not picked in mainline at the time of backporting.

get_rtc_noop() is used when an RTC is unavailable, but leaves its output
argument untouched. When CONFIG_INIT_STACK_ALL_ZERO is not enabled,
timekeeping_init() may therefore receive a nonzero invalid persistent
clock value and warn:
"Persistent clock returned invalid value"

Initialize the output to zero, the documented representation of an
unsupported persistent clock.

Fixes: c311ed6 ("x86/init: Allow DT configured systems to disable RTC at boot time")
Cc: stable@vger.kernel.org
Reviewed-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Roman Kisel <vdso@mailbox.org>
Reviewed-by: Dexuan Cui <decui@microsoft.com>
Reviewed-by: Hardik Garg <hargar@linux.microsoft.com>
Signed-off-by: Naman Jain <namjain@linux.microsoft.com>

Link: https://lore.kernel.org/all/20260831082528.1623843-1-namjain@linux.microsoft.com/
Reviewed, but not picked in mainline at the time of backporting.
Signed-off-by: Naman Jain <namjain@linux.microsoft.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The localized change correctly initializes the output to zero and has no unresolved review findings.

No open issues 🎉

What changed in this PR

This PR fixes the x86 fallback used when no RTC is available by returning a zero persistent-clock value instead of leaving the output uninitialized.

Changes:

  • Zero-initialize the timespec64 output in get_rtc_noop().
  • Prevent invalid persistent-clock warnings caused by uninitialized stack data.
File Description
arch/​x86/​kernel/​x86_init.c Initialize the no-RTC clock output to the documented unsupported-clock value.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants