ARM DEN0028A SMC Calling Convention
ARM DEN0028A SMC Calling Convention
ARM DEN0028A SMC Calling Convention
Page 1 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
System Software on ARM Platforms
Copyright © 2013 ARM Limited. All rights reserved.
Release information
The Release History table lists the releases of this document.
Page 2 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
1 ABOUT THIS DOCUMENT 4
1.1 Introduction 4
1.2 References 4
1.3 Terms and abbreviations 5
Page 3 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
1.1 Introduction
This document defines a common calling mechanism for use with the Secure Monitor Call (SMC)
instruction in both the ARMv7 and ARMv8 architectures.
The SMC instruction is used to generate a synchronous exception that is handled by Secure Monitor
code running in EL3. The arguments are passed in registers and then used to select which Secure
function to execute. These calls may then be passed on to a Trusted OS in S-EL1.
This specification aims to ease integration and reduce fragmentation between software layers, such as
Operating Systems, Hypervisors, Trusted OS, Secure Monitor and System Firmware.
Note: This document is defined with respect to the ARMv8 Exception levels, EL0 to EL3.
The relationship between these and the 32-bit ARMv7 Exception levels is described in [2].
1.2 References
This document refers to the following documents.
Ref Doc No Author(s) Title
[1] ARM DDI 0406 ARM ARM® Architecture Reference Manual
ARMv7-A and ARMv7-R edition
[2] ARM DDI 0487 ARM ARM® Architecture Reference Manual, ARMv8,
for ARMv8-A architecture profile
Note: Document under development, release
expected Q3-2013
[3] ARM IHI 0042 ARM Procedure Call Standard for the ARM 32-bit
Architecture
[4] ARM IHI 0055 ARM Procedure Call Standard for the ARM 64-bit
Architecture
[5] ARM DEN 022 ARM Power State Coordination Interface
Page 4 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
Page 5 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
The additional asynchronous infrastructure required for pre-emptible Standard Calls is outside of the
scope of this specification.
Page 6 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
Page 7 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
Note: Unused result and scratch registers can leak information after an SMC call. An implementation
can mitigate this risk by either preserving the register state over the call, or returning a constant
value, such as zero, in each register.
Note: SMC32 calls from AArch32 and AArch64 use the same physical registers for arguments and
results, since registers W0-W7 in AArch64 are equivalent to R0-R7 in AArch32.
Page 8 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
The hypervisor client ID is expected to be created within the hypervisor and used to register, reference
and de-register client operating systems to a Trusted OS. Is not expected to correspond to the VMIDs
used by the MMU.
All SMC calls generated by software executing at EL1 should be trapped by the hypervisor. Identification
information should be inserted into R7 or W7 before forwarding any SMC call on to the Secure Monitor.
It is expected that the Session ID is provided by the Trusted OS, and is used by its clients in subsequent
calls.
Page 9 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
For more information see [4] Procedure Call Standard for the ARM 64-bit Architecture
Page 10 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
Note: ARM recognizes that a number of vendors already use a proprietary calling convention and won’t
be able to meet all of the following requirements.
For more information see [3] Procedure Call Standard for the ARM 32-bit Architecture.
Page 11 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
Note: The Unknown SMC Function Identifier should not be used to discover the presence, or lack of, an
SMC Function. SMC Function Identifiers should be determined from the UID and Revision
information.
Register Value
AArch32 AArch64
R0 W0 Bytes 0…3 with byte 0 in the low order bits
R1 W1 Bytes 4…7 with byte 4 in the low order bits
R2 W2 Bytes 8…11 with byte 8 in the low order bits
R3 W3 Bytes 12…15 with byte 12 in the low order bits
UIDs with the first 32-bits set to 0xFFFFFFFF (i.e. the value of R0 or W0) should be avoided since they
are indistinguishable from Unknown SMC Function Identifiers (see section 0).
Page 12 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
Page 13 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
All Function Identifier ranges not listed in this table are reserved.
Page 14 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
The ARM Architecture Calls provide interfaces to generic services for the ARM Architecture.
Page 15 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
The CPU Service Calls provide interfaces to CPU implementation-specific services for this platform. Such
as access to errata work-arounds.
The SiP Service Calls provide interfaces to SoC implementation specific services on this platform.
For example, Secure platform initialization, configuration and some power control.
Page 16 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
The OEM Service Calls provide interfaces to OEM-specific services on this platform.
Page 17 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
ARM intends to define a set of standard Service Calls for the management of the overall system. By
standardizing such calls the job of implementing Operating Systems on ARM will be made easier.
The first of these standards is the Power State Coordination Interface [5].
Note: Standard Service identifiers need to be understood by a Hypervisor when it traps SMC calls
because it must know which SMC calls are for power control and similar operations so that it can
emulate these calls for its clients.
Page 18 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential
SMC Calling Convention
Note: It is the responsibility of a Trusted OS to identify and describe services provided by Trusted
Applications
Page 19 of 19 Copyright © 2013 ARM Limited. All rights reserved. ARM DEN 0028A (0.9.0)
Non-Confidential