Questions tagged [linux-kernel]

1

votes
4

answer
2.9k

Views

The implementation of copy_from_user()

I am just wondering why does copy_from_user(to, from, bytes) do real copy? Because it just wants kernel to access user-space data, can it directly maps physical address to kernel's address space without moving the data? Thanks,
stream101
1

votes
0

answer
21

Views

How do I copy over an integer from kernel space using copy_to_user?

Problem I am unable to copy over the data. User Space Here is my user space: #include #include #include #include #include #include #include int main (int argc, char *argv[]) { void *mytask; short allsize; struct sysinfo si; struct passwd *passwdStruct; // to get the userid of my raspberry pi so i c...
GioPoe
1

votes
1

answer
1.6k

Views

Create sysfs entry from kernel module

I want to pass a string > 1024 chars to my module (filesystem). As kernel parameters are limited to 1024 chars, someone recommended to use sysfs instead. I tried to include this example in my super.c class to create a string 'filename' & string 'code' entry in sysfs for my module. static decl_subsys...
goose999
1

votes
1

answer
1.4k

Views

How to pass compiler options during Linux kernel compilation?

For reasons, I need to compile the Linux kernel (currently 4.7.10) passing some simple and innocent additional command line options (e.g. -pipe -Wsomething etc) to the C compiler. How do I do it? More specifically, how do I enforce these compiler flags during plain make as well as during make menuco...
jotik
1

votes
1

answer
1.1k

Views

Linux module __must_check annotation

I'am learning development of module Linux, I begin.I read articles and tuto, so I found a site which supplies a source code for a simple char device. In this code a __must_check is used for one function. Here is prototype : __must_check int register_device(void); And this is function : int registe...
simon
0

votes
1

answer
14

Views

Why does the exception handler look up the system call table?

I am learning how system calls work. I know that for a system call to take place, the exception handler is invoked via a software interrupt. The exception handler then reads the system call ID from the eax register and then looks-up the system call table for the function's absolute address. How does...
0

votes
0

answer
6

Views

Will Linux kernel read before writing data which small than filesystem block size?

For example, File system block size is 4k, but I only write 1 byte to the file using Direct IO, will kernel read this block to page cache before writing?
pedia
0

votes
0

answer
2

Views

Why it is not possible to set permission on FAT fs?

chmod and mount from util-linux ackts unpredicteble when working under normal user, there is no any whey to set permission.
Hellseher
1

votes
1

answer
283

Views

How is module version checksum evaluated?

I have 2 copies of Linux kernel code (same version: 3.0.1), one is vanilla source code and the other with some modifications. After compiling both of them with the same config file (the unmodified code prompts for some additional configurations about drivers during make), they output slightly differ...
Xiangyu Zhu
1

votes
1

answer
66

Views

Is there a caching mechanism when using directly Linux VFS functions?

I'm building an application on top of KVM hypervisor where I access (thousand of times) a small database (3 mb) by calling directly Linux kernel VFS functions. After building a stable prototype of my application, I want to optimise its access to the database (by adding a cache for example). I know t...
Yacine Hebbal
1

votes
1

answer
1k

Views

How does the Linux kernel create the /proc/$pid/maps file?

I am doing some memory introspection and it requires me to know how proc/$pid/maps is created. I'm a bit confused by the code found in http://lxr.free-electrons.com/source/fs/proc/base.c on line 2750 I notice that there is a definition in this struct for maps but I want to know for each pid_entry wh...
dimlee
1

votes
1

answer
290

Views

How to flush memory before a pci device reads memory in linux kernel

I have a pci device that reads memory allocated by dma_alloc_coherent In the kernel documentation it says: 'You may however need to make sure to flush the processor's write buffers before telling devices to read that memory' How exactly do i do that? how do i flush the memory so that the device read...
yonigo
1

votes
2

answer
1k

Views

Creating a simple audio driver for a Cyclone V SoC (Linux)

I'm designing software for a board using an Altera Cyclone V SoC (ARM Cortex-A9 running Linux coupled to an FPGA). The Linux OS is running fine with support for on-board peripherals (Ethernet, SD card, etc.) and I can access the FPGA from userspace programs, currently using mmap(), though. Now, the...
Philipp Burch
1

votes
1

answer
627

Views

What are the Contents of /proc/vmcore

When the Kernel panics, it generates the /proc/vmcore file. Later we could use the makedumpfile utility to generate coredump using this vmcore file. What are the contents of this vmcore file? Does it contain Kernel Memory Region like Stack Area, Heap Area, Code Area and Constants? Does it also con...
Dinesh P.R.
1

votes
1

answer
312

Views

Compiling linux kernel (4.4) bpf samples with -O0 results in error

