aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-22 12:40:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-22 12:40:47 -0400
commit0a8abd97dcda50e5d2c893a51733416534e95706 (patch)
tree394b79791f6d9f45d9ac8e16d3f97b7bb5eb29d4
parentd6396a7331dbbe69c7e3fac2ab07b281ffe71fc8 (diff)
parent0555ac4333d7da7cff83d5b06bd3679a3e1ef584 (diff)
Merge tag 'for-linus-4.14b-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes from Juergen Gross: "A fix for a missing __init annotation and two cleanup patches" * tag 'for-linus-4.14b-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen, arm64: drop dummy lookup_address() xen: don't compile pv-specific parts if XEN_PV isn't configured xen: x86: mark xen_find_pt_base as __init
-rw-r--r--arch/x86/xen/mmu_pv.c2
-rw-r--r--drivers/xen/xenbus/xenbus_client.c130
-rw-r--r--include/xen/arm/page.h10
3 files changed, 68 insertions, 74 deletions
diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
index 509f560bd0c6..7330cb3b2283 100644
--- a/arch/x86/xen/mmu_pv.c
+++ b/arch/x86/xen/mmu_pv.c
@@ -2220,7 +2220,7 @@ static void __init xen_write_cr3_init(unsigned long cr3)
2220 * not the first page table in the page table pool. 2220 * not the first page table in the page table pool.
2221 * Iterate through the initial page tables to find the real page table base. 2221 * Iterate through the initial page tables to find the real page table base.
2222 */ 2222 */
2223static phys_addr_t xen_find_pt_base(pmd_t *pmd) 2223static phys_addr_t __init xen_find_pt_base(pmd_t *pmd)
2224{ 2224{
2225 phys_addr_t pt_base, paddr; 2225 phys_addr_t pt_base, paddr;
2226 unsigned pmdidx; 2226 unsigned pmdidx;
diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
index 82a8866758ee..a1c17000129b 100644
--- a/drivers/xen/xenbus/xenbus_client.c
+++ b/drivers/xen/xenbus/xenbus_client.c
@@ -519,64 +519,6 @@ static int __xenbus_map_ring(struct xenbus_device *dev,
519 return err; 519 return err;
520} 520}
521 521
522static int xenbus_map_ring_valloc_pv(struct xenbus_device *dev,
523 grant_ref_t *gnt_refs,
524 unsigned int nr_grefs,
525 void **vaddr)
526{
527 struct xenbus_map_node *node;
528 struct vm_struct *area;
529 pte_t *ptes[XENBUS_MAX_RING_GRANTS];
530 phys_addr_t phys_addrs[XENBUS_MAX_RING_GRANTS];
531 int err = GNTST_okay;
532 int i;
533 bool leaked;
534
535 *vaddr = NULL;
536
537 if (nr_grefs > XENBUS_MAX_RING_GRANTS)
538 return -EINVAL;
539
540 node = kzalloc(sizeof(*node), GFP_KERNEL);
541 if (!node)
542 return -ENOMEM;
543
544 area = alloc_vm_area(XEN_PAGE_SIZE * nr_grefs, ptes);
545 if (!area) {
546 kfree(node);
547 return -ENOMEM;
548 }
549
550 for (i = 0; i < nr_grefs; i++)
551 phys_addrs[i] = arbitrary_virt_to_machine(ptes[i]).maddr;
552
553 err = __xenbus_map_ring(dev, gnt_refs, nr_grefs, node->handles,
554 phys_addrs,
555 GNTMAP_host_map | GNTMAP_contains_pte,
556 &leaked);
557 if (err)
558 goto failed;
559
560 node->nr_handles = nr_grefs;
561 node->pv.area = area;
562
563 spin_lock(&xenbus_valloc_lock);
564 list_add(&node->next, &xenbus_valloc_pages);
565 spin_unlock(&xenbus_valloc_lock);
566
567 *vaddr = area->addr;
568 return 0;
569
570failed:
571 if (!leaked)
572 free_vm_area(area);
573 else
574 pr_alert("leaking VM area %p size %u page(s)", area, nr_grefs);
575
576 kfree(node);
577 return err;
578}
579
580struct map_ring_valloc_hvm 522struct map_ring_valloc_hvm
581{ 523{
582 unsigned int idx; 524 unsigned int idx;
@@ -725,6 +667,65 @@ int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
725} 667}
726EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree); 668EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
727 669
670#ifdef CONFIG_XEN_PV
671static int xenbus_map_ring_valloc_pv(struct xenbus_device *dev,
672 grant_ref_t *gnt_refs,
673 unsigned int nr_grefs,
674 void **vaddr)
675{
676 struct xenbus_map_node *node;
677 struct vm_struct *area;
678 pte_t *ptes[XENBUS_MAX_RING_GRANTS];
679 phys_addr_t phys_addrs[XENBUS_MAX_RING_GRANTS];
680 int err = GNTST_okay;
681 int i;
682 bool leaked;
683
684 *vaddr = NULL;
685
686 if (nr_grefs > XENBUS_MAX_RING_GRANTS)
687 return -EINVAL;
688
689 node = kzalloc(sizeof(*node), GFP_KERNEL);
690 if (!node)
691 return -ENOMEM;
692
693 area = alloc_vm_area(XEN_PAGE_SIZE * nr_grefs, ptes);
694 if (!area) {
695 kfree(node);
696 return -ENOMEM;
697 }
698
699 for (i = 0; i < nr_grefs; i++)
700 phys_addrs[i] = arbitrary_virt_to_machine(ptes[i]).maddr;
701
702 err = __xenbus_map_ring(dev, gnt_refs, nr_grefs, node->handles,
703 phys_addrs,
704 GNTMAP_host_map | GNTMAP_contains_pte,
705 &leaked);
706 if (err)
707 goto failed;
708
709 node->nr_handles = nr_grefs;
710 node->pv.area = area;
711
712 spin_lock(&xenbus_valloc_lock);
713 list_add(&node->next, &xenbus_valloc_pages);
714 spin_unlock(&xenbus_valloc_lock);
715
716 *vaddr = area->addr;
717 return 0;
718
719failed:
720 if (!leaked)
721 free_vm_area(area);
722 else
723 pr_alert("leaking VM area %p size %u page(s)", area, nr_grefs);
724
725 kfree(node);
726 return err;
727}
728
728static int xenbus_unmap_ring_vfree_pv(struct xenbus_device *dev, void *vaddr) 729static int xenbus_unmap_ring_vfree_pv(struct xenbus_device *dev, void *vaddr)
729{ 730{
730 struct xenbus_map_node *node; 731 struct xenbus_map_node *node;
@@ -788,6 +789,12 @@ static int xenbus_unmap_ring_vfree_pv(struct xenbus_device *dev, void *vaddr)
788 return err; 789 return err;
789} 790}
790 791
792static const struct xenbus_ring_ops ring_ops_pv = {
793 .map = xenbus_map_ring_valloc_pv,
794 .unmap = xenbus_unmap_ring_vfree_pv,
795};
796#endif
797
791struct unmap_ring_vfree_hvm 798struct unmap_ring_vfree_hvm
792{ 799{
793 unsigned int idx; 800 unsigned int idx;
@@ -916,11 +923,6 @@ enum xenbus_state xenbus_read_driver_state(const char *path)
916} 923}
917EXPORT_SYMBOL_GPL(xenbus_read_driver_state); 924EXPORT_SYMBOL_GPL(xenbus_read_driver_state);
918 925
919static const struct xenbus_ring_ops ring_ops_pv = {
920 .map = xenbus_map_ring_valloc_pv,
921 .unmap = xenbus_unmap_ring_vfree_pv,
922};
923
924static const struct xenbus_ring_ops ring_ops_hvm = { 926static const struct xenbus_ring_ops ring_ops_hvm = {
925 .map = xenbus_map_ring_valloc_hvm, 927 .map = xenbus_map_ring_valloc_hvm,
926 .unmap = xenbus_unmap_ring_vfree_hvm, 928 .unmap = xenbus_unmap_ring_vfree_hvm,
@@ -928,8 +930,10 @@ static const struct xenbus_ring_ops ring_ops_hvm = {
928 930
929void __init xenbus_ring_ops_init(void) 931void __init xenbus_ring_ops_init(void)
930{ 932{
933#ifdef CONFIG_XEN_PV
931 if (!xen_feature(XENFEAT_auto_translated_physmap)) 934 if (!xen_feature(XENFEAT_auto_translated_physmap))
932 ring_ops = &ring_ops_pv; 935 ring_ops = &ring_ops_pv;
933 else 936 else
937#endif
934 ring_ops = &ring_ops_hvm; 938 ring_ops = &ring_ops_hvm;
935} 939}
diff --git a/include/xen/arm/page.h b/include/xen/arm/page.h
index 415dbc6e43fd..6adc2a955340 100644
--- a/include/xen/arm/page.h
+++ b/include/xen/arm/page.h
@@ -84,16 +84,6 @@ static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
84 BUG(); 84 BUG();
85} 85}
86 86
87/* TODO: this shouldn't be here but it is because the frontend drivers
88 * are using it (its rolled in headers) even though we won't hit the code path.
89 * So for right now just punt with this.
90 */
91static inline pte_t *lookup_address(unsigned long address, unsigned int *level)
92{
93 BUG();
94 return NULL;
95}
96
97extern int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops, 87extern int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
98 struct gnttab_map_grant_ref *kmap_ops, 88 struct gnttab_map_grant_ref *kmap_ops,
99 struct page **pages, unsigned int count); 89 struct page **pages, unsigned int count);