Questions tagged [linux-kernel]

This tag is for questions about the internals of the Linux kernel itself - particularly about writing code that runs within the context of the kernel (like kernel modules or drivers). Questions about writing userspace code in Linux should generally be tagged [linux] instead. Since the internals of the Linux kernel are constantly changing, it is helpful to include the precise kernel version(s) that you are interested in.

This tag is for questions about the internals of the Linux kernel itself - particularly about writing code that runs within the context of the kernel (like kernel modules or drivers).

Questions about writing userspace code in Linux should generally be tagged instead. Since the internals of the Linux kernel are constantly changing, it is helpful to include the precise kernel version(s) that you are interested in.

The kernel is a UNIX-like kernel initially created by Linus Torvalds in 1991 and now is maintained by developers around the world.

Frequently Asked Questions

Online resources

Books

Kernel source code and source code browsers

Further reading

Mailing lists

17371 questions
6
votes
1 answer

Where is the memory allocation of "__this_module" variable?

From : #ifdef MODULE #define MODULE_GENERIC_TABLE(gtype,name) \ extern const struct gtype##_id __mod_##gtype##_table \ __attribute__ ((unused, alias(__stringify(name)))) extern struct module…
Nan Xiao
  • 16,671
  • 18
  • 103
  • 164
6
votes
1 answer

Adding a new system call to Linux that requires root privileges

I'm trying to add a system call to the linux kernel(version:3.10.91) that requires root privileges to run. You can see my attempt below: #include #include #include #include #include…
SpiderRico
  • 1,890
  • 8
  • 28
  • 48
6
votes
1 answer

Futexes and blocking in the kernel

I was reading some documentation and trying out a few samples of code that issue the futex system call in Linux. I read that if a mutex is acquired by thread_a using FUTEX_LOCK_PI, and say if another thread thread_b tries to acquire the same, the…
user277465
6
votes
2 answers

How to use find_module?

How to use linux kernel's find_module() function? The documentation says "must hold module_mutex". Does that mean that I should acquire a lock in my module code before searching for a pointer to another? When this mutex is locked by non-module…
Basilevs
  • 22,440
  • 15
  • 57
  • 102
6
votes
2 answers

Are there any DMA Linux kernel driver example with PCIe for FPGA?

I would like to write a driver in kernel space that: Communicate a FPGA connected by PCIe in a embedded system( with powerPC). It uses DMA to transfer information from the FPGA to RAM. User programs have to access to this information. I need some…
manolo tunez
  • 131
  • 1
  • 2
  • 9
6
votes
2 answers

Understanding the kernel dmesg timestamp

I want to decode the time format in the kernel logs: <3>[ 107.236115] <3>[ 107.245076] <4>[ 107.521858] <3>[ 107.522098] Is there any way to convert those time stamps into a "min:sec:msec" format? I found some scripts to decode which are…
srujan
  • 97
  • 1
  • 2
  • 6
6
votes
1 answer

What is the "linux-2.6.3x.x/include/asm-generic/' for?

My os-book says that if you want to add a system call to the Linux kernel, edit the linux-2.x/include/asm-i386/unistd.h. But the linux kernel's source structure seems to change a lot. In the linux-2.6.34.1 version kernel source tree, I only find a…
Zifei Tong
  • 1,697
  • 1
  • 19
  • 32
6
votes
1 answer

When to use /proc and when /dev

I need to write a kernel module that is not a device driver. That module will be communicating with some user space processes. As I dont want to use ioctl(), I am left with either creating a file in /proc directory or creating a device file in /dev…
binW
  • 13,220
  • 11
  • 56
  • 69
6
votes
2 answers

MCR and MRC does not exist on AARCH64?

I am trying to compile "mrc" and "mcr" instruction on AARCH64 based on Board but I am seeing below error message tmp/ccqOHmrK.s: Assembler messages: /tmp/ccqOHmrK.s:43: Error: unknown mnemonic `mrc' -- `mrc p15,0,x0,c14,c3,1' …
Amit Singh Tomar
  • 8,380
  • 27
  • 120
  • 199
6
votes
2 answers

How is a spin lock woken up in Linux/ARM64?

In the Linux kernel, arch_spin_lock() is implemented as follows: static inline void arch_spin_lock(arch_spinlock_t *lock) { unsigned int tmp; arch_spinlock_t lockval, newval; asm volatile( /* Atomically increment the next ticket.…
6
votes
2 answers

How i get absolute path in kernel space from file descriptor

I am trying to hook unlinkat.my hooking function. but i get only file name instead of absolute path.so i want absolute path to compare string.when i try rm -r than i get only file name if i get absolute path then it works.so please tell me how i get…
vikas_saini
  • 159
  • 1
  • 10
6
votes
2 answers

`./scripts/recordmcount: Syntax error: "(" unexpected` is reported when I compile driver module on Raspberry Pi

I recompiled my Raspberry Pi's Linux Kernel to enable some debug features. The new kernel is compiled on my X86 desktop PC by the tools that are supplied by https://github.com/raspberrypi/tools. The new kernel seems working fine until that I compile…
Douglas Su
  • 3,214
  • 7
  • 29
  • 58
6
votes
3 answers

What is the meaning of a phandle when used as device tree node name?

This code snippet comes from the device tree for the RIoTBoard (/arch/arm/boot/dts/imx6dl-riotboard.dts) &hdmi { ddc-i2c-bus = <&i2c2>; status = "okay"; }; I have gone through the device tree documentation both on devicetree.org…
Irr
  • 656
  • 1
  • 9
  • 19
6
votes
1 answer

Intercept ELF loader in linux kernel: fs/binfmt_elf.c file via loadable kernel module

I am new to kernel coding and at present I am working with ELF files which have been modified a little bit for the security purposes for which I need to look at some of it's custom section headers and extract the unique code encryption key from it…
bawejakunal
  • 1,678
  • 2
  • 25
  • 54
6
votes
3 answers

How to determine system value for _POSIX_PATH_MAX

Can anyone please tell me how to find the system value for _POSIX_PATH_MAX in Linux mint? I know that it is available in the file but I do not know how to find its value.
robert williams
  • 747
  • 2
  • 11
  • 18