diff options
Diffstat (limited to 'tools/testing/selftests/vm/vm_util.c')
-rw-r--r-- | tools/testing/selftests/vm/vm_util.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/testing/selftests/vm/vm_util.c b/tools/testing/selftests/vm/vm_util.c index 5bbf7641a0f0..710571902743 100644 --- a/tools/testing/selftests/vm/vm_util.c +++ b/tools/testing/selftests/vm/vm_util.c @@ -43,6 +43,16 @@ bool pagemap_is_populated(int fd, char *start) return entry & 0xc000000000000000ull; } +unsigned long pagemap_get_pfn(int fd, char *start) +{ + uint64_t entry = pagemap_get_entry(fd, start); + + /* If present (63th bit), PFN is at bit 0 -- 54. */ + if (entry & 0x8000000000000000ull) + return entry & 0x007fffffffffffffull; + return -1ull; +} + void clear_softdirty(void) { int ret; |