mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 18:07:57 +00:00
kerndat: add pagemap_scan_guard_pages feature check logic
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
This commit is contained in:
parent
54c078e6c2
commit
66b46e5988
@ -1599,6 +1599,12 @@ static int check_breakpoints(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int check_pagemap_scan_guard_pages(void)
|
||||||
|
{
|
||||||
|
kerndat_warn_about_madv_guards();
|
||||||
|
|
||||||
|
return kdat.has_pagemap_scan_guard_pages ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
static int (*chk_feature)(void);
|
static int (*chk_feature)(void);
|
||||||
|
|
||||||
@ -1724,6 +1730,7 @@ int cr_check(void)
|
|||||||
ret |= check_pagemap_scan();
|
ret |= check_pagemap_scan();
|
||||||
ret |= check_overlayfs_maps();
|
ret |= check_overlayfs_maps();
|
||||||
ret |= check_timer_cr_ids();
|
ret |= check_timer_cr_ids();
|
||||||
|
ret |= check_pagemap_scan_guard_pages();
|
||||||
|
|
||||||
if (kdat.lsm == LSMTYPE__APPARMOR)
|
if (kdat.lsm == LSMTYPE__APPARMOR)
|
||||||
ret |= check_apparmor_stacking();
|
ret |= check_apparmor_stacking();
|
||||||
@ -1853,6 +1860,7 @@ static struct feature_list feature_list[] = {
|
|||||||
{ "timer_cr_ids", check_timer_cr_ids },
|
{ "timer_cr_ids", check_timer_cr_ids },
|
||||||
{ "overlayfs_maps", check_overlayfs_maps },
|
{ "overlayfs_maps", check_overlayfs_maps },
|
||||||
{ "breakpoints", check_breakpoints },
|
{ "breakpoints", check_breakpoints },
|
||||||
|
{ "pagemap_scan_guard_pages", check_pagemap_scan_guard_pages },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ struct kerndat_s {
|
|||||||
bool has_timer_cr_ids;
|
bool has_timer_cr_ids;
|
||||||
bool has_breakpoints;
|
bool has_breakpoints;
|
||||||
bool has_madv_guard;
|
bool has_madv_guard;
|
||||||
|
bool has_pagemap_scan_guard_pages;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct kerndat_s kdat;
|
extern struct kerndat_s kdat;
|
||||||
@ -114,4 +115,6 @@ extern int kerndat_fs_virtualized(unsigned int which, u32 kdev);
|
|||||||
|
|
||||||
extern int kerndat_has_nspid(void);
|
extern int kerndat_has_nspid(void);
|
||||||
|
|
||||||
|
extern void kerndat_warn_about_madv_guards(void);
|
||||||
|
|
||||||
#endif /* __CR_KERNDAT_H__ */
|
#endif /* __CR_KERNDAT_H__ */
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#define PAGE_IS_PFNZERO (1 << 5)
|
#define PAGE_IS_PFNZERO (1 << 5)
|
||||||
#define PAGE_IS_HUGE (1 << 6)
|
#define PAGE_IS_HUGE (1 << 6)
|
||||||
#define PAGE_IS_SOFT_DIRTY (1 << 7)
|
#define PAGE_IS_SOFT_DIRTY (1 << 7)
|
||||||
|
#define PAGE_IS_GUARD (1 << 8)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* struct page_region - Page region with flags
|
* struct page_region - Page region with flags
|
||||||
|
@ -87,6 +87,10 @@ static int check_pagemap(void)
|
|||||||
if (ioctl(fd, PAGEMAP_SCAN, &args) == 0) {
|
if (ioctl(fd, PAGEMAP_SCAN, &args) == 0) {
|
||||||
pr_debug("PAGEMAP_SCAN is supported\n");
|
pr_debug("PAGEMAP_SCAN is supported\n");
|
||||||
kdat.has_pagemap_scan = true;
|
kdat.has_pagemap_scan = true;
|
||||||
|
|
||||||
|
args.return_mask |= PAGE_IS_GUARD;
|
||||||
|
if (ioctl(fd, PAGEMAP_SCAN, &args) == 0)
|
||||||
|
kdat.has_pagemap_scan_guard_pages = true;
|
||||||
} else {
|
} else {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
case EINVAL:
|
case EINVAL:
|
||||||
@ -1841,6 +1845,14 @@ mmap_cleanup:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void kerndat_warn_about_madv_guards(void)
|
||||||
|
{
|
||||||
|
if (kdat.has_madv_guard && !kdat.has_pagemap_scan_guard_pages)
|
||||||
|
pr_warn("ioctl(PAGEMAP_SCAN) doesn't support PAGE_IS_GUARD flag. "
|
||||||
|
"CRIU dump will fail if dumped processes use madvise(MADV_GUARD_INSTALL). "
|
||||||
|
"Please, consider updating your kernel.\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some features depend on resource that can be dynamically changed
|
* Some features depend on resource that can be dynamically changed
|
||||||
* at the OS runtime. There are cases that we cannot determine the
|
* at the OS runtime. There are cases that we cannot determine the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user