]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
.25 uml patches
authorGreg Kroah-Hartman <gregkh@suse.de>
Sat, 16 Aug 2008 22:32:10 +0000 (15:32 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 16 Aug 2008 22:32:10 +0000 (15:32 -0700)
15 files changed:
queue-2.6.25/series
queue-2.6.25/uml-deal-with-host-time-going-backwards.patch [new file with mode: 0644]
queue-2.6.25/uml-deal-with-inaccessible-address-space-start.patch [new file with mode: 0644]
queue-2.6.25/uml-fix-bad-ntp-interaction-with-clock.patch [new file with mode: 0644]
queue-2.6.25/uml-fix-boot-crash.patch [new file with mode: 0644]
queue-2.6.25/uml-fix-build-when-slob-is-enabled.patch [new file with mode: 0644]
queue-2.6.25/uml-fix-gcc-ices-and-unresolved-externs.patch [new file with mode: 0644]
queue-2.6.25/uml-memcpy-export-needs-to-follow-host-declaration.patch [new file with mode: 0644]
queue-2.6.25/uml-missed-kmalloc-in-pcap_user.c.patch [new file with mode: 0644]
queue-2.6.25/uml-missing-export-of-csum_partial-on-uml-amd64.patch [new file with mode: 0644]
queue-2.6.25/uml-path_max-needs-limits.h.patch [new file with mode: 0644]
queue-2.6.25/uml-physical-memory-shouldn-t-include-initial-stack.patch [new file with mode: 0644]
queue-2.6.25/uml-stub-needs-to-tolerate-sigwinch.patch [new file with mode: 0644]
queue-2.6.25/uml-track-and-make-up-lost-ticks.patch [new file with mode: 0644]
queue-2.6.25/uml-work-around-broken-host-ptrace_sysemu.patch [new file with mode: 0644]

index 59bdc24bb4de6f128c3a2f06b42c1a83d7d67533..b6b5f3996df5ad7c0346ac6b38f69ee15dd3e4a0 100644 (file)
@@ -24,3 +24,17 @@ random32-seeding-improvement.patch
 ipv6-fix-ip6_xmit-to-send-fragments-if-ipfragok-is-true.patch
 sparc64-futex_op_andn-fix.patch
 sparc64-do-not-clobber-g7-in-setcontext-trap.patch
+uml-fix-build-when-slob-is-enabled.patch
+uml-fix-bad-ntp-interaction-with-clock.patch
+uml-physical-memory-shouldn-t-include-initial-stack.patch
+uml-track-and-make-up-lost-ticks.patch
+uml-missed-kmalloc-in-pcap_user.c.patch
+uml-deal-with-host-time-going-backwards.patch
+uml-deal-with-inaccessible-address-space-start.patch
+uml-missing-export-of-csum_partial-on-uml-amd64.patch
+uml-memcpy-export-needs-to-follow-host-declaration.patch
+uml-stub-needs-to-tolerate-sigwinch.patch
+uml-work-around-broken-host-ptrace_sysemu.patch
+uml-fix-gcc-ices-and-unresolved-externs.patch
+uml-fix-boot-crash.patch
+uml-path_max-needs-limits.h.patch
diff --git a/queue-2.6.25/uml-deal-with-host-time-going-backwards.patch b/queue-2.6.25/uml-deal-with-host-time-going-backwards.patch
new file mode 100644 (file)
index 0000000..6bc2e12
--- /dev/null
@@ -0,0 +1,51 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:14:23 2008
+From: Jeff Dike <jdike@addtoit.com>
+Date: Tue, 5 Aug 2008 16:14:06 -0400
+Subject: uml: deal with host time going backwards
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201406.GA11786@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Jeff Dike <jdike@addtoit.com>
+
+commit 06e1e4ffbd1932e288839b3140cda6b8141eb684 upstream
+
+Protection against the host's time going backwards (eg, ntp activity on
+the host) by keeping track of the time at the last tick and if it's
+greater than the current time, keep time stopped until the host catches
+up.
+
+Cc: Nix <nix@esperi.org.uk>
+Signed-off-by: Jeff Dike <jdike@linux.intel.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/os-Linux/time.c |    7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/arch/um/os-Linux/time.c
++++ b/arch/um/os-Linux/time.c
+@@ -106,6 +106,10 @@ static void deliver_alarm(void)
+       unsigned long long this_tick = os_nsecs();
+       int one_tick = UM_NSEC_PER_SEC / UM_HZ;
++      /* Protection against the host's time going backwards */
++      if ((last_tick != 0) && (this_tick < last_tick))
++              this_tick = last_tick;
++
+       if (last_tick == 0)
+               last_tick = this_tick - one_tick;
+@@ -148,6 +152,9 @@ static int after_sleep_interval(struct t
+               start_usecs = usec;
+       start_usecs -= skew / UM_NSEC_PER_USEC;
++      if (start_usecs < 0)
++              start_usecs = 0;
++
+       tv = ((struct timeval) { .tv_sec  = start_usecs / UM_USEC_PER_SEC,
+                                .tv_usec = start_usecs % UM_USEC_PER_SEC });
+       interval = ((struct itimerval) { { 0, usec }, tv });
diff --git a/queue-2.6.25/uml-deal-with-inaccessible-address-space-start.patch b/queue-2.6.25/uml-deal-with-inaccessible-address-space-start.patch
new file mode 100644 (file)
index 0000000..214a1e2
--- /dev/null
@@ -0,0 +1,143 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:14:42 2008
+From: Tom Spink <tspink@gmail.com>
+Date: Tue, 5 Aug 2008 16:14:06 -0400
+Subject: uml: deal with inaccessible address space start
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201406.GA11788@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Tom Spink <tspink@gmail.com>
+
+commit 40fb16a360d9c6459afee91dc793c1e3374feb94 upstream
+
+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: Tom Spink <tspink@gmail.com>
+Signed-off-by: Jeff Dike <jdike@linux.intel.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/include/os.h                    |    2 -
+ arch/um/kernel/um_arch.c                |    2 -
+ arch/um/os-Linux/sys-i386/task_size.c   |   38 ++++++++++++++++++++++++--------
+ arch/um/os-Linux/sys-x86_64/task_size.c |    2 -
+ 4 files changed, 32 insertions(+), 12 deletions(-)
+
+--- a/arch/um/include/os.h
++++ b/arch/um/include/os.h
+@@ -298,6 +298,6 @@ extern int os_arch_prctl(int pid, int co
+ extern int get_pty(void);
+ /* sys-$ARCH/task_size.c */
+-extern unsigned long os_get_task_size(void);
++extern unsigned long os_get_top_address(void);
+ #endif
+--- a/arch/um/kernel/um_arch.c
++++ b/arch/um/kernel/um_arch.c
+@@ -273,7 +273,7 @@ int __init linux_main(int argc, char **a
+       if (have_root == 0)
+               add_arg(DEFAULT_COMMAND_LINE);
+-      host_task_size = os_get_task_size();
++      host_task_size = os_get_top_address();
+       /*
+        * TASK_SIZE needs to be PGDIR_SIZE aligned or else exit_mmap craps
+        * out
+--- a/arch/um/os-Linux/sys-i386/task_size.c
++++ b/arch/um/os-Linux/sys-i386/task_size.c
+@@ -63,7 +63,7 @@ static int page_ok(unsigned long page)
+       return ok;
+ }
+-unsigned long os_get_task_size(void)
++unsigned long os_get_top_address(void)
+ {
+       struct sigaction sa, old;
+       unsigned long bottom = 0;
+@@ -76,9 +76,9 @@ unsigned long os_get_task_size(void)
+        * hosts, but shouldn't hurt otherwise.
+        */
+       unsigned long top = 0xffffd000 >> UM_KERN_PAGE_SHIFT;
+-      unsigned long test;
++      unsigned long test, original;
+-      printf("Locating the top of the address space ... ");
++      printf("Locating the bottom of the address space ... ");
+       fflush(stdout);
+       /*
+@@ -88,14 +88,32 @@ unsigned long os_get_task_size(void)
+       sa.sa_handler = segfault;
+       sigemptyset(&sa.sa_mask);
+       sa.sa_flags = SA_NODEFER;
+-      sigaction(SIGSEGV, &sa, &old);
++      if (sigaction(SIGSEGV, &sa, &old)) {
++              perror("os_get_top_address");
++              exit(1);
++      }
+-      if (!page_ok(bottom)) {
+-              fprintf(stderr, "Address 0x%x no good?\n",
+-                      bottom << UM_KERN_PAGE_SHIFT);
++      /* Manually scan the address space, bottom-up, until we find
++       * the first valid page (or run out of them).
++       */
++      for (bottom = 0; bottom < top; bottom++) {
++              if (page_ok(bottom))
++                      break;
++      }
++
++      /* If we've got this far, we ran out of pages. */
++      if (bottom == top) {
++              fprintf(stderr, "Unable to determine bottom of address "
++                      "space.\n");
+               exit(1);
+       }
++      printf("0x%x\n", bottom << UM_KERN_PAGE_SHIFT);
++      printf("Locating the top of the address space ... ");
++      fflush(stdout);
++
++      original = bottom;
++
+       /* This could happen with a 4G/4G split */
+       if (page_ok(top))
+               goto out;
+@@ -110,8 +128,10 @@ unsigned long os_get_task_size(void)
+ out:
+       /* Restore the old SIGSEGV handling */
+-      sigaction(SIGSEGV, &old, NULL);
+-
++      if (sigaction(SIGSEGV, &old, NULL)) {
++              perror("os_get_top_address");
++              exit(1);
++      }
+       top <<= UM_KERN_PAGE_SHIFT;
+       printf("0x%x\n", top);
+       fflush(stdout);
+--- a/arch/um/os-Linux/sys-x86_64/task_size.c
++++ b/arch/um/os-Linux/sys-x86_64/task_size.c
+@@ -1,4 +1,4 @@
+-unsigned long os_get_task_size(unsigned long shift)
++unsigned long os_get_top_address(unsigned long shift)
+ {
+       /* The old value of CONFIG_TOP_ADDR */
+       return 0x7fc0000000;
diff --git a/queue-2.6.25/uml-fix-bad-ntp-interaction-with-clock.patch b/queue-2.6.25/uml-fix-bad-ntp-interaction-with-clock.patch
new file mode 100644 (file)
index 0000000..5f9399a
--- /dev/null
@@ -0,0 +1,52 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:14:46 2008
+From: Jeff Dike <jdike@addtoit.com>
+Date: Tue, 5 Aug 2008 16:14:03 -0400
+Subject: uml: fix bad NTP interaction with clock
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201403.GA11734@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Jeff Dike <jdike@addtoit.com>
+
+commit cfd28f6695d0fc047478480791a21bdd4967f98e upstream
+
+UML's supposed nanosecond clock interacts badly with NTP when NTP
+decides that the clock has drifted ahead and needs to be slowed down.
+Slowing down the clock is done by decrementing the cycle-to-nanosecond
+multiplier, which is 1.  Decrementing that gives you 0 and time is
+stopped.
+
+This is fixed by switching to a microsecond clock, with a multiplier
+of 1000.
+
+Signed-off-by: Jeff Dike <jdike@linux.intel.com>
+Cc: WANG Cong <xiyou.wangcong@gmail.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/kernel/time.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/arch/um/kernel/time.c
++++ b/arch/um/kernel/time.c
+@@ -74,7 +74,7 @@ static irqreturn_t um_timer(int irq, voi
+ static cycle_t itimer_read(void)
+ {
+-      return os_nsecs();
++      return os_nsecs() / 1000;
+ }
+ static struct clocksource itimer_clocksource = {
+@@ -82,7 +82,7 @@ static struct clocksource itimer_clockso
+       .rating         = 300,
+       .read           = itimer_read,
+       .mask           = CLOCKSOURCE_MASK(64),
+-      .mult           = 1,
++      .mult           = 1000,
+       .shift          = 0,
+       .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
+ };
diff --git a/queue-2.6.25/uml-fix-boot-crash.patch b/queue-2.6.25/uml-fix-boot-crash.patch
new file mode 100644 (file)
index 0000000..77b4bea
--- /dev/null
@@ -0,0 +1,53 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:14:58 2008
+From: Jeff Dike <jdike@addtoit.com>
+Date: Tue, 5 Aug 2008 16:14:10 -0400
+Subject: uml: Fix boot crash
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201410.GA11796@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Jeff Dike <jdike@addtoit.com>
+
+commit 7c1fed03b9fa32d4323d5caa6a9c7dcdd7eba767 upstream
+
+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: Jeff Dike <jdike@linux.intel.com>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/include/init.h |    8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+--- a/arch/um/include/init.h
++++ b/arch/um/include/init.h
+@@ -45,6 +45,8 @@ typedef void (*exitcall_t)(void);
+ # define __section(S) __attribute__ ((__section__(#S)))
+ #endif
++#if __GNUC__ == 3
++
+ #if __GNUC_MINOR__ >= 3
+ # define __used                       __attribute__((__used__))
+ #else
+@@ -52,6 +54,12 @@ typedef void (*exitcall_t)(void);
+ #endif
+ #else
++#if __GNUC__ == 4
++# define __used                       __attribute__((__used__))
++#endif
++#endif
++
++#else
+ #include <linux/compiler.h>
+ #endif
+ /* These are for everybody (although not all archs will actually
diff --git a/queue-2.6.25/uml-fix-build-when-slob-is-enabled.patch b/queue-2.6.25/uml-fix-build-when-slob-is-enabled.patch
new file mode 100644 (file)
index 0000000..12b8eaa
--- /dev/null
@@ -0,0 +1,283 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:14:54 2008
+From: Jeff Dike <jdike@addtoit.com>
+Date: Tue, 5 Aug 2008 16:14:03 -0400
+Subject: uml: fix build when SLOB is enabled
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201403.GA11778@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Jeff Dike <jdike@addtoit.com>
+
+commit 43f5b3085fdd27c4edf535d938b2cb0ccead4f75 upstream
+
+Reintroduce uml_kmalloc for the benefit of UML libc code.  The
+previous tactic of declaring __kmalloc so it could be called directly
+from the libc side of the house turned out to be getting too intimate
+with slab, and it doesn't work with slob.
+
+So, the uml_kmalloc wrapper is back.  It calls kmalloc or whatever
+that translates into, and libc code calls it.
+
+kfree is left alone since that still works, leaving a somewhat
+inconsistent API.
+
+Signed-off-by: Jeff Dike <jdike@linux.intel.com>
+Cc: WANG Cong <xiyou.wangcong@gmail.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/drivers/chan_user.c              |    1 +
+ arch/um/drivers/cow_sys.h                |    2 +-
+ arch/um/drivers/daemon_user.c            |    4 ++--
+ arch/um/drivers/fd.c                     |    2 +-
+ arch/um/drivers/mcast_user.c             |    3 ++-
+ arch/um/drivers/net_user.c               |    2 +-
+ arch/um/drivers/port_user.c              |    2 +-
+ arch/um/drivers/pty.c                    |    2 +-
+ arch/um/drivers/slip_user.c              |    2 +-
+ arch/um/drivers/tty.c                    |    2 +-
+ arch/um/drivers/xterm.c                  |    2 +-
+ arch/um/include/um_malloc.h              |    9 +++------
+ arch/um/kernel/mem.c                     |    5 +++++
+ arch/um/os-Linux/drivers/ethertap_user.c |    4 ++--
+ arch/um/os-Linux/helper.c                |    4 ++--
+ arch/um/os-Linux/main.c                  |    2 +-
+ arch/um/os-Linux/sigio.c                 |    4 ++--
+ 17 files changed, 28 insertions(+), 24 deletions(-)
+
+--- a/arch/um/drivers/chan_user.c
++++ b/arch/um/drivers/chan_user.c
+@@ -11,6 +11,7 @@
+ #include <termios.h>
+ #include <sys/ioctl.h>
+ #include "chan_user.h"
++#include "kern_constants.h"
+ #include "os.h"
+ #include "um_malloc.h"
+ #include "user.h"
+--- a/arch/um/drivers/cow_sys.h
++++ b/arch/um/drivers/cow_sys.h
+@@ -8,7 +8,7 @@
+ static inline void *cow_malloc(int size)
+ {
+-      return kmalloc(size, UM_GFP_KERNEL);
++      return uml_kmalloc(size, UM_GFP_KERNEL);
+ }
+ static inline void cow_free(void *ptr)
+--- a/arch/um/drivers/daemon_user.c
++++ b/arch/um/drivers/daemon_user.c
+@@ -34,7 +34,7 @@ static struct sockaddr_un *new_addr(void
+ {
+       struct sockaddr_un *sun;
+-      sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
++      sun = uml_kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
+       if (sun == NULL) {
+               printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un "
+                      "failed\n");
+@@ -83,7 +83,7 @@ static int connect_to_switch(struct daem
+               goto out_close;
+       }
+-      sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
++      sun = uml_kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
+       if (sun == NULL) {
+               printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un "
+                      "failed\n");
+--- a/arch/um/drivers/fd.c
++++ b/arch/um/drivers/fd.c
+@@ -40,7 +40,7 @@ static void *fd_init(char *str, int devi
+               return NULL;
+       }
+-      data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
++      data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
+       if (data == NULL)
+               return NULL;
+--- a/arch/um/drivers/mcast_user.c
++++ b/arch/um/drivers/mcast_user.c
+@@ -15,6 +15,7 @@
+ #include <unistd.h>
+ #include <errno.h>
+ #include <netinet/in.h>
++#include "kern_constants.h"
+ #include "mcast.h"
+ #include "net_user.h"
+ #include "um_malloc.h"
+@@ -24,7 +25,7 @@ static struct sockaddr_in *new_addr(char
+ {
+       struct sockaddr_in *sin;
+-      sin = kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL);
++      sin = uml_kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL);
+       if (sin == NULL) {
+               printk(UM_KERN_ERR "new_addr: allocation of sockaddr_in "
+                      "failed\n");
+--- a/arch/um/drivers/net_user.c
++++ b/arch/um/drivers/net_user.c
+@@ -222,7 +222,7 @@ static void change(char *dev, char *what
+               netmask[2], netmask[3]);
+       output_len = UM_KERN_PAGE_SIZE;
+-      output = kmalloc(output_len, UM_GFP_KERNEL);
++      output = uml_kmalloc(output_len, UM_GFP_KERNEL);
+       if (output == NULL)
+               printk(UM_KERN_ERR "change : failed to allocate output "
+                      "buffer\n");
+--- a/arch/um/drivers/port_user.c
++++ b/arch/um/drivers/port_user.c
+@@ -47,7 +47,7 @@ static void *port_init(char *str, int de
+       if (kern_data == NULL)
+               return NULL;
+-      data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
++      data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
+       if (data == NULL)
+               goto err;
+--- a/arch/um/drivers/pty.c
++++ b/arch/um/drivers/pty.c
+@@ -29,7 +29,7 @@ static void *pty_chan_init(char *str, in
+ {
+       struct pty_chan *data;
+-      data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
++      data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
+       if (data == NULL)
+               return NULL;
+--- a/arch/um/drivers/slip_user.c
++++ b/arch/um/drivers/slip_user.c
+@@ -96,7 +96,7 @@ static int slip_tramp(char **argv, int f
+       pid = err;
+       output_len = UM_KERN_PAGE_SIZE;
+-      output = kmalloc(output_len, UM_GFP_KERNEL);
++      output = uml_kmalloc(output_len, UM_GFP_KERNEL);
+       if (output == NULL) {
+               printk(UM_KERN_ERR "slip_tramp : failed to allocate output "
+                      "buffer\n");
+--- a/arch/um/drivers/tty.c
++++ b/arch/um/drivers/tty.c
+@@ -29,7 +29,7 @@ static void *tty_chan_init(char *str, in
+       }
+       str++;
+-      data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
++      data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
+       if (data == NULL)
+               return NULL;
+       *data = ((struct tty_chan) { .dev       = str,
+--- a/arch/um/drivers/xterm.c
++++ b/arch/um/drivers/xterm.c
+@@ -30,7 +30,7 @@ static void *xterm_init(char *str, int d
+ {
+       struct xterm_chan *data;
+-      data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
++      data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
+       if (data == NULL)
+               return NULL;
+       *data = ((struct xterm_chan) { .pid             = -1,
+--- a/arch/um/include/um_malloc.h
++++ b/arch/um/include/um_malloc.h
+@@ -8,15 +8,12 @@
+ #include "kern_constants.h"
+-extern void *__kmalloc(int size, int flags);
+-static inline void *kmalloc(int size, int flags)
+-{
+-      return __kmalloc(size, flags);
+-}
+-
++extern void *uml_kmalloc(int size, int flags);
+ extern void kfree(const void *ptr);
+ extern void *vmalloc(unsigned long size);
+ extern void vfree(void *ptr);
+ #endif /* __UM_MALLOC_H__ */
++
++
+--- a/arch/um/kernel/mem.c
++++ b/arch/um/kernel/mem.c
+@@ -375,3 +375,8 @@ pmd_t *pmd_alloc_one(struct mm_struct *m
+       return pmd;
+ }
+ #endif
++
++void *uml_kmalloc(int size, int flags)
++{
++      return kmalloc(size, flags);
++}
+--- a/arch/um/os-Linux/drivers/ethertap_user.c
++++ b/arch/um/os-Linux/drivers/ethertap_user.c
+@@ -52,7 +52,7 @@ static void etap_change(int op, unsigned
+               return;
+       }
+-      output = kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL);
++      output = uml_kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL);
+       if (output == NULL)
+               printk(UM_KERN_ERR "etap_change : Failed to allocate output "
+                      "buffer\n");
+@@ -165,7 +165,7 @@ static int etap_open(void *data)
+       err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0],
+                        control_fds[1], data_fds[0], data_fds[1]);
+       output_len = UM_KERN_PAGE_SIZE;
+-      output = kmalloc(output_len, UM_GFP_KERNEL);
++      output = uml_kmalloc(output_len, UM_GFP_KERNEL);
+       read_output(control_fds[0], output, output_len);
+       if (output == NULL)
+--- a/arch/um/os-Linux/helper.c
++++ b/arch/um/os-Linux/helper.c
+@@ -70,8 +70,8 @@ int run_helper(void (*pre_exec)(void *),
+       data.pre_data = pre_data;
+       data.argv = argv;
+       data.fd = fds[1];
+-      data.buf = __cant_sleep() ? kmalloc(PATH_MAX, UM_GFP_ATOMIC) :
+-                                      kmalloc(PATH_MAX, UM_GFP_KERNEL);
++      data.buf = __cant_sleep() ? uml_kmalloc(PATH_MAX, UM_GFP_ATOMIC) :
++                                      uml_kmalloc(PATH_MAX, UM_GFP_KERNEL);
+       pid = clone(helper_child, (void *) sp, CLONE_VM, &data);
+       if (pid < 0) {
+               ret = -errno;
+--- a/arch/um/os-Linux/main.c
++++ b/arch/um/os-Linux/main.c
+@@ -199,7 +199,7 @@ void *__wrap_malloc(int size)
+               return __real_malloc(size);
+       else if (size <= UM_KERN_PAGE_SIZE)
+               /* finding contiguous pages can be hard*/
+-              ret = kmalloc(size, UM_GFP_KERNEL);
++              ret = uml_kmalloc(size, UM_GFP_KERNEL);
+       else ret = vmalloc(size);
+       /*
+--- a/arch/um/os-Linux/sigio.c
++++ b/arch/um/os-Linux/sigio.c
+@@ -109,7 +109,7 @@ static int need_poll(struct pollfds *pol
+       if (n <= polls->size)
+               return 0;
+-      new = kmalloc(n * sizeof(struct pollfd), UM_GFP_ATOMIC);
++      new = uml_kmalloc(n * sizeof(struct pollfd), UM_GFP_ATOMIC);
+       if (new == NULL) {
+               printk(UM_KERN_ERR "need_poll : failed to allocate new "
+                      "pollfds\n");
+@@ -243,7 +243,7 @@ static struct pollfd *setup_initial_poll
+ {
+       struct pollfd *p;
+-      p = kmalloc(sizeof(struct pollfd), UM_GFP_KERNEL);
++      p = uml_kmalloc(sizeof(struct pollfd), UM_GFP_KERNEL);
+       if (p == NULL) {
+               printk(UM_KERN_ERR "setup_initial_poll : failed to allocate "
+                      "poll\n");
diff --git a/queue-2.6.25/uml-fix-gcc-ices-and-unresolved-externs.patch b/queue-2.6.25/uml-fix-gcc-ices-and-unresolved-externs.patch
new file mode 100644 (file)
index 0000000..0b1cd6f
--- /dev/null
@@ -0,0 +1,80 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:14:46 2008
+From: Jeff Dike <jdike@addtoit.com>
+Date: Tue, 5 Aug 2008 16:14:10 -0400
+Subject: uml: fix gcc ICEs and unresolved externs
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201410.GA11794@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Jeff Dike <jdike@addtoit.com>
+
+commit 4f81c5350b44bcc501ab6f8a089b16d064b4d2f6 upstream
+
+There are various constraints on the use of unit-at-a-time:
+ - i386 uses no-unit-at-a-time for pre-4.0 (not 4.3)
+ - x86_64 uses unit-at-a-time always
+
+Uli reported a crash on x86_64 with gcc 4.1.2 with unit-at-a-time,
+resulting in commit c0a18111e571138747a98af18b3a2124df56a0d1
+
+Ingo reported a gcc internal error with gcc 4.3 with no-unit-at-a-timem,
+resulting in 22eecde2f9034764a3fd095eecfa3adfb8ec9a98
+
+Benny Halevy is seeing extern inlines not resolved with gcc 4.3 with
+no-unit-at-a-time
+
+This patch reintroduces unit-at-a-time for gcc >= 4.0, bringing back the
+possibility of Uli's crash.  If that happens, we'll debug it.
+
+I started seeing both the internal compiler errors and unresolved
+inlines on Fedora 9.  This patch fixes both problems, without so far
+reintroducing the crash reported by Uli.
+
+Signed-off-by: Jeff Dike <jdike@linux.intel.com>
+Cc: Benny Halevy <bhalevy@panasas.com>
+Cc: Adrian Bunk <bunk@kernel.org>
+Cc: Ingo Molnar <mingo@elte.hu>
+Cc: Ulrich Drepper <drepper@redhat.com>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/Makefile        |    1 -
+ arch/um/Makefile-i386   |    7 +++++++
+ arch/um/Makefile-x86_64 |    3 +++
+ 3 files changed, 10 insertions(+), 1 deletion(-)
+
+--- a/arch/um/Makefile
++++ b/arch/um/Makefile
+@@ -77,7 +77,6 @@ include $(srctree)/$(ARCH_DIR)/Makefile-
+ KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
+                        -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
+ KBUILD_CFLAGS += $(KERNEL_DEFINES)
+-KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
+ PHONY += linux
+--- a/arch/um/Makefile-i386
++++ b/arch/um/Makefile-i386
+@@ -32,4 +32,11 @@ cflags-y += $(call cc-option,-mpreferred
+ # an unresolved reference.
+ cflags-y += -ffreestanding
++# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
++# a lot more stack due to the lack of sharing of stacklots.  Also, gcc
++# 4.3.0 needs -funit-at-a-time for extern inline functions.
++KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then \
++                      echo $(call cc-option,-fno-unit-at-a-time); \
++                      else echo $(call cc-option,-funit-at-a-time); fi ;)
++
+ KBUILD_CFLAGS += $(cflags-y)
+--- a/arch/um/Makefile-x86_64
++++ b/arch/um/Makefile-x86_64
+@@ -21,3 +21,6 @@ HEADER_ARCH := x86
+ LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib64
+ LINK-y += -m64
++
++# Do unit-at-a-time unconditionally on x86_64, following the host
++KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
diff --git a/queue-2.6.25/uml-memcpy-export-needs-to-follow-host-declaration.patch b/queue-2.6.25/uml-memcpy-export-needs-to-follow-host-declaration.patch
new file mode 100644 (file)
index 0000000..c1d2c02
--- /dev/null
@@ -0,0 +1,38 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:15:05 2008
+From: Jeff Dike <jdike@addtoit.com>
+Date: Tue, 5 Aug 2008 16:14:09 -0400
+Subject:  uml: memcpy export needs to follow host declaration
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201409.GA11792@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Jeff Dike <jdike@addtoit.com>
+
+commit 8bfd04b974689f700bbd053ad6e66b0a95fb80c9 upstream
+
+x86_64 defines either memcpy or __memcpy depending on the gcc version, and
+it looks like UML needs to follow that in its exporting.
+
+Cc: Gabriel C <nix.or.die@googlemail.com>
+Signed-off-by: Jeff Dike <jdike@linux.intel.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/sys-x86_64/ksyms.c |    4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/arch/um/sys-x86_64/ksyms.c
++++ b/arch/um/sys-x86_64/ksyms.c
+@@ -13,5 +13,9 @@ EXPORT_SYMBOL(__down_failed_trylock);
+ EXPORT_SYMBOL(__up_wakeup);
+ /*XXX: we need them because they would be exported by x86_64 */
++#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
++EXPORT_SYMBOL(memcpy);
++#else
+ EXPORT_SYMBOL(__memcpy);
++#endif
+ EXPORT_SYMBOL(csum_partial);
diff --git a/queue-2.6.25/uml-missed-kmalloc-in-pcap_user.c.patch b/queue-2.6.25/uml-missed-kmalloc-in-pcap_user.c.patch
new file mode 100644 (file)
index 0000000..f8ecffa
--- /dev/null
@@ -0,0 +1,33 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:14:38 2008
+From: Al Viro <viro@ftp.linux.org.uk>
+Date: Tue, 5 Aug 2008 16:14:05 -0400
+Subject: uml: missed kmalloc() in pcap_user.c
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201405.GA11736@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Al Viro <viro@ftp.linux.org.uk>
+
+commit 296cd66f7f6e130fe08e6880ecb13c3fc615a8db upstream
+
+Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
+Acked-by: Jeff Dike <jdike@addtoit.com>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/drivers/pcap_user.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/um/drivers/pcap_user.c
++++ b/arch/um/drivers/pcap_user.c
+@@ -50,7 +50,7 @@ static int pcap_open(void *data)
+                       return -EIO;
+               }
+-              pri->compiled = kmalloc(sizeof(struct bpf_program),
++              pri->compiled = uml_kmalloc(sizeof(struct bpf_program),
+                                       UM_GFP_KERNEL);
+               if (pri->compiled == NULL) {
+                       printk(UM_KERN_ERR "pcap_open : kmalloc failed\n");
diff --git a/queue-2.6.25/uml-missing-export-of-csum_partial-on-uml-amd64.patch b/queue-2.6.25/uml-missing-export-of-csum_partial-on-uml-amd64.patch
new file mode 100644 (file)
index 0000000..6021afd
--- /dev/null
@@ -0,0 +1,29 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:14:50 2008
+From: Al Viro <viro@ftp.linux.org.uk>
+Date: Tue, 5 Aug 2008 16:14:07 -0400
+Subject: uml: missing export of csum_partial() on uml/amd64
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201407.GA11790@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Al Viro <viro@ftp.linux.org.uk>
+
+commit 3e3b48e5198544dd90e27265a70c1a834139e025 upstream
+
+Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
+Cc: Jeff Dike <jdike@addtoit.com>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/sys-x86_64/ksyms.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/um/sys-x86_64/ksyms.c
++++ b/arch/um/sys-x86_64/ksyms.c
+@@ -14,3 +14,4 @@ EXPORT_SYMBOL(__up_wakeup);
+ /*XXX: we need them because they would be exported by x86_64 */
+ EXPORT_SYMBOL(__memcpy);
++EXPORT_SYMBOL(csum_partial);
diff --git a/queue-2.6.25/uml-path_max-needs-limits.h.patch b/queue-2.6.25/uml-path_max-needs-limits.h.patch
new file mode 100644 (file)
index 0000000..8df2d85
--- /dev/null
@@ -0,0 +1,35 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:15:02 2008
+From: Ingo Molnar <mingo@elte.hu>
+Date: Tue, 5 Aug 2008 16:14:11 -0400
+Subject: uml: PATH_MAX needs limits.h
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201411.GA11802@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Ingo Molnar <mingo@elte.hu>
+
+commit b6d8adf477439e7086224bc9674c6b6638780783 upstream.
+
+Include limits.h to get a definition of PATH_MAX.
+
+Signed-off-by: Ingo Molnar <mingo@elte.hu>
+Signed-off-by: Jeff Dike <jdike@linux.intel.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/os-Linux/helper.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/um/os-Linux/helper.c
++++ b/arch/um/os-Linux/helper.c
+@@ -7,6 +7,7 @@
+ #include <unistd.h>
+ #include <errno.h>
+ #include <sched.h>
++#include <linux/limits.h>
+ #include <sys/socket.h>
+ #include <sys/wait.h>
+ #include "kern_constants.h"
diff --git a/queue-2.6.25/uml-physical-memory-shouldn-t-include-initial-stack.patch b/queue-2.6.25/uml-physical-memory-shouldn-t-include-initial-stack.patch
new file mode 100644 (file)
index 0000000..e183ec4
--- /dev/null
@@ -0,0 +1,49 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:14:54 2008
+From: Jeff Dike <jdike@addtoit.com>
+Date: Tue, 5 Aug 2008 16:14:04 -0400
+Subject: uml: physical memory shouldn't include initial stack
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201404.GA11782@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Jeff Dike <jdike@addtoit.com>
+
+commit 60a2988aea701a6424809a5432bf068667aac177 upstream
+
+The top of physical memory should be below the initial process stack, not the
+top of the address space, at least for as long as the stack isn't known to the
+kernel VM system and appropriately reserved.
+
+Cc: "Christopher S. Aker" <caker@theshore.net>
+Signed-off-by: Jeff Dike <jdike@linux.intel.com>
+Cc: WANG Cong <xiyou.wangcong@gmail.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/kernel/um_arch.c |    5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/arch/um/kernel/um_arch.c
++++ b/arch/um/kernel/um_arch.c
+@@ -259,6 +259,7 @@ int __init linux_main(int argc, char **a
+       unsigned long avail, diff;
+       unsigned long virtmem_size, max_physmem;
+       unsigned int i, add;
++      unsigned long stack;
+       char * mode;
+       for (i = 1; i < argc; i++) {
+@@ -347,7 +348,9 @@ int __init linux_main(int argc, char **a
+       }
+       virtmem_size = physmem_size;
+-      avail = TASK_SIZE - start_vm;
++      stack = (unsigned long) argv;
++      stack &= ~(1024 * 1024 - 1);
++      avail = stack - start_vm;
+       if (physmem_size > avail)
+               virtmem_size = avail;
+       end_vm = start_vm + virtmem_size;
diff --git a/queue-2.6.25/uml-stub-needs-to-tolerate-sigwinch.patch b/queue-2.6.25/uml-stub-needs-to-tolerate-sigwinch.patch
new file mode 100644 (file)
index 0000000..840f405
--- /dev/null
@@ -0,0 +1,37 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:15:05 2008
+From: Jeff Dike <jdike@addtoit.com>
+Date: Tue, 5 Aug 2008 16:14:09 -0400
+Subject: uml: stub needs to tolerate SIGWINCH
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201409.GA11798@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Jeff Dike <jdike@addtoit.com>
+
+commit 3d5ede6f776bdb1483bcd086f79c3bf41fed3865 upstream
+
+We lost the marking of SIGWINCH as being OK to receive during stub
+execution, causing a panic should that happen.
+
+Cc: Benedict Verheyen <benedict.verheyen@gmail.com>
+Signed-off-by: Jeff Dike <jdike@linux.intel.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/os-Linux/skas/process.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/um/os-Linux/skas/process.c
++++ b/arch/um/os-Linux/skas/process.c
+@@ -55,7 +55,7 @@ static int ptrace_dump_regs(int pid)
+  * Signals that are OK to receive in the stub - we'll just continue it.
+  * SIGWINCH will happen when UML is inside a detached screen.
+  */
+-#define STUB_SIG_MASK (1 << SIGVTALRM)
++#define STUB_SIG_MASK ((1 << SIGVTALRM) | (1 << SIGWINCH))
+ /* Signals that the stub will finish with - anything else is an error */
+ #define STUB_DONE_MASK (1 << SIGTRAP)
diff --git a/queue-2.6.25/uml-track-and-make-up-lost-ticks.patch b/queue-2.6.25/uml-track-and-make-up-lost-ticks.patch
new file mode 100644 (file)
index 0000000..e685325
--- /dev/null
@@ -0,0 +1,161 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:14:23 2008
+From: Jeff Dike <jdike@addtoit.com>
+Date: Tue, 5 Aug 2008 16:14:05 -0400
+Subject: uml: track and make up lost ticks
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201405.GA11784@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Jeff Dike <jdike@addtoit.com>
+
+commit fe2cc53ee013a4d4d0317d418e7019fe6533a5a8 upstream
+
+Alarm delivery could be noticably late in the !CONFIG_NOHZ case because lost
+ticks weren't being taken into account.  This is now treated more carefully,
+with the time between ticks being calculated and the appropriate number of
+ticks delivered to the timekeeping system.
+
+Cc: Nix <nix@esperi.org.uk>
+Signed-off-by: Jeff Dike <jdike@linux.intel.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/include/process.h |    4 +--
+ arch/um/os-Linux/signal.c |    1 
+ arch/um/os-Linux/time.c   |   54 ++++++++++++++++++++++++++++++++++++++++++----
+ 3 files changed, 53 insertions(+), 6 deletions(-)
+
+--- a/arch/um/include/process.h
++++ b/arch/um/include/process.h
+@@ -8,8 +8,8 @@
+ #include <signal.h>
+-extern void sig_handler(int sig, struct sigcontext sc);
+-extern void alarm_handler(int sig, struct sigcontext sc);
++extern void sig_handler(int sig, struct sigcontext *sc);
++extern void alarm_handler(int sig, struct sigcontext *sc);
+ #endif
+--- a/arch/um/os-Linux/signal.c
++++ b/arch/um/os-Linux/signal.c
+@@ -12,6 +12,7 @@
+ #include "as-layout.h"
+ #include "kern_util.h"
+ #include "os.h"
++#include "process.h"
+ #include "sysdep/barrier.h"
+ #include "sysdep/sigcontext.h"
+ #include "user.h"
+--- a/arch/um/os-Linux/time.c
++++ b/arch/um/os-Linux/time.c
+@@ -9,7 +9,9 @@
+ #include <time.h>
+ #include <sys/time.h>
+ #include "kern_constants.h"
++#include "kern_util.h"
+ #include "os.h"
++#include "process.h"
+ #include "user.h"
+ int set_interval(void)
+@@ -58,12 +60,17 @@ static inline long long timeval_to_ns(co
+ long long disable_timer(void)
+ {
+       struct itimerval time = ((struct itimerval) { { 0, 0 }, { 0, 0 } });
++      int remain, max = UM_NSEC_PER_SEC / UM_HZ;
+       if (setitimer(ITIMER_VIRTUAL, &time, &time) < 0)
+               printk(UM_KERN_ERR "disable_timer - setitimer failed, "
+                      "errno = %d\n", errno);
+-      return timeval_to_ns(&time.it_value);
++      remain = timeval_to_ns(&time.it_value);
++      if (remain > max)
++              remain = max;
++
++      return remain;
+ }
+ long long os_nsecs(void)
+@@ -79,7 +86,44 @@ static int after_sleep_interval(struct t
+ {
+       return 0;
+ }
++
++static void deliver_alarm(void)
++{
++      alarm_handler(SIGVTALRM, NULL);
++}
++
++static unsigned long long sleep_time(unsigned long long nsecs)
++{
++      return nsecs;
++}
++
+ #else
++unsigned long long last_tick;
++unsigned long long skew;
++
++static void deliver_alarm(void)
++{
++      unsigned long long this_tick = os_nsecs();
++      int one_tick = UM_NSEC_PER_SEC / UM_HZ;
++
++      if (last_tick == 0)
++              last_tick = this_tick - one_tick;
++
++      skew += this_tick - last_tick;
++
++      while (skew >= one_tick) {
++              alarm_handler(SIGVTALRM, NULL);
++              skew -= one_tick;
++      }
++
++      last_tick = this_tick;
++}
++
++static unsigned long long sleep_time(unsigned long long nsecs)
++{
++      return nsecs > skew ? nsecs - skew : 0;
++}
++
+ static inline long long timespec_to_us(const struct timespec *ts)
+ {
+       return ((long long) ts->tv_sec * UM_USEC_PER_SEC) +
+@@ -102,6 +146,8 @@ static int after_sleep_interval(struct t
+        */
+       if (start_usecs > usec)
+               start_usecs = usec;
++
++      start_usecs -= skew / UM_NSEC_PER_USEC;
+       tv = ((struct timeval) { .tv_sec  = start_usecs / UM_USEC_PER_SEC,
+                                .tv_usec = start_usecs % UM_USEC_PER_SEC });
+       interval = ((struct itimerval) { { 0, usec }, tv });
+@@ -113,8 +159,6 @@ static int after_sleep_interval(struct t
+ }
+ #endif
+-extern void alarm_handler(int sig, struct sigcontext *sc);
+-
+ void idle_sleep(unsigned long long nsecs)
+ {
+       struct timespec ts;
+@@ -126,10 +170,12 @@ void idle_sleep(unsigned long long nsecs
+        */
+       if (nsecs == 0)
+               nsecs = UM_NSEC_PER_SEC / UM_HZ;
++
++      nsecs = sleep_time(nsecs);
+       ts = ((struct timespec) { .tv_sec       = nsecs / UM_NSEC_PER_SEC,
+                                 .tv_nsec      = nsecs % UM_NSEC_PER_SEC });
+       if (nanosleep(&ts, &ts) == 0)
+-              alarm_handler(SIGVTALRM, NULL);
++              deliver_alarm();
+       after_sleep_interval(&ts);
+ }
diff --git a/queue-2.6.25/uml-work-around-broken-host-ptrace_sysemu.patch b/queue-2.6.25/uml-work-around-broken-host-ptrace_sysemu.patch
new file mode 100644 (file)
index 0000000..88a9b82
--- /dev/null
@@ -0,0 +1,81 @@
+From stable-bounces@linux.kernel.org Tue Aug  5 13:14:58 2008
+From: Jeff Dike <jdike@addtoit.com>
+Date: Tue, 5 Aug 2008 16:14:09 -0400
+Subject: uml: work around broken host PTRACE_SYSEMU
+To: stable@kernel.org
+Cc: LKML <linux-kernel@vger.kernel.org>, uml-devel <user-mode-linux-devel@lists.sourceforge.net>
+Message-ID: <20080805201409.GA11800@c2.user-mode-linux.org>
+Content-Disposition: inline
+
+From: Jeff Dike <jdike@addtoit.com>
+
+commit f1ef9167ca4494a8c6d71d0031c73e9c8841eadd upstream
+
+Fedora broke PTRACE_SYSEMU again, and UML crashes as a result when it
+doesn't need to.  This patch makes the PTRACE_SYSEMU check fail gracefully
+and makes UML fall back to PTRACE_SYSCALL.
+
+Signed-off-by: Jeff Dike <jdike@linux.intel.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/um/os-Linux/start_up.c |   25 ++++++++++++++++---------
+ 1 file changed, 16 insertions(+), 9 deletions(-)
+
+--- a/arch/um/os-Linux/start_up.c
++++ b/arch/um/os-Linux/start_up.c
+@@ -122,8 +122,10 @@ static int stop_ptraced_child(int pid, i
+ {
+       int status, n, ret = 0;
+-      if (ptrace(PTRACE_CONT, pid, 0, 0) < 0)
+-              fatal_perror("stop_ptraced_child : ptrace failed");
++      if (ptrace(PTRACE_CONT, pid, 0, 0) < 0) {
++              perror("stop_ptraced_child : ptrace failed");
++              return -1;
++      }
+       CATCH_EINTR(n = waitpid(pid, &status, 0));
+       if (!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) {
+               int exit_with = WEXITSTATUS(status);
+@@ -203,7 +205,7 @@ static void __init check_sysemu(void)
+       if (n < 0)
+               fatal_perror("check_sysemu : wait failed");
+       if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
+-              fatal("check_sysemu : expected SIGTRAP, got status = %d",
++              fatal("check_sysemu : expected SIGTRAP, got status = %d\n",
+                     status);
+       if (ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
+@@ -245,9 +247,11 @@ static void __init check_sysemu(void)
+               if (WIFSTOPPED(status) &&
+                   (WSTOPSIG(status) == (SIGTRAP|0x80))) {
+-                      if (!count)
+-                              fatal("check_ptrace : SYSEMU_SINGLESTEP "
+-                                    "doesn't singlestep");
++                      if (!count) {
++                              non_fatal("check_ptrace : SYSEMU_SINGLESTEP "
++                                        "doesn't singlestep");
++                              goto fail;
++                      }
+                       n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET,
+                                  os_getpid());
+                       if (n < 0)
+@@ -257,9 +261,12 @@ static void __init check_sysemu(void)
+               }
+               else if (WIFSTOPPED(status) && (WSTOPSIG(status) == SIGTRAP))
+                       count++;
+-              else
+-                      fatal("check_ptrace : expected SIGTRAP or "
+-                            "(SIGTRAP | 0x80), got status = %d", status);
++              else {
++                      non_fatal("check_ptrace : expected SIGTRAP or "
++                                "(SIGTRAP | 0x80), got status = %d\n",
++                                status);
++                      goto fail;
++              }
+       }
+       if (stop_ptraced_child(pid, 0, 0) < 0)
+               goto fail_stopped;