git: 50a3713af846 - main - bhyve: Preserve string I/O registers on faults before progress
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 27 Nov 2026 07:25:16 UTC
The branch main has been updated by hayzam:
URL: https://cgit.FreeBSD.org/src/commit/?id=50a3713af846b915e5798b72fbf999df7f95c428
commit 50a3713af846b915e5798b72fbf999df7f95c428
Author: Hayzam Sherif <hayzam@FreeBSD.org>
AuthorDate: 2026-11-27 07:23:13 +0000
Commit: Hayzam Sherif <hayzam@FreeBSD.org>
CommitDate: 2026-11-27 07:23:13 +0000
bhyve: Preserve string I/O registers on faults before progress
When a string I/O instruction faults on its first transfer, the emulator
injects the exception but still writes the masked index and count back
to the guest. With a 32-bit address size in 64-bit mode this clears
the upper halves of RSI or RDI and of RCX, although no transfer
completed and the processor reports such a fault with the registers
unchanged.
Return before updating the registers whenever no transfer completed,
whether an error, a guest fault or an injected exception stopped the
first one. Exception injection has already restarted the instruction.
A repeated instruction with a zero count is handled as before.
Reviewed by: markj
Approved by: markj
Sponsored by: Alchemilla Ventures Private Limited
Differential Revision: https://reviews.freebsd.org/D61499
---
usr.sbin/bhyve/amd64/inout.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/usr.sbin/bhyve/amd64/inout.c b/usr.sbin/bhyve/amd64/inout.c
index 6cc90c36156a..9370c7595358 100644
--- a/usr.sbin/bhyve/amd64/inout.c
+++ b/usr.sbin/bhyve/amd64/inout.c
@@ -197,6 +197,15 @@ emulate_inout(struct vmctx *ctx, struct vcpu *vcpu, struct vm_exit *vmexit)
iterations--;
}
+ /*
+ * Preserve the original registers if an error, a guest fault
+ * or an injected exception prevented all progress. Exception
+ * injection has already restarted the instruction.
+ */
+ if (count != 0 &&
+ count == (vis->count & vie_size2mask(addrsize)))
+ return (retval);
+
/* Update index register */
error = vie_update_register(vcpu, idxreg, index, addrsize);
if (error != 0)