/r/kernel

Photograph via snooOG

A moderated community dedicated to technical discussion about the Linux kernel.

Welcome to /r/kernel, a moderated community dedicated to all things about the Linux kernel. Technical articles only, please!

You may be interested in the following links:

And some books:

Related Communities

/r/kernel

16,869 Subscribers

2

LSP support in kernel with GCC?

I want to add LSP support in Neovim for the kernel tree (for autocomplete, jump to definition etc..). I googled around a bit and found out about scripts/clang-tools/gen\_compile\_commands.py which generates a compile_commands.json which can be used by say the clangd LSP in Neovim.

My question is does the kernel have to be compiled with clang for this to work? Is there an alternative if I compile with GCC?

5 Comments
2024/04/12
17:39 UTC

10

why is there poweroff command in init script initramfs?

I'm currently working on some kernel challenge and I notice that in init script there is always a poweroff command at the end. Can someone help me explain this? What is the point of having poweroff in the init script? will it just shutdown the machine ?

https://preview.redd.it/mc2gw925sytc1.png?width=674&format=png&auto=webp&s=d09e4a82ceb8eb3829e83a3df853917fd696fdeb

3 Comments
2024/04/12
03:02 UTC

6

what are the specific benefits of having everything in Linux represented as a file?

ok, so i understand that everything in linux is represented as a file, i understand that design philosophy came from unix, which linux is based off of.

my question is, what are the specific benefits this design philosophy gives us? why should everything be a file or represented as a file on linux? what are the upsides?

thank you

14 Comments
2024/04/11
10:16 UTC

3

Creating my own Operating System : Deciding the architecture.

Basically i was trying to create my own operating system. where i got to the point that for creating your operating system -> you need a bootloader --> bootloader works on the particular hardware (architecture) --> every computer have different architectures. So for the newbies in the os development what could be the best architecture to start on. if so how to start. (buying hardwares could be costly,so recommend me something that will cost nothing)

6 Comments
2024/04/09
17:14 UTC

31

We built an infinite canvas for reading the linux kernel sources

I apologize if this post comes across as spammy. Hopefully it's still appropriate to post here as I think we can provide some value for the kernel devs.

I spent last couple of months with my friend building an „infinite canvas” kind of app for exploring source code. We take a repo, cut the code into individual definitions and give you a graph you can interactively explore on the web. The app can be found at https://territory.dev. Our goal is to make this service available for free for free software repos. We indexed linux and LLVM sources and will be covering more public repos soon.

random piece of code graph

I would love to hear if this is useful for you.

19 Comments
2024/04/04
21:14 UTC

3

How does the linker make data read only?

I was browsing through some linux kernel code and noticed some variables declared as "ro_after_init".

