Skip to content

Commit 4203d0e

Browse files
committed
Merge tag 'stable/for-linus-3.13-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull Xen bugfixes from Konrad Rzeszutek Wilk: - Fix balloon driver for auto-translate guests (PVHVM, ARM) to not use scratch pages. - Fix block API header for ARM32 and ARM64 to have proper layout - On ARM when mapping guests, stick on PTE_SPECIAL - When using SWIOTLB under ARM, don't call swiotlb functions twice - When unmapping guests memory and if we fail, don't return pages which failed to be unmapped. - Grant driver was using the wrong address on ARM. * tag 'stable/for-linus-3.13-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/balloon: Seperate the auto-translate logic properly (v2) xen/block: Correctly define structures in public headers on ARM32 and ARM64 arm: xen: foreign mapping PTEs are special. xen/arm64: do not call the swiotlb functions twice xen: privcmd: do not return pages which we have failed to unmap XEN: Grant table address, xen_hvm_resume_frames, is a phys_addr not a pfn
2 parents 5263f0a + c1d15f5 commit 4203d0e

File tree

6 files changed

+51
-44
lines changed

6 files changed

+51
-44
lines changed

arch/arm/xen/enlighten.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static int remap_pte_fn(pte_t *ptep, pgtable_t token, unsigned long addr,
9696
struct remap_data *info = data;
9797
struct page *page = info->pages[info->index++];
9898
unsigned long pfn = page_to_pfn(page);
99-
pte_t pte = pfn_pte(pfn, info->prot);
99+
pte_t pte = pte_mkspecial(pfn_pte(pfn, info->prot));
100100

101101
if (map_foreign_page(pfn, info->fgmfn, info->domid))
102102
return -EFAULT;
@@ -224,10 +224,10 @@ static int __init xen_guest_init(void)
224224
}
225225
if (of_address_to_resource(node, GRANT_TABLE_PHYSADDR, &res))
226226
return 0;
227-
xen_hvm_resume_frames = res.start >> PAGE_SHIFT;
227+
xen_hvm_resume_frames = res.start;
228228
xen_events_irq = irq_of_parse_and_map(node, 0);
229229
pr_info("Xen %s support found, events_irq=%d gnttab_frame_pfn=%lx\n",
230-
version, xen_events_irq, xen_hvm_resume_frames);
230+
version, xen_events_irq, (xen_hvm_resume_frames >> PAGE_SHIFT));
231231
xen_domain_type = XEN_HVM_DOMAIN;
232232

233233
xen_setup_features();

arch/arm64/include/asm/xen/page-coherent.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,21 @@ static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
2323
unsigned long offset, size_t size, enum dma_data_direction dir,
2424
struct dma_attrs *attrs)
2525
{
26-
__generic_dma_ops(hwdev)->map_page(hwdev, page, offset, size, dir, attrs);
2726
}
2827

2928
static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
3029
size_t size, enum dma_data_direction dir,
3130
struct dma_attrs *attrs)
3231
{
33-
__generic_dma_ops(hwdev)->unmap_page(hwdev, handle, size, dir, attrs);
3432
}
3533

3634
static inline void xen_dma_sync_single_for_cpu(struct device *hwdev,
3735
dma_addr_t handle, size_t size, enum dma_data_direction dir)
3836
{
39-
__generic_dma_ops(hwdev)->sync_single_for_cpu(hwdev, handle, size, dir);
4037
}
4138

4239
static inline void xen_dma_sync_single_for_device(struct device *hwdev,
4340
dma_addr_t handle, size_t size, enum dma_data_direction dir)
4441
{
45-
__generic_dma_ops(hwdev)->sync_single_for_device(hwdev, handle, size, dir);
4642
}
4743
#endif /* _ASM_ARM64_XEN_PAGE_COHERENT_H */

drivers/xen/balloon.c

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,19 @@ static enum bp_state increase_reservation(unsigned long nr_pages)
350350

351351
pfn = page_to_pfn(page);
352352

