Skip to contentSkip to conversation

Linux 2.4.19pre4-ac4

DISCUSSION Stas Sergeev 2 participants 2 messages Apr 4, 2002

lore
Share & tools
lore
#0 lore raw

Hello.

Quoted 4 lines · Kasper Dupont
Quoted 3 lines

Linux 2.4.19pre4-ac4
o Fix an additional vm86 case (Stas Sergeev)
| Check DOSemu again and this code wants some good review

[...]

This patch have nothing to do with your
and Manfred's exception handling fixes.
You can find it here if you want to have
a look:
http://dosemu.sourceforge.net/~stas/traps.diff
It prevents Oops in some cases, esp. if the
invalid instruction is executed in vm86.

Quoted 5 lines

I do consider the simplification to be safe.
In that case the macro would get to look like this:

   #define CHECK_IF_IN_TRAP \
           if (VMPI.vm86dbg_active && VMPI.vm86dbg_TFpendig) \
                   newflags |= TF_MASK;

I think you are right: already popped value must not make sense in the stack and even if it does, it seems to be even better if the TF is not set there, so that we have the value exactly which was pushed.

Quoted 2 lines

This is assuming Stas' way to use the macro. However since it
looks like Stas' use the old macro, I think his code is buggy.

The real bug was that set_vflags_long/short were used before the registers are changed, but they could return to userspace via set_IF() leaving the instuction executed only partially (not executed at all). This rendered vm86() disfunctional so that dosemu fails to even start in pre3-ac6. I have moved them down to fix the problem.
The macro was forgotten to update:(

Quoted 3 lines

And BTW does anybody happen to
know some software actually using the feature implemented by CHECK_IF_IN_TRAP?

dosemu's dosdebug uses it for force trace over iret and probably nobody else.

Quoted 1 line

I would appreachiate some comments on this subject.

I think that your simplification for this macro is the best fix if someone really wants to use this dosdebug's traceing feature.
Thank you.

#1 lore raw
Quoted 5 lines · Stas Sergeev

Hello.

Quoted 1 line · Kasper Dupont
Quoted 1 line

Linux 2.4.19pre4-ac4

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

o Fix an additional vm86 case (Stas Sergeev)
| Check DOSemu again and this code wants some good review

[...]

This patch have nothing to do with your
and Manfred's exception handling fixes.
You can find it here if you want to have
a look:
http://dosemu.sourceforge.net/~stas/traps.diff

Thanks, I haven't seen the patch before. I guess you are right that it is not related to our fixes.

Quoted 2 lines

It prevents Oops in some cases, esp. if the
invalid instruction is executed in vm86.

Fine.

Quoted 11 lines
Quoted 6 lines

I do consider the simplification to be safe.
In that case the macro would get to look like this:

   #define CHECK_IF_IN_TRAP \
           if (VMPI.vm86dbg_active && VMPI.vm86dbg_TFpendig) \
                   newflags |= TF_MASK;

I think you are right: already popped value must not make sense in the stack and even if it does, it seems to be even better if the TF is not set there, so that we have the value exactly which was pushed.

I agree, I just didn't want to change it without knowing if anything relied on that. BTW, is this feature something Linux specific or should it be compatible with something else?

Quoted 8 lines
Quoted 3 lines

This is assuming Stas' way to use the macro. However since it
looks like Stas' use the old macro, I think his code is buggy.

The real bug was that set_vflags_long/short were used before the registers are changed, but they could return to userspace via set_IF() leaving the instuction executed only partially (not executed at all). This rendered vm86() disfunctional so that dosemu fails to even start in pre3-ac6.

Now, I start wondering why I didn't experience any problems. (I tried another emulator, I don't yet understand what's the difference.) But I see the problem, I wasn't considering that set_vflags_* could return to userspace.

Quoted 6 lines

I have moved them down to fix the problem.
The macro was forgotten to update:(

Quoted 3 lines

And BTW does anybody happen to
know some software actually using the feature implemented by CHECK_IF_IN_TRAP?

Quoted 7 lines

dosemu's dosdebug uses it for force trace over iret and probably nobody else.

Quoted 1 line

I would appreachiate some comments on this subject.

I think that your simplification for this macro is the best fix if someone really wants to use this dosdebug's traceing feature.

I have written, but not yet tested a patch:
http://www.daimi.au.dk/~kasperd/linux_kernel/vm86.2.4.19-pre4-ac4.patch

arch/i386/kernel/vm86.c +3 -2
diff -Nur linux.old/arch/i386/kernel/vm86.c linux.new/arch/i386/kernel/vm86.c
@@ -7,7 +7,8 @@
 /*
  *  Bugfixes Copyright 2002 by Manfred Spraul and
  *  Kasper Dupont <[email protected]>
- *
+ *  Simplifications Copyright 2002 by Stas Sergeev
+ *  and Kasper Dupont
  */
 
 #include <linux/errno.h>
@@ -602,7 +603,7 @@
 
 #define CHECK_IF_IN_TRAP \
 	if (VMPI.vm86dbg_active && VMPI.vm86dbg_TFpendig) \
-		pushw(ssp,sp,popw(ssp,sp, regs, VM86_SIGSEGV) | TF_MASK, regs, VM86_SIGSEGV);
+		newflags |= TF_MASK;
 #define VM86_FAULT_RETURN \
 	if (VMPI.force_return_for_pic  && (VEFLAGS & (IF_MASK | VIF_MASK))) \
 		return_to_32bit(regs, VM86_PICRETURN); \

And I have put all the recent changes of vm86.c together in one (also untested) patch:
http://www.daimi.au.dk/~kasperd/linux_kernel/vm86.2.4.18-3.patch

Quoted 1 line

Thank you.

You too.

Signature · 2 lines
Kasper Dupont -- der bruger for meget tid på usenet.
For sending spam use mailto:[email protected]