Skip to content

Commit b5e708c

Browse files
authored
Merge pull request #148 from katexochen/platform-info-update
abi: parse PlatformInfo form v3 report and badram mitigation
2 parents ef2fcc0 + ccd51e9 commit b5e708c

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

abi/abi.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const (
7373
policyDebugBit = 19
7474
policySingleSocketBit = 20
7575

76-
maxPlatformInfoBit = 1
76+
maxPlatformInfoBit = 5
7777

7878
signatureOffset = 0x2A0
7979
ecdsaRSsize = 72 // From the ECDSA-P384-SHA384 format in SEV SNP API specification.
@@ -186,6 +186,16 @@ type SnpPlatformInfo struct {
186186
// TSMEEnabled represents if the platform that produced the attestation report has transparent
187187
// secure memory encryption (TSME) enabled.
188188
TSMEEnabled bool
189+
// ECCEnabled indicates that the platform is using error correcting codes for memory.
190+
// Present when EccMemReporting feature bit is set.
191+
ECCEnabled bool
192+
// RAPLDisabled indicates that the RAPL is disabled.
193+
RAPLDisabled bool
194+
// CiphertextHidingDRAMEnabled indicates cypher text hiding is enabled for DRAM.
195+
CiphertextHidingDRAMEnabled bool
196+
// AliasCheckComplete indicates that alias detection has completed since the last system reset and there are no aliasing addresses.
197+
// Mitigation for https://badram.eu/, see https://www.amd.com/en/resources/product-security/bulletin/amd-sb-3015.html#mitigation.
198+
AliasCheckComplete bool
189199
}
190200

191201
// SnpPolicy represents the bitmask guest policy that governs the VM's behavior from launch.
@@ -244,8 +254,12 @@ func SnpPolicyToBytes(policy SnpPolicy) uint64 {
244254
// unrecognized bits.
245255
func ParseSnpPlatformInfo(platformInfo uint64) (SnpPlatformInfo, error) {
246256
result := SnpPlatformInfo{
247-
SMTEnabled: (platformInfo & (1 << 0)) != 0,
248-
TSMEEnabled: (platformInfo & (1 << 1)) != 0,
257+
SMTEnabled: (platformInfo & (1 << 0)) != 0,
258+
TSMEEnabled: (platformInfo & (1 << 1)) != 0,
259+
ECCEnabled: (platformInfo & (1 << 2)) != 0,
260+
RAPLDisabled: (platformInfo & (1 << 3)) != 0,
261+
CiphertextHidingDRAMEnabled: (platformInfo & (1 << 4)) != 0,
262+
AliasCheckComplete: (platformInfo & (1 << 5)) != 0,
249263
}
250264
reserved := platformInfo & ^uint64((1<<(maxPlatformInfoBit+1))-1)
251265
if reserved != 0 {

abi/abi_test.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,35 @@ func TestSnpPlatformInfo(t *testing.T) {
236236
want: SnpPlatformInfo{TSMEEnabled: true, SMTEnabled: true},
237237
},
238238
{
239-
input: 4,
240-
wantErr: "unrecognized platform info bit(s): 0x4",
239+
input: 21,
240+
want: SnpPlatformInfo{
241+
SMTEnabled: true,
242+
ECCEnabled: true,
243+
CiphertextHidingDRAMEnabled: true,
244+
},
245+
},
246+
{
247+
input: 42,
248+
want: SnpPlatformInfo{
249+
TSMEEnabled: true,
250+
RAPLDisabled: true,
251+
AliasCheckComplete: true,
252+
},
253+
},
254+
{
255+
input: 63,
256+
want: SnpPlatformInfo{
257+
TSMEEnabled: true,
258+
SMTEnabled: true,
259+
ECCEnabled: true,
260+
RAPLDisabled: true,
261+
CiphertextHidingDRAMEnabled: true,
262+
AliasCheckComplete: true,
263+
},
264+
},
265+
{
266+
input: 64,
267+
wantErr: "unrecognized platform info bit(s): 0x40",
241268
},
242269
}
243270
for _, tc := range tests {

0 commit comments

Comments
 (0)