diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 4feed2c2498d..25a0ce3b4584 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -218,8 +218,9 @@ static __initdata struct { static int __init fdt_find_hyper_node(unsigned long node, const char *uname, int depth, void *data) { - const void *s = NULL; + const char *s = NULL; int len; + size_t prefix_len = strlen(hyper_node.prefix); if (depth != 1 || strcmp(uname, "hypervisor") != 0) return 0; @@ -228,9 +229,10 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname, hyper_node.found = true; s = of_get_flat_dt_prop(node, "compatible", &len); - if (strlen(hyper_node.prefix) + 3 < len && - !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix))) - hyper_node.version = s + strlen(hyper_node.prefix); + if (s && len > 0 && strnlen(s, len) < len && + len > prefix_len + 3 && + !strncmp(hyper_node.prefix, s, prefix_len)) + hyper_node.version = s + prefix_len; /* * Check if Xen supports EFI by checking whether there is the diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index 7f0b6262488c..c407592442cd 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -139,6 +139,9 @@ static ssize_t domU_write_console(uint32_t vtermno, const u8 *data, size_t len) if (cons == NULL) return -EINVAL; + if (cons->intf->connection == XENCONSOLE_DISCONNECTED) + return -ENOTCONN; + /* * Make sure the whole buffer is emitted, polling if * necessary. We don't ever want to rely on the hvc daemon diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 97e27f754d39..a6abf1ccd54c 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -1579,7 +1579,7 @@ static int gnttab_setup(void) } return gnttab_map(0, nr_grant_frames - 1); } - +#ifdef CONFIG_HIBERNATE_CALLBACKS int gnttab_resume(void) { gnttab_request_version(); @@ -1592,6 +1592,7 @@ int gnttab_suspend(void) gnttab_interface->unmap_frames(); return 0; } +#endif static int gnttab_expand(unsigned int req_entries) { diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c index e20c40a62e64..05d7de128e71 100644 --- a/drivers/xen/manage.c +++ b/drivers/xen/manage.c @@ -343,12 +343,11 @@ static int setup_shutdown_watcher(void) return err; } - #ifdef CONFIG_MAGIC_SYSRQ err = register_xenbus_watch(&sysrq_watch); if (err) { pr_err("Failed to set sysrq watcher\n"); - return err; + goto err_unregister_shutdown; } #endif @@ -361,11 +360,26 @@ static int setup_shutdown_watcher(void) if (err) { pr_err("%s: Error %d writing %s\n", __func__, err, node); - return err; + goto err_remove_features; } } return 0; + +err_remove_features: + while (--idx >= 0) { + if (!shutdown_handlers[idx].flag) + continue; + snprintf(node, FEATURE_PATH_SIZE, "feature-%s", + shutdown_handlers[idx].command); + xenbus_rm(XBT_NIL, "control", node); + } +#ifdef CONFIG_MAGIC_SYSRQ + unregister_xenbus_watch(&sysrq_watch); +err_unregister_shutdown: +#endif + unregister_xenbus_watch(&shutdown_watch); + return err; } static int shutdown_event(struct notifier_block *notifier, diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index ccf25027bec1..4a734ee38994 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -340,7 +340,7 @@ xen_swiotlb_sync_single_for_device(struct device *dev, dma_addr_t dma_addr, /* * Unmap a set of streaming mode DMA translations. Again, cpu read rules - * concerning calls here are the same as for swiotlb_unmap_phys() above. + * concerning calls here are the same as for xen_swiotlb_unmap_phys() above. */ static void xen_swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h index 69ac6d80a006..a33a60a2ea72 100644 --- a/include/xen/grant_table.h +++ b/include/xen/grant_table.h @@ -84,8 +84,20 @@ struct gntab_unmap_queue_data }; int gnttab_init(void); +#ifdef CONFIG_HIBERNATE_CALLBACKS int gnttab_suspend(void); int gnttab_resume(void); +#else +static inline int gnttab_suspend(void) +{ + return 0; +} + +static inline int gnttab_resume(void) +{ + return 0; +} +#endif int gnttab_grant_foreign_access(domid_t domid, unsigned long frame, int readonly); diff --git a/include/xen/interface/io/console.h b/include/xen/interface/io/console.h index cf17e89ed861..687949bdebb1 100644 --- a/include/xen/interface/io/console.h +++ b/include/xen/interface/io/console.h @@ -19,6 +19,19 @@ struct xencons_interface { char out[2048]; XENCONS_RING_IDX in_cons, in_prod; XENCONS_RING_IDX out_cons, out_prod; +/* + * Flag values signaling from backend to frontend whether the console is + * connected. i.e. Whether it will be serviced and emptied. + * + * The flag starts as disconnected. + */ +#define XENCONSOLE_DISCONNECTED 1 +/* + * The flag is set to connected when the backend connects and the console + * will be serviced. + */ +#define XENCONSOLE_CONNECTED 0 + uint8_t connection; }; #endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */