[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #64623] calculate tsc rate by the actual pmtimer delta
From: |
Qi Ai |
Subject: |
[bug #64623] calculate tsc rate by the actual pmtimer delta |
Date: |
Tue, 5 Sep 2023 07:18:21 -0400 (EDT) |
URL:
<https://savannah.gnu.org/bugs/?64623>
Summary: calculate tsc rate by the actual pmtimer delta
Group: GNU GRUB
Submitter: aiqi
Submitted: Tue 05 Sep 2023 11:18:19 AM UTC
Category: Booting
Severity: Major
Priority: 5 - Normal
Item Group: Software Error
Status: None
Privacy: Public
Assigned to: None
Originator Name: Qi Ai
Originator Email:
Open/Closed: Open
Release: Git master
Release:
Discussion Lock: Any
Reproducibility: None
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Tue 05 Sep 2023 11:18:19 AM UTC By: Qi Ai <aiqi>
In qemu/kvm, qemu emulates the pmtimer. Reading pmtimer in vm will cause a vm
exit, and qemu read the real time. If the qemu thread is scheduled out before
reading time, the time that vm reads may delay. In some case, pmtimer delta
may be far more than 1ms, which cause tsc rate is much larger than real rate.
So in grub menu, grub timeout will take more time than expected. So calculate
tsc rate by the actual pmtimer delta, not always use 1ms.
This fixs cannot fix the issue completely, it just reduce the probability of
the issue.
diff --git a/grub-core/kern/i386/tsc_pmtimer.c
b/grub-core/kern/i386/tsc_pmtimer.c
index 5c03c510a..6d0802dfe 100644
--- a/grub-core/kern/i386/tsc_pmtimer.c
+++ b/grub-core/kern/i386/tsc_pmtimer.c
@@ -84,7 +84,7 @@ grub_pmtimer_wait_count_tsc (grub_port_t pmtimer,
cur - start);
grub_dprintf ("pmtimer", "tsc delta is 0x%"PRIxGRUB_UINT64_T"\n",
end_tsc - start_tsc);
- return end_tsc - start_tsc;
+ return (end_tsc - start_tsc) / (cur - start) * num_pm_ticks;
}
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?64623>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #64623] calculate tsc rate by the actual pmtimer delta,
Qi Ai <=