If I compile samples/bpf/ from linux kernel with change in optimization as -O0, I'm getting following error. Though with -O2 (which is default in Makefile) works fine. Can anyone please explain what's wrong here. $ make samples/bpf/ [...] clang -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.9/i...
Ravi
1

votes
1

answer
359

Views

Information about network interface in kernel space

How can I get information about let's say eth0 in kernel space? I need to know if it's enabled or disabled, if it has set ipv6 (and ipv6 of course).
Kalvy
1

votes
1

answer
352

Views

Are linux IO ports software abstractions or real hardware ports

I am learning linux device drivers. I learned about ports. I am confused that are ports in linux a software abstraction or are real hardware ports. In the below device driver I wrote a code to allocate a port and to write or read. The port is allocated even if there is no new hardware connected. Wha...
Debesh Mohanty
1

votes
1

answer
104

Views

Linux kernel boot configuration

I am working on SH architecture, I found CONFIG_ZERO_PAGE_OFFSET=0x800000 CONFIG_ENTRY_OFFSET=0x00001000 in my kernel configuration. Can any one tell me, what is significance of these offsets? How are they used by kernel? Thanks in advance.
iGRJ
1

votes
2

answer
193

Views

linking error while trying to add print_stack_trace

I am getting a error that looks like a linking problem, after adding a call to 'print_stack_trace' in one of the exception handlers inside my embedded Linux kernel code. Details are as below: My objective & context: I am trying to debug an 'imprecise external abort' memory fault during my kernel's b...
manikandan
1

votes
1

answer
458

Views

is there any difference between list_head and LIST_HEAD

LIST_HEAD is found in the sys/queue.h file. After using man list_head, I get to know about 'LIST_HEAD' but not about 'list_head'. I'm just curious what are the definitions of LIST_HEAD and list_head. In which files are these definitions located in the include directory (I tried to use grep (grep com...
Harish Chennamsetty
1

votes
1

answer
96

Views

Linux kernel crash call stack length

Would anyone be able to tell how I can easily increase the number of call stack functions reported on a Linux Kernel crash? Currently I see: [] (free_buffer_head) from [] (try_to_free_buffers+0x7c/0xbc) [] (try_to_free_buffers) from [] (invalidate_inode_page+0x64/0x7c) [] (invalidate_inode_page) f...
amarkov
1

votes
1

answer
65

Views

How can linux be a kernel and an OS at the same time

I got some questions : - is Linux an OS or kernel (if both how?) - are the drivers a a part of a kernel or just stands between the kernel and the hardware - what does a driver do exactly (I already know that it takes system calls and gives them to the cpu) - what is API and ABI in lay man words (...
Mekacher Anis
1

votes
1

answer
1.4k

Views

dma_alloc_coherent failed on x86_64 but works on i686

I have a driver for pci device which uses CMA allocation mechanism for DMA allocations. It works fine on kernel 3.18 in 32bit mode but when I try to use it in 64 kernel(same config as in 32bit, but switched on 64bit mode) dma allocation failed. Only thing I see in dmesg is: fallback device: swiotlb...
dtoch
1

votes
1

answer
989

Views

Is kfree parts of memory valid or not?

I am debugging a memory corruption issue and found that Linux kernel seems to accept user to 'free parts of buffer'. Textbook always teaches us to call alloc/free in pairs. I get confused! So I write a small test running in Linux kernel. char *p_buf, *p_buf2; p_buf = kmalloc(1024, GFP_KERNEL); /...
acolor
1

votes
2

answer
239

Views

Accellera SystemC error with a large number of SC_THREAD

In the context of a SystemC simulation with many SC_THREAD processes (> 32000), I am facing the following error with the Accellera 2.3.1 implementation on an Intel X86 platform running Ubuntu 15.04: sc_cor_qt.cpp:114: virtual void sc_core::sc_cor_qt::stack_protect(bool) Assertion `ret == 0' failed...
Manuel Selva
1

votes
1

answer
259

Views

Content wrong inside mmap'ed memory (Kernelspace<>Userspace)

I implement a memory mapping via mmap. My Kernel module writes something into this memory and a userspace application read this. In short I allocate 0x10000 memory (with kcalloc on kernel side and with mmap on userspace side). Then I write something to the address offsets 0x0, 0xf00 and 0xf000 using...
Alex44
1

votes
2

answer
3.9k

Views

How to directly send touch events to /dev/input/event?

I want to send touch events throughout Android system. I'm sending events from a background service. My device is rooted and I've stored my app in /system/app. I tried instrumentation and system/bin/input tab, instrumentation didn't work outside the app, and the second one doesn't generate an error...
Dania
1

votes
1

answer
2.2k

Views

create_singlethread_workqueue in linux

I am very much new to the linux kernel development and getting confused in understanding the function create_singlethread_workqueue(). Can any one please provide with a basic example what exactly does create_singlethread_workqueue() do and what is the job of INIT_WORK .From the explanations I read i...
arpit joshi
1

votes
1

answer
1k

Views

How to set and lock cpu freq in linux

I am working under linux and what I want to do is to lock cpu to a certain frequency, disable cpu automatic freq change. Could anyone indicate how to do it in driver or kernel ? Thanks.
roMoon
1

votes
1

answer
612

Views

Samsung Android Kernel Development Toolchain

So, for building the open source version of Android, you need a toolchain to be able to build the kernel. How on earth do you know which version of the toolchain to download? I know it's dependent on the kernel version. But how do you work this out? On the Android website, in the Building Kernels se...
Rhythm17
1

votes
0

answer
6

Views

Developing Linux C++ program on a specific device

I've built Linux on a FPGA (Zedboard) with customized hardware using a open source hdl, and now I want to add applicationg to use this hardware. My problem is that I have to build the hardware using 2013 version Vivado, but I want to use a 2018 Xilins SDK to develop my application, which would not a...
j.young
1

votes
1

answer
178

Views

Behaviour or -EFAULT, Linux kernel

I am running some test cases that I know will cause my program (running in kernel space) to return an -EFAULT. Here is the code that returns the fault: for (index = 0; index < size; index++){ //copy_from_user checks to make sure input parameter is valid. Returns 0 on success if(copy_from_user(&curre...
Adam
1

votes
2

answer
355

Views

Counting the number of siblings a process has, Linux kernel

I'm using the list_for_each macro and the sibling field of the current task_struct to print out the number of siblings current has. Here's the code (inf.num_siblings tracks the number of siblings): struct list_head *curr_node; .... list_for_each(curr_node, &(current->sibling)) { inf.num_siblings++;...
Adam
1

votes
1

answer
243

Views

C Preprocessor KERNEL_VERSION reference bug fix

I am trying to fix a driver that references d_alias or d_u.d_alias in kernel 3.16.0-69. The macro looks for the kernel versions and uses the appropriate one. #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) || LINUX_VERSION_CODE == KERNEL_VERSION(3,12,49) || LINUX_VERSION_CODE == KERNEL_VERSION(3,16...
stephenc01
1

votes
1

answer
55

Views

how create a makefile for program.c and how to compile and execute in Real Time Application Interface

I have a hollowworld.c : /* hello.c */ #include #include MODULE_LICENSE('GPL'); int init_module(void) { printk('Hello world!\n'); /* printk = kernel printf, to the console */ return 0; } void cleanup_module(void) { printk('Goodbye world!\n'); return; } how create a makefile for program.c and h...
BkarimCe
1

votes
1

answer
863

Views

netlink multicast from kernel to user space error in linux kernel 3.10 in c

I have refered to the following source by Yd Ahhrk Multicast from kernel to user space via Netlink in C the module is insmod correctly , lsmod|less can see it is there , but while try to run user space application , I have the error: seotsockopt < 0 In user space application , it is doing the grou...
barfatchen
1

votes
1

answer
61

Views

Why is there a design difference between the way interrupts are serviced in case of linux and unix?

In the book The Design of the Unix Operating System by Maurice it is mentioned that interrupts are serviced in the context of the running process as it doesn't spawns a new process to service interrupts. So, in Unix a processor is doing exactly one of the two things: 1. In user-space, executing user...
Albert
1

votes
2

answer
93

Views

What trailer means in kernel hacking slang?

Reading though the raspberry documentation. I found these text 'Note that DT and ATAGs are mutually exclusive. As a result, passing a DT blob to a kernel that doesn't understand it causes a boot failure. To guard against this, the loader checks kernel images for DT-compatibility, which is marked by...
atevm
1

votes
1

answer
240

Views

“__tracepoint_sched_process_fork undefined” when run systemstap script

The error info : WARNING: '__tracepoint_sched_process_fork' [/tmp/stapH5cHsd/stap_958d0ff0e571c9357f1e193511d8baa3_269311.ko] undefined! WARNING: '__tracepoint_sys_exit' [/tmp/stapH5cHsd/stap_958d0ff0e571c9357f1e193511d8baa3_269311.ko] undefined! WARNING: '__tracepoint_sys_enter' [/tmp/stapH5cHsd/st...
vollen
1

votes
1

answer
697

Views

Multicast routing , why do we need pimreg interface?

I'm using pimd in my project. https://github.com/troglobit/pimd. PIM daemon creates a 'pimreg' virtual interface. Multicast routing works perfectly. but I'm curious why do we need 'pimreg' interface at all. The code which handles virtual interface creation in kernel is: static struct net_device *ip...
Pramod

View additional questions