direct-io.hg
changeset 6378:c42a9e2f6c5b
Fix x86/64 pagetable initialisation so that only things that
need to be are mapped read-only.
Signed-off-by: Keir Fraser <keir@xensource.com>
need to be are mapped read-only.
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Wed Aug 24 15:22:44 2005 +0000 (2005-08-24) |
parents | bca2fd76995e |
children | 8ba397608f1c 46d8c50b7a1c |
files | linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head64.c linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c xen/arch/x86/mm.c |
line diff
2.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c Wed Aug 24 15:21:48 2005 +0000 2.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c Wed Aug 24 15:22:44 2005 +0000 2.3 @@ -441,6 +441,31 @@ static inline void __set_pte(pte_t *dst, 2.4 *dst = val; 2.5 } 2.6 2.7 +static inline int make_readonly(unsigned long paddr) 2.8 +{ 2.9 + int readonly = 0; 2.10 + 2.11 + /* Make new page tables read-only. */ 2.12 + if ((paddr < ((table_start << PAGE_SHIFT) + tables_space)) && 2.13 + (paddr >= (table_start << PAGE_SHIFT))) 2.14 + readonly = 1; 2.15 + 2.16 + /* Make old page tables read-only. */ 2.17 + if ((paddr < ((xen_start_info.pt_base - __START_KERNEL_map) + 2.18 + (xen_start_info.nr_pt_frames << PAGE_SHIFT))) && 2.19 + (paddr >= (xen_start_info.pt_base - __START_KERNEL_map))) 2.20 + readonly = 1; 2.21 + 2.22 + /* 2.23 + * No need for writable mapping of kernel image. This also ensures that 2.24 + * page and descriptor tables embedded inside don't have writable mappings. 2.25 + */ 2.26 + if ((paddr >= __pa_symbol(&_text)) && (paddr < __pa_symbol(&_end))) 2.27 + readonly = 1; 2.28 + 2.29 + return readonly; 2.30 +} 2.31 + 2.32 void __init phys_pud_init(pud_t *pud, unsigned long address, unsigned long end) 2.33 { 2.34 long i, j, k; 2.35 @@ -477,9 +502,7 @@ void __init phys_pud_init(pud_t *pud, un 2.36 pte = alloc_low_page(&pte_phys); 2.37 pte_save = pte; 2.38 for (k = 0; k < PTRS_PER_PTE; pte++, k++, paddr += PTE_SIZE) { 2.39 - if (paddr < (table_start << PAGE_SHIFT) 2.40 - + tables_space) 2.41 - { 2.42 + if (make_readonly(paddr)) { 2.43 __set_pte(pte, 2.44 __pte(paddr | (_KERNPG_TABLE & ~_PAGE_RW))); 2.45 continue;
3.1 --- a/xen/arch/x86/mm.c Wed Aug 24 15:21:48 2005 +0000 3.2 +++ b/xen/arch/x86/mm.c Wed Aug 24 15:22:44 2005 +0000 3.3 @@ -1449,8 +1449,10 @@ int get_page_type(struct pfn_info *page, 3.4 if ( ((x & PGT_type_mask) != PGT_l2_page_table) || 3.5 ((type & PGT_type_mask) != PGT_l1_page_table) ) 3.6 MEM_LOG("Bad type (saw %" PRtype_info 3.7 - "!= exp %" PRtype_info ") for pfn %lx", 3.8 - x, type, page_to_pfn(page)); 3.9 + "!= exp %" PRtype_info ") " 3.10 + "for mfn %lx (pfn %x)", 3.11 + x, type, page_to_pfn(page), 3.12 + machine_to_phys_mapping[page_to_pfn(page)]); 3.13 return 0; 3.14 } 3.15 else if ( (x & PGT_va_mask) == PGT_va_mutable )