All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/init: Initialize wall clock in get_rtc_noop()
@ 2026-08-31  8:25 Naman Jain
  2026-09-09 18:42 ` Dexuan Cui
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Naman Jain @ 2026-08-31  8:25 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86
  Cc: hpa, decui, namjain, yunhong.jiang, ricardo.neri-calderon,
	rahul.tanwar, linux-kernel, linux-hyperv, stable

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: c311ed6183f4 ("x86/init: Allow DT configured systems to disable RTC at boot time")
Cc: stable@vger.kernel.org
Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
---
 arch/x86/kernel/x86_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index 252c5827d0634..3b9b41820c84c 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -37,7 +37,7 @@ static void iommu_shutdown_noop(void) { }
 bool __init bool_x86_init_noop(void) { return false; }
 void x86_op_int_noop(int cpu) { }
 int set_rtc_noop(const struct timespec64 *now) { return -EINVAL; }
-void get_rtc_noop(struct timespec64 *now) { }
+void get_rtc_noop(struct timespec64 *now) { *now = (struct timespec64){0}; }
 
 static __initconst const struct of_device_id of_cmos_match[] = {
 	{ .compatible = "motorola,mc146818" },
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* RE: [PATCH] x86/init: Initialize wall clock in get_rtc_noop()
  2026-08-31  8:25 [PATCH] x86/init: Initialize wall clock in get_rtc_noop() Naman Jain
@ 2026-09-09 18:42 ` Dexuan Cui
  2026-09-11  4:23 ` Hardik Garg
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Dexuan Cui @ 2026-09-09 18:42 UTC (permalink / raw)
  To: Naman Jain, tglx@kernel.org, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org
  Cc: hpa@zytor.com, yunhong.jiang@linux.intel.com,
	ricardo.neri-calderon@linux.intel.com,
	rahul.tanwar@linux.intel.com, linux-kernel@vger.kernel.org,
	linux-hyperv@vger.kernel.org, stable@vger.kernel.org

> From: Naman Jain <namjain@linux.microsoft.com>
> Sent: Monday, August 31, 2026 1:25 AM

LGTM.

Reviewed-by: Dexuan Cui <decui@microsoft.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/init: Initialize wall clock in get_rtc_noop()
  2026-08-31  8:25 [PATCH] x86/init: Initialize wall clock in get_rtc_noop() Naman Jain
  2026-09-09 18:42 ` Dexuan Cui
@ 2026-09-11  4:23 ` Hardik Garg
  2026-09-12  3:35 ` Roman Kisel
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Hardik Garg @ 2026-09-11  4:23 UTC (permalink / raw)
  To: namjain
  Cc: bp, dave.hansen, decui, hpa, linux-hyperv, linux-kernel, mingo,
	rahul.tanwar, ricardo.neri-calderon, stable, tglx, x86,
	yunhong.jiang

Reviewed-by: Hardik Garg <hargar@linux.microsoft.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/init: Initialize wall clock in get_rtc_noop()
  2026-08-31  8:25 [PATCH] x86/init: Initialize wall clock in get_rtc_noop() Naman Jain
  2026-09-09 18:42 ` Dexuan Cui
  2026-09-11  4:23 ` Hardik Garg
@ 2026-09-12  3:35 ` Roman Kisel
  2026-09-14 11:31   ` Naman Jain
  2026-10-12  5:24 ` Naman Jain
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 10+ messages in thread
From: Roman Kisel @ 2026-09-12  3:35 UTC (permalink / raw)
  To: Naman Jain
  Cc: glx, mingo, bp, dave.hansen, x86, hpa, decui, yunhong.jiang,
	ricardo.neri-calderon, rahul.tanwar, linux-kernel, linux-hyperv,
	stable

On Mon, Aug 31, 2026 at 08:25:28AM +0000, Naman Jain wrote:
> 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: c311ed6183f4 ("x86/init: Allow DT configured systems to disable RTC at boot time")
> Cc: stable@vger.kernel.org
> Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
> ---
>  arch/x86/kernel/x86_init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
> index 252c5827d0634..3b9b41820c84c 100644
> --- a/arch/x86/kernel/x86_init.c
> +++ b/arch/x86/kernel/x86_init.c
> @@ -37,7 +37,7 @@ static void iommu_shutdown_noop(void) { }
>  bool __init bool_x86_init_noop(void) { return false; }
>  void x86_op_int_noop(int cpu) { }
>  int set_rtc_noop(const struct timespec64 *now) { return -EINVAL; }
> -void get_rtc_noop(struct timespec64 *now) { }
> +void get_rtc_noop(struct timespec64 *now) { *now = (struct timespec64){0}; }

Hi Naman,

Could be

*now = (struct timespec64){};

to save a byte :)

LGTM.
Reviewed-by: Roman Kisel <vdso@mailbox.org>

>  
>  static __initconst const struct of_device_id of_cmos_match[] = {
>  	{ .compatible = "motorola,mc146818" },
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/init: Initialize wall clock in get_rtc_noop()
  2026-09-12  3:35 ` Roman Kisel
