Skip to content

Commit

Permalink
Adding deprecation flags for SEV components and bumping to 5.1
Browse files Browse the repository at this point in the history
As discussed, adding deprecation flags for SEV components, so that it
can be removed in the next 6.0 release. Bumping to 5.1 so that people
can still use 5.0.0 without compilation warnings if they are using SEV.

Signed-off-by: DGonzalezVillal <[email protected]>
  • Loading branch information
DGonzalezVillal committed Nov 25, 2024
1 parent f892722 commit 0de11c9
Show file tree
Hide file tree
Showing 18 changed files with 176 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sev"
version = "5.0.0"
version = "5.1.0"
authors = [
"Nathaniel McCallum <[email protected]>",
"The VirTEE Project Developers",
Expand Down
4 changes: 4 additions & 0 deletions src/certs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// SPDX-License-Identifier: Apache-2.0

/// Legacy SEV certificates.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(feature = "sev")]
pub mod sev;

Expand Down
17 changes: 16 additions & 1 deletion src/certs/sev/builtin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,23 @@
//!
//! These are primarily offered as a convenience measure to avoid making
//! HTTP requests to AMD's servers.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
pub mod genoa;
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
pub mod milan;
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
pub mod naples;
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
pub mod rome;
1 change: 0 additions & 1 deletion src/certs/sev/ca/cert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::mem::size_of;

use serde::{de, ser};
use serde_bytes::{ByteBuf, Bytes};

/// An OCA certificate.
#[derive(Clone, Copy)]
#[repr(C)]
Expand Down
8 changes: 8 additions & 0 deletions src/certs/sev/ca/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

//! For operating on OCA certificates.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
mod cert;
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
mod chain;

pub use cert::Certificate;
Expand Down
32 changes: 26 additions & 6 deletions src/certs/sev/mod.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
// SPDX-License-Identifier: Apache-2.0

//! Everything needed for working with AMD SEV certificate chains.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
pub mod builtin;
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
pub mod ca;
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
mod chain;

#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(feature = "openssl")]
mod crypto;
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[allow(clippy::module_inception)]
pub mod sev;

#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(feature = "openssl")]
mod util;

#[cfg(feature = "openssl")]
mod crypto;

pub use chain::Chain;

use crate::util::*;
Expand Down
12 changes: 12 additions & 0 deletions src/firmware/linux/host/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
// SPDX-License-Identifier: Apache-2.0

#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(feature = "sev")]
mod sev;

#[cfg(feature = "snp")]
mod snp;

#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(feature = "sev")]
pub use self::sev::*;

Expand Down Expand Up @@ -48,6 +56,10 @@ impl<'a> GetId<'a> {
/// Reset the platform's persistent state.
///
/// (Chapter 5.5)
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(feature = "sev")]
#[cfg(target_os = "linux")]
pub struct PlatformReset;
4 changes: 4 additions & 0 deletions src/launch/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
//! Operations and types for launching on Linux
pub(crate) mod ioctl;

#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(feature = "sev")]
pub(crate) mod sev;

Expand Down
4 changes: 4 additions & 0 deletions src/launch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#[cfg(any(feature = "sev", feature = "snp"))]
mod linux;

#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(feature = "sev")]
pub mod sev;

Expand Down
59 changes: 58 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,19 @@ pub mod launch;
target_os = "linux"
))]
pub mod measurement;

#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(all(target_os = "linux", feature = "openssl", feature = "sev"))]
pub mod session;
mod util;

#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
pub mod vmsa;

/// Error module.
Expand Down Expand Up @@ -255,10 +265,18 @@ impl codicon::Encoder<()> for Build {
#[derive(Copy, Clone)]
pub enum Generation {
/// First generation EPYC (SEV).
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(feature = "sev")]
Naples,

/// Second generation EPYC (SEV, SEV-ES).
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(feature = "sev")]
Rome,

Expand Down Expand Up @@ -388,7 +406,6 @@ impl Generation {
}

// The C FFI interface to the library.

