[[PageOutline]] [[TitleIndex(Dev/KernelHack,format=group)]] * [http://d.hatena.ne.jp/daisukebe/20080301/p2 socket()システムコールがソケットを確保するまで - HDIF?] = tools = * [http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/SystemTap_Beginners_Guide/topsyssect.html 4.3.5. Tracking Most Frequently Used System Calls] * [https://wiki.ubuntu.com/Kernel/CrashdumpRecipe Kernel/CrashdumpRecipe - Ubuntu Wiki] > LKCD is a project that tries to enable enterprise style post-mortem crash analysis in Linux operating systems. It uses a special mode of kexec which allows to automatically boot a secondary kernel whenever a crash (Oops/panic) occurs. This secondary kernel will then save the state and memory of the primary kernel to a certain location of the filesystem (/var/crash on newer releases). This file can then be used by crash to gather detailed information about the problem. * [http://mikemira.blog29.fc2.com/blog-entry-87.html つれづれにっき  Ubuntu 12.04でkdumpをとりたい] * github:penberg/linux-kvm/tree/master/tools/kvm > The goal of this tool is to provide a clean, from-scratch, lightweight > KVM host tool implementation that can boot Linux guest images (just a > hobby, won't be big and professional like QEMU) with no BIOS > dependencies and with only the minimal amount of legacy device > emulation. * twitter:fadis_/status/322973469979598848 = how to build kernel = * Ubuntuの場合、{{{aptitude build-dep linux}}}でカーネルのビルドに必要なパッケージは導入される * 3.9.x以降をビルドする場合は、{{{bc}}}パッケージも必要 {{{ BC kernel/timeconst.h /bin/sh: 1: bc: not found make[3]: *** [kernel/timeconst.h] Error 127 make[2]: *** [kernel] Error 2 }}} * https://help.ubuntu.com/community/Kernel/Compile * This page does NOT describe how to build upstream kernels from kernel.org. This is how to rebuild the actual Ubuntu kernel starting from source. * [http://d.hatena.ne.jp/haradats/20070819 VMware上のUbuntuで最新カーネルをビルドする - よそ行き顔で] > * パッケージの導入 > * build-essential(これがなくては/usr/includeすらない) > * kernel-package > * libncurses5-dev(make menuconfigを行うために必要。本来kernel-packageに入っていると良いような気がする) > * subversion, subversion-tools(TOMOYOのレポジトリの参照用) > * quilt(もともとはAndrew Mortonが作成したパッチ管理用ツール。自分で使うことはないだろうけれども一応。依存関係でgawkとdiffstatが導入された) > もし、rootでコンパイルしたくなければfakerootもあると良い。 * [http://d.hatena.ne.jp/adsaria/20081104/1225766991 Ubuntuのカーネル再構築 - adsaria mood] * [http://d.hatena.ne.jp/m-bird/20110805/1312507198 Linuxカーネルの再構築方法@Debian Squeeze - m-birdとFreeBSDの同棲日記] * [http://tinkering-is-fun.blogspot.jp/2009/12/compiling-linux-kernel-for-x86-on-x8664.html Tinkering Is Fun: Compiling linux kernel for x86 on x86_64] > Experimenting further reveals that all that is needed is: > {{{ > make ARCH=i386 > }}} * カーネルソースを展開して、「make help」でmakeオプションが表示される == (example) build 3.6.1 on Ubuntu 12.04 and install to 12.10 == * ソースの入手 * mitty@precise:~$ wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.6.1.tar.xz * mitty@precise:~$ tar xJf linux-3.6.1.tar.xz * ビルド環境構築 * mitty@precise:~$ sudo aptitude build-dep linux * mitty@precise:~/linux-3.6.1$ scp mitty@quantal64:/boot/config-3.5.0-17-generic .config * ビルド * mitty@precise:~/linux-3.6.1$ make oldconfig * $ make oldnoconfig -> Same as silentoldconfig but sets new symbols to their default value * mitty@precise:~/linux-3.6.1$ make -j9 deb-pkg * debパッケージのインストール * mitty@precise:~$ scp linux-image-3.6.1_3.6.1-3_amd64.deb mitty@quantal64:~ * mitty@quantal64:~$ sudo dpkg -i linux-image-3.6.1_3.6.1-3_amd64.deb = how to enhancement kernel = * [http://hekimian-williams.com/?p=20 Adding A System Call To Linux (Fedora 9) - Cory’s Place] Fedora 9 kernel 2.6.26 (i686) * [http://hira-consulting.com/wiki/ ようこそ - LinuxKernelHackJapan] 本サイトは、Linuxカーネル内部情報(総3,911ページ)の提供を目的としている。 * [http://www.geocities.jp/dinone_01/linux_driver.html Linux ドライバ作成 初心者編] * http://f42.aaa.livedoor.jp/~hassaku/crswikicrs/ > * LinuxDeviceDriver * [http://www.hakodate-ct.ac.jp/~tokai/tokai/research/kmod.html カーネルモジュール作成メモ] * [http://www.ibm.com/developerworks/jp/linux/library/l-system-calls/ Linux システム・コールを使用したカーネル・コマンド] * [http://stackoverflow.com/questions/290898/overriding-functionality-with-modules-in-linux-kernel c - Overriding functionality with modules in Linux kernel - Stack Overflow] > the kernel has an interface called kprobes to do just what you needed. * http://stackoverflow.com/questions/463332/is-it-possible-to-add-a-system-call-via-a-lkm linux - Is it possible to add a system call via a LKM? - Stack Overflow = debugging Linux Kernel with VMware Workstation = * http://wiki.osdev.org/VMWare > * Guest debugging > * These options are valid in Workstation 6.0+, and should be set in the virtual machine's .vmx file. > {{{ > debugStub.listen.guest32 = "TRUE" > debugStub.listen.guest64 = "TRUE" > }}} > * If using these options, Workstation prints a message "VMware Workstation is listening for debug connection on port 8832." into the vmware.log file. Start a GDB session (using a copy of your kernel that includes debug information), then: > {{{ > target remote localhost:8832 > }}} > * Standard gdb commands work in this mode (e.g. printing memory, backtrace). Note that this is a debug stub attached to the KERNEL, not a userspace program. > * Other useful options: > {{{ > debugStub.listen.guest32.remote = "TRUE" # Allows debugging from a different computer / VM instead of localhost. # The IP for remote debugging will be that of the host. > debugStub.listen.guest64.remote = "TRUE" # Same, but for 64-bit code > monitor.debugOnStartGuest32 = "TRUE" # Breaks into debug stub on first instruction (warning: in BIOS!) # This will halt the VM at the very first instruction at 0xFFFF0, you could set the next breakpoint to break *0x7c00 to break when the bootloader is loaded by the BIOS > debugStub.hideBreakpoints = "TRUE" # Allows gdb breakpoints to work > bios.bootDelay = "3000" # Delay booting the BIOS code. > }}} * windellはVistaとのデュアルブートなため、UTCではなくlocal timeでRTCが設定されている * Ubuntu インストール時に、UTCにすると時計が9時間進む == x86 == * http://archive.ubuntu.com/ubuntu/dists/lucid/main/installer-i386/current/images/netboot/mini.iso * Create a new VM * Ubuntu (not x64) * ubuntu-lucid * 1/1 cpu/core * 512MB * NAT * Buslogic == x64 == * viola0![1-6]でビルドする場合、そのままではx86_64のカーネルが作られるので注意 * http://archive.ubuntu.com/ubuntu/dists/lucid/main/installer-amd64/current/images/netboot/mini.iso * Create a new VM * Ubuntu 64-bit * ubuntu-lucid64 * 1/1 cpu/core * 512MB * NAT * LSI Logic * BusLogicはx64ゲストでは使用出来ないとのこと * [http://blog.zhangsen.org/2008/12/how-to-add-syscall-on-x8664.html Jesse's Blog: how to add syscall on x86_64] * [http://forum.soft32.com/linux/system-call-implementation-x86_64-ftopict344646.html system call implementation for x86_64] = Serial Console = * https://www.kernel.org/doc/Documentation/serial-console.txt https://www.kernel.org/doc/Documentation/serial-console.txt * [http://www.aji.sakura.ne.jp/linux/kernel_options.html Linux カーネル 起動オプション] > {{{ > console=tty0 console=ttyS0,115200n8r > }}} * see also wiki:TipAndDoc/VM/QEMU#ConsoleRedirection * http://qemu.weilnetz.de/qemu-doc.html#direct_005flinux_005fboot 3.9 Direct Linux Boot * ex) $ sudo qemu-system-x86_64 -m 512 -vnc :1 -kernel /boot/vmlinuz-3.5.0-45-generic -append "console=tty0 console=ttyS0,115200n8r" -serial stdio {{{ qemu-system-x86_64: pci_add_option_rom: failed to find romfile "pxe-rtl8139.rom" [ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Linux version 3.5.0-45-generic (buildd@toyol) (gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) ) #68-Ubuntu SMP Mon Dec 2 21:58:52 UTC 2013 (Ubuntu 3.5.0-45.68-generic 3.5.7.26) [ 0.000000] Command line: console=tty0 console=ttyS0,115200n8r (smip) }}} * マニュアルには{{{When using the direct Linux boot, a disk image for the first hard disk hda is required because its boot sector is used to launch the Linux kernel.}}}とあるが、少なくともqemu-kvm-1.2.0+noroms-0ubuntu2.12.10.6, Debianでは不要な模様