git: 5a43d257c0fe - stable/14 - bhyve: don't crash when guest writes TPM int_enable register

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Tue, 12 Nov 2024 07:55:42 UTC
The branch stable/14 has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=5a43d257c0fe009235c11463ace889aaef3d0c8e

commit 5a43d257c0fe009235c11463ace889aaef3d0c8e
Author:     Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
AuthorDate: 2024-09-09 08:41:31 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2024-11-12 07:54:22 +0000

    bhyve: don't crash when guest writes TPM int_enable register
    
    FreeBSD's own TPM driver writes 0 to the INT_ENABLE register during
    attach, making sure interrupts are off. bhyve really shouldn't kill the
    VM when that happens just because it doesn't support TPM interrupts.
    Even if a guest was trying to enable interrupts, we should just ignore
    it like real TPM hardware would.
    
    Reviewed by:            corvink
    MFC after:              1 week
    Differential Revision:  https://reviews.freebsd.org/D46562
    
    (cherry picked from commit 2feea221b2480f9f97b3bc0f47510b5bdec96b79)
---
 usr.sbin/bhyve/tpm_intf_crb.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/usr.sbin/bhyve/tpm_intf_crb.c b/usr.sbin/bhyve/tpm_intf_crb.c
index 95cd8b1aae31..3e0769d1fef6 100644
--- a/usr.sbin/bhyve/tpm_intf_crb.c
+++ b/usr.sbin/bhyve/tpm_intf_crb.c
@@ -338,6 +338,10 @@ tpm_crb_mem_handler(struct vcpu *vcpu __unused, const int dir,
 
 			break;
 		}
+		case offsetof(struct tpm_crb_regs, int_enable):
+			/* No interrupt support. Ignore writes to int_enable. */
+			break;
+
 		case offsetof(struct tpm_crb_regs, ctrl_start): {
 			union tpm_crb_reg_ctrl_start start;