Skip to content

Commit 43f7581

Browse files
authored
Merge pull request #158 from deeglaze/v4
Account for version 4 report from FW 1.55.31
2 parents 65042de + b8d75ce commit 43f7581

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

abi/abi.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,14 @@ const (
132132
// ReportVersion2 is set by the SNP API specification
133133
// https://web.archive.org/web/20231222054111if_/http://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/specifications/56860.pdf
134134
ReportVersion2 = 2
135+
// MinSupportedReportVersion is the lowest attestation report version that this library supports.
136+
MinSupportedReportVersion = 2
135137

136138
// ReportVersion3 is set by the SNP API specification
137139
// https://www.amd.com/system/files/TechDocs/56860.pdf
138140
ReportVersion3 = 3
141+
// MaxSupportedReportVersion is the highest attestation report version that this library supports.
142+
MaxSupportedReportVersion = 4
139143
)
140144

141145
// CertTableHeaderEntry defines an entry of the beginning of an extended attestation report which
@@ -502,7 +506,7 @@ func ReportToProto(data []uint8) (*pb.Report, error) {
502506
r.ReportedTcb = binary.LittleEndian.Uint64(data[0x180:0x188])
503507

504508
mbzLo := 0x188
505-
if r.Version == ReportVersion3 {
509+
if r.Version >= ReportVersion3 {
506510
mbzLo = 0x18B
507511
r.Cpuid1EaxFms = FmsToCpuid1Eax(data[0x188], data[0x189], data[0x18A])
508512
}
@@ -603,8 +607,8 @@ func ValidateReportFormat(r []byte) error {
603607
}
604608

605609
version := binary.LittleEndian.Uint32(r[0x00:0x04])
606-
if version != ReportVersion2 && version != ReportVersion3 {
607-
return fmt.Errorf("report version is: %d. Expected %d or %d", version, ReportVersion2, ReportVersion3)
610+
if version < MinSupportedReportVersion || version > MaxSupportedReportVersion {
611+
return fmt.Errorf("report version is: %d. Expected between %d and %d", version, MinSupportedReportVersion, MaxSupportedReportVersion)
608612
}
609613

610614
policy := binary.LittleEndian.Uint64(r[0x08:0x10])
@@ -649,7 +653,7 @@ func ReportToAbiBytes(r *pb.Report) ([]byte, error) {
649653
binary.LittleEndian.PutUint64(data[0x180:0x188], r.ReportedTcb)
650654

651655
// Add CPUID information if this is a version 3 report.
652-
if r.Version == ReportVersion3 {
656+
if r.Version >= ReportVersion3 {
653657
family, model, stepping := FmsFromCpuid1Eax(r.Cpuid1EaxFms)
654658
data[0x188] = family
655659
data[0x189] = model

0 commit comments

Comments
 (0)