@ 2026-09-14 11:31   ` Naman Jain
  2026-09-19  4:11     ` vdso
  0 siblings, 1 reply; 10+ messages in thread
From: Naman Jain @ 2026-09-14 11:31 UTC (permalink / raw)
  To: Roman Kisel
  Cc: glx, mingo, bp, dave.hansen, x86, hpa, decui, yunhong.jiang,
	ricardo.neri-calderon, rahul.tanwar, linux-kernel, linux-hyperv,
	stable



On 9/12/2026 9:05 AM, Roman Kisel wrote:
> On Mon, Aug 31, 2026 at 08:25:28AM +0000, Naman Jain wrote:
>> 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: c311ed6183f4 ("x86/init: Allow DT configured systems to disable RTC at boot time")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
>> ---
>>   arch/x86/kernel/x86_init.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
>> index 252c5827d0634..3b9b41820c84c 100644
>> --- a/arch/x86/kernel/x86_init.c
>> +++ b/arch/x86/kernel/x86_init.c
>> @@ -37,7 +37,7 @@ static void iommu_shutdown_noop(void) { }
>>   bool __init bool_x86_init_noop(void) { return false; }
>>   void x86_op_int_noop(int cpu) { }
>>   int set_rtc_noop(const struct timespec64 *now) { return -EINVAL; }
>> -void get_rtc_noop(struct timespec64 *now) { }
>> +void get_rtc_noop(struct timespec64 *now) { *now = (struct timespec64){0}; }
> 
> Hi Naman,
> 
> Could be
> 
> *now = (struct timespec64){};
> 
> to save a byte :)

hi Roman,
Thanks for reviewing.

Tianyu pointed out offline that this is handled in yet another way in 
jailhouse code:

arch/x86/kernel/jailhouse.c
static void jailhouse_get_wallclock(struct timespec64 *now)
{
       memset(now, 0, sizeof(now));
}

Regards,
Naman

> 
> LGTM.
> Reviewed-by: Roman Kisel <vdso@mailbox.org>
> 
>>   
>>   static __initconst const struct of_device_id of_cmos_match[] = {
>>   	{ .compatible = "motorola,mc146818" },
>> -- 
>> 2.43.0
>>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/init: Initialize wall clock in get_rtc_noop()
  2026-09-14 11:31   ` Naman Jain
@ 2026-09-19  4:11     ` vdso
  0 siblings, 0 replies; 10+ messages in thread
From: vdso @ 2026-09-19  4:11 UTC (permalink / raw)
  To: Naman Jain
  Cc: glx, mingo, bp, dave.hansen, x86, hpa, decui, yunhong.jiang,
	ricardo.neri-calderon, rahul.tanwar, linux-kernel, linux-hyperv,
	stable


> On 09/14/2026 4:31 AM PDT Naman Jain <namjain@linux.microsoft.com> wrote:
> 
>  
> On 9/12/2026 9:05 AM, Roman Kisel wrote:
> > On Mon, Aug 31, 2026 at 08:25:28AM +0000, Naman Jain wrote:

[...]

> >> +void get_rtc_noop(struct timespec64 *now) { *now = (struct timespec64){0}; }
> > 
> > Hi Naman,
> > 
> > Could be
> > 
> > *now = (struct timespec64){};
> > 
> > to save a byte :)
> 
> hi Roman,
> Thanks for reviewing.
> 
> Tianyu pointed out offline that this is handled in yet another way in 
> jailhouse code:
> 
> arch/x86/kernel/jailhouse.c
> static void jailhouse_get_wallclock(struct timespec64 *now)
> {
>        memset(now, 0, sizeof(now));
> }

