Commit 4a1e02b
Peter Zijlstra
x86,retpoline: Optimize patch_retpoline()
Currently the very common retpoline: "CS CALL __x86_indirect_thunk_r11"
is transformed into "CALL *R11; NOP3" for eIBRS/BHI_NO parts.
Similarly, paranoid fineibt has: "CALL *R11; NOP".
Recognise that CS stuffing can avoid the extra NOP. However, due to
prefix decode penalties, make sure to not emit too many CS prefixes.
Notably: "CS CALL __x86_indirect_thunk_rax" must not become "CS CS CS
CS CALL *RAX". Prefix decode penalties are typically many more cycles
than decoding an extra NOP.
Additionally, if the retpoline is a tail-call, the "JMP *%\reg" should
be followed by INT3 for straight-line-speculation mitigation, since
emit_indirect() now has a length argument, move this into
emit_indirect() such that other users (paranoid-fineibt) also do this.
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]1 parent 85a2d4a commit 4a1e02b
1 file changed
+26
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
713 | 713 | | |
714 | 714 | | |
715 | 715 | | |
716 | | - | |
| 716 | + | |
717 | 717 | | |
718 | | - | |
| 718 | + | |
719 | 719 | | |
| 720 | + | |
720 | 721 | | |
721 | 722 | | |
722 | 723 | | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
723 | 730 | | |
724 | 731 | | |
725 | 732 | | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
726 | 738 | | |
727 | 739 | | |
728 | 740 | | |
729 | 741 | | |
| 742 | + | |
730 | 743 | | |
731 | 744 | | |
732 | 745 | | |
733 | 746 | | |
734 | 747 | | |
735 | 748 | | |
736 | 749 | | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
737 | 753 | | |
738 | 754 | | |
739 | 755 | | |
| |||
745 | 761 | | |
746 | 762 | | |
747 | 763 | | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
748 | 767 | | |
749 | 768 | | |
750 | 769 | | |
| |||
918 | 937 | | |
919 | 938 | | |
920 | 939 | | |
921 | | - | |
| 940 | + | |
922 | 941 | | |
923 | 942 | | |
924 | 943 | | |
925 | 944 | | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | 945 | | |
936 | 946 | | |
937 | 947 | | |
| |||
1421 | 1431 | | |
1422 | 1432 | | |
1423 | 1433 | | |
1424 | | - | |
1425 | | - | |
| 1434 | + | |
1426 | 1435 | | |
1427 | 1436 | | |
1428 | 1437 | | |
| |||
1724 | 1733 | | |
1725 | 1734 | | |
1726 | 1735 | | |
1727 | | - | |
1728 | | - | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
1729 | 1739 | | |
1730 | 1740 | | |
1731 | 1741 | | |
| |||
0 commit comments