Skip to content

Commit 91e03f5

Browse files
authored
Merge pull request #60 from lrowe/fix-accessed-pages2
Fix get_accessed_pages to include 4KB pages.
2 parents a97f730 + c05aeb9 commit 91e03f5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/tinykvm/amd64/paging.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,9 @@ std::vector<std::pair<uint64_t, uint64_t>> get_accessed_pages(const vMemory& mem
552552
std::vector<std::pair<uint64_t, uint64_t>> accessed_pages;
553553
foreach_page(memory,
554554
[&accessed_pages] (uint64_t addr, uint64_t& entry, size_t size) {
555-
if ((entry & (PDE64_PS | PDE64_ACCESSED | PDE64_PRESENT)) == (PDE64_PS | PDE64_ACCESSED | PDE64_PRESENT)) {
555+
// Leaf pages are either huge pages with the PS bit set or of PAGE_SIZE.
556+
if ((entry & (PDE64_ACCESSED | PDE64_PRESENT)) == (PDE64_ACCESSED | PDE64_PRESENT) &&
557+
((entry & PDE64_PS) || (size == PAGE_SIZE))) {
556558
accessed_pages.push_back({addr & PDE64_ADDR_MASK, size});
557559
}
558560
}, false);

0 commit comments

Comments
 (0)