git: 582e01321ac6 - stable/15 - bhyve: tpm: Avoid printing a message when clearing the cancel bit

Mark Johnston <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a82fa2f.3bc74.56a47bc1__31064.2929560103$1786968759$gmane$org@gitrepo.freebsd.org>
The branch stable/15 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=582e01321ac6204f3560674c290a58ed89de39f5

commit 582e01321ac6204f3560674c290a58ed89de39f5
Author:     Mark Johnston <[email protected]>
AuthorDate: 2026-07-31 14:22:46 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2026-08-17 12:07:41 +0000

    bhyve: tpm: Avoid printing a message when clearing the cancel bit
    
    Some drivers do this routinely, e.g., FreeBSD's tpm20 does this every
    time it sends a command in tpmcrb_transmit().  This causes the console
    to fill up with messages.  Instead, only print a warning if the cancel
    bit is set to one.
    
    Reviewed by:    corvink
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D52425
    
    (cherry picked from commit 1c1a3646a1c86624e67a42636894fd1685386cf1)
---
 usr.sbin/bhyve/tpm_intf_crb.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/usr.sbin/bhyve/tpm_intf_crb.c b/usr.sbin/bhyve/tpm_intf_crb.c
index 9b44d1d133b0..bf5602a87659 100644
--- a/usr.sbin/bhyve/tpm_intf_crb.c
+++ b/usr.sbin/bhyve/tpm_intf_crb.c
@@ -371,11 +371,18 @@ tpm_crb_mem_handler(struct vcpu *vcpu __unused, const int dir,
 			break;
 		}
 		case offsetof(struct tpm_crb_regs, ctrl_cancel): {
-			/* TODO: cancel the tpm command */
-			warnx(
-			    "%s: cancelling a TPM command is not implemented yet",
-			    __func__);
+			union tpm_crb_reg_ctrl_cancel cancel;
+
+			if ((size_t)size > sizeof(cancel))
+				goto err_out;
 
+			tpm_crb_mmiocpy(&cancel, val, size);
+			if (cancel.cancel != 0) {
+				/* TODO: cancel the tpm command */
+				warnx(
+		    "%s: cancelling a TPM command is not implemented yet",
+				    __func__);
+			}
 			break;
 		}
 		case offsetof(struct tpm_crb_regs, int_enable):
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.