Skip to content

Commit 0e1dc42

Browse files
committed
Merge tag 'for-linus-4.1b-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen bug fixes from David Vrabel: - fix blkback regression if using persistent grants - fix various event channel related suspend/resume bugs - fix AMD x86 regression with X86_BUG_SYSRET_SS_ATTRS - SWIOTLB on ARM now uses frames <4 GiB (if available) so device only capable of 32-bit DMA work. * tag 'for-linus-4.1b-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen: Add __GFP_DMA flag when xen_swiotlb_init gets free pages on ARM hypervisor/x86/xen: Unset X86_BUG_SYSRET_SS_ATTRS on Xen PV guests xen/events: Set irq_info->evtchn before binding the channel to CPU in __startup_pirq() xen/console: Update console event channel on resume xen/xenbus: Update xenbus event channel on resume xen/events: Clear cpu_evtchn_mask before resuming xen-pciback: Add name prefix to global 'permissive' variable xen: Suspend ticks on all CPUs during suspend xen/grant: introduce func gnttab_unmap_refs_sync() xen/blkback: safely unmap purge persistent grants
2 parents 3d54ac9 + 8746515 commit 0e1dc42

File tree

21 files changed

+168
-74
lines changed

21 files changed

+168
-74
lines changed

arch/arm/include/asm/xen/page.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,6 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
110110
bool xen_arch_need_swiotlb(struct device *dev,
111111
unsigned long pfn,
112112
unsigned long mfn);
113+
unsigned long xen_get_swiotlb_free_pages(unsigned int order);
113114

114115
#endif /* _ASM_ARM_XEN_PAGE_H */

arch/arm/xen/mm.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/gfp.h>
55
#include <linux/highmem.h>
66
#include <linux/export.h>
7+
#include <linux/memblock.h>
78
#include <linux/of_address.h>
89
#include <linux/slab.h>
910
#include <linux/types.h>
@@ -21,6 +22,20 @@
2122
#include <asm/xen/hypercall.h>
2223
#include <asm/xen/interface.h>
2324

