WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [linux-2.6.18-xen] linux/x86-64: initialization code cle

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] linux/x86-64: initialization code cleanup
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 15 May 2008 10:20:11 -0700
Delivery-date: Thu, 15 May 2008 10:20:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1210860909 -3600
# Node ID 12e74c1433a6305a7f5fbaa7bd34f0dcfabe06fc
# Parent  c6e36a53cf054df48d892da2bb0145a5f111387a
linux/x86-64: initialization code cleanup

Since init_memory_mapping() installs the pgd entry after populating
all lower level tables, the whole mechanism can be coded to avoid
using xen_l?_entry_update() on pages that aren't page tables
(yet). Also, __set_pte() is a pure duplicate of set_pte() and hence
can go away.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 arch/x86_64/mm/init-xen.c |   54 ++++++++++++++++++++++------------------------
 1 files changed, 26 insertions(+), 28 deletions(-)

diff -r c6e36a53cf05 -r 12e74c1433a6 arch/x86_64/mm/init-xen.c
--- a/arch/x86_64/mm/init-xen.c Thu May 15 15:14:31 2008 +0100
+++ b/arch/x86_64/mm/init-xen.c Thu May 15 15:15:09 2008 +0100
@@ -59,6 +59,8 @@ EXPORT_SYMBOL(__kernel_page_user);
 EXPORT_SYMBOL(__kernel_page_user);
 #endif
 
+int after_bootmem;
+
 extern unsigned long *contiguous_bitmap;
 
 static unsigned long dma_reserve __initdata;
@@ -82,6 +84,8 @@ static void __meminit early_make_page_re
        unsigned long addr, _va = (unsigned long)va;
        pte_t pte, *ptep;
        unsigned long *page = (unsigned long *) init_level4_pgt;
+
+       BUG_ON(after_bootmem);
 
        if (xen_feature(feature))
                return;
@@ -207,7 +211,6 @@ void show_mem(void)
        printk(KERN_INFO "%lu pages swap cached\n",cached);
 }
 
-int after_bootmem;
 
 static __init void *spp_getpage(void)
 { 
@@ -373,11 +376,6 @@ static __meminit void *alloc_static_page
 
 #define PTE_SIZE PAGE_SIZE
 
-static inline void __set_pte(pte_t *dst, pte_t val)
-{
-       *dst = val;
-}
-
 static inline int make_readonly(unsigned long paddr)
 {
        extern char __vsyscall_0;
@@ -446,28 +444,28 @@ phys_pmd_init(pmd_t *pmd, unsigned long 
                unsigned long pte_phys;
                pte_t *pte, *pte_save;
 
-               if (address >= end) {
-                       if (!after_bootmem)
-                               for (; i < PTRS_PER_PMD; i++, pmd++)
-                                       set_pmd(pmd, __pmd(0));
+               if (address >= end)
                        break;
-               }
                pte = alloc_static_page(&pte_phys);
                pte_save = pte;
                for (k = 0; k < PTRS_PER_PTE; pte++, k++, address += PTE_SIZE) {
                        unsigned long pteval = address | _PAGE_NX | 
_KERNPG_TABLE;
 
-                       if ((address >= end) ||
-                           ((address >> PAGE_SHIFT) >=
-                            xen_start_info->nr_pages))
+                       if (address >= (after_bootmem
+                                       ? end
+                                       : xen_start_info->nr_pages << 
PAGE_SHIFT))
                                pteval = 0;
                        else if (make_readonly(address))
                                pteval &= ~_PAGE_RW;
-                       __set_pte(pte, __pte(pteval & __supported_pte_mask));
-               }
-               pte = pte_save;
-               early_make_page_readonly(pte, XENFEAT_writable_page_tables);
-               set_pmd(pmd, __pmd(pte_phys | _KERNPG_TABLE));
+                       set_pte(pte, __pte(pteval & __supported_pte_mask));
+               }
+               if (!after_bootmem) {
+                       early_make_page_readonly(pte_save, 
XENFEAT_writable_page_tables);
+                       *pmd = __pmd(pte_phys | _KERNPG_TABLE);
+               } else {
+                       make_page_readonly(pte_save, 
XENFEAT_writable_page_tables);
+                       set_pmd(pmd, __pmd(pte_phys | _KERNPG_TABLE));
+               }
        }
 }
 
@@ -504,11 +502,13 @@ static void __meminit phys_pud_init(pud_
                        break;
 
                pmd = alloc_static_page(&pmd_phys);
-               early_make_page_readonly(pmd, XENFEAT_writable_page_tables);
+
                spin_lock(&init_mm.page_table_lock);
-               set_pud(pud, __pud(pmd_phys | _KERNPG_TABLE));
+               *pud = __pud(pmd_phys | _KERNPG_TABLE);
                phys_pmd_init(pmd, paddr, end);
                spin_unlock(&init_mm.page_table_lock);
+
+               early_make_page_readonly(pmd, XENFEAT_writable_page_tables);
        }
        __flush_tlb();
 } 
@@ -739,20 +739,18 @@ void __meminit init_memory_mapping(unsig
                pgd_t *pgd = pgd_offset_k(start);
                pud_t *pud;
 
-               if (after_bootmem) {
+               if (after_bootmem)
                        pud = pud_offset(pgd, start & PGDIR_MASK);
-                       make_page_readonly(pud, XENFEAT_writable_page_tables);
-                       pud_phys = __pa(pud);
-               } else {
+               else
                        pud = alloc_static_page(&pud_phys);
-                       early_make_page_readonly(pud, 
XENFEAT_writable_page_tables);
-               }
                next = start + PGDIR_SIZE;
                if (next > end) 
                        next = end; 
                phys_pud_init(pud, __pa(start), __pa(next));
-               if (!after_bootmem)
+               if (!after_bootmem) {
+                       early_make_page_readonly(pud, 
XENFEAT_writable_page_tables);
                        set_pgd(pgd_offset_k(start), mk_kernel_pgd(pud_phys));
+               }
        }
 
        if (!after_bootmem) {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] linux/x86-64: initialization code cleanup, Xen patchbot-linux-2.6.18-xen <=