]> git.feebdaed.xyz Git - linuxyz.git/commitdiff
kfault
authorseantywork <seantywork@gmail.com>
Thu, 19 Jun 2025 12:48:25 +0000 (12:48 +0000)
committerseantywork <seantywork@gmail.com>
Thu, 19 Jun 2025 12:48:25 +0000 (12:48 +0000)
README.md
kfault/Makefile [new file with mode: 0644]
kfault/fault.c [new file with mode: 0644]

index f5aa283e3bc64852b6794ba36c788f7de02be9e6..df0d0c083a7104525d91eec66a561eeb87b1f4f8 100644 (file)
--- a/README.md
+++ b/README.md
@@ -479,7 +479,7 @@ efibootmgr
 ```shell
 
 # should be enabled
-# /boot/config
+# /boot/config-$(uname -r)
 
 CONFIG_RELOCATABLE=y
 CONFIG_KEXEC=y
@@ -489,7 +489,20 @@ CONFIG_DEBUG_INFO=y
 
 sudo apt update
 
-sudo apt install kdump-tools crash kexec-tools makedumpfile linux-image-$(uname -r)-dbg
+sudo apt install kdump-tools crash kexec-tools makedumpfile
+
+# dbg symbol package
+
+sudo apt install ubuntu-dbgsym-keyring
+
+sudo echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse
+deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse
+deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse" | \
+sudo tee -a /etc/apt/sources.list.d/ddebs.list
+
+sudo apt update
+
+sudo apt install linux-image-$(uname -r)-dbgsym
 
 # yes
 
@@ -497,8 +510,24 @@ sudo apt install kdump-tools crash kexec-tools makedumpfile linux-image-$(uname
 
 sudo grep USE_KDUMP /etc/default/kdump-tools
 
-grep LOAD_KEXEC /etc/default/kexec
+sudo grep LOAD_KEXEC /etc/default/kexec
+
+# check
+
+sudo kdump-config show
+
+# after panic and reboot
+
+sudo -i
+
+cd /var/crash/$CRASH_TIMESTAMP
+
+root@ubuntu24-8:/var/crash/xx# ls
+dmesg.xx  dump.xx
+
+# read dump
 
+crash /usr/lib/debug/boot/vmlinux-$(uname -r) dump.xx
 ```
 
 # GCC G++ CLANG COMPILE
diff --git a/kfault/Makefile b/kfault/Makefile
new file mode 100644 (file)
index 0000000..15430ce
--- /dev/null
@@ -0,0 +1,7 @@
+obj-m += fault.o
+
+all:
+       make -C /lib/modules/`uname -r`/build M=`pwd` modules
+
+clean:
+       make -C /lib/modules/`uname -r`/build M=`pwd` clean
\ No newline at end of file
diff --git a/kfault/fault.c b/kfault/fault.c
new file mode 100644 (file)
index 0000000..409f2cc
--- /dev/null
@@ -0,0 +1,67 @@
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/time.h>
+#include <linux/delay.h>
+#include <linux/workqueue.h>
+
+static DECLARE_WAIT_QUEUE_HEAD(this_wq);
+
+
+static struct work_struct job;
+
+
+static void job_handler(struct work_struct* work){
+
+    u8 okay[16] = {0};
+
+    u8* bomb = NULL;
+
+    printk(KERN_INFO "waitqueue handler: %s\n", __FUNCTION__);
+
+    printk(KERN_INFO "counting 5 seconds before light out\n");
+
+    for(int i = 1; i <= 5; i++){
+
+        printk(KERN_INFO "%d...\n", i);
+
+        msleep(1000);
+    }
+
+    printk(KERN_INFO "GOODBYE, WORLD!!!!\n");
+
+    
+    for(int i = 0 ; i < 16; i++){
+
+        if(okay[i] == bomb[i]){
+            printk(KERN_INFO "equal at %d: %d\n", okay[i]);
+        } else {
+            printk(KERN_INFO "not equal at %d: %d != %d\n", okay[i], bomb[i]);
+        }
+
+    }
+
+}
+
+static int __init fault_init(void){
+
+    printk(KERN_INFO "fault init\n");
+
+    INIT_WORK(&job, job_handler);
+
+    schedule_work(&job);
+
+    return 0;
+}
+
+static void __exit fault_exit(void){
+
+    printk(KERN_INFO "fault exit\n");
+
+}
+
+module_init(fault_init);
+module_exit(fault_exit);
+
+MODULE_AUTHOR("seantywork");
+MODULE_LICENSE("GPL");
\ No newline at end of file