OPAL Secure Variable API¶
Overview¶
In order to support host OS secure boot on POWER systems, the platform needs some form of tamper-resistant persistant storage for authorized public keys. Furthermore, these keys must be retrieveable by the host kernel, and new keys must be able to be submitted.
OPAL exposes an abstracted “variable” API, in which these keys can be stored
and retrieved. At a high level, opal_secvar_get retrieves a specific
variable corresponding to a particular key. opal_secvar_get_next can be
used to iterate through the keys of the stored variables.
opal_secvar_enqueue_update can be used to submit a new variable for
processing on next boot.
OPAL_SECVAR_GET¶
#define OPAL_SECVAR_GET 176
OPAL_SECVAR_GET call retrieves a data blob associated with the supplied
key.
Parameters¶
char *key
uint64_t key_len
void *data
uint64_t *data_size
keya buffer used to associate with the variable data. May be any encoding, but must not be all zeroes
key_lensize of the key buffer in bytes
datareturn buffer to store the data blob of the requested variable if a match was found. May be set to NULL to only query the size into
data_sizedata_sizereference to the size of the
databuffer. OPAL sets this to the size of the requested variable if found.
Return Values¶
OPAL_SUCCESSthe requested data blob was copied successfully.
datawas NULL, and thedata_sizevalue was set successfullyOPAL_PARAMETERkeyis NULL.key_lenis zero.data_sizeis NULL.OPAL_EMPTYno variable with the supplied
keywas foundOPAL_PARTIALthe buffer size provided in
data_sizewas insufficient.data_sizeis set to the minimum required size.OPAL_UNSUPPORTEDsecure variables are not supported by the platform
OPAL_RESOURCEsecure variables are supported, but did not initialize properly
OPAL_SECVAR_GET_NEXT¶
#define OPAL_SECVAR_GET_NEXT 177
OPAL_SECVAR_GET_NEXT returns the key of the next variable in the secure
variable bank in sequence.
Parameters¶
char *key
uint64_t *key_len
uint64_t key_buf_size
keyname of the previous variable or empty. The key of the next variable in sequence will be copied to
key. If passed as empty, returns the first variable in the bankkey_lenlength in bytes of the key in the
keybuffer. OPAL sets this to the length in bytes of the next variable in sequencekey_buf_sizemaximum size of the
keybuffer. The next key will not be copied if this value is less than the length of the next key
Return Values¶
OPAL_SUCCESSthe key and length of the next variable in sequence was copied successfully
OPAL_PARAMETERkeyorkey_lengthis NULL.key_sizeis zero.key_lengthis impossibly large. No variable with the associatedkeywas foundOPAL_EMPTYend of list reached
OPAL_PARTIALthe size specified in
key_sizeis insufficient for the next variable’s key length.key_lengthis set to the next variable’s length, butkeyis untouchedOPAL_UNSUPPORTEDsecure variables are not supported by the platform
OPAL_RESOURCEsecure variables are supported, but did not initialize properly
OPAL_SECVAR_ENQUEUE_UPDATE¶
#define OPAL_SECVAR_ENQUEUE_UPDATE 178
OPAL_SECVAR_ENQUEUE call appends the supplied variable data to the
queue for processing on next boot.
Parameters¶
char *key
uint64_t key_len
void *data
uint64_t data_size
keya buffer used to associate with the variable data. May be any encoding, but must not be all zeroes
key_lensize of the key buffer in bytes
databuffer containing the blob of data to enqueue
data_sizesize of the
databuffer
Return Values¶
OPAL_SUCCESSthe variable was appended to the update queue bank successfully
OPAL_PARAMETERkeyordatawas NULL.keywas empty.key_lenordata_sizewas zero.key_len,data_sizeis larger than the maximum sizeOPAL_NO_MEMOPAL was unable to allocate memory for the variable update
OPAL_HARDWAREOPAL was unable to write the update to persistant storage
OPAL_UNSUPPORTEDsecure variables are not supported by the platform
OPAL_RESOURCEsecure variables are supported, but did not initialize properly