Skip to content

Commit

Permalink
um: Set __HAVE_ARCH_GATE_AREA for i386
Browse files Browse the repository at this point in the history
When UML is unable to reuse the host's vDSO FIXADDR_USER_START is zero.
To handle this special case correclty we have to implement custom gate
area helper methods.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Richard Weinberger authored and Linus Torvalds committed Jul 26, 2011
1 parent b743ac5 commit 548f0a4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion arch/um/sys-i386/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

obj-y = bug.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \
ptrace_user.o setjmp.o signal.o stub.o stub_segv.o syscalls.o sysrq.o \
sys_call_table.o tls.o atomic64_cx8_32.o
sys_call_table.o tls.o atomic64_cx8_32.o mem.o

obj-$(CONFIG_BINFMT_ELF) += elfcore.o

Expand Down
2 changes: 2 additions & 0 deletions arch/um/sys-i386/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ extern unsigned long __kernel_vsyscall;
#define FIXADDR_USER_START VSYSCALL_BASE
#define FIXADDR_USER_END VSYSCALL_END

#define __HAVE_ARCH_GATE_AREA 1

/*
* Architecture-neutral AT_ values in 0-17, leave some room
* for more of them, start the x86-specific ones at 32.
Expand Down
62 changes: 62 additions & 0 deletions arch/um/sys-i386/mem.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/

#include <linux/mm.h>
#include <asm/page.h>
#include <asm/mman.h>

static struct vm_area_struct gate_vma;

static int __init gate_vma_init(void)
{
if (!FIXADDR_USER_START)
return 0;

gate_vma.vm_mm = NULL;
gate_vma.vm_start = FIXADDR_USER_START;
gate_vma.vm_end = FIXADDR_USER_END;
gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
gate_vma.vm_page_prot = __P101;

/*
* Make sure the vDSO gets into every core dump.
* Dumping its contents makes post-mortem fully interpretable later
* without matching up the same kernel and hardware config to see
* what PC values meant.
*/
gate_vma.vm_flags |= VM_ALWAYSDUMP;

return 0;
}
__initcall(gate_vma_init);

struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
{
return FIXADDR_USER_START ? &gate_vma : NULL;
}

int in_gate_area_no_mm(unsigned long addr)
{
if (!FIXADDR_USER_START)
return 0;

if ((addr >= FIXADDR_USER_START) && (addr < FIXADDR_USER_END))
return 1;

return 0;
}

int in_gate_area(struct mm_struct *mm, unsigned long addr)
{
struct vm_area_struct *vma = get_gate_vma(mm);

if (!vma)
return 0;

return (addr >= vma->vm_start) && (addr < vma->vm_end);
}

0 comments on commit 548f0a4

Please sign in to comment.