Skip to contentSkip to conversation

cr: restore vDSO on i386/x86_64

PATCH In review Alexey Dobriyan 3 participants 3 messages Apr 10, 2009 – Apr 16, 2009 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 18/30 cr: restore vDSO on i386/x86_64

FIXME: check VMA has same parameters.
FIXME: abort if target kernel has vDSO disabled (?)
FIXME: restore pages, vDSO is writable after all.

---

 arch/x86/vdso/vdso32-setup.c |    6 ++
 include/linux/cr.h           |   11 +++++
 include/linux/mm.h           |    5 +-
 kernel/cr/cr-mm.c            |   87 +++++++++++++++++++++++++++++++++++++++++++
 mm/mmap.c                    |    3 +
 5 files changed, 110 insertions(+), 2 deletions(-)
arch/x86/vdso/vdso32-setup.c +5 -1
@@ -328,6 +328,10 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, unsigned long start,
 
 	map_compat_vdso(compat);
 
+	if (start) {
+		addr = start;
+		goto map;
+	}
 	if (compat)
 		addr = VDSO_HIGH_BASE;
 	else {
@@ -337,7 +341,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, unsigned long start,
 			goto up_fail;
 		}
 	}
-
+map:
 	if (compat_uses_vma || !compat) {
 		/*
 		 * MAYWRITE to allow gdb to COW and set breakpoints
include/linux/cr.h +11 -0
@@ -34,6 +34,7 @@ struct cr_object_header {
 #define CR_OBJ_FILE		3
 #define CR_OBJ_VMA		4
 #define CR_OBJ_VMA_CONTENT	5
+#define CR_OBJ_VMA_VDSO		6
 	__u32	cr_type;	/* object type */
 	__u32	cr_len;		/* object length in bytes including header */
 } __packed;
@@ -177,6 +178,16 @@ struct cr_image_vma {
 	cr_pos_t	cr_pos_vm_file;
 } __packed;
 
+struct cr_image_vma_vdso {
+	struct cr_object_header cr_hdr;
+
+	__u64		cr_vm_start;
+	__u64		cr_vm_end;
+	__u64		cr_vm_page_prot;
+	__u64		cr_vm_flags;
+	__u64		cr_vm_pgoff;
+} __packed;
+
 struct cr_image_vma_content {
 	struct cr_object_header cr_hdr;
 
include/linux/mm.h +4 -1
@@ -1129,7 +1129,10 @@ extern int may_expand_vm(struct mm_struct *mm, unsigned long npages);
 extern int install_special_mapping(struct mm_struct *mm,
 				   unsigned long addr, unsigned long len,
 				   unsigned long flags, struct page **pages);
-
+#ifdef CONFIG_CR
+struct cr_context;
+int special_mapping_checkpoint(struct vm_area_struct *vma, struct cr_context *ctx);
+#endif
 extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
 
 extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
kernel/cr/cr-mm.c +87 -0

99 lines not on this page · raw message

mm/mmap.c +3 -0
@@ -2257,6 +2257,9 @@ static void special_mapping_close(struct vm_area_struct *vma)
 static struct vm_operations_struct special_mapping_vmops = {
 	.close = special_mapping_close,
 	.fault = special_mapping_fault,
+#ifdef CONFIG_CR
+	.checkpoint = special_mapping_checkpoint,
+#endif
 };
 
 /*

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 17 lines · Alexey Dobriyan

FIXME: check VMA has same parameters.
FIXME: abort if target kernel has vDSO disabled (?)
FIXME: restore pages, vDSO is writable after all.

---

 arch/x86/vdso/vdso32-setup.c |    6 ++
 include/linux/cr.h           |   11 +++++
 include/linux/mm.h           |    5 +-
 kernel/cr/cr-mm.c            |   87 +++++++++++++++++++++++++++++++++++++++++++
 mm/mmap.c                    |    3 +
 5 files changed, 110 insertions(+), 2 deletions(-)

arch/x86/vdso/vdso32-setup.c int arch_setup_additional_pages(struct linux_binprm *bprm, unsigned long start, · line 334

Quoted 7 lines
arch/x86/vdso/vdso32-setup.c +4 -0
@@ -328,6 +328,10 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, unsigned long start,
 
 	map_compat_vdso(compat);
 
+	if (start) {
+		addr = start;
+		goto map;
+	}

Hmm, is there any safety to be gained by using

	arch_get_unmapped_area(NULL, start, PAGE_SIZE, 0, 0);

so as to make sure there is a free page?

arch/x86/vdso/vdso32-setup.c int arch_setup_additional_pages(struct linux_binprm *bprm, unsigned long start, · line 347

Quoted 12 lines
arch/x86/vdso/vdso32-setup.c +1 -1
 	if (compat)
 		addr = VDSO_HIGH_BASE;
 	else {
@@ -337,7 +341,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, unsigned long start,
 			goto up_fail;
 		}
 	}
-
+map:
 	if (compat_uses_vma || !compat) {
 		/*
 		 * MAYWRITE to allow gdb to COW and set breakpoints

thanks,
-serge

#3 lore raw
In reply to Alexey Dobriyan
Quoted 17 lines · Alexey Dobriyan

FIXME: check VMA has same parameters.
FIXME: abort if target kernel has vDSO disabled (?)
FIXME: restore pages, vDSO is writable after all.

---

 arch/x86/vdso/vdso32-setup.c |    6 ++
 include/linux/cr.h           |   11 +++++
 include/linux/mm.h           |    5 +-
 kernel/cr/cr-mm.c            |   87 +++++++++++++++++++++++++++++++++++++++++++
 mm/mmap.c                    |    3 +
 5 files changed, 110 insertions(+), 2 deletions(-)

arch/x86/vdso/vdso32-setup.c int arch_setup_additional_pages(struct linux_binprm *bprm, unsigned long start, · line 334

Quoted 7 lines
arch/x86/vdso/vdso32-setup.c +4 -0
@@ -328,6 +328,10 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, unsigned long start,
 
 	map_compat_vdso(compat);
 
+	if (start) {
+		addr = start;
+		goto map;
+	}

Hmm, is there any safety to be gained by using

	arch_get_unmapped_area(NULL, start, PAGE_SIZE, 0, 0);

so as to make sure there is a free page?

arch/x86/vdso/vdso32-setup.c int arch_setup_additional_pages(struct linux_binprm *bprm, unsigned long start, · line 347

Quoted 12 lines
arch/x86/vdso/vdso32-setup.c +1 -1
 	if (compat)
 		addr = VDSO_HIGH_BASE;
 	else {
@@ -337,7 +341,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, unsigned long start,
 			goto up_fail;
 		}
 	}
-
+map:
 	if (compat_uses_vma || !compat) {
 		/*
 		 * MAYWRITE to allow gdb to COW and set breakpoints

thanks,
-serge