FAQ Database Discussion Community


Are shared library pages anonymous?

c,linux,memory-management,linux-kernel,kernel
From my understanding, memory mapped pages are pages that are backed by files whereas anonumous pages are pages that are allocated without a file or device backing them. According to this definition, memory pages that belong to shared libraries should be marked as memory mapped and should not be marked...

Get struct device pointer for this module?

kernel,driver,linux-device-driver
Is there a way to get pointer to "struct device" for current module in kernel driver ? Thank you, Ran...

How to load a module (not a driver) when a USB device is plugged in

c,linux,kernel
#include<linux/init.h> #include<linux/module.h> #include <linux/usb/input.h> #include <linux/hid.h> /* * Version information */ #define DRIVER_VERSION "" #define DRIVER_DESC "Hello World module" #define DRIVER_LICENSE "GPL" MODULE_LICENSE(DRIVER_LICENSE); MODULE_AUTHOR(DRIVER_AUTHOR); static void __exit hello_world_exit(void) { pr_debug("Bye!\n"); } static int __init hello_world_init(void) { pr_debug("Hello, USB!"); return 0; } static struct usb_device_id usb_kbd_id_table[] = { {...

how to include header correctly in the opencl kernel

header,kernel,opencl
I am writing an opencl kernel with many helper function in the same .cl file. I want to package the helper function into a header file. I read the spec and see I should pass -I Dir in the clCreateProgram function call. I am still confused here. When I crate...

What is a kernel stack used for?

process,operating-system,stack,kernel,context-switch
The following is a description I read of a context switch between process A and process B. I don't understand what a kernel stack is used for. There is suppose to be a per process kernel stack. And the description I am reading speaks of saving registers of A onto...

Why does this code works well? It changes the Constant storage area string;

linux,module,kernel,constants
this is a simple linux kernel module code to reverse a string which should Oops after insmod,but it works well,why? #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> static char *words = "words"; static int __init words_init(void) { printk(KERN_INFO "debug info\n"); int len = strlen(words); int k; for ( k = 0;...

VLAN information using NETLINK

c,linux,kernel,netlink,vlan
How do you get VLAN information like addition and deletion of VLAN sub interface from kernel to userspace using NETLINK socket in C? I did little study in NETLINK man as suggested in comments. I added and deleted a VLAN sub interface and monitored using netlink socket program. For addition...

“invalid configuration argument ” error for the call of CUDA kernel

cuda,kernel,gpu
I have GEFORCE 620M and my code is: int threadsPerBlock = 256; int blocksPerGrid = Number_AA_GPU / threadsPerBlock; for(it=0;it<Number_repeatGPU;it++) { Kernel_Update<<<blocksPerGrid,threadsPerBlock>>>(A, B,C, D, rand(), rand()); } and I get : invalid configuration argument. what could be the reason? ...

Dynamically creating variable in Kernel Module

linux-kernel,kernel,kernel-module
I am planning to use kthread_run API in my kernel module. As kthread_run, returns a struct task_struct *, which i want to store in a variable global across my module. However, i want one thread each for a cpu and i obtain no of cpus using num_online_cpus. However, when i...

Thread Context of main() after Kernel start

kernel,main,scheduler,rtos
Considering a code base where we have a main(). After calling the kernel start function, we have the OS running. Now in the context of which thread does the code snippet after the kernel start function call runs? int main() { /* DO SOMETHING */ /* Start scheduler */ osKernelStart();...

Bare bones OS kernel programming

c,linux,assembly,operating-system,kernel
I have recently started to take an interest in the topics of operating systems. I have a couple of things that are weighing on my mind, but I have decided to split the questions. Let's assume we're designing a kernel for a new instruction set architecture that's out on the...

Buildroot custom kernel under 1MB

linux,linux-kernel,kernel,buildroot
I am trying to build minimal kernel under 1 Mb with Buildroot. It is intended for small board with qspi memory and basic functionality, ethernet, usb, spi, and some GPIO's. Basic terminal access via ssh and UART. My first thoughts are if it is even possible to modify kernel .config...

How to mount the huge tlb (huge page) as a file system?

c,linux-kernel,kernel,cpu-architecture
Here is my machine details (ubuntu): $uname -a Linux rex-think 3.13.0-46-generic #76-Ubuntu SMP Thu Feb 26 18:52:13 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux I have enabled huge page in root user with: $echo 20 > /proc/sys/vm/nr_hugepages Now I want to mount huge page as a file system and open it...

How to write to a /proc kernel module

c,linux-kernel,kernel
How can I get data when a user writes to proc? (Ie: echo "foo" > /proc/myproc) I've seen reading from proc (ie user does a "cat /proc/myproc") as detailed from this site: http://www.linux.com/learn/linux-training/39972-kernel-debugging-with-proc-qsequenceq-files-part-2-of-3 That seems to work well enough, but I haven't seen the analogous method for writing. Also, I...

why non-blocking write to disk doesn't return EAGAIN or EWOULDBLOCK?

c,linux,kernel,nonblocking,syscall
I modified a program from APUE, the program first open a file, then mark the fd as non-blocking, then continue write to the fd until write return -1. I think since disk I/O is slow, when write buffers in OS is nearly full, the write system call will return -1,...

How to get OpenResult from IRP_MJ_CREATE callback?

c,windows,filesystems,kernel,driver
I have an event in process monitor and I am trying to get OpenResult value. I have a callback registered and triggered on IRP_MJ_CREATE, it looks like this ULONG CreateOperationCallback(PFLT_CALLBACK_DATA Data, PCFLT_RELATED_OBJECTS FltObjs) { if(Data->IoStatus.Status & FILE_CREATE) { DBGLOG("File created"); // :( not hit in the debugger } if(Data->Iopb->Parameters.Create.Options &...

Raspberry pi kernel 3.2.27 no keyboard detected on boot

keyboard,kernel,raspberry-pi,cross-compiling,boot
I'm trying to cross-compile a driver for Raspberry Pi. The driver works in kernel 3.2 so I downloaded the 3.2.27 raspberry pi's kernel. I compiled the kernel as follows: make -j3 ARCH=arm CROSS_COMPILE=<dir>/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- make -j3 ARCH=arm CROSS_COMPILE=<dir>/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- modules make -j3 ARCH=arm...

How do I suspend an i2c device in Linux from userspace?

c,linux,kernel,embedded
I am attempting to put a particular device into suspended mode, and have been unable to find a way to do this. I see in the kernel that a suspend command can be defined, but what is the user space analog to it, if there is one? In this case,...

Editing Functionality of Host Card Emulation in Android

android,kernel,nfc,hce
I'm currently in the process of developing a project for my University course wherein I will be hopefully editing the functionality of the HCE Feature of Android to allow me to set my own UID when emulating a card. Now, i've downloaded the AOSP source, and built a custom image...

Read from device file

c,kernel,linux-device-driver
I have a kernel module myModule with major number 100 and minor number 120. Here is what I did: make all sudo insmod ./myModule.ko mknod ~/myModule c 100 120 When I check the log with cat /proc/syslog then it shows the printk() things from the init function. But I have...

Can Linux Kernel OOPS be cause by user process?

linux,linux-kernel,kernel,embedded-linux
In my development environment, I am getting a kernel oops. Someone suggested that one of my Daemon is making a kernel oops. This is quite intriguing to me. By definition (http://en.wikipedia.org/wiki/Linux_kernel_oops) : "oops is a deviation from correct behavior of the Linux kernel - one which produces a certain error...

binutils - kernel - “_binary” meaning?

c,assembly,linker,kernel,binutils
I am reading xv6 lectures. I have a file named initcode.S that is to be linked in the kernel. Now two symbols are created that way : extern char _binary_initcode_start[], _binary_initcode_size[]; inside a function. The lecture says : as part of the kernel build process, the linker embeds that binary...

how to transfer string(char*) in kernel into user process using copy_to_user

linux-kernel,kernel,system-calls
I'm making code to transfer string in kernel to usermode using systemcall and copy_to_user here is my code kernel #include<linux/kernel.h> #include<linux/syscalls.h> #include<linux/sched.h> #include<linux/slab.h> #include<linux/errno.h> asmlinkage int sys_getProcTagSysCall(pid_t pid, char **tag){ printk("getProcTag system call \n\n"); struct task_struct *task= (struct task_struct*) kmalloc(sizeof(struct task_struct),GFP_KERNEL); read_lock(&tasklist_lock); task = find_task_by_vpid(pid); if(task == NULL ) {...

Modify the MPU3050 driver in linux kernel (Android) to use MPU6050

android,kernel,driver,accelerometer
I have a device to run (gsensor, MPU6050) with an Android system. I can't build it directly because it does not exist with the 3.4 kernel, but I wonder if I can modify the MPU3050 driver for my device works. I have found this readme, but I wonder if it...

Accessing kernel memory from user mode (windows)

windows,memory,kernel,driver
I'm writing a driver that needs to allocate a Non Paged pool of memory and this memory, for performance sake, must be directly accessible from a usermode program. In the driver entry I've allocated some memory with this two type of methods pMdl = IoAllocateMdl(NULL, 4096, FALSE, FALSE, NULL); if(!pMdl)...

android kernel build (first time)

android,linux,linux-kernel,kernel,kali-linux
Ok so first off, Im brand new to android dev. This is my first attempt at any form of kernel anything. I have a limited knowledge of java and python, but no C. I have a galaxy tab 4 sm-t330nu running 4.4.2. its running a qualcomm snapdragon 400 msm8226 cpu....

Error 13: Invalid or unsupported executable while booting simple kernel in grub with string literal

c,gcc,assembly,kernel,grub
I've written a simple kernel that tries to write two characters to the frame buffer. If I define a string literal in the kernel, I get the following output when it boots: Booting 'os' kernel /boot/kernel.elf Error 13: Invalid or unsupported executable format Press any key to continue... Otherwise, if...

text section in process memory map

unix,process,operating-system,kernel
Normally, the process memory map consists of stack, text, data+bss and heap. The memory address is independent to other processes except text section. My question is about in text section, is there only child process could share the same text section with its parent process? or other processes could share...

kernel module no debugging symbols found

c,linux,module,gdb,kernel
After I loaded linux kernel module with [email protected]:$ insmod mmaptest.ko I can verify that it is loaded via [email protected]:$ cat /proc/modules mmaptest 12727 0 - Live 0x0000000000000000 (OF) but all segments are listed with 0x00 addresses. [email protected]$:$ systool -vm mmaptest Module = "mmaptest" Attributes: coresize = "12727" initsize = "0"...

C Kernel - Works fine on VM but not actual computer?

c,assembly,operating-system,kernel,hex
I am making a basic C kernel. (Loaded by an assembly program) I am compiling it with an i686-elf cross compiler for windows. My C code is as follows: void cls(); void drawhappy(); void main(){ char *vidptr = (char *)0xb8000; cls(); drawhappy(); } void cls(){ char *vidptr = (char *)0xb8000;...

Failed to build android kernel

android,python,kernel,android-5.0-lollipop
I am trying to build the Android kernel for emulator. But the build failed. I am using the android-5.1.1-r1. Here are the error messages: mkdir -p /home/ying/WORKING_DIRECTORY/out/target/product/generic/obj/GYP/shared_intermediates/templates/org/chromium/base; cd external/chromium_org/base; python ../build/android/gyp/gcc_preprocess.py "--include-path=.." "--output=/home/ying/WORKING_DIRECTORY/out/target/product/generic/obj/GYP/shared_intermediates/templates/org/chromium/base/ApplicationState.java"...

Kernel - Scheduler : what happens when switching between process

process,linux-kernel,stack,kernel,scheduler
Context: I don't really understand how the kernel saves the state of a running code when it gets to exceed its time slice. I don't visualize what happens actually. Question: 1) Where is stored the current running code (and its stack ?) ? 2) When the kernel will "see" the...

Read chunks in a disk (kernel programming)

c,linux,kernel
I want to read the first(s) chunks of my disk. I'm currently developing a driver and i want to stock (and retrieve) some meta data (the number of time each chunks is consulted) in the firsts chunk of my disk I've see How to read a sector using a bio...

Passing kernel parametes to EFI-Stub in Apple's EFI env

linux,osx,kernel,boot,efi
Good day, everybody. I'm trying to shorten the boot process of an iMac dual-booting OS-X and Ubuntu as much as possible. So far i managed to boot grub (and Ubuntu afterwards) directly by Apple's EFI boot manager. I've accomplished this by masquerading (via hardlinks, alias, folder's tree, etc.) the grub...

“Segmentation fault” when `rmmod` or `modprobe -r`

c,linux,kernel,embedded,kernel-module
Trying the simplest kernel module from LDD3 without any modification on custom built kernel v4.1.0-rc6 for Beagle Bone board with BusyBox v1.23.0. The code for the module is as follows: #include <linux/init.h> #include <linux/module.h> MODULE_LICENSE("Dual BSD/GPL"); static int hello_init(void) { printk(KERN_ALERT "Hello, world\n"); return 0; } static void hello_exit(void) {...

Linux 3.13 Kernel Module set procfile_read end of file condition

c,linux,module,kernel,posix
I am writing a Kernel Module for Linux 3.13 where the procfile_read function prototype is defined as: static ssize_t procfile_read(struct file *file, char __user *buffer, size_t count, loff_t * data) This is different from every resource I can find online, such as http://linux.die.net/lkmpg/x769.html, where the function prototype was different for...

nmap shows random open ports on localhost for a fraction of a second

linux,kernel,port,nmap
When I scan myself I will often see random open ports: nmap -sT -T normal -p 1-65535 localhost E.g. 43194/tcp open unknown 58167/tcp open unknown Sometimes nothing, sometimes a couple like that. I see however that this has been a false positive before, but it is now very old: http://seclists.org/incidents/2002/Dec/136...

Getting the device address by device tree file in C

c,linux,kernel,device-tree
I am working on Linux; when Linux starts up the DTS (device tree), the file will be loaded by Linux kernel. My question is, is there have any way to get device address by DTS file using the C lanugage? For example: Some part of the DTS file is like:...

How does C distinguish between a byte long character and a 2 byte long character?

c,linux,bash,io,kernel
I have this sample code: #include <fcntl.h> #include <stdio.h> #include <unistd.h> int main(void){ printf("%li\n",sizeof(char)); char mytext[20]; read(1,mytext,3); printf("%s",mytext); return 0; } First run: [email protected]:~$ ./a.out 1 pp pp [email protected]:~$ Well I think this is all expected as p is 1 byte long character defined in ASCII and I am reading...

How does kernel restrict processes to their own memory pool?

c,memory,assembly,kernel
This is purely academical question not related to any OS We have x86 CPU and operating memory, this memory resembles some memory pool, that consist of addressable memory units that can be read or written to, using their address by MOV instruction of CPU (we can move memory from /...

What's the shortcut to interrupt the kernel in Canopy?

osx,kernel,interrupt,shortcut,canopy
I'm on OSX, using canopy. Does anybody know what the shortcut for interrupting the kernel is? Thanks.

why is u8 u16 u32 u64 used instead of unsigned int in kernel programming

c,linux,kernel,linux-device-driver
I see u8 u16 u32 u64 data types being used in kernel code. And I am wondering why is there need to use u8 or u16 or u32 or u64 and not unsigned int?

How does Linux remember its Kernel Stack Pointer?

linux,linux-kernel,stack,kernel,interrupt
I know that there are two types of stack in Linux : user stack for each user threads and Kernel Stack for kernel threads (but 1 process). The interruptions, more precisely, the interruption procedures, are the bridges between this two modes, kernel (0) and user (3). The interrupt vector table...

Plotting 2D Kernel Density Estimation with Python

python,matplotlib,plot,kernel,seaborn
I would like to plot a 2D kernel density estimation. I find the seaborn package very useful here. However, after searching for a long time, I couldn't figure out how to make the y-axis and x-axis non-transparent. Also, how to show the values of the density on the contour? I...

Missing headers for kernel in bzImage loaded on qemu

linux-kernel,kernel,header-files,kernel-module,qemu
I am trying to compile a kernel module of kernel version 3.2.0 on a linux kernel bzImage loaded on a qemu emulator, however I am getting the following error: /lib/modules/3.2.0/build no such file or directory. I tried to look up solutions over the net but nothing specific related to solve...

hrtimer runs even thogh it is not started

linux,time,kernel,linux-device-driver,embedded-linux
I'm performing hrtimer_init(hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); And after a while ( 30, maybe 60 seconds ), i perform: hrtimer_start(hr_timer, ktime_set(0, timeout), HRTIMER_MODE_REL); And immediatelly after, in less than 1 second, i perform ktime_to_timeval(hrtimer_expires_remaining(hr_timer)); The output timeval struct contains the time since hrtimer_init, and not from the start. What is akward, is...

How to give texture to a Point cloud? OpenGL / CUDA / C++

c++,opencv,opengl,cuda,kernel
I have a disparity image obtained using OpenCV. I am able to display a 640 x 360 grid of points using OpenGL and CUDA, and give to each point a Z value which corresponds to the disparity value. The result: Now I wish to give to each point in the...

Operating system kernel and processes in main memory

c,linux,operating-system,kernel,ram
Continuing my endeavors in OS development research, I have constructed an almost complete picture in my head. One thing still eludes me. Here is the basic boot process, from my understanding: 1) BIOS/Bootloader perform necessary checks, initialize everything. 2) The kernel is loaded into RAM. 3) Kernel performs its initializations...

