Skip to content

Commit e84dc59

Browse files
cjen1-msftachamayouCopilot
authored
Fix Turin cpuid (#7748)
Co-authored-by: Amaury Chamayou <amaury@xargs.fr> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 6344ccf commit e84dc59

2 files changed

Lines changed: 54 additions & 12 deletions

File tree

include/ccf/pal/sev_snp_cpuid.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,17 @@ namespace ccf::pal::snp
150150
switch (product)
151151
{
152152
case ProductName::Milan:
153+
// See Table 2 of "Revision Guide for 19h 00h-0Fh Processors"
154+
// https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/revision-guides/56683.pdf
153155
return "00a00f11";
154156
case ProductName::Genoa:
157+
// See Table 2 of "Revision Guide for 19h 10h-1Fh Processors"
158+
// https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/revision-guides/57095-PUB_1_01.pdf
155159
return "00a10f11";
156160
case ProductName::Turin:
157-
return "00b00f11";
161+
// See Table 2 of "Revision Guide for 1Ah 00h-0Fh Processors"
162+
// https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/revision-guides/58251.pdf
163+
return "00b00f21";
158164
default:
159165
throw std::logic_error(fmt::format(
160166
"SEV-SNP: Unsupported product for CPUID: {}", to_string(product)));

src/pal/test/snp_attestation_validation.cpp

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,13 @@ TEST_CASE("Mismatched attestation and endorsements fail")
9494
pal::PlatformAttestationMeasurement measurement;
9595
pal::PlatformAttestationReportData report_data;
9696

97-
try
98-
{
97+
CHECK_THROWS_WITH_AS(
9998
pal::verify_snp_attestation_report(
100-
mismatched_quote, measurement, report_data);
101-
}
102-
catch (const std::logic_error& e)
103-
{
104-
const std::string what = e.what();
105-
CHECK(
106-
what.find("SEV-SNP: The root of trust public key for this attestation "
107-
"was not the expected one") != std::string::npos);
108-
}
99+
mismatched_quote, measurement, report_data),
100+
doctest::Contains(
101+
"SEV-SNP: The root of trust public key for this attestation "
102+
"was not the expected one"),
103+
std::logic_error);
109104
}
110105

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

157+
TEST_CASE("CPUID product mapping roundtrip")
158+
{
159+
const std::vector<ccf::pal::snp::ProductName> products = {
160+
ccf::pal::snp::ProductName::Milan,
161+
ccf::pal::snp::ProductName::Genoa,
162+
ccf::pal::snp::ProductName::Turin,
163+
};
164+
165+
for (const auto product : products)
166+
{
167+
const auto cpuid_hex = ccf::pal::snp::get_cpuid_of_snp_sev_product(product);
168+
const auto cpuid = ccf::pal::snp::cpuid_from_hex(cpuid_hex);
169+
170+
CHECK_EQ(cpuid.hex_str(), cpuid_hex);
171+
CHECK_EQ(ccf::pal::snp::get_sev_snp_product(cpuid), product);
172+
CHECK_EQ(
173+
ccf::pal::snp::get_sev_snp_product(
174+
cpuid.get_family_id(), cpuid.get_model_id()),
175+
product);
176+
177+
switch (product)
178+
{
179+
case ccf::pal::snp::ProductName::Milan:
180+
CHECK_EQ(cpuid.get_family_id(), 0x19);
181+
CHECK_EQ(cpuid.get_model_id(), 0x01);
182+
break;
183+
case ccf::pal::snp::ProductName::Genoa:
184+
CHECK_EQ(cpuid.get_family_id(), 0x19);
185+
CHECK_EQ(cpuid.get_model_id(), 0x11);
186+
break;
187+
case ccf::pal::snp::ProductName::Turin:
188+
CHECK_EQ(cpuid.get_family_id(), 0x1A);
189+
CHECK_EQ(cpuid.get_model_id(), 0x02);
190+
break;
191+
default:
192+
FAIL("Unexpected SNP product");
193+
break;
194+
}
195+
}
196+
}
197+
162198
struct QuoteEndorsementsTestCase
163199
{
164200
std::vector<uint8_t> attestation;

0 commit comments

Comments
 (0)