25+
unsigned long xen_get_swiotlb_free_pages(unsigned int order)
26+
{
27+
struct memblock_region *reg;
28+
gfp_t flags = __GFP_NOWARN;
29+
30+
for_each_memblock(memory, reg) {
31+
if (reg->base < (phys_addr_t)0xffffffff) {
32+
flags |= __GFP_DMA;
33+
break;
34+
}
35+
}
36+
return __get_free_pages(flags, order);
37+
}
38+
2439
enum dma_cache_op {
2540
DMA_UNMAP,
2641
DMA_MAP,

arch/x86/include/asm/hypervisor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extern const struct hypervisor_x86 *x86_hyper;
5050
/* Recognized hypervisors */
5151
extern const struct hypervisor_x86 x86_hyper_vmware;
5252
extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
53-
extern const struct hypervisor_x86 x86_hyper_xen_hvm;
53+
extern const struct hypervisor_x86 x86_hyper_xen;
5454
extern const struct hypervisor_x86 x86_hyper_kvm;
5555

5656
extern void init_hypervisor(struct cpuinfo_x86 *c);

arch/x86/include/asm/xen/page.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,9 @@ static inline bool xen_arch_need_swiotlb(struct device *dev,
269269
return false;
270270
}
271271

272+
static inline unsigned long xen_get_swiotlb_free_pages(unsigned int order)
273+
{
274+
return __get_free_pages(__GFP_NOWARN, order);
275+
}
276+
272277
#endif /* _ASM_X86_XEN_PAGE_H */

arch/x86/kernel/cpu/hypervisor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
static const __initconst struct hypervisor_x86 * const hypervisors[] =
2929
{
30-
#ifdef CONFIG_XEN_PVHVM
31-
&x86_hyper_xen_hvm,
30+
#ifdef CONFIG_XEN
31+
&x86_hyper_xen,
3232
#endif
3333
&x86_hyper_vmware,
3434
&x86_hyper_ms_hyperv,

arch/x86/xen/enlighten.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,9 @@ static struct notifier_block xen_hvm_cpu_notifier = {
17601760

17611761
static void __init xen_hvm_guest_init(void)
17621762
{
1763+
if (xen_pv_domain())
1764+
return;
1765+
17631766
init_hvm_pv_info();
17641767

17651768
xen_hvm_init_shared_info();
@@ -1775,6 +1778,7 @@ static void __init xen_hvm_guest_init(void)
17751778
xen_hvm_init_time_ops();
17761779
xen_hvm_init_mmu_ops();
17771780
}
1781+
#endif
17781782

17791783
static bool xen_nopv = false;
17801784
static __init int xen_parse_nopv(char *arg)
@@ -1784,14 +1788,11 @@ static __init int xen_parse_nopv(char *arg)
17841788
}
17851789
early_param("xen_nopv", xen_parse_nopv);
17861790

1787-
static uint32_t __init xen_hvm_platform(void)
1791+
static uint32_t __init xen_platform(void)
17881792
{
17891793
if (xen_nopv)
17901794
return 0;
17911795

1792-
if (xen_pv_domain())
1793-
return 0;
1794-
17951796
return xen_cpuid_base();
17961797
}
17971798

@@ -1809,11 +1810,19 @@ bool xen_hvm_need_lapic(void)
18091810
}
18101811
EXPORT_SYMBOL_GPL(xen_hvm_need_lapic);
18111812

1812-
const struct hypervisor_x86 x86_hyper_xen_hvm __refconst = {
1813-
.name = "Xen HVM",
1814-
.detect = xen_hvm_platform,
1813+
static void xen_set_cpu_features(struct cpuinfo_x86 *c)
1814+
{
1815+
if (xen_pv_domain())
1816+
clear_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
1817+
}
1818+
1819+
const struct hypervisor_x86 x86_hyper_xen = {
1820+
.name = "Xen",
1821+
.detect = xen_platform,
1822+
#ifdef CONFIG_XEN_PVHVM
18151823
.init_platform = xen_hvm_guest_init,
1824+
#endif
18161825
.x2apic_available = xen_x2apic_para_available,
1826+
.set_cpu_features = xen_set_cpu_features,
18171827
};
1818-
EXPORT_SYMBOL(x86_hyper_xen_hvm);
1819-
#endif
1828+
EXPORT_SYMBOL(x86_hyper_xen);

arch/x86/xen/suspend.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,17 @@ static void xen_vcpu_notify_restore(void *data)
8888
tick_resume_local();
8989
}
9090

91+
static void xen_vcpu_notify_suspend(void *data)
92+
{
93+
tick_suspend_local();
94+
}
95+
9196
void xen_arch_resume(void)
9297
{
9398
on_each_cpu(xen_vcpu_notify_restore, NULL, 1);
9499
}
100+
101+
void xen_arch_suspend(void)
102+
{
103+
on_each_cpu(xen_vcpu_notify_suspend, NULL, 1);
104+
}

drivers/block/xen-blkback/blkback.c

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -265,17 +265,6 @@ static void put_persistent_gnt(struct xen_blkif *blkif,
265265
atomic_dec(&blkif->persistent_gnt_in_use);
266266
}
267267

268-
static void free_persistent_gnts_unmap_callback(int result,
269-
struct gntab_unmap_queue_data *data)
270-
{
271-
struct completion *c = data->data;
272-
273-
/* BUG_ON used to reproduce existing behaviour,
274-
but is this the best way to deal with this? */
275-
BUG_ON(result);
276-
complete(c);
277-
}
278-
279268
static void free_persistent_gnts(struct xen_blkif *blkif, struct rb_root *root,
280269
unsigned int num)
281270
{
@@ -285,12 +274,7 @@ static void free_persistent_gnts(struct xen_blkif *blkif, struct rb_root *root,
285274
struct rb_node *n;
286275
int segs_to_unmap = 0;
287276
struct gntab_unmap_queue_data unmap_data;
288-
struct completion unmap_completion;
289277

290-
init_completion(&unmap_completion);
291-
292-
unmap_data.data = &unmap_completion;
293-
unmap_data.done = &free_persistent_gnts_unmap_callback;
294278
unmap_data.pages = pages;
295279
unmap_data.unmap_ops = unmap;
296280
unmap_data.kunmap_ops = NULL;
@@ -310,8 +294,7 @@ static void free_persistent_gnts(struct xen_blkif *blkif, struct rb_root *root,
310294
!rb_next(&persistent_gnt->node)) {
311295

312296
unmap_data.count = segs_to_unmap;
313-
gnttab_unmap_refs_async(&unmap_data);
314-
wait_for_completion(&unmap_completion);
297+
BUG_ON(gnttab_unmap_refs_sync(&unmap_data));
315298

316299
put_free_pages(blkif, pages, segs_to_unmap);
317300
segs_to_unmap = 0;
@@ -329,8 +312,13 @@ void xen_blkbk_unmap_purged_grants(struct work_struct *work)
329312
struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
330313
struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST];
331314
struct persistent_gnt *persistent_gnt;
332-
int ret, segs_to_unmap = 0;
315+
int segs_to_unmap = 0;
333316
struct xen_blkif *blkif = container_of(work, typeof(*blkif), persistent_purge_work);
317+
struct gntab_unmap_queue_data unmap_data;
318+
319+
unmap_data.pages = pages;
320+
unmap_data.unmap_ops = unmap;
321+
unmap_data.kunmap_ops = NULL;
334322

335323
while(!list_empty(&blkif->persistent_purge_list)) {
336324
persistent_gnt = list_first_entry(&blkif->persistent_purge_list,
@@ -346,17 +334,16 @@ void xen_blkbk_unmap_purged_grants(struct work_struct *work)
346334
pages[segs_to_unmap] = persistent_gnt->page;
347335

348336
if (++segs_to_unmap == BLKIF_MAX_SEGMENTS_PER_REQUEST) {
349-
ret = gnttab_unmap_refs(unmap, NULL, pages,
350-
segs_to_unmap);
351-
BUG_ON(ret);
337+
unmap_data.count = segs_to_unmap;
338+
BUG_ON(gnttab_unmap_refs_sync(&unmap_data));
352339
put_free_pages(blkif, pages, segs_to_unmap);
353340
segs_to_unmap = 0;
354341
}
355342
kfree(persistent_gnt);
356343
}
357344
if (segs_to_unmap > 0) {
358-
ret = gnttab_unmap_refs(unmap, NULL, pages, segs_to_unmap);
359-
BUG_ON(ret);
345+
unmap_data.count = segs_to_unmap;
346+
BUG_ON(gnttab_unmap_refs_sync(&unmap_data));
360347
put_free_pages(blkif, pages, segs_to_unmap);
361348
}
362349
}

drivers/tty/hvc/hvc_xen.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,27 @@ static int xen_initial_domain_console_init(void)
299299
return 0;
300300
}
301301

302+
static void xen_console_update_evtchn(struct xencons_info *info)
303+
{
304+
if (xen_hvm_domain()) {
305+
uint64_t v;
306+
int err;
307+
308+
err = hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN, &v);
309+
if (!err && v)
310+
info->evtchn = v;
311+
} else
312+
info->evtchn = xen_start_info->console.domU.evtchn;
313+
}
314+
302315
void xen_console_resume(void)
303316
{
304317
struct xencons_info *info = vtermno_to_xencons(HVC_COOKIE);
305-
if (info != NULL && info->irq)
318+
if (info != NULL && info->irq) {
319+
if (!xen_initial_domain())
320+
xen_console_update_evtchn(info);
306321
rebind_evtchn_irq(info->evtchn, info->irq);
322+
}
307323
}
308324

309325
static void xencons_disconnect_backend(struct xencons_info *info)

drivers/xen/events/events_2l.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,15 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)
345345
return IRQ_HANDLED;
346346
}
347347

