From: Stefan Berger <stefanb@linux.ibm.com>
To: qemu-devel@nongnu.org
Cc: armenon@redhat.com, marcandre.lureau@gmail.com,
Stefan Berger <stefanb@linux.ibm.com>
Subject: [PATCH v2 08/10] hw/tpm: crb: Implement tpm_ppi_uninit and use it in tpm_crb_unrealize
Date: Thu, 24 Sep 2026 10:40:24 -0400 [thread overview]
Message-ID: <20260924144026.953360-9-stefanb@linux.ibm.com> (raw)
In-Reply-To: <20260924144026.953360-1-stefanb@linux.ibm.com>
Implement tpm_ppi_uninit and use it for proper teardown of the PPI in
tpm_crb_unrealize.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
hw/tpm/tpm_crb.c | 3 +++
hw/tpm/tpm_ppi.c | 10 ++++++++++
hw/tpm/tpm_ppi.h | 10 ++++++++++
3 files changed, 23 insertions(+)
diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
index 9a9677db6b..92d36608d0 100644
--- a/hw/tpm/tpm_crb.c
+++ b/hw/tpm/tpm_crb.c
@@ -16,6 +16,7 @@
#include "qemu/osdep.h"
+#include "qemu/memalign.h"
#include "qemu/module.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
@@ -529,6 +530,8 @@ static void tpm_crb_unrealize(DeviceState *dev)
if (s->migration_blocker) {
migrate_del_blocker(&s->migration_blocker);
}
+
+ tpm_ppi_uninit(&s->ppi, get_system_memory(), OBJECT(s));
}
static void tpm_crb_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c
index f0c34291dc..35baa083f2 100644
--- a/hw/tpm/tpm_ppi.c
+++ b/hw/tpm/tpm_ppi.c
@@ -57,3 +57,13 @@ void tpm_ppi_init(TPMPPI *tpmppi, MemoryRegion *m,
memory_region_add_subregion(m, addr, &tpmppi->ram);
}
+
+void tpm_ppi_uninit(TPMPPI *tpmppi, MemoryRegion *m, Object *obj)
+{
+ memory_region_del_subregion(m, &tpmppi->ram);
+
+ vmstate_unregister_ram(&tpmppi->ram, DEVICE(obj));
+
+ qemu_vfree(tpmppi->buf);
+ tpmppi->buf = NULL;
+}
diff --git a/hw/tpm/tpm_ppi.h b/hw/tpm/tpm_ppi.h
index 88f316ee95..c173889033 100644
--- a/hw/tpm/tpm_ppi.h
+++ b/hw/tpm/tpm_ppi.h
@@ -32,6 +32,16 @@ typedef struct TPMPPI {
void tpm_ppi_init(TPMPPI *tpmppi, MemoryRegion *m,
hwaddr addr, Object *obj);
+/**
+ * tpm_ppi_uninit:
+ * @tpmppi: a TPMPPI
+ * @m: the address-space / MemoryRegion to use
+ * @obj: the owner object
+ *
+ * Function to unregister the TPM PPI region.
+ */
+void tpm_ppi_uninit(TPMPPI *tpmppi, MemoryRegion *m, Object *obj);
+
/**
* tpm_ppi_reset:
* @tpmppi: a TPMPPI
--
2.55.0
next prev parent reply other threads:[~2026-09-24 14:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 14:40 [PATCH v2 00/10] Fix a couple of issues in TPM related code Stefan Berger
2026-09-24 14:40 ` [PATCH v2 01/10] tpm_util: Pass TPMVersion to function writing fatal error response Stefan Berger
2026-09-24 14:40 ` [PATCH v2 02/10] tpm_emulator: Reject TPM responses whose size is too small Stefan Berger
2026-09-24 14:40 ` [PATCH v2 03/10] tpm_emulator: Reject sending commands smaller than the request header Stefan Berger
2026-09-24 14:40 ` [PATCH v2 04/10] hw/tpm: tis: Only read from response buffer if rw_offset < len Stefan Berger
2026-09-24 14:40 ` [PATCH v2 05/10] hw/tpm: tis: Use uint32_t for len to avoid truncating size of command Stefan Berger
2026-09-24 14:40 ` [PATCH v2 06/10] hw/tpm: crb: Do not clear internal buffers when backend is busy Stefan Berger
2026-09-24 14:40 ` [PATCH v2 07/10] hw/tpm: crb: Avoid potential integer underflow Stefan Berger
2026-09-24 14:40 ` Stefan Berger [this message]
2026-09-24 14:40 ` [PATCH v2 09/10] hw/tpm: crb: Consider response_buffer->len of received response Stefan Berger
2026-09-24 14:40 ` [PATCH v2 10/10] tests: Add tests with commands with bad length Stefan Berger
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=20260924144026.953360-9-stefanb@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=armenon@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.