diff options
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/gntdev.c | 13 | ||||
-rw-r--r-- | drivers/xen/grant-table.c | 89 |
2 files changed, 18 insertions, 84 deletions
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index 34a2704fbc88..073b4a19a8b0 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c | |||
@@ -284,10 +284,8 @@ static int map_grant_pages(struct grant_map *map) | |||
284 | } | 284 | } |
285 | 285 | ||
286 | pr_debug("map %d+%d\n", map->index, map->count); | 286 | pr_debug("map %d+%d\n", map->index, map->count); |
287 | err = gnttab_map_refs_userspace(map->map_ops, | 287 | err = gnttab_map_refs(map->map_ops, use_ptemod ? map->kmap_ops : NULL, |
288 | use_ptemod ? map->kmap_ops : NULL, | 288 | map->pages, map->count); |
289 | map->pages, | ||
290 | map->count); | ||
291 | if (err) | 289 | if (err) |
292 | return err; | 290 | return err; |
293 | 291 | ||
@@ -317,10 +315,9 @@ static int __unmap_grant_pages(struct grant_map *map, int offset, int pages) | |||
317 | } | 315 | } |
318 | } | 316 | } |
319 | 317 | ||
320 | err = gnttab_unmap_refs_userspace(map->unmap_ops + offset, | 318 | err = gnttab_unmap_refs(map->unmap_ops + offset, |
321 | use_ptemod ? map->kmap_ops + offset : NULL, | 319 | use_ptemod ? map->kmap_ops + offset : NULL, map->pages + offset, |
322 | map->pages + offset, | 320 | pages); |
323 | pages); | ||
324 | if (err) | 321 | if (err) |
325 | return err; | 322 | return err; |
326 | 323 | ||
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 8ee13e2e45e2..b84e3ab839aa 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c | |||
@@ -928,17 +928,15 @@ void gnttab_batch_copy(struct gnttab_copy *batch, unsigned count) | |||
928 | } | 928 | } |
929 | EXPORT_SYMBOL_GPL(gnttab_batch_copy); | 929 | EXPORT_SYMBOL_GPL(gnttab_batch_copy); |
930 | 930 | ||
931 | int __gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | 931 | int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, |
932 | struct gnttab_map_grant_ref *kmap_ops, | 932 | struct gnttab_map_grant_ref *kmap_ops, |
933 | struct page **pages, unsigned int count, | 933 | struct page **pages, unsigned int count) |
934 | bool m2p_override) | ||
935 | { | 934 | { |
936 | int i, ret; | 935 | int i, ret; |
937 | bool lazy = false; | 936 | bool lazy = false; |
938 | pte_t *pte; | 937 | pte_t *pte; |
939 | unsigned long mfn, pfn; | 938 | unsigned long mfn; |
940 | 939 | ||
941 | BUG_ON(kmap_ops && !m2p_override); | ||
942 | ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map_ops, count); | 940 | ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map_ops, count); |
943 | if (ret) | 941 | if (ret) |
944 | return ret; | 942 | return ret; |
@@ -957,12 +955,10 @@ int __gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | |||
957 | set_phys_to_machine(map_ops[i].host_addr >> PAGE_SHIFT, | 955 | set_phys_to_machine(map_ops[i].host_addr >> PAGE_SHIFT, |
958 | map_ops[i].dev_bus_addr >> PAGE_SHIFT); | 956 | map_ops[i].dev_bus_addr >> PAGE_SHIFT); |
959 | } | 957 | } |
960 | return 0; | 958 | return ret; |
961 | } | 959 | } |
962 | 960 | ||
963 | if (m2p_override && | 961 | if (!in_interrupt() && paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE) { |
964 | !in_interrupt() && | ||
965 | paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE) { | ||
966 | arch_enter_lazy_mmu_mode(); | 962 | arch_enter_lazy_mmu_mode(); |
967 | lazy = true; | 963 | lazy = true; |
968 | } | 964 | } |
@@ -979,20 +975,8 @@ int __gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | |||
979 | } else { | 975 | } else { |
980 | mfn = PFN_DOWN(map_ops[i].dev_bus_addr); | 976 | mfn = PFN_DOWN(map_ops[i].dev_bus_addr); |
981 | } | 977 | } |
982 | pfn = page_to_pfn(pages[i]); | 978 | ret = m2p_add_override(mfn, pages[i], kmap_ops ? |
983 | 979 | &kmap_ops[i] : NULL); | |
984 | WARN_ON(PagePrivate(pages[i])); | ||
985 | SetPagePrivate(pages[i]); | ||
986 | set_page_private(pages[i], mfn); | ||
987 | |||
988 | pages[i]->index = pfn_to_mfn(pfn); | ||
989 | if (unlikely(!set_phys_to_machine(pfn, FOREIGN_FRAME(mfn)))) { | ||
990 | ret = -ENOMEM; | ||
991 | goto out; | ||
992 | } | ||
993 | if (m2p_override) | ||
994 | ret = m2p_add_override(mfn, pages[i], kmap_ops ? | ||
995 | &kmap_ops[i] : NULL); | ||
996 | if (ret) | 980 | if (ret) |
997 | goto out; | 981 | goto out; |
998 | } | 982 | } |
@@ -1003,32 +987,15 @@ int __gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | |||
1003 | 987 | ||
1004 | return ret; | 988 | return ret; |
1005 | } | 989 | } |
1006 | |||
1007 | int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | ||
1008 | struct page **pages, unsigned int count) | ||
1009 | { | ||
1010 | return __gnttab_map_refs(map_ops, NULL, pages, count, false); | ||
1011 | } | ||
1012 | EXPORT_SYMBOL_GPL(gnttab_map_refs); | 990 | EXPORT_SYMBOL_GPL(gnttab_map_refs); |
1013 | 991 | ||
1014 | int gnttab_map_refs_userspace(struct gnttab_map_grant_ref *map_ops, | 992 | int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, |
1015 | struct gnttab_map_grant_ref *kmap_ops, | ||
1016 | struct page **pages, unsigned int count) | ||
1017 | { | ||
1018 | return __gnttab_map_refs(map_ops, kmap_ops, pages, count, true); | ||
1019 | } | ||
1020 | EXPORT_SYMBOL_GPL(gnttab_map_refs_userspace); | ||
1021 | |||
1022 | int __gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, | ||
1023 | struct gnttab_map_grant_ref *kmap_ops, | 993 | struct gnttab_map_grant_ref *kmap_ops, |
1024 | struct page **pages, unsigned int count, | 994 | struct page **pages, unsigned int count) |
1025 | bool m2p_override) | ||
1026 | { | 995 | { |
1027 | int i, ret; | 996 | int i, ret; |
1028 | bool lazy = false; | 997 | bool lazy = false; |
1029 | unsigned long pfn, mfn; | ||
1030 | 998 | ||
1031 | BUG_ON(kmap_ops && !m2p_override); | ||
1032 | ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap_ops, count); | 999 | ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap_ops, count); |
1033 | if (ret) | 1000 | if (ret) |
1034 | return ret; | 1001 | return ret; |
@@ -1039,33 +1006,17 @@ int __gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, | |||
1039 | set_phys_to_machine(unmap_ops[i].host_addr >> PAGE_SHIFT, | 1006 | set_phys_to_machine(unmap_ops[i].host_addr >> PAGE_SHIFT, |
1040 | INVALID_P2M_ENTRY); | 1007 | INVALID_P2M_ENTRY); |
1041 | } | 1008 | } |
1042 | return 0; | 1009 | return ret; |
1043 | } | 1010 | } |
1044 | 1011 | ||
1045 | if (m2p_override && | 1012 | if (!in_interrupt() && paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE) { |
1046 | !in_interrupt() && | ||
1047 | paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE) { | ||
1048 | arch_enter_lazy_mmu_mode(); | 1013 | arch_enter_lazy_mmu_mode(); |
1049 | lazy = true; | 1014 | lazy = true; |
1050 | } | 1015 | } |
1051 | 1016 | ||
1052 | for (i = 0; i < count; i++) { | 1017 | for (i = 0; i < count; i++) { |
1053 | pfn = page_to_pfn(pages[i]); | 1018 | ret = m2p_remove_override(pages[i], kmap_ops ? |
1054 | mfn = get_phys_to_machine(pfn); | 1019 | &kmap_ops[i] : NULL); |
1055 | if (mfn == INVALID_P2M_ENTRY || !(mfn & FOREIGN_FRAME_BIT)) { | ||
1056 | ret = -EINVAL; | ||
1057 | goto out; | ||
1058 | } | ||
1059 | |||
1060 | set_page_private(pages[i], INVALID_P2M_ENTRY); | ||
1061 | WARN_ON(!PagePrivate(pages[i])); | ||
1062 | ClearPagePrivate(pages[i]); | ||
1063 | set_phys_to_machine(pfn, pages[i]->index); | ||
1064 | if (m2p_override) | ||
1065 | ret = m2p_remove_override(pages[i], | ||
1066 | kmap_ops ? | ||
1067 | &kmap_ops[i] : NULL, | ||
1068 | mfn); | ||
1069 | if (ret) | 1020 | if (ret) |
1070 | goto out; | 1021 | goto out; |
1071 | } | 1022 | } |
@@ -1076,22 +1027,8 @@ int __gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, | |||
1076 | 1027 | ||
1077 | return ret; | 1028 | return ret; |
1078 | } | 1029 | } |
1079 | |||
1080 | int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *map_ops, | ||
1081 | struct page **pages, unsigned int count) | ||
1082 | { | ||
1083 | return __gnttab_unmap_refs(map_ops, NULL, pages, count, false); | ||
1084 | } | ||
1085 | EXPORT_SYMBOL_GPL(gnttab_unmap_refs); | 1030 | EXPORT_SYMBOL_GPL(gnttab_unmap_refs); |
1086 | 1031 | ||
1087 | int gnttab_unmap_refs_userspace(struct gnttab_unmap_grant_ref *map_ops, | ||
1088 | struct gnttab_map_grant_ref *kmap_ops, | ||
1089 | struct page **pages, unsigned int count) | ||
1090 | { | ||
1091 | return __gnttab_unmap_refs(map_ops, kmap_ops, pages, count, true); | ||
1092 | } | ||
1093 | EXPORT_SYMBOL_GPL(gnttab_unmap_refs_userspace); | ||
1094 | |||
1095 | static unsigned nr_status_frames(unsigned nr_grant_frames) | 1032 | static unsigned nr_status_frames(unsigned nr_grant_frames) |
1096 | { | 1033 | { |
1097 | BUG_ON(grefs_per_grant_frame == 0); | 1034 | BUG_ON(grefs_per_grant_frame == 0); |