Blob Blame History Raw
From: jbeulich@novell.com
Subject: no need to build certain bits when building non-privileged kernel
Patch-mainline: n/a

--- head.orig/arch/x86/Kconfig	2012-02-10 11:43:34.000000000 +0100
+++ head/arch/x86/Kconfig	2012-04-11 17:04:26.000000000 +0200
@@ -713,6 +713,7 @@ config APB_TIMER
 config DMI
 	default y
 	bool "Enable DMI scanning" if EXPERT
+	depends on !XEN_UNPRIVILEGED_GUEST
 	---help---
 	  Enabled scanning of DMI to identify machine quirks. Say Y
 	  here unless you have verified that your setup is not
@@ -767,6 +768,7 @@ config CALGARY_IOMMU_ENABLED_BY_DEFAULT
 # need this always selected by IOMMU for the VIA workaround
 config SWIOTLB
 	def_bool y if X86_64 || XEN
+	prompt "Software I/O TLB" if XEN_UNPRIVILEGED_GUEST && !XEN_PCIDEV_FRONTEND
 	---help---
 	  Support for software bounce buffers used on x86-64 systems
 	  which don't have a hardware IOMMU (e.g. the current generation
@@ -1981,13 +1983,15 @@ config PCI_GOBIOS
 
 config PCI_GOMMCONFIG
 	bool "MMConfig"
+	depends on !XEN_UNPRIVILEGED_GUEST
 
 config PCI_GODIRECT
 	bool "Direct"
+	depends on !XEN_UNPRIVILEGED_GUEST
 
 config PCI_GOOLPC
 	bool "OLPC XO-1"
-	depends on OLPC
+	depends on OLPC && !XEN_UNPRIVILEGED_GUEST
 
 config PCI_GOXEN_FE
 	bool "Xen PCI Frontend"
@@ -1998,6 +2002,7 @@ config PCI_GOXEN_FE
 
 config PCI_GOANY
 	bool "Any"
+	depends on !XEN_UNPRIVILEGED_GUEST
 
 endchoice
 
@@ -2200,7 +2205,7 @@ endif # X86_32
 
 config AMD_NB
 	def_bool y
-	depends on CPU_SUP_AMD && PCI
+	depends on CPU_SUP_AMD && PCI && !XEN_UNPRIVILEGED_GUEST
 
 source "drivers/pcmcia/Kconfig"
 
--- head.orig/arch/x86/Kconfig.debug	2012-02-08 11:50:34.000000000 +0100
+++ head/arch/x86/Kconfig.debug	2011-07-21 12:33:36.000000000 +0200
@@ -33,6 +33,7 @@ config X86_VERBOSE_BOOTUP
 
 config EARLY_PRINTK
 	bool "Early printk" if EXPERT
+	depends on !XEN_UNPRIVILEGED_GUEST
 	default y
 	---help---
 	  Write kernel log output directly into the VGA buffer or to a serial
--- head.orig/arch/x86/include/mach-xen/asm/swiotlb.h	2011-02-01 15:09:47.000000000 +0100
+++ head/arch/x86/include/mach-xen/asm/swiotlb.h	2011-02-02 15:10:34.000000000 +0100
@@ -1,4 +1,8 @@
 #include_next <asm/swiotlb.h>
 
+#ifndef CONFIG_SWIOTLB
+#define swiotlb_init(verbose) ((void)(verbose))
+#endif
+
 dma_addr_t swiotlb_map_single_phys(struct device *, phys_addr_t, size_t size,
 				   int dir);
--- head.orig/drivers/pci/Kconfig	2012-04-10 17:23:20.000000000 +0200
+++ head/drivers/pci/Kconfig	2012-04-11 17:05:21.000000000 +0200
@@ -87,7 +87,7 @@ config PARAVIRT_XEN_PCIDEV_FRONTEND
 
 config XEN_PCIDEV_FRONTEND
 	def_bool y
-	prompt "Xen PCI Frontend" if X86_64
+	prompt "Xen PCI Frontend" if X86_64 && !XEN_UNPRIVILEGED_GUEST
 	depends on PCI && XEN && (PCI_GOXEN_FE || PCI_GOANY || X86_64)
  	select HOTPLUG
 	help
--- head.orig/drivers/video/Kconfig	2012-04-10 16:44:11.000000000 +0200
+++ head/drivers/video/Kconfig	2011-11-18 16:46:17.000000000 +0100
@@ -754,7 +754,7 @@ config FB_UVESA
 
 config FB_VESA
 	bool "VESA VGA graphics support"
-	depends on (FB = y) && X86
+	depends on (FB = y) && X86 && !XEN_UNPRIVILEGED_GUEST
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
--- head.orig/drivers/xen/Kconfig	2012-02-17 14:38:14.000000000 +0100
+++ head/drivers/xen/Kconfig	2012-02-10 11:56:27.000000000 +0100
@@ -18,7 +18,8 @@ config XEN_PRIVILEGED_GUEST
 	  Support for privileged operation (domain 0)
 
 config XEN_UNPRIVILEGED_GUEST
-	def_bool !XEN_PRIVILEGED_GUEST
+	def_bool y
+	depends on !XEN_PRIVILEGED_GUEST
 	select PM
 	select SUSPEND
 
@@ -209,6 +210,7 @@ config XEN_USB_FRONTEND_HCD_PM
 
 config XEN_GRANT_DEV
 	tristate "User-space granted page access driver"
+	depends on XEN_BACKEND != n
 	default XEN_PRIVILEGED_GUEST
 	help
 	  Device for accessing (in user-space) pages that have been granted
--- head.orig/drivers/xen/balloon/balloon.c	2012-06-08 10:38:39.000000000 +0200
+++ head/drivers/xen/balloon/balloon.c	2012-06-08 11:25:24.000000000 +0200
@@ -41,6 +41,7 @@
 #include <linux/swap.h>
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
+#include <linux/kconfig.h>
 #include <linux/slab.h>
 #include <linux/mutex.h>
 #include <xen/xen_proc.h>
@@ -627,6 +628,9 @@ void balloon_update_driver_allowance(lon
 	bs.driver_pages += delta;
 	balloon_unlock(flags);
 }
+EXPORT_SYMBOL_GPL(balloon_update_driver_allowance);
+
+#if IS_ENABLED(CONFIG_XEN_BACKEND)
 
 #ifdef CONFIG_XEN
 static int dealloc_pte_fn(
@@ -735,6 +739,7 @@ struct page **alloc_empty_pages_and_page
 	pagevec = NULL;
 	goto out;
 }
+EXPORT_SYMBOL_GPL(alloc_empty_pages_and_pagevec);
 
 void free_empty_pages_and_pagevec(struct page **pagevec, int nr_pages)
 {
@@ -755,6 +760,9 @@ void free_empty_pages_and_pagevec(struct
 
 	schedule_work(&balloon_worker);
 }
+EXPORT_SYMBOL_GPL(free_empty_pages_and_pagevec);
+
+#endif /* CONFIG_XEN_BACKEND */
 
 void balloon_release_driver_page(struct page *page)
 {
@@ -768,10 +776,6 @@ void balloon_release_driver_page(struct 
 
 	schedule_work(&balloon_worker);
 }
-
-EXPORT_SYMBOL_GPL(balloon_update_driver_allowance);
-EXPORT_SYMBOL_GPL(alloc_empty_pages_and_pagevec);
-EXPORT_SYMBOL_GPL(free_empty_pages_and_pagevec);
 EXPORT_SYMBOL_GPL(balloon_release_driver_page);
 
 MODULE_LICENSE("Dual BSD/GPL");
--- head.orig/drivers/xen/console/console.c	2012-03-22 14:26:59.000000000 +0100
+++ head/drivers/xen/console/console.c	2012-03-22 14:31:13.000000000 +0100
@@ -45,7 +45,6 @@
 #include <linux/init.h>
 #include <linux/console.h>
 #include <linux/sysrq.h>
-#include <linux/screen_info.h>
 #include <linux/vt.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/event_channel.h>
@@ -236,6 +235,7 @@ static int __init xen_console_init(void)
 }
 console_initcall(xen_console_init);
 
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 /*** Useful function for console debugging -- goes straight to Xen. ***/
 int xprintk(const char *fmt, ...)
 {
@@ -253,6 +253,7 @@ int xprintk(const char *fmt, ...)
 
 	return 0;
 }
+#endif
 
 /*** Forcibly flush console data before dying. ***/
 void xencons_force_flush(void)
@@ -277,6 +278,9 @@ void xencons_force_flush(void)
 }
 
 
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
+#include <linux/screen_info.h>
+
 void __init dom0_init_screen_info(const struct dom0_vga_console_info *info, size_t size)
 {
 	/* This is drawn from a dump from vgacon:startup in
@@ -332,6 +336,7 @@ void __init dom0_init_screen_info(const 
 		break;
 	}
 }
+#endif
 
 
 /******************** User-space console driver (/dev/console) ************/
--- head.orig/drivers/xen/console/xencons_ring.c	2012-03-22 14:04:29.000000000 +0100
+++ head/drivers/xen/console/xencons_ring.c	2012-03-22 14:31:18.000000000 +0100
@@ -89,7 +89,11 @@ static irqreturn_t handle_input(int irq,
 	return IRQ_HANDLED;
 }
 
-int xencons_ring_init(void)
+int
+#ifndef CONFIG_PM_SLEEP
+__init
+#endif
+xencons_ring_init(void)
 {
 	int irq;
 
--- head.orig/drivers/xen/core/evtchn.c	2012-06-08 10:39:35.000000000 +0200
+++ head/drivers/xen/core/evtchn.c	2012-06-08 10:39:44.000000000 +0200
@@ -1828,6 +1828,7 @@ void evtchn_register_pirq(int irq)
 				      "fasteoi");
 }
 
