[CRIU] [PATCH 07/11] vdso: Save vdso/vvar pair order inside vdso_symtable

Dmitry Safonov dsafonov at virtuozzo.com
Thu Jun 15 19:36:11 MSK 2017


I plan to keep boot-persistent vdso_symtable inside kdat,
moving {vvar,vdso}_start addresses out into new structure.
As order of vdso/vvar is preserved across one booting store
it inside of vdso_symtable.

Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/include/util-vdso.h |  2 ++
 criu/pie/parasite-vdso.c | 12 +++++-------
 criu/vdso.c              |  3 +++
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/criu/include/util-vdso.h b/criu/include/util-vdso.h
index 4f734593c337..6e7182ba15f4 100644
--- a/criu/include/util-vdso.h
+++ b/criu/include/util-vdso.h
@@ -33,6 +33,7 @@ struct vdso_symtable {
 	unsigned long		vvar_start;
 	unsigned long		vvar_size;
 	struct vdso_symbol	symbols[VDSO_SYMBOL_MAX];
+	bool			vdso_before_vvar; /* order of vdso/vvar pair */
 };
 
 #define VDSO_SYMBOL_INIT	{ .offset = VDSO_BAD_ADDR, }
@@ -47,6 +48,7 @@ struct vdso_symtable {
 			[0 ... VDSO_SYMBOL_MAX - 1] =			\
 				(struct vdso_symbol)VDSO_SYMBOL_INIT,	\
 			},						\
+		.vdso_before_vvar	= false,			\
 	}
 
 #ifdef CONFIG_VDSO_32
diff --git a/criu/pie/parasite-vdso.c b/criu/pie/parasite-vdso.c
index 31b7f8d93655..05aa973b2819 100644
--- a/criu/pie/parasite-vdso.c
+++ b/criu/pie/parasite-vdso.c
@@ -48,8 +48,8 @@ int vdso_do_park(struct vdso_symtable *sym_rt, unsigned long park_at, unsigned l
 
 	BUG_ON((sym_rt->vdso_size + sym_rt->vvar_size) < park_size);
 
-	if (sym_rt->vvar_start != VDSO_BAD_ADDR) {
-		if (sym_rt->vdso_start < sym_rt->vvar_start) {
+	if (sym_rt->vvar_start != VVAR_BAD_ADDR) {
+		if (sym_rt->vdso_before_vvar) {
 			ret  = vdso_remap("rt-vdso", sym_rt->vdso_start,
 					  park_at, sym_rt->vdso_size);
 			park_at += sym_rt->vdso_size;
@@ -127,13 +127,12 @@ static bool blobs_matches(VmaEntry *vdso_img, VmaEntry *vvar_img,
 	}
 
 	if (vvar_img && sym_rt->vvar_start != VVAR_BAD_ADDR) {
-		long delta_rt = sym_rt->vvar_start - sym_rt->vdso_start;
-		long delta_img = vvar_img->start - vdso_img->start;
+		bool vdso_firstly = (vvar_img->start > vdso_img->start);
 
 		if (sym_rt->vvar_size != vma_entry_len(vvar_img))
 			return false;
 
-		return delta_rt == delta_img;
+		return (vdso_firstly == sym_rt->vdso_before_vvar);
 	}
 
 	return true;
@@ -238,8 +237,7 @@ int vdso_proxify(struct vdso_symtable *sym_rt, unsigned long vdso_rt_parked_at,
 	/*
 	 * Don't forget to shift if vvar is before vdso.
 	 */
-	if (sym_rt->vvar_start != VDSO_BAD_ADDR &&
-	    sym_rt->vvar_start < sym_rt->vdso_start)
+	if (sym_rt->vvar_start != VDSO_BAD_ADDR && !sym_rt->vdso_before_vvar)
 		vdso_rt_parked_at += sym_rt->vvar_size;
 
 	if (vdso_redirect_calls(vdso_rt_parked_at,
diff --git a/criu/vdso.c b/criu/vdso.c
index de5f22c07beb..d6e47cf8185d 100644
--- a/criu/vdso.c
+++ b/criu/vdso.c
@@ -283,6 +283,9 @@ static int vdso_parse_maps(pid_t pid, struct vdso_symtable *s)
 		}
 	}
 
+	if (s->vdso_start != VDSO_BAD_ADDR && s->vvar_start != VVAR_BAD_ADDR)
+		s->vdso_before_vvar = (s->vdso_start < s->vvar_start);
+
 	exit_code = 0;
 err:
 	bclose(&f);
-- 
2.12.2



More information about the CRIU mailing list