Skip to content

Instantly share code, notes, and snippets.

@ricarkol
ricarkol / kvm-host.c
Last active October 24, 2023 08:23 — forked from zserge/kvm-host.c
Tiny KVM host to at least partially run Linux kernel
#define _GNU_SOURCE
#include <asm/bootparam.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/kvm.h>
#include <linux/kvm_para.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ricarkol
ricarkol / histo.py
Last active June 18, 2020 23:28
Continuously shows the histogram of a stream of strings (in ascii using curses).
#!/usr/bin/env python
from collections import defaultdict
import sys
import time
import curses
import math
"""
Continously shows the histogram of a stream of strings.
diff --git a/bindings/cpu_aarch64.h b/bindings/cpu_aarch64.h
index f1514aa..4afd5dd 100644
--- a/bindings/cpu_aarch64.h
+++ b/bindings/cpu_aarch64.h
@@ -69,7 +69,7 @@ static inline uint64_t mul64_32(uint64_t a, uint32_t b, uint8_t s)
}
#endif /* !ASM_FILE */
-static inline void cpu_set_tls_base(uint64_t base)
+__attribute__((always_inline)) static inline void cpu_set_tls_base(uint64_t base)
#include "solo5.h"
#include "../../bindings/lib.c"
#if defined(__linux__)
__thread volatile uint64_t data;
#else
/* This case is not tested. */
volatile uint64_t data;
#endif
@ricarkol
ricarkol / blk size diff
Last active February 19, 2019 19:14
solo5-blksize-test.c
--- a/tenders/hvt/hvt_module_blk.c
+++ b/tenders/hvt/hvt_module_blk.c
@@ -116,8 +116,8 @@ static int setup(struct hvt *hvt)
if (diskfd == -1)
err(1, "Could not open disk: %s", diskfile);
- blkinfo.sector_size = 512;
- blkinfo.num_sectors = lseek(diskfd, 0, SEEK_END) / 512;
+ blkinfo.sector_size = 16384;
+ blkinfo.num_sectors = lseek(diskfd, 0, SEEK_END) / 16384;
diff --git a/bindings/spt/start.c b/bindings/spt/start.c
index 4064a41..f9ddede 100644
--- a/bindings/spt/start.c
+++ b/bindings/spt/start.c
@@ -20,10 +20,23 @@
#include "bindings.h"
+extern uintptr_t __stack_chk_guard;
+
import argparse
import pexpect
import os
import time
parser = argparse.ArgumentParser()
parser.add_argument('--cmd', dest='cmd', help='unikernel command', default='echo hi', type=str)
parser.add_argument('--show', dest='show', help='show output', default=False, type=bool)
parser.add_argument('--num', dest='num', help='number of runs', default=10, type=int)
parser.add_argument('--timeout', dest='timeout', help='timeout', default=30, type=int)
@ricarkol
ricarkol / test-ocaml-fat-list.sh
Created April 21, 2018 15:40
Test for the ocaml-fat bin
umount /tmp/mnt_fat_test || true
mkdir -p /tmp/mnt_fat_test
(
dd if=/dev/zero of=test/disk-512.dat count=4096 bs=4096
mkfs.fat -f 1 -S 512 test/disk-512.dat
mount test/disk-512.dat /tmp/mnt_fat_test
cd /tmp/mnt_fat_test
bash -c "mkdir -p {root1,root2}/{abc,xyz/cba/zyx}"
@ricarkol
ricarkol / gdb-test.sh
Created June 5, 2017 20:04
Test for GDB server in ukvm
./tests/test_hello/ukvm-bin --gdb ./tests/test_hello/test_hello.ukvm &
gdb \
--eval-command="set confirm off" \
--eval-command="shell sleep 1" \
--eval-command="target remote localhost:1234" \
--eval-command="set {int} 0x00040000 = 12345" \
--eval-command="p {int} 0x00040000" \
--eval-command="b solo5_console_write" \
--eval-command="c" \
--eval-command="c" \
@ricarkol
ricarkol / snp.py
Created March 16, 2017 22:59
Messing with 23andme raw exported data
import sys
# Parse an exported raw genome data file from 23andme.com, wihch is basically
# one SNP per line. Each SNP is looked up in a small dictionary of
# "interesting" genes, like the ones related to celiac disease,
# lactointolerance, or obesity. The first and only arg is the name of the file
# (umcompressed).
db = {'rs2187668': {'geno':
{'AA': 'Autoimmune disorder risk (lupus, celiac disease) due to 2 HLA-DRB1*0301 alleles',