Linux booting hang up after adding a printk statement in the kernel source code

c,linux,ubuntu,linux-kernel,kernel
I have added single printk statement in the kernel source code. After compiling and building the kernel, when I boot-up the system it is hanging by printing the statement. printk(KERN_INFO "I'm inside the function!\n"); I'm using core i3 machine in ubuntu 13.04, the version of kernel is 3.4.106 ( I've...

Java JBoss Fatal error: cannot find the required native library named JLinkNativeLibrary

java,jboss,kernel,wolfram-mathematica
I'm trying to work with Wolfram Mathematica Kernel from Java Web Application using JBoss. Here is a Main Class. public class Main { static KernelLink ml; static KernelLink ml2; public Main(){ String path = "-linkmode launch -linkname 'C:/Program Files/Wolfram Research/Mathematica/9.0/MathKernel.exe'"; try { ml = MathLinkFactory.createKernelLink(path);// подключаем ядро ml.setComplexClass(MyComplex.class); System.out.println(ml.getComplexClass()); ml.discardAnswer();...

windbg first connect then stuck on “Debuggee not connected.” message during kernel debugging

windows,debugging,kernel,windbg
I am trying to do Windows kernel debugging so I have set up two machines for this purpose: HOST - DEBUGGER - The computer that runs the windbg debugger TARGET - DEBUGEE - The computer being debugged Both HOST and TARGET runs Windows 7 32 bit and both have Windows...