353-
set_phys_to_machine(pfn, frame_list[i]);
354-
355353
#ifdef CONFIG_XEN_HAVE_PVMMU
356-
/* Link back into the page tables if not highmem. */
357-
if (xen_pv_domain() && !PageHighMem(page)) {
358-
int ret;
359-
ret = HYPERVISOR_update_va_mapping(
360-
(unsigned long)__va(pfn << PAGE_SHIFT),
361-
mfn_pte(frame_list[i], PAGE_KERNEL),
362-
0);
363-
BUG_ON(ret);
354+
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
355+
set_phys_to_machine(pfn, frame_list[i]);
356+
357+
/* Link back into the page tables if not highmem. */
358+
if (!PageHighMem(page)) {
359+
int ret;
360+
ret = HYPERVISOR_update_va_mapping(
361+
(unsigned long)__va(pfn << PAGE_SHIFT),
362+
mfn_pte(frame_list[i], PAGE_KERNEL),
363+
0);
364+
BUG_ON(ret);
365+
}
364366
}
365367
#endif
366368

@@ -378,7 +380,6 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
378380
enum bp_state state = BP_DONE;
379381
unsigned long pfn, i;
380382
struct page *page;
381-
struct page *scratch_page;
382383
int ret;
383384
struct xen_memory_reservation reservation = {
384385
.address_bits = 0,
@@ -411,27 +412,29 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
411412

412413
scrub_page(page);
413414

415+
#ifdef CONFIG_XEN_HAVE_PVMMU
414416
/*
415417
* Ballooned out frames are effectively replaced with
416418
* a scratch frame. Ensure direct mappings and the
417419
* p2m are consistent.
418420
*/
419-
scratch_page = get_balloon_scratch_page();
420-
#ifdef CONFIG_XEN_HAVE_PVMMU
421-
if (xen_pv_domain() && !PageHighMem(page)) {
422-
ret = HYPERVISOR_update_va_mapping(
423-
(unsigned long)__va(pfn << PAGE_SHIFT),
424-
pfn_pte(page_to_pfn(scratch_page),
425-
PAGE_KERNEL_RO), 0);
426-
BUG_ON(ret);
427-
}
428-
#endif
429421
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
430422
unsigned long p;
423+
struct page *scratch_page = get_balloon_scratch_page();
424+
425+
if (!PageHighMem(page)) {
426+
ret = HYPERVISOR_update_va_mapping(
427+
(unsigned long)__va(pfn << PAGE_SHIFT),
428+
pfn_pte(page_to_pfn(scratch_page),
429+
PAGE_KERNEL_RO), 0);
430+
BUG_ON(ret);
431+
}
431432
p = page_to_pfn(scratch_page);
432433
__set_phys_to_machine(pfn, pfn_to_mfn(p));
434+
435+
put_balloon_scratch_page();
433436
}
434-
put_balloon_scratch_page();
437+
#endif
435438

436439
balloon_append(pfn_to_page(pfn));
437440
}
@@ -627,15 +630,17 @@ static int __init balloon_init(void)
627630
if (!xen_domain())
628631
return -ENODEV;
629632

630-
for_each_online_cpu(cpu)
631-
{
632-
per_cpu(balloon_scratch_page, cpu) = alloc_page(GFP_KERNEL);
633-
if (per_cpu(balloon_scratch_page, cpu) == NULL) {
634-
pr_warn("Failed to allocate balloon_scratch_page for cpu %d\n", cpu);
635-
return -ENOMEM;
633+
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
634+
for_each_online_cpu(cpu)
635+
{
636+
per_cpu(balloon_scratch_page, cpu) = alloc_page(GFP_KERNEL);
637+
if (per_cpu(balloon_scratch_page, cpu) == NULL) {
638+
pr_warn("Failed to allocate balloon_scratch_page for cpu %d\n", cpu);
639+
return -ENOMEM;
640+
}
636641
}
642+
register_cpu_notifier(&balloon_cpu_notifier);
637643
}
638-
register_cpu_notifier(&balloon_cpu_notifier);
639644

640645
pr_info("Initialising balloon driver\n");
641646

drivers/xen/grant-table.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,8 @@ static int gnttab_setup(void)
11761176
gnttab_shared.addr = xen_remap(xen_hvm_resume_frames,
11771177
PAGE_SIZE * max_nr_gframes);
11781178
if (gnttab_shared.addr == NULL) {
1179-
pr_warn("Failed to ioremap gnttab share frames!\n");
1179+
pr_warn("Failed to ioremap gnttab share frames (addr=0x%08lx)!\n",
1180+
xen_hvm_resume_frames);
11801181
return -ENOMEM;
11811182
}
11821183
}

