aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/xen
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2011-04-26 04:22:15 -0400
committerJiri Kosina <jkosina@suse.cz>2011-04-26 04:22:59 -0400
commit07f9479a40cc778bc1462ada11f95b01360ae4ff (patch)
tree0676cf38df3844004bb3ebfd99dfa67a4a8998f5 /arch/x86/xen
parent9d5e6bdb3013acfb311ab407eeca0b6a6a3dedbf (diff)
parentcd2e49e90f1cae7726c9a2c54488d881d7f1cd1c (diff)
Merge branch 'master' into for-next
Fast-forwarded to current state of Linus' tree as there are patches to be applied for files that didn't exist on the old branch.
Diffstat (limited to 'arch/x86/xen')
-rw-r--r--arch/x86/xen/Kconfig1
-rw-r--r--arch/x86/xen/enlighten.c21
-rw-r--r--arch/x86/xen/mmu.c38
-rw-r--r--arch/x86/xen/p2m.c10
-rw-r--r--arch/x86/xen/setup.c2
5 files changed, 38 insertions, 34 deletions
diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
index 1c7121ba18ff..5cc821cb2e09 100644
--- a/arch/x86/xen/Kconfig
+++ b/arch/x86/xen/Kconfig
@@ -39,6 +39,7 @@ config XEN_MAX_DOMAIN_MEMORY
39config XEN_SAVE_RESTORE 39config XEN_SAVE_RESTORE
40 bool 40 bool
41 depends on XEN 41 depends on XEN
42 select HIBERNATE_CALLBACKS
42 default y 43 default y
43 44
44config XEN_DEBUG_FS 45config XEN_DEBUG_FS
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 49dbd78ec3cb..e3c6a06cf725 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -238,6 +238,7 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
238static __init void xen_init_cpuid_mask(void) 238static __init void xen_init_cpuid_mask(void)
239{ 239{
240 unsigned int ax, bx, cx, dx; 240 unsigned int ax, bx, cx, dx;
241 unsigned int xsave_mask;
241 242
242 cpuid_leaf1_edx_mask = 243 cpuid_leaf1_edx_mask =
243 ~((1 << X86_FEATURE_MCE) | /* disable MCE */ 244 ~((1 << X86_FEATURE_MCE) | /* disable MCE */
@@ -249,24 +250,16 @@ static __init void xen_init_cpuid_mask(void)
249 cpuid_leaf1_edx_mask &= 250 cpuid_leaf1_edx_mask &=
250 ~((1 << X86_FEATURE_APIC) | /* disable local APIC */ 251 ~((1 << X86_FEATURE_APIC) | /* disable local APIC */
251 (1 << X86_FEATURE_ACPI)); /* disable ACPI */ 252 (1 << X86_FEATURE_ACPI)); /* disable ACPI */
252
253 ax = 1; 253 ax = 1;
254 cx = 0;
255 xen_cpuid(&ax, &bx, &cx, &dx); 254 xen_cpuid(&ax, &bx, &cx, &dx);
256 255
257 /* cpuid claims we support xsave; try enabling it to see what happens */ 256 xsave_mask =
258 if (cx & (1 << (X86_FEATURE_XSAVE % 32))) { 257 (1 << (X86_FEATURE_XSAVE % 32)) |
259 unsigned long cr4; 258 (1 << (X86_FEATURE_OSXSAVE % 32));
260
261 set_in_cr4(X86_CR4_OSXSAVE);
262
263 cr4 = read_cr4();
264 259
265 if ((cr4 & X86_CR4_OSXSAVE) == 0) 260 /* Xen will set CR4.OSXSAVE if supported and not disabled by force */
266 cpuid_leaf1_ecx_mask &= ~(1 << (X86_FEATURE_XSAVE % 32)); 261 if ((cx & xsave_mask) != xsave_mask)
267 262 cpuid_leaf1_ecx_mask &= ~xsave_mask; /* disable XSAVE & OSXSAVE */
268 clear_in_cr4(X86_CR4_OSXSAVE);
269 }
270} 263}
271 264
272static void xen_set_debugreg(int reg, unsigned long val) 265static void xen_set_debugreg(int reg, unsigned long val)
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 39ee7182fd18..aef7af92b28b 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -565,13 +565,13 @@ pte_t xen_make_pte_debug(pteval_t pte)
565 if (io_page && 565 if (io_page &&
566 (xen_initial_domain() || addr >= ISA_END_ADDRESS)) { 566 (xen_initial_domain() || addr >= ISA_END_ADDRESS)) {
567 other_addr = pfn_to_mfn(addr >> PAGE_SHIFT) << PAGE_SHIFT; 567 other_addr = pfn_to_mfn(addr >> PAGE_SHIFT) << PAGE_SHIFT;
568 WARN(addr != other_addr, 568 WARN_ONCE(addr != other_addr,
569 "0x%lx is using VM_IO, but it is 0x%lx!\n", 569 "0x%lx is using VM_IO, but it is 0x%lx!\n",
570 (unsigned long)addr, (unsigned long)other_addr); 570 (unsigned long)addr, (unsigned long)other_addr);
571 } else { 571 } else {
572 pteval_t iomap_set = (_pte.pte & PTE_FLAGS_MASK) & _PAGE_IOMAP; 572 pteval_t iomap_set = (_pte.pte & PTE_FLAGS_MASK) & _PAGE_IOMAP;
573 other_addr = (_pte.pte & PTE_PFN_MASK); 573 other_addr = (_pte.pte & PTE_PFN_MASK);
574 WARN((addr == other_addr) && (!io_page) && (!iomap_set), 574 WARN_ONCE((addr == other_addr) && (!io_page) && (!iomap_set),
575 "0x%lx is missing VM_IO (and wasn't fixed)!\n", 575 "0x%lx is missing VM_IO (and wasn't fixed)!\n",
576 (unsigned long)addr); 576 (unsigned long)addr);
577 } 577 }
@@ -1473,28 +1473,35 @@ static void xen_pgd_free(struct mm_struct *mm, pgd_t *pgd)
1473#endif 1473#endif
1474} 1474}
1475 1475
1476#ifdef CONFIG_X86_32
1476static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte) 1477static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte)
1477{ 1478{
1478 unsigned long pfn = pte_pfn(pte);
1479
1480#ifdef CONFIG_X86_32
1481 /* If there's an existing pte, then don't allow _PAGE_RW to be set */ 1479 /* If there's an existing pte, then don't allow _PAGE_RW to be set */
1482 if (pte_val_ma(*ptep) & _PAGE_PRESENT) 1480 if (pte_val_ma(*ptep) & _PAGE_PRESENT)
1483 pte = __pte_ma(((pte_val_ma(*ptep) & _PAGE_RW) | ~_PAGE_RW) & 1481 pte = __pte_ma(((pte_val_ma(*ptep) & _PAGE_RW) | ~_PAGE_RW) &
1484 pte_val_ma(pte)); 1482 pte_val_ma(pte));
1485#endif 1483
1484 return pte;
1485}
1486#else /* CONFIG_X86_64 */
1487static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte)
1488{
1489 unsigned long pfn = pte_pfn(pte);
1486 1490
1487 /* 1491 /*
1488 * If the new pfn is within the range of the newly allocated 1492 * If the new pfn is within the range of the newly allocated
1489 * kernel pagetable, and it isn't being mapped into an 1493 * kernel pagetable, and it isn't being mapped into an
1490 * early_ioremap fixmap slot, make sure it is RO. 1494 * early_ioremap fixmap slot as a freshly allocated page, make sure
1495 * it is RO.
1491 */ 1496 */
1492 if (!is_early_ioremap_ptep(ptep) && 1497 if (((!is_early_ioremap_ptep(ptep) &&
1493 pfn >= pgt_buf_start && pfn < pgt_buf_end) 1498 pfn >= pgt_buf_start && pfn < pgt_buf_end)) ||
1499 (is_early_ioremap_ptep(ptep) && pfn != (pgt_buf_end - 1)))
1494 pte = pte_wrprotect(pte); 1500 pte = pte_wrprotect(pte);
1495 1501
1496 return pte; 1502 return pte;
1497} 1503}
1504#endif /* CONFIG_X86_64 */
1498 1505
1499/* Init-time set_pte while constructing initial pagetables, which 1506/* Init-time set_pte while constructing initial pagetables, which
1500 doesn't allow RO pagetable pages to be remapped RW */ 1507 doesn't allow RO pagetable pages to be remapped RW */
@@ -1700,9 +1707,6 @@ static __init void xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
1700 for (pteidx = 0; pteidx < PTRS_PER_PTE; pteidx++, pfn++) { 1707 for (pteidx = 0; pteidx < PTRS_PER_PTE; pteidx++, pfn++) {
1701 pte_t pte; 1708 pte_t pte;
1702 1709
1703 if (pfn > max_pfn_mapped)
1704 max_pfn_mapped = pfn;
1705
1706 if (!pte_none(pte_page[pteidx])) 1710 if (!pte_none(pte_page[pteidx]))
1707 continue; 1711 continue;
1708 1712
@@ -1760,6 +1764,12 @@ __init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
1760 pud_t *l3; 1764 pud_t *l3;
1761 pmd_t *l2; 1765 pmd_t *l2;
1762 1766
1767 /* max_pfn_mapped is the last pfn mapped in the initial memory
1768 * mappings. Considering that on Xen after the kernel mappings we
1769 * have the mappings of some pages that don't exist in pfn space, we
1770 * set max_pfn_mapped to the last real pfn mapped. */
1771 max_pfn_mapped = PFN_DOWN(__pa(xen_start_info->mfn_list));
1772
1763 /* Zap identity mapping */ 1773 /* Zap identity mapping */
1764 init_level4_pgt[0] = __pgd(0); 1774 init_level4_pgt[0] = __pgd(0);
1765 1775
@@ -1864,9 +1874,7 @@ __init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
1864 initial_kernel_pmd = 1874 initial_kernel_pmd =
1865 extend_brk(sizeof(pmd_t) * PTRS_PER_PMD, PAGE_SIZE); 1875 extend_brk(sizeof(pmd_t) * PTRS_PER_PMD, PAGE_SIZE);
1866 1876
1867 max_pfn_mapped = PFN_DOWN(__pa(xen_start_info->pt_base) + 1877 max_pfn_mapped = PFN_DOWN(__pa(xen_start_info->mfn_list));
1868 xen_start_info->nr_pt_frames * PAGE_SIZE +
1869 512*1024);
1870 1878
1871 kernel_pmd = m2v(pgd[KERNEL_PGD_BOUNDARY].pgd); 1879 kernel_pmd = m2v(pgd[KERNEL_PGD_BOUNDARY].pgd);
1872 memcpy(initial_kernel_pmd, kernel_pmd, sizeof(pmd_t) * PTRS_PER_PMD); 1880 memcpy(initial_kernel_pmd, kernel_pmd, sizeof(pmd_t) * PTRS_PER_PMD);
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 215a3ce61068..141eb0de8b06 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -497,7 +497,7 @@ static bool alloc_p2m(unsigned long pfn)
497 return true; 497 return true;
498} 498}
499 499
500bool __early_alloc_p2m(unsigned long pfn) 500static bool __init __early_alloc_p2m(unsigned long pfn)
501{ 501{
502 unsigned topidx, mididx, idx; 502 unsigned topidx, mididx, idx;
503 503
@@ -530,7 +530,7 @@ bool __early_alloc_p2m(unsigned long pfn)
530 } 530 }
531 return idx != 0; 531 return idx != 0;
532} 532}
533unsigned long set_phys_range_identity(unsigned long pfn_s, 533unsigned long __init set_phys_range_identity(unsigned long pfn_s,
534 unsigned long pfn_e) 534 unsigned long pfn_e)
535{ 535{
536 unsigned long pfn; 536 unsigned long pfn;
@@ -671,7 +671,9 @@ int m2p_add_override(unsigned long mfn, struct page *page)
671 page->private = mfn; 671 page->private = mfn;
672 page->index = pfn_to_mfn(pfn); 672 page->index = pfn_to_mfn(pfn);
673 673
674 __set_phys_to_machine(pfn, FOREIGN_FRAME(mfn)); 674 if (unlikely(!set_phys_to_machine(pfn, FOREIGN_FRAME(mfn))))
675 return -ENOMEM;
676
675 if (!PageHighMem(page)) 677 if (!PageHighMem(page))
676 /* Just zap old mapping for now */ 678 /* Just zap old mapping for now */
677 pte_clear(&init_mm, address, ptep); 679 pte_clear(&init_mm, address, ptep);
@@ -709,7 +711,7 @@ int m2p_remove_override(struct page *page)
709 spin_lock_irqsave(&m2p_override_lock, flags); 711 spin_lock_irqsave(&m2p_override_lock, flags);
710 list_del(&page->lru); 712 list_del(&page->lru);
711 spin_unlock_irqrestore(&m2p_override_lock, flags); 713 spin_unlock_irqrestore(&m2p_override_lock, flags);
712 __set_phys_to_machine(pfn, page->index); 714 set_phys_to_machine(pfn, page->index);
713 715
714 if (!PageHighMem(page)) 716 if (!PageHighMem(page))
715 set_pte_at(&init_mm, address, ptep, 717 set_pte_at(&init_mm, address, ptep,
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index fa0269a99377..90bac0aac3a5 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -227,7 +227,7 @@ char * __init xen_memory_setup(void)
227 227
228 memcpy(map_raw, map, sizeof(map)); 228 memcpy(map_raw, map, sizeof(map));
229 e820.nr_map = 0; 229 e820.nr_map = 0;
230 xen_extra_mem_start = mem_end; 230 xen_extra_mem_start = max((1ULL << 32), mem_end);
231 for (i = 0; i < memmap.nr_entries; i++) { 231 for (i = 0; i < memmap.nr_entries; i++) {
232 unsigned long long end; 232 unsigned long long end;
233 233