Skip to content
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
8 changes: 7 additions & 1 deletion include/ccf/pal/sev_snp_cpuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,17 @@ namespace ccf::pal::snp
switch (product)
{
case ProductName::Milan:
// See Table 2 of "Revision Guide for 19h 00h-0Fh Processors"
// https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/revision-guides/56683.pdf
return "00a00f11";
case ProductName::Genoa:
// See Table 2 of "Revision Guide for 19h 10h-1Fh Processors"
// https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/revision-guides/57095-PUB_1_01.pdf
return "00a10f11";
case ProductName::Turin:
return "00b00f11";
// See Table 2 of "Revision Guide for 1Ah 00h-0Fh Processors"
// https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/revision-guides/58251.pdf
return "00b00f21";
default:
throw std::logic_error(fmt::format(
"SEV-SNP: Unsupported product for CPUID: {}", to_string(product)));
Expand Down
58 changes: 47 additions & 11 deletions src/pal/test/snp_attestation_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,13 @@ TEST_CASE("Mismatched attestation and endorsements fail")
pal::PlatformAttestationMeasurement measurement;
pal::PlatformAttestationReportData report_data;

try
{
CHECK_THROWS_WITH_AS(
pal::verify_snp_attestation_report(
mismatched_quote, measurement, report_data);
}
catch (const std::logic_error& e)
{
const std::string what = e.what();
CHECK(
what.find("SEV-SNP: The root of trust public key for this attestation "
"was not the expected one") != std::string::npos);
}
mismatched_quote, measurement, report_data),
doctest::Contains(
"SEV-SNP: The root of trust public key for this attestation "
"was not the expected one"),
std::logic_error);
}

TEST_CASE("Parsing of Tcb versions from strings")
Expand Down Expand Up @@ -159,6 +154,47 @@ TEST_CASE("Parsing tcb versions from attestaion")
CHECK_EQ(milan_tcb.boot_loader, 0x04);
}

TEST_CASE("CPUID product mapping roundtrip")
{
const std::vector<ccf::pal::snp::ProductName> products = {
ccf::pal::snp::ProductName::Milan,
ccf::pal::snp::ProductName::Genoa,
ccf::pal::snp::ProductName::Turin,
};

for (const auto product : products)
{
const auto cpuid_hex = ccf::pal::snp::get_cpuid_of_snp_sev_product(product);
const auto cpuid = ccf::pal::snp::cpuid_from_hex(cpuid_hex);

CHECK_EQ(cpuid.hex_str(), cpuid_hex);
CHECK_EQ(ccf::pal::snp::get_sev_snp_product(cpuid), product);
CHECK_EQ(
ccf::pal::snp::get_sev_snp_product(
cpuid.get_family_id(), cpuid.get_model_id()),
product);

switch (product)
{
case ccf::pal::snp::ProductName::Milan:
CHECK_EQ(cpuid.get_family_id(), 0x19);
CHECK_EQ(cpuid.get_model_id(), 0x01);
break;
case ccf::pal::snp::ProductName::Genoa:
CHECK_EQ(cpuid.get_family_id(), 0x19);
CHECK_EQ(cpuid.get_model_id(), 0x11);
break;
case ccf::pal::snp::ProductName::Turin:
CHECK_EQ(cpuid.get_family_id(), 0x1A);
CHECK_EQ(cpuid.get_model_id(), 0x02);
break;
default:
FAIL("Unexpected SNP product");
break;
}
}
}

struct QuoteEndorsementsTestCase
{
std::vector<uint8_t> attestation;
Expand Down