From: Ivan Maidanski Date: Fri, 23 Sep 2016 06:39:18 +0000 (+0300) Subject: Fix page calculation in checksums X-Git-Tag: v8.0.0~1144 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6837b48ce6e0593cb84683cbb65f94648a6341b7;p=gc Fix page calculation in checksums While consistent use of rounding mode for computing GC_faulted entries is ok, the proper way of getting page number of an address is just to clear the lowest bits of the latter. * checksums.c (GC_record_fault, GC_was_faulted): Do not round-up when computing page. * checksums.c (GC_record_fault): Add assertion that GC_page_size is initialized. --- diff --git a/checksums.c b/checksums.c index f0f902a3..c0ecebea 100644 --- a/checksums.c +++ b/checksums.c @@ -41,8 +41,9 @@ STATIC size_t GC_n_faulted = 0; void GC_record_fault(struct hblk * h) { - word page = ROUNDUP_PAGESIZE((word)h); + word page = (word)h & ~(GC_page_size - 1); + GC_ASSERT(GC_page_size != 0); if (GC_n_faulted >= NSUMS) ABORT("write fault log overflowed"); GC_faulted[GC_n_faulted++] = page; } @@ -50,7 +51,7 @@ void GC_record_fault(struct hblk * h) STATIC GC_bool GC_was_faulted(struct hblk *h) { size_t i; - word page = ROUNDUP_PAGESIZE((word)h); + word page = (word)h & ~(GC_page_size - 1); for (i = 0; i < GC_n_faulted; ++i) { if (GC_faulted[i] == page) return TRUE;