x64 0.16.2

x86_64 support with LA57 (5-level paging) for 57-bit virtual addresses
Documentation
name: Build

on:
  push:
    branches:
      - "master"
    tags:
      - "*"
  schedule:
    - cron: "40 4 * * *" # every day at 4:40
  pull_request:

permissions:
  contents: read

env:
  RUSTFLAGS: -Dwarnings
  RUSTDOCFLAGS: -Dwarnings

jobs:
  stable:
    name: "Test MSRV and Stable Features"
    strategy:
      matrix:
        rust:
          - nightly
          - 1.59
    runs-on: ubuntu-latest
    env:
      # rustup prioritizes environment variables over rust-toolchain.toml files.
      RUSTUP_TOOLCHAIN: ${{ matrix.rust }}
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}
      - run: cargo build --no-default-features --features instructions
      - run: cargo build --no-default-features --features memory_encryption
      - run: cargo build --no-default-features
      - run: cargo doc --no-default-features --features instructions
      - run: cargo doc --no-default-features --features memory_encryption
      - run: cargo doc --no-default-features
      - run: cargo test --no-default-features --features instructions
      - run: cargo test --no-default-features --features memory_encryption
      - run: cargo test --no-default-features

  test:
    name: "Test"

    strategy:
      fail-fast: false
      matrix:
        platform: [ubuntu-latest, macos-latest, windows-latest]

    runs-on: ${{ matrix.platform }}
    timeout-minutes: 15

    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
        with:
          targets: x86_64-unknown-linux-musl, i686-unknown-linux-musl, thumbv7em-none-eabihf

      - run: cargo build

      - run: cargo doc

      - run: cargo build --target x86_64-unknown-linux-musl
        if: runner.os == 'Linux'

      - run: cargo test

      - run: cargo test --target x86_64-unknown-linux-musl
        if: runner.os == 'Linux'

      - name: "Build on non x86_64 platforms"
        run: |

          cargo build --target i686-unknown-linux-musl --no-default-features --features nightly
          cargo build --target thumbv7em-none-eabihf --no-default-features --features nightly

      - run: cargo test --target i686-unknown-linux-musl --no-default-features --features nightly
        if: runner.os == 'Linux'

  bootloader-test:
    name: "Bootloader Integration Test"

    strategy:
      fail-fast: false
      matrix:
        platform: [ubuntu-latest, macos-latest, windows-latest]

    runs-on: ${{ matrix.platform }}
    timeout-minutes: 15

    steps:
      - name: "Checkout Repository"
        uses: actions/checkout@v6

      - name: Cache binaries
        id: cache-bin
        uses: actions/cache@v5
        with:
          path: binaries
          key: ${{ runner.OS }}-binaries
      - name: Add binaries/bin to PATH
        run: echo "$GITHUB_WORKSPACE/binaries/bin" >> $GITHUB_PATH
        shell: bash

      - uses: dtolnay/rust-toolchain@nightly
        with:
          targets: x86_64-unknown-none
          components: rust-src, llvm-tools
      - name: "Install bootimage"
        run: cargo install bootimage --debug --root binaries

        # install QEMU
      - name: Install QEMU (Linux)
        run: |

          sudo apt update
          sudo apt install qemu-system-x86
        if: runner.os == 'Linux'
      - name: Install QEMU (macOS)
        run: brew install qemu
        if: runner.os == 'macOS'
        env:
          HOMEBREW_NO_AUTO_UPDATE: 1
          HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 1
          HOMEBREW_NO_INSTALL_CLEANUP: 1
      - name: Install QEMU (Windows)
        run: |

          choco install qemu --version 2021.5.5
          echo "$Env:Programfiles\qemu" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
        if: runner.os == 'Windows'
        shell: pwsh

      - name: "Print QEMU Version"
        run: qemu-system-x86_64 --version

      - name: "Run Test Framework"
        run: cargo test --target x86_64-unknown-none
        shell: bash
        working-directory: "testing"
        env:
          RUSTFLAGS: -Crelocation-model=static -Dwarnings

  check_formatting:
    name: "Check Formatting"
    runs-on: ubuntu-latest
    timeout-minutes: 2
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: rustfmt
      - run: cargo fmt --all -- --check

  clippy:
    name: "Clippy"
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: clippy
      - run: cargo clippy

  semver-checks:
    name: Semver Checks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: Swatinem/rust-cache@v2
        with:
          shared-key: "semver-checks"
          cache-targets: false
      - run: cargo install cargo-semver-checks --locked
      - name: Check semver
        run: cargo +stable semver-checks check-release --default-features

  kani:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: Swatinem/rust-cache@v2
        with:
          shared-key: "kani"
          cache-targets: false
      - uses: model-checking/kani-github-action@v1.1