Generation

Enum Generation 

Source
pub enum Generation {
    Naples,
    Rome,
    Milan,
    Genoa,
    Turin,
}
Expand description

A representation for EPYC generational product lines.

Implements type conversion traits to determine which generation a given SEV certificate chain corresponds to. This is helpful for automatically detecting what platform code is running on, as one can simply export the SEV certificate chain and attempt to produce a Generation from it with the TryFrom trait.

§Example


// NOTE: The conversion traits require the `sev` crate to have the
// `openssl` feature enabled.

use std::convert::TryFrom;
use sev::certs::sev::Usage;
use sev::firmware::host::types::Firmware;
use sev::Generation;

let mut firmware = Firmware::open().expect("failed to open /dev/sev");

let chain = firmware.pdh_cert_export()
    .expect("unable to export SEV certificates");

let id = firmware.get_identifier().expect("error fetching identifier");

// NOTE: Requesting a signed CEK from AMD's KDS has been omitted for
// brevity.

let generation = Generation::try_from(&chain).expect("not a SEV/ES chain");
match generation {
    Generation::Naples => println!("Naples"),
    Generation::Rome => println!("Rome"),
}

Variants§

§

Naples

First generation EPYC (SEV).

§

Rome

Second generation EPYC (SEV, SEV-ES).

§

Milan

Third generation EPYC (SEV, SEV-ES, SEV-SNP).

§

Genoa

Fourth generation EPYC (SEV, SEV-ES, SEV-SNP).

§

Turin

Fifth generation EPYC (SEV, SEV-ES, SEV-SNP).

Implementations§

Source§

impl Generation

Source

pub fn identify_cpu(family: u8, model: u8) -> Result<Self, Error>

Identify the SEV generation based on the CPU family and model.

Source

pub fn identify_host_generation() -> Result<Self, Error>

Identify the EPYC processor generation based on the CPUID instruction.

Source§

impl Generation

Source

pub fn titlecase(&self) -> String

Create a title-cased string identifying the SEV generation.

Trait Implementations§

Source§

impl Clone for Generation

Source§

fn clone(&self) -> Generation

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl From<Generation> for Chain

Source§

fn from(generation: Generation) -> CertSevCaChain

Converts to this type from the input type.
Source§

impl TryFrom<&[u8]> for Generation

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<(u8, u8)> for Generation

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(val: (CpuFamily, CpuModel)) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<String> for Generation

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(val: String) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Generation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.