Skip to content

Instantly share code, notes, and snippets.

@sandip4n
sandip4n / risudump
Last active July 5, 2018 10:20
Dumping Risu Test Blobs
#!/bin/sh
# risudump - A wrapper script for dumping test blobs generated by
# risu (https://git.linaro.org/people/peter.maydell/risu.git)
#
# Copyright (C) 2018 Sandipan Das
#
if [ -z "$1" ] ; then
echo "Usage: $0 <file>"
exit 1
struct resv_map
--> for MAP_SHARED, resv_map is preallocated at some point and kept
in the inode mapping metadata
--> inode_resv_map()
--> resv_map = inode->i_mapping->private_data
--> for MAP_ANONYMOUS, vma->vm_private_data points to the map
sys_mmap() with MAP_PRIVATE, MAP_ANONYMOUS, MAP_HUGETLB in flags
--> ksys_mmap_pgoff()
--> hugetlb_file_setup()
#define _LARGEFILE64_SOURCE
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <errno.h>
#include <sys/mman.h>
/*
* Compile as follows:
* gcc -O0 -nostdlib -static gem5-endian-test.c
*/
#ifndef __powerpc64__
#error "unsupported architecture"
#endif
#define MSG "Hello world\n"
diff --git a/src/arch/power/isa/decoder.isa b/src/arch/power/isa/decoder.isa
index 0dbe35a88..dd4a3a83c 100644
--- a/src/arch/power/isa/decoder.isa
+++ b/src/arch/power/isa/decoder.isa
@@ -40,6 +40,14 @@
//
decode PO default Unknown::unknown() {
+ format IntOp {
+ // Fake endianness switch
@sandip4n
sandip4n / generate-git-completions.fish
Last active October 24, 2019 11:45
Fish shell script to generate git completions
for file in (find $HOME/.config/fish/completions -name 'git-*.fish')
set gitcmd (basename $file .fish)
set subcmd (echo $gitcmd | sed 's/git-//g')
sed -i 's/'$gitcmd' /git -n \'__fish_git_using_command '$subcmd'\' /1' $file
end
@sandip4n
sandip4n / xyz-tracer.py
Last active October 1, 2019 09:09
bpf: read nested struct members
#!/usr/bin/python
from __future__ import print_function
from bcc import BPF
from bcc.utils import printb
from time import sleep
# load BPF program
b = BPF(text="""
#include <uapi/linux/ptrace.h>
@sandip4n
sandip4n / hello.s
Created November 1, 2019 07:39
Hello World - PPC64LE Assembly
## Hello World - PPC64LE Assembly
## This is the ELF ABI v2 little-endian equivalent of
## https://developer.ibm.com/articles/l-ppc/#listing-4-hello-world-ppc64-assembly
##
## Cross-compile as shown below.
## $ powerpc64le-linux-gnu-as hello.s -o hello.o
## $ powerpc64le-linux-gnu-ld hello.o -o hello
##
## Author: Sandipan Das <sandipan@linux.ibm.com>
##
## Building on Fedora 31
sudo dnf -y install python2-scons python3-scons python2-devel python3-devel \
protobuf-devel protobuf-compiler gperftools-devel
## Generate Gtags
find src/ -type f -print | gtags -i -f -
## Build for POWER
scons CPU_MODELS="AtomicSimpleCPU" build/POWER/gem5.debug -j4
/*
* Compile as:
* powerpc64-linux-gnu-gcc -o radix-stress -g -O0 \
* -mcpu=powerpc64 -mno-altivec \
* -mno-vsx -nostdlib -static \
* radix-stress.c
*/
#ifndef __powerpc64__
#error "unsupported architecture"