clocksource/drivers/hyper-v: Re-enable VDSO_CLOCKMODE_HVCLOCK on X86
Subsystems (4)
PATCH 1/1 clocksource/drivers/hyper-v: Re-enable VDSO_CLOCKMODE_HVCLOCK on X86
Mohammed reports (https://bugzilla.kernel.org/show_bug.cgi?id=213029)
the commit e4ab4658f1cf ("clocksource/drivers/hyper-v: Handle vDSO differences inline") broke vDSO on x86. The problem appears to be that VDSO_CLOCKMODE_HVCLOCK is an enum value in 'enum vdso_clock_mode' and '#ifdef VDSO_CLOCKMODE_HVCLOCK' branch evaluates to false (it is not a define). Replace it with CONFIG_X86 as it is the only arch which has this mode currently.
--- drivers/clocksource/hyperv_timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clocksource/hyperv_timer.c +2 -2
@@ -419,7 +419,7 @@ static void resume_hv_clock_tsc(struct clocksource *arg)hv_set_register (HV_REGISTER_REFERENCE_TSC , tsc_msr); } -#ifdef VDSO_CLOCKMODE_HVCLOCK +#ifdef CONFIG_X86 static int hv_cs_enable (struct clocksource *cs) {vclocks_set_used (VDSO_CLOCKMODE_HVCLOCK );
@@ -435,7 +435,7 @@ static struct clocksource hyperv_cs_tsc = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, .suspend= suspend_hv_clock_tsc, .resume = resume_hv_clock_tsc, -#ifdef VDSO_CLOCKMODE_HVCLOCK +#ifdef CONFIG_X86 .enable = hv_cs_enable, .vdso_clock_mode = VDSO_CLOCKMODE_HVCLOCK, #else
Signature · 1 line
2.31.1
From: Vitaly Kuznetsov <[email protected]> Sent: Wednesday, May 12, 2021 1:47 AM
Quoted 39 lines
Mohammed reports (https://bugzilla.kernel.org/show_bug.cgi?id=213029)
the commite4ab4658f1cf("clocksource/drivers/hyper-v: Handle vDSO differences inline") broke vDSO on x86. The problem appears to be thatVDSO_CLOCKMODE_HVCLOCKis an enum value in 'enumvdso_clock_mode' and '#ifdefVDSO_CLOCKMODE_HVCLOCK' branch evaluates to false (it is not a define). Replace it withCONFIG_X86as it is the only arch which has this mode currently.Reported-by Mohammed Gamal <[email protected]>Fixes e4ab4658f1cf ("clocksource/drivers/hyper-v: Handle vDSO differences inline")Signed-off-by Vitaly Kuznetsov <[email protected]>--- drivers/clocksource/hyperv_timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/clocksource/hyperv_timer.c +2
-3@@ -419,7 +419,7 @@ static void resume_hv_clock_tsc(struct clocksource *arg)hv_set_register (HV_REGISTER_REFERENCE_TSC , tsc_msr); } -#ifdef VDSO_CLOCKMODE_HVCLOCK +#ifdef CONFIG_X86 static int hv_cs_enable (struct clocksource *cs) {vclocks_set_used (VDSO_CLOCKMODE_HVCLOCK );@@ -435,7 +435,7 @@ static struct clocksource hyperv_cs_tsc = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, .suspend= suspend_hv_clock_tsc, .resume = resume_hv_clock_tsc, -#ifdef VDSO_CLOCKMODE_HVCLOCK +#ifdef CONFIG_X86 .enable = hv_cs_enable, .vdso_clock_mode = VDSO_CLOCKMODE_HVCLOCK, #else --
Quoted 1 line
2.31.1
Well, bummer. I thought I was being so clever. I hate having to base the behavior directly on the architecture instead of the actual VDSO feature, but I don't see a way to detect whether VDSO_CLOCKMODE_HVCLOCK is defined or not. The other alternative would be to add another #define such as VDSO_CLOCKMODE_HVCLOCK_PRESENT in arch/x86/include/asm/vdso/clocksource.h, and use it in the #ifdefs here. But that's a bit messy too, and I'm not sure it's worth the trouble. So,
Mohammed -- Thanks for finding this!
Quoted 29 lines · Vitaly Kuznetsov
Mohammed reports (https://bugzilla.kernel.org/show_bug.cgi?id=213029)
the commite4ab4658f1cf("clocksource/drivers/hyper-v: Handle vDSO differences inline") broke vDSO on x86. The problem appears to be thatVDSO_CLOCKMODE_HVCLOCKis an enum value in 'enumvdso_clock_mode' and '#ifdefVDSO_CLOCKMODE_HVCLOCK' branch evaluates to false (it is not a define). Replace it withCONFIG_X86as it is the only arch which has this mode currently.Reported-by Mohammed Gamal <[email protected]>Fixes e4ab4658f1cf ("clocksource/drivers/hyper-v: Handle vDSO differences inline")Signed-off-by Vitaly Kuznetsov <[email protected]>--- drivers/clocksource/hyperv_timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/clocksource/hyperv_timer.c +1
-1@@ -419,7 +419,7 @@ static void resume_hv_clock_tsc(struct clocksource *arg)hv_set_register (HV_REGISTER_REFERENCE_TSC , tsc_msr); } -#ifdef VDSO_CLOCKMODE_HVCLOCK +#ifdef CONFIG_X86 static int hv_cs_enable (struct clocksource *cs) {vclocks_set_used (VDSO_CLOCKMODE_HVCLOCK );
drivers/clocksource/hyperv_timer.c static struct clocksource hyperv_cs_tsc = { · line 441
Quoted 8 lines
drivers/clocksource/hyperv_timer.c +1
-1@@ -435,7 +435,7 @@ static struct clocksource hyperv_cs_tsc = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, .suspend= suspend_hv_clock_tsc, .resume = resume_hv_clock_tsc, -#ifdef VDSO_CLOCKMODE_HVCLOCK +#ifdef CONFIG_X86 .enable = hv_cs_enable, .vdso_clock_mode = VDSO_CLOCKMODE_HVCLOCK, #else
That's lame as it needs to be patched differently once ARM64 gains support. What about the below?
Thanks,
tglx
---
arch/x86/include/asm/vdso/clocksource.h +2 -0
@@ -7,4 +7,6 @@VDSO_CLOCKMODE_PVCLOCK , \ VDSO_CLOCKMODE_HVCLOCK +#define HAVE_VDSO_CLOCKMODE_HVCLOCK +#endif /* __ASM_VDSO_CLOCKSOURCE_H */
drivers/clocksource/hyperv_timer.c +2 -2
@@ -419,7 +419,7 @@ static void resume_hv_clock_tsc(struct chv_set_register (HV_REGISTER_REFERENCE_TSC , tsc_msr); } -#ifdef VDSO_CLOCKMODE_HVCLOCK +#ifdef HAVE_VDSO_CLOCKMODE_HVCLOCK static int hv_cs_enable (struct clocksource *cs) {vclocks_set_used (VDSO_CLOCKMODE_HVCLOCK );
@@ -435,7 +435,7 @@ static struct clocksource hyperv_cs_tsc .flags = CLOCK_SOURCE_IS_CONTINUOUS, .suspend= suspend_hv_clock_tsc, .resume = resume_hv_clock_tsc, -#ifdef VDSO_CLOCKMODE_HVCLOCK +#ifdef HAVE_VDSO_CLOCKMODE_HVCLOCK .enable = hv_cs_enable, .vdso_clock_mode = VDSO_CLOCKMODE_HVCLOCK, #else
Quoted 33 lines · Thomas Gleixner
Quoted 32 lines · Vitaly Kuznetsov
Mohammed reports (https://bugzilla.kernel.org/show_bug.cgi?id=213029)
the commite4ab4658f1cf("clocksource/drivers/hyper-v: Handle vDSO differences inline") broke vDSO on x86. The problem appears to be thatVDSO_CLOCKMODE_HVCLOCKis an enum value in 'enumvdso_clock_mode' and '#ifdefVDSO_CLOCKMODE_HVCLOCK' branch evaluates to false (it is not a define). Replace it withCONFIG_X86as it is the only arch which has this mode currently.Reported-by Mohammed Gamal <[email protected]>Fixes e4ab4658f1cf ("clocksource/drivers/hyper-v: Handle vDSO differences inline")Signed-off-by Vitaly Kuznetsov <[email protected]>--- drivers/clocksource/hyperv_timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/clocksource/hyperv_timer.c +1
-1@@ -419,7 +419,7 @@ static void resume_hv_clock_tsc(struct clocksource *arg)hv_set_register (HV_REGISTER_REFERENCE_TSC , tsc_msr); } -#ifdef VDSO_CLOCKMODE_HVCLOCK +#ifdef CONFIG_X86 static int hv_cs_enable (struct clocksource *cs) {vclocks_set_used (VDSO_CLOCKMODE_HVCLOCK );@@ -435,7 +435,7 @@ static struct clocksource hyperv_cs_tsc = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, .suspend= suspend_hv_clock_tsc, .resume = resume_hv_clock_tsc,
Quoted 9 lines
drivers/clocksource/hyperv_timer.c static struct clocksource hyperv_cs_tsc · line 441
Quoted 5 lines
drivers/clocksource/hyperv_timer.c +1
-1-#ifdef VDSO_CLOCKMODE_HVCLOCK +#ifdef CONFIG_X86 .enable = hv_cs_enable, .vdso_clock_mode = VDSO_CLOCKMODE_HVCLOCK,#else That's lame as it needs to be patched differently once ARM64 gains support. What about the below?
The solution I liked the most was Michael's: no need to do anything except for adding VDSO_CLOCKMODE_HVCLOCK to the enum. Too bad it didn't work)
You proposal seems to be slightly better than mine: when adding VDSO_CLOCKMODE_HVCLOCK to ARM the change will be limited to drivers/clocksource/hyperv_timer.c will stay intact.
I'll send v2 shortly, thanks!
Quoted 34 lines
Thanks,
tglx
---arch/x86/include/asm/vdso/clocksource.h +2
-0@@ -7,4 +7,6 @@VDSO_CLOCKMODE_PVCLOCK , \ VDSO_CLOCKMODE_HVCLOCK +#define HAVE_VDSO_CLOCKMODE_HVCLOCK +#endif /* __ASM_VDSO_CLOCKSOURCE_H */ drivers/clocksource/hyperv_timer.c +2
-2@@ -419,7 +419,7 @@ static void resume_hv_clock_tsc(struct chv_set_register (HV_REGISTER_REFERENCE_TSC , tsc_msr); } -#ifdef VDSO_CLOCKMODE_HVCLOCK +#ifdef HAVE_VDSO_CLOCKMODE_HVCLOCK static int hv_cs_enable (struct clocksource *cs) {vclocks_set_used (VDSO_CLOCKMODE_HVCLOCK );@@ -435,7 +435,7 @@ static struct clocksource hyperv_cs_tsc .flags = CLOCK_SOURCE_IS_CONTINUOUS, .suspend= suspend_hv_clock_tsc, .resume = resume_hv_clock_tsc, -#ifdef VDSO_CLOCKMODE_HVCLOCK +#ifdef HAVE_VDSO_CLOCKMODE_HVCLOCK .enable = hv_cs_enable, .vdso_clock_mode = VDSO_CLOCKMODE_HVCLOCK, #else
Signature · 1 line
Vitaly