-
Notifications
You must be signed in to change notification settings - Fork 173
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
jit/x86: add emit_indirect_branch_target #288
Conversation
e36a585
to
279e7d9
Compare
@@ -866,6 +867,11 @@ fn emit_set_exception_kind<E: UserDefinedError>(jit: &mut JitCompiler, err: Ebpf | |||
X86Instruction::store_immediate(OperandSize::S64, R10, X86IndirectAccess::Offset(8), err_kind as i64).emit(jit) | |||
} | |||
|
|||
#[inline] | |||
fn emit_indirect_branch_target<E: UserDefinedError>(jit: &mut JitCompiler) -> Result<(), EbpfError<E>> { | |||
X86Instruction::end_branch().emit(jit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we put a feature flag here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary, in fact I would remove the entire emit_indirect_branch_target
function and only let the X86Instruction::end_branch()
in.
Why put the Edit: I would expect |
I think I'm fundamentally misunderstanding call and return sites in the JIT. 😅 @Lichtso What do you think of just addressing a small PR first that adds the |
You're right. Updated PR to omit this change. |
@@ -96,6 +98,11 @@ impl Default for X86Instruction { | |||
|
|||
impl X86Instruction { | |||
pub fn emit<E: UserDefinedError>(&self, jit: &mut JitCompiler) -> Result<(), EbpfError<E>> { | |||
match self.repeat_string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe turn this into an enum:
- Repeat Non Zero
- Repeat Zero
- Don't Repeat
@@ -866,6 +867,11 @@ fn emit_set_exception_kind<E: UserDefinedError>(jit: &mut JitCompiler, err: Ebpf | |||
X86Instruction::store_immediate(OperandSize::S64, R10, X86IndirectAccess::Offset(8), err_kind as i64).emit(jit) | |||
} | |||
|
|||
#[inline] | |||
fn emit_indirect_branch_target<E: UserDefinedError>(jit: &mut JitCompiler) -> Result<(), EbpfError<E>> { | |||
X86Instruction::end_branch().emit(jit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary, in fact I would remove the entire emit_indirect_branch_target
function and only let the X86Instruction::end_branch()
in.
@@ -980,6 +986,22 @@ impl JitCompiler { | |||
}) | |||
} | |||
|
|||
#[cfg(test)] | |||
#[allow(dead_code)] | |||
pub(crate) fn new_mock() -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be moved over in x86.rs mod test { ... }
as this is only used by the instruction emitter.
|
||
#[cfg(test)] | ||
#[allow(dead_code)] | ||
pub(crate) fn get_text_result(&self) -> &[u8] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not needed, just make the result accessible crate wide.
Closing for now as we currently have no need for it and it got unresolved conflicts. |
This PR adds the ability to emit the
endbr64
instruction to begin the work on Indirect Branch Tracking (IBT).This does not introduce any functional changes to the JIT compiler.
The bulk of the work to enable IBT, which involves adding
endbr64
s to code translated from SBF, is not implemented in this PR.Relates to #287
Changes
JitCompiler::new_mock()
andJitCompiler::get_text_result()
methods to allow test case assertions on x86-compiled code.emit_indirect_branch_target
function to emitendbr64
per Intel CET.