Skip to content

Commit f99c6ac

Browse files
committed
[pkg/amd] Fix typos and formatting
Signed-off-by: Dmitrii Okunev <xaionaro@meta.com>
1 parent 0a968a8 commit f99c6ac

7 files changed

Lines changed: 21 additions & 23 deletions

File tree

pkg/amd/apcb/apcb.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import (
1515
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1616
//
1717
// APCB config consists of tokens, all tokens have the following attributes: ID, type, priority, boardMask, value
18-
// ID - is token's unqique identifier. Note APCB config may contain multiple tokens with same ID. The used one is determined by priority and board
18+
// ID - is token's unique identifier. Note APCB config may contain multiple tokens with same ID. The used one is determined by priority and board
1919
// Type - boolean, 1, 2 or 4 bytes value
2020
// Priority - see PriorityLevel
21-
// BoardMask - determines type of hardware for wich the token is aplicable
21+
// BoardMask - determines type of hardware for which the token is applicable
2222
// Value - token's value according to its type
2323
//
2424
// Structure of APCB/APCB recovery config is the following:

pkg/amd/psb/entries.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ type DirectoryType uint8
2020
const (
2121
// PSPDirectoryLevel1 represents PSP directory table level 1
2222
PSPDirectoryLevel1 DirectoryType = iota
23+
2324
// PSPDirectoryLevel2 represents PSP directory table level 2
2425
PSPDirectoryLevel2
26+
2527
// BIOSDirectoryLevel1 represents BIOS directory table level 1
2628
BIOSDirectoryLevel1
29+
2730
// BIOSDirectoryLevel2 represents BIOS directory table level 2
2831
BIOSDirectoryLevel2
2932
)

pkg/amd/psb/keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func NewTokenKey(buff *bytes.Buffer, keySet KeySet) (*Key, error) {
310310
// * modulus
311311
// * signature.
312312
//
313-
// Exponent, modulus and signature are all of the same size. Only the latter is not signed, hence the lenght
313+
// Exponent, modulus and signature are all of the same size. Only the latter is not signed, hence the length
314314
// of the signed payload is header size + 2 * exponent/modulus size.
315315
lenSigned := uint64(64 + 2*key.data.ModulusSize/8)
316316
if uint64(len(raw)) < lenSigned {

pkg/amd/psb/keyset.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
amd_manifest "github.com/linuxboot/fiano/pkg/amd/manifest"
1515
)
1616

17-
const keydbHeaderSize = 80
18-
1917
// KeyType represents the type of the key stored in KeySet
2018
type KeyType string
2119

@@ -52,7 +50,7 @@ func (kdb *KeySet) String() string {
5250
// AddKey adds a key to the key set
5351
func (kdb KeySet) AddKey(k *Key, keyType KeyType) error {
5452
if _, ok := kdb.db[k.data.KeyID]; ok {
55-
return fmt.Errorf("canont add key id %s to set, key with same id already exists", k.data.KeyID.Hex())
53+
return fmt.Errorf("cannot add key id %s to set, key with same id already exists", k.data.KeyID.Hex())
5654
}
5755

5856
kdb.db[k.data.KeyID] = k
@@ -102,8 +100,8 @@ func (kdb KeySet) KeysetFromType(keyType KeyType) (KeySet, error) {
102100
return keySet, nil
103101
}
104102

105-
// keydbHeader represents the header pre-pended to keydb structure
106-
type keydbHeader struct {
103+
// keyDBHeader represents the header pre-pended to keydb structure
104+
type keyDBHeader struct {
107105
DataSize uint32
108106
Version uint32
109107
Cookie uint32
@@ -122,8 +120,8 @@ func readAndCountSize(r io.Reader, order binary.ByteOrder, data interface{}, cou
122120
}
123121

124122
// extractKeydbHeader parses keydbHeader from binary buffer. KeyDB header is supposed to be 80 bytes long
125-
func extractKeydbHeader(buff io.Reader) (*keydbHeader, error) {
126-
header := keydbHeader{}
123+
func extractKeydbHeader(buff io.Reader) (*keyDBHeader, error) {
124+
header := keyDBHeader{}
127125

128126
if err := binary.Read(buff, binary.LittleEndian, &header); err != nil {
129127
return nil, fmt.Errorf("could not read key database header: %w", err)

pkg/amd/psb/psbbinary.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@ const pspHeaderSize = 0x100
1616
// signedDataStart indicates the start address of signed data content within a PSP binary
1717
const signedDataStart = 0x0
1818

19-
// sizeSignedToSignatureParametersLen is the size of the header from sizeSigned field to signatureParameters
20-
const sizeSignedToSignatureParametersLen = 32
21-
22-
// PspHeaderData emebds the data of PspHeader
23-
type PspHeaderData struct {
19+
// PSPHeaderData embeds the data of PspHeader
20+
type PSPHeaderData struct {
2421
Nonce Buf16B
2522
HeaderVersion uint32
2623
SizeSigned uint32
2724
EncryptionOptions uint32
28-
IkekType uint8
25+
IKEKType uint8
2926
Reserved0 Buf3B
3027
EncryptionParameters Buf16B
3128
SignatureOption uint32
@@ -54,7 +51,7 @@ type PspHeaderData struct {
5451

5552
// PspHeader models the header pre-pended to PSP binaries
5653
type PspHeader struct {
57-
data PspHeaderData
54+
data PSPHeaderData
5855

5956
// There should be 48 bytes of padding after the last field of the header,
6057
// which can be ignored. What we care about is the signature of the binary,
@@ -132,7 +129,7 @@ func (b *PSPBinary) getSignedBlob(keyDB KeySet) (*SignedBlob, error) {
132129
sizeImage = b.header.data.SizeImage
133130
} else {
134131
// the image is compressed, SizeFWSigned is to be ignored and instead compressedImageSize should be
135-
// taken into consideration and aligned to 16 bits. PSP header size is not included in compresseImageSize.
132+
// taken into consideration and aligned to 16 bits. PSP header size is not included in compressedImageSize.
136133
alignment := uint32(0x10)
137134
sizeSignedImage = (b.header.data.CompressedImageSize+alignment-1) & ^(alignment-1) + pspHeaderSize
138135
sizeImage = sizeSignedImage + sizeSignature

pkg/amd/psb/pspentries.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const (
1919
// AMDPublicKeyEntry denotes AMD public key entry in PSP Directory table
2020
AMDPublicKeyEntry amd_manifest.PSPDirectoryTableEntryType = 0x00
2121

22-
// PSPRecoveryBootlader is a recovery instance of PSP bootloader
23-
PSPRecoveryBootlader amd_manifest.PSPDirectoryTableEntryType = 0x03
22+
// PSPRecoveryBootloader is a recovery instance of PSP bootloader
23+
PSPRecoveryBootloader amd_manifest.PSPDirectoryTableEntryType = 0x03
2424

2525
// SMUOffChipFirmwareEntry points to a region of firmware containing SMU offchip firmware
2626
SMUOffChipFirmwareEntry amd_manifest.PSPDirectoryTableEntryType = 0x08

pkg/amd/psb/util.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func reverse(s []byte) []byte {
12-
if s == nil || len(s) == 0 {
12+
if len(s) == 0 {
1313
return nil
1414
}
1515
d := make([]byte, len(s))
@@ -24,10 +24,10 @@ func reverse(s []byte) []byte {
2424

2525
func checkBoundaries(start, end uint64, blob []byte) error {
2626
if start > uint64(len(blob)) {
27-
return fmt.Errorf("boundary check error: start is beyond blob bondary (%d > %d)", start, len(blob))
27+
return fmt.Errorf("boundary check error: start is beyond blob boundary (%d > %d)", start, len(blob))
2828
}
2929
if end > uint64(len(blob)) {
30-
return fmt.Errorf("boundary check error: start is beyond blob bondary (%d > %d)", end, len(blob))
30+
return fmt.Errorf("boundary check error: start is beyond blob boundary (%d > %d)", end, len(blob))
3131
}
3232
if start > end {
3333
return fmt.Errorf("boundary check error: start > end (%d > %d)", start, end)

0 commit comments

Comments
 (0)