Re: RFC: Petition Intel/AMD to add POPF_IF insn

From: Denys Vlasenko
Date: Wed Aug 17 2016 - 15:27:01 EST


On 08/17/2016 09:13 PM, Andy Lutomirski wrote:
On Wed, Aug 17, 2016 at 12:01 PM, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
On Aug 17, 2016 11:41 AM, "Denys Vlasenko" <dvlasenk@xxxxxxxxxx> wrote:

OTOH 5 years will inevitably pass.

Yes. But in five years, maybe we'll have a popf that is faster anyway.

I'd actually prefer that in the end. The problem with popf right now seems
to be mainly that it's effectively serializing and does stupid things in
microcode. It doesn't have to be that way. It could actually do much better,
but it hasn't been a high enough priority for Intel.


It wouldn't surprise me if that were easier said than done. popf
potentially changes AC, and AC affects address translation. popf also
potentially changes IOPL, and I don't know whether Intel chips track
IOPL in a way that lets them find all the dependent instructions
without serializing. But maybe their pipeline is fancy enough.

Exactly. And more:

POPF potentially changes TF (and it works even in CPL3).
POPD changes DF - must serialize versus string insns.
POPF changes NT - must serialize versus IRET insns.
POPF changes VIF, from a different bit in a popped value,
and under a rather complex conditions.

Intel's documentation has a pseudo-code for the instructions.
For POPF, that pseudo-code is two pages long...