aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/pgtable_64.h1
-rw-r--r--arch/x86/xen/mmu.c27
-rw-r--r--drivers/xen/balloon.c4
-rw-r--r--drivers/xen/gntalloc.c16
-rw-r--r--drivers/xen/manage.c7
5 files changed, 22 insertions, 33 deletions
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index 5be9063545d2..3874693c0e53 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -19,6 +19,7 @@ extern pud_t level3_ident_pgt[512];
19extern pmd_t level2_kernel_pgt[512]; 19extern pmd_t level2_kernel_pgt[512];
20extern pmd_t level2_fixmap_pgt[512]; 20extern pmd_t level2_fixmap_pgt[512];
21extern pmd_t level2_ident_pgt[512]; 21extern pmd_t level2_ident_pgt[512];
22extern pte_t level1_fixmap_pgt[512];
22extern pgd_t init_level4_pgt[]; 23extern pgd_t init_level4_pgt[];
23 24
24#define swapper_pg_dir init_level4_pgt 25#define swapper_pg_dir init_level4_pgt
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index e8a1201c3293..16fb0099b7f2 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -1866,12 +1866,11 @@ static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
1866 * 1866 *
1867 * We can construct this by grafting the Xen provided pagetable into 1867 * We can construct this by grafting the Xen provided pagetable into
1868 * head_64.S's preconstructed pagetables. We copy the Xen L2's into 1868 * head_64.S's preconstructed pagetables. We copy the Xen L2's into
1869 * level2_ident_pgt, level2_kernel_pgt and level2_fixmap_pgt. This 1869 * level2_ident_pgt, and level2_kernel_pgt. This means that only the
1870 * means that only the kernel has a physical mapping to start with - 1870 * kernel has a physical mapping to start with - but that's enough to
1871 * but that's enough to get __va working. We need to fill in the rest 1871 * get __va working. We need to fill in the rest of the physical
1872 * of the physical mapping once some sort of allocator has been set 1872 * mapping once some sort of allocator has been set up. NOTE: for
1873 * up. 1873 * PVH, the page tables are native.
1874 * NOTE: for PVH, the page tables are native.
1875 */ 1874 */
1876void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn) 1875void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
1877{ 1876{
@@ -1902,8 +1901,11 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
1902 /* L3_i[0] -> level2_ident_pgt */ 1901 /* L3_i[0] -> level2_ident_pgt */
1903 convert_pfn_mfn(level3_ident_pgt); 1902 convert_pfn_mfn(level3_ident_pgt);
1904 /* L3_k[510] -> level2_kernel_pgt 1903 /* L3_k[510] -> level2_kernel_pgt
1905 * L3_i[511] -> level2_fixmap_pgt */ 1904 * L3_k[511] -> level2_fixmap_pgt */
1906 convert_pfn_mfn(level3_kernel_pgt); 1905 convert_pfn_mfn(level3_kernel_pgt);
1906
1907 /* L3_k[511][506] -> level1_fixmap_pgt */
1908 convert_pfn_mfn(level2_fixmap_pgt);
1907 } 1909 }
1908 /* We get [511][511] and have Xen's version of level2_kernel_pgt */ 1910 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
1909 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd); 1911 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
@@ -1913,21 +1915,15 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
1913 addr[1] = (unsigned long)l3; 1915 addr[1] = (unsigned long)l3;
1914 addr[2] = (unsigned long)l2; 1916 addr[2] = (unsigned long)l2;
1915 /* Graft it onto L4[272][0]. Note that we creating an aliasing problem: 1917 /* Graft it onto L4[272][0]. Note that we creating an aliasing problem:
1916 * Both L4[272][0] and L4[511][511] have entries that point to the same 1918 * Both L4[272][0] and L4[511][510] have entries that point to the same
1917 * L2 (PMD) tables. Meaning that if you modify it in __va space 1919 * L2 (PMD) tables. Meaning that if you modify it in __va space
1918 * it will be also modified in the __ka space! (But if you just 1920 * it will be also modified in the __ka space! (But if you just
1919 * modify the PMD table to point to other PTE's or none, then you 1921 * modify the PMD table to point to other PTE's or none, then you
1920 * are OK - which is what cleanup_highmap does) */ 1922 * are OK - which is what cleanup_highmap does) */
1921 copy_page(level2_ident_pgt, l2); 1923 copy_page(level2_ident_pgt, l2);
1922 /* Graft it onto L4[511][511] */ 1924 /* Graft it onto L4[511][510] */
1923 copy_page(level2_kernel_pgt, l2); 1925 copy_page(level2_kernel_pgt, l2);
1924 1926
1925 /* Get [511][510] and graft that in level2_fixmap_pgt */
1926 l3 = m2v(pgd[pgd_index(__START_KERNEL_map + PMD_SIZE)].pgd);
1927 l2 = m2v(l3[pud_index(__START_KERNEL_map + PMD_SIZE)].pud);
1928 copy_page(level2_fixmap_pgt, l2);
1929 /* Note that we don't do anything with level1_fixmap_pgt which
1930 * we don't need. */
1931 if (!xen_feature(XENFEAT_auto_translated_physmap)) { 1927 if (!xen_feature(XENFEAT_auto_translated_physmap)) {
1932 /* Make pagetable pieces RO */ 1928 /* Make pagetable pieces RO */
1933 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO); 1929 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
@@ -1937,6 +1933,7 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
1937 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO); 1933 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
1938 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO); 1934 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
1939 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO); 1935 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
1936 set_page_prot(level1_fixmap_pgt, PAGE_KERNEL_RO);
1940 1937
1941 /* Pin down new L4 */ 1938 /* Pin down new L4 */
1942 pin_pagetable_pfn(MMUEXT_PIN_L4_TABLE, 1939 pin_pagetable_pfn(MMUEXT_PIN_L4_TABLE,
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 5c660c77f03b..1e0a317d3dcd 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -230,8 +230,8 @@ static enum bp_state reserve_additional_memory(long credit)
230 rc = add_memory(nid, hotplug_start_paddr, balloon_hotplug << PAGE_SHIFT); 230 rc = add_memory(nid, hotplug_start_paddr, balloon_hotplug << PAGE_SHIFT);
231 231
232 if (rc) { 232 if (rc) {
233 pr_info("%s: add_memory() failed: %i\n", __func__, rc); 233 pr_warn("Cannot add additional memory (%i)\n", rc);
234 return BP_EAGAIN; 234 return BP_ECANCELED;
235 } 235 }
236 236
237 balloon_hotplug -= credit; 237 balloon_hotplug -= credit;
diff --git a/drivers/xen/gntalloc.c b/drivers/xen/gntalloc.c
index 787d17945418..e53fe191738c 100644
--- a/drivers/xen/gntalloc.c
+++ b/drivers/xen/gntalloc.c
@@ -124,7 +124,7 @@ static int add_grefs(struct ioctl_gntalloc_alloc_gref *op,
124 int i, rc, readonly; 124 int i, rc, readonly;
125 LIST_HEAD(queue_gref); 125 LIST_HEAD(queue_gref);
126 LIST_HEAD(queue_file); 126 LIST_HEAD(queue_file);
127 struct gntalloc_gref *gref; 127 struct gntalloc_gref *gref, *next;
128 128
129 readonly = !(op->flags & GNTALLOC_FLAG_WRITABLE); 129 readonly = !(op->flags & GNTALLOC_FLAG_WRITABLE);
130 rc = -ENOMEM; 130 rc = -ENOMEM;
@@ -141,13 +141,11 @@ static int add_grefs(struct ioctl_gntalloc_alloc_gref *op,
141 goto undo; 141 goto undo;
142 142
143 /* Grant foreign access to the page. */ 143 /* Grant foreign access to the page. */
144 gref->gref_id = gnttab_grant_foreign_access(op->domid, 144 rc = gnttab_grant_foreign_access(op->domid,
145 pfn_to_mfn(page_to_pfn(gref->page)), readonly); 145 pfn_to_mfn(page_to_pfn(gref->page)), readonly);
146 if ((int)gref->gref_id < 0) { 146 if (rc < 0)
147 rc = gref->gref_id;
148 goto undo; 147 goto undo;
149 } 148 gref_ids[i] = gref->gref_id = rc;
150 gref_ids[i] = gref->gref_id;
151 } 149 }
152 150
153 /* Add to gref lists. */ 151 /* Add to gref lists. */
@@ -162,8 +160,8 @@ undo:
162 mutex_lock(&gref_mutex); 160 mutex_lock(&gref_mutex);
163 gref_size -= (op->count - i); 161 gref_size -= (op->count - i);
164 162
165 list_for_each_entry(gref, &queue_file, next_file) { 163 list_for_each_entry_safe(gref, next, &queue_file, next_file) {
166 /* __del_gref does not remove from queue_file */ 164 list_del(&gref->next_file);
167 __del_gref(gref); 165 __del_gref(gref);
168 } 166 }
169 167
@@ -193,7 +191,7 @@ static void __del_gref(struct gntalloc_gref *gref)
193 191
194 gref->notify.flags = 0; 192 gref->notify.flags = 0;
195 193
196 if (gref->gref_id > 0) { 194 if (gref->gref_id) {
197 if (gnttab_query_foreign_access(gref->gref_id)) 195 if (gnttab_query_foreign_access(gref->gref_id))
198 return; 196 return;
199 197
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 5f1e1f3cd186..f8bb36f9d9ce 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -103,16 +103,11 @@ static void do_suspend(void)
103 103
104 shutting_down = SHUTDOWN_SUSPEND; 104 shutting_down = SHUTDOWN_SUSPEND;
105 105
106#ifdef CONFIG_PREEMPT
107 /* If the kernel is preemptible, we need to freeze all the processes
108 to prevent them from being in the middle of a pagetable update
109 during suspend. */
110 err = freeze_processes(); 106 err = freeze_processes();
111 if (err) { 107 if (err) {
112 pr_err("%s: freeze failed %d\n", __func__, err); 108 pr_err("%s: freeze failed %d\n", __func__, err);
113 goto out; 109 goto out;
114 } 110 }
115#endif
116 111
117 err = dpm_suspend_start(PMSG_FREEZE); 112 err = dpm_suspend_start(PMSG_FREEZE);
118 if (err) { 113 if (err) {
@@ -157,10 +152,8 @@ out_resume:
157 dpm_resume_end(si.cancelled ? PMSG_THAW : PMSG_RESTORE); 152 dpm_resume_end(si.cancelled ? PMSG_THAW : PMSG_RESTORE);
158 153
159out_thaw: 154out_thaw:
160#ifdef CONFIG_PREEMPT
161 thaw_processes(); 155 thaw_processes();
162out: 156out:
163#endif
164 shutting_down = SHUTDOWN_INVALID; 157 shutting_down = SHUTDOWN_INVALID;
165} 158}
166#endif /* CONFIG_HIBERNATE_CALLBACKS */ 159#endif /* CONFIG_HIBERNATE_CALLBACKS */