10000 Add show commands for identifier and VCEK URL. by jplevyak · Pull Request #107 · virtee/sevctl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add show commands for identifier and VCEK URL. #107

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 1 commit into from
Feb 22, 2023
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
9 changes: 6 additions & 3 deletions docs/sevctl.1.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,14 @@ COMMANDS
*sevctl show*::
usage: sevctl show [flags || guests]

This command describes the state of the SEV platform. There are two
This command describes the state of the SEV platform. There are several
platform details to describe:

SEV platform flags: sevctl show flags
SEV guest inforation: sevctl show guests
SEV platform flags: sevctl show flags
SEV guest inforation: sevctl show guests
SEV platform identifier: sevctl show identifier
SEV SNP status: sevctl show snp-status
SEV SNP VCEK URL: sevctl show veck-url

options:
-h, --help Show a help message
Expand Down
38 changes: 37 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use codicon::*;

use ::sev::certs::*;
use ::sev::firmware::host::{
types::{PlatformStatusFlags, Status},
types::{PlatformStatusFlags, SnpStatus, Status},
Firmware,
};
use ::sev::Generation;
Expand Down Expand Up @@ -189,6 +189,13 @@ fn platform_status() -> Result<Status> {
.context("unable to fetch platform status")
}

fn snp_platform_status() -> Result<SnpStatus> {
firmware()?
.snp_platform_status()
.map_err(|e| anyhow::anyhow!(format!("{:?}", e)))
.context("unable to fetch snp platform status")
}

fn chain() -> Result<sev::Chain> {
const CEK_SVC: &str = "https://kdsintf.amd.com/cek/id";

Expand Down Expand Up @@ -273,6 +280,15 @@ mod show {
#[structopt(about = "Show the current number of guests")]
Guests,

#[structopt(about = "Show the platform identifier")]
Identifier,

#[structopt(about = "Show the SNP platform status")]
SnpStatus,

#[structopt(about = "Show the VCEK DER download URL")]
VcekUrl,

#[structopt(about = "Show the platform's firmware version")]
Version,
}
Expand All @@ -283,6 +299,26 @@ mod show {
match show {
Show::Version => println!("{}", status.build),
Show::Guests => println!("{}", status.guests),
Show::Identifier => {
let id = firmware()?
.get_identifier()
.map_err(|e| anyhow::anyhow!(format!("{:?}", e)))
.context("error fetching identifier")?;
println!("{}", id);
}
Show::SnpStatus => {
let snp_status = snp_platform_status()?;
println!("{:#?}", snp_status);
}
Show::VcekUrl => {
let id = firmware()?
.get_identifier()
.map_err(|e| anyhow::anyhow!(format!("{:?}", e)))
.context("error fetching identifier")?;
let snp_status = snp_platform_status()?;
println!("https://kdsintf.amd.com/vcek/v1/Milan/{}?blSPL={:02}&teeSPL={:02}&snpSPL={:02}&ucodeSPL={:02}",
id, snp_status.tcb.platform_version.bootloader, snp_status.tcb.platform_version.tee, snp_status.tcb.platform_version.snp, snp_status.tcb.platform_version.microcode);
}
Show::Flags => {
for f in [
PlatformStatusFlags::OWNED,
Expand Down
0