Appreciate sharing! Makes sense to me, looks way more explicit. Most
importantly imo, the memset isn't actually producing a call here so
the clock no-op stays cheap when choosing `memset` over ` = {}`.

One can see that the kernel build compiles ` = {0}`, ` = {}` into

pxor ...
movups ...

on x64 in the above. I made sure the memset "call" is relaxed/optimized
away into the same sequence `pxor ...; movups ...`.

> 
> Regards,
> Naman
> 
> > 
> > LGTM.
> > Reviewed-by: Roman Kisel <vdso@mailbox.org>
> > 
> >>   
> >>   static __initconst const struct of_device_id of_cmos_match[] = {
> >>   	{ .compatible = "motorola,mc146818" },
> >> -- 
> >> 2.43.0
> >>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/init: Initialize wall clock in get_rtc_noop()
  2026-08-31  8:25 [PATCH] x86/init: Initialize wall clock in get_rtc_noop() Naman Jain
                   ` (2 preceding siblings ...)
  2026-09-12  3:35 ` Roman Kisel
@ 2026-10-12  5:24 ` Naman Jain
  2026-10-15 21:38 ` Thomas Gleixner
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Naman Jain @ 2026-10-12  5:24 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86
  Cc: hpa, decui, yunhong.jiang, ricardo.neri-calderon, rahul.tanwar,
	linux-kernel, linux-hyperv, stable



On 8/31/2026 1:55 PM, Naman Jain wrote:
> 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: c311ed6183f4 ("x86/init: Allow DT configured systems to disable RTC at boot time")
> Cc: stable@vger.kernel.org
> Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
> ---
>   arch/x86/kernel/x86_init.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
> index 252c5827d0634..3b9b41820c84c 100644
> --- a/arch/x86/kernel/x86_init.c
> +++ b/arch/x86/kernel/x86_init.c
> @@ -37,7 +37,7 @@ static void iommu_shutdown_noop(void) { }
>   bool __init bool_x86_init_noop(void) { return false; }
>   void x86_op_int_noop(int cpu) { }
>   int set_rtc_noop(const struct timespec64 *now) { return -EINVAL; }
> -void get_rtc_noop(struct timespec64 *now) { }
> +void get_rtc_noop(struct timespec64 *now) { *now = (struct timespec64){0}; }
>   
>   static __initconst const struct of_device_id of_cmos_match[] = {
>   	{ .compatible = "motorola,mc146818" },

Hi Maintainers,
Gentle ping on this patch. Please let me know if there are any comments 
or if any changes are needed from my side.

Regards,
Naman

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/init: Initialize wall clock in get_rtc_noop()
  2026-08-31  8:25 [PATCH] x86/init: Initialize wall clock in get_rtc_noop() Naman Jain
                   ` (3 preceding siblings ...)
  2026-10-12  5:24 ` Naman Jain
@ 2026-10-15 21:38 ` Thomas Gleixner
  2026-11-03  4:42 ` Naman Jain
  2026-11-03  5:57 ` [tip: x86/urgent] " tip-bot2 for Naman Jain
  6 siblings, 0 replies; 10+ messages in thread
From: Thomas Gleixner @ 2026-10-15 21:38 UTC (permalink / raw)
  To: Naman Jain, mingo, bp, dave.hansen, x86
  Cc: hpa, decui, namjain, yunhong.jiang, ricardo.neri-calderon,
	rahul.tanwar, linux-kernel, linux-hyperv, stable

On Mon, Aug 31 2026 at 08:25, Naman Jain wrote:
> 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: c311ed6183f4 ("x86/init: Allow DT configured systems to disable RTC at boot time")
> Cc: stable@vger.kernel.org
> Signed-off-by: Naman Jain <namjain@linux.microsoft.com>

Reviewed-by: Thomas Gleixner <tglx@kernel.org>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/init: Initialize wall clock in get_rtc_noop()
  2026-08-31  8:25 [PATCH] x86/init: Initialize wall clock in get_rtc_noop() Naman Jain
                   ` (4 preceding siblings ...)
  2026-10-15 21:38 ` Thomas Gleixner
@ 2026-11-03  4:42 ` Naman Jain
  2026-11-03  5:57 ` [tip: x86/urgent] " tip-bot2 for Naman Jain
  6 siblings, 0 replies; 10+ messages in thread
From: Naman Jain @ 2026-11-03  4:42 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86
  Cc: hpa, decui, yunhong.jiang, ricardo.neri-calderon, rahul.tanwar,
	linux-kernel, linux-hyperv, stable



On 8/31/2026 1:55 PM, Naman Jain wrote:
> 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: c311ed6183f4 ("x86/init: Allow DT configured systems to disable RTC at boot time")
> Cc: stable@vger.kernel.org
> Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
> ---
>   arch/x86/kernel/x86_init.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
> index 252c5827d0634..3b9b41820c84c 100644
> --- a/arch/x86/kernel/x86_init.c
> +++ b/arch/x86/kernel/x86_init.c
> @@ -37,7 +37,7 @@ static void iommu_shutdown_noop(void) { }
>   bool __init bool_x86_init_noop(void) { return false; }
>   void x86_op_int_noop(int cpu) { }
>   int set_rtc_noop(const struct timespec64 *now) { return -EINVAL; }
> -void get_rtc_noop(struct timespec64 *now) { }
> +void get_rtc_noop(struct timespec64 *now) { *now = (struct timespec64){0}; }
>   
>   static __initconst const struct of_device_id of_cmos_match[] = {
>   	{ .compatible = "motorola,mc146818" },

Hi all,

Gentle ping on this patch. Would it be possible to pick this change
up through the x86 tree?

Thanks,
Naman

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [tip: x86/urgent] x86/init: Initialize wall clock in get_rtc_noop()
  2026-08-31  8:25 [PATCH] x86/init: Initialize wall clock in get_rtc_noop() Naman Jain
                   ` (5 preceding siblings ...)
  2026-11-03  4:42 ` Naman Jain
@ 2026-11-03  5:57 ` tip-bot2 for Naman Jain
  6 siblings, 0 replies; 10+ messages in thread
From: tip-bot2 for Naman Jain @ 2026-11-03  5:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Naman Jain, Borislav Petkov (AMD), Thomas Gleixner, Roman Kisel,
	Hardik Garg, Dexuan Cui, stable, x86, linux-kernel

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

Commit-ID:     7d5af1f256fdecff6a7986bbc9146b69cb355bb5
Gitweb:        https://git.kernel.org/tip/7d5af1f256fdecff6a7986bbc9146b69cb355bb5
Author:        Naman Jain <namjain@linux.microsoft.com>
AuthorDate:    Mon, 31 Aug 2026 08:25:28 
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 02 Nov 2026 21:38:37 -08:00

x86/init: Initialize wall clock in get_rtc_noop()

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: c311ed6183f4 ("x86/init: Allow DT configured systems to disable RTC at boot time")
Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Roman Kisel <vdso@mailbox.org>
Reviewed-by: Hardik Garg <hargar@linux.microsoft.com>
Reviewed-by: Dexuan Cui <decui@microsoft.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260831082528.1623843-1-namjain@linux.microsoft.com
---
 arch/x86/kernel/x86_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index 252c582..3b9b418 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -37,7 +37,7 @@ static void iommu_shutdown_noop(void) { }
 bool __init bool_x86_init_noop(void) { return false; }
 void x86_op_int_noop(int cpu) { }
 int set_rtc_noop(const struct timespec64 *now) { return -EINVAL; }
-void get_rtc_noop(struct timespec64 *now) { }
+void get_rtc_noop(struct timespec64 *now) { *now = (struct timespec64){0}; }
 
 static __initconst const struct of_device_id of_cmos_match[] = {
 	{ .compatible = "motorola,mc146818" },

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-03  5:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-31  8:25 [PATCH] x86/init: Initialize wall clock in get_rtc_noop() Naman Jain
2026-09-09 18:42 ` Dexuan Cui
2026-09-11  4:23 ` Hardik Garg
2026-09-12  3:35 ` Roman Kisel
2026-09-14 11:31   ` Naman Jain
2026-09-19  4:11     ` vdso
2026-10-12  5:24 ` Naman Jain
2026-10-15 21:38 ` Thomas Gleixner
2026-11-03  4:42 ` Naman Jain
2026-11-03  5:57 ` [tip: x86/urgent] " tip-bot2 for Naman Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.