fortanix / rust-sgx

The Fortanix Rust Enclave Development Platform
https://edp.fortanix.com
Mozilla Public License 2.0
433 stars 98 forks source link

Fix not FFI-safe `PageProperties` #539

Closed raoulstrackx closed 11 months ago

raoulstrackx commented 11 months ago

Compilation of sgxs-loaders results in following warning:

warning: `extern` fn uses type `defs::PageProperties`, which is not FFI-safe
   --> intel-sgx/sgxs-loaders/src/sgx_enclave_common/defs.rs:74:30
    |
74  |   pub type EnclaveLoadDataFn = unsafe extern "C" fn(
    |  ______________________________^
75  | |     target_address: *mut c_void,
76  | |     target_size: usize,
77  | |     source_buffer: *const Align4096<[u8; 4096]>,
78  | |     data_properties: PageProperties,
79  | |     enclave_error: Option<&mut u32>,
80  | | ) -> usize;
    | |__________^ not FFI-safe
    |
    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
    = note: this struct has unspecified layout
note: the type is defined here
   --> /home/raoul/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bitflags-1.2.1/src/lib.rs:345:14
    |
333 |   macro_rules! bitflags {
    |   --------------------- in this expansion of `bitflags!`
...
345 |               (pub) $BitFlags: $T {
    |  ______________^
346 | |                 $(
347 | |                     $(#[$inner $($args)*])*
348 | |                     $Flag = $value;
...   |
408 | |             bits: $T,
409 | |         }
    | |_________^
    |
   ::: intel-sgx/sgxs-loaders/src/sgx_enclave_common/defs.rs:38:1
    |
38  | / bitflags! {
39  | |     pub struct PageProperties: u32 {
40  | |         const R           = 0x00_01;
41  | |         const W           = 0x00_02;
...   |
45  | |     }
46  | | }
    | |_- in this macro invocation
    = note: `#[warn(improper_ctypes_definitions)]` on by default