diff --git a/kernel.spec b/kernel.spec index fe6fd45..f0fde96 100644 --- a/kernel.spec +++ b/kernel.spec @@ -48,8 +48,9 @@ Group: System/Kernel Url: http://www.kernel.org/ AutoReqProv: on BuildRequires: coreutils module-init-tools sparse -BuildRequires: qubes-core-libs-devel +BuildRequires: qubes-kernel-vm-support BuildRequires: dracut +BuildRequires: busybox Provides: multiversion(kernel) Provides: %name = %kernelrelease @@ -84,8 +85,6 @@ Source100: config-%{build_flavor} Source204: patches.rpmify Source205: patches.xen Source300: patches.qubes -Source301: u2mfn -Source302: vm-initramfs BuildRoot: %{_tmppath}/%{name}-%{version}-build ExclusiveArch: x86_64 @@ -104,11 +103,6 @@ SYMBOLS="xen-dom0 %{build_flavor}" # Unpack all sources and patches %setup -q -c -T -a 0 -if [ %{_sourcedir} != %{_builddir} ]; then - cp -r %{SOURCE301} %{_builddir}/ - cp -r %{SOURCE302} %{_builddir}/ -fi - mkdir -p %kernel_build_dir cd linux-%version @@ -158,6 +152,9 @@ make clean $MAKE_ARGS rm -f source find . ! -type d -printf '%%P\n' > %my_builddir/obj-files +u2mfn_ver=`dkms status u2mfn|tail -n 1|cut -f 2 -d ' '|tr -d ':,:'` +rm -rf %_builddir/u2mfn +cp -r /usr/src/u2mfn-$u2mfn_ver %_builddir/u2mfn %build @@ -176,7 +173,7 @@ export AFTER_LINK=\ make %{?_smp_mflags} all $MAKE_ARGS CONFIG_DEBUG_SECTION_MISMATCH=y # Build u2mfn module -make -C %kernel_build_dir SUBDIRS=%_builddir/u2mfn modules +make -C %kernel_build_dir M=%_builddir/u2mfn modules %install @@ -215,7 +212,7 @@ dd if=/dev/zero of=%buildroot/boot/initramfs-%kernelrelease.img \ gzip -c9 < Module.symvers > %buildroot/boot/symvers-%kernelrelease.gz make modules_install $MAKE_ARGS INSTALL_MOD_PATH=%buildroot -make -C %kernel_build_dir SUBDIRS=%_builddir/u2mfn modules_install $MAKE_ARGS INSTALL_MOD_PATH=%buildroot +make modules_install $MAKE_ARGS INSTALL_MOD_PATH=%buildroot M=%_builddir/u2mfn mkdir -p %buildroot/%src_install_dir @@ -342,8 +339,8 @@ fi mkdir -p %buildroot/%vm_install_dir /sbin/dracut --nomdadmconf --nolvmconf \ --kmoddir %buildroot/lib/modules/%kernelrelease \ - --include %_sourcedir/vm-initramfs / \ - --add "dm" --omit "plymouth" \ + --modules "kernel-modules qubes-vm-simple" \ + --conf /dev/null --confdir /var/empty \ -d "xenblk xen-blkfront cdrom ext4 jbd2 crc16 dm_snapshot" \ %buildroot/%vm_install_dir/initramfs %kernelrelease diff --git a/u2mfn/.gitignore b/u2mfn/.gitignore deleted file mode 100644 index 3a7427f..0000000 --- a/u2mfn/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -.tmp_versions/ -*.ko.cmd -*.o.cmd -*.o -Makefile.xen -Module.symvers -modules.order -u2mfn.ko -u2mfn.mod.c diff --git a/u2mfn/Makefile b/u2mfn/Makefile deleted file mode 100644 index 59e222d..0000000 --- a/u2mfn/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# -# The Qubes OS Project, http://www.qubes-os.org -# -# Copyright (C) 2010 Rafal Wojtczuk -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# - -obj-m += u2mfn.o - -clean: - rm -f *.o *.ko *~ - rm -f .u2mfn.* *.mod.c Module.symvers modules.order - rm -fr .tmp_versions - rm -f Makefile.xen diff --git a/u2mfn/buildme.sh b/u2mfn/buildme.sh deleted file mode 100755 index cc332e9..0000000 --- a/u2mfn/buildme.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# -# The Qubes OS Project, http://www.qubes-os.org -# -# Copyright (C) 2010 Rafal Wojtczuk -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# - - -make -C /lib/modules/`uname -r`/build/ SUBDIRS=`pwd` modules \ - EXTRA_CFLAGS=-I`pwd`/../xenincl \ No newline at end of file diff --git a/u2mfn/cleanup.sh b/u2mfn/cleanup.sh deleted file mode 100755 index ea9352d..0000000 --- a/u2mfn/cleanup.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -make -C /lib/modules/`uname -r`/build/ SUBDIRS=`pwd` clean diff --git a/u2mfn/u2mfn.c b/u2mfn/u2mfn.c deleted file mode 100644 index 1303ed0..0000000 --- a/u2mfn/u2mfn.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * The Qubes OS Project, http://www.qubes-os.org - * - * Copyright (C) 2010 Rafal Wojtczuk - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include -#include -#include -#include -#include -#include -#ifndef FOREIGN_FRAME_BIT -#include -#endif -#include -#include "/usr/include/u2mfn-kernel.h" - - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) -static inline unsigned long virt_to_phys(volatile void *address) -{ - return __pa((unsigned long) address); -} -#endif - -#ifdef virt_to_mfn -#define VIRT_TO_MFN virt_to_mfn -#else -extern unsigned long *phys_to_machine_mapping; -static inline unsigned long VIRT_TO_MFN(void *addr) -{ - unsigned int pfn = virt_to_phys(addr) >> PAGE_SHIFT; - return phys_to_machine_mapping[pfn] & ~FOREIGN_FRAME_BIT; -} -#endif - -/// User virtual address to mfn translator -/** - \param cmd ignored - \param data the user-specified address - \return mfn corresponding to "data" argument, or -1 on error -*/ -static long u2mfn_ioctl(struct file *f, unsigned int cmd, - unsigned long data) -{ - struct page *user_page; - void *kaddr; - int ret; - - if (_IOC_TYPE(cmd) != U2MFN_MAGIC) { - printk("Qubes u2mfn: wrong IOCTL magic"); - return -ENOTTY; - } - - switch (cmd) { - case U2MFN_GET_MFN_FOR_PAGE: - down_read(¤t->mm->mmap_sem); - ret = get_user_pages - (current, current->mm, data, 1, 1, 0, &user_page, 0); - up_read(¤t->mm->mmap_sem); - if (ret != 1) { - printk("U2MFN_GET_MFN_FOR_PAGE: get_user_pages failed, ret=0x%x\n", ret); - return -1; - } - kaddr = kmap(user_page); - ret = VIRT_TO_MFN(kaddr); - kunmap(user_page); - put_page(user_page); - break; - - case U2MFN_GET_LAST_MFN: - if (f->private_data) - ret = VIRT_TO_MFN(f->private_data); - else - ret = 0; - break; - - default: - printk("Qubes u2mfn: wrong ioctl passed!\n"); - return -ENOTTY; - } - - - return ret; -} - -static int u2mfn_mmap(struct file *f, struct vm_area_struct *vma) -{ - int ret; - char *kbuf; - long length = vma->vm_end - vma->vm_start; - printk("u2mfn_mmap: entering, private=%p\n", f->private_data); - if (f->private_data) - return -EBUSY; - if (length != PAGE_SIZE) - return -EINVAL; - kbuf = (char *) __get_free_page(GFP_KERNEL); - if (!kbuf) - return -ENOMEM; - - f->private_data = kbuf; - - ret = remap_pfn_range(vma, vma->vm_start, - virt_to_phys(kbuf) >> PAGE_SHIFT, - length, vma->vm_page_prot); - - printk("u2mfn_mmap: calling remap return %d\n", ret); - if (ret) - return ret; - - - return 0; -} - -static int u2mfn_release(struct inode *i, struct file *f) -{ - printk("u2mfn_release, priv=%p\n", f->private_data); - if (f->private_data) - __free_page(f->private_data); - f->private_data = NULL; - return 0; -} - -static struct file_operations u2mfn_fops = { - .unlocked_ioctl = u2mfn_ioctl, - .mmap = u2mfn_mmap, - .release = u2mfn_release -}; - -/// u2mfn module registration -/** - tries to register "/proc/u2mfn" pseudofile -*/ -static int u2mfn_init(void) -{ - struct proc_dir_entry *u2mfn_node = - proc_create_data("u2mfn", 0666, NULL, - &u2mfn_fops, 0); - if (!u2mfn_node) - return -1; - return 0; -} - -static void u2mfn_exit(void) -{ - remove_proc_entry("u2mfn", 0); -} - -module_init(u2mfn_init); -module_exit(u2mfn_exit); -MODULE_LICENSE("GPL"); diff --git a/vm-initramfs/lib/dracut/hooks/pre-pivot/50_mount_modules.sh b/vm-initramfs/lib/dracut/hooks/pre-pivot/50_mount_modules.sh deleted file mode 100755 index 3e0262a..0000000 --- a/vm-initramfs/lib/dracut/hooks/pre-pivot/50_mount_modules.sh +++ /dev/null @@ -1,10 +0,0 @@ -# -# This file should be places in pre-pivot directory in dracut's initramfs -# - -#!/bin/sh - -echo "Waiting for /dev/xvdd device..." -while ! [ -e /dev/xvdd ]; do sleep 0.1; done - -mount -n -t ext3 /dev/xvdd $NEWROOT/lib/modules diff --git a/vm-initramfs/lib/dracut/hooks/pre-udev/90_qubes_cow_setup.sh b/vm-initramfs/lib/dracut/hooks/pre-udev/90_qubes_cow_setup.sh deleted file mode 100755 index 19bb9d3..0000000 --- a/vm-initramfs/lib/dracut/hooks/pre-udev/90_qubes_cow_setup.sh +++ /dev/null @@ -1,31 +0,0 @@ -# -# This file should be places in pre-mount directory in dracut's initramfs -# - -#!/bin/sh -echo "Qubes initramfs script here:" - -if [ -e /dev/mapper/dmroot ] ; then - die "Qubes: FATAL error: /dev/mapper/dmroot already exists?!" -fi - -modprobe xenblk || modprobe xen-blkfront || echo "Qubes: Cannot load Xen Block Frontend..." - -echo "Waiting for /dev/xvda* devices..." -while ! [ -e /dev/xvda ]; do sleep 0.1; done - -if [ `cat /sys/block/xvda/ro` = 1 ] ; then - echo "Qubes: Doing COW setup for AppVM..." - - while ! [ -e /dev/xvdc ]; do sleep 0.1; done - while ! [ -e /dev/xvdc2 ]; do sleep 0.1; done - - echo "0 `cat /sys/block/xvda/size` snapshot /dev/xvda /dev/xvdc2 N 16" | \ - dmsetup create dmroot || { echo "Qubes: FATAL: cannot create dmroot!"; } - echo Qubes: done. -else - echo "Qubes: Doing R/W setup for TemplateVM..." - echo "0 `cat /sys/block/xvda/size` linear /dev/xvda 0" | \ - dmsetup create dmroot || { echo "Qubes: FATAL: cannot create dmroot!"; exit 1; } - echo Qubes: done. -fi diff --git a/vm-initramfs/pre-pivot/50_mount_modules.sh b/vm-initramfs/pre-pivot/50_mount_modules.sh deleted file mode 120000 index 968f123..0000000 --- a/vm-initramfs/pre-pivot/50_mount_modules.sh +++ /dev/null @@ -1 +0,0 @@ -../lib/dracut/hooks/pre-pivot/50_mount_modules.sh \ No newline at end of file diff --git a/vm-initramfs/pre-udev/90_qubes_cow_setup.sh b/vm-initramfs/pre-udev/90_qubes_cow_setup.sh deleted file mode 120000 index 7c3643c..0000000 --- a/vm-initramfs/pre-udev/90_qubes_cow_setup.sh +++ /dev/null @@ -1 +0,0 @@ -../lib/dracut/hooks/pre-udev/90_qubes_cow_setup.sh \ No newline at end of file