Browse Source

Leave protected-mode return address on PM stack when issuing a

real_call(), rather than moving it to the RM stack and back again.
This allows the real-mode function to completely destroy the stack
contents, provided that it manages to return to real_call().
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
a9369bb503
1 changed files with 10 additions and 11 deletions
  1. 10
    11
      src/arch/i386/transitions/librm.S

+ 10
- 11
src/arch/i386/transitions/librm.S View File

455
 	.code32
455
 	.code32
456
 	.globl real_call
456
 	.globl real_call
457
 real_call:
457
 real_call:
458
-	/* Create register dump on PM stack */
458
+	/* Create register dump and function pointer copy on PM stack */
459
 	pushal
459
 	pushal
460
+	pushl	RC_OFFSET_FUNCTION(%esp)
460
 
461
 
461
-	/* Switch to real mode and move register dump to RM stack */
462
-	movl	$RC_OFFSET_END, %ecx
462
+	/* Switch to real mode and move register dump to RM stack  */
463
+	movl	$( RC_OFFSET_RETADDR + 4 /* function pointer copy */ ), %ecx
463
 	pushl	$1f
464
 	pushl	$1f
464
 	jmp	prot_to_real
465
 	jmp	prot_to_real
465
 	.section ".text16"
466
 	.section ".text16"
466
 	.code16
467
 	.code16
467
 1:
468
 1:
468
-	/* Construct call to real-mode function */
469
-	movw	%sp, %bp
470
-	movw	RC_OFFSET_FUNCTION(%bp), %ax
471
-	movw	%ax, rc_function
472
-
473
 	/* Call real-mode function */
469
 	/* Call real-mode function */
470
+	popl	rc_function
474
 	popal
471
 	popal
475
 	call	*rc_function
472
 	call	*rc_function
476
 	pushal
473
 	pushal
477
 
474
 
478
 	/* Switch to protected mode and move register dump back to PM stack */
475
 	/* Switch to protected mode and move register dump back to PM stack */
479
-	movl	$RC_OFFSET_END, %ecx
476
+	movl	$RC_OFFSET_RETADDR, %ecx
480
 	pushl	$1f
477
 	pushl	$1f
481
 	jmp	real_to_prot
478
 	jmp	real_to_prot
482
 	.section ".text"
479
 	.section ".text"
487
 	ret
484
 	ret
488
 
485
 
489
 
486
 
490
-	/* Function vector, used because */
487
+	/* Function vector, used because "call xx(%sp)" is not a valid
488
+	 * 16-bit expression.
489
+	 */
491
 	.section ".data16"
490
 	.section ".data16"
492
-rc_function:	.word 0
491
+rc_function:	.word 0, 0
493
 	
492
 	
494
 /****************************************************************************
493
 /****************************************************************************
495
  * Stored real-mode and protected-mode stack pointers
494
  * Stored real-mode and protected-mode stack pointers

Loading…
Cancel
Save