aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2026-05-24 01:07:51 +0000
committeriximeow <me@iximeow.net>2026-05-24 22:20:18 +0000
commit4532dbcfe444a05dea7022d86a502308eedd367f (patch)
treefb7c883c38b10ed99e5474c7c283635133549a06
parent347d8f4b677d6879856241a1c2b39783a61df026 (diff)
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--README.md28
3 files changed, 28 insertions, 4 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 5b4b566..77d5c45 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,7 +4,7 @@ version = 4
[[package]]
name = "asmlinator"
-version = "2.0.0"
+version = "2.1.0"
dependencies = [
"kvm-bindings",
"kvm-ioctls",
diff --git a/Cargo.toml b/Cargo.toml
index 87f8d1c..1ef8e45 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "asmlinator"
-version = "2.0.0"
+version = "2.1.0"
authors = [ "iximeow <me@iximeow.net>" ]
license = "0BSD"
repository = "https://git.iximeow.net/asmlinator/"
diff --git a/README.md b/README.md
index 1d229c6..15ec30e 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,30 @@ eprintln!("ending rip: {:016x}", regs.rip);
eprintln!("ending rax: {:016x}", regs.rax);
```
+for non-x86-64 modes, the path is slightly longer:
+```
+use asmlinator::x86_64::{IsaMode, VcpuExit, VmSettings, Vm};
+
+let settings = VmSettings::new(1024 * 1024, IsaMode::Real);
+let mut vm = Vm::create_by_settings(settings)
+ .expect("can create the VM");
+
+let mut regs = vm.get_regs().unwrap();
+regs.rax = 0x11223344_55667788;
+
+// program VM with "xor al, al; hlt"
+vm.program(&[0x33, 0xc0, 0xf4], &mut regs);
+vm.set_regs(&regs).unwrap();
+
+let res = vm.run().expect("can run cpu");
+assert_eq!(res, VcpuExit::Hlt);
+
+let regs = vm.get_regs().unwrap();
+eprintln!("ending rip: {:016x}", regs.rip);
+eprintln!("ending rax: {:016x}", regs.rax);
+assert_eq!(regs.rax, 0x1122334455660000);
+```
+
### design
it's just a glorified virtual CPU wrapper. there is no device emulation, there
@@ -46,8 +70,8 @@ require setting up an IDT, GDT, paging, ...
### future
-it'd be nice to set up aarch64 processors for code execution too. and
-32-bit/16-bit x86. and to do all this on other OSes with other VM APIs.
+it'd be nice to set up aarch64 processors for code execution too. and to do all
+this on other OSes with other VM APIs.
it would probably nice to expose a C ffi to embed this into other programs!
such an ffi interface should be straightforward. i haven't needed one yet.