]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.2-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 7 Feb 2012 01:05:49 +0000 (17:05 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 7 Feb 2012 01:05:49 +0000 (17:05 -0800)
added patches:
pm-hibernate-thaw-kernel-threads-in-snapshot_create_image-ioctl-path.patch
pm-hibernate-thaw-processes-in-snapshot_create_image-ioctl-test-path.patch
sched-rt-fix-task-stack-corruption-under-__arch_want_interrupts_on_ctxsw.patch

queue-3.2/pm-hibernate-thaw-kernel-threads-in-snapshot_create_image-ioctl-path.patch [new file with mode: 0644]
queue-3.2/pm-hibernate-thaw-processes-in-snapshot_create_image-ioctl-test-path.patch [new file with mode: 0644]
queue-3.2/sched-rt-fix-task-stack-corruption-under-__arch_want_interrupts_on_ctxsw.patch [new file with mode: 0644]
queue-3.2/series

diff --git a/queue-3.2/pm-hibernate-thaw-kernel-threads-in-snapshot_create_image-ioctl-path.patch b/queue-3.2/pm-hibernate-thaw-kernel-threads-in-snapshot_create_image-ioctl-path.patch
new file mode 100644 (file)
index 0000000..303d38c
--- /dev/null
@@ -0,0 +1,45 @@
+From fe9161db2e6053da21e4649d77bbefaf3030b11d Mon Sep 17 00:00:00 2001
+From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
+Date: Wed, 1 Feb 2012 22:16:36 +0100
+Subject: PM / Hibernate: Thaw kernel threads in SNAPSHOT_CREATE_IMAGE ioctl path
+
+From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
+
+commit fe9161db2e6053da21e4649d77bbefaf3030b11d upstream.
+
+In the SNAPSHOT_CREATE_IMAGE ioctl, if the call to hibernation_snapshot()
+fails, the frozen tasks are not thawed.
+
+And in the case of success, if we happen to exit due to a successful freezer
+test, all tasks (including those of userspace) are thawed, whereas actually
+we should have thawed only the kernel threads at that point. Fix both these
+issues.
+
+Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
+Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/power/user.c |    6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/kernel/power/user.c
++++ b/kernel/power/user.c
+@@ -283,13 +283,15 @@ static long snapshot_ioctl(struct file *
+               }
+               pm_restore_gfp_mask();
+               error = hibernation_snapshot(data->platform_support);
+-              if (!error) {
++              if (error) {
++                      thaw_kernel_threads();
++              } else {
+                       error = put_user(in_suspend, (int __user *)arg);
+                       if (!error && !freezer_test_done)
+                               data->ready = 1;
+                       if (freezer_test_done) {
+                               freezer_test_done = false;
+-                              thaw_processes();
++                              thaw_kernel_threads();
+                       }
+               }
+               break;
diff --git a/queue-3.2/pm-hibernate-thaw-processes-in-snapshot_create_image-ioctl-test-path.patch b/queue-3.2/pm-hibernate-thaw-processes-in-snapshot_create_image-ioctl-test-path.patch
new file mode 100644 (file)
index 0000000..2376380
--- /dev/null
@@ -0,0 +1,76 @@
+From 97819a26224f019e73d88bb2fd4eb5a614860461 Mon Sep 17 00:00:00 2001
+From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
+Date: Thu, 1 Dec 2011 22:33:10 +0100
+Subject: PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl test path
+
+From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
+
+commit 97819a26224f019e73d88bb2fd4eb5a614860461 upstream.
+
+Commit 2aede851ddf08666f68ffc17be446420e9d2a056 (PM / Hibernate: Freeze
+kernel threads after preallocating memory) moved the freezing of kernel
+threads to hibernation_snapshot() function.
+
+So now, if the call to hibernation_snapshot() returns early due to a
+successful hibernation test, the caller has to thaw processes to ensure
+that the system gets back to its original state.
+
+But in SNAPSHOT_CREATE_IMAGE hibernation ioctl, the caller does not thaw
+processes in case hibernation_snapshot() returned due to a successful
+freezer test. Fix this issue. But note we still send the value of 'in_suspend'
+(which is now 0) to userspace, because we are not in an error path per-se,
+and moreover, the value of in_suspend correctly depicts the situation here.
+
+Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
+Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/power/hibernate.c |    2 +-
+ kernel/power/power.h     |    2 ++
+ kernel/power/user.c      |   11 ++++++++---
+ 3 files changed, 11 insertions(+), 4 deletions(-)
+
+--- a/kernel/power/hibernate.c
++++ b/kernel/power/hibernate.c
+@@ -55,7 +55,7 @@ enum {
+ static int hibernation_mode = HIBERNATION_SHUTDOWN;
+-static bool freezer_test_done;
++bool freezer_test_done;
+ static const struct platform_hibernation_ops *hibernation_ops;
+--- a/kernel/power/power.h
++++ b/kernel/power/power.h
+@@ -50,6 +50,8 @@ static inline char *check_image_kernel(s
+ #define SPARE_PAGES   ((1024 * 1024) >> PAGE_SHIFT)
+ /* kernel/power/hibernate.c */
++extern bool freezer_test_done;
++
+ extern int hibernation_snapshot(int platform_mode);
+ extern int hibernation_restore(int platform_mode);
+ extern int hibernation_platform_enter(void);
+--- a/kernel/power/user.c
++++ b/kernel/power/user.c
+@@ -283,10 +283,15 @@ static long snapshot_ioctl(struct file *
+               }
+               pm_restore_gfp_mask();
+               error = hibernation_snapshot(data->platform_support);
+-              if (!error)
++              if (!error) {
+                       error = put_user(in_suspend, (int __user *)arg);
+-              if (!error)
+-                      data->ready = 1;
++                      if (!error && !freezer_test_done)
++                              data->ready = 1;
++                      if (freezer_test_done) {
++                              freezer_test_done = false;
++                              thaw_processes();
++                      }
++              }
+               break;
+       case SNAPSHOT_ATOMIC_RESTORE:
diff --git a/queue-3.2/sched-rt-fix-task-stack-corruption-under-__arch_want_interrupts_on_ctxsw.patch b/queue-3.2/sched-rt-fix-task-stack-corruption-under-__arch_want_interrupts_on_ctxsw.patch
new file mode 100644 (file)
index 0000000..b291117
--- /dev/null
@@ -0,0 +1,91 @@
+From cb297a3e433dbdcf7ad81e0564e7b804c941ff0d Mon Sep 17 00:00:00 2001
+From: Chanho Min <chanho0207@gmail.com>
+Date: Thu, 5 Jan 2012 20:00:19 +0900
+Subject: sched/rt: Fix task stack corruption under __ARCH_WANT_INTERRUPTS_ON_CTXSW
+
+From: Chanho Min <chanho0207@gmail.com>
+
+commit cb297a3e433dbdcf7ad81e0564e7b804c941ff0d upstream.
+
+This issue happens under the following conditions:
+
+ 1. preemption is off
+ 2. __ARCH_WANT_INTERRUPTS_ON_CTXSW is defined
+ 3. RT scheduling class
+ 4. SMP system
+
+Sequence is as follows:
+
+ 1.suppose current task is A. start schedule()
+ 2.task A is enqueued pushable task at the entry of schedule()
+   __schedule
+    prev = rq->curr;
+    ...
+    put_prev_task
+     put_prev_task_rt
+      enqueue_pushable_task
+ 4.pick the task B as next task.
+   next = pick_next_task(rq);
+ 3.rq->curr set to task B and context_switch is started.
+   rq->curr = next;
+ 4.At the entry of context_swtich, release this cpu's rq->lock.
+   context_switch
+    prepare_task_switch
+     prepare_lock_switch
+      raw_spin_unlock_irq(&rq->lock);
+ 5.Shortly after rq->lock is released, interrupt is occurred and start IRQ context
+ 6.try_to_wake_up() which called by ISR acquires rq->lock
+    try_to_wake_up
+     ttwu_remote
+      rq = __task_rq_lock(p)
+      ttwu_do_wakeup(rq, p, wake_flags);
+        task_woken_rt
+ 7.push_rt_task picks the task A which is enqueued before.
+   task_woken_rt
+    push_rt_tasks(rq)
+     next_task = pick_next_pushable_task(rq)
+ 8.At find_lock_lowest_rq(), If double_lock_balance() returns 0,
+   lowest_rq can be the remote rq.
+  (But,If preemption is on, double_lock_balance always return 1 and it
+   does't happen.)
+   push_rt_task
+    find_lock_lowest_rq
+     if (double_lock_balance(rq, lowest_rq))..
+ 9.find_lock_lowest_rq return the available rq. task A is migrated to
+   the remote cpu/rq.
+   push_rt_task
+    ...
+    deactivate_task(rq, next_task, 0);
+    set_task_cpu(next_task, lowest_rq->cpu);
+    activate_task(lowest_rq, next_task, 0);
+ 10. But, task A is on irq context at this cpu.
+     So, task A is scheduled by two cpus at the same time until restore from IRQ.
+     Task A's stack is corrupted.
+
+To fix it, don't migrate an RT task if it's still running.
+
+Signed-off-by: Chanho Min <chanho.min@lge.com>
+Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
+Acked-by: Steven Rostedt <rostedt@goodmis.org>
+Link: http://lkml.kernel.org/r/CAOAMb1BHA=5fm7KTewYyke6u-8DP0iUuJMpgQw54vNeXFsGpoQ@mail.gmail.com
+Signed-off-by: Ingo Molnar <mingo@elte.hu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/sched_rt.c |    5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/kernel/sched_rt.c
++++ b/kernel/sched_rt.c
+@@ -1388,6 +1388,11 @@ static int push_rt_task(struct rq *rq)
+       if (!next_task)
+               return 0;
++#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
++       if (unlikely(task_running(rq, next_task)))
++               return 0;
++#endif
++
+ retry:
+       if (unlikely(next_task == rq->curr)) {
+               WARN_ON(1);
index 87bcac78044e69a4396733821bdb70f7a3281272..9b16e757a3c3f9683c19936ca5f37be9c5e193f8 100644 (file)
@@ -32,3 +32,6 @@ drm-radeon-set-desktop_height-register-to-the-framebuffer-not-mode-height.patch
 drm-nouveau-gem-fix-fence_sync-race-oops.patch
 drm-radeon-kms-disable-output-polling-when-suspended.patch
 drm-radeon-kms-fix-travis-panel-setup.patch
+sched-rt-fix-task-stack-corruption-under-__arch_want_interrupts_on_ctxsw.patch
+pm-hibernate-thaw-processes-in-snapshot_create_image-ioctl-test-path.patch
+pm-hibernate-thaw-kernel-threads-in-snapshot_create_image-ioctl-path.patch