@@ -213,6 +213,9 @@
#define OPAL_NX_COPROC_INIT 167
#define OPAL_XIVE_GET_VP_STATE 170
#define OPAL_SECVAR_GET 173
+#define OPAL_SECVAR_GET_SIZE 174
+#define OPAL_SECVAR_GET_NEXT 175
+#define OPAL_SECVAR_ENQUEUE_UPDATE 176
#define OPAL_SECVAR_BACKEND 177
#define OPAL_LAST 177
@@ -20,4 +20,13 @@ extern int opal_get_variable(u8 *key, unsigned long ksize,
extern int opal_variable_version(unsigned long *backend);
+extern int opal_get_variable_size(u8 *key, unsigned long ksize,
+ unsigned long *mdsize, unsigned long *dsize);
+
+extern int opal_get_next_variable(u8 *key, unsigned long *keylen,
+ unsigned long keysize);
+
+extern int opal_set_variable(u8 *key, unsigned long ksize, u8 *metadata,
+ unsigned long mdsize, u8 *data,
+ unsigned long dsize);
#endif
@@ -399,6 +399,14 @@ extern int opal_secvar_get(uint64_t k_key, uint64_t k_key_len,
uint64_t k_data, uint64_t k_data_size);
extern int opal_secvar_backend(uint64_t k_backend);
+extern int opal_secvar_get_size(uint64_t k_key, uint64_t k_key_len,
+ uint64_t k_metadata_size, uint64_t k_data_size);
+extern int opal_secvar_get_next(uint64_t k_key, uint64_t k_key_len,
+ uint64_t k_key_size);
+extern int opal_secvar_enqueue_update(uint64_t k_key, uint64_t k_key_len,
+ uint64_t k_metadata,
+ uint64_t k_metadata_size,
+ uint64_t k_data, uint64_t k_data_size);
#endif /* __ASSEMBLY__ */
@@ -290,3 +290,6 @@ OPAL_CALL(opal_sensor_group_enable, OPAL_SENSOR_GROUP_ENABLE);
OPAL_CALL(opal_nx_coproc_init, OPAL_NX_COPROC_INIT);
OPAL_CALL(opal_secvar_get, OPAL_SECVAR_GET);
OPAL_CALL(opal_secvar_backend, OPAL_SECVAR_BACKEND);
+OPAL_CALL(opal_secvar_get_size, OPAL_SECVAR_GET_SIZE);
+OPAL_CALL(opal_secvar_get_next, OPAL_SECVAR_GET_NEXT);
+OPAL_CALL(opal_secvar_enqueue_update, OPAL_SECVAR_ENQUEUE_UPDATE);
@@ -30,7 +30,10 @@ static bool is_opal_secvar_supported(void)
return opal_secvar_supported;
if (!opal_check_token(OPAL_SECVAR_GET)
- || !opal_check_token(OPAL_SECVAR_BACKEND)) {
+ || !opal_check_token(OPAL_SECVAR_BACKEND)
+ || !opal_check_token(OPAL_SECVAR_GET_SIZE)
+ || !opal_check_token(OPAL_SECVAR_GET_NEXT)
+ || !opal_check_token(OPAL_SECVAR_ENQUEUE_UPDATE)) {
pr_err("OPAL doesn't support secure variables\n");
opal_secvar_supported = false;
} else {
@@ -83,3 +86,58 @@ int opal_variable_version(unsigned long *backend)
return rc;
}
+
+int opal_get_variable_size(u8 *key, unsigned long ksize, unsigned long *mdsize,
+ unsigned long *dsize)
+{
+ int rc;
+
+ if (!is_opal_secvar_supported())
+ return OPAL_UNSUPPORTED;
+
+ if (mdsize)
+ *mdsize = cpu_to_be64(*mdsize);
+ if (dsize)
+ *dsize = cpu_to_be64(*dsize);
+
+ rc = opal_secvar_get_size(__pa(key), ksize, __pa(mdsize), __pa(dsize));
+
+ if (mdsize)
+ *mdsize = be64_to_cpu(*mdsize);
+ if (dsize)
+ *dsize = be64_to_cpu(*dsize);
+ return rc;
+}
+
+int opal_get_next_variable(u8 *key, unsigned long *keylen,
+ unsigned long keysize)
+{
+ int rc;
+
+ if (!is_opal_secvar_supported())
+ return OPAL_UNSUPPORTED;
+
+ if (!keylen)
+ return OPAL_PARAMETER;
+ *keylen = cpu_to_be64(*keylen);
+
+ rc = opal_secvar_get_next(__pa(key), __pa(keylen), keysize);
+
+ *keylen = be64_to_cpu(*keylen);
+
+ return rc;
+}
+
+int opal_set_variable(u8 *key, unsigned long ksize, u8 *metadata,
+ unsigned long mdsize, u8 *data, unsigned long dsize)
+{
+ int rc;
+
+ if (!is_opal_secvar_supported())
+ return OPAL_UNSUPPORTED;
+
+ rc = opal_secvar_enqueue_update(__pa(key), ksize, __pa(metadata),
+ mdsize, __pa(data), dsize);
+
+ return rc;
+}