Skip to content

Latest commit

 

History

History
119 lines (81 loc) · 3.54 KB

kernel.mkd

File metadata and controls

119 lines (81 loc) · 3.54 KB

debugfs read

refer to http://lxr.free-electrons.com/source/drivers/base/regmap/regmap-debugfs.c#L30

simple_read_from_buffer

snprintf, scnprintf

http://lwn.net/Articles/69419/ http://lwn.net/Articles/334546/

int scnprintf(char *buf, size_t size, const char *format, ...);
int vscnprintf(char *buf, size_t size, const char *format, va_list args);

verify_area

All, looks like verify_area is no longer in this kernel version. Some architectures have redefined it for their convenience. See:

http://lxr.fsl.cs.sunysb.edu/linux/source/arch/mn10300/include/asm/uaccess.h#L75

You can do the same, or call access_ok as follows

if (!access_ok(VERIFY_READ, ptr, len))
    return -EFAULT;

kenerl crypto example of using scatterlist

http://lxr.fsl.cs.sunysb.edu/linux/source/net/ceph/crypto.c#L197

kernel debugging

Obviously, we strongly suggest you to recompile your kernel, so that you can enable a number of useful debugging features, such as forced module unloading (MODULE_FORCE_UNLOAD): when this option is enabled, you can force the kernel to unload a module even when it believes it is unsafe, via a rmmod -f module command.

Ring 0

Ring 0: os operation mode

X86 modes

x86 Real mode (state at boot; 20-bit address, no virtual memory; no paging)

x86 Protected mode (VM, segmentation and paging)

x86 Long mode

control registers

cr3 (control register 3) point to current paging table

TLB

TLB (Translation Lookaside Buffer) is not coherent with memory (tlb_invalidate)

Parkinson's law

To paraphrase Parkinson's law, "Programs expand to fill the memory available to hold them."

block device

Floppy and hard disks for PCs are divided into 512 byte regions called sectors. A sector is the disk's minimum transfer granularity: each read or write operation must be one or more sectors in size and aligned on a sector boundary.

exceptions

Faults: Can generally be corrected; once corrected, the program is allowed to restart with no loss of continuity.

Trap: Reported immediately following the execution of the trapping instruction; after the kernel returns control to the program, it is allowed to continue its execution with no loss of continuity.

update kernel module without deleting the old one

/lib/module//updates/ directory and depmod

# cd e1000/src
# make (DON.T RUN make install!)

These steps will create the e1000.k[o] in the e1000/src directory but will not
automatically install the kernel module. The remaining steps are:
copy the e1000.k[o] file from the e1000/src directory into the
/lib/modules/<KERNEL VERSION>/updates directory. If the updates directory
doesn.t exist, create it.

# depmod

This will not overwrite the old e1000 kernel module. The newest module will be
loaded from the updates directory. If you need to roll back, all you would need
to do is delete the e1000.k[o] file from the /lib/modules/<KERNEL
VERSION>/updates directory and run depmo

/proc/slabinfo

#cat /proc/slabinfo | grep delegation
nfsd4_delegations      0      0    368   10    1 : tunables   54   27    8 : slabdata      0      0      0

/proc/kallsyms

All kernel symbols

kdump

http://www.thegeekstuff.com/2014/05/kdump/

configure:

  • install yum install kexec-tools

  • append "crashkernel=128M" to the kernel boot parameter

  • edit "/etc/kdump.conf" to the correct path

  • start kdump

    chkconfig kdump on

    service kdump start

and test

# cat /proc/cmd-line
# service kdump status
# echo 1 > /proc/sys/kernel/sysrq
# echo c > /proc/sysrq-trigger