retpoline: disable jump tables
To mitigate Meltdown, Xen has been fixed with a software fix, namely using retpoline sequences generated by the compiler. This way, indirect branches are protected against the attack.
However, the retpoline sequence comes with a slow down. To make up for this, we propose to avoid jump tables in the first place. Without the retpoline sequences, this code would be less efficient. However, when retpoline is enabled, this actually results in a slight performance improvement.
This change might become irrelevant once the compiler starts avoiding jump tables in case retpolines are used:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86952
--- xen/arch/x86/Rules.mk | 1 + 1 file changed, 1 insertion(+)
xen/arch/x86/Rules.mk +1 -0
@@ -48,6 +48,7 @@ endif ifneq ($(call cc-option,$(CC),-mindirect-branch-register,n),n) CFLAGS += -mindirect-branch=thunk-extern -mindirect-branch-register CFLAGS += -DCONFIG_INDIRECT_THUNK +CFLAGS += -fno-jump-tables export CONFIG_INDIRECT_THUNK=y endif
Signature · 18 lines
2.7.4 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrer: Christian Schlaeger, Ralf Herbrich Ust-ID: DE 289 237 879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Jan Beulich
Acked-byQuoted 11 lines
Quoted 1 line
Quoted 1 line · On 20.11.18 at 16:37, <[email protected]> wrote:
To mitigate Meltdown, Xen has been fixed with a software fix, namely using retpoline sequences generated by the compiler. This way, indirect branches are protected against the attack.
However, the retpoline sequence comes with a slow down. To make up for this, we propose to avoid jump tables in the first place. Without the retpoline sequences, this code would be less efficient. However, when retpoline is enabled, this actually results in a slight performance improvement.
Quoted 7 lines
This change might become irrelevant once the compiler starts avoiding jump tables in case retpolines are used:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86952Reported-by Julian Stecklina <[email protected]>Reported-by Pawel Wieczorkiewicz <[email protected]>Signed-off-by Norbert Manthey <[email protected]>
In the future please play by patch submission rules: Patches get sent _to_ the list, with maintainers (and whoever else) on _cc_.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 20.11.18 at 16:37, <[email protected]> wrote:
To mitigate Meltdown, Xen has been fixed with a software fix, namely using retpoline sequences generated by the compiler. This way, indirect branches are protected against the attack.
Actually I was meaning to commit this right away, but then my attention was drawn by the mention of Meltdown above: I think you mean Spectre v2 instead? I'd like to avoid the change being confusing to readers later on ...
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 20.11.18 at 16:37, <[email protected]> wrote:
To mitigate Meltdown, Xen has been fixed with a software fix, namely using retpoline sequences generated by the compiler. This way, indirect branches are protected against the attack.
However, the retpoline sequence comes with a slow down. To make up for this, we propose to avoid jump tables in the first place. Without the retpoline sequences, this code would be less efficient. However, when retpoline is enabled, this actually results in a slight performance improvement.
Quoted 7 lines
Quoted 7 lines
This change might become irrelevant once the compiler starts avoiding jump tables in case retpolines are used:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86952Reported-by Julian Stecklina <[email protected]>Reported-by Pawel Wieczorkiewicz <[email protected]>Signed-off-by Norbert Manthey <[email protected]>
Shouldn't this use cc-option-add, or is it guaranteed that every compiler that supports -mindirect-branch-register will also support -fno-jump-tables?
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 20.11.18 at 16:57, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 20.11.18 at 16:37, <[email protected]> wrote:
To mitigate Meltdown, Xen has been fixed with a software fix, namely using retpoline sequences generated by the compiler. This way, indirect branches are protected against the attack.
However, the retpoline sequence comes with a slow down. To make up for this, we propose to avoid jump tables in the first place. Without the retpoline sequences, this code would be less efficient. However, when retpoline is enabled, this actually results in a slight performance improvement.
This change might become irrelevant once the compiler starts avoiding jump tables in case retpolines are used:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86952
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Reported-by Julian Stecklina <[email protected]>Reported-by Pawel Wieczorkiewicz <[email protected]>Signed-off-by Norbert Manthey <[email protected]>Shouldn't this use cc-option-add, or is it guaranteed that every compiler that supports -mindirect-branch-register will also support -fno-jump-tables?
I've checked that gcc supports this at least back to 4.1.x. With this long history I'm pretty sure clang has been doing so too for a long time.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 20.11.18 at 16:37, <[email protected]> wrote:
To mitigate Meltdown, Xen has been fixed with a software fix, namely using retpoline sequences generated by the compiler. This way, indirect branches are protected against the attack.
Actually I was meaning to commit this right away, but then my attention was drawn by the mention of Meltdown above: I think you mean Spectre v2 instead? I'd like to avoid the change being confusing to readers later on ...
Yes - jump tables / retpolines are only relevant to Spectre v2 / "Branch Target Injection".
Meltdown isn't applicable here.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 20.11.18 at 16:37, <[email protected]> wrote:
To mitigate Meltdown, Xen has been fixed with a software fix, namely using retpoline sequences generated by the compiler. This way, indirect branches are protected against the attack.
Actually I was meaning to commit this right away, but then my attention was drawn by the mention of Meltdown above: I think you mean Spectre v2 instead? I'd like to avoid the change being confusing to readers later on ...
Quoted 6 lines
Yes - jump tables / retpolines are only relevant to Spectre v2 / "Branch Target Injection".
Meltdown isn't applicable here.
~Andrew
Yes, I mixed these two up. I sometimes get confused with all the variants and numbers. I'll send a second version with an updated commit message.
Best,
Norbert
Amazon Development Center Germany GmbH Krausenstr. 38
10117 Berlin
Geschaeftsfuehrer: Christian Schlaeger, Ralf Herbrich
Ust-ID: DE 289 237 879
Eingetragen am Amtsgericht Charlottenburg HRB 149173 B
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 13 lines · Norbert Manthey
Quoted 12 lines · Andrew Cooper
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 20.11.18 at 16:37, <[email protected]> wrote:
To mitigate Meltdown, Xen has been fixed with a software fix, namely using retpoline sequences generated by the compiler. This way, indirect branches are protected against the attack.
Actually I was meaning to commit this right away, but then my attention was drawn by the mention of Meltdown above: I think you mean Spectre v2 instead? I'd like to avoid the change being confusing to readers later on ...
Yes - jump tables / retpolines are only relevant to Spectre v2 / "Branch Target Injection".
Quoted 6 lines
Quoted 3 lines
Meltdown isn't applicable here.
~Andrew
Yes, I mixed these two up. I sometimes get confused with all the variants and numbers. I'll send a second version with an updated commit message.
No need. Jan fixed it up on commit.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel