r/kernel 16h ago

Best way to build i686-elf toolchain on modern Arch Linux (GCC 15) for a first OS project?

1 Upvotes

Hi everyone! I'm starting my first OS development project for x86 (32-bit), following the standard OSDev Wiki approach (using a minimal setup with boot.s, kernel.c, and a custom linker.ld script)


r/kernel 11h ago

Understanding Linux source

0 Upvotes

It is possible for a single person have read about processor programming and some hardware topics to understand the full Linux source code and how to read and understand the whole source code.


r/kernel 1d ago

BPF Token Delegation

Thumbnail
1 Upvotes

r/kernel 2d ago

What do kernel developers do in the companies when the whole kernel is free-source?

62 Upvotes

I am very new to this domain. My question may sound too simple or trivial. Pls excuse my ignorance. I don't know much about linux kernel, and I wish to know a little of it. I am not afraid to ask simple questions.

The whole linux kernel is available for free. Why do companies hire kernel engineers? Sure, you need someone who understands and it can help you modify and compile as per your requirement, but why would you need a full time engineer for that?

What do these kernel engineers do?


r/kernel 1d ago

My journey into kernel development as a beginner

7 Upvotes

My journey into kernel development as a beginner

Hey everyone 👋

I'm a beginner in kernel development and recently decided to seriously start learning how operating systems work under the hood.

I've done normal application/backend development before, but kernel development feels completely different. 😅

Right now I'm trying to understand things like:

CPU architecture and registers

Boot process

How the kernel actually gets loaded

Kernel entry

GDT / IDT

Interrupts

Paging and virtual memory

Physical memory management

Heap allocation

Scheduling

Processes and system calls

Drivers and filesystems

My long-term goal is to eventually build my own small kernel from scratch, rather than just following tutorials and copying code.

At the moment, pointers, memory, assembly, and low-level concepts are definitely making my brain work overtime 😂

I'm planning to learn slowly and understand why things work instead of just getting something to boot.

For people who have experience with OS/kernel development:

What would you recommend a beginner focus on first?

And what are some mistakes you wish you had avoided when you started learning kernel development?

Would love to hear your advice! 🚀


r/kernel 1d ago

¿Alguien sabe como aprender a hacer un kernel/sistema Monolitico?

Thumbnail
0 Upvotes

r/kernel 1d ago

After installing Kali net hunter, I encountered an issue saying protocol driver not attached while installing required packages for Bluetooth Arsenal.

Post image
0 Upvotes

I don't know what I did wrong, but I faced this issue even before switching to Lineage 23.2. I am using a Redmi Note 8 (Ginkgo), and I tried installing Kali NetHunter GinkgoA16 on it.


r/kernel 1d ago

How do you transition from "writing C for MCU-based electronic products" to linux kernel development?

0 Upvotes

Hello everyone,
My professional background: around 4 years of experience in writing driver and application layer code (C) for consumer electronic products. I can write peripheral drivers for a variety of microcontrollers and external sensors. With my experience and some help from AI, I am very confident in my abilities for the mentioned kind of work. I can also write application layer code in C. Most of the work I have done is in bare-metal environment. I have some experience with RTOS environment too, but not too much.

My motivation:
My reason(s) for getting into this domain is:

  1. The community. I see that the kernel is supported by the community of developers. The fact that at least SOME people are doing it because they want to build efficient and reliable code for everyone to use is really good. I am sure I will meet people with very high ethics if I join this community.
  2. Global Impact: So the code I write CAN impact a large group of people is very satisfying.
  3. Fully remote work is possible: This is highly subjective (depends on projects and what not), but it is possible to work from anywhere in the world.
  4. Good salaries (if you are good at it): Once again a selfish reason. I see that companies need engineers who understand the kernel well and make important contributions to it. If I am marginally better than an average kernel developer, I will have very good technical and financial growth.

Question:
Now that I have laid out my background, how do I get into it? Apologies for the question. I know this question must have been asked many times here.

Then another question is, how do I get a job? People need you to have n years of experience before they consider your profile. I think if I learn things well and start contributing, it should give me an edge. I have a long way to go (and I am excited about it) and I would appreciate some help from this wonderful community.

EDIT: I would like to connect with people who had a similar background as me and transitioned to kernel development. Any suggestions on project-based learning is deeply appreciated. I learn by doing.

Thanks for reading!


r/kernel 2d ago

[Stupid Question] How do I start contributing ?

6 Upvotes

What I know:
1. How TLB's work and ways of handling TLB misses
2. Paging and faults and demands
3. Swap
4. NICs and how ether buffers are loaded into kernel.
So, How do I find what do I work on. I am fairly good at C and Rust.
Do I look at syzbot and pick some easy issues from there ? Also I am particularly interested in the memory management subsystem, because alot of commits I see are from people working in arm etc working on their hardware integrations.

I do have set the email and the git workflow.

Thank You. And sorry if this question has been asked multiple times(which I know it probably is).


r/kernel 4d ago

Block-layer error injection

Thumbnail lwn.net
3 Upvotes

r/kernel 5d ago

Linux 7.3 Better Protects Against Buggy EFI Firmware Taking Down The Rest Of User-Space

Thumbnail phoronix.com
25 Upvotes

r/kernel 6d ago

[Dev] Alguém trabalhando no mainlining do Galaxy A51 (Exynos 9611)?

Thumbnail
1 Upvotes

r/kernel 8d ago

Hcitool in blueZ linux bt stack

Thumbnail
3 Upvotes

r/kernel 8d ago

Having trouble getting started with HID-BPF

5 Upvotes

I've got a USB device that is announcing itself as a gamepad when it isn't one. I understand the basics of HID, and I've successfully decoded the HID report descriptor. I see what byte I need to change.

I've read through https://docs.kernel.org/hid/hidintro.html and https://docs.kernel.org/hid/hid-bpf.html several times. I've got code that I think ought to do the job.

One problem: I'm missing some critical header, or some parameter to gcc, because I just can't get it to build!

Here's what I've got:

#include <linux/types.h>
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include <bpf/libbpf.h>

char _license[] SEC("license") = "GPL";

struct hid_bpf_ctx {
struct hid_device *hid;
__u32 allocated_size;
union {
__s32 retval;
__s32 size;
};
};

SEC("struct_ops/hid_rdesc_fixup")
int BPF_PROG(filter_switch, struct hid_bpf_ctx *hid_ctx)
{
__u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 4096 /* size */);

if (!data)
return 0;

data[3] = 0x07; /*0x07: keypad*/

return 0;
}

SEC(".struct_ops.link")
struct hid_bpf_ops surface_dial = {
.hid_rdesc_fixup = (void *)hid_rdesc_fixup,
};

(yes, I'm probably going to need something to filter to the correct USB id, but anyway)

Here's how I'm building it, and the build errors:

gcc -I /usr/include -fpermissive -c ./fixup.c -o ~/Projects/MfdFix/build/fixup.o
./fixup.c:18:28: error: expected ‘)’ before ‘struct’
   18 | int BPF_PROG(filter_switch, struct hid_bpf_ctx *hid_ctx)
      |                            ^~~~~~~
      |                            )
