Skip to content

Conversation

akirilov-arm
Copy link
Contributor

@akirilov-arm akirilov-arm commented May 31, 2022

Now the fiber implementation on AArch64 authenticates function return addresses and includes the relevant BTI instructions, except on macOS, following the guidelines presented in the bytecodealliance/rfcs#17 RFC proposal.

This PR has been spun off from #3606 and fixes #3183.

@akirilov-arm akirilov-arm requested a review from alexcrichton May 31, 2022 13:39
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:aarch64 Issues related to AArch64 backend. labels May 31, 2022
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me!

To confirm, have you had the chance to test this on macOS arm hardware as well? If not I'm sure @cfallin would be able to test this out.

@cfallin
Copy link
Member

cfallin commented May 31, 2022

To confirm, have you had the chance to test this on macOS arm hardware as well? If not I'm sure @cfallin would be able to test this out.

I can confirm that ./ci/run-tests.sh passes successfully on my M1 system.

@akirilov-arm
Copy link
Contributor Author

Thanks for testing my changes, @cfallin! Otherwise my main testing platform is an AWS Graviton3 instance that supports pointer authentication natively and that runs Ubuntu 20.04.

@alexcrichton
Copy link
Member

Hm CI timed out here for qemu emulation of AArch64 which we haven't seen before AFAIK, so that may actually be related to the changes here as well?

Now the fiber implementation on AArch64 authenticates function
return addresses and includes the relevant BTI instructions, except
on macOS.

Also, change the locations of the saved FP and LR registers on the
fiber stack to make them compliant with the Procedure Call Standard
for the Arm 64-bit Architecture.

Copyright (c) 2022, Arm Limited.
@akirilov-arm
Copy link
Contributor Author

@alexcrichton I have tried to elaborate on the most important technical details in the comments - please, let me know if you feel that there is anything else that warrants further explanation. Also, now this PR fixes #4226 and, finally, I have added a fix for a minor issue that I have noticed previously - I have changed the locations of the saved FP and LR registers on the fiber stack to improve compliance with the procedure call standard.

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for this!

@alexcrichton alexcrichton merged commit c15c306 into bytecodealliance:main Jun 9, 2022
@akirilov-arm akirilov-arm deleted the fiber_cfi branch June 9, 2022 15:20
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Jun 30, 2023
This resolves two issues from recent changes in bytecodealliance#6649:

* First the s390x calling convention for wasm functions is changed back
  to `WasmtimeSystemV` from `Fast`. This was an accidental omission from
  bytecodealliance#6649 where the conclusion was that s390x will continue using a
  calling convention with little-endian lane order for lane arguments.
  The only calling convention that supports this today is
  `WasmtimeSystemV`, although the `Tail` calling convention will likely
  use it in the future as well.

* Second the apple-aarch64 platform now uses the `Fast` calling
  convention instead of `AppleAarch64` calling convention. That
  convention was specified in bytecodealliance#4195 but local testing shows that is not
  necessary in the sense that tests all pass with the `Fast` calling
  convention. This means that the prior comment why the `AppleAarch64`
  calling convention is required is no longer accurate and in the
  absence of a reason not to I went ahead and switched it to `Fast`.

In the near future all wasm functions will unconditionally use the
`Tail` calling convention and at that time the lane order can be
specified on s390x to be little-endian to satisfy all the constraints
here. Additionally any unwinding directives, if necessary for aarch64,
can be specified as needed.
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Jul 5, 2023
This resolves two issues from recent changes in bytecodealliance#6649:

* First the s390x calling convention for wasm functions is changed back
  to `WasmtimeSystemV` from `Fast`. This was an accidental omission from
  bytecodealliance#6649 where the conclusion was that s390x will continue using a
  calling convention with little-endian lane order for lane arguments.
  The only calling convention that supports this today is
  `WasmtimeSystemV`, although the `Tail` calling convention will likely
  use it in the future as well.

* Second the apple-aarch64 platform now uses the `Fast` calling
  convention instead of `AppleAarch64` calling convention. That
  convention was specified in bytecodealliance#4195 but local testing shows that is not
  necessary in the sense that tests all pass with the `Fast` calling
  convention. This means that the prior comment why the `AppleAarch64`
  calling convention is required is no longer accurate and in the
  absence of a reason not to I went ahead and switched it to `Fast`.

In the near future all wasm functions will unconditionally use the
`Tail` calling convention and at that time the lane order can be
specified on s390x to be little-endian to satisfy all the constraints
here. Additionally any unwinding directives, if necessary for aarch64,
can be specified as needed.
github-merge-queue bot pushed a commit that referenced this pull request Jul 6, 2023
* Update calling conventions for wasm functions slightly

This resolves two issues from recent changes in #6649:

* First the s390x calling convention for wasm functions is changed back
  to `WasmtimeSystemV` from `Fast`. This was an accidental omission from
  #6649 where the conclusion was that s390x will continue using a
  calling convention with little-endian lane order for lane arguments.
  The only calling convention that supports this today is
  `WasmtimeSystemV`, although the `Tail` calling convention will likely
  use it in the future as well.

* Second the apple-aarch64 platform now uses the `Fast` calling
  convention instead of `AppleAarch64` calling convention. That
  convention was specified in #4195 but local testing shows that is not
  necessary in the sense that tests all pass with the `Fast` calling
  convention. This means that the prior comment why the `AppleAarch64`
  calling convention is required is no longer accurate and in the
  absence of a reason not to I went ahead and switched it to `Fast`.

In the near future all wasm functions will unconditionally use the
`Tail` calling convention and at that time the lane order can be
specified on s390x to be little-endian to satisfy all the constraints
here. Additionally any unwinding directives, if necessary for aarch64,
can be specified as needed.

* Fix compile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wasmtime doesn't work on Linux AArch64 with PAC enabled
3 participants