2

I am trying to write a program that issues one SMC call. After searching the previous questions, it is my understanding that there is no real API within the Linux kernel for implementing ARM SMC? I am working on a prototype based on msm8974, and want to know what is the best way to do it.

I am still learning about section magic and how the linker maps assembly export 'tag'? Macros? ( Not sure what they are called ) to the C procedures. Please tell me if I really need to read through the GNU linker document to understand how that happens.

@Ross Ridge- Thanks. SMC, Secure Monitor Call, is an instruction to interface with the ARM Trust Zone service. My question is how to implement this call. Most of the posts and the answers here imply that such interface is not available on the Linux kernel tree yet. So, I know I have to write it in assembly. @Notlikethat - Hey man. I am using the different platfrom. What is involved at a highlevel to implement these other implementations for my platform, which is Qualcomm Snapdragon?

@Notlikethat - Here is what I see under /arch/arm/kerel:

sansari@ubuntu:~/WORKING_DIRECTORY/arch/arm/kernel$ ls
arch_timer.c    entry-common.S   kprobes-arm.c           perf_event_v6.c      suspend.c
armksyms.c      entry-header.S   kprobes.c               perf_event_v7.c      swp_emulate.c
arthur.c        etm.c            kprobes-common.c        perf_event_xscale.c  sys_arm.c
asm-offsets.c   fiqasm.S         kprobes.h               pj4-cp0.c            sys_oabi-compat.c
atags.c         fiq.c            kprobes-test-arm.c      pmu.c                tcm.c
atags.h         ftrace.c         kprobes-test.c          process.c            tcm.h
bios32.c        head-common.S    kprobes-test.h          ptrace.c             thumbee.c
calls.S         head-nommu.S     kprobes-test-thumb.c    relocate_kernel.S    time.c
compat.c        head.S           kprobes-thumb.c         return_address.c     topology.c
compat.h        hw_breakpoint.c  leds.c                  sched_clock.c        traps.c
cpuidle.c       init_task.c      machine_kexec.c         setup.c              unwind.c
crash_dump.c    insn.c           Makefile                signal.c             update_vsyscall_arm.c
debug.S         insn.h           module.c                signal.h             update_vsyscall_arm.h
devtree.c       io.c             opcodes.c               sleep.S              user_accessible_timer.c
dma.c           irq.c            patch.c                 smp.c                vmlinux.lds.S
dma-isa.c       isa.c            patch.h                 smp_scu.c            xscale-cp0.c
early_printk.c  iwmmxt.S         perf_event.c            smp_tlb.c
elf.c           jump_label.c     perf_event_msm.c        smp_twd.c
entry-armv.S    kgdb.c           perf_event_msm_krait.c  stacktrace.c

I need an updated kernel perhaps?

@Notlikethat - Would you please point me to the documentation on the implementations you mentioned EXINOS and ...?

@all- Thank you for your help and explanation. Arun - this definitely helps.

user3326293
  • 817
  • 1
  • 14
  • 37
  • You need to give a better description of what you're trying to accomplish. Most of your post is just guessing what the solution might be with random stabs in the dark. – Ross Ridge Jul 04 '15 at 22:22
  • 1
    It's really not clear what you're getting at here - what's all this stuff about bootloaders and linkers?. Issuing an SMC call, at its simplest, is no more than `asm volatile("smc #whatever");` - I know of at least 3 implementations already in the kernel (the PSCI code in arch/arm/kernel, and some Tegra and Exynos firmware drivers) that you could draw on. Or are you actually talking about writing the secure firmware to _handle_ that call? – Notlikethat Jul 04 '15 at 22:51
  • You still haven't explained what you're trying to accomplish. – Ross Ridge Jul 05 '15 at 00:00

1 Answers1

4

I believe there is a misunderstanding about the ARM trustzone implementation.

The whole execution environment is divided into Secure and Non-Secure worlds. Linux resides in the non-secure world. Usually a (safety) certified piece of code runs in the secure world. This secure image is usually released by the SoC vendor and cannot be tampered with.

The Secure code is loaded to secure memory before linux bootup. From then onward an SMC call acts as a bridge that takes the execution mode to the secure world. Calling an SMC takes the execution mode to Secure Monitor mode (that is implemented in the secure code) which is a higher privilege level and outside the linux kernel's purview.

As you cannot tamper with the SoC vendor's trustzone implementation you cannot add any new APIs to it. If you need to call an existing secure API, you need to know the calling conventions followed and API definition. If the SoC vendor provides these information you will be able to call an existing secure API.