Skip to content

Instantly share code, notes, and snippets.

View mischief's full-sized avatar
🐡
hack the planet

Nick Owens mischief

🐡
hack the planet
View GitHub Profile
@mischief
mischief / README.md
Created October 26, 2026 19:41
obsd-gpt: boot a native OpenBSD partition in a libvirt VM via device mapper

obsd-gpt: boot a native OpenBSD partition in a libvirt VM

These scripts let a Linux host boot a VM from an OpenBSD install on a partition of the host disk. You can also boot the same install on bare metal.

OpenBSD writes its disklabel inside a GPT partition of type A600. The partition offsets in the disklabel count from the start of the physical disk, not from the start of the GPT partition. The kernel also checks that the disklabel partitions are inside the bounds of the A600 GPT

@mischief
mischief / c-dispatch-hardening.md
Last active October 28, 2026 09:37
C dispatch hardening: pin object tables and method pointers to frozen ELF sections

C dispatch hardening

Pin the origin of dispatch targets in C language runtimes. Object tables and method pointers come only from frozen sections of the loaded ELF files, never from the heap. The idea is similar to OpenBSD pinsyscalls, applied to indirect calls instead of syscall instructions.

This document has the design, deployment shapes that need no new calls from the caller, a prototype library with tests, Coccinelle

@mischief
mischief / spacemit-llama.md
Created July 12, 2026 18:01
spacemit k3 llama.cpp

llama.cpp on the SpacemiT K3 Pico-ITX (RISC-V) — Reproduction Guide

Tested 2026-07-11 on: SpacemiT K3 pico-ITX, 32GB RAM SKU, Bianbu 4.0.1 (Resolute Raccoon), kernel 6.18.3, GCC 15.2. 16 cores (8× perf @2.2GHz, 8× @1.8GHz). End result: Qwen3-30B-A3B MoE served at ~38 tok/s prompt processing / ~8-11 tok/s generation, CPU-only, via the SpacemiT IME (integrated matrix engine) instructions.

TL;DR

@mischief
mischief / shell.lua
Last active March 21, 2026 04:33
a "shell" in lua
local unistd = require("posix.unistd")
local stdlib = require("posix.stdlib")
local wait = require("posix.sys.wait")
local topcmd = nil
local Cmd = {}
function Cmd:exec()
local cmds = {}
@mischief
mischief / notes.md
Created February 13, 2026 07:17
notes for lua on openbsd

cqueues does not really like libressl, so

env ALL_LDFLAGS="$(pkg-config --libs eopenssl36) -Wl,-rpath=/usr/local/lib/eopenssl36" \
   luarocks install --local --force cqueues OPENSSL_INCDIR=/usr/local/include/eopenssl36/

to force openssl from packages. cqueues goofy makefile doesn't look at LDFLAGS.

for added fun, http rock

env ALL_LDFLAGS="$(pkg-config --libs eopenssl36) -Wl,-rpath=/usr/local/lib/eopenssl36" \

@mischief
mischief / vmd.patch
Created February 6, 2026 04:14
fix vmd 'invalid fault_type 2'
diff --git a/usr.sbin/vmd/vm.c b/usr.sbin/vmd/vm.c
index 6d571ce90fc..141ecdb80a7 100644
--- a/usr.sbin/vmd/vm.c
+++ b/usr.sbin/vmd/vm.c
@@ -42,8 +42,6 @@
#include "virtio.h"
#include "vmd.h"
-#define MMIO_NOTYET 0
-
@mischief
mischief / cgofuse.diff
Created January 22, 2026 16:04
rclone hacking for openbsd
diff --git a/fuse/host_cgo.go b/fuse/host_cgo.go
index b957917..682d239 100644
--- a/fuse/host_cgo.go
+++ b/fuse/host_cgo.go
@@ -190,7 +190,7 @@ static void *cgofuse_init_fuse(void)
#elif defined(__NetBSD__)
h = dlopen("librefuse.so.2", RTLD_NOW);
#elif defined(__OpenBSD__)
- h = dlopen("libfuse.so.2.0", RTLD_NOW);
+ h = dlopen("libfuse.so", RTLD_NOW);
#include <sys/param.h> /* MIN */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stddef.h>
#include <errno.h>
#include <assert.h>
@mischief
mischief / os.txt
Created June 16, 2025 08:15
megrez notes
sifive p550 ubuntu works on megrez mostly
https://github.com/sifiveinc/hifive-premier-p550-ubuntu/releases/tag/2025.04.00
- missing wifi fw
- audio driver seems broken, untested
@mischief
mischief / ffs2.lua
Created June 4, 2025 21:57
scan for ffs2 slices
local ffi = require("ffi")
local io = require("io")
local bit = require("bit")
ffi.cdef[[
typedef unsigned char u_char;
typedef unsigned char u_int8_t;
typedef uint32_t u_int32_t;
typedef uint64_t u_int64_t;