]> git.ipfire.org Git - thirdparty/glibc.git/commit
x86: Add COND_VZEROUPPER that can replace vzeroupper if no `ret`
authorNoah Goldstein <goldstein.w.n@gmail.com>
Tue, 7 Jun 2022 04:11:28 +0000 (21:11 -0700)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Tue, 7 Jun 2022 20:08:28 +0000 (13:08 -0700)
commitdd5c483b2598f411428df4d8864c15c4b8a3cd68
treec859b1416e2e839f5d9903efe6358373b9f68b97
parent8a780a6b910023e71f3173f37f0793834c047554
x86: Add COND_VZEROUPPER that can replace vzeroupper if no `ret`

The RTM vzeroupper mitigation has no way of replacing inline
vzeroupper not before a return.

This can be useful when hoisting a vzeroupper to save code size
for example:

```
L(foo):
cmpl %eax, %edx
jz L(bar)
tzcntl %eax, %eax
addq %rdi, %rax
VZEROUPPER_RETURN

L(bar):
xorl %eax, %eax
VZEROUPPER_RETURN
```

Can become:

```
L(foo):
COND_VZEROUPPER
cmpl %eax, %edx
jz L(bar)
tzcntl %eax, %eax
addq %rdi, %rax
ret

L(bar):
xorl %eax, %eax
ret
```

This code does not change any existing functionality.

There is no difference in the objdump of libc.so before and after this
patch.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
sysdeps/x86_64/multiarch/avx-rtm-vecs.h
sysdeps/x86_64/sysdep.h