How does Linux allocate memory for its physical allocator?

c,linux,memory-management,linux-kernel,kernel
I was recently delving into the details of Linux's memory management as I want to implement something similar for my own toy kernel, so I was hoping if someone who's familiar with the details could help me understand one thing. Apparently the physical memory manager is a buddy algorithm, which...

Fork() cannot be called from a Device Driver in linux

c,linux,kernel,fork,device-driver
So, I'm writing this driver wich recieves a "command" via "write" and it is supposed to call fork and let the child finish the job while the parent dies. When I compile it the output is this. [email protected]:~/Área de Trabalho/mc504-linux/linux-3.17.2$ make -j 5 ARCH=i386 CHK include/config/kernel.release CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h...

How to tune parameters of SVM Rank?

machine-learning,kernel,svm,ranking
I am using SVM Rank, which has multiple parameters, changing whom I am getting a variety of results. Is there some mechanism to tune and get the best parameters, as tuned according to the best results on validation set? Below are the different parameters: Learning Options: -c float -> C:...

android log's time-stamp addition

android,android-activity,kernel
while looking in android logging frame work - I checked /dev/log/main |system |event log files. in these log file I dont see time stamp. but at the same time "logcat -v time" display time stamp along with log. I check Logcat code Its reading androidlog_entry from /dev/log/* buffers and displaying...

Get kernel root dir in Twig template with Symfony 2

php,symfony2,templates,kernel,twig
I need to get kernel.root_dir in my twig template, I found solutions here, but it does not work. I get error about non existing method Kernel in this class. Realy in GlobalVariables class method getKernel() not exists. So how I can get root_dir in twig template. (P.S. No I cant...

how to make gdbserver accept more than one connection?

gdb,kernel,qemu,gdbserver
I'm debugging an operating system (kernel + one user space application) within qemu, using gdb connected to gdbserver. Since i'm in presence of two binaries, i would like to connect to gdbserver firstly with the kernel binary, and secondly with the user space binary so that i could switch from...

Program counter of a process

process,operating-system,kernel
I thought program counter is a part of hardware. I'm confused after reading the following. Can someone clarfiy the difference? A single-threaded process has one program counter specifying the next instruction to execute. (Threads are covered in Chapter 4.) The execution of such a process must be sequential. The CPU...

ioremap returns NULL

linux,linux-kernel,kernel,raspberry-pi,linux-device-driver
I'm trying to create a customised UART driver for Raspberry PI. I try to ioremap the MMIO. But ioremap returns always NULL. #define UART_REG_BASE_ADDR 0x7E20100 pUart = ioremap(UART_REG_BASE_ADDR, 1024); if (pUart==NULL) { printk("Couldn't remap UART MMIO\n"); return -EIO; } dmesg dumps following: [ 2906.579848] CPU: 0 PID: 4983 Comm: insmod...

When one thread blocks in C, why doesn't the entire process block

c,multithreading,process,operating-system,kernel
I'm in a course on operating systems and we're talking about threading. On Wikipedia here it says that for 1:N kernel threads: If one of the threads needs to execute an I/O request, the whole process is blocked and the threading advantage cannot be utilized However this got me thinking....

Strange return type of __get_free_pages

kernel
Why does it return unsigned long? Why not void* or char*? unsigned long __get_free_pages(unsigned int gfp_mask, unsigned int order) I guess it returns an adress, or have I misunderstood that function completely?...

How the kernel functions work?

linux-kernel,kernel
Normally during a function call the function gets pushed into the stack part of the process and the calling function waits. But the program stack requires a process right? But the kernel is not part of any process (by kernel I mean the part that does file management and interprocess...

Makefile for kernel kecho command issue

linux,makefile,make,kernel
This a makefile for compiling the kernel module. # Makefile – makefile of our first driver # # if KERNELRELEASE is defined, we've been invoked from the # kernel build system and can use its language. ifneq (${KERNELRELEASE},) obj-m = first-driver.o # Otherwise we were called directly from the command...

Moxa RealTTY module compilation error on Linux kernel 3.16

c,linux,module,kernel,linux-device-driver
I used MOXA devices on Debian 7.0 with kernel 3.2. I was able to successfully compiled Moxa RealTTY driver for this kernel, but after I upgraded to Debian 8.0 with kernel 3.16 I can't compile it. I asked MOXA for newest driver, but so far no answer. Latest driver was...

Where, in the e1000 linux code, can I zeroize rx/tx network packets?

c,linux,networking,kernel
I'd need to know where can I make zeroization for the received/transmitted network packets in the e1000 linux driver. I need to know this to pass one compliance requirement, but I'm not able to find in the code of the e1000 where to do zeroization of the network packet buffer...

Set cpu affinity on a loadable linux kernel module

c,module,kernel,cpu,affinity
I need to create a kernel module that enables ARM PMU counters on every core in the computer. I have trouble setting the cpu affinity. Ive tried sched_get_affinity, but apparently, it only works for user space processes. My code is below. Any ideas? #define _GNU_SOURCE #include <linux/module.h> /* Needed by...

How to write a simple “page fault generator”?

c,memory,memory-management,kernel,microbenchmark
For my course project on Linux Kernel, I need to simulate a situation where there is a lot of page swapping due to low memory. I want to write a program which needs a lot of physical memory, so that pages accessed by this program have to be swapped in...

Using strsep in kernel space to separate a string

c,string,linux-kernel,kernel
I'm trying to separate a string based on some delimeter in a kernel module. I'm trying to use the strsep() function, but when I try to use it my kernel crashes. Can someone identify the bug in the code below? char *test = "test1:test2:test3"; char *token = test; char *end...

System time and file system time are not the same

linux,file,time,filesystems,kernel
I met a strange problem on one cluster with 10 nodes. On any node, any file operation makes the access/modification/change time of that file in the future that is 1min52s after the current system time obtained from date. That makes all make command cannot work correctly. Following command are tested:...

c - kernel - spinlocks vs queues

linux,linux-kernel,kernel,queue,spinlock
I think, no matter the whole lot of documentation available, I don't understand why one have to wait for a spin lock in a kernel context. Why isn't there a specific queue with process requiring a lock with an atomic counter/index and , with preempt disabled, treat them as they...

Various debug modes of windbg

debugging,kernel,windbg
I would like also ask about one thing: somewhere I've read that windbg supports multiple modes of debugging and one of those modes is some kind of kernel debugging where system is normally running and does not wait for windbg breakpoints etc. Is this lokal kernel debugging mode? Also if...

How to link kernel functions to user-space program?

linux,linker,kernel,freebsd,static-linking
I have a user-space program (Capstone). I would like to use it in FreeBSD kernel. I believe most of them have the same function name, semantics and arguments (in FreeBSD, the kernel printf is also named printf). First I built it as libcapstone.a library, and link my program with it....

Best way to handle ERESTARTSYS in kthread?

thread-safety,kernel,kernel-module
I have a kthread that blocks on a wait event until a timeout is reached. However, if a system event interrupts it (such as the system going into suspend), it returns -ERESTARTSYS. I'm curious to know how to handle this situation, since I don't want the kthread to die, just...

How to understand the output of objdump, about indirect jmp?

linux,kernel,reverse-engineering,x86-64,disassembling
When objdump -S my_program, usually I can see the following indirect jmp instruction, which is typically used for switch/case jump table: ffffffff802e04d3: ff 24 d5 38 2e 10 81 jmpq *-0x7eefd1c8(,%rdx,8) How to understand the address -0x7eefd1c8? It means the table's base address is 0xffffffff802e04d3 - 0x7eefd1c8? Also, how can...

does the mode bit change when initialising a variable?

operating-system,kernel,system-calls
So I know that a system call (e.g. open, close, read, write etc.) changes the mode bit twice - from user mode to kernel mode to serve the system call request and then back to user mode once it's done. But if we have for example int a = open("lol.txt",...

How is a process state updated to blocked state (TASK_INTERRUPTABLE)?

kernel,process,io,block-device,scheduling
When a process is waiting for IO, how is the task state updated to TASK_INTERRUPTABLE (that is, blocked)? Imagine this case, a process issues an IO request to a block device. According to my previous thread, the process finally invokes elv_add_request() to add the request to the IO queue. So...

Does LIST_HEAD macro re-initialize all variables?

c,linux-kernel,kernel
I am writing some Kernel code using the LINUX built in linked list. I am wondering if multiple calls to INIT_LIST_HEAD will re-initialize all of the variables that I have created. What is the behavior of the INIT_LIST_HEAD macro? Here is some example code: INIT_LIST_HEAD(same_list); for(i = 0; i <...

Implementing LRU with timestamp: How expensive is memory store and load?

performance,memory-management,operating-system,kernel,lru
I'm talking about LRU memory page replacement algorithm implement in C, NOT in Java or C++. According to the OS course notes: OK, so how do we actually implement a LRU? Idea 1): mark everything we touch with a timestamp. Whenever we need to evict a page, we select the...

How to get Keyboard inputs into a kernel?

c,keyboard,kernel,osdev
I am writing my own kernel in c OS. Now I want to code a Console to interact with the Kernel. It should work like the normal Terminal on Linux. How can I get a input over the Keyboard (an example would be nice) Thanks for Help.

NetBSD kernel crash due to cache error - What is good point to start debugging?

caching,kernel,mips,interrupt,netbsd
Below is the stack trace of NetBSD 5.1 kernel crash. Basic data collected from minicore is : ------------------------------------------------------------- VALID MAGIC: 0xdfeedfee --------------------------PANIC STRING----------------------- panic string is :cache error @ EPC 0xffffffff80359a78 L1D_CACHE_ERROR_LOG 0 L1D_CACHE_INTERRUPT 0 status 0x8305, cause 0x78 Stack Trace : sys/arch/evbmips/navasota/md_dump.c:52: 803e092c : sys/arch/evbmips/rmixl/machdep.c:1247: 8032c468 : sys/kern/subr_prf.c:313: 802934ec...

How to exclude kernel updates in Raspbian (Raspberry Pi)

kernel,debian,packages,updates,exclude
I always use 'sudo apt-get update && sudo apt-get dist-upgrade' in Raspberry Pi but I need to keep my kernel current version. I want to upgrade all packages except kernel ones. Is it possible? Can I use an option in this command? Thanks

Kernel task_struct & siblings pointers

c,linux,list,linux-kernel,kernel
I have a question regarding the task_struct lists. /* * pointers to (original) parent process, youngest child, younger sibling, * older sibling, respectively. (p->father can be replaced with * p->p_pptr->pid) */ task_t *p_opptr, *p_pptr, *p_cptr, *p_ysptr, *p_osptr; I'm using these pointers to run through process's children. What I don't understand...

kernel - booting address. Why?

linux-kernel,kernel
Context: Reading how a kernel boots. I was on that page: http://www.linuxjournal.com/article/2239 and it says the kernel loads at 0x10000. Question: why this address? ...

BlueZ scotest App and with Linux Config Can't Connect to SCO Socket

linux,bluetooth,linux-kernel,kernel,bluez
I am using BlueZ 4.101 on an embedded Linux project with Kernel 3.4.79+. Normal Bluetooth operations work great and I can use many headset with my device to transfer Audio. Now I am working towards Bluetooth Compliance and so I am using the Bluetooth SIG's USB PTS Dongle. I am...

How to change version string of the kernel?

linux,kernel,version,fedora,uname
I'm very new to Linux and very new to building/compiling my own kernel. For starters, I'm just trying to figure out how to change the version string of my kernel. For instance, when I do uname -a, it prints out "Linux localhost.localdomain 3.11.10-100.fc18.i686". I'd like to customize that, but I'm...

How to restrict receiving a generic netlink multicast to the root user?

linux,linux-kernel,kernel,kernel-module,netlink
I wrote a kernel module that sends generic Netlink multicasts, and wrote a userland client using libmnl that receives them. That all works fine, but my client works even when it's not the root user, and I want to prevent that. man 7 netlink says: Only processes with an effective...

Are Berkeley Packet Filter opcode values implementation defined?

kernel,libpcap,tcpdump,bpf
Are Berkeley Packet Filter opcode values implementation defined? I always thought of tcpdump/libpcap as authoritative in the BPF arena. I noticed that the linux kernel and tcpdump read BPF filters differently. The BPF mnemonics and behavior is the same, but the actual opcode values themselves seem different. I went looking...

trigger exec fault on non-exec page

linux,kernel
I'm looking for a way to trigger from a user written program a fault where a non-exec mmap'd page is executed leading to the kernel killing the process. I'm not sure how I can push executable code in the allocated mmap buffer form within the actual program so it contains...

How to on/off an electric bulb via computer's usb port using C language program

c,operating-system,kernel,hardware-interface
I want to write code in C language to switch on/off an electric bulb via USB port. USB port gives 5 volts, so I want that bulb can take power from computer's USB port. Is it possible?...

Switch to user space

assembly,x86,operating-system,kernel
this is part of code which demonstrates basic functions of os kernel. After flushing GTD and setting up IDT I want to switch to ring 3 run some int and context switch. However I cannot jump to user mode. I want to use trick with iret instruction. As far I...

How to boot Linux kernel from u-boot?

kernel,u-boot
My Linux kernel image uImage is in my U-disk. And I want to boot it from U-Boot. Also the device tree file am335x-evm.dtb is in my U-disk. What I did is below: U-Boot# usb start (Re)start USB... USB0: scanning bus 0 for devices... 1 USB Device(s) found scanning usb for...

