Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all 12279 articles
Browse latest View live

Access permissions of /dev/mem

$
0
0

I have a set of questions regarding /dev/mem:

  1. Many articles on the net, seem to refer /dev/mem as the gateway to "Physical RAM". But if I am right, /dev/mem is the gateway to the "Physical Address Space" of the processor which might include control registers of many HW peripherals and not just the RAM? Please, correct me if I am wrong!

  2. In order to prevent attackers from misusing /dev/mem and altering kernel memory, a flag CONFIG_STRICT_DEVMEM needs to be enabled which will prevent user apps from accessing physical address space beyond 1MB. I checked the config file on my PC (Ubuntu) and found that CONFIG_STRICT_DEVMEM = y. And I wrote a program which tries to read to physical memory beyond 1 MB and I was able to read! No segmentation fault or any Operation NOT Permitted error. How is this possible?

My program roughly looks like this:

fd = open ( "/dev/mem", O_RDWR);ptr = (int*) mmap(0, MAP_SIZE, PROT_READ, fd, myAddress & (~MAP_MASK));printf("%d", *ptr);

Kali linux 2020 slow performance and freezes after fresh install [closed]

$
0
0

I am very new to kali, that being said I've just installed the latest version on dual boot with windows.

My Kali OS completely freezes EVERYTIME after a few minutes of rebooting, I've also noticed slow performance in doing any tasks like opening safari browser or a terminal before it completely freezes and there's nothing I can do except force shut down or rebooting.It even takes a while to show "login" menu.

I installed it using Guided partitioning and default settings (running on lightdm).I have also tried adding line 'nouveau.modeset=0' in grub after i've looked online for a solution and it didn't work.

ANY SUGGESTIONS would be helpful. Thank you.

make keyboard events on linux

$
0
0

Hello I want to made a wireless keyboard of a wired keyboard to telephone that sends the keyboard event to a pc using websocket how could I make the keyboard events on linux using java programming laguage

How does the linux kernel maintain the vast amount of config options?

$
0
0

This question is about configuration maintenance and testing.

When used wrongly, #ifdef, #ifndef, #elseif, #elif, #else, #endif preprocessor instructions do not only diminish the readability and maintainability of C-code, but they also increase the risk of regression bugs (e.g. when a specific build configuration has not been tested for a certain period of time).

I wonder how the linux kernel is able to maintain the tremendous amount of config options without running into a complete maintenance hell?

I understand that this is necessary to be flexible for all kinds of different hardware, but the sheer number of config options looks really frightening to me as an application developer.

Which of the following statements would you consider as true?

  • Most vendors only use a set of standard configurations for their targeted platform, so that most of the possible config combinations are neither tested nor used
  • A very strict coding guideline exists that allows the introduction of new #ifdef's only for clearly separable pieces of code, where it makes sense to disable a feature (and the right people in charge to make these decisions)
  • There are so many testers for every new kernel release that the configuration related bugs get fixed in time, since most of them are likely to be only build regressions

Custom DDR controller initialization in u-boot code

$
0
0

I am working on custom board part of that, we are changing DDR controller presented in the Board imx6ull boardQuestion1. what are all changes to make new DDR controller up2. What are other controllers depend DDR controller in u-boot code.3. What is meant by DDR calibration in SoC 4. What is DDR controller IC name used in existing board

I have gone through u-boot code,DDR init is present with .c file as spl_ddr_init() --> mx6ul_dram_iocfg() & mx6_dram_cfg()

Board name: imx6ul_14x14_evk board

Can you please provide information with doc.s/links to understand the same.

Thanks in advance.

RegardsSatish G

Passing argument 4 of ‘proc_create’ from incompatible pointer type [closed]

$
0
0

I'm trying to make a simple procfs module, but I get this error:

error: passing argument 4 of ‘proc_create’ from incompatible pointer type [-Werror=incompatible-pointer-types]

I tried many online examples and i got same error message.

NETEM + TC - Delay + Pfifo

$
0
0

I'm new to NETEM, I'd like to have some latency between two machines and some jitter, but I don't want packet reordering.

I've used the following commands:

tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 flowid 1:100 match ip src 10.88.0.61/32tc class add dev eth0 parent 1:0 classid 1:100 htb rate 1000mbittc qdisc add dev eth0 parent 1:100 handle 100: netem delay 100ms 1000us distribution normaltc qdisc add dev eth0 parent 100:1 handle 101: pfifo limit 3000

but I'm not sure about the parent and handle in the last line, is the syntax correct? would the Pfifo property apply for the rule involving the delay on the IP?

Linux hrtimer run in hardirq context

$
0
0

What is the difference between running hrtimer in softirq vs hardirq context? Isn't hardirq run only if triggered by a hardware event?


What does this command do? ls /bin | sort | tee /tmp/lista | wc -l

$
0
0

I would like to understand better what this command does, when I ran it it appeared the number 77, as shown in the image, does this represent the number of words in the list? Or is there something more to explain?

enter image description here

Why do we need booth read and write barriers?

$
0
0

Why do we need to define two types of barriers with same implementation?

For example code from io_uring in linux:

#if defined(__x86_64) || defined(__i386__)#define read_barrier()  __asm__ __volatile__("":::"memory")#define write_barrier() __asm__ __volatile__("":::"memory")#else

tcp_reordering setting for tcp connection

$
0
0

From my understanding, the tcp connection's reordering value should scaled between /proc/sys/net/ipv4/tcp_reordering (default 3)and /proc/sys/net/ipv4/tcp_max_reordering(default 300). But when I change the tcp_reordering from default value 3 to 6, the new connection still has the reordering value to 3 instead of 6 or more. I setup about 20K new connections, the result from the ss -i shows there are few connection with the tcp_reordering to 6 or more, most are still has the value equals to 3. The tcp server is running inside a container, and I also changed the proc value inside container.

Our kernel version is:

-bash-4.2# uname -r4.15.0-43.generic.x86_64

Why do we need both read and write barriers?

$
0
0

Why do we need to define two types of barriers with the same implementation?

For example, this code from io_uring in Linux:

#if defined(__x86_64) || defined(__i386__)#define read_barrier()  __asm__ __volatile__("":::"memory")#define write_barrier() __asm__ __volatile__("":::"memory")#else

How to run write something in a file with android kernel source code?

$
0
0

I want to write some logs in a file and I have tried to import stdlib.h for system function so that I can run echo command to write a log in a file on /sdcard/ but linux kernel source code doesn't support this include. I can see other #include in sources are from /include/linux folder.

Any help?

Where can I find the pci_find_device() declaration building a network driver on Debian Stretch?

$
0
0

I am trying to build a network driver. However, when I try to build it says:

error: implicit declaration of function ‘pci_find_device

Here is my driver:

#define REALTEK_VENDER_ID  0x10EC#define REALTEK_DEVICE_ID   0x8139#include <linux/kernel.h>#include <linux/module.h>#include <linux/stddef.h>#include <linux/pci.h>int init_module(void){    struct pci_dev *pdev;    pdev = pci_find_device(REALTEK_VENDER_ID, REALTEK_DEVICE_ID, NULL);    if(!pdev)        printk("<1>Device not found\n");    else        printk("<1>Device found\n");    return 0;}MODULE_LICENSE("GPL");

Here is my Makefile

obj-m += ethDriver.oall:    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modulesclean:    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

When I build, I get the following errors:

ethDriver.c: In function ‘init_module’:/home/xxx/ethDriver/ethDriver.c:13:12: error: implicit declaration of function ‘pci_find_device’ [-Werror=implicit-function-declaration]     pdev = pci_find_device(REALTEK_VENDER_ID, REALTEK_DEVICE_ID, NULL);            ^~~~~~~~~~~~~~~/home/xxx/ethDriver/ethDriver.c:13:10: warning: assignment makes pointer from integer without a cast [-Wint-conversion]     pdev = pci_find_device(REALTEK_VENDER_ID, REALTEK_DEVICE_ID, NULL);          ^cc1: some warnings being treated as errors/usr/src/linux-headers-4.9.0-3-common/scripts/Makefile.build:315: recipe for target '/home/xxx/ethDriver/ethDriver.o' failedmake[4]: *** [/home/xxx/ethDriver/ethDriver.o] Error 1/usr/src/linux-headers-4.9.0-3-common/Makefile:1507: recipe for target '_module_/home/xxx/ethDriver' failedmake[3]: *** [_module_/home/xxx/ethDriver] Error 2Makefile:150: recipe for target 'sub-make' failedmake[2]: *** [sub-make] Error 2Makefile:8: recipe for target 'all' failedmake[1]: *** [all] Error 2make[1]: Leaving directory '/usr/src/linux-headers-4.9.0-3-amd64'Makefile:4: recipe for target 'all' failedmake: *** [all] Error 2

