Skip to contentSkip to conversation

x86: Hyper-V clock source's offset should be signed

PATCH In review Wei Liu 2 participants 5 messages Dec 20, 2019

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 x86: Hyper-V clock source's offset should be signed

Fixes 685d16bd5 (x86: implement Hyper-V clock source)

---
I discover this stupid mistake when I work on extracting common code from viridian and the clock source implementation.

---
 xen/arch/x86/time.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/x86/time.c +2 -1
index a3c9b927e8..bbcc9b10b8 100644
@@ -698,7 +698,8 @@ static int64_t __init init_hyperv_timer(struct platform_timesource *pts)
 
 static inline uint64_t read_hyperv_timer(void)
 {
-    uint64_t scale, offset, ret, tsc;
+    uint64_t scale, ret, tsc;
+    int64_t offset;
     uint32_t seq;
     const struct ms_hyperv_tsc_page *tsc_page = hyperv_tsc;
 
Signature · 7 lines
2.20.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 5 lines · Wei Liu
Fixes 685d16bd5 (x86: implement Hyper-V clock source)

---
I discover this stupid mistake when I work on extracting common code from viridian and the clock source implementation.

Does it make a practical difference?

xen/arch/x86/time.c static int64_t __init init_hyperv_timer(struct platform_timesource *pts) · line 699

Quoted 11 lines
---
 xen/arch/x86/time.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/x86/time.c +0 -0
index a3c9b927e8..bbcc9b10b8 100644
@@ -698,7 +698,8 @@ static int64_t __init init_hyperv_timer(struct platform_timesource *pts)
 
 static inline uint64_t read_hyperv_timer(void)

Also, this function is only ever accessed via pointer.  The inline can't be satisfied at all.

~Andrew

xen/arch/x86/time.c static int64_t __init init_hyperv_timer(struct platform_timesource *pts) · line 705

Quoted 7 lines
xen/arch/x86/time.c +2 -1
 {
-    uint64_t scale, offset, ret, tsc;
+    uint64_t scale, ret, tsc;
+    int64_t offset;
     uint32_t seq;
     const struct ms_hyperv_tsc_page *tsc_page = hyperv_tsc;
 

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#2 lore raw
Quoted 10 lines · Andrew Cooper
Quoted 5 lines · Wei Liu
Fixes 685d16bd5 (x86: implement Hyper-V clock source)

---
I discover this stupid mistake when I work on extracting common code from viridian and the clock source implementation.

Does it make a practical difference?

Probably not. The specs says that field is signed, so our code should reflect that.

Quoted 10 lines
Quoted 10 lines
---
 xen/arch/x86/time.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/x86/time.c +0 -0
index a3c9b927e8..bbcc9b10b8 100644
@@ -698,7 +698,8 @@ static int64_t __init init_hyperv_timer(struct platform_timesource *pts)
 
Quoted 5 lines

xen/arch/x86/time.c static int64_t __init init_hyperv_timer(struct platform_timesource *pts) · line 699

Quoted 1 line
xen/arch/x86/time.c +0 -0
 static inline uint64_t read_hyperv_timer(void)

Also, this function is only ever accessed via pointer. The inline can't be satisfied at all.

I can drop the inline here.

Wei.

Quoted 10 lines

~Andrew

Quoted 7 lines
xen/arch/x86/time.c +2 -1
 {
-    uint64_t scale, offset, ret, tsc;
+    uint64_t scale, ret, tsc;
+    int64_t offset;
     uint32_t seq;
     const struct ms_hyperv_tsc_page *tsc_page = hyperv_tsc;
 

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 11 lines · Wei Liu
Quoted 8 lines · Andrew Cooper
Quoted 5 lines · Wei Liu
Fixes 685d16bd5 (x86: implement Hyper-V clock source)

---
I discover this stupid mistake when I work on extracting common code from viridian and the clock source implementation.

Does it make a practical difference?

Probably not. The specs says that field is signed, so our code should reflect that.

Fair enough.  Acked-by: Andrew Cooper <[email protected]> (with the inline fix as well)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#4 lore raw
Quoted 8 lines · Andrew Cooper
Quoted 7 lines · Wei Liu
Quoted 6 lines · Andrew Cooper
Quoted 5 lines · Wei Liu
Fixes 685d16bd5 (x86: implement Hyper-V clock source)

---
I discover this stupid mistake when I work on extracting common code from viridian and the clock source implementation.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Does it make a practical difference?

Probably not. The specs says that field is signed, so our code should reflect that.

Fair enough.  Acked-by: Andrew Cooper <[email protected]> (with the inline fix as well)

Thanks. I will commit this now.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel