Skip to content

Instantly share code, notes, and snippets.

@aqjune
aqjune / a.ml
Created January 11, 2024 19:14
executing 10 instructions to make x0 zero to 3
(****** A simple specification about program 'simple_arm.S' *******)
(* If you are using HOL Light Online, this line is not necessary. *)
(* needs "arm/proofs/base.ml";; *)
let simple_arm_mc = new_definition `simple_arm_mc = [
word 0xe0; word 0x03; word 0x1f; word 0xaa; // arm_MOV X0 XZR
word 0x00; word 0x04; word 0x00; word 0x91; // arm_ADD X0 X0 (rvalue (word 1))
word 0x1f; word 0x0c; word 0x00; word 0xf1; // arm_CMP X0 (rvalue (word 3))
word 0xc1; word 0xff; word 0xff; word 0x54 // arm_BNE (word 2097144)
@aqjune
aqjune / stp.ml
Last active July 21, 2023 18:55
stp.ml
needs "arm/proofs/base.ml";;
let stp_mc = define_assert_from_elf "stp_mc" "stp.o"
[
0xa9004c31 (* arm_STP X17 X19 X1 (Immediate_Offset (iword (&0))) *)
];;
let STP_EXEC = ARM_MK_EXEC_RULE stp_mc;;
@aqjune
aqjune / bashlog.txt
Created June 12, 2023 17:18
Success case
dev-dsk-lebjuney-1d-d3fc5ff7 % make sematest
../tools/run-sematest.sh . 32 "/home/lebjuney/hol-light-ocaml4.14/hollight "
- Child 1 (pid 8752) has started (log path: /tmp/tmp.qeBbXPDRRr)
- Child 2 (pid 8756) has started (log path: /tmp/tmp.I0ALk9exvX)
- Child 3 (pid 8761) has started (log path: /tmp/tmp.DGJxWS09ar)
- Child 4 (pid 8767) has started (log path: /tmp/tmp.uCaV3R0nnS)
- Child 5 (pid 8771) has started (log path: /tmp/tmp.uzG2Tnfrgw)
- Child 6 (pid 8778) has started (log path: /tmp/tmp.TuTNQssTIo)
- Child 7 (pid 8784) has started (log path: /tmp/tmp.hKGajyyESl)
@aqjune
aqjune / bashlog.txt
Created June 12, 2023 17:17
Failure case
dev-dsk-lebjuney-1d-d3fc5ff7 % make sematest
../tools/run-sematest.sh . 32 "/home/lebjuney/hol-light-ocaml4.14/hollight "
- Child 1 (pid 3178) has started (log path: /tmp/tmp.muukON4ZUi)
- Child 2 (pid 3183) has started (log path: /tmp/tmp.sQ1LEwAzA5)
- Child 3 (pid 3187) has started (log path: /tmp/tmp.d6SAmJ6Hfz)
- Child 4 (pid 3193) has started (log path: /tmp/tmp.tUY6sTyOYR)
- Child 5 (pid 3198) has started (log path: /tmp/tmp.q5XSylRFhq)
- Child 6 (pid 3205) has started (log path: /tmp/tmp.MtloMm7gT3)
- Child 7 (pid 3211) has started (log path: /tmp/tmp.cdFrUjdqn6)
@aqjune
aqjune / sli_umull.ml
Created May 16, 2023 01:19
sli_umull.ml
(* sli v3.2d, v4.2d, #32 *)
(* 1. Check that decode succeeds *)
DECODE_CONV `decode (word 0x6f605483)`;;
(* output: - : thm = |- decode (word 1868584067) = SOME (arm_SLI_VEC Q3 Q4 32 64) *)
(* 2. Check that the symbolic output looks ok *)
let code_6f605483 = define `code_6f605483:byte list = [word 0x83; word 0x54; word 0x60; word 0x6f]`;;
let execth = ARM_MK_EXEC_RULE code_6f605483;;
g `ensures arm
@aqjune
aqjune / decode-test-usra.ml
Created April 29, 2023 02:21
decode-test-usra.ml
(* usra v1.2d, v3.2d, #30 *)
(* 1. Check that decode succeeds *)
DECODE_CONV `decode (word 0x6f621461)`;;
(* output: - : thm = |- decode (word 1868698721) = SOME (arm_USRA_VEC Q1 Q3 30 64 128) *)
(* 2. Check that the symbolic output looks ok *)
let code_6f621461 = define `code_6f621461:byte list = [word 0x61; word 0x14; word 0x62; word 0x6f]`;;
let execth = ARM_MK_EXEC_RULE code_6f621461;;
g `ensures arm
(\s. aligned_bytes_loaded s (word pc) code_6f621461 /\
read PC s = word pc)
@aqjune
aqjune / test.ml
Created April 28, 2023 23:57
test.ml
let test_mc =
define_assert_from_elf "test_mc" "test.o"
[
0x3dc00000; (* arm_LDR Q0 X0 (Immediate_Offset (word 0)) *)
0xa9000c22 (* arm_STP X2 X3 X1 (Immediate_Offset (iword (&0))) *)
];;
let TEST_EXEC = ARM_MK_EXEC_RULE test_mc;;
let STORE_DOES_NOT_TOUCH_LDR_Q = prove(
@aqjune
aqjune / tests.ml
Created April 21, 2023 13:04
PR-NEON8
(* ============= *)
(* 1. dup: https://developer.arm.com/documentation/ddi0602/2022-06/SIMD-FP-Instructions/DUP--general---Duplicate-general-purpose-register-to-vector- *)
(* dup v2.2d, x4 (0x4e080c82, 0100 1110 0000 1000 0000 1100 1000 0010) *)
(* 1. Check that decode succeeds *)
DECODE_CONV `decode (word 0x4e080c82)`;;
(* output: - : thm = |- decode (word 1309150338) = SOME (arm_DUP Q2 X4) *)
(* 2. Check that the symbolic output looks ok *)
let code_4e080c82 = define `code_4e080c82:byte list = [word 0x82; word 0x0c; word 0x08; word 0x4e]`;;
@aqjune
aqjune / bufferize-fail.mlir
Created November 11, 2021 14:13
bufferize-fail.mlir
#map0 = affine_map<(d0, d1) -> (d0, d1)>
#map1 = affine_map<(d0) -> (d0)>
#map2 = affine_map<(d0, d1) -> (d0)>
module {
func @encrypt(%arg0: tensor<18x131072xi64>, %arg1: tensor<18x131072xi64>) -> tensor<18x131072xi64> {
%cst = arith.constant dense<[1, 131072]> : tensor<2xi64>
%cst_0 = arith.constant dense<1> : tensor<1xi64>
%cst_1 = arith.constant dense<131072> : tensor<1xi64>
%cst_2 = arith.constant dense<[30, 1]> : tensor<2xi64>
%c18 = arith.constant 18 : index
@aqjune
aqjune / ff_seek_frame_binary.c
Created October 18, 2021 03:20
A function that is in seek-preproc.c
int ff_seek_frame_binary(AVFormatContext *s, int stream_index,
int64_t target_ts, int flags)
{
const AVInputFormat *const avif = s->iformat;
int64_t pos_min=pos_min, pos_max=pos_max, pos, pos_limit;
int64_t ts_min, ts_max, ts;
int index;
int64_t ret;
AVStream *st;
FFStream *sti;