GNU GRUB - Bugs: bug #64623, calculate tsc rate by the actual...
You are not allowed to post comments on this tracker with your current authentication level.
bug #64623: calculate tsc rate by the actual pmtimer delta
Submitter: | Qi Ai <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 |
Open/Closed: | Open | Release: | Git master |
Release: | Reproducibility: | None | |
Planned Release: | None |
Attached Files
file #55112: 0001-kern-tsc-calculate-tsc-rate-by-the-actual-pmtimer-de.patch added by aiqi (1KiB - application/octet-stream)
Depends on the following items: None found
Items that depend on this one: None found
Carbon-Copy List
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Follows 1 latest change.
Date | Changed by | Updated Field | Previous Value | => | Replaced by |
---|---|---|---|---|---|
2023-09-05 | aiqi | Attached File | - | Added 0001-kern-tsc-calculate-tsc-rate-by-the-actual-pmtimer-de.patch, #55112 |
Powered by Savane 3.13-02a9.
Corresponding source code
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;
}