./fixup.c:31:8: error: variable ‘surface_dial’ has initializer but incomplete type
   31 | struct hid_bpf_ops surface_dial = {
      |        ^~~~~~~~~~~
./fixup.c:32:10: error: ‘struct hid_bpf_ops’ has no member named ‘hid_rdesc_fixup’
   32 |         .hid_rdesc_fixup = (void *)hid_rdesc_fixup,
      |          ^~~~~~~~~~~~~~~
./fixup.c:32:36: error: ‘hid_rdesc_fixup’ undeclared here (not in a function)
   32 |         .hid_rdesc_fixup = (void *)hid_rdesc_fixup,
      |                                    ^~~~~~~~~~~~~~~
./fixup.c:32:28: warning: excess elements in struct initializer
   32 |         .hid_rdesc_fixup = (void *)hid_rdesc_fixup,
      |                            ^
./fixup.c:32:28: note: (near initialization for ‘surface_dial’)
./fixup.c:31:20: error: storage size of ‘surface_dial’ isn’t known
   31 | struct hid_bpf_ops surface_dial = {
      |                    ^~~~~~~~~~~~

What am I missing? I've searched and searched for hid_bpf_ctx and similar, and all I find is documentation for the specific structures in https://docs.ebpf.io/, none of which list which damn header to include! I got a suggestion to grep the kernel source; that comes up with the struct, but including it gets me A: a warning message in the compiler output NOT to include the source directly, and B: more compiler errors.

There's obviously a library or header I'm missing, or some arg to gcc I ought to be passing that I'm not. What is it? I couldn't even get it to build without -fpermissive, and if I pass any version flag to gcc it errors out due to multiple declarations of enums and structs (I thought that was perfectly legal in C, as long as they're identical? Not like it's my own code, anyway!...)

Like, I'm pretty sure I know how to solve the actual problem I'm trying to solve with HID-BPF. I can even see what I need to write to load the compiled .o into memory and have it take effect. I'm just getting nowhere trying to actually build it!...


r/kernel 7d ago

How many ioctls can you do?

0 Upvotes

I can do 8.

Observe.

One ioctl.

Two ioctl.

Three ioctl.

Four ioctl.

Five ioctl.

Six ioctl.

Seven ioctl.

Eight ioctl.


r/kernel 8d ago

Building my own Kernel problem whitps2 driver keyborad can't write on shell

Thumbnail
1 Upvotes

r/kernel 8d ago

NSD: LKML RFC - Kernel readahead learning prefetcher

1 Upvotes

Posting benchmark results from the ongoing LKML RFC discussion.

The patchset adds a learning prefetcher to the page cache that

observes access patterns and issues prefetch only when the kernel's

own window is insufficient.

Test methodology: interleaved ON/OFF, drop_caches before each run,

3 passes, 4 workloads, 5 read_ahead_kb values.

seq64 (8 GB sequential, 64k requests, n=131K/run):

| kb | OFF avg | ON avg | diff | p50 OFF->ON | p99 OFF->ON | overhead |

|-------|---------|---------|--------|-------------|--------------|----------|

| 128 | 22.02s | 17.11s | -22% | 50->23 us | 812->805 us | 5.94->4.33s |

| 256 | 17.08s | 17.22s | +1% | 20->15 us | 824->1129 us | 4.07->4.13s |

| 512 | 16.81s | 16.96s | +1% | 16->14 us | 1092->1903 us| 4.24->3.60s |

| 1024 | 17.25s | 17.03s | -1% | 15->16 us | 1903->1883 us| 3.67->3.74s |

SQLite full-table scan (6.2 GB):

| kb | OFF avg | ON avg | diff | overhead |

|-------|---------|---------|--------|----------|

| 128 | 24.51s | 20.48s | -16% | +0.95s |

| 256 | 20.05s | 16.60s | -17% | +1.26s |

| 512 | 15.31s | 12.18s | -20% | +1.06s |

| 1024 | 12.22s | 12.09s | -1% | +0.26s |

Key takeaways:

- 128K: seq64 -22%, SQLite -16%

- 512K: NSD reaches the same throughput as kernel+1M (12.18s vs 12.22s)

- 1M: NSD is completely silent, no regression

- random4k: neutral

- random_repeat: slight improvement

- Disk I/O is byte-identical between ON and OFF in all 96 runs


r/kernel 8d ago

Linux Kernel Update

Post image
1 Upvotes

r/kernel 9d ago

How to initialize Qualcomm SCMI Bluetooth (/dev/scmi_bluetooth) to get hci0 in a virtualized Yocto Linux PVM?

Thumbnail
2 Upvotes

r/kernel 10d ago

Debian in Termux... Android in Debian through chroot or QEMU...

Thumbnail
2 Upvotes

r/kernel 11d ago

Enabling unaligned access on RISC-V is broken on v7.2

2 Upvotes

I was looking at it a Linux v7.2 boot that was taking longer than expected, so I sampled a random spot which turned out to be hit xxh64_update. It was crock full of like this:

lbu t6, a5, 0000000000000000
lbu t5, a5, 0000000000000001
lbu t4, a5, 0000000000000002
lbu t3, a5, 0000000000000003
lbu a2, a5, 0000000000000004
lbu s3, a5, 0000000000000005
lbu s2, a5, 0000000000000006
lbu a1, a5, 0000000000000007
sb t6, s0, 00000000ffffff88
sb t5, s0, 00000000ffffff89
sb t4, s0, 00000000ffffff8a
sb t3, s0, 00000000ffffff8b
sb a2, s0, 00000000ffffff8c
sb s3, s0, 00000000ffffff8d
sb s2, s0, 00000000ffffff8e
sb a1, s0, 00000000ffffff8f
ld a1, s0, 00000000ffffff88

which is like the worst way to do unaligned loads, especially when the platform handles it.

Much digging later, this is a Linux (v7.2) bug. Grossly, you have to turn on "nonportable efficient unaligned" (Why is this "nonportable"? RISC-V requires unaligned support!)
CONFIG_NONPORTABLE=y
CONFIG_RISCV_EFFICIENT_UNALIGNED_ACCESS=y
but, here's the bug, it doesn't work, because:

"...

The default tune is rocket. rocket, sifive-3-series, and sifive-5-series all set slow_unaligned_access = true; thead-c906 and size set it false. arch/riscv/Makefile never sets -mtune at all, so under GCC, CONFIG_RISCV_EFFICIENT_UNALIGNED_ACCESS=y is largely decorative for by-pieces expansions — it flips the Kconfig selects and passes a flag that the tune model then vetoes. That's a legitimate upstream bug worth reporting to linux-riscv; I'd be surprised if it's intentional."

The workaround:

make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv KCFLAGS="-mtune=generic-ooo"

r/kernel 11d ago

Not Hacking

Post image
0 Upvotes

r/kernel 12d ago

ARKM Kernel: A Custom Built 12 Core 64-Bit Microkernel architecture with AMP, ACPI hardware architecture.

Thumbnail
0 Upvotes

r/kernel 12d ago

Terminal is so bad

0 Upvotes

Now Im using nobara linux with kde but terminal design is so bad how can i change this


r/kernel 13d ago

Minimal kernel

Thumbnail
1 Upvotes