Re: [patch 00/38] x86/retbleed: Call depth tracking mitigation

Linus Torvalds
2022-07-21T18:07:06Z

On Thu, Jul 21, 2022 at 10:56 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> this seems to work, let me go hack the kernel..

Am I missing something?

Isn't this generating

movl $~IMM,%r10d
negl %r10d
cmpl %r10d,-4(%calldest)

for the sequence?

That seems bogus for two reasons:

(a) 'neg' is not the opposite of '~'. Did you mean 'notl' or did you mean '-'?

Or am I missing something entirely?

(b) since you have that r10 use anyway, why can't you just generate the simpler

movl $-IMM,%r10d
addl -4(%calldest),%r10d

instead? You only need ZF anyway.

Maybe you need to add some "r10 is clobbered" thing, I don't know.

But again: I don't know llvm, so the above is basically me just doing
the "pattern matching monkey" thing.

Linus