From 16e506efc08e5cab313588bd0e38803d4bbaad59 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Thu, 25 Feb 2016 12:10:37 +0000 Subject: [PATCH 01/10] hvc_xen: add earlycon support Introduce EARLYCON support in hvc_xen, useful for early debugging on arm and arm64, where xen early_printk is not available. It is different from xenboot_write_console on x86 in two ways: - it does not return if !xen_pv_domain(), not only because ARM guests are xen_hvm_domain(), but also because we want to capture all the early boot messages, before xen support is discovered - it does not try to print to the domU console at all, because xen support will only be discovered at a later point Signed-off-by: Stefano Stabellini Reviewed-by: Boris Ostrovsky --- drivers/tty/hvc/hvc_xen.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index fa816b7193b6..68b8ec886bec 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -664,3 +665,18 @@ void xen_raw_printk(const char *fmt, ...) xen_raw_console_write(buf); } + +static void xenboot_earlycon_write(struct console *console, + const char *string, + unsigned len) +{ + dom0_write_console(0, string, len); +} + +static int __init xenboot_earlycon_setup(struct earlycon_device *device, + const char *opt) +{ + device->con->write = xenboot_earlycon_write; + return 0; +} +EARLYCON_DECLARE(xenboot, xenboot_earlycon_setup); From 5de738b3fbbd52a21850d5c1b6c1e5823db18b21 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Thu, 25 Feb 2016 12:10:38 +0000 Subject: [PATCH 02/10] hvc_xen: fix xenboot for DomUs The xenboot early console has been partially broken for DomU for a long time: the output would only go to the hypervisor via hypercall (HYPERVISOR_console_io), while it wouldn't actually go to the DomU console. The reason is that domU_write_console would return early as no xencons structs are configured for it. Add an appropriate xencons struct for xenboot from the xenboot setup callback. Signed-off-by: Stefano Stabellini Reviewed-by: Boris Ostrovsky --- drivers/tty/hvc/hvc_xen.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index 68b8ec886bec..f34dec1d588a 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -246,6 +246,18 @@ err: return -ENODEV; } +static int xencons_info_pv_init(struct xencons_info *info, int vtermno) +{ + info->evtchn = xen_start_info->console.domU.evtchn; + /* GFN == MFN for PV guest */ + info->intf = gfn_to_virt(xen_start_info->console.domU.mfn); + info->vtermno = vtermno; + + list_add_tail(&info->list, &xenconsoles); + + return 0; +} + static int xen_pv_console_init(void) { struct xencons_info *info; @@ -265,13 +277,8 @@ static int xen_pv_console_init(void) /* already configured */ return 0; } - info->evtchn = xen_start_info->console.domU.evtchn; - /* GFN == MFN for PV guest */ - info->intf = gfn_to_virt(xen_start_info->console.domU.mfn); - info->vtermno = HVC_COOKIE; - spin_lock(&xencons_lock); - list_add_tail(&info->list, &xenconsoles); + xencons_info_pv_init(info, HVC_COOKIE); spin_unlock(&xencons_lock); return 0; @@ -599,6 +606,18 @@ static int xen_cons_init(void) console_initcall(xen_cons_init); #ifdef CONFIG_EARLY_PRINTK +static int __init xenboot_setup_console(struct console *console, char *string) +{ + static struct xencons_info xenboot; + + if (xen_initial_domain()) + return 0; + if (!xen_pv_domain()) + return -ENODEV; + + return xencons_info_pv_init(&xenboot, 0); +} + static void xenboot_write_console(struct console *console, const char *string, unsigned len) { @@ -629,6 +648,7 @@ static void xenboot_write_console(struct console *console, const char *string, struct console xenboot_console = { .name = "xenboot", .write = xenboot_write_console, + .setup = xenboot_setup_console, .flags = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME, .index = -1, }; From a4d7b75be034115d36b6a20db566eb8b11bacaf8 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Thu, 25 Feb 2016 12:10:39 +0000 Subject: [PATCH 03/10] hvc_xen: make early_printk work with HVM guests Refactor the existing code in xen_raw_console_write to get the generic early_printk console work with HVM guests. Take the opportunity to replace the outb loop with a single outsb call to reduce the number of vmexit. Signed-off-by: Stefano Stabellini Reviewed-by: Boris Ostrovsky --- drivers/tty/hvc/hvc_xen.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index f34dec1d588a..71784950048f 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -605,6 +605,16 @@ static int xen_cons_init(void) } console_initcall(xen_cons_init); +#ifdef CONFIG_X86 +static void xen_hvm_early_write(uint32_t vtermno, const char *str, int len) +{ + if (xen_cpuid_base()) + outsb(0xe9, str, len); +} +#else +static void xen_hvm_early_write(uint32_t vtermno, const char *str, int len) { } +#endif + #ifdef CONFIG_EARLY_PRINTK static int __init xenboot_setup_console(struct console *console, char *string) { @@ -624,8 +634,10 @@ static void xenboot_write_console(struct console *console, const char *string, unsigned int linelen, off = 0; const char *pos; - if (!xen_pv_domain()) + if (!xen_pv_domain()) { + xen_hvm_early_write(0, string, len); return; + } dom0_write_console(0, string, len); @@ -661,17 +673,10 @@ void xen_raw_console_write(const char *str) if (xen_domain()) { rc = dom0_write_console(0, str, len); -#ifdef CONFIG_X86 - if (rc == -ENOSYS && xen_hvm_domain()) - goto outb_print; - - } else if (xen_cpuid_base()) { - int i; -outb_print: - for (i = 0; i < len; i++) - outb(str[i], 0xe9); -#endif + if (rc != -ENOSYS || !xen_hvm_domain()) + return; } + xen_hvm_early_write(0, str, len); } void xen_raw_printk(const char *fmt, ...) From 04b6b4a56884327c1648c517f1f46a2638f04c9d Mon Sep 17 00:00:00 2001 From: Boris Ostrovsky Date: Fri, 26 Feb 2016 14:02:36 -0500 Subject: [PATCH 04/10] xen/x86: Zero out .bss for PV guests ELF spec is unclear about whether .bss must me cleared by the loader. Currently the domain builder does it when loading the guest but because it is not (or rather may not be) guaranteed we should zero it out explicitly. Signed-off-by: Boris Ostrovsky Signed-off-by: David Vrabel --- arch/x86/xen/xen-head.S | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S index b65f59a358a2..5c63d2d955bb 100644 --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S @@ -38,6 +38,15 @@ __INIT ENTRY(startup_xen) cld + + /* Clear .bss */ + xor %eax,%eax + mov $__bss_start, %_ASM_DI + mov $__bss_stop, %_ASM_CX + sub %_ASM_DI, %_ASM_CX + shr $__ASM_SEL(2, 3), %_ASM_CX + rep __ASM_SIZE(stos) + #ifdef CONFIG_X86_32 mov %esi,xen_start_info mov $init_thread_union+THREAD_SIZE,%esp From 4478c407ea3810aad300ef8d4cee23b3d708461b Mon Sep 17 00:00:00 2001 From: Boris Ostrovsky Date: Fri, 26 Feb 2016 14:02:37 -0500 Subject: [PATCH 05/10] xen/x86: Drop mode-selecting ifdefs in startup_xen() Use asm/asm.h macros instead. Signed-off-by: Boris Ostrovsky Signed-off-by: David Vrabel --- arch/x86/xen/xen-head.S | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S index 5c63d2d955bb..de93b20fa0d2 100644 --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S @@ -47,13 +47,9 @@ ENTRY(startup_xen) shr $__ASM_SEL(2, 3), %_ASM_CX rep __ASM_SIZE(stos) -#ifdef CONFIG_X86_32 - mov %esi,xen_start_info - mov $init_thread_union+THREAD_SIZE,%esp -#else - mov %rsi,xen_start_info - mov $init_thread_union+THREAD_SIZE,%rsp -#endif + mov %_ASM_SI, xen_start_info + mov $init_thread_union+THREAD_SIZE, %_ASM_SP + jmp xen_start_kernel __FINIT From 59aa56bf2a92e1df97d218937d5cd108927a5c46 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Sun, 21 Feb 2016 19:06:04 -0500 Subject: [PATCH 06/10] xen: audit usages of module.h ; remove unnecessary instances Code that uses no modular facilities whatsoever should not be sourcing module.h at all, since that header drags in a bunch of other headers with it. Similarly, code that is not explicitly using modular facilities like module_init() but only is declaring module_param setup variables should be using moduleparam.h and not the larger module.h file for that. In making this change, we also uncover an implicit use of BUG() in inline fcns within arch/arm/include/asm/xen/hypercall.h so we explicitly source for that file now. Signed-off-by: Paul Gortmaker Reviewed-by: Stefano Stabellini Signed-off-by: David Vrabel --- arch/arm/include/asm/xen/hypercall.h | 2 ++ drivers/xen/events/events_2l.c | 1 - drivers/xen/events/events_base.c | 2 +- drivers/xen/events/events_fifo.c | 1 - drivers/xen/features.c | 2 +- drivers/xen/grant-table.c | 1 - drivers/xen/xen-pciback/conf_space.c | 2 +- drivers/xen/xen-pciback/pciback_ops.c | 2 +- drivers/xen/xen-pciback/xenbus.c | 2 +- drivers/xen/xen-selfballoon.c | 1 - drivers/xen/xenbus/xenbus_xs.c | 1 - drivers/xen/xenfs/xensyms.c | 1 - 12 files changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/arm/include/asm/xen/hypercall.h b/arch/arm/include/asm/xen/hypercall.h index d769972db8cb..b6b962d70db9 100644 --- a/arch/arm/include/asm/xen/hypercall.h +++ b/arch/arm/include/asm/xen/hypercall.h @@ -33,6 +33,8 @@ #ifndef _ASM_ARM_XEN_HYPERCALL_H #define _ASM_ARM_XEN_HYPERCALL_H +#include + #include #include #include diff --git a/drivers/xen/events/events_2l.c b/drivers/xen/events/events_2l.c index 7dd46312c180..51b488f5bfe9 100644 --- a/drivers/xen/events/events_2l.c +++ b/drivers/xen/events/events_2l.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 524c22146429..488017a0806a 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c index eff2b88003d9..9289a17712e2 100644 --- a/drivers/xen/events/events_fifo.c +++ b/drivers/xen/events/events_fifo.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/xen/features.c b/drivers/xen/features.c index 99eda169c779..d7d34fdfc993 100644 --- a/drivers/xen/features.c +++ b/drivers/xen/features.c @@ -7,7 +7,7 @@ */ #include #include -#include +#include #include diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index effbaf91791f..bb36b1e1dbcc 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -33,7 +33,6 @@ #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt -#include #include #include #include diff --git a/drivers/xen/xen-pciback/conf_space.c b/drivers/xen/xen-pciback/conf_space.c index 9c234209d8b5..8e67336f8ddd 100644 --- a/drivers/xen/xen-pciback/conf_space.c +++ b/drivers/xen/xen-pciback/conf_space.c @@ -10,7 +10,7 @@ */ #include -#include +#include #include #include "pciback.h" #include "conf_space.h" diff --git a/drivers/xen/xen-pciback/pciback_ops.c b/drivers/xen/xen-pciback/pciback_ops.c index 73dafdc494aa..5ad01f9c24fc 100644 --- a/drivers/xen/xen-pciback/pciback_ops.c +++ b/drivers/xen/xen-pciback/pciback_ops.c @@ -6,7 +6,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include +#include #include #include #include diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c index 4843741e703a..c252eb3f0176 100644 --- a/drivers/xen/xen-pciback/xenbus.c +++ b/drivers/xen/xen-pciback/xenbus.c @@ -6,7 +6,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include +#include #include #include #include diff --git a/drivers/xen/xen-selfballoon.c b/drivers/xen/xen-selfballoon.c index 3b2bffde534f..53a085fca00c 100644 --- a/drivers/xen/xen-selfballoon.c +++ b/drivers/xen/xen-selfballoon.c @@ -71,7 +71,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c index ba804f3d8278..374b12af8812 100644 --- a/drivers/xen/xenbus/xenbus_xs.c +++ b/drivers/xen/xenbus/xenbus_xs.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/xen/xenfs/xensyms.c b/drivers/xen/xenfs/xensyms.c index a03f261b12d8..c6e2b4a542ea 100644 --- a/drivers/xen/xenfs/xensyms.c +++ b/drivers/xen/xenfs/xensyms.c @@ -1,4 +1,3 @@ -#include #include #include #include From 106eaa8e6e19cbaff34c99c9996d61634fb44b0d Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Sun, 21 Feb 2016 19:06:05 -0500 Subject: [PATCH 07/10] drivers/xen: make [xen-]ballon explicitly non-modular MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Makefile / Kconfig currently controlling compilation here is: obj-y += grant-table.o features.o balloon.o manage.o preempt.o time.o [...] obj-$(CONFIG_XEN_BALLOON) += xen-balloon.o ...with: drivers/xen/Kconfig:config XEN_BALLOON drivers/xen/Kconfig: bool "Xen memory balloon driver" ...meaning that they currently are not being built as modules by anyone. Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only. In doing so we uncover two implict includes that were obtained by module.h having such a wide include scope itself: In file included from drivers/xen/xen-balloon.c:41:0: include/xen/balloon.h:26:51: warning: ‘struct page’ declared inside parameter list [enabled by default] int alloc_xenballooned_pages(int nr_pages, struct page **pages); ^ include/xen/balloon.h: In function ‘register_xen_selfballooning’: include/xen/balloon.h:35:10: error: ‘ENOSYS’ undeclared (first use in this function) return -ENOSYS; ^ This is fixed by adding mm-types.h and errno.h to the list. We also delete the MODULE_LICENSE tags since all that information is already contained at the top of the file in the comments. Signed-off-by: Paul Gortmaker Reviewed-by: Stefano Stabellini Signed-off-by: David Vrabel --- drivers/xen/balloon.c | 4 ---- drivers/xen/xen-balloon.c | 14 +++----------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 12eab503efd1..481c3f86033a 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -751,7 +750,4 @@ static int __init balloon_init(void) return 0; } - subsys_initcall(balloon_init); - -MODULE_LICENSE("GPL"); diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c index 39e7ef8d3957..79865b8901ba 100644 --- a/drivers/xen/xen-balloon.c +++ b/drivers/xen/xen-balloon.c @@ -33,7 +33,9 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include +#include +#include +#include #include #include @@ -109,14 +111,6 @@ static int __init balloon_init(void) } subsys_initcall(balloon_init); -static void balloon_exit(void) -{ - /* XXX - release balloon here */ - return; -} - -module_exit(balloon_exit); - #define BALLOON_SHOW(name, format, args...) \ static ssize_t show_##name(struct device *dev, \ struct device_attribute *attr, \ @@ -250,5 +244,3 @@ static int register_balloon(struct device *dev) return 0; } - -MODULE_LICENSE("GPL"); From ab1241a1fc4351be16a5fd5c34001de08c696169 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Sun, 21 Feb 2016 19:06:06 -0500 Subject: [PATCH 08/10] drivers/xen: make xenbus_dev_[front/back]end explicitly non-modular The Makefile / Kconfig currently controlling compilation here is: obj-y += xenbus_dev_frontend.o [...] obj-$(CONFIG_XEN_BACKEND) += xenbus_dev_backend.o ...with: drivers/xen/Kconfig:config XEN_BACKEND drivers/xen/Kconfig: bool "Backend driver support" ...meaning that they currently are not being built as modules by anyone. Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only. Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit. We also delete the MODULE_LICENSE tag since all that information is already contained at the top of the file in the comments. Signed-off-by: Paul Gortmaker Reviewed-by: Stefano Stabellini Signed-off-by: David Vrabel --- drivers/xen/xenbus/xenbus_dev_backend.c | 13 ++----------- drivers/xen/xenbus/xenbus_dev_frontend.c | 13 ++----------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_dev_backend.c b/drivers/xen/xenbus/xenbus_dev_backend.c index ee6d9efd7b76..4a41ac9af966 100644 --- a/drivers/xen/xenbus/xenbus_dev_backend.c +++ b/drivers/xen/xenbus/xenbus_dev_backend.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -18,8 +18,6 @@ #include "xenbus_comms.h" -MODULE_LICENSE("GPL"); - static int xenbus_backend_open(struct inode *inode, struct file *filp) { if (!capable(CAP_SYS_ADMIN)) @@ -132,11 +130,4 @@ static int __init xenbus_backend_init(void) pr_err("Could not register xenbus backend device\n"); return err; } - -static void __exit xenbus_backend_exit(void) -{ - misc_deregister(&xenbus_backend_dev); -} - -module_init(xenbus_backend_init); -module_exit(xenbus_backend_exit); +device_initcall(xenbus_backend_init); diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c index 9433e46518c8..8c0a359ab4a8 100644 --- a/drivers/xen/xenbus/xenbus_dev_frontend.c +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c @@ -55,7 +55,7 @@ #include #include #include -#include +#include #include "xenbus_comms.h" @@ -63,8 +63,6 @@ #include #include -MODULE_LICENSE("GPL"); - /* * An element of a list of outstanding transactions, for which we're * still waiting a reply. @@ -624,11 +622,4 @@ static int __init xenbus_init(void) pr_err("Could not register xenbus frontend device\n"); return err; } - -static void __exit xenbus_exit(void) -{ - misc_deregister(&xenbus_dev); -} - -module_init(xenbus_init); -module_exit(xenbus_exit); +device_initcall(xenbus_init); From 46894f17af151f9f2050821aaa889a32c7cbd16f Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Sun, 21 Feb 2016 19:06:07 -0500 Subject: [PATCH 09/10] drivers/xen: make sys-hypervisor.c explicitly non-modular The Kconfig currently controlling compilation of this code is: config XEN_SYS_HYPERVISOR bool "Create xen entries under /sys/hypervisor" ...meaning that it currently is not being built as a module by anyone. Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only. Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit. However one could argue that fs_initcall() might make more sense here. This change means that the one line function xen_properties_destroy() has only one user left, and since that is inside an #ifdef, we just manually inline it there vs. adding more ifdeffery around the function to avoid compile warnings about "defined but not used". In order to be consistent we also manually inline the other _destroy functions that are also just one line sysfs functions calls with only one call site remaing, even though they wouldn't need #ifdeffery. Signed-off-by: Paul Gortmaker Reviewed-by: Stefano Stabellini Signed-off-by: David Vrabel --- drivers/xen/sys-hypervisor.c | 59 +++++------------------------------- 1 file changed, 8 insertions(+), 51 deletions(-) diff --git a/drivers/xen/sys-hypervisor.c b/drivers/xen/sys-hypervisor.c index b5a7342e0ba5..6881b3ceb675 100644 --- a/drivers/xen/sys-hypervisor.c +++ b/drivers/xen/sys-hypervisor.c @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -50,11 +50,6 @@ static int __init xen_sysfs_type_init(void) return sysfs_create_file(hypervisor_kobj, &type_attr.attr); } -static void xen_sysfs_type_destroy(void) -{ - sysfs_remove_file(hypervisor_kobj, &type_attr.attr); -} - /* xen version attributes */ static ssize_t major_show(struct hyp_sysfs_attr *attr, char *buffer) { @@ -111,11 +106,6 @@ static int __init xen_sysfs_version_init(void) return sysfs_create_group(hypervisor_kobj, &version_group); } -static void xen_sysfs_version_destroy(void) -{ - sysfs_remove_group(hypervisor_kobj, &version_group); -} - /* UUID */ static ssize_t uuid_show_fallback(struct hyp_sysfs_attr *attr, char *buffer) @@ -157,11 +147,6 @@ static int __init xen_sysfs_uuid_init(void) return sysfs_create_file(hypervisor_kobj, &uuid_attr.attr); } -static void xen_sysfs_uuid_destroy(void) -{ - sysfs_remove_file(hypervisor_kobj, &uuid_attr.attr); -} - /* xen compilation attributes */ static ssize_t compiler_show(struct hyp_sysfs_attr *attr, char *buffer) @@ -235,11 +220,6 @@ static int __init xen_compilation_init(void) return sysfs_create_group(hypervisor_kobj, &xen_compilation_group); } -static void xen_compilation_destroy(void) -{ - sysfs_remove_group(hypervisor_kobj, &xen_compilation_group); -} - /* xen properties info */ static ssize_t capabilities_show(struct hyp_sysfs_attr *attr, char *buffer) @@ -366,11 +346,6 @@ static int __init xen_properties_init(void) return sysfs_create_group(hypervisor_kobj, &xen_properties_group); } -static void xen_properties_destroy(void) -{ - sysfs_remove_group(hypervisor_kobj, &xen_properties_group); -} - #ifdef CONFIG_XEN_HAVE_VPMU struct pmu_mode { const char *name; @@ -484,11 +459,6 @@ static int __init xen_pmu_init(void) { return sysfs_create_group(hypervisor_kobj, &xen_pmu_group); } - -static void xen_pmu_destroy(void) -{ - sysfs_remove_group(hypervisor_kobj, &xen_pmu_group); -} #endif static int __init hyper_sysfs_init(void) @@ -517,7 +487,8 @@ static int __init hyper_sysfs_init(void) if (xen_initial_domain()) { ret = xen_pmu_init(); if (ret) { - xen_properties_destroy(); + sysfs_remove_group(hypervisor_kobj, + &xen_properties_group); goto prop_out; } } @@ -525,31 +496,17 @@ static int __init hyper_sysfs_init(void) goto out; prop_out: - xen_sysfs_uuid_destroy(); + sysfs_remove_file(hypervisor_kobj, &uuid_attr.attr); uuid_out: - xen_compilation_destroy(); + sysfs_remove_group(hypervisor_kobj, &xen_compilation_group); comp_out: - xen_sysfs_version_destroy(); + sysfs_remove_group(hypervisor_kobj, &version_group); version_out: - xen_sysfs_type_destroy(); + sysfs_remove_file(hypervisor_kobj, &type_attr.attr); out: return ret; } - -static void __exit hyper_sysfs_exit(void) -{ -#ifdef CONFIG_XEN_HAVE_VPMU - xen_pmu_destroy(); -#endif - xen_properties_destroy(); - xen_compilation_destroy(); - xen_sysfs_uuid_destroy(); - xen_sysfs_version_destroy(); - xen_sysfs_type_destroy(); - -} -module_init(hyper_sysfs_init); -module_exit(hyper_sysfs_exit); +device_initcall(hyper_sysfs_init); static ssize_t hyp_sysfs_show(struct kobject *kobj, struct attribute *attr, From e01dc539df3ada9061a1097224513236b5381349 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Sun, 21 Feb 2016 19:06:08 -0500 Subject: [PATCH 10/10] drivers/xen: make platform-pci.c explicitly non-modular The Kconfig currently controlling compilation of this code is: arch/x86/xen/Kconfig:config XEN_PVHVM arch/x86/xen/Kconfig: def_bool y ...meaning that it currently is not being built as a module by anyone. Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only. Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit. Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code. We also delete the MODULE_LICENSE tag etc. since all that information was (or is now) contained at the top of the file in the comments. In removing "module" from the init fcn name, we observe a namespace collision with the probe function, so we use "probe" in the name of the probe function, and "init" in the registration fcn, as per standard convention, as suggested by Stefano. Signed-off-by: Paul Gortmaker Reviewed-by: Stefano Stabellini Signed-off-by: David Vrabel --- drivers/xen/platform-pci.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/xen/platform-pci.c b/drivers/xen/platform-pci.c index 3454973dc3bb..cf9666680c8c 100644 --- a/drivers/xen/platform-pci.c +++ b/drivers/xen/platform-pci.c @@ -2,6 +2,9 @@ * platform-pci.c * * Xen platform PCI device driver + * + * Authors: ssmith@xensource.com and stefano.stabellini@eu.citrix.com + * * Copyright (c) 2005, Intel Corporation. * Copyright (c) 2007, XenSource Inc. * Copyright (c) 2010, Citrix @@ -24,7 +27,7 @@ #include #include -#include +#include #include #include @@ -36,10 +39,6 @@ #define DRV_NAME "xen-platform-pci" -MODULE_AUTHOR("ssmith@xensource.com and stefano.stabellini@eu.citrix.com"); -MODULE_DESCRIPTION("Xen platform PCI device"); -MODULE_LICENSE("GPL"); - static unsigned long platform_mmio; static unsigned long platform_mmio_alloc; static unsigned long platform_mmiolen; @@ -101,8 +100,8 @@ static int platform_pci_resume(struct pci_dev *pdev) return 0; } -static int platform_pci_init(struct pci_dev *pdev, - const struct pci_device_id *ent) +static int platform_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) { int i, ret; long ioaddr; @@ -181,20 +180,17 @@ static struct pci_device_id platform_pci_tbl[] = { {0,} }; -MODULE_DEVICE_TABLE(pci, platform_pci_tbl); - static struct pci_driver platform_driver = { .name = DRV_NAME, - .probe = platform_pci_init, + .probe = platform_pci_probe, .id_table = platform_pci_tbl, #ifdef CONFIG_PM .resume_early = platform_pci_resume, #endif }; -static int __init platform_pci_module_init(void) +static int __init platform_pci_init(void) { return pci_register_driver(&platform_driver); } - -module_init(platform_pci_module_init); +device_initcall(platform_pci_init);