Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix register mapping to avoid volatile registers and issues with R12 #78

Merged
merged 3 commits into from
Jun 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Alan-Jowett marked this conversation as resolved.
Show resolved Hide resolved
RDI,
RSI,
RBX,
RBP,
};
#else
Expand Down