qcom: scm: Be careful with side-effects from is_scm_armv8

Currently, when deciding which version of scm call to make in scm_call2,
we check the scm_version variable.  However, the scm_version variable is
only initialized as a side-effect of calling is_scm_armv8, which isn't
called anywhere in scm_call2.  So if someone makes an scm_call2 before
is_scm_armv8 has been called then they could get the wrong scm version.
Fix this by calling is_scm_armv8 at the top of the scm_call2
function (and bailing out if it's not v8 since scm_call2 only supports
v8 forward).  Similarly for scm_call2_atomic.

Since is_scm_armv8 caches its result the performance overhead of calling
on every invocation of scm_call2 should be negligible.

Change-Id: I46d2423ae2e4b5204fc5eefa1c6660c3c95a95b0
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
This commit is contained in:
Mitchel Humpherys 2015-10-13 11:19:24 -07:00 committed by Rohit Vaswani
parent 17b27dfb0e
commit 32b29d83ff

View file

@ -637,6 +637,9 @@ int scm_call2(u32 fn_id, struct scm_desc *desc)
int ret, retry_count = 0;
u64 x0;
if (unlikely(!is_scm_armv8()))
return -ENODEV;
ret = allocate_extra_arg_buffer(desc, GFP_KERNEL);
if (ret)
return ret;
@ -705,6 +708,9 @@ int scm_call2_atomic(u32 fn_id, struct scm_desc *desc)
int ret;
u64 x0;
if (unlikely(!is_scm_armv8()))
return -ENODEV;
ret = allocate_extra_arg_buffer(desc, GFP_ATOMIC);
if (ret)
return ret;