Skip to content

Commit 6ca4d6f

Browse files
mihalicynrst0git
authored andcommitted
criu/mem: dump: skip MADV_GUARD pages content dump
1. get info about MADV_GUARD_INSTALL-protected pages with help of pagemap by looking for PME_GUARD_REGION flag if /proc/<pid>/pagemap is used or by looking for PAGE_IS_GUARD flag if ioctl(PAGEMAP_SCAN) is used 2. skip those pages Signed-off-by: Alexander Mikhalitsyn <[email protected]>
1 parent 53d3e0c commit 6ca4d6f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

criu/include/mem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ extern int parasite_dump_pages_seized(struct pstree_item *item, struct vm_area_l
3535
#define PME_PRESENT (1ULL << 63)
3636
#define PME_SWAP (1ULL << 62)
3737
#define PME_FILE (1ULL << 61)
38+
#define PME_GUARD_REGION (1ULL << 58)
3839
#define PME_SOFT_DIRTY (1ULL << 55)
3940
#define PME_PSHIFT_BITS (6)
4041
#define PME_STATUS_BITS (3)

criu/mem.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,18 @@ int should_dump_page(pmc_t *pmc, VmaEntry *vmae, u64 vaddr, struct page_info *pa
143143
return 0;
144144
}
145145

146+
if (pmc->regs[pmc->regs_idx].categories & PAGE_IS_GUARD)
147+
goto skip_guard_page;
148+
146149
page_info->softdirty = pmc->regs[pmc->regs_idx].categories & PAGE_IS_SOFT_DIRTY;
147150
page_info->next = vaddr;
148151
return 0;
149152
} else {
150153
u64 pme = pmc->map[PAGE_PFN(vaddr - pmc->start)];
151154

155+
if (pme & PME_GUARD_REGION)
156+
goto skip_guard_page;
157+
152158
/*
153159
* Optimisation for private mapping pages, that haven't
154160
* yet being COW-ed
@@ -173,6 +179,10 @@ int should_dump_page(pmc_t *pmc, VmaEntry *vmae, u64 vaddr, struct page_info *pa
173179
"%#016" PRIx64 "-%#016" PRIx64 " vaddr=%#016" PRIx64 "\n",
174180
vmae->start, vmae->end, vaddr);
175181
return -1;
182+
183+
skip_guard_page:
184+
page_info->next = vaddr + PAGE_SIZE;
185+
return 0;
176186
}
177187

178188
bool page_is_zero(u64 pme)

0 commit comments

Comments
 (0)