ia64/linux-2.6.18-xen.hg

changeset 556:6b0a85eb5155

merge with linux-2.6.18-xen.hg
author Isaku Yamahata <yamahata@valinux.co.jp>
date Tue May 20 11:33:33 2008 +0900 (2008-05-20)
parents 2d858799d109 8ce60d057d0c
children 8792274adfd0
files
line diff
     1.1 --- a/arch/x86_64/mm/init-xen.c	Thu May 15 16:26:16 2008 +0900
     1.2 +++ b/arch/x86_64/mm/init-xen.c	Tue May 20 11:33:33 2008 +0900
     1.3 @@ -59,6 +59,8 @@ unsigned int __kernel_page_user;
     1.4  EXPORT_SYMBOL(__kernel_page_user);
     1.5  #endif
     1.6  
     1.7 +int after_bootmem;
     1.8 +
     1.9  extern unsigned long *contiguous_bitmap;
    1.10  
    1.11  static unsigned long dma_reserve __initdata;
    1.12 @@ -83,6 +85,8 @@ static void __meminit early_make_page_re
    1.13  	pte_t pte, *ptep;
    1.14  	unsigned long *page = (unsigned long *) init_level4_pgt;
    1.15  
    1.16 +	BUG_ON(after_bootmem);
    1.17 +
    1.18  	if (xen_feature(feature))
    1.19  		return;
    1.20  
    1.21 @@ -207,7 +211,6 @@ void show_mem(void)
    1.22  	printk(KERN_INFO "%lu pages swap cached\n",cached);
    1.23  }
    1.24  
    1.25 -int after_bootmem;
    1.26  
    1.27  static __init void *spp_getpage(void)
    1.28  { 
    1.29 @@ -373,11 +376,6 @@ static __meminit void *alloc_static_page
    1.30  
    1.31  #define PTE_SIZE PAGE_SIZE
    1.32  
    1.33 -static inline void __set_pte(pte_t *dst, pte_t val)
    1.34 -{
    1.35 -	*dst = val;
    1.36 -}
    1.37 -
    1.38  static inline int make_readonly(unsigned long paddr)
    1.39  {
    1.40  	extern char __vsyscall_0;
    1.41 @@ -446,28 +444,28 @@ phys_pmd_init(pmd_t *pmd, unsigned long 
    1.42  		unsigned long pte_phys;
    1.43  		pte_t *pte, *pte_save;
    1.44  
    1.45 -		if (address >= end) {
    1.46 -			if (!after_bootmem)
    1.47 -				for (; i < PTRS_PER_PMD; i++, pmd++)
    1.48 -					set_pmd(pmd, __pmd(0));
    1.49 +		if (address >= end)
    1.50  			break;
    1.51 -		}
    1.52  		pte = alloc_static_page(&pte_phys);
    1.53  		pte_save = pte;
    1.54  		for (k = 0; k < PTRS_PER_PTE; pte++, k++, address += PTE_SIZE) {
    1.55  			unsigned long pteval = address | _PAGE_NX | _KERNPG_TABLE;
    1.56  
    1.57 -			if ((address >= end) ||
    1.58 -			    ((address >> PAGE_SHIFT) >=
    1.59 -			     xen_start_info->nr_pages))
    1.60 +			if (address >= (after_bootmem
    1.61 +			                ? end
    1.62 +			                : xen_start_info->nr_pages << PAGE_SHIFT))
    1.63  				pteval = 0;
    1.64  			else if (make_readonly(address))
    1.65  				pteval &= ~_PAGE_RW;
    1.66 -			__set_pte(pte, __pte(pteval & __supported_pte_mask));
    1.67 +			set_pte(pte, __pte(pteval & __supported_pte_mask));
    1.68  		}
    1.69 -		pte = pte_save;
    1.70 -		early_make_page_readonly(pte, XENFEAT_writable_page_tables);
    1.71 -		set_pmd(pmd, __pmd(pte_phys | _KERNPG_TABLE));
    1.72 +		if (!after_bootmem) {
    1.73 +			early_make_page_readonly(pte_save, XENFEAT_writable_page_tables);
    1.74 +			*pmd = __pmd(pte_phys | _KERNPG_TABLE);
    1.75 +		} else {
    1.76 +			make_page_readonly(pte_save, XENFEAT_writable_page_tables);
    1.77 +			set_pmd(pmd, __pmd(pte_phys | _KERNPG_TABLE));
    1.78 +		}
    1.79  	}
    1.80  }
    1.81  
    1.82 @@ -504,11 +502,13 @@ static void __meminit phys_pud_init(pud_
    1.83  			break;
    1.84  
    1.85  		pmd = alloc_static_page(&pmd_phys);
    1.86 -		early_make_page_readonly(pmd, XENFEAT_writable_page_tables);
    1.87 +
    1.88  		spin_lock(&init_mm.page_table_lock);
    1.89 -		set_pud(pud, __pud(pmd_phys | _KERNPG_TABLE));
    1.90 +		*pud = __pud(pmd_phys | _KERNPG_TABLE);
    1.91  		phys_pmd_init(pmd, paddr, end);
    1.92  		spin_unlock(&init_mm.page_table_lock);
    1.93 +
    1.94 +		early_make_page_readonly(pmd, XENFEAT_writable_page_tables);
    1.95  	}
    1.96  	__flush_tlb();
    1.97  } 
    1.98 @@ -739,20 +739,18 @@ void __meminit init_memory_mapping(unsig
    1.99  		pgd_t *pgd = pgd_offset_k(start);
   1.100  		pud_t *pud;
   1.101  
   1.102 -		if (after_bootmem) {
   1.103 +		if (after_bootmem)
   1.104  			pud = pud_offset(pgd, start & PGDIR_MASK);
   1.105 -			make_page_readonly(pud, XENFEAT_writable_page_tables);
   1.106 -			pud_phys = __pa(pud);
   1.107 -		} else {
   1.108 +		else
   1.109  			pud = alloc_static_page(&pud_phys);
   1.110 -			early_make_page_readonly(pud, XENFEAT_writable_page_tables);
   1.111 -		}
   1.112  		next = start + PGDIR_SIZE;
   1.113  		if (next > end) 
   1.114  			next = end; 
   1.115  		phys_pud_init(pud, __pa(start), __pa(next));
   1.116 -		if (!after_bootmem)
   1.117 +		if (!after_bootmem) {
   1.118 +			early_make_page_readonly(pud, XENFEAT_writable_page_tables);
   1.119  			set_pgd(pgd_offset_k(start), mk_kernel_pgd(pud_phys));
   1.120 +		}
   1.121  	}
   1.122  
   1.123  	if (!after_bootmem) {
     2.1 --- a/arch/x86_64/mm/pageattr-xen.c	Thu May 15 16:26:16 2008 +0900
     2.2 +++ b/arch/x86_64/mm/pageattr-xen.c	Tue May 20 11:33:33 2008 +0900
     2.3 @@ -276,7 +276,7 @@ void pte_free(struct page *pte)
     2.4  }
     2.5  #endif	/* CONFIG_XEN */
     2.6  
     2.7 -static inline pte_t *lookup_address(unsigned long address) 
     2.8 +pte_t *lookup_address(unsigned long address) 
     2.9  { 
    2.10  	pgd_t *pgd = pgd_offset_k(address);
    2.11  	pud_t *pud;
     3.1 --- a/drivers/pci/msi-xen.c	Thu May 15 16:26:16 2008 +0900
     3.2 +++ b/drivers/pci/msi-xen.c	Tue May 20 11:33:33 2008 +0900
     3.3 @@ -33,7 +33,6 @@ int msi_register(struct msi_ops *ops)
     3.4  }
     3.5  
     3.6  static LIST_HEAD(msi_dev_head);
     3.7 -static int msi_dev_head_inited = 0;
     3.8  DEFINE_SPINLOCK(msi_dev_lock);
     3.9  
    3.10  struct msi_dev_list {
    3.11 @@ -97,6 +96,23 @@ static int attach_pirq_entry(int pirq, i
    3.12  	return 0;
    3.13  }
    3.14  
    3.15 +static void detach_pirq_entry(int entry_nr,
    3.16 + 							struct msi_dev_list *msi_dev_entry)
    3.17 +{
    3.18 +	unsigned long flags;
    3.19 +	struct msi_pirq_entry *pirq_entry;
    3.20 +
    3.21 +	list_for_each_entry(pirq_entry, &msi_dev_entry->pirq_list_head, list) {
    3.22 +		if (pirq_entry->entry_nr == entry_nr) {
    3.23 +			spin_lock_irqsave(&msi_dev_entry->pirq_list_lock, flags);
    3.24 +			list_del(&pirq_entry->list);
    3.25 +			spin_unlock_irqrestore(&msi_dev_entry->pirq_list_lock, flags);
    3.26 +			kfree(pirq_entry);
    3.27 +			return;
    3.28 +		}
    3.29 +	}
    3.30 +}
    3.31 +
    3.32  /*
    3.33   * pciback will provide device's owner
    3.34   */
    3.35 @@ -379,40 +395,42 @@ static int msi_capability_init(struct pc
    3.36  static int msix_capability_init(struct pci_dev *dev,
    3.37  				struct msix_entry *entries, int nvec)
    3.38  {
    3.39 -	int pirq, i, pos;
    3.40 +	int pirq, i, j, mapped, pos;
    3.41  	struct msi_dev_list *msi_dev_entry = get_msi_dev_pirq_list(dev);
    3.42 -	struct msi_pirq_entry *pirq_entry, *tmp;
    3.43 -	unsigned long flags;
    3.44 +	struct msi_pirq_entry *pirq_entry;
    3.45  
    3.46  	if (!msi_dev_entry)
    3.47  		return -ENOMEM;
    3.48  
    3.49 -	spin_lock_irqsave(&msi_dev_entry->pirq_list_lock, flags);
    3.50 -	if (!list_empty(&msi_dev_entry->pirq_list_head))
    3.51 -	{
    3.52 -		printk(KERN_WARNING "msix pirqs for dev %02x:%02x:%01x are not freed \
    3.53 -		       before acquire again.\n", dev->bus->number, PCI_SLOT(dev->devfn),
    3.54 -			   PCI_FUNC(dev->devfn));
    3.55 -		list_for_each_entry_safe(pirq_entry, tmp,
    3.56 -		                         &msi_dev_entry->pirq_list_head, list) {
    3.57 -			msi_unmap_pirq(dev, pirq_entry->pirq);
    3.58 -			list_del(&pirq_entry->list);
    3.59 -			kfree(pirq_entry);
    3.60 -		}
    3.61 -	}
    3.62 -	spin_unlock_irqrestore(&msi_dev_entry->pirq_list_lock, flags);
    3.63 -
    3.64  	/* MSI-X Table Initialization */
    3.65  	for (i = 0; i < nvec; i++) {
    3.66 +		mapped = 0;
    3.67 +		list_for_each_entry(pirq_entry, &msi_dev_entry->pirq_list_head, list) {
    3.68 +			if (pirq_entry->entry_nr == entries[i].entry) {
    3.69 +				printk(KERN_WARNING "msix entry %d for dev %02x:%02x:%01x are \
    3.70 +				       not freed before acquire again.\n", entries[i].entry,
    3.71 +					   dev->bus->number, PCI_SLOT(dev->devfn),
    3.72 +					   PCI_FUNC(dev->devfn));
    3.73 +				(entries + i)->vector = pirq_entry->pirq;
    3.74 +				mapped = 1;
    3.75 +				break;
    3.76 +			}
    3.77 +		}
    3.78 +		if (mapped)
    3.79 +			continue;
    3.80  		pirq = msi_map_vector(dev, entries[i].entry, 0);
    3.81  		if (pirq < 0)
    3.82  			break;
    3.83  		attach_pirq_entry(pirq, entries[i].entry, msi_dev_entry);
    3.84  		(entries + i)->vector = pirq;
    3.85  	}
    3.86 +
    3.87  	if (i != nvec) {
    3.88 -		msi_unmap_pirq(dev, dev->irq);
    3.89 -		(entries + i)->vector = 0;
    3.90 +		for (j = --i; j >= 0; j--) {
    3.91 +			msi_unmap_pirq(dev, entries[j].vector);
    3.92 +			detach_pirq_entry(entries[j].entry, msi_dev_entry);
    3.93 +			entries[j].vector = 0;
    3.94 +		}
    3.95  		return -EBUSY;
    3.96  	}
    3.97  
     4.1 --- a/drivers/xen/balloon/balloon.c	Thu May 15 16:26:16 2008 +0900
     4.2 +++ b/drivers/xen/balloon/balloon.c	Tue May 20 11:33:33 2008 +0900
     4.3 @@ -197,8 +197,8 @@ static unsigned long current_target(void
     4.4  static unsigned long minimum_target(void)
     4.5  {
     4.6  #ifndef CONFIG_XEN
     4.7 -	return 0;
     4.8 -#else
     4.9 +#define max_pfn num_physpages
    4.10 +#endif
    4.11  	unsigned long min_pages, curr_pages = current_target();
    4.12  
    4.13  #define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
    4.14 @@ -226,6 +226,8 @@ static unsigned long minimum_target(void
    4.15  
    4.16  	/* Don't enforce growth */
    4.17  	return min(min_pages, curr_pages);
    4.18 +#ifndef CONFIG_XEN
    4.19 +#undef max_pfn
    4.20  #endif
    4.21  }
    4.22  
     5.1 --- a/include/asm-i386/mach-xen/asm/pgtable.h	Thu May 15 16:26:16 2008 +0900
     5.2 +++ b/include/asm-i386/mach-xen/asm/pgtable.h	Tue May 20 11:33:33 2008 +0900
     5.3 @@ -477,19 +477,16 @@ void make_page_writable(void *va, unsign
     5.4  void make_pages_readonly(void *va, unsigned int nr, unsigned int feature);
     5.5  void make_pages_writable(void *va, unsigned int nr, unsigned int feature);
     5.6  
     5.7 -#define virt_to_ptep(__va)						\
     5.8 +#define virt_to_ptep(va)						\
     5.9  ({									\
    5.10 -	pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));		\
    5.11 -	pud_t *__pud = pud_offset(__pgd, (unsigned long)(__va));	\
    5.12 -	pmd_t *__pmd = pmd_offset(__pud, (unsigned long)(__va));	\
    5.13 -	pte_offset_kernel(__pmd, (unsigned long)(__va));		\
    5.14 +	pte_t *__ptep = lookup_address((unsigned long)(va));		\
    5.15 +	BUG_ON(!__ptep || !pte_present(*__ptep));			\
    5.16 +	__ptep;								\
    5.17  })
    5.18  
    5.19 -#define arbitrary_virt_to_machine(__va)					\
    5.20 -({									\
    5.21 -	maddr_t m = (maddr_t)pte_mfn(*virt_to_ptep(__va)) << PAGE_SHIFT;\
    5.22 -	m | ((unsigned long)(__va) & (PAGE_SIZE-1));			\
    5.23 -})
    5.24 +#define arbitrary_virt_to_machine(va)					\
    5.25 +	(((maddr_t)pte_mfn(*virt_to_ptep(va)) << PAGE_SHIFT)		\
    5.26 +	 | ((unsigned long)(va) & (PAGE_SIZE - 1)))
    5.27  
    5.28  #endif /* !__ASSEMBLY__ */
    5.29  
     6.1 --- a/include/asm-x86_64/mach-xen/asm/pgtable.h	Thu May 15 16:26:16 2008 +0900
     6.2 +++ b/include/asm-x86_64/mach-xen/asm/pgtable.h	Tue May 20 11:33:33 2008 +0900
     6.3 @@ -18,19 +18,18 @@ extern pud_t level3_user_pgt[512];
     6.4  
     6.5  extern void xen_init_pt(void);
     6.6  
     6.7 -#define virt_to_ptep(__va)						\
     6.8 +extern pte_t *lookup_address(unsigned long address);
     6.9 +
    6.10 +#define virt_to_ptep(va)						\
    6.11  ({									\
    6.12 -	pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));		\
    6.13 -	pud_t *__pud = pud_offset(__pgd, (unsigned long)(__va));	\
    6.14 -	pmd_t *__pmd = pmd_offset(__pud, (unsigned long)(__va));	\
    6.15 -	pte_offset_kernel(__pmd, (unsigned long)(__va));		\
    6.16 +	pte_t *__ptep = lookup_address((unsigned long)(va));		\
    6.17 +	BUG_ON(!__ptep || !pte_present(*__ptep));			\
    6.18 +	__ptep;								\
    6.19  })
    6.20  
    6.21 -#define arbitrary_virt_to_machine(__va)					\
    6.22 -({									\
    6.23 -	maddr_t m = (maddr_t)pte_mfn(*virt_to_ptep(__va)) << PAGE_SHIFT;\
    6.24 -	m | ((unsigned long)(__va) & (PAGE_SIZE-1));			\
    6.25 -})
    6.26 +#define arbitrary_virt_to_machine(va)					\
    6.27 +	(((maddr_t)pte_mfn(*virt_to_ptep(va)) << PAGE_SHIFT)		\
    6.28 +	 | ((unsigned long)(va) & (PAGE_SIZE - 1)))
    6.29  #endif
    6.30  
    6.31  extern pud_t level3_kernel_pgt[512];
     7.1 --- a/include/xen/interface/sysctl.h	Thu May 15 16:26:16 2008 +0900
     7.2 +++ b/include/xen/interface/sysctl.h	Tue May 20 11:33:33 2008 +0900
     7.3 @@ -212,6 +212,40 @@ struct xen_sysctl_availheap {
     7.4  };
     7.5  typedef struct xen_sysctl_availheap xen_sysctl_availheap_t;
     7.6  DEFINE_XEN_GUEST_HANDLE(xen_sysctl_availheap_t);
     7.7 +
     7.8 +#define XEN_SYSCTL_get_pmstat        10
     7.9 +struct pm_px_val {
    7.10 +    uint64_aligned_t freq;        /* Px core frequency */
    7.11 +    uint64_aligned_t residency;   /* Px residency time */
    7.12 +    uint64_aligned_t count;       /* Px transition count */
    7.13 +};
    7.14 +typedef struct pm_px_val pm_px_val_t;
    7.15 +DEFINE_XEN_GUEST_HANDLE(pm_px_val_t);
    7.16 +
    7.17 +struct pm_px_stat {
    7.18 +    uint8_t total;        /* total Px states */
    7.19 +    uint8_t usable;       /* usable Px states */
    7.20 +    uint8_t last;         /* last Px state */
    7.21 +    uint8_t cur;          /* current Px state */
    7.22 +    XEN_GUEST_HANDLE_64(uint64) trans_pt;   /* Px transition table */
    7.23 +    XEN_GUEST_HANDLE_64(pm_px_val_t) pt;
    7.24 +};
    7.25 +typedef struct pm_px_stat pm_px_stat_t;
    7.26 +DEFINE_XEN_GUEST_HANDLE(pm_px_stat_t);
    7.27 +
    7.28 +struct xen_sysctl_get_pmstat {
    7.29 +#define PMSTAT_get_max_px   0x11
    7.30 +#define PMSTAT_get_pxstat   0x12
    7.31 +#define PMSTAT_reset_pxstat 0x13
    7.32 +    uint32_t type;
    7.33 +    uint32_t cpuid;
    7.34 +    union {
    7.35 +        struct pm_px_stat getpx;
    7.36 +        /* other struct for cx, tx, etc */
    7.37 +    } u;
    7.38 +};
    7.39 +typedef struct xen_sysctl_get_pmstat xen_sysctl_get_pmstat_t;
    7.40 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_get_pmstat_t);
    7.41   
    7.42  struct xen_sysctl {
    7.43      uint32_t cmd;
    7.44 @@ -226,6 +260,7 @@ struct xen_sysctl {
    7.45          struct xen_sysctl_debug_keys        debug_keys;
    7.46          struct xen_sysctl_getcpuinfo        getcpuinfo;
    7.47          struct xen_sysctl_availheap         availheap;
    7.48 +        struct xen_sysctl_get_pmstat        get_pmstat;
    7.49          uint8_t                             pad[128];
    7.50      } u;
    7.51  };