Revert "UPSTREAM: bpf, x86: Align dispatcher branch targets to 16B"

This reverts commit f6a4d900cc.

It conflicts with the BPF merge and will come in through that tree
instead.

Cc: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Idffa84def2a994a306c79803d49b7461adfae44c
This commit is contained in:
Greg Kroah-Hartman
2020-01-31 08:13:23 +01:00
parent 24e0e1f009
commit cf29e01887
2 changed files with 2 additions and 30 deletions

View File

@@ -1548,26 +1548,6 @@ static int emit_cond_near_jump(u8 **pprog, void *func, void *ip, u8 jmp_cond)
return 0;
}
static void emit_nops(u8 **pprog, unsigned int len)
{
unsigned int i, noplen;
u8 *prog = *pprog;
int cnt = 0;
while (len > 0) {
noplen = len;
if (noplen > ASM_NOP_MAX)
noplen = ASM_NOP_MAX;
for (i = 0; i < noplen; i++)
EMIT1(ideal_nops[noplen][i]);
len -= noplen;
}
*pprog = prog;
}
static int emit_fallback_jump(u8 **pprog)
{
u8 *prog = *pprog;
@@ -1590,8 +1570,8 @@ static int emit_fallback_jump(u8 **pprog)
static int emit_bpf_dispatcher(u8 **pprog, int a, int b, s64 *progs)
{
u8 *jg_reloc, *jg_target, *prog = *pprog;
int pivot, err, jg_bytes = 1, cnt = 0;
u8 *jg_reloc, *prog = *pprog;
s64 jg_offset;
if (a == b) {
@@ -1640,14 +1620,6 @@ static int emit_bpf_dispatcher(u8 **pprog, int a, int b, s64 *progs)
if (err)
return err;
/* From Intel 64 and IA-32 Architectures Optimization
* Reference Manual, 3.4.1.4 Code Alignment, Assembly/Compiler
* Coding Rule 11: All branch targets should be 16-byte
* aligned.
*/
jg_target = PTR_ALIGN(prog, 16);
if (jg_target != prog)
emit_nops(&prog, jg_target - prog);
jg_offset = prog - jg_reloc;
emit_code(jg_reloc - jg_bytes, jg_offset, jg_bytes);

View File

@@ -472,7 +472,7 @@ struct bpf_trampoline {
u64 selector;
};
#define BPF_DISPATCHER_MAX 48 /* Fits in 2048B */
#define BPF_DISPATCHER_MAX 64 /* Fits in 2048B */
struct bpf_dispatcher_prog {
struct bpf_prog *prog;