ia64/xen-unstable

changeset 96:f7ff141acc2a

bitkeeper revision 1.15.1.8 (3e2d5b75k3SSnLdVzMd7kREO_EvMLw)

Added macros and counters to page table flushes.

macros and the counter are in a new header file -- flushtlb.h
author akw27@labyrinth.cl.cam.ac.uk
date Tue Jan 21 14:38:45 2003 +0000 (2003-01-21)
parents f72ea5eac57b
children ce656d157bbf
files .rootkeys xen-2.4.16/common/domain.c xen-2.4.16/common/memory.c xen-2.4.16/include/asm-i386/flushtlb.h xen-2.4.16/include/asm-i386/page.h
line diff
     1.1 --- a/.rootkeys	Sun Jan 19 20:34:43 2003 +0000
     1.2 +++ b/.rootkeys	Tue Jan 21 14:38:45 2003 +0000
     1.3 @@ -134,6 +134,7 @@ 3ddb79c34BFiXjBJ_cCKB0aCsV1IDw xen-2.4.1
     1.4  3e20b82fl1jmQiKdLy7fxMcutfpjWA xen-2.4.16/include/asm-i386/domain_page.h
     1.5  3ddb79c2O729EttZTYu1c8LcsUO_GQ xen-2.4.16/include/asm-i386/elf.h
     1.6  3ddb79c3NU8Zy40OTrq3D-i30Y3t4A xen-2.4.16/include/asm-i386/fixmap.h
     1.7 +3e2d29944GI24gf7vOP_7x8EyuqxeA xen-2.4.16/include/asm-i386/flushtlb.h
     1.8  3ddb79c39o75zPP0T1aQQ4mNrCAN2w xen-2.4.16/include/asm-i386/hardirq.h
     1.9  3ddb79c3BFEIwXR4IsWbwp4BoL4DkA xen-2.4.16/include/asm-i386/hdreg.h
    1.10  3ddb79c3TMDjkxVndKFKnGiwY0HzDg xen-2.4.16/include/asm-i386/i387.h
     2.1 --- a/xen-2.4.16/common/domain.c	Sun Jan 19 20:34:43 2003 +0000
     2.2 +++ b/xen-2.4.16/common/domain.c	Tue Jan 21 14:38:45 2003 +0000
     2.3 @@ -11,6 +11,7 @@
     2.4  #include <xeno/dom0_ops.h>
     2.5  #include <asm/io.h>
     2.6  #include <asm/domain_page.h>
     2.7 +#include <asm/flushtlb.h>
     2.8  
     2.9  rwlock_t tasklist_lock __cacheline_aligned = RW_LOCK_UNLOCKED;
    2.10  
    2.11 @@ -581,8 +582,7 @@ int setup_guestos(struct task_struct *p,
    2.12  
    2.13      /* Install the new page tables. */
    2.14      __cli();
    2.15 -    __asm__ __volatile__ (
    2.16 -        "mov %%eax,%%cr3" : : "a" (pagetable_val(p->mm.pagetable)));
    2.17 +    __write_cr3_counted(pagetable_val(p->mm.pagetable));
    2.18  
    2.19      /* Copy the guest OS image. */
    2.20      src = (char *)__va(mod[0].mod_start + 12);
    2.21 @@ -657,8 +657,7 @@ int setup_guestos(struct task_struct *p,
    2.22      }
    2.23  
    2.24      /* Reinstate the caller's page tables. */
    2.25 -    __asm__ __volatile__ (
    2.26 -        "mov %%eax,%%cr3" : : "a" (pagetable_val(current->mm.pagetable)));    
    2.27 +    __write_cr3_counted(pagetable_val(current->mm.pagetable));
    2.28      __sti();
    2.29  
    2.30      new_thread(p, 
     3.1 --- a/xen-2.4.16/common/memory.c	Sun Jan 19 20:34:43 2003 +0000
     3.2 +++ b/xen-2.4.16/common/memory.c	Tue Jan 21 14:38:45 2003 +0000
     3.3 @@ -171,6 +171,7 @@
     3.4  #include <xeno/sched.h>
     3.5  #include <xeno/errno.h>
     3.6  #include <asm/page.h>
     3.7 +#include <asm/flushtlb.h>
     3.8  #include <asm/io.h>
     3.9  #include <asm/uaccess.h>
    3.10  #include <asm/domain_page.h>
    3.11 @@ -766,9 +767,7 @@ int do_process_page_updates(page_update_
    3.12      if ( tlb_flush[smp_processor_id()] )
    3.13      {
    3.14          tlb_flush[smp_processor_id()] = 0;
    3.15 -        __asm__ __volatile__ (
    3.16 -            "movl %%eax,%%cr3" : : 
    3.17 -            "a" (pagetable_val(current->mm.pagetable)));
    3.18 +        __write_cr3_counted(pagetable_val(current->mm.pagetable));
    3.19      }
    3.20  
    3.21      return(0);
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/xen-2.4.16/include/asm-i386/flushtlb.h	Tue Jan 21 14:38:45 2003 +0000
     4.3 @@ -0,0 +1,48 @@
     4.4 +/******************************************************************************
     4.5 + * flushtlb.h
     4.6 + * 
     4.7 + * TLB flush macros that count flushes.  Counting is used to enforce 
     4.8 + * zero-copy safety, particularily for the network code.
     4.9 + *
    4.10 + * akw - Jan 21, 2003
    4.11 + */
    4.12 +
    4.13 +#ifndef __FLUSHTLB_H
    4.14 +#define __FLUSHTLB_H
    4.15 +
    4.16 +#include <xeno/smp.h>
    4.17 +
    4.18 +unsigned long tlb_flush_count[NR_CPUS];
    4.19 +//#if 0 
    4.20 +#define __read_cr3(__var)                                               \
    4.21 +    do {                                                                \
    4.22 +                __asm__ __volatile (                                    \
    4.23 +                        "movl %%cr3, %0;"                               \
    4.24 +                        : "=r" (__var));                                \
    4.25 +    } while (0)
    4.26 +//#endif
    4.27 +
    4.28 +#define __write_cr3_counted(__pa)                                       \
    4.29 +    do {                                                                \
    4.30 +                __asm__ __volatile__ (                                  \
    4.31 +                        "movl %0, %%cr3;"                               \
    4.32 +                        :: "r" (__pa)                                    \
    4.33 +                        : "memory");                                    \
    4.34 +                tlb_flush_count[smp_processor_id()]++;                  \
    4.35 +    } while (0)
    4.36 +
    4.37 +//#endif
    4.38 +#define __flush_tlb_counted()                                           \
    4.39 +        do {                                                            \
    4.40 +                unsigned int tmpreg;                                    \
    4.41 +                                                                        \
    4.42 +                __asm__ __volatile__(                                   \
    4.43 +                        "movl %%cr3, %0;  # flush TLB \n"               \
    4.44 +                        "movl %0, %%cr3;                "               \
    4.45 +                        : "=r" (tmpreg)                                \
    4.46 +                        :: "memory");                                   \
    4.47 +                tlb_flush_count[smp_processor_id()]++;                  \
    4.48 +        } while (0)
    4.49 +
    4.50 +#endif
    4.51 +                           
     5.1 --- a/xen-2.4.16/include/asm-i386/page.h	Sun Jan 19 20:34:43 2003 +0000
     5.2 +++ b/xen-2.4.16/include/asm-i386/page.h	Tue Jan 21 14:38:45 2003 +0000
     5.3 @@ -91,36 +91,36 @@ typedef struct { unsigned long pt_lo; } 
     5.4  #include <asm/processor.h>
     5.5  #include <asm/fixmap.h>
     5.6  #include <asm/bitops.h>
     5.7 +#include <asm/flushtlb.h>
     5.8  
     5.9  extern l2_pgentry_t idle0_pg_table[ENTRIES_PER_L2_PAGETABLE];
    5.10  extern l2_pgentry_t *idle_pg_table[NR_CPUS];
    5.11  extern void paging_init(void);
    5.12  
    5.13 -#define __flush_tlb()							\
    5.14 -	do {								\
    5.15 -		unsigned int tmpreg;					\
    5.16 -									\
    5.17 -		__asm__ __volatile__(					\
    5.18 -			"movl %%cr3, %0;  # flush TLB \n"		\
    5.19 -			"movl %0, %%cr3;              \n"		\
    5.20 -			: "=r" (tmpreg)					\
    5.21 -			:: "memory");					\
    5.22 -	} while (0)
    5.23 +#define __flush_tlb() __flush_tlb_counted()
    5.24  
    5.25  /* Flush global pages as well. */
    5.26 +
    5.27 +#define __pge_off()                                                     \
    5.28 +        do {                                                            \
    5.29 +                __asm__ __volatile__(                                   \
    5.30 +                        "movl %0, %%cr4;  # turn off PGE     "          \
    5.31 +                        :: "r" (mmu_cr4_features & ~X86_CR4_PGE));      \
    5.32 +        } while (0)
    5.33 +
    5.34 +#define __pge_on()                                                      \
    5.35 +        do {                                                            \
    5.36 +                __asm__ __volatile__(                                   \
    5.37 +                        "movl %0, %%cr4;  # turn off PGE     "          \
    5.38 +                        :: "r" (mmu_cr4_features));                     \
    5.39 +        } while (0)
    5.40 +
    5.41 +
    5.42  #define __flush_tlb_all()						\
    5.43  	do {								\
    5.44 -		unsigned int tmpreg;					\
    5.45 -									\
    5.46 -		__asm__ __volatile__(					\
    5.47 -			"movl %1, %%cr4;  # turn off PGE     \n"	\
    5.48 -			"movl %%cr3, %0;  # flush TLB        \n"	\
    5.49 -			"movl %0, %%cr3;                     \n"	\
    5.50 -			"movl %2, %%cr4;  # turn PGE back on \n"	\
    5.51 -			: "=&r" (tmpreg)				\
    5.52 -			: "r" (mmu_cr4_features & ~X86_CR4_PGE),	\
    5.53 -			  "r" (mmu_cr4_features)			\
    5.54 -			: "memory");					\
    5.55 +                __pge_off();                                            \
    5.56 +		__flush_tlb_counted();					\
    5.57 +                __pge_on();                                             \
    5.58  	} while (0)
    5.59  
    5.60  #define __flush_tlb_one(__addr) \