0001
0002
0003
0004
0005 #include <linux/linkage.h>
0006 #include <linux/arm-smccc.h>
0007
0008 #include <asm/asm-offsets.h>
0009 #include <asm/assembler.h>
0010 #include <asm/thread_info.h>
0011
0012
0013
0014
0015
0016
0017
0018 SYM_FUNC_START(__arm_smccc_sve_check)
0019
0020 ldr_l x16, smccc_has_sve_hint
0021 cbz x16, 2f
0022
0023 get_current_task x16
0024 ldr x16, [x16, #TSK_TI_FLAGS]
0025 tbnz x16, #TIF_FOREIGN_FPSTATE, 1f // Any live FP state?
0026 tbnz x16, #TIF_SVE, 2f // Does that state include SVE?
0027
0028 1: orr x0, x0, ARM_SMCCC_1_3_SVE_HINT
0029
0030 2: ret
0031 SYM_FUNC_END(__arm_smccc_sve_check)
0032 EXPORT_SYMBOL(__arm_smccc_sve_check)
0033
0034 .macro SMCCC instr
0035 stp x29, x30, [sp, #-16]!
0036 mov x29, sp
0037 alternative_if ARM64_SVE
0038 bl __arm_smccc_sve_check
0039 alternative_else_nop_endif
0040 \instr #0
0041 ldr x4, [sp, #16]
0042 stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS]
0043 stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS]
0044 ldr x4, [sp, #24]
0045 cbz x4, 1f
0046 ldr x9, [x4, #ARM_SMCCC_QUIRK_ID_OFFS]
0047 cmp x9, #ARM_SMCCC_QUIRK_QCOM_A6
0048 b.ne 1f
0049 str x6, [x4, ARM_SMCCC_QUIRK_STATE_OFFS]
0050 1: ldp x29, x30, [sp], #16
0051 ret
0052 .endm
0053
0054
0055
0056
0057
0058
0059
0060 SYM_FUNC_START(__arm_smccc_smc)
0061 SMCCC smc
0062 SYM_FUNC_END(__arm_smccc_smc)
0063 EXPORT_SYMBOL(__arm_smccc_smc)
0064
0065
0066
0067
0068
0069
0070
0071 SYM_FUNC_START(__arm_smccc_hvc)
0072 SMCCC hvc
0073 SYM_FUNC_END(__arm_smccc_hvc)
0074 EXPORT_SYMBOL(__arm_smccc_hvc)
0075
0076 .macro SMCCC_1_2 instr
0077
0078 stp x1, x19, [sp, #-16]!
0079
0080
0081 mov x19, x0
0082
0083
0084 ldp x0, x1, [x19, #ARM_SMCCC_1_2_REGS_X0_OFFS]
0085 ldp x2, x3, [x19, #ARM_SMCCC_1_2_REGS_X2_OFFS]
0086 ldp x4, x5, [x19, #ARM_SMCCC_1_2_REGS_X4_OFFS]
0087 ldp x6, x7, [x19, #ARM_SMCCC_1_2_REGS_X6_OFFS]
0088 ldp x8, x9, [x19, #ARM_SMCCC_1_2_REGS_X8_OFFS]
0089 ldp x10, x11, [x19, #ARM_SMCCC_1_2_REGS_X10_OFFS]
0090 ldp x12, x13, [x19, #ARM_SMCCC_1_2_REGS_X12_OFFS]
0091 ldp x14, x15, [x19, #ARM_SMCCC_1_2_REGS_X14_OFFS]
0092 ldp x16, x17, [x19, #ARM_SMCCC_1_2_REGS_X16_OFFS]
0093
0094 \instr #0
0095
0096
0097 ldr x19, [sp]
0098
0099
0100 stp x0, x1, [x19, #ARM_SMCCC_1_2_REGS_X0_OFFS]
0101 stp x2, x3, [x19, #ARM_SMCCC_1_2_REGS_X2_OFFS]
0102 stp x4, x5, [x19, #ARM_SMCCC_1_2_REGS_X4_OFFS]
0103 stp x6, x7, [x19, #ARM_SMCCC_1_2_REGS_X6_OFFS]
0104 stp x8, x9, [x19, #ARM_SMCCC_1_2_REGS_X8_OFFS]
0105 stp x10, x11, [x19, #ARM_SMCCC_1_2_REGS_X10_OFFS]
0106 stp x12, x13, [x19, #ARM_SMCCC_1_2_REGS_X12_OFFS]
0107 stp x14, x15, [x19, #ARM_SMCCC_1_2_REGS_X14_OFFS]
0108 stp x16, x17, [x19, #ARM_SMCCC_1_2_REGS_X16_OFFS]
0109
0110
0111 ldp xzr, x19, [sp], #16
0112 ret
0113 .endm
0114
0115
0116
0117
0118
0119 SYM_FUNC_START(arm_smccc_1_2_hvc)
0120 SMCCC_1_2 hvc
0121 SYM_FUNC_END(arm_smccc_1_2_hvc)
0122 EXPORT_SYMBOL(arm_smccc_1_2_hvc)
0123
0124
0125
0126
0127
0128 SYM_FUNC_START(arm_smccc_1_2_smc)
0129 SMCCC_1_2 smc
0130 SYM_FUNC_END(arm_smccc_1_2_smc)
0131 EXPORT_SYMBOL(arm_smccc_1_2_smc)