Rebuilding 3.1 & 3.0 Linux Kernel in Ubuntu style to support PV-on-HVM

*********************************************************************************************************************
Stock kernel for Oneiric (3.0.X.Y) has same Xen configuration as 3.1. I have filed bug against 3.1 at Launchpad regarding kernel configuration fix,however, in meantime i had to pass through procedure bellow with intend to benefit from PV-on-HVM feature providing by Xen 4.1.X Hypervisor and properly built 3.0 or 3.1 linux kernel. I follow [1] step by step updating config.flavour.pvhvm as required to perform kernel rebuild. In meantime status of bug at Launchpad is “Triaged”.There is another attractive option – just add driver xen-platform-pci.ko to initrd.img as post installation procedure. Then reboot with xen_platform_pci=1. I choosed kernel rebuild as option following core development [2]
**********************************************************************************************************************

A) To rebuild 3.1 :-
$ git clone git://kernel.ubuntu.com/ubuntu/ubuntu-precise.git source
B) To rebuild 3.0 :-
$ git clone git://kernel.ubuntu.com/ubuntu/ubuntu-oneiric.git source
$ cd source
$ git tag|grep Ubu|sort -V
Ubuntu-3.1.0-1.0
Ubuntu-3.1.0-1.1
Ubuntu-3.1.0-2.2
Ubuntu-3.1.0-2.3
Checkout branch and give it name "pvhvm"
$ git checkout Ubuntu-3.1.0-2.3 -b pvhvm
$ cp debian.master/config/amd64/config.flavour.generic debian.master/config/amd64/config.flavour.pvhvm
$ fakeroot debian/rules clean
$ debian/rules updateconfigs
$ debian/rules editconfigs
*************************************************************
$ Do you want to edit config: amd64/config.flavour.pvhvm? [Y/n]
*************************************************************
#
# Config options for config.flavour.pv automatically generated by splitconfig.pl
#
CONFIG_DEFAULT_CFQ=y
# CONFIG_DEFAULT_DEADLINE is not set
CONFIG_DEFAULT_IOSCHED="cfq"
CONFIG_FB_SYS_COPYAREA=y
CONFIG_FB_SYS_FILLRECT=y
CONFIG_FB_SYS_FOPS=y
CONFIG_FB_SYS_IMAGEBLIT=y
CONFIG_INTEL_IDLE=y
CONFIG_NR_CPUS=256
# CONFIG_PREEMPT_NONE is not set
CONFIG_PREEMPT_VOLUNTARY=y
CONFIG_VIRTIO=m
CONFIG_VIRTIO_BLK=m
CONFIG_VIRTIO_NET=m
CONFIG_VIRTIO_PCI=m
CONFIG_VIRTIO_RING=m
CONFIG_XEN_BLKDEV_FRONTEND=m
CONFIG_XEN_FBDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=m
CONFIG_XEN_PLATFORM_PCI=y
CONFIG_XEN_XENBUS_FRONTEND=y






Make sure you have updated config.flavour.pvhvm before proceed.
****************
Backup config
****************

$ cp debian.master/config/amd64/config.flavour.pvhvm ../.
$ git reset --hard
$ git clean -df
To pick up number of previous version.
$ ls debian.master/abi
3.1.0-2.2
$ cp debian.master/abi/3.1.0-2.2/amd64/generic debian.master/abi/3.1.0-2.2/amd64/pvhvm
$ cp debian.master/abi/3.1.0-2.2/amd64/generic.modules debian.master/abi/3.1.0-2.2/amd64/pvhvm.modules

***************
Restore config
***************

cp ../config.flavour.pvhvm debian.master/config/amd64/

File: debian.master/etc/getabis

Search for the line:
getall amd64 generic server virtual
Change it in:
getall amd64 generic server virtual pvhvm

File: debian.master/rules.d/amd64.mk

Search for the line:
flavours = generic server virtual
Change it in:
flavours = generic server virtual pvhvm

File: debian.master/control.d/vars.pv
This files does not exist and in order to make the compilation process aware of our own flavor we want to compile we need to create it.

$ cp debian.master/control.d/vars.generic debian.master/control.d/vars.pvhvm
$ git add .
$ git commit -a -m "pv Modifications"
Checkout branch "work" for build
$ git checkout -b work
$ fakeroot debian/rules clean
$ skipabi=true skipmodule=true fakeroot debian/rules binary-indep
$ skipabi=true skipmodule=true fakeroot debian/rules binary-perarch
$ skipabi=true skipmodule=true fakeroot debian/rules binary-pvhvm

If all went OK, then
~/KERNEL02/source$ ls -l ../
total 54208
-rw-rw-r– 1 boris boris 606 2011-11-06 16:39 config.flavour.pvhvm
-rw-r–r– 1 boris boris 4496196 2011-11-06 16:52 linux-doc_3.1.0-2.3_all.deb
-rw-r–r– 1 boris boris 11586658 2011-11-06 16:52 linux-headers-3.1.0-2_3.1.0-2.3_all.deb
-rw-r–r– 1 boris boris 965564 2011-11-06 17:19 linux-headers-3.1.0-2-pvhvm_3.1.0-2.3_amd64.deb
-rw-r–r– 1 boris boris 37880092 2011-11-06 17:19 linux-image-3.1.0-2-pvhvm_3.1.0-2.3_amd64.deb
-rw-r–r– 1 boris boris 63952 2011-11-06 16:52 linux-source-3.1.0_3.1.0-2.3_all.deb
-rw-r–r– 1 boris boris 382278 2011-11-06 16:53 linux-tools-3.1.0-2_3.1.0-2.3_amd64.deb
-rw-r–r– 1 boris boris 112558 2011-11-06 16:52 linux-tools-common_3.1.0-2.3_all.deb
drwxr-xr-x 27 boris boris 4096 2011-11-06 16:53 source

Changes done to kernel been rebuilt .

--- xenconf.3.1.0-030100-generic 2011-11-06 11:03:39.225828270 +0400
+++ xenconf.3.1.0-2-vnc 2011-11-06 11:04:58.621827223 +0400
@@ -16,19 +16,20 @@
CONFIG_INPUT_XEN_KBDDEV_FRONTEND=m
CONFIG_HVC_XEN=y
CONFIG_XEN_WDT=m
-CONFIG_XEN_FBDEV_FRONTEND=m
+CONFIG_XEN_FBDEV_FRONTEND=y
CONFIG_XEN_BALLOON=y
-# CONFIG_XEN_SELFBALLOONING is not set
+CONFIG_XEN_SELFBALLOONING=y
+CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DEV_EVTCHN=m
CONFIG_XEN_BACKEND=y
CONFIG_XENFS=m
CONFIG_XEN_COMPAT_XENFS=y
CONFIG_XEN_SYS_HYPERVISOR=y
-CONFIG_XEN_XENBUS_FRONTEND=m
+CONFIG_XEN_XENBUS_FRONTEND=y
CONFIG_XEN_GNTDEV=m
CONFIG_XEN_GRANT_DEV_ALLOC=m
-CONFIG_XEN_PLATFORM_PCI=m
+CONFIG_XEN_PLATFORM_PCI=y
CONFIG_SWIOTLB_XEN=y
CONFIG_XEN_TMEM=y
CONFIG_XEN_PCIDEV_BACKEND=m

References
1. http://blog.avirtualhome.com/2011/10/28/how-to-compile-a-new-ubuntu-11-10-oneiric-kernel/
2. http://xen.1045712.n5.nabble.com/PATCH-xen-remove-XEN-PLATFORM-PCI-config-option-td4833154.html

3 Responses to Rebuilding 3.1 & 3.0 Linux Kernel in Ubuntu style to support PV-on-HVM

  1. […] pm and is filed underneath PVHVM Xen drivers. You can follow any responses to this entrance by a RSS 2.0 feed. You can leave a response, or trackback from your possess […]

  2. Ian Campbell says:

    Thanks for posting this, I needed a 3.1 kernel for an entirely different reason but this was still very helpful.

  3. Hmm it looks like your site ate my first comment (it was
    extremely long) so I guess I’ll just sum it up what
    I had written and say, I’m thoroughly enjoying your blog.
    I too am an aspiring blog blogger but I’m still new to the whole thing.
    Do you have any tips and hints for inexperienced blog writers?
    I’d really appreciate it.

Leave a comment