From e37c8e0f9319e3df3ff801f5a38f4717a8a20b28 Mon Sep 17 00:00:00 2001 From: johannst Date: Sun, 22 Oct 2023 12:29:22 +0000 Subject: deploy: 474c2545cbb1af85a326a47e202fe1e6c450b496 --- src/juicebox_asm/imm.rs.html | 7 +++---- src/juicebox_asm/insn.rs.html | 7 +++---- src/juicebox_asm/insn/add.rs.html | 7 +++---- src/juicebox_asm/insn/call.rs.html | 7 +++---- src/juicebox_asm/insn/dec.rs.html | 7 +++---- src/juicebox_asm/insn/jmp.rs.html | 7 +++---- src/juicebox_asm/insn/jnz.rs.html | 7 +++---- src/juicebox_asm/insn/jz.rs.html | 7 +++---- src/juicebox_asm/insn/mov.rs.html | 7 +++---- src/juicebox_asm/insn/nop.rs.html | 7 +++---- src/juicebox_asm/insn/ret.rs.html | 7 +++---- src/juicebox_asm/insn/test.rs.html | 7 +++---- src/juicebox_asm/label.rs.html | 7 +++---- src/juicebox_asm/lib.rs.html | 7 +++---- src/juicebox_asm/prelude.rs.html | 7 +++---- src/juicebox_asm/reg.rs.html | 7 +++---- src/juicebox_asm/rt.rs.html | 21 +++++++++++++++------ 17 files changed, 63 insertions(+), 70 deletions(-) (limited to 'src/juicebox_asm') diff --git a/src/juicebox_asm/imm.rs.html b/src/juicebox_asm/imm.rs.html index 0a9933e..acb8add 100644 --- a/src/juicebox_asm/imm.rs.html +++ b/src/juicebox_asm/imm.rs.html @@ -1,4 +1,4 @@ -imm.rs - source
1
+imm.rs - source
1
 2
 3
 4
@@ -48,7 +48,7 @@
 48
 49
 50
-
//! Definition of different immediate types which are used as input operands for various
+
//! Definition of different immediate types which are used as input operands for various
 //! instructions.
 
 /// Trait to interact with immediate operands.
@@ -98,5 +98,4 @@
     /// Type representing a 64 bit immediate.
     Imm64, 8, from: { u64, i64, u32, i32, u16, i16, u8, i8 }
 );
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/insn.rs.html b/src/juicebox_asm/insn.rs.html index fd7a473..24e26cb 100644 --- a/src/juicebox_asm/insn.rs.html +++ b/src/juicebox_asm/insn.rs.html @@ -1,4 +1,4 @@ -insn.rs - source
1
+insn.rs - source
1
 2
 3
 4
@@ -53,7 +53,7 @@
 53
 54
 55
-
//! Trait definitions of various instructions.
+
//! Trait definitions of various instructions.
 
 mod add;
 mod call;
@@ -108,5 +108,4 @@
     /// `SF`, `ZF`, and `PF` status flags, the result is discarded.
     fn test(&mut self, op1: T, op2: U);
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/insn/add.rs.html b/src/juicebox_asm/insn/add.rs.html index eb5d35f..0a24951 100644 --- a/src/juicebox_asm/insn/add.rs.html +++ b/src/juicebox_asm/insn/add.rs.html @@ -1,4 +1,4 @@ -add.rs - source
1
+add.rs - source
1
 2
 3
 4
@@ -11,7 +11,7 @@
 11
 12
 13
