From c046807641b8c06eaa537022044a871f1929cd80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 7 Apr 2019 23:02:45 +0200 Subject: [PATCH] Remove u2mfn module Since converting GUI agent to use grant tables, it isn't needed anymore. This also allows to not install dkms anymore. Fixes QubesOS/qubes-issues#4280 --- Makefile | 3 - archlinux/PKGBUILD | 4 +- archlinux/PKGBUILD-initcpio-install.sh | 1 - debian/control | 6 +- debian/qubes-kernel-vm-support.dkms | 1 - debian/qubes-kernel-vm-support.install | 1 - debian/rules | 2 +- kernel-modules/Makefile | 10 +- kernel-modules/qubes-prepare-vm-kernel | 10 -- kernel-modules/u2mfn/Makefile | 28 ---- kernel-modules/u2mfn/dkms.conf.in | 12 -- kernel-modules/u2mfn/u2mfn.c | 173 ----------------------- rpm_spec/qubes-kernel-vm-support.spec.in | 12 +- 13 files changed, 5 insertions(+), 258 deletions(-) delete mode 100644 debian/qubes-kernel-vm-support.dkms delete mode 100644 kernel-modules/u2mfn/Makefile delete mode 100644 kernel-modules/u2mfn/dkms.conf.in delete mode 100644 kernel-modules/u2mfn/u2mfn.c diff --git a/Makefile b/Makefile index 269ca2b..f4159eb 100644 --- a/Makefile +++ b/Makefile @@ -37,9 +37,6 @@ install-debian-kernel-support: $(MAKE) -C dracut install $(MAKE) -C kernel-modules install $(MAKE) -C grub install-debian - # expand module version - rm -f debian/qubes-kernel-vm-support.dkms - echo debian/tmp/usr/src/u2mfn-*/dkms.conf > debian/qubes-kernel-vm-support.dkms clean: $(MAKE) -C qrexec-lib clean diff --git a/archlinux/PKGBUILD b/archlinux/PKGBUILD index 437daf8..ac3e097 100644 --- a/archlinux/PKGBUILD +++ b/archlinux/PKGBUILD @@ -57,7 +57,7 @@ make -C imgconverter install DESTDIR=$pkgdir LIBDIR=/usr/lib SYSLIBDIR=/usr/lib } package_qubes-vm-kernel-support() { -depends=(mkinitcpio dkms grub) +depends=(mkinitcpio grub) install=PKGBUILD-qubes-vm-kernel-support.install mkdir -p ${pkgdir}/usr/lib/initcpio/install/ @@ -68,8 +68,6 @@ mkdir -p ${pkgdir}/usr/bin/ install -m 611 ${srcdir}/PKGBUILD-initcpio-install.sh ${pkgdir}/usr/lib/initcpio/install/qubes install -m 611 ${srcdir}/PKGBUILD-initcpio-hook.sh ${pkgdir}/usr/lib/initcpio/hooks/qubes install -m 755 ${srcdir}/dracut/full-dmroot/qubes_cow_setup.sh ${pkgdir}/usr/lib/qubes/qubes_cow_setup.sh -make install-u2mfn DESTDIR=$pkgdir -C kernel-modules - } diff --git a/archlinux/PKGBUILD-initcpio-install.sh b/archlinux/PKGBUILD-initcpio-install.sh index aadab73..598052a 100644 --- a/archlinux/PKGBUILD-initcpio-install.sh +++ b/archlinux/PKGBUILD-initcpio-install.sh @@ -3,7 +3,6 @@ build() { add_module "xen-blkfront" - add_module "u2mfn" add_binary "/usr/bin/sfdisk" add_binary "/usr/bin/mkswap" add_binary "/usr/bin/dmsetup" diff --git a/debian/control b/debian/control index f2f7823..0d309cc 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,6 @@ Build-Depends: pkg-config, debhelper (>= 9.0.0), dh-systemd, - dkms, python-setuptools, Standards-Version: 3.9.3 Homepage: http://www.qubes-os.org @@ -26,15 +25,12 @@ Description: Qubes Linux utilities Package: qubes-kernel-vm-support Architecture: any Recommends: initramfs-tools -Depends: dkms, ${misc:Depends} +Depends: ${misc:Depends} Description: Qubes VM kernel and initramfs modules This package contains: 1. mkinitramfs module required to setup Qubes VM root filesystem. This package is needed in VM only when the VM uses its own kernel (via pvgrub or so). Otherwise initrd is provided by dom0. - . - 2. u2mfn kernel module sources (dkms) required by GUI agent and R2 version of - libvchan library. Package: libqubes-rpc-filecopy2 Architecture: any diff --git a/debian/qubes-kernel-vm-support.dkms b/debian/qubes-kernel-vm-support.dkms deleted file mode 100644 index 6880d97..0000000 --- a/debian/qubes-kernel-vm-support.dkms +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/src/u2mfn-3.1.2/dkms.conf diff --git a/debian/qubes-kernel-vm-support.install b/debian/qubes-kernel-vm-support.install index 2e52219..f64243f 100644 --- a/debian/qubes-kernel-vm-support.install +++ b/debian/qubes-kernel-vm-support.install @@ -5,5 +5,4 @@ usr/lib/dracut/modules.d/90qubes-vm/* usr/lib/dracut/modules.d/90qubes-vm-modules/* usr/lib/dracut/modules.d/90qubes-vm-simple/* usr/lib/dracut/modules.d/80xen-scrub-pages/* -usr/src/u2mfn-*/* etc/default/grub.d/30-qubes-kernel-vm-support.cfg diff --git a/debian/rules b/debian/rules index bbf30c9..79ed191 100755 --- a/debian/rules +++ b/debian/rules @@ -7,7 +7,7 @@ export DESTDIR=$(shell pwd)/debian/tmp #export DH_VERBOSE=1 %: - dh $@ --with=systemd,dkms + dh $@ --with=systemd override_dh_auto_build: make all LIBDIR=/usr/lib DEBIANBUILD=1 diff --git a/kernel-modules/Makefile b/kernel-modules/Makefile index 6f2bbc8..98edeb9 100644 --- a/kernel-modules/Makefile +++ b/kernel-modules/Makefile @@ -1,13 +1,5 @@ -ver := $(shell cat ../version) -srcdir := /usr/src/u2mfn-$(ver) - -install: install-u2mfn install-scripts +install: install-scripts install-scripts: install -d $(DESTDIR)/usr/sbin install qubes-prepare-vm-kernel $(DESTDIR)/usr/sbin - -install-u2mfn: - install -d $(DESTDIR)$(srcdir) - install -m 644 u2mfn/u2mfn.c u2mfn/Makefile $(DESTDIR)$(srcdir) - sed -e 's#@@VERSION@@#$(ver)#' u2mfn/dkms.conf.in > $(DESTDIR)$(srcdir)/dkms.conf diff --git a/kernel-modules/qubes-prepare-vm-kernel b/kernel-modules/qubes-prepare-vm-kernel index 2f11e49..d7064ad 100644 --- a/kernel-modules/qubes-prepare-vm-kernel +++ b/kernel-modules/qubes-prepare-vm-kernel @@ -25,14 +25,6 @@ set -e basedir=/var/lib/qubes/vm-kernels -function recompile_u2mfn() { - kver=$1 - u2mfn_ver=`dkms status u2mfn|tail -n 1|cut -f 2 -d ' '|tr -d ':,'` - if ! modinfo -k "$kver" -n u2mfn >/dev/null; then - dkms install u2mfn/$u2mfn_ver -k $kver --no-initrd - fi -} - function build_modules_img() { kver=$1 initramfs=$2 @@ -81,8 +73,6 @@ fi echo "--> Building files for $kernel_version in $output_dir" -echo "---> Recompiling kernel module (u2mfn)" -recompile_u2mfn "$kernel_version" mkdir -p "$output_dir" cp "/boot/vmlinuz-$kernel_version" "$output_dir/vmlinuz" echo "---> Generating initramfs" diff --git a/kernel-modules/u2mfn/Makefile b/kernel-modules/u2mfn/Makefile deleted file mode 100644 index 59e222d..0000000 --- a/kernel-modules/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/kernel-modules/u2mfn/dkms.conf.in b/kernel-modules/u2mfn/dkms.conf.in deleted file mode 100644 index 0a32c8e..0000000 --- a/kernel-modules/u2mfn/dkms.conf.in +++ /dev/null @@ -1,12 +0,0 @@ -PACKAGE_VERSION="@@VERSION@@" - -# Items below here should not have to change with each driver version -PACKAGE_NAME="u2mfn" - -BUILT_MODULE_NAME[0]="u2mfn" -DEST_MODULE_LOCATION[0]="/extra/" -AUTOINSTALL=yes -# BUILD_EXCLUSIVE_KERNEL doesn't support negation :( -if echo "$kernelver"|grep -q qubes; then - BUILD_EXCLUSIVE_KERNEL=not-on-qubes-kernel -fi diff --git a/kernel-modules/u2mfn/u2mfn.c b/kernel-modules/u2mfn/u2mfn.c deleted file mode 100644 index 1209dc5..0000000 --- a/kernel-modules/u2mfn/u2mfn.c +++ /dev/null @@ -1,173 +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 - -/* copy of /usr/include/u2mfn-kernel.h, to reduce requirements */ -#include -#define U2MFN_MAGIC 0xf5 -#define U2MFN_GET_MFN_FOR_PAGE _IOW(U2MFN_MAGIC, 1, int) -#define U2MFN_GET_LAST_MFN _IO(U2MFN_MAGIC, 2) - - -#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) -{ - return phys_to_machine_mapping[virt_to_phys(addr) >> PAGE_SHIFT] & ~FOREIGN_FRAME_BIT; -} -#endif - -static int u2mfn_get_mfn(pte_t *pte, pgtable_t token, unsigned long addr, void *data) { - *((unsigned long *) data) = pfn_to_mfn(pte_pfn(*pte)); - return 0; -} - -/// 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) -{ - long ret; - unsigned long mfn; - - if (_IOC_TYPE(cmd) != U2MFN_MAGIC) { - printk("Qubes u2mfn: wrong IOCTL magic"); - return -ENOTTY; - } - - switch (cmd) { - case U2MFN_GET_MFN_FOR_PAGE: - ret = apply_to_page_range(current->mm, data, PAGE_SIZE, u2mfn_get_mfn, &mfn); - - if (ret < 0 || mfn == INVALID_P2M_ENTRY) { - printk("U2MFN_GET_MFN_FOR_PAGE: failed to get mfn, " - "addr=0x%lx ret=0x%lx\n", data, ret); - return -1; - } - - ret = mfn; - 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"); -MODULE_VERSION("5.0.0"); diff --git a/rpm_spec/qubes-kernel-vm-support.spec.in b/rpm_spec/qubes-kernel-vm-support.spec.in index 965a02a..522582c 100644 --- a/rpm_spec/qubes-kernel-vm-support.spec.in +++ b/rpm_spec/qubes-kernel-vm-support.spec.in @@ -22,7 +22,7 @@ Name: qubes-kernel-vm-support Version: @VERSION@ Release: 1%{?dist} -Summary: Qubes VM kernel and initramfs modules +Summary: Qubes VM initramfs modules Source0: qubes-utils-%{version}.tar.gz Group: Qubes @@ -31,7 +31,6 @@ License: GPL v2 only URL: http://www.qubes-os.org Requires: dracut -Requires: dkms %description This package contains: @@ -39,9 +38,6 @@ This package contains: needed in VM only when the VM uses its own kernel (via pvgrub or so). Otherwise initrd is provided by dom0. -2. u2mfn kernel module sources (dkms) required by GUI agent and R2 version of -libvchan library. - %prep %setup -q -n qubes-utils-%{version} @@ -53,7 +49,6 @@ make install-fedora-kernel-support DESTDIR=%{buildroot} /usr/lib/dracut/modules.d/90qubes-vm-modules /usr/lib/dracut/modules.d/90qubes-vm-simple /usr/lib/dracut/modules.d/80xen-scrub-pages -/usr/src/u2mfn-%{version}/ /usr/sbin/qubes-prepare-vm-kernel %config(noreplace) /etc/default/grub.qubes-kernel-vm-support @@ -64,12 +59,7 @@ if ! grep -q '/etc/default/grub.qubes-kernel-vm-support$' /etc/default/grub 2>/d echo '. /etc/default/grub.qubes-kernel-vm-support' >> /etc/default/grub fi -%post -dkms add -m u2mfn -v %{version} --rpm_safe_upgrade - %preun -dkms remove -m u2mfn -v %{version} --all --rpm_safe_upgrade - if [ $1 -eq 0 ]; then if grep -q '/etc/default/grub.qubes-kernel-vm-support$' /etc/default/grub 2>/dev/null; then sed -i -e '/grub.qubes-kernel-vm-support$/d' /etc/default/grub