Skip to content

Commit

Permalink
Fix MacOS and Windows compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
heavenboy8 authored and ThibsG committed Mar 8, 2024
1 parent 0e15b31 commit a951b90
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 90 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ on: [push, pull_request]
name: test
jobs:
sw-openssl:
name: sw openssl ${{ matrix.toolchain }} ${{ matrix.profile.name }} ${{ matrix.features }}
runs-on: ubuntu-latest
name: sw openssl ${{ matrix.runner }} ${{ matrix.toolchain }} ${{ matrix.profile.name }} ${{ matrix.features }}
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -14,6 +14,9 @@ jobs:
strategy:
fail-fast: false
matrix:
runner:
- ubuntu-latest
- macos-12
toolchain:
- 1.70.0
- stable
Expand All @@ -25,8 +28,8 @@ jobs:
- openssl

sw-crypto_nossl:
name: sw crypto_nossl ${{ matrix.toolchain }} ${{ matrix.profile.name }} ${{ matrix.features }}
runs-on: ubuntu-latest
name: sw crypto_nossl ${{ matrix.runner }} ${{ matrix.toolchain }} ${{ matrix.profile.name }} ${{ matrix.features }}
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -36,6 +39,10 @@ jobs:
strategy:
fail-fast: false
matrix:
runner:
- ubuntu-latest
- macos-12
- windows-latest
toolchain:
- 1.70.0
- stable
Expand Down
73 changes: 37 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ x509-cert = { version = "0.2.5", optional = true }
byteorder = "1.4.3"
base64 = "0.22.0"

[dev-dependencies]
[target.'cfg(target_os = "linux")'.dev-dependencies]
kvm-ioctls = ">=0.12"

[dev-dependencies]
kvm-bindings = ">=0.6"
serial_test = "3.0"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Firmware (SNP)] (https://www.amd.com/content/dam/amd/en/documents/epyc-technical

### SEV APIs

The Linux kernel exposes two technically distinct AMD SEV APIs:
The linux kernel exposes two technically distinct AMD SEV APIs:

1. An API for managing the SEV platform itself
2. An API for managing SEV-enabled KVM virtual machines
Expand All @@ -21,7 +21,7 @@ code through a flexible and type-safe high-level interface.

### SNP ABIs

Like SEV, the Linux kernel exposes another two different AMD SEV-SNP ABIs:
Like SEV, the linux kernel exposes another two different AMD SEV-SNP ABIs:

1. An ABI for managing the SEV-SNP platform itself
2. An ABI for managing SEV-SNP enabled KVM virtual machines
Expand Down Expand Up @@ -62,7 +62,7 @@ and enabling both at the same time leads to a compiler error.

### Remarks

Note that the Linux kernel provides access to these APIs through a set
Note that the linux kernel provides access to these APIs through a set
of `ioctl`s that are meant to be called on device nodes (`/dev/kvm` and
`/dev/sev`, to be specific). As a result, these `ioctl`s form the substrate
of the `sev` crate. Binaries that result from consumers of this crate are
Expand Down
7 changes: 6 additions & 1 deletion src/firmware/host/types/snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ pub use crate::firmware::linux::host::types::RawData;

pub(crate) use crate::firmware::linux::host as FFI;

use crate::{firmware::host::CertError, Version};
use crate::Version;

#[cfg(target_os = "linux")]
use crate::error::CertError;

use std::{
convert::{TryFrom, TryInto},
Expand Down Expand Up @@ -172,11 +175,13 @@ impl CertTableEntry {
}

/// Builds a Kernel formatted CertTable for sending the certificate content to the PSP.
#[cfg(target_os = "linux")]
pub fn cert_table_to_vec_bytes(table: &[Self]) -> Result<Vec<u8>, CertError> {
FFI::types::CertTableEntry::uapi_to_vec_bytes(table)
}

/// Takes in bytes in kernel CertTable format and returns in user API CertTable format.
#[cfg(target_os = "linux")]
pub fn vec_bytes_to_cert_table(bytes: &mut [u8]) -> Result<Vec<Self>, CertError> {
let cert_bytes_ptr: *mut FFI::types::CertTableEntry =
bytes.as_mut_ptr() as *mut FFI::types::CertTableEntry;
Expand Down
3 changes: 3 additions & 0 deletions src/firmware/linux/host/types/snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::error::CertError;

use crate::firmware::host as UAPI;

#[cfg(target_os = "linux")]
use uuid::Uuid;

/// Raw certificate bytes (by pointer or Vec<u8>).
Expand Down Expand Up @@ -163,6 +164,7 @@ impl CertTableEntry {
/// };
/// ```
///
#[cfg(target_os = "linux")]
pub unsafe fn parse_table(
mut data: *mut CertTableEntry,
) -> Result<Vec<UAPI::CertTableEntry>, uuid::Error> {
Expand Down Expand Up @@ -305,6 +307,7 @@ mod test {
}
}

#[cfg(target_os = "linux")]
mod cert_table_entry {

use crate::firmware::host as UAPI;
Expand Down
Loading

0 comments on commit a951b90

Please sign in to comment.