Bash aliases to aid in kernel dev (the previous gist got deleted, sorry)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kgit-config() { | |
git config user.name "Your name" | |
git config user.email "your@email.com" | |
git config commit.gpgsign false | |
git config pull.rebase true | |
git config sendemail.smtpServer "smtp.email.com" | |
git config sendemail.smtpEncryption tls | |
git config sendemail.smtpServerPort 587 | |
git config sendemail.smtpUser "your@email.com" | |
git config sendemail.confirm "always" | |
echo -e '#!/bin/bash | |
patch=$(git show --format=email HEAD) | |
./scripts/checkpatch.pl --show-types --strict --codespell - <<< "$patch" | |
' | awk '{$1=$1};1' > .git/hooks/post-commit | |
chmod u+x .git/hooks/post-commit | |
} | |
alias git-config-kernel=kgit-config | |
alias kpatch-check="git diff | ./scripts/checkpatch.pl --show-types --strict - " | |
kconfig() { | |
case "$1" in | |
"--def") | |
make defconfig | |
./scripts/kconfig/merge_config.sh .config \ | |
/home/yoojer/linux/common.config \ | |
/home/yoojer/linux/kvm.config | |
;; | |
"--fix") | |
./scripts/kconfig/merge_config.sh .config \ | |
/home/yoojer/linux/common.config \ | |
;; | |
"--virt") | |
virtme-configkernel --arch=x86_64 --defconfig | |
./scripts/kconfig/merge_config.sh .config \ | |
/home/yoojer/linux/common.config \ | |
;; | |
"--debug") | |
./scripts/kconfig/merge_config.sh .config \ | |
/home/yoojer/linux/common.config \ | |
/home/yoojer/linux/debug.config \ | |
/home/yoojer/linux/kvm.config | |
;; | |
*) echo "Pass either --def, --fix, --virt, or --debug." | |
;; | |
esac | |
} | |
alias kmake-all="make -j`nproc` all" | |
kemulate() { | |
kernel="./arch/x86_64/boot/bzImage" | |
stretch_image="/home/yoojer/linux/qemu/image/stretch.img" | |
qemu_args="$@" | |
cmd_line="console=ttyS0 root=/dev/sda earlyprintk=serial " | |
cmd_line+="net.ifnames=0 nokaslr " | |
if [[ "$1" == "--selinux" ]]; then | |
cmd_line+="selinux=1" | |
qemu_args="${qemu_args:9}" | |
else | |
cmd_line+="selinux=0" | |
fi | |
qemu-system-x86_64 \ | |
-m 4G \ | |
-smp 6 \ | |
-kernel "$kernel" \ | |
-append "$cmd_line" \ | |
-drive file=$stretch_image,format=raw \ | |
-net user,host=10.0.2.10,hostfwd=tcp:127.0.0.1:10021-:22 \ | |
-net nic,model=e1000 \ | |
-accel kvm \ | |
-cpu host\ | |
-nographic \ | |
-pidfile vm.pid \ | |
$qemu_args \ | |
2>&1 | tee vm.log | |
} | |
kemulate-one() { | |
kernel="./arch/x86_64/boot/bzImage" | |
stretch_image="/home/yoojer/linux/qemu/image/stretch.img" | |
qemu_args="$@" | |
cmd_line="console=ttyS0 root=/dev/sda earlyprintk=serial " | |
cmd_line+="net.ifnames=0 nokaslr " | |
if [[ "$1" == "--selinux" ]]; then | |
cmd_line+="selinux=1" | |
qemu_args="${qemu_args:9}" | |
else | |
cmd_line+="selinux=0" | |
fi | |
qemu-system-x86_64 \ | |
-m 4G \ | |
-smp 1 \ | |
-kernel "$kernel" \ | |
-append "$cmd_line" \ | |
-drive file=$stretch_image,format=raw \ | |
-net user,host=10.0.2.10,hostfwd=tcp:127.0.0.1:10021-:22 \ | |
-net nic,model=e1000 \ | |
-accel kvm \ | |
-cpu host\ | |
-nographic \ | |
-pidfile vm.pid \ | |
$qemu_args \ | |
2>&1 | tee vm.log | |
} | |
kemulate-virt() { | |
kernel="./arch/x86_64/boot/bzImage" | |
stretch_image="/home/yoojer/linux/qemu/image/stretch.img" | |
qemu_args="$@" | |
cmd_line="console=ttyS0 root=/dev/sda earlyprintk=serial " | |
cmd_line+="net.ifnames=0 nokaslr " | |
if [[ "$1" == "--selinux" ]]; then | |
cmd_line+="selinux=1" | |
qemu_args="${qemu_args:9}" | |
else | |
cmd_line+="selinux=0" | |
fi | |
virtme-run \ | |
--kdir . \ | |
--mods auto \ | |
--rw \ | |
--graphics \ | |
--qemu-opts \ | |
-m 4G \ | |
-smp 6 \ | |
-kernel "$kernel" \ | |
-append "$cmd_line" \ | |
-drive file=$stretch_image,format=raw \ | |
-net user,host=10.0.2.10,hostfwd=tcp:127.0.0.1:10021-:22 \ | |
-net nic,model=e1000 \ | |
-cpu host \ | |
-pidfile vm.pid \ | |
-vga virtio \ | |
-display gtk,gl=on \ | |
$qemu_args \ | |
2>&1 | tee vm.log | |
} | |
klogin() { | |
ssh -i /home/yoojer/linux/qemu/image/stretch.id_rsa \ | |
-p 10021 -o "StrictHostKeyChecking no" root@localhost \ | |
2>&1 | tee ssh_op.log | |
} | |
syzkemu() { | |
syzkaller_dir="/home/yoojer/linux/syzkaller" | |
scp -P 10021 -i /home/yoojer/linux/qemu/image/stretch.id_rsa \ | |
$syzkaller_dir/bin/linux_amd64/syz-execprog \ | |
$syzkaller_dir/bin/linux_amd64/syz-executor \ | |
root@localhost:/root/syz/ | |
} | |
ktrace-decode() { | |
(./scripts/decode_stacktrace.sh vmlinux < "$1") > "$2" | |
} | |
kget-maintainers() { | |
./scripts/get_maintainer.pl "$@" | |
} | |
kunit-drm-run() { | |
make ARCH=um mrproper | |
./tools/testing/kunit/kunit.py run \ | |
--kunitconfig=drivers/gpu/drm/tests/ \ | |
--make_options=LLVM=1 \ | |
--kunitconfig=/home/yoojer/linux/kunit.config | |
} | |
kunit-drm-coverage() { | |
make ARCH=um mrproper | |
./tools/testing/kunit/kunit.py run \ | |
--kunitconfig=drivers/gpu/drm/tests/ \ | |
--make_options=CC=gcc-6 \ | |
--kunitconfig=/home/yoojer/linux/kunit.config | |
lcov -t "kunit_tests" -o coverage.info -c -d .kunit/ \ | |
--gcov-tool=gcov-6 | |
genhtml -o /tmp/coverage_html coverage.info | |
firefox /tmp/coverage_html/drivers/gpu/drm/index.html | |
} | |
ksend-patch() { | |
# This is for sending a single patch with Thunderbird. | |
# Prefer git send-email though, the existence of this | |
# implies I already tried to skirt it, unsuccessfully. | |
# Need argument for commit. | |
if [ $# -eq 0 ]; then | |
echo "Provide at least commit ID / branch." | |
return 1 | |
fi | |
# Create and check the patch. | |
patch=$(git format-patch --stdout "$@") | |
echo -e "$patch\n\n" | |
./scripts/checkpatch.pl --show-types --strict - <<< "$patch" | |
if [ $? -ne 0 ]; then | |
# Last command failed. | |
return 1 | |
fi | |
# Remove the first three lines, it is in mbox format but we are going for a GUI client. | |
patch=$(sed -e '1,3d' <<< "$patch") | |
if [[ ${patch:15:1} == "]" ]]; then # Starts with "Subject: [PATCH]" | |
# Save and remove the subject line. | |
subject=${patch#"Subject: "} | |
subject=${subject%%$'\n'*} | |
patch=${patch#*$'\n'} | |
patch="${patch:1}" # Removes the remaining newline. | |
else | |
echo "Supplied multiple patches in one email. Don't do it." | |
return 1 | |
fi | |
thunderbird -compose "format='text',subject='$subject',body='$patch'" > /dev/null 2>&1 & | |
disown | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONFIG_DYNAMIC_DEBUG=y | |
CONFIG_DEBUG_FS=y | |
CONFIG_CONFIGFS_FS=y | |
CONFIG_SECURITYFS=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONFIG_KCOV=y | |
CONFIG_KASAN=y | |
CONFIG_KASAN_INLINE=y | |
CONFIG_FTRACE=y | |
CONFIG_DYNAMIC_FTRACE=y | |
CONFIG_FUNCTION_TRACER=y | |
CONFIG_FUNCTION_GRAPH_TRACER=y | |
CONFIG_IRQSOFF_TRACER=y | |
CONFIG_PREEMPT_TRACER=y | |
CONFIG_SCHED_TRACER=y | |
CONFIG_STACK_TRACER=y | |
CONFIG_BLK_DEV_IO_TRACE=y | |
CONFIG_FUNCTION_PROFILER=y | |
CONFIG_FTRACE_MCOUNT_RECORD=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONFIG_VIRTIO_UML=y | |
CONFIG_UML_PCI_OVER_VIRTIO=y | |
CONFIG_DEBUG_KERNEL=y | |
CONFIG_DEBUG_INFO=y | |
CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y | |
CONFIG_GCOV=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONFIG_HAVE_KVM=y | |
CONFIG_HAVE_KVM_PFNCACHE=y | |
CONFIG_HAVE_KVM_IRQCHIP=y | |
CONFIG_HAVE_KVM_IRQFD=y | |
CONFIG_HAVE_KVM_IRQ_ROUTING=y | |
CONFIG_HAVE_KVM_DIRTY_RING=y | |
CONFIG_HAVE_KVM_EVENTFD=y | |
CONFIG_KVM_MMIO=y | |
CONFIG_KVM_ASYNC_PF=y | |
CONFIG_HAVE_KVM_MSI=y | |
CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT=y | |
CONFIG_KVM_VFIO=y | |
CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT=y | |
CONFIG_KVM_COMPAT=y | |
CONFIG_HAVE_KVM_IRQ_BYPASS=y | |
CONFIG_HAVE_KVM_NO_POLL=y | |
CONFIG_KVM_XFER_TO_GUEST_WORK=y | |
CONFIG_HAVE_KVM_PM_NOTIFIER=y | |
CONFIG_VIRTUALIZATION=y | |
CONFIG_KVM=y | |
CONFIG_KVM_AMD=y | |
CONFIG_DRM_VKMS=y | |
CONFIG_DRM_BOCHS=y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment