<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Linux-Recompile on virtfunc</title><link>https://virtfunc.com/tags/linux-recompile/</link><description>Recent content in Linux-Recompile on virtfunc</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Wed, 04 Jun 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://virtfunc.com/tags/linux-recompile/index.xml" rel="self" type="application/rss+xml"/><item><title>KVM Rapid Iteration</title><link>https://virtfunc.com/projects/kvm-rapid-iteration/</link><pubDate>Wed, 04 Jun 2025 00:00:00 +0000</pubDate><guid>https://virtfunc.com/projects/kvm-rapid-iteration/</guid><description>&lt;p&gt;Rebuilding a the full linux kernel when modifying KVM for the purposes of patching VM exit RDTSC timings is a tedious process. Thankfully, the linux kernel is modular and can be built in pieces and incrementally upgraded.&lt;/p&gt;
&lt;p&gt;This can be accomplished relatively safely by following the rough steps outlined below:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Fully build the kernel once, and loading this built kernel.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Compile only KVM as a module.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Kill all running VMs.&lt;/p&gt;</description><content>&lt;p&gt;Rebuilding a the full linux kernel when modifying KVM for the purposes of patching VM exit RDTSC timings is a tedious process. Thankfully, the linux kernel is modular and can be built in pieces and incrementally upgraded.&lt;/p&gt;
&lt;p&gt;This can be accomplished relatively safely by following the rough steps outlined below:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Fully build the kernel once, and loading this built kernel.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Compile only KVM as a module.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Kill all running VMs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Remove existing KVM modules.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Load freshly built KVM modules.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Restart killed VMs.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;On first use, the script may perform a full kernel build if it cannot find &lt;code&gt;vmlinux&lt;/code&gt; in the source folder. Subsequent iterations skip the full build, reducing iteration time from ~10 minutes to approximately 5 seconds, plus the time it takes to reboot your virtual machines.&lt;/p&gt;
&lt;p&gt;To use the script:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone a copy of &lt;a href="https://github.com/Scrut1ny/AutoVirt"&gt;AutoVirt&lt;/a&gt;. (commit &lt;code&gt;c69721f&lt;/code&gt; was tested.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Drop the script in the &lt;code&gt;modules&lt;/code&gt; folder.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Build the kernel by executing the kernel script in &lt;code&gt;modules&lt;/code&gt; folder.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Make your changes to the linux kernel KVM source code on disk.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the iteration script after killing all VMs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Restart your VMs.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Note that a full build will revert to the tag specified. For iterative builds, the script uses the current source files on disk directly, no Git operations are performed.&lt;/p&gt;
&lt;h1 id="source"&gt;Source:&lt;/h1&gt;
&lt;p&gt;Available at: &lt;a href="https://gist.github.com/virtfunc/2278f2f6f1d486521cb635813ff8dde7"&gt;https://gist.github.com/virtfunc/2278f2f6f1d486521cb635813ff8dde7&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Caveats and assumptions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Hardcoded to use &lt;code&gt;kvm_amd&lt;/code&gt;, but should work on Intel processors with simple modifications.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Expects to be present in the &lt;code&gt;modules&lt;/code&gt; folder of an &lt;a href="https://github.com/Scrut1ny/AutoVirt"&gt;AutoVirt&lt;/a&gt; git project. (Tested against commit &lt;code&gt;c69721f&lt;/code&gt;.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Assumes Arch Linux, other distros untested.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;</content></item></channel></rss>