To make "/dev/dsp1" exist, which configs should I enable?

$
0
0

My program needs to open "/dev/dsp1". But my compiled kernel does not have this file. To have this file, which configs in .config should I enable?Thanks


Why does my UART Kernel Module not send the last 8 characters of my message?

$
0
0

I am building a UART Kernel Module with the RTDM API. For the datasheet of this AUART, I worked with chapter 30 of the following link: Link of datasheet

The driver is very basic, it only has to send a buffer which is passed to it in user-space with write function. It works like this:

  1. In open function, activate UART with UARTEN bit of UART Control Register
  2. In write function, I activate the Transmitter with TXE bit of UART Control Register
  3. Then, start sending characters with:
static void rt_mxs_auart_tx_chars(struct rt_mxs_auart_ctx *ctx){    int ch;    pr_info("Start transmitting\n");    while (ctx->out_npend > 0 &&           !(mxs_read(ctx->port, REG_STAT) & AUART_STAT_TXFF)) {        ch = ctx->out_buf[ctx->out_head++];        mxs_write(ch, ctx->port, REG_DATA);        ctx->out_head &= (OUT_BUFFER_SIZE - 1);        ctx->out_npend--;    }    if (mxs_read(ctx->port, REG_STAT) & AUART_STAT_TXFF){        pr_info("We've stopped transmitting because FIFO is full, remains: %d to be sent (bytes pending)\n", ctx->out_npend);    }    if(ctx->out_npend > 0 ) {        mxs_set(AUART_INTR_TXIEN, ctx->port, REG_INTR);        pr_info("%d bytes pending, setting AUART_INTR_TXIEN\n", ctx->out_npend);    }    else {        mxs_clr(AUART_INTR_TXIEN, ctx->port, REG_INTR);        pr_info("%d bytes pending, clearing AUART_INTR_TXIEN\n", ctx->out_npend);    }}

TXIEN corresponds to Transmit Interrupt Enable, and AUART_STAT_TXFF means that the transmit FIFO is full. Here's the ctx structure:

struct rt_mxs_auart_ctx {    struct rtser_config config; /* current device configuration */    rtdm_irq_t irq_handle;      /* device IRQ handle */    rtdm_lock_t lock;       /* lock to protect context struct */    int in_head;            /* RX ring buffer, head pointer */    int in_tail;            /* RX ring buffer, tail pointer */    size_t in_npend;        /* pending bytes in RX ring */    int in_nwait;           /* bytes the user waits for */    rtdm_event_t in_event;      /* raised to unblock reader */    char in_buf[IN_BUFFER_SIZE];    /* RX ring buffer */    volatile unsigned long in_lock; /* single-reader lock */    uint64_t *in_history;       /* RX timestamp buffer */    int out_head;           /* TX ring buffer, head pointer */    int out_tail;           /* TX ring buffer, tail pointer */    size_t out_npend;       /* pending bytes in TX ring */    rtdm_event_t out_event;     /* raised to unblock writer */    char out_buf[OUT_BUFFER_SIZE];  /* TX ring buffer */    rtdm_mutex_t out_lock;      /* single-writer mutex */    uint64_t last_timestamp;    /* timestamp of last event */    int ioc_events;         /* recorded events */    rtdm_event_t ioc_event;     /* raised to unblock event waiter */    volatile unsigned long ioc_event_lock;  /* single-waiter lock */    int ier_status;         /* IER cache */    int mcr_status;         /* MCR cache */    int status;         /* cache for LSR + soft-states */    int saved_errors;       /* error cache for RTIOC_GET_STATUS */    /*     * The port structure holds all the information about the UART     * port like base address, and so on.     */    struct rt_mxs_auart_port *port;};

In my interrupt handler, I do this:

    if (istat & AUART_INTR_TXIS){        pr_info("Transmit Interrupt Status enabled\n");        rt_mxs_auart_tx_chars(ctx);        istat &= ~AUART_INTR_TXIS;        ret = RTDM_IRQ_HANDLED;    }

which means that if the interrupt status flag is active, we send data again with the same function rt_mxs_auart_tx_chars

My problem is that I do not seem to receive the end of my message. For example, if I try to send "This... is my second message" (29 char) I only get "This... is my sec" (17 char). The log is the following:

