security: tf_driver: fix incorrect cpu affinity in tf_driver
Hyung Taek Ryoo [Thu, 31 Jan 2013 04:50:03 +0000 (20:50 -0800)]
This change fixes incorrect cpu affinity after excuting tf_driver.
The process using tf_driver sometimes can't be schecduled to
available onlined cpu. It is because cpu affinity has changed
after using tf_driver. tf_driver saves current cpu affinity by
calling sched_getaffinity which returns cpu affinity AND-masked
by onlined cpus. tf_driver should save just current cpu affinity,
not cpu affinity AND-masked by onlined cpus.

bug 1218943

cherry picked from commit bba209aa7fe8b4f52f5d42acc1b21d8f54c18fe0)
Reviewed-on: http://git-master/r/#change,195830

Change-Id: I4f39b9768f95dd773582fbff6bb4577c3debd9b3
Signed-off-by: Hyung Taek Ryoo <hryoo@nvidia.com>
Reviewed-on: http://git-master/r/198844
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>

security/tf_driver/tf_comm.c
security/tf_driver/tf_comm_tz.c

index b3d58e2..0153824 100644 (file)
@@ -1461,7 +1461,7 @@ int tf_send_receive(struct tf_comm *comm,
 
 #ifdef CONFIG_SMP
        cpu_set(0, local_cpu_mask);
-       sched_getaffinity(0, &saved_cpu_mask);
+       cpumask_copy(&saved_cpu_mask, tsk_cpus_allowed(current));
        ret_affinity = sched_setaffinity(0, &local_cpu_mask);
        if (ret_affinity != 0)
                dprintk(KERN_ERR "sched_setaffinity #1 -> 0x%lX", ret_affinity);
index a0e9941..0f36209 100644 (file)
@@ -61,7 +61,7 @@ static inline void tf_smc_generic_call(
        cpumask_t local_cpu_mask = CPU_MASK_NONE;
 
        cpu_set(0, local_cpu_mask);
-       sched_getaffinity(0, &saved_cpu_mask);
+       cpumask_copy(&saved_cpu_mask, tsk_cpus_allowed(current));
        ret = sched_setaffinity(0, &local_cpu_mask);
        if (ret != 0)
                dprintk(KERN_ERR "sched_setaffinity #1 -> 0x%lX", ret);