Skip to contentSkip to conversation

Add mm->task_size and fix powerpc vdso]

PATCH In review Benjamin Herrenschmidt 3 participants 4 messages Feb 28, 2006

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

PATCH 1/1 Add mm->task_size and fix powerpc vdso]

Forgot this list on the CC ... Comments welcome, the idea is to finally track if an mm is 32 or 64 bits (knowing that I have an urgent need to get that fixed in 2.6.16 due to a problem with the powerpc vdso).

Please, arch maintainer, comment if the approach I use for setting mm->task_size is valid for you.

Ben.

-------- Forwarded Message --------
From: Benjamin Herrenschmidt <[email protected]>
To: Andrew Morton <[email protected]>
Cc: [email protected], [email protected], [email protected], [email protected], David S. Miller <[email protected]>
Subject: [PATCH] Add mm->task_size and fix powerpc vdso
Date: Tue, 28 Feb 2006 17:27:20 +1100

This patch adds mm->task_size to keep track of the task size of a given mm and uses that to fix the powerpc vdso so that it uses the mm task size to decide what pages to fault in instead of the current thread flags (which broke when ptracing).

arch/powerpc/kernel/vdso.c +2 -2
Index: linux-work/arch/powerpc/kernel/vdso.c
===================================================================
@@ -182,8 +182,8 @@ static struct page * vdso_vma_nopage(str
 	unsigned long offset = address - vma->vm_start;
 	struct page *pg;
 #ifdef CONFIG_PPC64
-	void *vbase = test_thread_flag(TIF_32BIT) ?
-		vdso32_kbase : vdso64_kbase;
+	void *vbase = (vma->vm_mm->task_size > TASK_SIZE_USER32) ?
+		vdso64_kbase : vdso32_kbase;
 #else
 	void *vbase = vdso32_kbase;
 #endif
fs/exec.c +6 -0
Index: linux-work/fs/exec.c
===================================================================
@@ -885,6 +885,12 @@ int flush_old_exec(struct linux_binprm *
 	current->flags &= ~PF_RANDOMIZE;
 	flush_thread();
 
+	/* Set the new mm task size. We have to do that late because it may
+	 * depend on TIF_32BIT which is only updated in flush_thread() on
+	 * some architectures like powerpc
+	 */
+	current->mm->task_size = TASK_SIZE;
+
 	if (bprm->e_uid != current->euid || bprm->e_gid != current->egid || 
 	    file_permission(bprm->file, MAY_READ) ||
 	    (bprm->interp_flags & BINPRM_FLAGS_ENFORCE_NONDUMP)) {
include/linux/sched.h +1 -0
Index: linux-work/include/linux/sched.h
===================================================================
@@ -299,6 +299,7 @@ struct mm_struct {
 				unsigned long pgoff, unsigned long flags);
 	void (*unmap_area) (struct mm_struct *mm, unsigned long addr);
         unsigned long mmap_base;		/* base of mmap area */
+	unsigned long task_size;		/* size of task vm space */
         unsigned long cached_hole_size;         /* if non-zero, the largest hole below free_area_cache */
 	unsigned long free_area_cache;		/* first hole of size cached_hole_size or larger */
 	pgd_t * pgd;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 3 lines · Benjamin Herrenschmidt

Forgot this list on the CC ... Comments welcome, the idea is to finally track if an mm is 32 or 64 bits (knowing that I have an urgent need to get that fixed in 2.6.16 due to a problem with the powerpc vdso).

Is it possible to end up with a 32-bit and a 64-bit process sharing an mm_struct? I assume not as I imagine this is set up by execve() which'll destroy any CLONE_VM sharing.

David

#2 lore raw
Quoted 9 lines · David Howells
Quoted 3 lines · Benjamin Herrenschmidt

Forgot this list on the CC ... Comments welcome, the idea is to finally track if an mm is 32 or 64 bits (knowing that I have an urgent need to get that fixed in 2.6.16 due to a problem with the powerpc vdso).

Is it possible to end up with a 32-bit and a 64-bit process sharing an mm_struct? I assume not as I imagine this is set up by execve() which'll destroy any CLONE_VM sharing.

Well, if it's possible, I don't see how it would be possible for those to have a vDSO at all ... But I don't think it's possible with any current code path.

Ben.

#3 lore raw
In reply to David Howells
Quoted 3 lines · David Howells

Is it possible to end up with a 32-bit and a 64-bit process sharing an mm_struct? I assume not as I imagine this is set up by execve() which'll destroy any CLONE_VM sharing.

No... the only way to switch between 32-bit and 64-bit is via exec, which creates a new mm.

Paul.