aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/grant-table.c
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2014-02-03 06:43:59 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2014-02-03 06:44:49 -0500
commite85fc9805591a17ca8af50023ee8e2b61d9a123b (patch)
tree95fbacb38701217f001adefa0abe6f8b65c5ce84 /drivers/xen/grant-table.c
parentf93576e1ac34fd7a93d6f3432e71295bbe6a27ce (diff)
Revert "xen/grant-table: Avoid m2p_override during mapping"
This reverts commit 08ece5bb2312b4510b161a6ef6682f37f4eac8a1. As it breaks ARM builds and needs more attention on the ARM side. Acked-by: David Vrabel <david.vrabel@citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen/grant-table.c')
-rw-r--r--drivers/xen/grant-table.c89
1 files changed, 13 insertions, 76 deletions
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}
929EXPORT_SYMBOL_GPL(gnttab_batch_copy); 929EXPORT_SYMBOL_GPL(gnttab_batch_copy);
930 930
931int __gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, 931int 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
1007int 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}
1012EXPORT_SYMBOL_GPL(gnttab_map_refs); 990EXPORT_SYMBOL_GPL(gnttab_map_refs);
1013 991
1014int gnttab_map_refs_userspace(struct gnttab_map_grant_ref *map_ops, 992int 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}
1020EXPORT_SYMBOL_GPL(gnttab_map_refs_userspace);
1021
1022int __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
1080int 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}
1085EXPORT_SYMBOL_GPL(gnttab_unmap_refs); 1030EXPORT_SYMBOL_GPL(gnttab_unmap_refs);
1086 1031
1087int 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}
1093EXPORT_SYMBOL_GPL(gnttab_unmap_refs_userspace);
1094
1095static unsigned nr_status_frames(unsigned nr_grant_frames) 1032static 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);