Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable CONFIG_IKHEADERS=m in WSL kernel #5526

Open
ahupp opened this issue Jul 2, 2020 · 9 comments
Open

Enable CONFIG_IKHEADERS=m in WSL kernel #5526

ahupp opened this issue Jul 2, 2020 · 9 comments
Assignees
Labels
feature kconfig linux kernel configuration

Comments

@ahupp
Copy link

ahupp commented Jul 2, 2020

Is your feature request related to a problem? Please describe.
I'm using BPF to build profiling tools. This depends on having kernel headers that match the currently running kernel. However, there's (of course) no -headers package in debian for the MS kernel. I can probably pull the kernel source from github and use those headers but this a bit of a pain.

Describe the solution you'd like
Modern kernels can be packaged with the headers as a kernel module using CONFIG_IKHEADERS=m. This is the simplest way to make sure there's headers available that are in sync with the running kernel, esp if that kernel is distributed outside of the distribution I'm running.

Describe alternatives you've considered
I could maybe try to run a stock kernel (this works in WSL2, yes?), or download the headers, but that seems more error prone than the proposal.

Additional context
N/A

@benhillis benhillis self-assigned this Jul 2, 2020
@benhillis
Copy link
Member

I like this suggestion, I will see about adding this support. Looks like 4.19 does not support this config flag, but we are moving to 5.4 "soon".

@therealkenc
Copy link
Collaborator

Heads up archivemount, at least as a thought experiment if not an entirely serious proposal. Given that the idea of a cross-distro /usr/lib/wsl/lib automount has been entertained, /usr/lib/wsl/include/kernel is not a long walk, philosophically. Just sayin'.

@therealkenc therealkenc added the kconfig linux kernel configuration label Jul 6, 2020
@chadbrewbaker
Copy link

@benhillis stupid question. I have the git branch for 4.19.104-microsoft-standard built. What are the steps for copying the kernel headers to to a linux-headers-4.19.104-microsoft-standard directory for bpf tools? Ubuntu20.04 if it matters.

@chadbrewbaker
Copy link

Figured it out. Aww yeah ... BPF tools under WSL2 🥳

cd /path/to/WSL2-Linux-Kernel #check out branch corresponding to uname -r tag
make KCONFIG_CONFIG=Microsoft/config-wsl
sudo ln /path/to/WSL2-Linux-Kernel -s /lib/modules/4.19.104-microsoft-standard/build

@jthoward64
Copy link

Any progress on this issue now that 5.4 is way further along?

@ThomsonTan
Copy link

Any progress on this issue since 5.10 was released for some time?

voltrare added a commit to voltrare/WSL2-Kernel-autobuild that referenced this issue Jun 22, 2022
@MageekChiu
Copy link

MageekChiu commented Nov 23, 2022

Wondering this myself

@danielkatz
Copy link

danielkatz commented Aug 16, 2023

@benhillis Can we get an update of this proposal? It's a trivial (as far as i understand it) change that'll lower the bar for entry to the already complicated enough world of eBPF programming.

@clouds56
Copy link

Let's moving forward on this, there are lots of user scenarios requiring linux-headers. Most of them are following some scripts or tech blogs asking apt install linux-headers-$(uname -r), so it might be hard for them to sync git and build linux just for headers every month.

e.g. #11942 #11596 #11557 #10967 #10913 #10069 (comment) #7437 #6650 #6635 #4132 #4128 #3235 #2649 #2363

It would be great to take advantage of github actions in https://github.com/microsoft/WSL2-Linux-Kernel that build headers at release.

For those who have to built headers themselves and lost in many dup issues.

git clone https://github.com/microsoft/WSL2-Linux-Kernel.git
cd WSL2-Linux-Kernel

We need to update config

# cp -af Microsoft/config-wsl .config # if use default config
zcat /proc/config.gz > .config # if use current config
sudo make INSTALL_HDR_PATH=/usr/lib/modules/"$(uname -r)"/build headers_install

Nevuly added a commit to Nevuly/WSL2-Linux-Kernel-Rolling that referenced this issue Jan 20, 2025
 * Enable kernel headers through /sys/kernel/kheaders.tar.xz feature.
 * Enable trim unused exported kernel symbols feature.
 * Enable multipath TCP and support IPv6 too.
 * Related from microsoft/WSL#5526 and Locietta/xanmod-kernel-WSL2#64.

Signed-off-by: Yang Jeong Hun <[email protected]>
Nevuly added a commit to Nevuly/WSL2-Linux-Kernel-Rolling-LTS that referenced this issue Jan 20, 2025
 * Enable kernel headers through /sys/kernel/kheaders.tar.xz feature.
 * Enable trim unused exported kernel symbols feature.
 * Enable multipath TCP and support IPv6 too.
 * Related from microsoft/WSL#5526 and Locietta/xanmod-kernel-WSL2#64.

Signed-off-by: Yang Jeong Hun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature kconfig linux kernel configuration
Projects
None yet
Development

No branches or pull requests

9 participants