Skip to content

Commit 8396455

Browse files
committed
Merge tag 'for-linus-7.1-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen updates from Juergen Gross: - fix an error path in drivers/xen/manage.c - fix the Xen console driver solving a boot hangup when the console backend isn't yet running - comment fix in the Xen swiotlb driver - hardening for Xen on Arm adding a more thorough validation - cleanup of the Xen grant table code hiding suspend/resume code for the case if CONFIG_HIBERNATE_CALLBACKS isn't defined * tag 'for-linus-7.1-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/grant-table: guard gnttab_suspend/resume with CONFIG_HIBERNATE_CALLBACKS hvc/xen: Check console connection flag xen/swiotlb: fix stale reference to swiotlb_unmap_page() xen/manage: unwind partial shutdown watcher setup on error ARM: xen: validate hypervisor compatible before parsing its version
2 parents a5f9980 + 3f100dd commit 8396455

7 files changed

Lines changed: 54 additions & 9 deletions

File tree

arch/arm/xen/enlighten.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,9 @@ static __initdata struct {
218218
static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
219219
int depth, void *data)
220220
{
221-
const void *s = NULL;
221+
const char *s = NULL;
222222
int len;
223+
size_t prefix_len = strlen(hyper_node.prefix);
223224

224225
if (depth != 1 || strcmp(uname, "hypervisor") != 0)
225226
return 0;
@@ -228,9 +229,10 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
228229
hyper_node.found = true;
229230

230231
s = of_get_flat_dt_prop(node, "compatible", &len);
231-
if (strlen(hyper_node.prefix) + 3 < len &&
232-
!strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
233-
hyper_node.version = s + strlen(hyper_node.prefix);
232+
if (s && len > 0 && strnlen(s, len) < len &&
233+
len > prefix_len + 3 &&
234+
!strncmp(hyper_node.prefix, s, prefix_len))
235+
hyper_node.version = s + prefix_len;
234236

235237
/*
236238
* Check if Xen supports EFI by checking whether there is the

drivers/tty/hvc/hvc_xen.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ static ssize_t domU_write_console(uint32_t vtermno, const u8 *data, size_t len)
139139
if (cons == NULL)
140140
return -EINVAL;
141141

142+
if (cons->intf->connection == XENCONSOLE_DISCONNECTED)
143+
return -ENOTCONN;
144+
142145
/*
143146
* Make sure the whole buffer is emitted, polling if
144147
* necessary. We don't ever want to rely on the hvc daemon

drivers/xen/grant-table.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,7 @@ static int gnttab_setup(void)
15791579
}
15801580
return gnttab_map(0, nr_grant_frames - 1);
15811581
}
1582-
1582+
#ifdef CONFIG_HIBERNATE_CALLBACKS
15831583
int gnttab_resume(void)
15841584
{
15851585
gnttab_request_version();
@@ -1592,6 +1592,7 @@ int gnttab_suspend(void)
15921592
gnttab_interface->unmap_frames();
15931593
return 0;
15941594
}
1595+
#endif
15951596

15961597
static int gnttab_expand(unsigned int req_entries)
15971598
{

drivers/xen/manage.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,11 @@ static int setup_shutdown_watcher(void)
343343
return err;
344344
}
345345

346-
347346
#ifdef CONFIG_MAGIC_SYSRQ
348347
err = register_xenbus_watch(&sysrq_watch);
349348
if (err) {
350349
pr_err("Failed to set sysrq watcher\n");
351-
return err;
350+
goto err_unregister_shutdown;
352351
}
353352
#endif
354353

@@ -361,11 +360,26 @@ static int setup_shutdown_watcher(void)
361360
if (err) {
362361
pr_err("%s: Error %d writing %s\n", __func__,
363362
err, node);
364-
return err;
363+
goto err_remove_features;
365364
}
366365
}
367366

368367
return 0;
368+
369+
err_remove_features:
370+
while (--idx >= 0) {
371+
if (!shutdown_handlers[idx].flag)
372+
continue;
373+
snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
374+
shutdown_handlers[idx].command);
375+
xenbus_rm(XBT_NIL, "control", node);
376+
}
377+
#ifdef CONFIG_MAGIC_SYSRQ
378+
unregister_xenbus_watch(&sysrq_watch);
379+
err_unregister_shutdown:
380+
#endif
381+
unregister_xenbus_watch(&shutdown_watch);
382+
return err;
369383
}
370384

371385
static int shutdown_event(struct notifier_block *notifier,

drivers/xen/swiotlb-xen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ xen_swiotlb_sync_single_for_device(struct device *dev, dma_addr_t dma_addr,
340340

341341
/*
342342
* Unmap a set of streaming mode DMA translations. Again, cpu read rules
343-
* concerning calls here are the same as for swiotlb_unmap_phys() above.
343+
* concerning calls here are the same as for xen_swiotlb_unmap_phys() above.
344344
*/
345345
static void
346346
xen_swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,

include/xen/grant_table.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,20 @@ struct gntab_unmap_queue_data
8484
};
8585

8686
int gnttab_init(void);
87+
#ifdef CONFIG_HIBERNATE_CALLBACKS
8788
int gnttab_suspend(void);
8889
int gnttab_resume(void);
90+
#else
91+
static inline int gnttab_suspend(void)
92+
{
93+
return 0;
94+
}
95+
96+
static inline int gnttab_resume(void)
97+
{
98+
return 0;
99+
}
100+
#endif
89101

90102
int gnttab_grant_foreign_access(domid_t domid, unsigned long frame,
91103
int readonly);

include/xen/interface/io/console.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ struct xencons_interface {
1919
char out[2048];
2020
XENCONS_RING_IDX in_cons, in_prod;
2121
XENCONS_RING_IDX out_cons, out_prod;
22+
/*
23+
* Flag values signaling from backend to frontend whether the console is
24+
* connected. i.e. Whether it will be serviced and emptied.
25+
*
26+
* The flag starts as disconnected.
27+
*/
28+
#define XENCONSOLE_DISCONNECTED 1
29+
/*
30+
* The flag is set to connected when the backend connects and the console
31+
* will be serviced.
32+
*/
33+
#define XENCONSOLE_CONNECTED 0
34+
uint8_t connection;
2235
};
2336

2437
#endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */

0 commit comments

Comments
 (0)