Calling open functionCalling write functionEnabling TransmitterStart transmittingWe've stopped transmitting because FIFO is full, remains: 12 to be sent (bytes pending)12 bytes pending, setting AUART_INTR_TXIENIRQ handler calledTransmit Interrupt Status enabledStart transmittingWe've stopped transmitting because FIFO is full, remains: 4 to be sent (bytes pending)4 bytes pending, setting AUART_INTR_TXIENReceive Interrupt Status or Receive Timeout Interrupt Status enabledIRQ handler calledTransmit Interrupt Status enabledStart transmitting0 bytes pending, clearing AUART_INTR_TXIENDisabling Transmitter

How do you think can I correct this?

why - is before -ENOMEM in linux kernel code? [duplicate]

$
0
0

I see return -ENOMEM; in linux kernel code , why used - before ENOMEM .

if (vma->vm_end - vma->vm_start > stack_base)        return -ENOMEM; 

grub/i386-pc/normal.mod not found centos 7

$
0
0

A CnetOS7 VM which is installed on top of ESXI is suddenly stopped booting and showing the screen as grub secure>

I have tried the solutionhttps://unix.stackexchange.com/questions/70538/grub-error-file-grub-i386-pc-normal-mod-not-found but couldn't get through.

my prefix settings are like below.prefix=(hd0,msdos1)/boot/grubroot=hd0,msdos1

ls:(hd0) (hd0,msdos2) (hd0,msdos1)

ls (hd0,msdos2)unknown file system

ls (hd0)unknown file system

-- confirmed above are not our partitions.

ls (hd0,msdos1)(hd0,msdos1); File system is xfs-- This is our partition and we have prefix also the same.[prefix=(hd0,msdos1)/boot/grub]

but when I am listing inside objects of (hd0,msdos1) I am getting nothing it's showing part of below./ ../

Can anyone have any solution?

Tree structure for Linux kernel source code [closed]

$
0
0

How to Construct a tree structure for depicting the organization of LinuxKernel source code with various important modules and sub-modules?

Can someone please help me understand the object dump of a init_module?

$
0
0

I have a kernel module and I'm trying to understand how this module is working. My init_module section is like this,

char *sym_name = "sys_call_table";static sys_call_ptr_t *sys_call_table;static int __init start(void){       sys_call_table = (sys_call_ptr_t *)kallsyms_lookup_name(sym_name);    old_write = (original_write)sys_call_table[__NR_write];     disable_write_protection();     sys_call_table[__NR_write] = (sys_call_ptr_t)test_write;    enable_write_protection();      return 0;}

And objdump -dr xxx.ko give me this

Disassembly of section .init.text:0000000000000000 <init_module>:0:  e8 00 00 00 00          callq  5 <init_module+0x5>        1: R_X86_64_PC32    __fentry__-0x45:  55                      push   %rbp6:  48 8b 3d 00 00 00 00    mov    0x0(%rip),%rdi        # d <init_module+0xd>        9: R_X86_64_PC32    sym_name-0x4d:  48 89 e5                mov    %rsp,%rbp10: 53                      push   %rbx11: e8 00 00 00 00          callq  16 <init_module+0x16>        12: R_X86_64_PC32   kallsyms_lookup_name-0x416: 48 89 c3                mov    %rax,%rbx19: 48 89 05 00 00 00 00    mov    %rax,0x0(%rip)        # 20 <init_module+0x20>        1c: R_X86_64_PC32   .bss+0x420: 48 8b 40 08             mov    0x8(%rax),%rax24: 48 89 05 00 00 00 00    mov    %rax,0x0(%rip)        # 2b <init_module+0x2b>        27: R_X86_64_PC32   old_write-0x42b: e8 00 00 00 00          callq  30 <init_module+0x30>        2c: R_X86_64_PC32   disable_write_protection-0x430: 48 c7 43 08 00 00 00    movq   $0x0,0x8(%rbx)37: 00         34: R_X86_64_32S    test_write38: e8 00 00 00 00          callq  3d <init_module+0x3d>        39: R_X86_64_PC32   enable_write_protection-0x43d: 31 c0                   xor    %eax,%eax3f: 5b                      pop    %rbx40: 5d                      pop    %rbp41: c3                      retq      

I'm trying to relate my original code with this object dump but I'm lost. How can I interpret this assembly code to my actual code?

Viewing all 12279 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>