From: Jiri Pirko <jiri@resnulli.us>
To: linux-coco@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org,
x86@kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org,
jgg@ziepe.ca, david.quigley@intel.com, lukas@wunner.de,
ksinyuk@kernel.org, rodrigo.vivi@intel.com,
cedric.xing@intel.com, sameo@meta.com, drdeeglaze@gmail.com,
James.Bottomley@HansenPartnership.com, aik@amd.com,
jpiotrowski@nvidia.com, qinkun@google.com, pgonda@google.com,
jic23@kernel.org, alistair.francis@wdc.com, ankita@nvidia.com,
suzuki.poulose@arm.com, kas@kernel.org,
rick.p.edgecombe@intel.com, elena.reshetova@intel.com,
dave.hansen@linux.intel.com,
sathyanarayanan.kuppuswamy@linux.intel.com, peter.fang@intel.com
Subject: [PATCH RFC 16/20] attestation: Prepare measurement register journal
Date: Thu, 15 Oct 2026 16:50:49 +0200 [thread overview]
Message-ID: <20261015145053.3664509-17-jiri@resnulli.us> (raw)
In-Reply-To: <20261015145053.3664509-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@nvidia.com>
Add static MR state, append-only INFO and EXTEND records, and journal
notifications.
The journal objects can be compile-checked here. CONFIG_ATTESTATION remains
unwired until the CTLV operation handlers complete the module.
Assisted-by: Cursor: GPT-5.6 Sol
Assisted-by: Cursor: Claude Opus 5.5
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
Documentation/driver-api/attestation.rst | 8 +
drivers/attestation/Makefile | 2 +-
drivers/attestation/core/core.c | 76 ++++-
drivers/attestation/core/events.c | 65 ++++
drivers/attestation/core/internal.h | 79 ++++-
drivers/attestation/core/mr.c | 376 +++++++++++++++++++++++
6 files changed, 600 insertions(+), 6 deletions(-)
create mode 100644 drivers/attestation/core/events.c
create mode 100644 drivers/attestation/core/mr.c
diff --git a/Documentation/driver-api/attestation.rst b/Documentation/driver-api/attestation.rst
index 6d0cf9095c66..3cddd853aaa0 100644
--- a/Documentation/driver-api/attestation.rst
+++ b/Documentation/driver-api/attestation.rst
@@ -27,6 +27,14 @@ callback, journal commit and event emission with one instance mutex.
Fixed MRs are listed in the provider descriptor. Their property storage
remains valid until ``ctlv_destroy()`` or failed-creation unwind completes.
+MR journal
+==========
+
+MR extension is transactional. The core allocates the complete journal entry
+and event before invoking ``mr_extend``. A successful callback is followed
+only by infallible publication, so userspace observes the same ordered
+journal.
+
Teardown
========
diff --git a/drivers/attestation/Makefile b/drivers/attestation/Makefile
index 8a75558a7013..e7c9cb2dfec0 100644
--- a/drivers/attestation/Makefile
+++ b/drivers/attestation/Makefile
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_ATTESTATION) += attestation.o
-attestation-y := core/core.o
+attestation-y := core/core.o core/events.o core/mr.o
diff --git a/drivers/attestation/core/core.c b/drivers/attestation/core/core.c
index e112d3a0ff2b..6db8ed093e93 100644
--- a/drivers/attestation/core/core.c
+++ b/drivers/attestation/core/core.c
@@ -157,6 +157,13 @@ bool attestation_registered(struct attestation *att)
return registered;
}
+void attestation_mr_changed(struct attestation *att)
+{
+ lockdep_assert_held(&att->lock);
+ att->log->generation++;
+ att->mr_read_generation++;
+}
+
void attestation_stop(struct attestation *att)
{
lockdep_assert_held(&att->lock);
@@ -165,6 +172,38 @@ void attestation_stop(struct attestation *att)
xa_unlock(&attestation_instances);
}
+static struct attestation_mr *attestation_mr_alloc(struct attestation *att,
+ const struct attestation_mr_props *props)
+{
+ struct attestation_mr *mr;
+ int ret;
+
+ ret = attestation_mr_props_validate(att->provider, props);
+ if (ret)
+ return ERR_PTR(ret);
+ if (xa_load(&att->mrs, props->id))
+ return ERR_PTR(-EEXIST);
+ mr = kzalloc_obj(*mr, GFP_KERNEL);
+ if (!mr)
+ return ERR_PTR(-ENOMEM);
+ mr->props = props;
+ ret = xa_insert(&att->mrs, props->id, mr, GFP_KERNEL);
+ if (ret) {
+ kfree(mr);
+ return ERR_PTR(ret);
+ }
+ return mr;
+}
+
+struct attestation_mr *attestation_mr_lookup_live(struct attestation *att, unsigned int mr_id)
+{
+ struct attestation_mr *mr;
+
+ lockdep_assert_held(&att->lock);
+ mr = xa_load(&att->mrs, mr_id);
+ return mr ? mr : ERR_PTR(-ENOENT);
+}
+
void attestation_provide_ops(struct attestation *att)
{
const struct attestation_provider *provider = att->provider;
@@ -174,37 +213,66 @@ void attestation_provide_ops(struct attestation *att)
ctlv_attestation_evidence_get_provide(ctlvdev);
ctlv_attestation_evidence_get_enable(ctlvdev);
}
+ if (provider->mrs_count) {
+ ctlv_attestation_mr_get_provide(ctlvdev);
+ ctlv_attestation_mr_dump_provide(ctlvdev);
+ ctlv_attestation_mr_log_get_provide(ctlvdev);
+ if (provider->mr_read)
+ ctlv_attestation_mr_read_provide(ctlvdev);
+ if (provider->mr_extend)
+ ctlv_attestation_mr_extend_provide(ctlvdev);
+ }
}
int attestation_core_init(struct attestation *att, struct ctlv_device *ctlvdev,
const struct attestation_provider *provider)
{
+ size_t index;
int ret;
ret = attestation_provider_validate(provider);
if (ret)
return ret;
mutex_init(&att->lock);
+ xa_init(&att->mrs);
att->ctlvdev = ctlvdev;
att->provider = provider;
+ for (index = 0; index < provider->mrs_count; index++) {
+ struct attestation_mr *mr;
+
+ mr = attestation_mr_alloc(att, &provider->mrs[index]);
+ if (IS_ERR(mr)) {
+ ret = PTR_ERR(mr);
+ goto err_mrs;
+ }
+ }
ret = attestation_registry_insert(att);
if (ret)
- goto err_core;
+ goto err_mrs;
attestation_provide_ops(att);
att->initialized = true;
return 0;
-err_core:
+err_mrs:
attestation_core_fini(att);
return ret;
}
void attestation_core_fini(struct attestation *att)
{
+ struct attestation_mr *mr;
+ unsigned long index;
+
if (!att->ctlvdev)
return;
if (att->initialized)
attestation_registry_remove(att);
+ xa_for_each(&att->mrs, index, mr) {
+ xa_erase(&att->mrs, index);
+ kfree(mr);
+ }
+ attestation_mr_log_free(att->log);
+ xa_destroy(&att->mrs);
mutex_destroy(&att->lock);
att->ctlvdev = NULL;
}
@@ -222,7 +290,11 @@ int ctlv_attestation_init(struct ctlv_device *ctlvdev, const void *init_info, vo
int ctlv_attestation_post_init(struct ctlv_device *ctlvdev, void *priv)
{
struct attestation *att = priv;
+ int ret;
+ ret = attestation_mr_log_init(att);
+ if (ret)
+ return ret;
xa_lock(&attestation_instances);
__xa_set_mark(&attestation_instances, att->index, ATTESTATION_REGISTERED);
xa_unlock(&attestation_instances);
diff --git a/drivers/attestation/core/events.c b/drivers/attestation/core/events.c
new file mode 100644
index 000000000000..2cf8df4b6479
--- /dev/null
+++ b/drivers/attestation/core/events.c
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <linux/err.h>
+
+#include "internal.h"
+
+int attestation_events_prepare(struct attestation *att, struct attestation_event_batch *events)
+{
+ struct attestation_event *event = &events->mr_log;
+
+ lockdep_assert_held(&att->lock);
+ event->ctx = ctlv_attestation_mr_log_entry_appended_create(att->ctlvdev, &event->reply,
+ GFP_KERNEL);
+ if (IS_ERR(event->ctx)) {
+ int ret = PTR_ERR(event->ctx);
+
+ event->ctx = NULL;
+ event->reply = NULL;
+ return ret;
+ }
+ return 0;
+}
+
+void attestation_events_abort(struct attestation_event_batch *events)
+{
+ struct attestation_event *event = &events->mr_log;
+
+ if (!event->ctx)
+ return;
+ ctlv_event_abort(event->ctx);
+ event->ctx = NULL;
+ event->reply = NULL;
+}
+
+static void attestation_event_finish(struct attestation_event *event, int ret)
+{
+ if (ret) {
+ pr_err("attestation event encoding failed: %d\n", ret);
+ ctlv_event_abort(event->ctx);
+ } else {
+ ret = ctlv_event_emit(event->ctx);
+ if (ret)
+ pr_err("attestation event emission failed: %d\n", ret);
+ }
+ event->ctx = NULL;
+ event->reply = NULL;
+}
+
+void attestation_mr_log_event_emit(struct attestation_event_batch *events,
+ const struct attestation_mr_log_entry *entry)
+{
+ struct attestation_event *event = &events->mr_log;
+ struct ctlv_cursor nested;
+ int ret;
+
+ if (!event->ctx)
+ return;
+ if (!ctlv_attestation_notification_entry_start(event->reply, &nested)) {
+ ret = -EMSGSIZE;
+ goto out;
+ }
+ ret = attestation_mr_log_entry_encode(&nested, entry);
+ ctlv_nest_end(&nested);
+out:
+ attestation_event_finish(event, ret);
+}
diff --git a/drivers/attestation/core/internal.h b/drivers/attestation/core/internal.h
index 767c02275d0f..64dca12a3d04 100644
--- a/drivers/attestation/core/internal.h
+++ b/drivers/attestation/core/internal.h
@@ -11,25 +11,98 @@
#define ATTESTATION_REGISTERED XA_MARK_1
+enum attestation_mr_log_entry_type {
+ ATTESTATION_MR_LOG_ENTRY_INFO,
+ ATTESTATION_MR_LOG_ENTRY_EXTEND,
+};
+
+struct attestation_mr_log_entry {
+ unsigned int mr_generation;
+ unsigned int mr_id;
+ enum attestation_mr_log_entry_type type;
+};
+
+struct attestation_mr_log_entry_info {
+ struct attestation_mr_log_entry entry;
+ struct attestation_mr_props props;
+};
+
+struct attestation_mr_log_entry_extend {
+ struct attestation_mr_log_entry entry;
+ struct attestation_digest_set values;
+};
+
+struct attestation_mr_log {
+ unsigned int generation;
+ struct xarray entries;
+};
+
struct attestation {
struct ctlv_device *ctlvdev;
const struct attestation_provider *provider;
unsigned int index;
- /* Mutable instance state. */
+ /* Mutable instance, MR, and journal state. */
struct mutex lock;
+ unsigned int mr_read_generation;
+ struct xarray mrs;
+ struct attestation_mr_log *log;
bool initialized;
};
-int attestation_core_init(struct attestation *att,
- struct ctlv_device *ctlvdev,
+struct attestation_mr {
+ const struct attestation_mr_props *props;
+};
+
+struct attestation_event {
+ struct ctlv_op_ctx *ctx;
+ struct ctlv_cursor *reply;
+};
+
+struct attestation_event_batch {
+ struct attestation_event mr_log;
+};
+
+struct attestation_mr_change {
+ struct attestation_mr *mr;
+ struct attestation_mr_log_entry_extend *entry;
+ struct attestation_event_batch events;
+};
+
+int attestation_core_init(struct attestation *att, struct ctlv_device *ctlvdev,
const struct attestation_provider *provider);
void attestation_core_fini(struct attestation *att);
bool attestation_registered(struct attestation *att);
void attestation_stop(struct attestation *att);
+void attestation_mr_changed(struct attestation *att);
int attestation_provider_validate(const struct attestation_provider *provider);
void attestation_provide_ops(struct attestation *att);
+struct attestation_mr *attestation_mr_lookup_live(struct attestation *att, unsigned int mr_id);
+int attestation_mr_values_validate(const struct attestation_mr *mr,
+ const struct attestation_digest_set *values);
+int attestation_mr_log_init(struct attestation *att);
+struct attestation_mr_log_entry_info *attestation_mr_info_alloc(const struct attestation_mr *mr);
+void attestation_mr_log_entry_free(struct attestation_mr_log_entry *entry);
+void attestation_mr_log_free(struct attestation_mr_log *log);
+void attestation_mr_log_append(struct attestation *att, struct attestation_mr_log_entry *entry);
+struct attestation_mr_change *
+attestation_mr_change_prepare(struct attestation *att, struct attestation_mr *mr,
+ const struct attestation_digest_set *values);
+const struct attestation_mr_log_entry *
+attestation_mr_extend_locked(struct attestation *att, struct attestation_mr_change *change);
+void attestation_mr_change_free(struct attestation_mr_change *change);
+
+int attestation_events_prepare(struct attestation *att, struct attestation_event_batch *events);
+void attestation_events_abort(struct attestation_event_batch *events);
+void attestation_mr_log_event_emit(struct attestation_event_batch *events,
+ const struct attestation_mr_log_entry *entry);
+
+int attestation_mr_log_entry_encode(struct ctlv_cursor *reply,
+ const struct attestation_mr_log_entry *entry);
+int attestation_mr_props_encode(struct ctlv_cursor *reply, const struct attestation_mr *mr,
+ bool include_id);
+
#endif /* _ATTESTATION_INTERNAL_H */
diff --git a/drivers/attestation/core/mr.c b/drivers/attestation/core/mr.c
new file mode 100644
index 000000000000..db80cbd2b582
--- /dev/null
+++ b/drivers/attestation/core/mr.c
@@ -0,0 +1,376 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <crypto/hash_info.h>
+#include <linux/cleanup.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+
+#include "internal.h"
+
+int attestation_mr_values_validate(const struct attestation_mr *mr,
+ const struct attestation_digest_set *values)
+{
+ size_t index;
+
+ if (!values || !values->values || values->values_count != mr->props->algorithms_count)
+ return -EINVAL;
+ for (index = 0; index < values->values_count; index++)
+ if (values->values[index].algorithm != mr->props->algorithms[index])
+ return -EINVAL;
+ return 0;
+}
+
+static int attestation_digest_set_copy(struct attestation_digest_set *dst,
+ const struct attestation_digest_set *src)
+{
+ size_t index;
+
+ if (!src || !src->values || !src->values_count)
+ return -EINVAL;
+ for (index = 0; index < src->values_count; index++) {
+ enum hash_algo algorithm = src->values[index].algorithm;
+
+ if (algorithm >= HASH_ALGO__LAST || !hash_digest_size[algorithm] ||
+ (index && src->values[index - 1].algorithm >= algorithm))
+ return -EINVAL;
+ }
+ dst->values =
+ kmemdup_array(src->values, src->values_count, sizeof(*src->values), GFP_KERNEL);
+ if (!dst->values)
+ return -ENOMEM;
+ dst->values_count = src->values_count;
+ return 0;
+}
+
+static void attestation_digest_set_free(struct attestation_digest_set *set)
+{
+ kfree(set->values);
+ set->values = NULL;
+ set->values_count = 0;
+}
+
+struct attestation_mr_log_entry_info *attestation_mr_info_alloc(const struct attestation_mr *mr)
+{
+ struct attestation_mr_log_entry_info *info;
+ enum hash_algo *algorithms;
+ char *name;
+
+ info = kzalloc_obj(*info, GFP_KERNEL);
+ if (!info)
+ return ERR_PTR(-ENOMEM);
+ name = kstrdup(mr->props->name, GFP_KERNEL);
+ if (!name)
+ goto err_info;
+ algorithms = kmemdup_array(mr->props->algorithms, mr->props->algorithms_count,
+ sizeof(*algorithms), GFP_KERNEL);
+ if (!algorithms)
+ goto err_name;
+ info->entry.type = ATTESTATION_MR_LOG_ENTRY_INFO;
+ info->entry.mr_id = mr->props->id;
+ info->props = *mr->props;
+ info->props.name = name;
+ info->props.algorithms = algorithms;
+ return info;
+
+err_name:
+ kfree(name);
+err_info:
+ kfree(info);
+ return ERR_PTR(-ENOMEM);
+}
+
+void attestation_mr_log_entry_free(struct attestation_mr_log_entry *entry)
+{
+ if (!entry)
+ return;
+ switch (entry->type) {
+ case ATTESTATION_MR_LOG_ENTRY_INFO: {
+ struct attestation_mr_log_entry_info *info =
+ container_of(entry, typeof(*info), entry);
+
+ kfree(info->props.algorithms);
+ kfree(info->props.name);
+ kfree(info);
+ break;
+ }
+ case ATTESTATION_MR_LOG_ENTRY_EXTEND: {
+ struct attestation_mr_log_entry_extend *extend =
+ container_of(entry, typeof(*extend), entry);
+
+ attestation_digest_set_free(&extend->values);
+ kfree(extend);
+ break;
+ }
+ }
+}
+
+void attestation_mr_log_free(struct attestation_mr_log *log)
+{
+ struct attestation_mr_log_entry *entry;
+ unsigned long index;
+
+ if (!log)
+ return;
+ xa_for_each(&log->entries, index, entry) {
+ xa_erase(&log->entries, index);
+ attestation_mr_log_entry_free(entry);
+ }
+ xa_destroy(&log->entries);
+ kfree(log);
+}
+
+void attestation_mr_log_append(struct attestation *att, struct attestation_mr_log_entry *entry)
+{
+ struct attestation_mr_log *log = att->log;
+
+ xa_store(&log->entries, entry->mr_generation, entry, GFP_NOWAIT);
+}
+
+int attestation_mr_log_init(struct attestation *att)
+{
+ struct attestation_mr_log_entry_info **infos;
+ struct attestation_mr_log *log;
+ struct attestation_mr *mr;
+ unsigned long mr_id;
+ size_t count = 0;
+ size_t index = 0;
+ int ret = -ENOMEM;
+
+ xa_for_each(&att->mrs, mr_id, mr)
+ count++;
+ log = kzalloc_obj(*log, GFP_KERNEL);
+ if (!log)
+ return -ENOMEM;
+ xa_init(&log->entries);
+ infos = kcalloc(count, sizeof(*infos), GFP_KERNEL);
+ if (count && !infos)
+ goto err_log;
+ xa_for_each(&att->mrs, mr_id, mr) {
+ infos[index] = attestation_mr_info_alloc(mr);
+ if (IS_ERR(infos[index])) {
+ ret = PTR_ERR(infos[index]);
+ infos[index] = NULL;
+ goto err_infos;
+ }
+ index++;
+ }
+
+ att->log = log;
+ index = 0;
+ xa_for_each(&att->mrs, mr_id, mr) {
+ struct attestation_mr_log_entry *entry = &infos[index]->entry;
+
+ if (log->generation == UINT_MAX) {
+ ret = -EOVERFLOW;
+ goto err_attached;
+ }
+ entry->mr_generation = ++log->generation;
+ ret = xa_insert(&log->entries, entry->mr_generation, entry, GFP_KERNEL);
+ if (ret)
+ goto err_attached;
+ infos[index++] = NULL;
+ }
+ kfree(infos);
+ return 0;
+
+err_attached:
+ att->log = NULL;
+ attestation_mr_log_free(log);
+ log = NULL;
+err_infos:
+ for (index = 0; index < count; index++)
+ if (infos[index])
+ attestation_mr_log_entry_free(&infos[index]->entry);
+ kfree(infos);
+err_log:
+ attestation_mr_log_free(log);
+ return ret;
+}
+
+static struct attestation_mr_log_entry_extend *
+attestation_extend_alloc(enum attestation_mr_log_entry_type type, size_t size,
+ struct attestation_mr *mr, const struct attestation_digest_set *values)
+{
+ struct attestation_mr_log_entry_extend *extend;
+ int ret;
+
+ extend = kzalloc(size, GFP_KERNEL);
+ if (!extend)
+ return ERR_PTR(-ENOMEM);
+ extend->entry.type = type;
+ extend->entry.mr_id = mr->props->id;
+ ret = attestation_digest_set_copy(&extend->values, values);
+ if (ret) {
+ kfree(extend);
+ return ERR_PTR(ret);
+ }
+ return extend;
+}
+
+struct attestation_mr_change *
+attestation_mr_change_prepare(struct attestation *att, struct attestation_mr *mr,
+ const struct attestation_digest_set *values)
+{
+ struct attestation_mr_change *change;
+ int ret;
+
+ lockdep_assert_held(&att->lock);
+ change = kzalloc_obj(*change, GFP_KERNEL);
+ if (!change)
+ return ERR_PTR(-ENOMEM);
+ change->mr = mr;
+ change->entry = attestation_extend_alloc(ATTESTATION_MR_LOG_ENTRY_EXTEND,
+ sizeof(*change->entry), mr, values);
+ if (IS_ERR(change->entry)) {
+ ret = PTR_ERR(change->entry);
+ goto err_change;
+ }
+ ret = attestation_events_prepare(att, &change->events);
+ if (ret)
+ goto err_entry;
+ return change;
+
+err_entry:
+ attestation_mr_log_entry_free(&change->entry->entry);
+err_change:
+ kfree(change);
+ return ERR_PTR(ret);
+}
+
+const struct attestation_mr_log_entry *
+attestation_mr_extend_locked(struct attestation *att, struct attestation_mr_change *change)
+{
+ struct attestation_mr_log_entry_extend *extend = change->entry;
+ struct attestation_mr_log_entry *entry = &extend->entry;
+ int ret;
+
+ lockdep_assert_held(&att->lock);
+ if (att->log->generation == UINT_MAX) {
+ attestation_stop(att);
+ return ERR_PTR(-EOVERFLOW);
+ }
+ entry->mr_generation = att->log->generation + 1;
+ ret = xa_reserve(&att->log->entries, entry->mr_generation, GFP_KERNEL);
+ if (ret)
+ return ERR_PTR(ret);
+ ret = att->provider->mr_extend(att, change->mr->props->id, &extend->values);
+ if (ret) {
+ xa_release(&att->log->entries, entry->mr_generation);
+ return ERR_PTR(ret);
+ }
+ attestation_mr_changed(att);
+ attestation_mr_log_append(att, entry);
+ attestation_mr_log_event_emit(&change->events, entry);
+ change->entry = NULL;
+ return entry;
+}
+
+void attestation_mr_change_free(struct attestation_mr_change *change)
+{
+ if (!change)
+ return;
+ attestation_events_abort(&change->events);
+ if (change->entry)
+ attestation_mr_log_entry_free(&change->entry->entry);
+ kfree(change);
+}
+
+int attestation_mr_props_encode(struct ctlv_cursor *reply, const struct attestation_mr *mr,
+ bool include_id)
+{
+ u64 caps = 0;
+ size_t index;
+ bool ok = true;
+
+ if (include_id)
+ ok &= ctlv_attestation_mr_id_put(reply, mr->props->id);
+ ok &= ctlv_attestation_mr_name_put(reply, mr->props->name);
+ for (index = 0; index < mr->props->algorithms_count; index++)
+ ok &= ctlv_attestation_mr_supported_hash_algo_put(reply,
+ mr->props->algorithms[index]);
+ if (mr->props->has_register_index)
+ ok &= ctlv_attestation_mr_register_index_put(reply, mr->props->register_index);
+ if (mr->props->readable)
+ caps |= CTLV_ATTESTATION_MR_CAPS_READ;
+ if (mr->props->extendable)
+ caps |= CTLV_ATTESTATION_MR_CAPS_EXTEND;
+ ok &= ctlv_attestation_mr_caps_put(reply, caps);
+ return ok ? 0 : -EMSGSIZE;
+}
+
+static int attestation_values_encode(struct ctlv_cursor *reply,
+ const struct attestation_digest_set *values)
+{
+ struct ctlv_cursor nested;
+ size_t index;
+ bool ok = true;
+
+ for (index = 0; index < values->values_count; index++) {
+ const struct attestation_digest *value = &values->values[index];
+
+ if (!ctlv_attestation_mr_value_start(reply, &nested))
+ return -EMSGSIZE;
+ ok &= ctlv_attestation_mr_hash_algo_put(&nested, value->algorithm);
+ ok &= ctlv_attestation_mr_data_put(&nested, value->data,
+ hash_digest_size[value->algorithm]);
+ ctlv_nest_end(&nested);
+ }
+ return ok ? 0 : -EMSGSIZE;
+}
+
+static int attestation_mr_info_encode(struct ctlv_cursor *reply,
+ const struct attestation_mr_props *props)
+{
+ u64 caps = 0;
+ size_t index;
+ bool ok;
+
+ ok = ctlv_attestation_mr_name_put(reply, props->name);
+ for (index = 0; index < props->algorithms_count; index++)
+ ok &= ctlv_attestation_mr_supported_hash_algo_put(reply,
+ props->algorithms[index]);
+ if (props->has_register_index)
+ ok &= ctlv_attestation_mr_register_index_put(reply, props->register_index);
+ if (props->readable)
+ caps |= CTLV_ATTESTATION_MR_CAPS_READ;
+ if (props->extendable)
+ caps |= CTLV_ATTESTATION_MR_CAPS_EXTEND;
+ ok &= ctlv_attestation_mr_caps_put(reply, caps);
+ return ok ? 0 : -EMSGSIZE;
+}
+
+int attestation_mr_log_entry_encode(struct ctlv_cursor *reply,
+ const struct attestation_mr_log_entry *entry)
+{
+ struct ctlv_cursor nested;
+ bool ok;
+ int ret;
+
+ ok = ctlv_attestation_mr_generation_put(reply, entry->mr_generation);
+ ok &= ctlv_attestation_mr_id_put(reply, entry->mr_id);
+ ok &= ctlv_attestation_log_event_put(reply, entry->type == ATTESTATION_MR_LOG_ENTRY_INFO ?
+ CTLV_ATTESTATION_MR_LOG_EVENT_INFO :
+ CTLV_ATTESTATION_MR_LOG_EVENT_EXTEND);
+ if (!ok)
+ return -EMSGSIZE;
+
+ if (entry->type == ATTESTATION_MR_LOG_ENTRY_INFO) {
+ const struct attestation_mr_log_entry_info *info =
+ container_of(entry, typeof(*info), entry);
+
+ if (!ctlv_attestation_log_mr_start(reply, &nested))
+ return -EMSGSIZE;
+ ret = attestation_mr_info_encode(&nested, &info->props);
+ ctlv_nest_end(&nested);
+ return ret;
+ }
+
+ ret = attestation_values_encode(reply,
+ &container_of(entry,
+ const struct attestation_mr_log_entry_extend,
+ entry)
+ ->values);
+ if (ret)
+ return ret;
+ return 0;
+}
--
2.56.0
next prev parent reply other threads:[~2026-10-15 14:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 14:50 [PATCH RFC 00/20] attestation: Add a common subsystem and TDX support Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 01/20] ctlv: Add the schema language and generator Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 02/20] ctlv: Add the UAPI wire format and family API Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 03/20] ctlv: Add the root family specification and generated files Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 04/20] Documentation: ctlv: Add userspace ABI Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 05/20] ctlv: Prepare message input handling Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 06/20] ctlv: Prepare blob descriptor validation Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 07/20] ctlv: Prepare schema validation Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 08/20] ctlv: Prepare message output handling Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 09/20] ctlv: Prepare VA blob handling Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 10/20] ctlv: Prepare event queue support Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 11/20] ctlv: Prepare runtime introspection Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 12/20] ctlv: Add device and operation dispatch Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 13/20] Documentation: ctlv: Describe how to write a family Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 14/20] attestation: Add the base family specification and generated files Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 15/20] attestation: Prepare provider and instance core Jiri Pirko
2026-10-15 14:50 ` Jiri Pirko [this message]
2026-10-15 14:50 ` [PATCH RFC 17/20] attestation: Add CTLV operation handling Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 18/20] tdx-guest: Expose the native attestation service API Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 19/20] attestation: Add the TDX family specification and generated files Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 20/20] attestation: Add the TDX family implementation Jiri Pirko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261015145053.3664509-17-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=James.Bottomley@HansenPartnership.com \
--cc=aik@amd.com \
--cc=alistair.francis@wdc.com \
--cc=ankita@nvidia.com \
--cc=cedric.xing@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=david.quigley@intel.com \
--cc=drdeeglaze@gmail.com \
--cc=elena.reshetova@intel.com \
--cc=jgg@ziepe.ca \
--cc=jic23@kernel.org \
--cc=jpiotrowski@nvidia.com \
--cc=kas@kernel.org \
--cc=ksinyuk@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=peter.fang@intel.com \
--cc=pgonda@google.com \
--cc=qinkun@google.com \
--cc=rick.p.edgecombe@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=sameo@meta.com \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=suzuki.poulose@arm.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox