Skip to content

Commit

Permalink
um: embed ->stub_pages[] into mmu_context
Browse files Browse the repository at this point in the history
seriously, kmalloc() for two-element array of pointers?

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Mar 21, 2012
1 parent 104bb37 commit ea6fb41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion arch/um/include/asm/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
typedef struct mm_context {
struct mm_id id;
struct uml_arch_mm_context arch;
struct page **stub_pages;
struct page *stub_pages[2];
} mm_context_t;

extern void __switch_mm(struct mm_id * mm_idp);
Expand Down
23 changes: 5 additions & 18 deletions arch/um/kernel/skas/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
goto out_free;
}

to_mm->stub_pages = NULL;

return 0;

out_free:
Expand All @@ -120,29 +118,20 @@ void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
if (ret)
goto out;

pages = kmalloc(2 * sizeof(struct page *), GFP_KERNEL);
if (pages == NULL) {
printk(KERN_ERR "arch_dup_mmap failed to allocate 2 page "
"pointers\n");
goto out;
}

pages[0] = virt_to_page(&__syscall_stub_start);
pages[1] = virt_to_page(mm->context.id.stack);
mm->context.stub_pages = pages;
mm->context.stub_pages[0] = virt_to_page(&__syscall_stub_start);
mm->context.stub_pages[1] = virt_to_page(mm->context.id.stack);

/* dup_mmap already holds mmap_sem */
err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
VM_READ | VM_MAYREAD | VM_EXEC |
VM_MAYEXEC | VM_DONTCOPY, pages);
VM_MAYEXEC | VM_DONTCOPY,
mm->context.stub_pages);
if (err) {
printk(KERN_ERR "install_special_mapping returned %d\n", err);
goto out_free;
goto out;
}
return;

out_free:
kfree(pages);
out:
force_sigsegv(SIGSEGV, current);
}
Expand All @@ -151,8 +140,6 @@ void arch_exit_mmap(struct mm_struct *mm)
{
pte_t *pte;

if (mm->context.stub_pages != NULL)
kfree(mm->context.stub_pages);
pte = virt_to_pte(mm, STUB_CODE);
if (pte != NULL)
pte_clear(mm, STUB_CODE, pte);
Expand Down

0 comments on commit ea6fb41

Please sign in to comment.