git: 79ceb5107b3b - stable/13 - i386 doreti: stop saving/restoring %ecx around calls into C

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 31 Aug 2022 01:32:14 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=79ceb5107b3ba5d917d529221f00b6087b6dc64d

commit 79ceb5107b3ba5d917d529221f00b6087b6dc64d
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-08-18 04:07:29 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-08-31 01:20:27 +0000

    i386 doreti: stop saving/restoring %ecx around calls into C
    
    (cherry picked from commit e8b2980e4a126407e15d33ee8d987385c8321261)
---
 sys/i386/i386/exception.s | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s
index 7dad1cc5978b..90c3182f9b13 100644
--- a/sys/i386/i386/exception.s
+++ b/sys/i386/i386/exception.s
@@ -546,22 +546,21 @@ doreti_exit:
 	je	doreti_iret_nmi
 	cmpl	$T_TRCTRAP, TF_TRAPNO(%esp)
 	je	doreti_iret_nmi
-	movl	$TF_SZ, %ecx
 	testl	$PSL_VM,TF_EFLAGS(%esp)
-	jz	1f			/* PCB_VM86CALL is not set */
-	addl	$VM86_STACK_SPACE, %ecx
-	jmp	2f
-1:	testl	$SEL_RPL_MASK, TF_CS(%esp)
+	jnz	1f			/* PCB_VM86CALL is not set */
+	testl	$SEL_RPL_MASK, TF_CS(%esp)
 	jz	doreti_popl_fs
-2:	movl	$handle_ibrs_exit,%eax
-	pushl	%ecx			/* preserve enough call-used regs */
+1:	movl	$handle_ibrs_exit,%eax
 	call	*%eax
 	movl	mds_handler,%eax
 	call	*%eax
-	popl	%ecx
 	movl	%esp, %esi
 	movl	PCPU(TRAMPSTK), %edx
-	subl	%ecx, %edx
+	movl	$TF_SZ, %ecx
+	testl	$PSL_VM,TF_EFLAGS(%esp)
+	jz	2f			/* PCB_VM86CALL is not set */
+	addl	$VM86_STACK_SPACE, %ecx
+2:	subl	$TF_SZ, %edx
 	movl	%edx, %edi
 	rep; movsb
 	movl	%edx, %esp