You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Morello] Change the PCS to pass memory arguments through C9
instead of passing them on the stack.
In practice for non-compartment calls the arguments are
still passed on the stack, although now there is no explicit
requirement for this.
Variadic arguments are still passed through C9 in the same
way, at the first 16-byte aligned location after the last
non-variadic argument.
This is done is such a way that reading more variadic
arguments than were passed is guaranteed to cause an
out-of-bounds fault.
Implements #158.
@@ -420,7 +420,7 @@ Additionally, a stack-pointer register, SP in a 64-bit context or CSP in a capab
420
420
421
421
The first eight registers, r0-r7, are used to pass argument values into a subroutine and to return result values from a function. They may also be used to hold intermediate values within a routine (but, in general, only between subroutine calls).
422
422
423
-
In AAPCS64-cap the r9 register is used to pass anonymous arguments in variadic calls.
423
+
In AAPCS64-cap the r9 register is used to pass arguments through memory.
424
424
425
425
Registers r16 (IP0/CIP0) and r17 (IP1/CIP1) may be used by a linker as a scratch register between a routine and any subroutine it calls (for details, see `Use of CIP0 and CIP1 by the linker`_). They can also be used within a routine to hold intermediate values between subroutine calls.
426
426
@@ -446,7 +446,7 @@ Processes, Memory and the Stack
446
446
The Stack in AAPCS64-cap
447
447
^^^^^^^^^^^^^^^^^^^^^^^^
448
448
449
-
The stack is a contiguous area of memory that may be used for storage of local variables and, when there are insufficient argument registers available, for passing additional arguments to subroutines .
449
+
The stack is a contiguous area of memory that may be used for storage of local variables. Memory passed arguments may be allocated on the stack, although this is not mandatory.
450
450
451
451
The stack implementation is full-descending, with the current extent of the stack held in the special-purpose register CSP. The stack will have both a base and a limit, and an application can get these values by observing the base and limit of CSP.
452
452
@@ -496,7 +496,12 @@ The A64 and C64 branch instructions are unable to reach every destination in the
496
496
Parameter Passing
497
497
-----------------
498
498
499
-
The base standard provides for passing arguments in general-purpose registers (r0-r7), SIMD/floating-point registers (v0-v7) and on the stack. For subroutines that take a small number of small parameters, only registers are used.
499
+
The base standard provides for passing arguments in general-purpose registers (r0-r7), SIMD/floating-point registers (v0-v7) and in memory. For subroutines that take a small number of small parameters, only registers are used.
500
+
501
+
Memory passed parameters
502
+
^^^^^^^^^^^^^^^^^^^^^^^^
503
+
504
+
We define an argument as being memory passed if it copied to memory as part of Stage C from `Parameter Passing Rules`_. The addres of a memory passed argument is the address of the memory location where the argument was copied to as part of Stage C from `Parameter Passing Rules`_.
500
505
501
506
Parameter Passing Rules
502
507
^^^^^^^^^^^^^^^^^^^^^^^
@@ -521,22 +526,22 @@ The differences in language bindings used for AAPCS64 and AAPCS64-cap are descri
The Arguments Capability is a capability that has the bounds of the arguments memory area and its address will be that of the first memory passed argument. The address of the Arguments Capability is 16-byte aligned. The capability offset of the Arguments Capability may not be zero. The capability offset is such that the first 16-byte aligned location after the last memory passed argument will be larger or equal than capability limit of the Arguments Capability.
543
+
544
+
540
545
.. rubric:: Stage B – Pre-padding and extension of arguments
541
546
542
547
.. class:: aapcs64-morello-parameter-passing
@@ -593,7 +598,7 @@ The differences in language bindings used for AAPCS64 and AAPCS64-cap are descri
In AAPCS64-cap all Anonymous arguments are memory passed.
695
701
696
-
In AAPCS64-cap if the callee is variadic and there are fewer than 4096 Anonymous arguments, the length of C9 divided by 16 is equal to the number of Anonymous arguments. The length of C9 divided by 16 is always greater or equal to the number of Anonymous arguments.
702
+
.. note::
703
+
In AAPCS64-cap if the callee is variadic the number of Anonymous arguments is equal to (length(C)-offset(C)/16) where C is the adjusted value of C9 that has the address of the first Anonymous Argument.
697
704
698
705
Result Return
699
706
-------------
@@ -799,7 +806,7 @@ Languages such as C and C++ permit routines that take a variable number of argum
799
806
The va_list type
800
807
----------------
801
808
802
-
The ``va_list`` type may refer to any parameter in a parameter list. All Anonymous parameters are passed on the stack in AAPCS64-cap.
809
+
The ``va_list`` type may refer to any parameter in a parameter list. All Anonymous parameters are passed in memory in AAPCS64-cap.
803
810
804
811
.. code-block:: c
805
812
@@ -808,7 +815,7 @@ The ``va_list`` type may refer to any parameter in a parameter list. All Anonymo
808
815
The va_start() macro
809
816
--------------------
810
817
811
-
The ``va_start`` macro shall initialize the ``va_list`` argument to the value of C9 as seen in the entry of the callee.
818
+
The ``va_start`` macro shall initialize the ``va_list`` argument to the value of derived from C9 with the address of the first Anonymous argument.
0 commit comments