#[cfg(all(feature = "sev", target_os = "linux"))]
lazy_static! {
static ref INIT_MAP: Mutex<HashMap<RawFd, Launcher<New, RawFd, RawFd>>> =
Expand All @@ -401,6 +418,10 @@ lazy_static! {
Mutex::new(HashMap::new());
}

#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(all(feature = "sev", target_os = "linux"))]
fn set_fw_err(ptr: *mut c_int, err: FirmwareError) {
unsafe { *ptr = err.into() };
Expand All @@ -412,6 +433,10 @@ fn set_fw_err(ptr: *mut c_int, err: FirmwareError) {
///
/// The caller of this function is responsible for ensuring that the pointer arguments are
/// valid.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(all(feature = "sev", target_os = "linux"))]
#[no_mangle]
pub unsafe extern "C" fn sev_init(vm_fd: c_int, sev_fd: c_int, fw_err: *mut c_int) -> c_int {
Expand All @@ -438,6 +463,10 @@ pub unsafe extern "C" fn sev_init(vm_fd: c_int, sev_fd: c_int, fw_err: *mut c_in
///
/// The caller of this function is responsible for ensuring that the pointer arguments are
/// valid.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(all(feature = "sev", target_os = "linux"))]
#[no_mangle]
pub unsafe extern "C" fn sev_es_init(vm_fd: c_int, sev_fd: c_int, fw_err: *mut c_int) -> c_int {
Expand All @@ -464,6 +493,10 @@ pub unsafe extern "C" fn sev_es_init(vm_fd: c_int, sev_fd: c_int, fw_err: *mut c
///
/// The caller of this function is responsible for ensuring that the pointer arguments are
/// valid.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(all(feature = "sev", target_os = "linux"))]
#[no_mangle]
pub unsafe extern "C" fn sev_launch_start(
Expand Down Expand Up @@ -510,6 +543,10 @@ pub unsafe extern "C" fn sev_launch_start(
///
/// The caller of this function is responsible for ensuring that the pointer arguments are
/// valid.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(all(feature = "sev", target_os = "linux"))]
#[no_mangle]
pub unsafe extern "C" fn sev_launch_update_data(
Expand Down Expand Up @@ -539,6 +576,10 @@ pub unsafe extern "C" fn sev_launch_update_data(
///
/// The caller of this function is responsible for ensuring that the pointer arguments are
/// valid.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(all(feature = "sev", target_os = "linux"))]
#[no_mangle]
pub unsafe extern "C" fn sev_launch_update_vmsa(vm_fd: c_int, fw_err: *mut c_int) -> c_int {
Expand All @@ -565,6 +606,10 @@ pub unsafe extern "C" fn sev_launch_update_vmsa(vm_fd: c_int, fw_err: *mut c_int
///
/// The "measurement_data" argument should be a valid pointer able to hold the meausurement's
/// bytes. The measurement is 48 bytes in size.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(all(feature = "sev", target_os = "linux"))]
#[no_mangle]
pub unsafe extern "C" fn sev_launch_measure(
Expand Down Expand Up @@ -612,6 +657,10 @@ pub unsafe extern "C" fn sev_launch_measure(
///
/// The caller of this function is responsible for ensuring that the pointer arguments are
/// valid.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(all(feature = "sev", target_os = "linux"))]
#[no_mangle]
pub unsafe extern "C" fn sev_inject_launch_secret(
Expand Down Expand Up @@ -658,6 +707,10 @@ pub unsafe extern "C" fn sev_inject_launch_secret(
///
/// The caller of this function is responsible for ensuring that the pointer arguments are
/// valid.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(all(feature = "sev", target_os = "linux"))]
#[no_mangle]
pub unsafe extern "C" fn sev_launch_finish(vm_fd: c_int, fw_err: *mut c_int) -> c_int {
Expand Down Expand Up @@ -687,6 +740,10 @@ pub unsafe extern "C" fn sev_launch_finish(vm_fd: c_int, fw_err: *mut c_int) ->
///
/// The caller of this function is responsible for ensuring that the pointer arguments are
/// valid.
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(all(feature = "sev", target_os = "linux"))]
#[allow(unused_assignments)]
#[no_mangle]
Expand Down
4 changes: 4 additions & 0 deletions src/measurement/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ pub mod vcpu_types;
#[cfg(all(feature = "snp", feature = "openssl"))]
pub mod snp;

#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
#[cfg(all(feature = "sev", feature = "openssl"))]
pub mod sev;

Expand Down
8 changes: 8 additions & 0 deletions src/measurement/sev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ pub fn seves_calc_launch_digest(
Ok(launch_hash.finish())
}

#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
/// Arguments required to calculate the SEV measurement
pub struct SevMeasurementArgs<'a> {
/// Path to OVMF file
Expand All @@ -92,6 +96,10 @@ pub struct SevMeasurementArgs<'a> {
pub append: Option<&'a str>,
}

#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
/// Calculate an SEV launch digest
pub fn sev_calc_launch_digest(
sev_measurement: SevMeasurementArgs,
Expand Down
4 changes: 4 additions & 0 deletions src/measurement/vmsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ use std::{convert::TryFrom, fmt, str::FromStr};
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum SevMode {
/// SEV
#[deprecated(
since = "5.0.0",
note = "Legacy SEV features will no longer be included/supported in library versions past 5"
)]
Sev,
/// SEV-ES
SevEs,
Expand Down
Loading

0 comments on commit 0de11c9

Please sign in to comment.