direct-io.hg

changeset 2202:a3feaa0784a7

bitkeeper revision 1.1159.17.18 (411b7a4clSlwGNpVa4jPTa9wgDjfmw)

Add compile-time option to use writable pagetables.
author cl349@freefall.cl.cam.ac.uk
date Thu Aug 12 14:10:20 2004 +0000 (2004-08-12)
parents adf2043c9382
children 34bccd941eb4 b8884dc7fd28
files linux-2.6.7-xen-sparse/arch/xen/Kconfig linux-2.6.7-xen-sparse/arch/xen/i386/kernel/setup.c linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/page.h linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/pgalloc.h linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/pgtable.h
line diff
     1.1 --- a/linux-2.6.7-xen-sparse/arch/xen/Kconfig	Thu Aug 12 11:28:13 2004 +0000
     1.2 +++ b/linux-2.6.7-xen-sparse/arch/xen/Kconfig	Thu Aug 12 14:10:20 2004 +0000
     1.3 @@ -36,6 +36,12 @@ config XEN_PHYSDEV_ACCESS
     1.4  	help
     1.5  	  Device-driver domain (physical device access)
     1.6  
     1.7 +config XEN_WRITABLE_PAGETABLES
     1.8 +	bool "Use writable pagetables"
     1.9 +	default n
    1.10 +	help
    1.11 +	  Use writable L1 pagetables
    1.12 +
    1.13  endmenu
    1.14  
    1.15  # Xen's block device backend driver needs 2^12 pages
     2.1 --- a/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/setup.c	Thu Aug 12 11:28:13 2004 +0000
     2.2 +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/setup.c	Thu Aug 12 14:10:20 2004 +0000
     2.3 @@ -1104,7 +1104,7 @@ void __init setup_arch(char **cmdline_p)
     2.4  
     2.5  	HYPERVISOR_vm_assist(VMASST_CMD_enable,
     2.6  			     VMASST_TYPE_4gb_segments);
     2.7 -#if 0
     2.8 +#ifdef CONFIG_XEN_WRITABLE_PAGETABLES
     2.9  	HYPERVISOR_vm_assist(VMASST_CMD_enable,
    2.10  			     VMASST_TYPE_writeable_pagetables);
    2.11  #endif
     3.1 --- a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/page.h	Thu Aug 12 11:28:13 2004 +0000
     3.2 +++ b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/page.h	Thu Aug 12 14:10:20 2004 +0000
     3.3 @@ -95,7 +95,7 @@ typedef struct { unsigned long pgprot; }
     3.4  static inline unsigned long pmd_val(pmd_t x)
     3.5  {
     3.6      unsigned long ret = x.pmd;
     3.7 -    if ( (ret & 1) ) ret = machine_to_phys(ret);
     3.8 +    if ( (ret) ) ret = machine_to_phys(ret);
     3.9      return ret;
    3.10  }
    3.11  #define pgd_val(x)	({ BUG(); (unsigned long)0; })
     4.1 --- a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/pgalloc.h	Thu Aug 12 11:28:13 2004 +0000
     4.2 +++ b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/pgalloc.h	Thu Aug 12 14:10:20 2004 +0000
     4.3 @@ -6,6 +6,7 @@
     4.4  #include <asm/fixmap.h>
     4.5  #include <linux/threads.h>
     4.6  #include <linux/mm.h>		/* for struct page */
     4.7 +#include <asm/io.h>		/* for phys_to_virt and page_to_pseudophys */
     4.8  
     4.9  #define pmd_populate_kernel(mm, pmd, pte) \
    4.10  		set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
    4.11 @@ -15,7 +16,8 @@ static inline void pmd_populate(struct m
    4.12  	set_pmd(pmd, __pmd(_PAGE_TABLE +
    4.13  		((unsigned long long)page_to_pfn(pte) <<
    4.14  			(unsigned long long) PAGE_SHIFT)));
    4.15 -	flush_page_update_queue(); /* XXXcl flush */
    4.16 +	flush_page_update_queue();
    4.17 +	/* XXXcl queue */
    4.18  }
    4.19  /*
    4.20   * Allocate and free page tables.
    4.21 @@ -30,17 +32,25 @@ extern struct page *pte_alloc_one(struct
    4.22  static inline void pte_free_kernel(pte_t *pte)
    4.23  {
    4.24  	free_page((unsigned long)pte);
    4.25 +	__make_page_writeable(pte);
    4.26  }
    4.27  
    4.28  static inline void pte_free(struct page *pte)
    4.29  {
    4.30 -	__free_page(pte);
    4.31 +#ifdef CONFIG_HIGHPTE
    4.32 +	if (pte < highmem_start_page)
    4.33 +#endif
    4.34 +	{
    4.35 +		__make_page_writeable(phys_to_virt(page_to_pseudophys(pte)));
    4.36 +		__free_page(pte);
    4.37 +	}
    4.38  }
    4.39  
    4.40  
    4.41  #define __pte_free_tlb(tlb,pte) do {			\
    4.42  	tlb_remove_page((tlb),(pte));			\
    4.43 -	flush_page_update_queue(); /* XXXcl flush */	\
    4.44 +	flush_page_update_queue();			\
    4.45 +	/* XXXcl queue */ \
    4.46  } while (0)
    4.47  
    4.48  /*
     5.1 --- a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	Thu Aug 12 11:28:13 2004 +0000
     5.2 +++ b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	Thu Aug 12 14:10:20 2004 +0000
     5.3 @@ -40,8 +40,13 @@ static inline int pgd_present(pgd_t pgd)
     5.4   * within a page table are directly modified.  Thus, the following
     5.5   * hook is made available.
     5.6   */
     5.7 +#ifdef CONFIG_XEN_WRITABLE_PAGETABLES
     5.8 +#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
     5.9 +#define set_pte_atomic(pteptr, pteval) (*(pteptr) = pteval)
    5.10 +#else
    5.11  #define set_pte(pteptr, pteval) queue_l1_entry_update(pteptr, (pteval).pte_low)
    5.12  #define set_pte_atomic(pteptr, pteval) queue_l1_entry_update(pteptr, (pteval).pte_low)
    5.13 +#endif
    5.14  /*
    5.15   * (pmds are folded into pgds so this doesn't get actually called,
    5.16   * but the define is needed for a generic inline function.)
    5.17 @@ -70,7 +75,7 @@ static inline pte_t ptep_get_and_clear(p
    5.18  {
    5.19  	pte_t pte = *xp;
    5.20  	if (pte.pte_low)
    5.21 -		queue_l1_entry_update(xp, 0);
    5.22 +		set_pte(xp, __pte_ma(0));
    5.23  	return pte;
    5.24  }
    5.25  
     6.1 --- a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Thu Aug 12 11:28:13 2004 +0000
     6.2 +++ b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Thu Aug 12 14:10:20 2004 +0000
     6.3 @@ -191,7 +191,7 @@ extern unsigned long pg0[];
     6.4  #define pmd_none(x)	(!pmd_val(x))
     6.5  #define pmd_present(x)	(pmd_val(x) & _PAGE_PRESENT)
     6.6  /* pmd_clear below */
     6.7 -#define	pmd_bad(x)	((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
     6.8 +#define	pmd_bad(x)	((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER & ~_PAGE_PRESENT)) != (_KERNPG_TABLE & ~_PAGE_PRESENT))
     6.9  
    6.10  
    6.11  #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
    6.12 @@ -241,9 +241,9 @@ static inline  int ptep_test_and_clear_y
    6.13  }
    6.14  static inline void ptep_set_wrprotect(pte_t *ptep)
    6.15  {
    6.16 -	unsigned long pteval = *(unsigned long *)ptep;
    6.17 -	if ((pteval & _PAGE_RW))
    6.18 -		queue_l1_entry_update(ptep, pteval & ~_PAGE_RW);
    6.19 +	pte_t pte = *ptep;
    6.20 +	if (pte_write(pte))
    6.21 +		set_pte(ptep, pte_wrprotect(pte));
    6.22  }
    6.23  static inline void ptep_mkdirty(pte_t *ptep)
    6.24  {
    6.25 @@ -283,6 +283,7 @@ static inline pte_t pte_modify(pte_t pte
    6.26  	pmd_t p = *(xp);					\
    6.27  	set_pmd(xp, __pmd(0));					\
    6.28  	__make_page_writeable((void *)pmd_page_kernel(p));	\
    6.29 +	/* XXXcl queue */ \
    6.30  } while (0)
    6.31  
    6.32  #ifndef CONFIG_DISCONTIGMEM
    6.33 @@ -401,6 +402,7 @@ static inline void make_page_readonly(vo
    6.34  	if ( (unsigned long)va >= VMALLOC_START )
    6.35  		__make_page_readonly(machine_to_virt(
    6.36  			*(unsigned long *)pte&PAGE_MASK));
    6.37 +	/* XXXcl queue */
    6.38  }
    6.39  
    6.40  static inline void make_page_writeable(void *va)
    6.41 @@ -412,6 +414,7 @@ static inline void make_page_writeable(v
    6.42  	if ( (unsigned long)va >= VMALLOC_START )
    6.43  		__make_page_writeable(machine_to_virt(
    6.44  			*(unsigned long *)pte&PAGE_MASK));
    6.45 +	/* XXXcl queue */
    6.46  }
    6.47  
    6.48  static inline void make_pages_readonly(void *va, unsigned int nr)
    6.49 @@ -421,6 +424,7 @@ static inline void make_pages_readonly(v
    6.50  		make_page_readonly(va);
    6.51  		va = (void *)((unsigned long)va + PAGE_SIZE);
    6.52  	}
    6.53 +	/* XXXcl queue */
    6.54  }
    6.55  
    6.56  static inline void make_pages_writeable(void *va, unsigned int nr)
    6.57 @@ -430,6 +434,7 @@ static inline void make_pages_writeable(
    6.58  		make_page_writeable(va);
    6.59  		va = (void *)((unsigned long)va + PAGE_SIZE);
    6.60  	}
    6.61 +	/* XXXcl queue */
    6.62  }
    6.63  
    6.64  static inline unsigned long arbitrary_virt_to_phys(void *va)