[FOSS_TLK]tegra: common: Add checks for ns_vfp_hw_context
Sharif Inamdar [Wed, 18 Feb 2015 10:44:52 +0000 (15:44 +0530)]
If any task is not loaded then this will be NULL.
Hence adding checks before accessing.

Change-Id: I41fdaebb3124581823f8a064d38621b503be0c7c
Signed-off-by: Sharif Inamdar <isharif@nvidia.com>
Reviewed-on: http://git-master/r/715783
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Varun Wadekar <vwadekar@nvidia.com>
Tested-by: Varun Wadekar <vwadekar@nvidia.com>

platform/tegra/common/tz.c

index 98c1392..fefb287 100644 (file)
@@ -187,10 +187,9 @@ struct tz_monitor_frame *tz_switch_to_ns(uint32_t smc_type, struct tz_monitor_fr
                 */
                arch_vfp_restore(ns_vfp_hw_context);
                ns_vfp_hw_context->valid = false;
+               arm_set_vfp_fpexc(ns_vfp_hw_context->fpexc);
        }
 
-       arm_set_vfp_fpexc(ns_vfp_hw_context->fpexc);
-
 #if defined(WITH_MONITOR_BIN)
        /* go to monitor, for return to NS */
        incoming_smc = monitor_send_receive(smc_type, frame);
@@ -202,9 +201,12 @@ struct tz_monitor_frame *tz_switch_to_ns(uint32_t smc_type, struct tz_monitor_fr
        exit_critical_section();
 
        /* on entry, save NS fpexc and disable to detect vfp usage */
-       ns_vfp_hw_context->fpexc = arm_get_vfp_fpexc();
+       if (ns_vfp_hw_context && ns_vfp_hw_context->valid)
+               ns_vfp_hw_context->fpexc = arm_get_vfp_fpexc();
+
        arm_set_vfp_fpexc(0x0);
 
+
        return incoming_smc;
 }