-
use crate::prelude::*;
+
use crate::prelude::*;
 
 impl Add<Reg64, Reg64> for Asm {
     fn add(&mut self, op1: Reg64, op2: Reg64) {
@@ -24,5 +24,4 @@
         self.encode_rr(0x01, op1, op2);
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/insn/call.rs.html b/src/juicebox_asm/insn/call.rs.html index c9d073e..38cb339 100644 --- a/src/juicebox_asm/insn/call.rs.html +++ b/src/juicebox_asm/insn/call.rs.html @@ -1,16 +1,15 @@ -call.rs - source
1
+call.rs - source
1
 2
 3
 4
 5
 6
 7
-
use crate::prelude::*;
+
use crate::prelude::*;
 
 impl Call<Reg64> for Asm {
     fn call(&mut self, op1: Reg64) {
         self.encode_r(0xff, 0x2, op1);
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/insn/dec.rs.html b/src/juicebox_asm/insn/dec.rs.html index 4cf1c5e..2d46c4c 100644 --- a/src/juicebox_asm/insn/dec.rs.html +++ b/src/juicebox_asm/insn/dec.rs.html @@ -1,4 +1,4 @@ -dec.rs - source
1
+dec.rs - source
1
 2
 3
 4
@@ -11,7 +11,7 @@
 11
 12
 13
-
use crate::prelude::*;
+
use crate::prelude::*;
 
 impl Dec<Reg64> for Asm {
     fn dec(&mut self, op1: Reg64) {
@@ -24,5 +24,4 @@
         self.encode_r(0xff, 1, op1);
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/insn/jmp.rs.html b/src/juicebox_asm/insn/jmp.rs.html index f3e4859..77b34c5 100644 --- a/src/juicebox_asm/insn/jmp.rs.html +++ b/src/juicebox_asm/insn/jmp.rs.html @@ -1,16 +1,15 @@ -jmp.rs - source
1
+jmp.rs - source
1
 2
 3
 4
 5
 6
 7
-
use crate::prelude::*;
+
use crate::prelude::*;
 
 impl Jmp<&mut Label> for Asm {
     fn jmp(&mut self, op1: &mut Label) {
         self.encode_jmp_label(&[0xe9], op1);
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/insn/jnz.rs.html b/src/juicebox_asm/insn/jnz.rs.html index ac38297..24a1e4a 100644 --- a/src/juicebox_asm/insn/jnz.rs.html +++ b/src/juicebox_asm/insn/jnz.rs.html @@ -1,16 +1,15 @@ -jnz.rs - source
1
+jnz.rs - source
1
 2
 3
 4
 5
 6
 7
-
use crate::prelude::*;
+
use crate::prelude::*;
 
 impl Jnz<&mut Label> for Asm {
     fn jnz(&mut self, op1: &mut Label) {
         self.encode_jmp_label(&[0x0f, 0x85], op1);
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/insn/jz.rs.html b/src/juicebox_asm/insn/jz.rs.html index b6f16c1..bbc67d8 100644 --- a/src/juicebox_asm/insn/jz.rs.html +++ b/src/juicebox_asm/insn/jz.rs.html @@ -1,16 +1,15 @@ -jz.rs - source
1
+jz.rs - source
1
 2
 3
 4
 5
 6
 7
-
use crate::prelude::*;
+
use crate::prelude::*;
 
 impl Jz<&mut Label> for Asm {
     fn jz(&mut self, op1: &mut Label) {
         self.encode_jmp_label(&[0x0f, 0x84], op1);
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/insn/mov.rs.html b/src/juicebox_asm/insn/mov.rs.html index ebc9193..0508d37 100644 --- a/src/juicebox_asm/insn/mov.rs.html +++ b/src/juicebox_asm/insn/mov.rs.html @@ -1,4 +1,4 @@ -mov.rs - source
1
+mov.rs - source
1
 2
 3
 4
@@ -103,7 +103,7 @@
 103
 104
 105
-
use crate::prelude::*;
+
use crate::prelude::*;
 
 // -- MOV : reg reg
 
@@ -208,5 +208,4 @@
         self.encode_oi(0xb0, op1, op2);
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/insn/nop.rs.html b/src/juicebox_asm/insn/nop.rs.html index 49a1571..0469ab0 100644 --- a/src/juicebox_asm/insn/nop.rs.html +++ b/src/juicebox_asm/insn/nop.rs.html @@ -1,16 +1,15 @@ -nop.rs - source
1
+nop.rs - source
1
 2
 3
 4
 5
 6
 7
-
use crate::Asm;
+
use crate::Asm;
 
 impl Asm {
     pub fn nop(&mut self) {
         self.emit(&[0x90]);
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/insn/ret.rs.html b/src/juicebox_asm/insn/ret.rs.html index a1ae96b..bb50d9f 100644 --- a/src/juicebox_asm/insn/ret.rs.html +++ b/src/juicebox_asm/insn/ret.rs.html @@ -1,16 +1,15 @@ -ret.rs - source
1
+ret.rs - source
1
 2
 3
 4
 5
 6
 7
-
use crate::Asm;
+
use crate::Asm;
 
 impl Asm {
     pub fn ret(&mut self) {
         self.emit(&[0xc3]);
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/insn/test.rs.html b/src/juicebox_asm/insn/test.rs.html index e158f34..5245439 100644 --- a/src/juicebox_asm/insn/test.rs.html +++ b/src/juicebox_asm/insn/test.rs.html @@ -1,4 +1,4 @@ -test.rs - source
1
+test.rs - source
1
 2
 3
 4
@@ -11,7 +11,7 @@
 11
 12
 13
-
use crate::prelude::*;
+
use crate::prelude::*;
 
 impl Test<Reg64, Reg64> for Asm {
     fn test(&mut self, op1: Reg64, op2: Reg64) {
@@ -24,5 +24,4 @@
         self.encode_rr(0x85, op1, op2);
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/label.rs.html b/src/juicebox_asm/label.rs.html index aff9f8f..e1fb18a 100644 --- a/src/juicebox_asm/label.rs.html +++ b/src/juicebox_asm/label.rs.html @@ -1,4 +1,4 @@ -label.rs - source
1
+label.rs - source
1
 2
 3
 4
@@ -80,7 +80,7 @@
 80
 81
 82
-
//! Definition of the lable type which can be used as jump target and can be bound to a location in
+
//! Definition of the lable type which can be used as jump target and can be bound to a location in
 //! the emitted code.
 
 use std::collections::HashSet;
@@ -162,5 +162,4 @@
         assert!(self.offsets.is_empty());
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/lib.rs.html b/src/juicebox_asm/lib.rs.html index 47e6bf6..4d6d4fe 100644 --- a/src/juicebox_asm/lib.rs.html +++ b/src/juicebox_asm/lib.rs.html @@ -1,4 +1,4 @@ -lib.rs - source
1
+lib.rs - source
1
 2
 3
 4
@@ -408,7 +408,7 @@
 408
 409
 410
-
//! A simple `x64` jit assembler with a minimal runtime to execute emitted code for fun.
+
//! A simple `x64` jit assembler with a minimal runtime to execute emitted code for fun.
 //!
 //! The following is an fibonacci example implementation.
 //! ```rust
@@ -818,5 +818,4 @@
 }
 impl EncodeMR<Reg32> for Asm {}
 impl EncodeMR<Reg64> for Asm {}
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/prelude.rs.html b/src/juicebox_asm/prelude.rs.html index a066379..ac02bf8 100644 --- a/src/juicebox_asm/prelude.rs.html +++ b/src/juicebox_asm/prelude.rs.html @@ -1,4 +1,4 @@ -prelude.rs - source
1
+prelude.rs - source
1
 2
 3
 4
@@ -8,7 +8,7 @@
 8
 9
 10
-
//! Crate prelude, which can be used to import the most important types at once.
+
//! Crate prelude, which can be used to import the most important types at once.
 
 pub use crate::Asm;
 pub use crate::MemOp;
@@ -18,5 +18,4 @@
 pub use crate::reg::{Reg16, Reg32, Reg64, Reg8};
 
 pub use crate::insn::{Add, Call, Dec, Jmp, Jnz, Jz, Mov, Test};
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/reg.rs.html b/src/juicebox_asm/reg.rs.html index 8791ddb..fec18cf 100644 --- a/src/juicebox_asm/reg.rs.html +++ b/src/juicebox_asm/reg.rs.html @@ -1,4 +1,4 @@ -reg.rs - source
1
+reg.rs - source
1
 2
 3
 4
@@ -332,7 +332,7 @@
 332
 333
 334
-
//! Definition of registers which are used as input operands for various instructions.
+
//! Definition of registers which are used as input operands for various instructions.
 
 /// Trait to interact with register operands.
 pub(crate) trait Reg {
@@ -666,5 +666,4 @@
         }
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/juicebox_asm/rt.rs.html b/src/juicebox_asm/rt.rs.html index 254745c..46597b0 100644 --- a/src/juicebox_asm/rt.rs.html +++ b/src/juicebox_asm/rt.rs.html @@ -1,4 +1,4 @@ -rt.rs - source
1
+rt.rs - source
1
 2
 3
 4
@@ -52,10 +52,15 @@
 52
 53
 54
-
//! A simple runtime which can be used to execute emitted instructions.
+55
+56
+57
+58
+59
+
//! A simple runtime which can be used to execute emitted instructions.
 
 use core::ffi::c_void;
-use nix::sys::mman::{mmap, munmap, MapFlags, ProtFlags};
+use nix::sys::mman::{mmap, mprotect, munmap, MapFlags, ProtFlags};
 
 /// A simple `mmap`ed runtime with executable pages.
 pub struct Runtime {
@@ -72,7 +77,7 @@
             mmap(
                 None,
                 len,
-                ProtFlags::PROT_WRITE | ProtFlags::PROT_READ | ProtFlags::PROT_EXEC,
+                ProtFlags::PROT_WRITE,
                 MapFlags::MAP_PRIVATE | MapFlags::MAP_ANONYMOUS,
                 0, /* fd */
                 0, /* off */
@@ -85,6 +90,11 @@
             assert!(code.len() < len.get());
             unsafe { std::ptr::copy_nonoverlapping(code.as_ptr(), buf.cast(), len.get()) };
         }
+        unsafe {
+            // Remove write permissions from code buffer and allow to read-execute from it.
+            mprotect(buf, len.get(), ProtFlags::PROT_READ | ProtFlags::PROT_EXEC)
+                .expect("Failed to RX mprotect Runtime code buffer");
+        }
 
         Runtime {
             buf,
@@ -106,5 +116,4 @@
         }
     }
 }
-
-
\ No newline at end of file + \ No newline at end of file -- cgit v1.2.3