From 81e863c3a28e69fd60411bde9f779b0f8ad0212a Mon Sep 17 00:00:00 2001 From: Julien Grall Date: Wed, 6 May 2015 14:09:06 +0000 Subject: arm/xen: Correctly check if the event channel interrupt is present The function irq_of_parse_and_map returns 0 when the IRQ is not found. Futhermore, move the check before notifying the user that we are running on Xen. Signed-off-by: Julien Grall Signed-off-by: Stefano Stabellini Acked-by: Ian Campbell --- arch/arm/xen/enlighten.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'arch') diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 7d0f07020c80..6fbdc8fa4a19 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -51,7 +51,7 @@ EXPORT_SYMBOL_GPL(xen_have_vector_callback); int xen_platform_pci_unplug = XEN_UNPLUG_ALL; EXPORT_SYMBOL_GPL(xen_platform_pci_unplug); -static __read_mostly int xen_events_irq = -1; +static __read_mostly unsigned int xen_events_irq; int xen_remap_domain_mfn_array(struct vm_area_struct *vma, unsigned long addr, @@ -179,12 +179,14 @@ static int __init xen_guest_init(void) return 0; grant_frames = res.start; xen_events_irq = irq_of_parse_and_map(node, 0); + if (!xen_events_irq) { + pr_debug("Xen event channel interrupt not found\n"); + return -ENODEV; + } + pr_info("Xen %s support found, events_irq=%d gnttab_frame=%pa\n", version, xen_events_irq, &grant_frames); - if (xen_events_irq < 0) - return -ENODEV; - xen_domain_type = XEN_HVM_DOMAIN; xen_setup_features(); -- cgit v1.2.3 From 5882bfef6327093bff63569be19795170ff71e5f Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Wed, 6 May 2015 14:13:31 +0000 Subject: arm,arm64/xen: move Xen initialization earlier Currently, Xen is initialized/discovered in an initcall. This doesn't allow us to support earlyprintk or choosing the preferred console when running on Xen. The current function xen_guest_init is now split in 2 parts: - xen_early_init: Check if there is a Xen node in the device tree and setup domain type - xen_guest_init: Retrieve the information from the device node and initialize Xen (grant table, shared page...) The former is called in setup_arch, while the latter is an initcall. Signed-off-by: Stefano Stabellini Signed-off-by: Julien Grall Acked-by: Ian Campbell Acked-by: Will Deacon --- arch/arm/include/asm/xen/hypervisor.h | 8 +++++ arch/arm/kernel/setup.c | 2 ++ arch/arm/xen/enlighten.c | 58 ++++++++++++++++++++--------------- arch/arm64/kernel/setup.c | 2 ++ 4 files changed, 46 insertions(+), 24 deletions(-) (limited to 'arch') diff --git a/arch/arm/include/asm/xen/hypervisor.h b/arch/arm/include/asm/xen/hypervisor.h index 1317ee40f4df..04ff8e7b37df 100644 --- a/arch/arm/include/asm/xen/hypervisor.h +++ b/arch/arm/include/asm/xen/hypervisor.h @@ -1,6 +1,8 @@ #ifndef _ASM_ARM_XEN_HYPERVISOR_H #define _ASM_ARM_XEN_HYPERVISOR_H +#include + extern struct shared_info *HYPERVISOR_shared_info; extern struct start_info *xen_start_info; @@ -18,4 +20,10 @@ static inline enum paravirt_lazy_mode paravirt_get_lazy_mode(void) extern struct dma_map_ops *xen_dma_ops; +#ifdef CONFIG_XEN +void __init xen_early_init(void); +#else +static inline void xen_early_init(void) { return; } +#endif + #endif /* _ASM_ARM_XEN_HYPERVISOR_H */ diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 6c777e908a24..aa9bfebe113f 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -951,6 +952,7 @@ void __init setup_arch(char **cmdline_p) arm_dt_init_cpu_maps(); psci_init(); + xen_early_init(); #ifdef CONFIG_SMP if (is_smp()) { if (!mdesc->smp_init || !mdesc->smp_init()) { diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 6fbdc8fa4a19..3463a9e1ff65 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -53,6 +53,8 @@ EXPORT_SYMBOL_GPL(xen_platform_pci_unplug); static __read_mostly unsigned int xen_events_irq; +static __initdata struct device_node *xen_node; + int xen_remap_domain_mfn_array(struct vm_area_struct *vma, unsigned long addr, xen_pfn_t *mfn, int nr, @@ -150,42 +152,28 @@ static irqreturn_t xen_arm_callback(int irq, void *arg) * documentation of the Xen Device Tree format. */ #define GRANT_TABLE_PHYSADDR 0 -static int __init xen_guest_init(void) +void __init xen_early_init(void) { - struct xen_add_to_physmap xatp; - static struct shared_info *shared_info_page = 0; - struct device_node *node; int len; const char *s = NULL; const char *version = NULL; const char *xen_prefix = "xen,xen-"; - struct resource res; - phys_addr_t grant_frames; - node = of_find_compatible_node(NULL, NULL, "xen,xen"); - if (!node) { + xen_node = of_find_compatible_node(NULL, NULL, "xen,xen"); + if (!xen_node) { pr_debug("No Xen support\n"); - return 0; + return; } - s = of_get_property(node, "compatible", &len); + s = of_get_property(xen_node, "compatible", &len); if (strlen(xen_prefix) + 3 < len && !strncmp(xen_prefix, s, strlen(xen_prefix))) version = s + strlen(xen_prefix); if (version == NULL) { pr_debug("Xen version not found\n"); - return 0; - } - if (of_address_to_resource(node, GRANT_TABLE_PHYSADDR, &res)) - return 0; - grant_frames = res.start; - xen_events_irq = irq_of_parse_and_map(node, 0); - if (!xen_events_irq) { - pr_debug("Xen event channel interrupt not found\n"); - return -ENODEV; + return; } - pr_info("Xen %s support found, events_irq=%d gnttab_frame=%pa\n", - version, xen_events_irq, &grant_frames); + pr_info("Xen %s support found\n", version); xen_domain_type = XEN_HVM_DOMAIN; @@ -195,10 +183,32 @@ static int __init xen_guest_init(void) xen_start_info->flags |= SIF_INITDOMAIN|SIF_PRIVILEGED; else xen_start_info->flags &= ~(SIF_INITDOMAIN|SIF_PRIVILEGED); +} + +static int __init xen_guest_init(void) +{ + struct xen_add_to_physmap xatp; + struct shared_info *shared_info_page = NULL; + struct resource res; + phys_addr_t grant_frames; + + if (!xen_domain()) + return 0; + + if (of_address_to_resource(xen_node, GRANT_TABLE_PHYSADDR, &res)) { + pr_err("Xen grant table base address not found\n"); + return -ENODEV; + } + grant_frames = res.start; + + xen_events_irq = irq_of_parse_and_map(xen_node, 0); + if (!xen_events_irq) { + pr_err("Xen event channel interrupt not found\n"); + return -ENODEV; + } + + shared_info_page = (struct shared_info *)get_zeroed_page(GFP_KERNEL); - if (!shared_info_page) - shared_info_page = (struct shared_info *) - get_zeroed_page(GFP_KERNEL); if (!shared_info_page) { pr_err("not enough memory\n"); return -ENOMEM; diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 74753132c3ac..1b36ba9b73ac 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -64,6 +64,7 @@ #include #include #include +#include unsigned long elf_hwcap __read_mostly; EXPORT_SYMBOL_GPL(elf_hwcap); @@ -416,6 +417,7 @@ void __init setup_arch(char **cmdline_p) psci_acpi_init(); acpi_init_cpus(); } + xen_early_init(); #ifdef CONFIG_SMP smp_build_mpidr_hash(); -- cgit v1.2.3 From f1dddd118c555508ce383b7262f4e6440927bdf4 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Wed, 6 May 2015 14:14:22 +0000 Subject: xen/arm: allow console=hvc0 to be omitted for guests From: Ard Biesheuvel This patch registers hvc0 as the preferred console if no console has been specified explicitly on the kernel command line. The purpose is to allow platform agnostic kernels and boot images (such as distro installers) to boot in a Xen/ARM domU without the need to modify the command line by hand. Signed-off-by: Ard Biesheuvel Signed-off-by: Stefano Stabellini Reviewed-by: Julien Grall --- arch/arm/xen/enlighten.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'arch') diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 3463a9e1ff65..6c09cc440a2b 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -183,6 +184,9 @@ void __init xen_early_init(void) xen_start_info->flags |= SIF_INITDOMAIN|SIF_PRIVILEGED; else xen_start_info->flags &= ~(SIF_INITDOMAIN|SIF_PRIVILEGED); + + if (!console_set_on_cmdline && !xen_initial_domain()) + add_preferred_console("hvc", 0, NULL); } static int __init xen_guest_init(void) -- cgit v1.2.3 From 6c6685055a285de53f18fbf6611687291b57ccd6 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 20 May 2015 11:53:39 -0700 Subject: kconfig: add xenconfig defconfig helper This lets you build a kernel which can support xen dom0 or xen guests on i386, x86-64 and arm64 by just using: make xenconfig You can start from an allnoconfig and then switch to xenconfig. This also splits out the options which are available currently to be built with x86 and 'make ARCH=arm64' under a shared config. Technically xen supports a dom0 kernel and also a guest kernel configuration but upon review with the xen team since we don't have many dom0 options its best to just combine these two into one. A few generic notes: we enable both of these: CONFIG_INET=y CONFIG_BINFMT_ELF=y although technically not required given you likely will end up with a pretty useless system otherwise. A few architectural differences worth noting: $ make allnoconfig; make xenconfig > /dev/null ; \ grep XEN .config > 64-bit-config $ make ARCH=i386 allnoconfig; make ARCH=i386 xenconfig > /dev/null; \ grep XEN .config > 32-bit-config $ make ARCH=arm64 allnoconfig; make ARCH=arm64 xenconfig > /dev/null; \ grep XEN .config > arm64-config Since the options are already split up with a generic config and architecture specific configs you anything on the x86 configs are known to only work right now on x86. For instance arm64 doesn't support MEMORY_HOTPLUG yet as such although we try to enabe it generically arm64 doesn't have it yet, so we leave the xen specific kconfig option XEN_BALLOON_MEMORY_HOTPLUG on x86's config file to set expecations correctly. Then on x86 we have differences between i386 and x86-64. The difference between 64-bit-config and 32-bit-config is you don't get XEN_MCE_LOG as this is only supported on 64-bit. You also do not get on i386 XEN_BALLOON_MEMORY_HOTPLUG, there does not seem to be any technical reasons to not allow this but I gave up after a few attempts. Cc: Josh Triplett Cc: Borislav Petkov Cc: Pekka Enberg Cc: David Rientjes Cc: Michal Marek Cc: Randy Dunlap Cc: penberg@kernel.org Cc: levinsasha928@gmail.com Cc: mtosatti@redhat.com Cc: fengguang.wu@intel.com Cc: David Vrabel Cc: Ian Campbell Cc: Konrad Rzeszutek Wilk Cc: xen-devel@lists.xenproject.org Acked-by: Stefano Stabellini Acked-by: Julien Grall Acked-by: Michal Marek Acked-by: David Rientjes Reviewed-by: Josh Triplett Signed-off-by: Luis R. Rodriguez Signed-off-by: David Vrabel --- arch/x86/configs/xen.config | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 arch/x86/configs/xen.config (limited to 'arch') diff --git a/arch/x86/configs/xen.config b/arch/x86/configs/xen.config new file mode 100644 index 000000000000..d9fc7139fd46 --- /dev/null +++ b/arch/x86/configs/xen.config @@ -0,0 +1,28 @@ +# global x86 required specific stuff +# On 32-bit HIGHMEM4G is not allowed +CONFIG_HIGHMEM64G=y +CONFIG_64BIT=y + +# These enable us to allow some of the +# not so generic stuff below +CONFIG_HYPERVISOR_GUEST=y +CONFIG_PCI=y +CONFIG_PCI_MSI=y +CONFIG_X86_MCE=y +CONFIG_ACPI_PROCESSOR=y +CONFIG_CPU_FREQ=y + +# x86 xen specific config options +CONFIG_XEN_PVH=y +CONFIG_XEN_MAX_DOMAIN_MEMORY=500 +CONFIG_XEN_SAVE_RESTORE=y +# CONFIG_XEN_DEBUG_FS is not set +CONFIG_XEN_MCE_LOG=y +CONFIG_XEN_ACPI_PROCESSOR=m +# x86 specific backend drivers +CONFIG_XEN_PCIDEV_BACKEND=m +# x86 specific frontend drivers +CONFIG_XEN_PCIDEV_FRONTEND=m +# depends on MEMORY_HOTPLUG, arm64 doesn't enable this yet, +# move to generic config if it ever does. +CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y -- cgit v1.2.3 From a9fd60e2683fb80f5b26a7d686aebe3327a63e70 Mon Sep 17 00:00:00 2001 From: Julien Grall Date: Wed, 17 Jun 2015 15:28:02 +0100 Subject: xen: Include xen/page.h rather than asm/xen/page.h Using xen/page.h will be necessary later for using common xen page helpers. As xen/page.h already include asm/xen/page.h, always use the later. Signed-off-by: Julien Grall Reviewed-by: David Vrabel Cc: Stefano Stabellini Cc: Ian Campbell Cc: Wei Liu Cc: Konrad Rzeszutek Wilk Cc: Boris Ostrovsky Cc: netdev@vger.kernel.org Signed-off-by: David Vrabel --- arch/arm/xen/mm.c | 2 +- arch/arm/xen/p2m.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c index 498325074a06..03e75fef15b8 100644 --- a/arch/arm/xen/mm.c +++ b/arch/arm/xen/mm.c @@ -15,10 +15,10 @@ #include #include #include +#include #include #include -#include #include #include diff --git a/arch/arm/xen/p2m.c b/arch/arm/xen/p2m.c index cb7a14c5cd69..887596c67b12 100644 --- a/arch/arm/xen/p2m.c +++ b/arch/arm/xen/p2m.c @@ -10,10 +10,10 @@ #include #include +#include #include #include -#include #include #include -- cgit v1.2.3 From 90d73c4f43630ca45398cee7f32f0fe51271b2ce Mon Sep 17 00:00:00 2001 From: Julien Grall Date: Wed, 17 Jun 2015 15:28:05 +0100 Subject: arm/xen: Drop duplicate define mfn_to_virt Signed-off-by: Julien Grall Cc: Stefano Stabellini Signed-off-by: David Vrabel --- arch/arm/include/asm/xen/page.h | 1 - 1 file changed, 1 deletion(-) (limited to 'arch') diff --git a/arch/arm/include/asm/xen/page.h b/arch/arm/include/asm/xen/page.h index 0b579b2f4e0e..1bee8ca12494 100644 --- a/arch/arm/include/asm/xen/page.h +++ b/arch/arm/include/asm/xen/page.h @@ -12,7 +12,6 @@ #include #define phys_to_machine_mapping_valid(pfn) (1) -#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT)) #define pte_mfn pte_pfn #define mfn_pte pfn_pte -- cgit v1.2.3