Skip to content

Fix AArch64 build #243

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

Merged
merged 3 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,27 @@ on:
- cron: '0 0 * * 0-6'

jobs:
build:
name: Build on AArch64
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rust-src
# TODO: cache Rust binaries

- name: Build
run: ./build.py build --target aarch64
working-directory: ./uefi-test-runner

build_and_test:
name: Build and run tests
name: Build and run tests on x86_64
runs-on: ubuntu-latest
steps:
- name: Checkout sources
Expand Down
39 changes: 30 additions & 9 deletions src/proto/shim/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
//! Shim lock protocol.

#![cfg(any(
target_arch = "i386",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"
))]

use crate::proto::Protocol;
use crate::result::Error;
use crate::{unsafe_guid, Result, Status};
Expand Down Expand Up @@ -36,6 +43,18 @@ pub struct Hashes {
pub sha1: [u8; SHA1_DIGEST_SIZE],
}

// These macros set the correct calling convention for the Shim protocol methods.

#[cfg(any(target_arch = "i386", target_arch = "x86_64"))]
macro_rules! shim_function {
(fn $args:tt -> $return_type:ty) => (extern "sysv64" fn $args -> $return_type)
}

#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
macro_rules! shim_function {
(fn $args:tt -> $return_type:ty) => (extern "C" fn $args -> $return_type)
}

/// The Shim lock protocol.
///
/// This protocol is not part of the UEFI specification, but is
Expand All @@ -50,15 +69,17 @@ pub struct Hashes {
#[unsafe_guid("605dab50-e046-4300-abb6-3dd810dd8b23")]
#[derive(Protocol)]
pub struct ShimLock {
verify: extern "sysv64" fn(buffer: *const u8, size: u32) -> Status,
hash: extern "sysv64" fn(
buffer: *const u8,
size: u32,
context: *mut Context,
sha256: *mut [u8; SHA256_DIGEST_SIZE],
sha1: *mut [u8; SHA1_DIGEST_SIZE],
) -> Status,
context: extern "sysv64" fn(buffer: *const u8, size: u32, context: *mut Context) -> Status,
verify: shim_function! { fn(buffer: *const u8, size: u32) -> Status },
hash: shim_function! {
fn(
buffer: *const u8,
size: u32,
context: *mut Context,
sha256: *mut [u8; SHA256_DIGEST_SIZE],
sha1: *mut [u8; SHA1_DIGEST_SIZE]
) -> Status
},
context: shim_function! { fn(buffer: *const u8, size: u32, context: *mut Context) -> Status },
}

impl ShimLock {
Expand Down
6 changes: 4 additions & 2 deletions uefi-test-runner/aarch64-unknown-uefi.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
"/machine:arm64"
]
},
"stack_probes": true,
"stack-probes": {
"kind": "call"
},
"target-c-int-width": "32",
"target-endian": "little",
"target-pointer-width": "64"
}
}
13 changes: 13 additions & 0 deletions uefi-test-runner/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ pub fn test(st: &mut SystemTable<Boot>) {
debug::test(bt);
media::test(bt);
pi::test(bt);

#[cfg(any(
target_arch = "i386",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"
))]
shim::test(bt);
}

Expand All @@ -33,4 +40,10 @@ mod console;
mod debug;
mod media;
mod pi;
#[cfg(any(
target_arch = "i386",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"
))]
mod shim;