ret_from_syscall source code and when it is called

linux,linux-kernel,kernel,linux-device-driver,system-calls
In the below call trace we see function called ret_from_syscall. Which function is this ? When it will called during system call ? Where is the corresponding code for this ? May 7 16:40:34.322086 warn TCU-0 kernel: [cf83ddc0] [00009751] 0x9751 (unreliable) May 7 16:40:34.322086 warn TCU-0 kernel: [cf83ddd0] [c00469ac] do_syslog+0x198/0x424...

difference between one CPU and multiple CPU in schedule routine - Linux kernel

linux-kernel,operating-system,kernel
In Linux kernel (2.6) is there a difference between the performance of the "schedule()" routine in a system that has only one processor than in a system with multiple processors? I have tried to find the answer in the book "Understanding the Linux kernel (3rd ed.)" but no luck finding...

Strange behaviour of C pointers with memory mapped I/O

c,pointers,kernel,osdev
I am currently working on writing a basic operating system as a learning project. I use a gcc 4.9.2 cross compiler for this purpose. When trying to use memory-mapped I/O I stumbled upon behaviour of C pointers (or possibly memory-mapped I/O) which I fail to understand. When directly accessing the...

linux kernel module not autoloading

c,linux,kernel
I'm studing the linux kernel and start with hello world module at this point everything is fine but after compile $ make and install $ insmod akmod.ko the module it's not showing a "hello world" message on KERN_DEBUG $ dmesg nothing here $ just show on rmmod $ rmmod akmod...