drivers/xen/privcmd.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,12 +533,17 @@ static void privcmd_close(struct vm_area_struct *vma)
533533
{
534534
struct page **pages = vma->vm_private_data;
535535
int numpgs = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
536+
int rc;
536537

537538
if (!xen_feature(XENFEAT_auto_translated_physmap) || !numpgs || !pages)
538539
return;
539540

540-
xen_unmap_domain_mfn_range(vma, numpgs, pages);
541-
free_xenballooned_pages(numpgs, pages);
541+
rc = xen_unmap_domain_mfn_range(vma, numpgs, pages);
542+
if (rc == 0)
543+
free_xenballooned_pages(numpgs, pages);
544+
else
545+
pr_crit("unable to unmap MFN range: leaking %d pages. rc=%d\n",
546+
numpgs, rc);
542547
kfree(pages);
543548
}
544549

include/xen/interface/io/blkif.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ struct blkif_request_segment_aligned {
146146
struct blkif_request_rw {
147147
uint8_t nr_segments; /* number of segments */
148148
blkif_vdev_t handle; /* only for read/write requests */
149-
#ifdef CONFIG_X86_64
149+
#ifndef CONFIG_X86_32
150150
uint32_t _pad1; /* offsetof(blkif_request,u.rw.id) == 8 */
151151
#endif
152152
uint64_t id; /* private guest value, echoed in resp */
@@ -163,7 +163,7 @@ struct blkif_request_discard {
163163
uint8_t flag; /* BLKIF_DISCARD_SECURE or zero. */
164164
#define BLKIF_DISCARD_SECURE (1<<0) /* ignored if discard-secure=0 */
165165
blkif_vdev_t _pad1; /* only for read/write requests */
166-
#ifdef CONFIG_X86_64
166+
#ifndef CONFIG_X86_32
167167
uint32_t _pad2; /* offsetof(blkif_req..,u.discard.id)==8*/
168168
#endif
169169
uint64_t id; /* private guest value, echoed in resp */
@@ -175,7 +175,7 @@ struct blkif_request_discard {
175175
struct blkif_request_other {
176176
uint8_t _pad1;
177177
blkif_vdev_t _pad2; /* only for read/write requests */
178-
#ifdef CONFIG_X86_64
178+
#ifndef CONFIG_X86_32
179179
uint32_t _pad3; /* offsetof(blkif_req..,u.other.id)==8*/
180180
#endif
181181
uint64_t id; /* private guest value, echoed in resp */
@@ -184,15 +184,15 @@ struct blkif_request_other {
184184
struct blkif_request_indirect {
185185
uint8_t indirect_op;
186186
uint16_t nr_segments;
187-
#ifdef CONFIG_X86_64
187+
#ifndef CONFIG_X86_32
188188
uint32_t _pad1; /* offsetof(blkif_...,u.indirect.id) == 8 */
189189
#endif
190190
uint64_t id;
191191
blkif_sector_t sector_number;
192192
blkif_vdev_t handle;
193193
uint16_t _pad2;
194194
grant_ref_t indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];
195-
#ifdef CONFIG_X86_64
195+
#ifndef CONFIG_X86_32
196196
uint32_t _pad3; /* make it 64 byte aligned */
197197
#else
198198
uint64_t _pad3; /* make it 64 byte aligned */

0 commit comments

Comments
 (0)