348+
static void evtchn_2l_resume(void)
349+
{
350+
int i;
351+
352+
for_each_online_cpu(i)
353+
memset(per_cpu(cpu_evtchn_mask, i), 0, sizeof(xen_ulong_t) *
354+
EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD);
355+
}
356+
348357
static const struct evtchn_ops evtchn_ops_2l = {
349358
.max_channels = evtchn_2l_max_channels,
350359
.nr_channels = evtchn_2l_max_channels,
@@ -356,6 +365,7 @@ static const struct evtchn_ops evtchn_ops_2l = {
356365
.mask = evtchn_2l_mask,
357366
.unmask = evtchn_2l_unmask,
358367
.handle_events = evtchn_2l_handle_events,
368+
.resume = evtchn_2l_resume,
359369
};
360370

361371
void __init xen_evtchn_2l_init(void)

drivers/xen/events/events_base.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,8 @@ static unsigned int __startup_pirq(unsigned int irq)
529529
if (rc)
530530
goto err;
531531

532-
bind_evtchn_to_cpu(evtchn, 0);
533532
info->evtchn = evtchn;
533+
bind_evtchn_to_cpu(evtchn, 0);
534534

535535
rc = xen_evtchn_port_setup(info);
536536
if (rc)
@@ -1279,8 +1279,9 @@ void rebind_evtchn_irq(int evtchn, int irq)
12791279

12801280
mutex_unlock(&irq_mapping_update_lock);
12811281

1282-
/* new event channels are always bound to cpu 0 */
1283-
irq_set_affinity(irq, cpumask_of(0));
1282+
bind_evtchn_to_cpu(evtchn, info->cpu);
1283+
/* This will be deferred until interrupt is processed */
1284+
irq_set_affinity(irq, cpumask_of(info->cpu));
12841285

12851286
/* Unmask the event channel. */
12861287
enable_irq(irq);

drivers/xen/gntdev.c

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -327,30 +327,10 @@ static int map_grant_pages(struct grant_map *map)
327327
return err;
328328
}
329329

