Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mach ports continued + support aarch64-apple unwinding #2723

Merged
merged 6 commits into from
Mar 17, 2021

Commits on Mar 17, 2021

  1. Switch macOS to using mach ports for trap handling

    This commit moves macOS to using mach ports instead of signals for
    handling traps. The motivation for this is listed in bytecodealliance#2456, namely that
    once mach ports are used in a process that means traditional UNIX signal
    handlers won't get used. This means that if Wasmtime is integrated with
    Breakpad, for example, then Wasmtime's trap handler never fires and
    traps don't work.
    
    The `traphandlers` module is refactored as part of this commit to split
    the platform-specific bits into their own files (it was growing quite a
    lot for one inline `cfg_if!`). The `unix.rs` and `windows.rs` files
    remain the same as they were before with a few minor tweaks for some
    refactored interfaces. The `macos.rs` file is brand new and lifts almost
    its entire implementation from SpiderMonkey, adapted for Wasmtime
    though.
    
    The main gotcha with mach ports is that a separate thread is what
    services the exception. Some unsafe magic allows this separate thread to
    read non-`Send` and temporary state from other threads, but is hoped to
    be safe in this context. The unfortunate downside is that calling wasm
    on macOS now involves taking a global lock and modifying a global hash
    map twice-per-call. I'm not entirely sure how to get out of this cost
    for now, but hopefully for any embeddings on macOS it's not the end of
    the world.
    
    Closes bytecodealliance#2456
    alexcrichton authored and bnjbvr committed Mar 17, 2021
    Configuration menu
    Copy the full SHA
    f460efd View commit details
    Browse the repository at this point in the history
  2. Add a sketch of arm64 apple support

    alexcrichton authored and bnjbvr committed Mar 17, 2021
    Configuration menu
    Copy the full SHA
    687e08b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7bb96dd View commit details
    Browse the repository at this point in the history
  4. cranelift/aarch64: generate unwind directives to disable pointer auth

    Aarch64 post ARMv8.3 has a feature called pointer authentication,
    designed to fight ROP/JOP attacks: some pointers may be signed using new
    instructions, adding payloads to the high (previously unused) bits of
    the pointers. More on this here: https://lwn.net/Articles/718888/
    
    Unwinders on aarch64 need to know if some pointers contained on the call
    frame contain an authentication code or not, to be able to properly
    authenticate them or use them directly. Since native code may have
    enabled it by default (as is the case on the Mac M1), and the default is
    that this configuration value is inherited, we need to explicitly
    disable it, for the only kind of supported pointers (return addresses).
    
    To do so, we set the value of a non-existing dwarf pseudo register (34)
    to 0, as documented in
    https://github.com/ARM-software/abi-aa/blob/master/aadwarf64/aadwarf64.rst#note-8.
    
    This is done at the function granularity, in the spirit of Cranelift
    compilation model. Alternatively, a single directive could be generated
    in the CIE, generating less information per module.
    bnjbvr committed Mar 17, 2021
    Configuration menu
    Copy the full SHA
    1186c0d View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    931577c View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    8fa9859 View commit details
    Browse the repository at this point in the history