Skip to content

Commit

Permalink
Revert "Refactor - Sanitization of memory accesses in JIT (#6)" (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso authored Jan 2, 2025
1 parent 3997d39 commit ace7ec4
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1169,16 +1169,12 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {

match vm_addr {
Value::RegisterPlusConstant64(reg, constant, user_provided) => {
debug_assert!(user_provided);
// First half of emit_sanitized_load_immediate(REGISTER_SCRATCH, vm_addr)
let lower_key = self.immediate_value_key as i32 as i64;
self.emit_ins(X86Instruction::lea(OperandSize::S64, reg, REGISTER_SCRATCH, Some(
if reg == R12 {
X86IndirectAccess::OffsetIndexShift(constant.wrapping_sub(lower_key) as i32, RSP, 0)
} else {
X86IndirectAccess::Offset(constant.wrapping_sub(lower_key) as i32)
}
)));
if user_provided && self.should_sanitize_constant(constant) {
self.emit_sanitized_load_immediate(REGISTER_SCRATCH, constant);
} else {
self.emit_ins(X86Instruction::load_immediate(REGISTER_SCRATCH, constant));
}
self.emit_ins(X86Instruction::alu(OperandSize::S64, 0x01, reg, REGISTER_SCRATCH, None));
},
_ => {
#[cfg(debug_assertions)]
Expand Down Expand Up @@ -1597,8 +1593,6 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
] {
let target_offset = *anchor_base + len.trailing_zeros() as usize;
self.set_anchor(ANCHOR_TRANSLATE_MEMORY_ADDRESS + target_offset);
// Second half of emit_sanitized_load_immediate(REGISTER_SCRATCH, vm_addr)
self.emit_ins(X86Instruction::alu_immediate(OperandSize::S64, 0x81, 0, REGISTER_SCRATCH, lower_key, None));
// call MemoryMapping::(load|store) storing the result in RuntimeEnvironmentSlot::ProgramResult
if *anchor_base == 0 { // AccessType::Load
let load = match len {
Expand Down

0 comments on commit ace7ec4

Please sign in to comment.