330-
struct unmap_grant_pages_callback_data
331-
{
332-
struct completion completion;
333-
int result;
334-
};
335-
336-
static void unmap_grant_callback(int result,
337-
struct gntab_unmap_queue_data *data)
338-
{
339-
struct unmap_grant_pages_callback_data* d = data->data;
340-
341-
d->result = result;
342-
complete(&d->completion);
343-
}
344-
345330
static int __unmap_grant_pages(struct grant_map *map, int offset, int pages)
346331
{
347332
int i, err = 0;
348333
struct gntab_unmap_queue_data unmap_data;
349-
struct unmap_grant_pages_callback_data data;
350-
351-
init_completion(&data.completion);
352-
unmap_data.data = &data;
353-
unmap_data.done= &unmap_grant_callback;
354334

355335
if (map->notify.flags & UNMAP_NOTIFY_CLEAR_BYTE) {
356336
int pgno = (map->notify.addr >> PAGE_SHIFT);
@@ -367,11 +347,9 @@ static int __unmap_grant_pages(struct grant_map *map, int offset, int pages)
367347
unmap_data.pages = map->pages + offset;
368348
unmap_data.count = pages;
369349

370-
gnttab_unmap_refs_async(&unmap_data);
371-
372-
wait_for_completion(&data.completion);
373-
if (data.result)
374-
return data.result;
350+
err = gnttab_unmap_refs_sync(&unmap_data);
351+
if (err)
352+
return err;
375353

376354
for (i = 0; i < pages; i++) {
377355
if (map->unmap_ops[offset+i].status)

drivers/xen/grant-table.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ struct gnttab_ops {
123123
int (*query_foreign_access)(grant_ref_t ref);
124124
};
125125

126+
struct unmap_refs_callback_data {
127+
struct completion completion;
128+
int result;
129+
};
130+
126131
static struct gnttab_ops *gnttab_interface;
127132

128133
static int grant_table_version;
@@ -863,6 +868,29 @@ void gnttab_unmap_refs_async(struct gntab_unmap_queue_data* item)
863868
}
864869
EXPORT_SYMBOL_GPL(gnttab_unmap_refs_async);
865870

871+
static void unmap_refs_callback(int result,
872+
struct gntab_unmap_queue_data *data)
873+
{
874+
struct unmap_refs_callback_data *d = data->data;
875+
876+
d->result = result;
877+
complete(&d->completion);
878+
}
879+
880+
int gnttab_unmap_refs_sync(struct gntab_unmap_queue_data *item)
881+
{
882+
struct unmap_refs_callback_data data;
883+
884+
init_completion(&data.completion);
885+
item->data = &data;
886+
item->done = &unmap_refs_callback;
887+
gnttab_unmap_refs_async(item);
888+
wait_for_completion(&data.completion);
889+
890+
return data.result;
891+
}
892+
EXPORT_SYMBOL_GPL(gnttab_unmap_refs_sync);
893+
866894
static int gnttab_map_frames_v1(xen_pfn_t *frames, unsigned int nr_gframes)
867895
{
868896
int rc;

0 commit comments

Comments
 (0)