Re: [PATCH v6 11/10] x86/retpoline: Avoid return buffer underflows on context switch

From: Linus Torvalds
Date: Mon Jan 08 2018 - 19:48:19 EST


On Mon, Jan 8, 2018 at 4:42 PM, David Woodhouse <dwmw2@xxxxxxxxxxxxx> wrote:
>
> Hm... on a context switch you're reloading the registers that were in
> the other saved context.

Actually, iirc we used to very actively try to minimize that by having
the inline asm mark a lot of registers as clobbered.

We moved away from that and now have that "switch_to_asm()" call
instead, but that was for unrelated reasons.

If I remember our old inline asm, we actually had *very* little real
data that was actually live on context switch, particularly that last
"branch to new EIP" point.

Partly because we had different targets, one of which was that "return
from fork" case.

But maybe I mis-remember. Wouldn't be the first time. This is code I
used to know well, but that was many many moons ago, now there are
other suckers^W maintainers who actually work with it.

Linus