Skip to content

Commit d30defa

Browse files
committed
abi: parse PlatformInfo form v3 report
Signed-off-by: Paul Meyer <[email protected]>
1 parent ef2fcc0 commit d30defa

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

abi/abi.go

Lines changed: 13 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 = 4
7777

7878
signatureOffset = 0x2A0
7979
ecdsaRSsize = 72 // From the ECDSA-P384-SHA384 format in SEV SNP API specification.
@@ -186,6 +186,13 @@ 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
189196
}
190197

191198
// SnpPolicy represents the bitmask guest policy that governs the VM's behavior from launch.
@@ -244,8 +251,11 @@ func SnpPolicyToBytes(policy SnpPolicy) uint64 {
244251
// unrecognized bits.
245252
func ParseSnpPlatformInfo(platformInfo uint64) (SnpPlatformInfo, error) {
246253
result := SnpPlatformInfo{
247-
SMTEnabled: (platformInfo & (1 << 0)) != 0,
248-
TSMEEnabled: (platformInfo & (1 << 1)) != 0,
254+
SMTEnabled: (platformInfo & (1 << 0)) != 0,
255+
TSMEEnabled: (platformInfo & (1 << 1)) != 0,
256+
ECCEnabled: (platformInfo & (1 << 2)) != 0,
257+
RAPLDisabled: (platformInfo & (1 << 3)) != 0,
258+
CiphertextHidingDRAMEnabled: (platformInfo & (1 << 4)) != 0,
249259
}
250260
reserved := platformInfo & ^uint64((1<<(maxPlatformInfoBit+1))-1)
251261
if reserved != 0 {

abi/abi_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,16 @@ 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: 32,
248+
wantErr: "unrecognized platform info bit(s): 0x20",
241249
},
242250
}
243251
for _, tc := range tests {

0 commit comments

Comments
 (0)