1. 23 10月, 2008 7 次提交
  2. 25 7月, 2008 2 次提交
  3. 24 7月, 2008 1 次提交
    • J
      UML - Fix boot crash · 7c1fed03
      Jeff Dike 提交于
      My copying of linux/init.h didn't go far enough.  The definition of
      __used singled out gcc minor version 3, but didn't care what the major
      version was.  This broke when unit-at-a-time was added and gcc started
      throwing out initcalls.
      
      This results in an early boot crash when ptrace tries to initialize a
      process with an empty, uninitialized register set.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7c1fed03
  4. 07 6月, 2008 1 次提交
    • T
      uml: deal with inaccessible address space start · 40fb16a3
      Tom Spink 提交于
      This patch makes os_get_task_size locate the bottom of the address space,
      as well as the top.  This is for systems which put a lower limit on mmap
      addresses.  It works by manually scanning pages from zero onwards until a
      valid page is found.
      
      Because the bottom of the address space may not be zero, it's not
      sufficient to assume the top of the address space is the size of the
      address space.  The size is the difference between the top address and
      bottom address.
      
      [jdike@addtoit.com: changed the name to reflect that this function is
      supposed to return the top of the process address space, not its size and
      changed the return value to reflect that.  Also some minor formatting
      changes]
      Signed-off-by: NTom Spink <tspink@gmail.com>
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      40fb16a3
  5. 13 5月, 2008 7 次提交
  6. 09 5月, 2008 1 次提交
  7. 28 4月, 2008 2 次提交
  8. 24 2月, 2008 1 次提交
    • J
      uml: fix FP register corruption · 2f56debd
      Jeff Dike 提交于
      Commit ee3d9bd4 ("uml: simplify SIGSEGV
      handling"), while greatly simplifying the kernel SIGSEGV handler that
      runs in the process address space, introduced a bug which corrupts FP
      state in the process.
      
      Previously, the SIGSEGV handler called the sigreturn system call by hand - it
      couldn't return through the restorer provided to it because that could try to
      call the libc restorer which likely wouldn't exist in the process address
      space.  So, it blocked off some signals, including SIGUSR1, on entry to the
      SIGSEGV handler, queued a SIGUSR1 to itself, and invoked sigreturn.  The
      SIGUSR1 was delivered, and was visible to the UML kernel after sigreturn
      finished.
      
      The commit eliminated the signal masking and the call to sigreturn.  The
      handler simply hits itself with a SIGTRAP to let the UML kernel know that it
      is finished.  UML then restores the process registers, which effectively
      longjmps the process out of the signal handler, skipping sigreturn's restoring
      of register state and the signal mask.
      
      The bug is that the host apparently sets used_fp to 0 when it saves the
      process FP state in the sigcontext on the process signal stack.  Thus, when
      the process is longjmped out of the handler, its FP state is corrupt because
      it wasn't saved on the context switch to the UML kernel.
      
      This manifested itself as sleep hanging.  For some reason, sleep uses floating
      point in order to calculate the sleep interval.  When a page fault corrupts
      its FP state, it is faked into essentially sleeping forever.
      
      This patch saves the FP state before entering the SIGSEGV handler and restores
      it afterwards.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2f56debd
  9. 09 2月, 2008 3 次提交
    • J
      uml: fix mm_context memory leak · ac2a6599
      Jeff Dike 提交于
      [ Spotted by Miklos ]
      
      Fix a memory leak in init_new_context.  The struct page ** buffer allocated
      for install_special_mapping was never recorded, and thus leaked when the
      mm_struct was freed.  Fix it by saving the pointer in mm_context_t and freeing
      it in arch_exit_mmap.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Cc: Miklos Szeredi <miklos@szeredi.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ac2a6599
    • J
      uml: style fixes in arch/um/os-Linux · 5134d8fe
      Jeff Dike 提交于
      Style changes under arch/um/os-Linux:
      	include trimming
      	CodingStyle fixes
      	some printks needed severity indicators
      
      make_tempfile turns out not to be used outside of mem.c, so it is now static.
      Its declaration in tempfile.h is no longer needed, and tempfile.h itself is no
      longer needed.
      
      create_tmp_file was also made static.
      
      checkpatch moans about an EXPORT_SYMBOL in user_syms.c which is part of a
      macro definition - this is copying a bit of kernel infrastructure into the
      libc side of UML because the kernel headers can't be included there.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5134d8fe
    • J
      uml: runtime host VMSPLIT detection · 536788fe
      Jeff Dike 提交于
      Calculate TASK_SIZE at run-time by figuring out the host's VMSPLIT - this is
      needed on i386 if UML is to run on hosts with varying VMSPLITs without
      recompilation.
      
      TASK_SIZE is now defined in terms of a variable, task_size.  This gets rid of
      an include of pgtable.h from processor.h, which can cause include loops.
      
      On i386, task_size is calculated early in boot by probing the address space in
      a binary search to figure out where the boundary between usable and non-usable
      memory is.  This tries to make sure that a page that is considered to be in
      userspace is, or can be made, read-write.  I'm concerned about a system-global
      VDSO page in kernel memory being hit and considered to be a userspace page.
      
      On x86_64, task_size is just the old value of CONFIG_TOP_ADDR.
      
      A bunch of config variable are gone now.  CONFIG_TOP_ADDR is directly replaced
      by TASK_SIZE.  NEST_LEVEL is gone since the relocation of the stubs makes it
      irrelevant.  All the HOST_VMSPLIT stuff is gone.  All references to these in
      arch/um/Makefile are also gone.
      
      I noticed and fixed a missing extern in os.h when adding os_get_task_size.
      
      Note: This has been revised to fix the 32-bit UML on 64-bit host bug that
      Miklos ran into.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Cc: Miklos Szeredi <miklos@szeredi.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      536788fe
  10. 06 2月, 2008 15 次提交
    • J
      uml: redo the calculation of NR_syscalls · f87ea91d
      Jeff Dike 提交于
      Redo the calculation of NR_syscalls since that disappeared from i386 and
      use a similar mechanism on x86_64.
      
      We now figure out the size of the system call table in arch code and stick
      that in syscall_table_size.  arch/um/kernel/skas/syscall.c defines
      NR_syscalls in terms of that since its the only thing that needs to know
      how many system calls there are.
      
      The old mechananism that was used on x86_64 is gone.
      
      arch/um/include/sysdep-i386/syscalls.h got some formatting since I was
      looking at it.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Cc: WANG Cong <xiyou.wangcong@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f87ea91d
    • J
      uml: remove unused fields from mm_context · d449c503
      Jeff Dike 提交于
      The 3-level page table fixes forgot to remove a couple now-unused fields from
      struct mm_context.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d449c503
    • J
      uml: style fixes in arch/um/sys-x86_64 · 95906b24
      Jeff Dike 提交于
      Style fixes in arch/um/sys-x86_64:
      	updated copyrights
      	CodingStyle fixes
      	added severities to printks which needed them
      
      A bunch of functions in sys-*/ptrace_user.c turn out to be unused, so they and
      their declarations are gone.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      95906b24
    • J
      uml: SMP locking commentary · 80e39311
      Jeff Dike 提交于
      Add some more commentary about various pieces of global data not needing
      locking.
      
      Also got rid of unmap_physmem since that is no longer used.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      80e39311
    • J
      uml: remove init_irq_signals · 3a24ebf0
      Jeff Dike 提交于
      init_irq_signals doesn't need to be called from the context of a new process.
      It initializes handlers, which are useless in process context.  With that call
      gone, init_irq_signals has only one caller, so it can be inlined into
      init_new_thread_signals.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3a24ebf0
    • J
      uml: move sig_handler_common_skas · 75ada8ff
      Jeff Dike 提交于
      This patch moves sig_handler_common_skas from
      arch/um/os-Linux/skas/trap.c to its only caller in
      arch/um/os-Linux/signal.c.  trap.c is now empty, so it can be removed.
      
      This is code movement only - the significant cleanup needed here is
      done in the next patch.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      75ada8ff
    • J
      uml: get rid of syscall counters · a9b71b6c
      Jeff Dike 提交于
      Get rid of some syscall counters which haven't been useful in ages.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a9b71b6c
    • J
      uml: tidy helper code · 1aa351a3
      Jeff Dike 提交于
      Style fixes to arch/um/os/helper.c and tidying up the breakpoint fix a
      bit.
      
      helper.c gets all the usual style fixes -
      	 updated copyright
      	 all printks get severities
      
      Also -
      	 errval changes to err in helper_child
      	 fixed an obsolete comment
      	 run_helper was killing a child process which is guaranteed to
      be dead or dying anyway
      
      Removed the nohang and pname arguments from helper_wait and fixed the
      declaration and callers.  nohang was used only in the slirp driver and
      I don't think it was needed.  I think pname was a bit of overkill in
      putting out an error message when something goes wrong.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1aa351a3
    • J
      uml: install panic notifier earlier · 0983a88b
      Jeff Dike 提交于
      It turns out that if there's a panic early enough, UML will just sit there in
      the LED-blinking loop because the panic notifier hadn't been installed yet.
      
      This patch installs it earlier.
      
      It also fixes the problem which exposed the hang, namely that if you give UML
      a zero-sized initrd, it will ask alloc_bootmem for zero bytes, and that will
      cause the panic.
      
      While I was in initrd.c, I gave it a style makeover.
      
      Prompted by checkpatch, I moved a couple extern declarations of uml_exitcode
      to kern_util.h.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0983a88b
    • J
      uml: eliminate setjmp_wrapper · 8efa3c9d
      Jeff Dike 提交于
      setjmp_wrapper existed to provide setjmp to kernel code when UML used libc's
      setjmp and longjmp.  Now that UML has its own implementation, this isn't
      needed and kernel code can invoke setjmp directly.
      
      do_buffer_op is massively cleaned up since it is no longer a callback from
      setjmp_wrapper and given a va_list from which it must extract its arguments.
      
      The actual setjmp is moved from buffer_op to do_op_one_page because the copy
      operation is inside an atomic section (kmap_atomic to kunmap_atomic) and it
      shouldn't be longjmp-ed out of.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8efa3c9d
    • J
      uml: style fixes in file.c · 1adfd609
      Jeff Dike 提交于
      arch/um/os-Linux/file.c needed some style work -
      	updated the copyright
      	cleaned up the includes
      	CodingStyle fixes
      	added some missing CATCH_EINTRs
      	os_set_owner was unused, so it is gone
      	all printks now have severities
      	fcntl(F_GETFL) was being called without checking the return
      	removed an obsolete comment
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1adfd609
    • J
      uml: miscellaneous code cleanups · bf8fde78
      Jeff Dike 提交于
      Code tidying -
      	the pid field of struct irq_fd isn't used, so it is removed
           	os_set_fd_async needed to read flags before changing them, it
      doesn't need a pid passed in because it can call getpid itself, and a
      block of unused code needed deleting
      	os_get_exec_close was unused, so it is removed
      	ptrace_child called _exit for historical reasons which are no
      longer valid, so just calls exit instead
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      bf8fde78
    • J
      uml: cover stubs with a VMA · 3963333f
      Jeff Dike 提交于
      Give the stubs a VMA.  This allows the removal of a truly nasty kludge to make
      sure that mm->nr_ptes was correct in exit_mmap.  The underlying problem was
      always that the stubs, which have ptes, and thus allocated a page table,
      weren't covered by a VMA.
      
      This patch fixes that by using install_special_mapping in arch_dup_mmap and
      activate_context to create the VMA.  The stubs have to be moved, since
      shift_arg_pages seems to assume that the stack is the only VMA present at that
      point during exec, and uses vma_adjust to fiddle its VMA.  However, that
      extends the stub VMA by the amount removed from the stack VMA.
      
      To avoid this problem, the stubs were moved to a different fixed location at
      the start of the address space.
      
      The init_stub_pte calls were moved from init_new_context to arch_dup_mmap
      because I was occasionally seeing arch_dup_mmap not being called, causing
      exit_mmap to die.  Rather than figure out what was really happening, I decided
      it was cleaner to just move the calls so that there's no doubt that both the
      pte and VMA creation happen, no matter what.  arch_exit_mmap is used to clear
      the stub ptes at exit time.
      
      The STUB_* constants in as-layout.h no longer depend on UM_TASK_SIZE, that
      that definition is removed, along with the comments complaining about gcc.
      
      Because the stubs are no longer at the top of the address space, some care is
      needed while flushing TLBs.  update_pte_range checks for addresses in the stub
      range and skips them.  flush_thread now issues two unmaps, one for the range
      before STUB_START and one for the range after STUB_END.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3963333f
    • J
      uml: clean up TASK_SIZE usage · 42a2b54c
      Jeff Dike 提交于
      Clean up the calculation and use of the usable address space size on the host.
      
      task_size is gone, replaced with TASK_SIZE, which is calculated from
      CONFIG_TOP_ADDR.  get_kmem_end and set_task_sizes_skas are also gone.
      
      host_task_size, which refers to the entire address space usable by the UML
      kernel and which may be larger than the address space usable by a UML process,
      since that has to end on a pgdir boundary, is replaced by CONFIG_TOP_ADDR.
      
      STACK_TOP is now TASK_SIZE minus the two stub pages.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      42a2b54c
    • J
      uml: kill processes instead of panicing kernel · 3e6f2ac4
      Jeff Dike 提交于
      UML was panicing in the case of failures of libc calls which shouldn't happen.
       This is an overreaction since a failure from libc doesn't normally mean that
      kernel data structures are in an unknown state.  Instead, the current process
      should just be killed if there is no way to recover.
      
      The case that prompted this was a failure of PTRACE_SETREGS restoring the same
      state that was read by PTRACE_GETREGS.  It appears that when a process tries
      to load a bogus value into a segment register, it segfaults (as expected) and
      the value is actually loaded and is seen by PTRACE_GETREGS (not expected).
      
      This case is fixed by forcing a fatal SIGSEGV on the process so that it
      immediately dies.  fatal_sigsegv was added for this purpose.  It was declared
      as noreturn, so in order to pursuade gcc that it actually does not return, I
      added a call to os_dump_core (and declared it noreturn) so that I get a core
      file if somehow the process survives.
      
      All other calls in arch/um/os-Linux/skas/process.c got the same treatment,
      with failures causing the process to die instead of a kernel panic, with some
      exceptions.
      
      userspace_tramp exits with status 1 if anything goes wrong there.  That will
      cause start_userspace to return an error.  copy_context_skas0 and
      map_stub_pages also now return errors instead of panicing.  Callers of thes
      functions were changed to check for errors and do something appropriate.
      Usually that's to return an error to their callers.
      check_skas3_ptrace_faultinfo just exits since that's too early to do anything
      else.
      
      save_registers, restore_registers, and init_registers now return status
      instead of panicing on failure, with their callers doing something
      appropriate.
      
      There were also duplicate declarations of save_registers and restore_registers
      in os.h - these are gone.
      
      I noticed and fixed up some whitespace damage.
      Signed-off-by: NJeff Dike <jdike@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3e6f2ac4