+#ifdef CONFIG_PCI_MSI
 int evtchn_map_pirq(int irq, int xen_pirq)
 {
 	if (irq < 0) {
@@ -1902,6 +1903,7 @@ int evtchn_map_pirq(int irq, int xen_pir
 	}
 	return index_from_irq(irq) ? irq : -EINVAL;
 }
+#endif
 
 int evtchn_get_xen_pirq(int irq)
 {
--- head.orig/drivers/xen/core/gnttab.c	2012-05-23 13:47:43.000000000 +0200
+++ head/drivers/xen/core/gnttab.c	2012-06-08 11:27:09.000000000 +0200
@@ -521,8 +521,6 @@ static inline unsigned int max_nr_grant_
 
 #ifdef CONFIG_XEN
 
-static DEFINE_SEQLOCK(gnttab_dma_lock);
-
 #ifdef CONFIG_X86
 static int map_pte_fn(pte_t *pte, struct page *pmd_page,
 		      unsigned long addr, void *data)
@@ -592,6 +590,10 @@ static int gnttab_map(unsigned int start
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_XEN_BACKEND)
+
+static DEFINE_SEQLOCK(gnttab_dma_lock);
+
 static void gnttab_page_free(struct page *page, unsigned int order)
 {
 	BUG_ON(order);
@@ -723,6 +725,8 @@ void __gnttab_dma_map_page(struct page *
 	} while (unlikely(read_seqretry(&gnttab_dma_lock, seq)));
 }
 
+#endif /* CONFIG_XEN_BACKEND */
+
 #ifdef __HAVE_ARCH_PTE_SPECIAL
 
 static unsigned int GNTMAP_pte_special;
--- head.orig/drivers/xen/privcmd/Makefile	2007-07-10 09:42:30.000000000 +0200
+++ head/drivers/xen/privcmd/Makefile	2011-02-02 15:10:34.000000000 +0100
@@ -1,3 +1,3 @@
-
-obj-y	+= privcmd.o
-obj-$(CONFIG_COMPAT)	+= compat_privcmd.o
+priv-$(CONFIG_COMPAT) := compat_privcmd.o
+obj-y := privcmd.o
+obj-$(CONFIG_XEN_PRIVILEGED_GUEST) += $(priv-y)
--- head.orig/drivers/xen/privcmd/privcmd.c	2012-01-20 15:05:37.000000000 +0100
+++ head/drivers/xen/privcmd/privcmd.c	2012-01-20 15:08:03.000000000 +0100
@@ -27,6 +27,9 @@
 static struct proc_dir_entry *privcmd_intf;
 static struct proc_dir_entry *capabilities_intf;
 
+#ifndef CONFIG_XEN_PRIVILEGED_GUEST
+#define HAVE_ARCH_PRIVCMD_MMAP
+#endif
 #ifndef HAVE_ARCH_PRIVCMD_MMAP
 static int enforce_singleshot_mapping_fn(pte_t *pte, struct page *pmd_page,
 					 unsigned long addr, void *data)
@@ -51,12 +54,14 @@ static long privcmd_ioctl(struct file *f
 {
 	long ret;
 	void __user *udata = (void __user *) data;
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 	unsigned long i, addr, nr, nr_pages;
 	int paged_out;
 	struct mm_struct *mm = current->mm;
 	struct vm_area_struct *vma;
 	LIST_HEAD(pagelist);
 	struct list_head *l, *l2;
+#endif
 
 	switch (cmd) {
 	case IOCTL_PRIVCMD_HYPERCALL: {
@@ -81,6 +86,8 @@ static long privcmd_ioctl(struct file *f
 	}
 	break;
 
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
+
 	case IOCTL_PRIVCMD_MMAP: {
 #define MMAP_NR_PER_PAGE \
 	(unsigned long)((PAGE_SIZE - sizeof(*l)) / sizeof(*msg))
@@ -386,6 +393,8 @@ static long privcmd_ioctl(struct file *f
 	}
 	break;
 
+#endif /* CONFIG_XEN_PRIVILEGED_GUEST */
+
 	default:
 		ret = -EINVAL;
 		break;
@@ -424,7 +433,9 @@ static const struct file_operations priv
 	.open = nonseekable_open,
 	.llseek = no_llseek,
 	.unlocked_ioctl = privcmd_ioctl,
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 	.mmap = privcmd_mmap,
+#endif
 };
 
 static int capabilities_read(char *page, char **start, off_t off,
--- head.orig/drivers/xen/xenbus/xenbus_comms.c	2011-04-11 15:03:17.000000000 +0200
+++ head/drivers/xen/xenbus/xenbus_comms.c	2011-04-01 10:23:25.000000000 +0200
@@ -52,12 +52,12 @@
 
 static int xenbus_irq;
 
-static DECLARE_WORK(probe_work, xenbus_probe);
-
 static DECLARE_WAIT_QUEUE_HEAD(xb_waitq);
 
 static irqreturn_t wake_waiting(int irq, void *unused)
 {
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
+	static DECLARE_WORK(probe_work, xenbus_probe);
 	int old, new;
 
 	old = atomic_read(&xenbus_xsd_state);
@@ -85,6 +85,7 @@ static irqreturn_t wake_waiting(int irq,
 		schedule_work(&probe_work);
 
 wake:
+#endif
 	wake_up(&xb_waitq);
 	return IRQ_HANDLED;
 }
--- head.orig/drivers/xen/xenbus/xenbus_probe.c	2012-03-12 13:55:51.000000000 +0100
+++ head/drivers/xen/xenbus/xenbus_probe.c	2012-03-22 14:31:27.000000000 +0100
@@ -93,7 +93,11 @@ static unsigned long xen_store_mfn;
 
 extern struct mutex xenwatch_mutex;
 
-static BLOCKING_NOTIFIER_HEAD(xenstore_chain);
+static
+#ifdef CONFIG_XEN_UNPRIVILEGED_GUEST
+__initdata
+#endif
+BLOCKING_NOTIFIER_HEAD(xenstore_chain);
 
 #if defined(CONFIG_XEN) || defined(MODULE)
 static void wait_for_devices(struct xenbus_driver *xendrv);
@@ -1066,7 +1070,13 @@ static void xenbus_reset_state(void)
 }
 #endif
 
-void xenbus_probe(struct work_struct *unused)
+void
+#if defined(CONFIG_XEN_UNPRIVILEGED_GUEST)
+__init
+#elif defined(MODULE)
+__devinit
+#endif
+xenbus_probe(struct work_struct *unused)
 {
 	BUG_ON(!is_xenstored_ready());
 
--- head.orig/drivers/xen/xenbus/xenbus_probe_backend.c	2011-11-17 15:56:06.000000000 +0100
+++ head/drivers/xen/xenbus/xenbus_probe_backend.c	2012-03-13 14:38:50.000000000 +0100
@@ -322,7 +322,7 @@ subsys_initcall(xenbus_probe_backend_ini
 
 #else
 
-void xenbus_backend_bus_register(void)
+void __init xenbus_backend_bus_register(void)
 {
 	xenbus_backend.error = bus_register(&xenbus_backend.bus);
 	if (xenbus_backend.error)
@@ -330,7 +330,7 @@ void xenbus_backend_bus_register(void)
 			   xenbus_backend.error);
 }
 
-void xenbus_backend_device_register(void)
+void __init xenbus_backend_device_register(void)
 {
 	if (xenbus_backend.error)
 		return;
--- head.orig/drivers/xen/xenbus/xenbus_xs.c	2012-03-12 16:18:49.000000000 +0100
+++ head/drivers/xen/xenbus/xenbus_xs.c	2012-03-22 14:31:25.000000000 +0100
@@ -949,7 +949,13 @@ static int xenbus_thread(void *unused)
 	return 0;
 }
 
-int xs_init(void)
+int
+#ifndef MODULE
+__init
+#else
+__devinit
+#endif
+xs_init(void)
 {
 	struct task_struct *task;
 
--- head.orig/fs/compat_ioctl.c	2012-04-10 17:02:34.000000000 +0200
+++ head/fs/compat_ioctl.c	2012-04-11 17:05:27.000000000 +0200
@@ -1487,7 +1487,7 @@ static long do_ioctl_trans(int fd, unsig
 		return do_video_stillpicture(fd, cmd, argp);
 	case VIDEO_SET_SPU_PALETTE:
 		return do_video_set_spu_palette(fd, cmd, argp);
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 	case IOCTL_PRIVCMD_MMAP_32:
 	case IOCTL_PRIVCMD_MMAPBATCH_32:
 	case IOCTL_PRIVCMD_MMAPBATCH_V2_32:
--- head.orig/include/xen/gnttab.h	2012-03-12 14:00:59.000000000 +0100
+++ head/include/xen/gnttab.h	2012-06-08 11:26:50.000000000 +0200
@@ -40,6 +40,7 @@
 #include <asm/hypervisor.h>
 #include <asm/maddr.h> /* maddr_t */
 #include <linux/mm.h>
+#include <linux/kconfig.h>
 #include <linux/delay.h>
 #include <xen/interface/grant_table.h>
 #include <xen/features.h>
@@ -106,7 +107,11 @@ void gnttab_grant_foreign_transfer_ref(g
 				       unsigned long pfn);
 
 int gnttab_copy_grant_page(grant_ref_t ref, struct page **pagep);
+#if IS_ENABLED(CONFIG_XEN_BACKEND)
 void __gnttab_dma_map_page(struct page *page);
+#else
+#define __gnttab_dma_map_page __gnttab_dma_unmap_page
+#endif
 static inline void __gnttab_dma_unmap_page(struct page *page)
 {
 }