This basically stands for __attribute__((section(.data..ro_after_init)).

This make the data read-only after init. But how exactly does this data become read only? When I am in kernel mode with full privileges, I am able to access all physical memory right?

Please lemme know what I am missing here. Thanks

2 Comments
2024/04/04
17:10 UTC

0

How to get the Root Process id from the process id

Hello everyone I am new to windows kernel programming, I am writing a minifilter drive to file system monitoring now I need to find the Root Process id for the process id which get using psGetCurrentProcessId if anyone know how solve this comment on this thanks

1 Comment
2024/04/04
17:02 UTC

4

Is there any support in lm-sensors for DDR5 temperature sensors?

The standard is easily found at https://www.jedec.org/standards-documents/docs/jesd300-5b01 , but I can't find any evidence this is supported yet in Linux.

Before I give up on this and eventually try to make my own patch (doubtful), I want to make sure I am not missing anything.

0 Comments
2024/04/01
21:21 UTC

0

Kernel Program Doubt

Hello folks i am new to windows kernel programming and I have written a basic program how I have a some doubt in drivers is there is a any process id for driver I have read in many documents and msdn in that they are the drivers doesn't have any process id but some of them saying that the drivers doesn't not have direct process it associated with come other like that if any body knows about this please clarify this

#kernel #driver #windows #beginer #os

6 Comments
2024/04/01
17:17 UTC

2

How is kmem_cache_create() different from kmalloc()?

According to an article in kernel.org, (https://www.kernel.org/doc/html/next/core-api/memory-allocation.html)

If you need to allocate many identical objects you can use the slab cache allocator. The cache should be set up with kmem_cache_create() or kmem_cache_create_usercopy().

What advantage does this give when multiple “identical” entities need memory?

And what is being “cached” here and how?

1 Comment
2024/04/01
13:56 UTC

5

What email do y'all use? I'm trying to find a good mail provider for mutt in 2024

2 Comments
2024/03/30
13:40 UTC

4

How to replace linux kernel with debug symbols?

I have installed Raspberry Pi OS on my RPi4b and wanted to debug it using KGDB's serial connection onto another machine running gdb.

I have compiled the kernel on the other machine for inserting the symbol file and successfully connect to the PI's KGDB.

But it was too late when I realised the PI's kernel does not have debug symbols compiled in (obviously since it is a release build).

Now I have built a new kernel for the PI with CONFIG_DEBUG_INFO turned on. I want to replace this new kernel with the old one.

How do I go about it? Is it even possible?

0 Comments
2024/03/27
04:56 UTC

5

Where in the kernel is block caching done? At the individual FS driver level or at some higher core kernel level?

2 Comments
2024/03/25
12:17 UTC

3

Help with Nothing Phone 1 kernel

I'm a beginner in kernel development, trying to compile the Nothing Phone 1 kernel, but keep hitting errors. Please don't direct me towards general Linux kernel compiling guides—they've never worked for me. Can anyone offer a device-specific guide or tips to get this done correctly?

0 Comments
2024/03/23
23:47 UTC

2

What is VHE and nVHE?

I found these two directories in arch/arm64/kvm/ and was unable to find much resources online about them as a whole. Only mailing lists which explained a specific part of these two.

Please drop some resources and information:)

2 Comments
2024/03/23
06:15 UTC

2

How to write binary data to eerpom device with at24.c library?

Hi all,

I quite new to linux kernel development so sorry if I has stupid question.

As of now I am working with CAT24C256WI-GT3, the requirement is there was a configuration file which previously used to "flash" the configures to CAT24C256WI-GT3 via Aarvark, now I want to build an script/executable program to flash it from terminal.

something like:

updateeprom read

and:

updateeprom write [path_to_binary_file]

I am looking into at24.c lib and trying to use it.

Any suggestion is very appreciated.

Thank you!

1 Comment
2024/03/20
03:46 UTC

0

6.8 Running on Ubuntu 22.04.4

I installed 6.8 on my Beelink Mini S12 Pro PC today, so far it's running smoothly. Anyone else try the new kernel?

5 Comments
2024/03/14
07:07 UTC

6

What is the point of using atomic64 variables?

For example,

If atomic variable "v" has to be set to "i".

arch/arm64/kvm/vmid.c: atomic64_set(&v, i) is called.

This is where it takes us,

atomic64_set() --> raw_atomic64_set() --> arch_atomic64_set() --> arch_atomic_set() --> __WRITE_ONCE((v->counter), (i))

This expands to: *(volatile typeof(x) *)&(x) = (val); (include/asm-generic/rwonce.h)

Q1) So, what was the point of all this? How is an atomic variable different from any other variable?

Q2) Why typecast it as a volatile pointer and then dereference it?

Please help.

6 Comments
2024/03/11
16:49 UTC

1

Ubuntu 22.04, kernel version 6.5.0-25.25 not recognizing GeForce GTX 970

Hello, I updated the kernel to version 6.5.0-25.25 in the past week. The computer stays on Suspend mode often. Today, I rebooted the computer. The computer has two monitors, and I noticed that one would not load as usual. Upon booting, the graphics card was not detected and a single monitor continued to function. I restarted the computer multiple times before attempting to load into the older kernel (the older kernel is version 6.5.0-21.21). The second monitor responded during booting from the older kernel, and the system is running normally now that the older kernel version is loaded. I'll try to include relevant information below. Please inform me if additional information is needed (and the commands to obtain it would be helpful, as well).

Thanks in advance

uname -a

Linux ubuntu-desktop 6.5.0-21-generic #21~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Feb 9 13:32:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

