trusty: Add trusty_fast_call64 api on 64 bit systems.
Arve Hjønnevåg [Tue, 15 Apr 2014 00:16:06 +0000 (17:16 -0700)]
Bug 1818826

Change-Id: Ibb74be14fd3ddcb792862f7e1bd9c588007924d5
Signed-off-by: Arve Hjønnevåg <arve@android.com>
(cherry picked from commit 6b1a2d31a5682fd626b1c41895ddf7ab6bb8c643 from https://android.googlesource.com/kernel/common/+/android-trusty-3.10)
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-on: http://git-master/r/1255789
(cherry picked from commit d66af47b07b50d442ab85ae700a2de5a3fc151a1 in dev-kernel-3.10)
Reviewed-on: http://git-master/r/1257349
GVS: Gerrit_Virtual_Submit
Reviewed-by: Varun Wadekar <vwadekar@nvidia.com>

drivers/trusty/trusty.c
include/linux/trusty/smcall.h
include/linux/trusty/trusty.h

index bf21300..2c281ee 100644 (file)
@@ -44,12 +44,12 @@ struct trusty_state {
 #define SMC_REGISTERS_TRASHED  "ip"
 #endif
 
-static inline u32 smc(u32 r0, u32 r1, u32 r2, u32 r3)
+static inline ulong smc(ulong r0, ulong r1, ulong r2, ulong r3)
 {
-       register u32 _r0 asm(SMC_ARG0) = r0;
-       register u32 _r1 asm(SMC_ARG1) = r1;
-       register u32 _r2 asm(SMC_ARG2) = r2;
-       register u32 _r3 asm(SMC_ARG3) = r3;
+       register ulong _r0 asm(SMC_ARG0) = r0;
+       register ulong _r1 asm(SMC_ARG1) = r1;
+       register ulong _r2 asm(SMC_ARG2) = r2;
+       register ulong _r3 asm(SMC_ARG3) = r3;
 
        asm volatile(
                __asmeq("%0", SMC_ARG0)
@@ -74,17 +74,32 @@ s32 trusty_fast_call32(struct device *dev, u32 smcnr, u32 a0, u32 a1, u32 a2)
 
        BUG_ON(!s);
        BUG_ON(!SMC_IS_FASTCALL(smcnr));
+       BUG_ON(SMC_IS_SMC64(smcnr));
 
        return smc(smcnr, a0, a1, a2);
 }
 EXPORT_SYMBOL(trusty_fast_call32);
 
+#ifdef CONFIG_64BIT
+s64 trusty_fast_call64(struct device *dev, u64 smcnr, u64 a0, u64 a1, u64 a2)
+{
+       struct trusty_state *s = platform_get_drvdata(to_platform_device(dev));
+
+       BUG_ON(!s);
+       BUG_ON(!SMC_IS_FASTCALL(smcnr));
+       BUG_ON(!SMC_IS_SMC64(smcnr));
+
+       return smc(smcnr, a0, a1, a2);
+}
+#endif
+
 s32 trusty_std_call32(struct device *dev, u32 smcnr, u32 a0, u32 a1, u32 a2)
 {
        int ret;
        struct trusty_state *s = platform_get_drvdata(to_platform_device(dev));
 
        BUG_ON(SMC_IS_FASTCALL(smcnr));
+       BUG_ON(SMC_IS_SMC64(smcnr));
 
        mutex_lock(&s->smc_lock);
 
index 5b15348..cba6134 100644 (file)
 #define SMC_NUM_PARAMS         (SMC_NUM_ARGS - 1)
 
 #define SMC_IS_FASTCALL(smc_nr)        ((smc_nr) & 0x80000000)
+#define SMC_IS_SMC64(smc_nr)   ((smc_nr) & 0x40000000)
 #define SMC_ENTITY(smc_nr)     (((smc_nr) & 0x3F000000) >> 24)
 #define SMC_FUNCTION(smc_nr)   ((smc_nr) & 0x0000FFFF)
 
-#define SMC_NR(entity, fn, fastcall) ( (((fastcall) & 0x1) << 31) | \
-                                       (((entity) & 0x3F) << 24) | \
-                                       ((fn) & 0xFFFF) \
-                                    )
+#define SMC_NR(entity, fn, fastcall, smc64) ((((fastcall) & 0x1) << 31) | \
+                                            (((smc64) & 0x1) << 30) | \
+                                            (((entity) & 0x3F) << 24) | \
+                                            ((fn) & 0xFFFF) \
+                                           )
 
-#define SMC_FASTCALL_NR(entity, fn)    SMC_NR((entity), (fn), 1)
-#define SMC_STDCALL_NR(entity, fn)     SMC_NR((entity), (fn), 0)
+#define SMC_FASTCALL_NR(entity, fn)    SMC_NR((entity), (fn), 1, 0)
+#define SMC_STDCALL_NR(entity, fn)     SMC_NR((entity), (fn), 0, 0)
+#define SMC_FASTCALL64_NR(entity, fn)  SMC_NR((entity), (fn), 1, 1)
+#define SMC_STDCALL64_NR(entity, fn)   SMC_NR((entity), (fn), 0, 1)
 
 #define        SMC_ENTITY_ARCH                 0       /* ARM Architecture calls */
 #define        SMC_ENTITY_CPU                  1       /* CPU Service calls */
index 89f9907..ce00c1d 100644 (file)
@@ -20,6 +20,9 @@
 #ifdef CONFIG_TRUSTY
 s32 trusty_std_call32(struct device *dev, u32 smcnr, u32 a0, u32 a1, u32 a2);
 s32 trusty_fast_call32(struct device *dev, u32 smcnr, u32 a0, u32 a1, u32 a2);
+#ifdef CONFIG_64BIT
+s64 trusty_fast_call64(struct device *dev, u64 smcnr, u64 a0, u64 a1, u64 a2);
+#endif
 #else
 static inline s32 trusty_std_call32(struct device *dev, u32 smcnr,
                                    u32 a0, u32 a1, u32 a2)
@@ -31,6 +34,13 @@ static inline s32 trusty_fast_call32(struct device *dev, u32 smcnr,
 {
        return SM_ERR_UNDEFINED_SMC;
 }
+#ifdef CONFIG_64BIT
+static inline s64 trusty_fast_call64(struct device *dev,
+                                    u64 smcnr, u64 a0, u64 a1, u64 a2)
+{
+       return SM_ERR_UNDEFINED_SMC;
+}
+#endif
 #endif
 
 struct notifier_block;