From 642841bb1542c304e9da5eb98f4c18100b723cb8 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 27 Apr 2009 13:53:05 -0700 Subject: [PATCH] bcopyxx: clear all flags before jumping to the successor code Clear the flags register while we still have a stack to do so. This makes the state in the target OS more predictable. It's worth noting that none of the instructions we use in either the PM or RM trampolines change the flags, either (except the IF setting in the RM trampoline, but that is intentional.) Signed-off-by: H. Peter Anvin --- core/bcopyxx.inc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/bcopyxx.inc b/core/bcopyxx.inc index 06b03b2..4d0266e 100644 --- a/core/bcopyxx.inc +++ b/core/bcopyxx.inc @@ -232,8 +232,10 @@ pm_shuffle: call pm_bcopy jmp .loop .done: + push ecx ; == 0, for cleaning the flags register and esi,esi jz pm_shuffle_real_mode + popfd ; Clean the flags jmp edi ; Protected mode entry ; We have a real-mode entry point, so we need to return @@ -250,14 +252,16 @@ pm_shuffle_real_mode: mov [ebx+PM_CS16+7],ah mov [ebx+PM_DS16+4],al mov [ebx+PM_DS16+7],ah - mov ax,PM_DS16 - mov ds,eax - mov es,eax - mov fs,eax - mov gs,eax - mov ss,eax mov eax,cr0 and al,~1 + popfd ; Clean the flags + ; No flag-changing instructions below... + mov dx,PM_DS16 + mov ds,edx + mov es,edx + mov fs,edx + mov gs,edx + mov ss,edx jmp PM_CS16:0 align 16 -- 2.7.4