Page MenuHomeFreeBSD

D60430.diff
No OneTemporary

D60430.diff

diff --git a/sys/amd64/vmm/io/vpmtmr.c b/sys/amd64/vmm/io/vpmtmr.c
--- a/sys/amd64/vmm/io/vpmtmr.c
+++ b/sys/amd64/vmm/io/vpmtmr.c
@@ -50,7 +50,6 @@
#define PMTMR_FREQ 3579545 /* 3.579545MHz */
struct vpmtmr {
- sbintime_t freq_sbt;
sbintime_t baseuptime;
uint32_t baseval;
};
@@ -61,15 +60,11 @@
vpmtmr_init(struct vm *vm)
{
struct vpmtmr *vpmtmr;
- struct bintime bt;
vpmtmr = malloc(sizeof(struct vpmtmr), M_VPMTMR, M_WAITOK | M_ZERO);
vpmtmr->baseuptime = sbinuptime();
vpmtmr->baseval = 0;
- FREQ2BT(PMTMR_FREQ, &bt);
- vpmtmr->freq_sbt = bttosbt(bt);
-
return (vpmtmr);
}
@@ -99,7 +94,13 @@
delta = now - vpmtmr->baseuptime;
KASSERT(delta >= 0, ("vpmtmr_handler: uptime went backwards: "
"%#lx to %#lx", vpmtmr->baseuptime, now));
- *val = vpmtmr->baseval + delta / vpmtmr->freq_sbt;
+ /*
+ * delta is in seconds as 32.32 fixed point; multiply each half by the
+ * frequency rather than divide by the period, which is not a whole
+ * number of sbintime units.
+ */
+ *val = vpmtmr->baseval + (uint64_t)(delta >> 32) * PMTMR_FREQ +
+ (((uint64_t)delta & 0xffffffff) * PMTMR_FREQ >> 32);
return (0);
}

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 8, 11:40 AM (17 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40407328
Default Alt Text
D60430.diff (1 KB)

Event Timeline