From: jbeulich@novell.com Subject: no need to build certain bits when building non-privileged kernel Patch-mainline: n/a --- head-2010-05-12.orig/arch/x86/Kconfig 2010-03-25 14:39:15.000000000 +0100 +++ head-2010-05-12/arch/x86/Kconfig 2010-05-06 16:05:14.000000000 +0200 @@ -737,6 +737,7 @@ config APB_TIMER config DMI default y bool "Enable DMI scanning" if EMBEDDED + 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 @@ -817,6 +818,7 @@ config AMD_IOMMU_STATS # 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 @@ -2021,13 +2023,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" - depends on OLPC + depends on OLPC && !XEN_UNPRIVILEGED_GUEST config PCI_GOXEN_FE bool "Xen PCI Frontend" @@ -2038,6 +2042,7 @@ config PCI_GOXEN_FE config PCI_GOANY bool "Any" + depends on !XEN_UNPRIVILEGED_GUEST endchoice @@ -2068,7 +2073,7 @@ config PCI_MMCONFIG 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 @@ -2213,7 +2218,7 @@ endif # X86_32 config K8_NB def_bool y - depends on CPU_SUP_AMD && PCI + depends on CPU_SUP_AMD && PCI && !XEN_UNPRIVILEGED_GUEST source "drivers/pcmcia/Kconfig" @@ -2264,7 +2269,9 @@ source "net/Kconfig" source "drivers/Kconfig" +if !XEN_UNPRIVILEGED_GUEST source "drivers/firmware/Kconfig" +endif source "fs/Kconfig" --- head-2010-05-12.orig/arch/x86/include/mach-xen/asm/swiotlb.h 2010-03-24 16:00:05.000000000 +0100 +++ head-2010-05-12/arch/x86/include/mach-xen/asm/swiotlb.h 2010-03-25 14:39:33.000000000 +0100 @@ -1,6 +1,10 @@ #include_next +#ifdef CONFIG_SWIOTLB #define pci_swiotlb_detect() 1 +#else +#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-2010-05-12.orig/drivers/firmware/Kconfig 2009-10-21 12:05:13.000000000 +0200 +++ head-2010-05-12/drivers/firmware/Kconfig 2010-04-28 17:21:34.000000000 +0200 @@ -115,7 +115,7 @@ config DMIID config ISCSI_IBFT_FIND bool "iSCSI Boot Firmware Table Attributes" - depends on X86 && !XEN_UNPRIVILEGED_GUEST + depends on X86 default n help This option enables the kernel to find the region of memory --- head-2010-05-12.orig/drivers/xen/Kconfig 2010-03-31 14:11:36.000000000 +0200 +++ head-2010-05-12/drivers/xen/Kconfig 2010-03-31 14:12:07.000000000 +0200 @@ -275,6 +275,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-2010-05-12.orig/drivers/xen/balloon/balloon.c 2010-02-03 11:56:18.000000000 +0100 +++ head-2010-05-12/drivers/xen/balloon/balloon.c 2010-04-15 11:44:37.000000000 +0200 @@ -663,6 +663,9 @@ void balloon_update_driver_allowance(lon bs.driver_pages += delta; balloon_unlock(flags); } +EXPORT_SYMBOL_GPL(balloon_update_driver_allowance); + +#if defined(CONFIG_XEN_BACKEND) || defined(CONFIG_XEN_BACKEND_MODULE) #ifdef CONFIG_XEN static int dealloc_pte_fn( @@ -771,6 +774,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) { @@ -791,6 +795,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) { @@ -804,10 +811,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-2010-05-12.orig/drivers/xen/core/Makefile 2010-03-25 14:39:15.000000000 +0100 +++ head-2010-05-12/drivers/xen/core/Makefile 2010-03-25 14:39:33.000000000 +0100 @@ -2,9 +2,10 @@ # Makefile for the linux kernel. # -obj-y := evtchn.o gnttab.o reboot.o machine_reboot.o firmware.o +obj-y := evtchn.o gnttab.o reboot.o machine_reboot.o -obj-$(CONFIG_PCI) += pci.o +priv-$(CONFIG_PCI) += pci.o +obj-$(CONFIG_XEN_PRIVILEGED_GUEST) += firmware.o $(priv-y) obj-$(CONFIG_PROC_FS) += xen_proc.o obj-$(CONFIG_SYS_HYPERVISOR) += hypervisor_sysfs.o obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o --- head-2010-05-12.orig/drivers/xen/core/gnttab.c 2010-04-15 11:44:26.000000000 +0200 +++ head-2010-05-12/drivers/xen/core/gnttab.c 2010-04-15 11:44:35.000000000 +0200 @@ -438,8 +438,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) @@ -509,6 +507,10 @@ static int gnttab_map(unsigned int start return 0; } +#if defined(CONFIG_XEN_BACKEND) || defined(CONFIG_XEN_BACKEND_MODULE) + +static DEFINE_SEQLOCK(gnttab_dma_lock); + static void gnttab_page_free(struct page *page, unsigned int order) { BUG_ON(order); @@ -640,6 +642,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-2010-05-12.orig/drivers/xen/privcmd/Makefile 2007-07-10 09:42:30.000000000 +0200 +++ head-2010-05-12/drivers/xen/privcmd/Makefile 2010-03-25 14:39:33.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-2010-05-12.orig/drivers/xen/privcmd/privcmd.c 2010-03-24 15:12:36.000000000 +0100 +++ head-2010-05-12/drivers/xen/privcmd/privcmd.c 2010-03-25 14:39:33.000000000 +0100 @@ -33,6 +33,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) @@ -57,12 +60,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: { @@ -87,6 +92,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)) @@ -392,6 +399,8 @@ static long privcmd_ioctl(struct file *f } break; +#endif /* CONFIG_XEN_PRIVILEGED_GUEST */ + default: ret = -EINVAL; break; @@ -427,7 +436,9 @@ static int privcmd_mmap(struct file * fi static const struct file_operations privcmd_file_ops = { .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-2010-05-12.orig/fs/compat_ioctl.c 2010-05-12 09:02:56.000000000 +0200 +++ head-2010-05-12/fs/compat_ioctl.c 2010-05-12 09:15:02.000000000 +0200 @@ -1602,7 +1602,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-2010-05-12.orig/include/xen/firmware.h 2007-07-02 08:16:19.000000000 +0200 +++ head-2010-05-12/include/xen/firmware.h 2010-03-25 14:39:33.000000000 +0100 @@ -5,6 +5,10 @@ void copy_edd(void); #endif +#ifdef CONFIG_XEN_PRIVILEGED_GUEST void copy_edid(void); +#else +static inline void copy_edid(void) {} +#endif #endif /* __XEN_FIRMWARE_H__ */ --- head-2010-05-12.orig/include/xen/gnttab.h 2009-11-06 11:10:15.000000000 +0100 +++ head-2010-05-12/include/xen/gnttab.h 2010-03-25 14:39:33.000000000 +0100 @@ -103,7 +103,11 @@ void gnttab_grant_foreign_transfer_ref(g unsigned long pfn); int gnttab_copy_grant_page(grant_ref_t ref, struct page **pagep); +#if defined(CONFIG_XEN_BACKEND) || defined(CONFIG_XEN_BACKEND_MODULE) 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) { }