Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/arch/amd64/amd64



e 24/03/2017 à 21:32, coypu%SDF.ORG@localhost a écrit :
cool!

I see in arch/i386/i386/locore.S that there is another call gate and
there's:

1246 IDTVEC(osyscall)
1247 #ifndef XEN
1248         /* XXX we are in trouble! interrupts be off here. */
1249         cli                     /* must be first instruction */
1250 #endif
1251         pushfl                  /* set eflags in trap frame */

Is 'cli' as first instruction what should've been done here, if it
wasn't been otherwise useless? can xen not do it?

Yes, I saw that too. In fact, I didn't understand how putting 'cli' fixed
the issue, since an interrupt can still happen before this instruction.
Given that it was committed by ad@, he probably must have thought about
this too; so it perhaps means that call gates on i386 disable interrupt for
the first instruction or something like that, but I was unable to find any
reference to this in the SDMs.

For Xen, there is no documentation, so if you want to find out what happens
you need to dig into the Xen source code. As far as I can test, it seems
that Xen disables interrupts on call gates.

There is still at least one bug here: now that pushfl is the second
instruction, the first two single-steps should be ignored, and this [1]
branch should be 'osyscall + 2', otherwise we may unintentionnally disable
single-stepping when returing to userland.

[1] https://nxr.netbsd.org/xref/src/sys/arch/i386/i386/trap.c#716


Home | Main Index | Thread Index | Old Index