Skip to content

Commit

Permalink
Merge pull request #78 from Alan-Jowett/issue77
Browse files Browse the repository at this point in the history
Fix register mapping to avoid volatile registers and issues with R12
  • Loading branch information
rlane committed Jun 16, 2021
2 parents 221bbe0 + 955e51c commit bdb5618
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions vm/ubpf_jit_x86_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,24 @@ static int platform_nonvolatile_registers[] = {
static int platform_parameter_registers[] = {
RCX, RDX, R8, R9
};
#define RCX_ALT R15
#define RCX_ALT R10
// Register assignments:
// BPF R0-R4 are "volatile"
// BPF R5-R10 are "non-volatile"
// Map BPF volatile registers to x64 volatile and map BPF non-volatile to
// x64 non-volatile.
// Avoid R12 as we don't support encoding modrm modifier for using R12.
static int register_map[REGISTER_MAP_SIZE] = {
RAX,
R15,
R10,
RDX,
R8,
R9,
R10,
R11,
R12,
R13,
R14,
R15,
RDI,
RSI,
RBX,
RBP,
};
#else
Expand Down

0 comments on commit bdb5618

Please sign in to comment.