sudo lshw -c video

*-display

description: VGA compatible controller

product: GM204 [GeForce GTX 970]

vendor: NVIDIA Corporation

physical id: 0

bus info: pci@0000:07:00.0

version: a1

width: 64 bits

clock: 33MHz

capabilities: pm msi pciexpress vga_controller bus_master cap_list rom

configuration: driver=nvidia latency=0

resources: irq:75 memory:fd000000-fdffffff memory:c0000000-cfffffff memory:d0000000-d1ffffff ioport:c000(size=128) memory:c0000-dffff

*-graphics

product: EFI VGA

physical id: 1

logical name: /dev/fb0

capabilities: fb

configuration: depth=32 resolution=1024,768

1 Comment
2024/03/10
03:02 UTC

3

COSMOS C# - My OS

I just built my OS and tested it on real hardware. This was done in the Cosmos C# Kernel. The only problem is that when it starts it shows for 1 second the error: PS/2 Controller Device Detection Failed: FirstByte 171

Help!!!

4 Comments
2024/03/09
08:41 UTC

16

How are people developing the KVM subsystem for ARM64?

I am asking this because in the current kernel, the ARM64 KVM cannot be compiled out-of-tree as a module.

So if you make some changes, lets say you add some printk() statements, you will have to reboot the entire host machine in order to see changes. I see this as very cumbersome especially for an development environment.

So, that being said, how are people actually going about developing this subsystem of the kernel without external module support?

Thanks

8 Comments
2024/03/03
12:44 UTC

12

Howto develop a driver for linux

I've been looking at the mainline Linux kernel driver/staging directory and have found a driver (rtl8912c) that I am interested in contributing to, mainly because I have a device with the rtl8912cu chipset.

I tried searching for a datasheet / reference manual / thing that describes the registers of the device, but could not find one. I have 2 questions :

  1. How would the original driver have been developed?
  2. A follow up, do I even need the datasheet / reference manual to contribute (significantly) to the driver? Significantly means, not checkpatch fixes but rather un-implemented functionality as listed in the TODO.
3 Comments
2024/03/02
17:59 UTC

6

Why are flex and bison listed as Linux kernel build dependencies?

And many other system softwares for that matter.

13 Comments
2024/02/29
01:58 UTC

11

PSA: Some interesting Confidential Computing kernel work will be presented at OC3

The open confidential computing conference is coming up online on March 13th: https://www.oc3.dev/
Some interesting talks from the kernel community:

  • Asterinas: A safe and efficient Rust-based OS kernel for TEE and beyond
  • Using TDISP to Extend Attestation to Devices connected to a Trusted Execution Environment
  • News from the COCONUT-SVSM Community
  • DICE Attestation on AMD SEV-SNP
  • Evolution of the Arm Confidential Compute Architecture, and how Arm is supporting ecosystem developers

0 Comments
2024/02/28
16:21 UTC

5

Tracking of writes/access to mapped memory inside of device driver

Hey guys,

I am trying to write a device driver that detects writes (or accesses) to memory, that has been allocated (with kalloc) in the module's init function and mmaped to userspace when a process mmaps the given device.

I have read about UIO driver but from what I got, there is usually hardware and a IRQ involved in the course of the usage. Unfortunately I dont have hardware.

I have looked a bit into the mmu_notifier interface, but right now I am not experienced enough to know how this could work and what is needed to set this up properly.

Is the mmu_notifier the way to go or how is this achievable?

1 Comment
2024/02/27
10:45 UTC

0

XFS bug

hey guys,

has the XFS bug (kernel 6.3) been fixed?

https://bugzilla.redhat.com/show_bug.cgi?id=2208553

4 Comments
2024/02/27
07:40 UTC

7

How to debug the KVM module?

I am trying to understand the KVM and QEMU internals.

I am debugging QEMU using gdb but QEMU calls ioctl() to talk to KVM using /dev/kvm.

But how do I debug when control reaches the kernel itself?

Since it is KVM, I cannot compile and run a linux kernel on QEMU and debug it I believe.

5 Comments
2024/02/25
06:32 UTC

Back To Top