deadlock using read write lock in kernel

linux,multithreading,kernel
i am trying to write a simple debugfs with read and write file operations. The code is as below. static ssize_t foo_read(struct file *fp, char __user *user, size_t size, loff_t *loff) { ssize_t retval; up_read(&foo_sem); retval = simple_read_from_buffer(user, size, loff, fooBuffer, fooBufferSize); down_read(&foo_sem); return retval; } static ssize_t foo_write(struct file...

Android Studio - HAX kernel Module not installed

java,android,kernel,development-environment,virtualization
i installed Android Studio for Windows. I got an AMD 7850K processor and an A78M-E35 Mainboard. I cant run the emulator because the Installer for the HAX Module is only for Intel. What alternatives do i have for running the emulator with an AMD? Greets...

Kernel spin-lock enables preemption before releasing lock

linux,linux-kernel,kernel,locking,scheduling
When I was discussing the behavior of spinlocks in uni- and SMP kernels with some colleagues, we dived into the code and found a line that really surprised us, and we can’t figure out why it’s done this way. short calltrace to show where we’re coming from: spin_lock calls raw_spin_lock,...

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

c,linux-kernel,kernel,kernel-module,elf
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 for the...

Is it possible to access/edit kernel memory in C#?

c#,kernel,ram
I was wondering if it's possible to access the kernel's memory via C# and edit it. If not, is it possible to access the whole RAM? Using ReadProcessMemory on the RAM without defining a specific process? I am trying to search for a string in the kernel/RAM yet it has...