Skip to content

x86/kvm/emulate: Avoid RET for FASTOPs

Peter Zijlstra kvm lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest12 patches 25 repliesIn review
  2. v111 patches 8 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12objtool: Generic annotation infrastructureinclude/linux/objtool.h tools/objtool/check.c+64 -08 replies
2/12objtool: Convert ANNOTATE_NOENDBR to ANNOTATEinclude/linux/objtool.h include/linux/objtool_types.h tools/include/linux/objtool_types.h +1 more+19 -400 replies
3/12objtool: Convert ANNOTATE_RETPOLINE_SAFE to ANNOTATEarch/x86/include/asm/nospec-branch.h include/linux/objtool_types.h tools/include/linux/objtool_types.h +1 more+22 -452 replies
4/12objtool: Convert instrumentation_{begin,end}() to ANNOTATEinclude/linux/instrumentation.h include/linux/objtool.h include/linux/objtool_types.h +2 more+25 -484 replies
5/12objtool: Convert VALIDATE_UNRET_BEGIN to ANNOTATEinclude/linux/objtool.h include/linux/objtool_types.h tools/include/linux/objtool_types.h +1 more+10 -290 replies
6/12objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE to ANNOTATEarch/x86/include/asm/alternative.h include/linux/objtool_types.h tools/include/linux/objtool_types.h +1 more+15 -460 replies
7/12objtool: Convert ANNOTATE_INTRA_FUNCTION_CALLS to ANNOTATEinclude/linux/objtool.h include/linux/objtool_types.h tools/include/linux/objtool_types.h +1 more+47 -672 replies
8/12objtool: Collapse annotate sequencestools/objtool/check.c+32 -550 replies
9/12x86/nospec: JMP_NOSPECarch/x86/include/asm/nospec-branch.h+32 -00 replies
10/12x86,nospec: Simplify {JMP,CALL}_NOSPEC (part 2)arch/x86/include/asm/nospec-branch.h+11 -182 replies
11/12x86/kvm/emulate: Implement test_cc() in Carch/x86/include/asm/text-patching.h arch/x86/kvm/emulate.c+15 -391 reply
12/12x86/kvm/emulate: Avoid RET for fastopsarch/x86/kvm/emulate.c include/linux/objtool_types.h tools/include/linux/objtool_types.h +1 more+27 -65 replies

Reviews trailers per patch

1 of 12 patches has a Reviewed-by or Acked-by.

PatchSean Christopherson
1/12
2/12
3/12
4/12
5/12
6/12
7/12
8/12
9/12
10/12
11/12A-b
12/12

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/12] x86/kvm/emulate: Avoid RET for FASTOPs

Hi!

At long last, a respin of these patches.

The FASTOPs are special because they rely on RET to preserve CFLAGS, which is a problem with all the mitigation stuff. Also see things like: ba5ca5e5e6a1 ("x86/retpoline: Don't clobber RFLAGS during srso_safe_ret()").

Rework FASTOPs to no longer use RET and side-step the problem of trying to make the various return thunks preserve CFLAGS for just this one case.

There are two separate instances, test_cc() and fastop(). The first is basically a SETCC wrapper, which seems like a very complicated (and somewhat expensive) way to read FLAGS. Instead use the code we already have to emulate JCC to fully emulate the instruction.

That then leaves fastop(), which when marked noinline is guaranteed to exist only once. As such, CALL+RET isn't needed, because we'll always be RETurning to the same location, as such replace with JMP+JMP.

My plan is to take the objtool patches through tip/objtool/core, the nospec patches through tip/x86/core and either stick the fastop patches in that latter tree if the KVM folks agree, or they can merge the aforementioned two branches and then stick the patches on top, whatever works for people.