# HG changeset patch
# User Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
# Date 1211250813 -32400
# Node ID 6b0a85eb515569490f4a02876c95d2b1153d444a
# Parent 2d858799d109f2225882257c029c84ae10538972
# Parent 8ce60d057d0c4d4394df2c5fab4965d4ec189722
merge with linux-2.6.18-xen.hg
---
arch/x86_64/mm/init-xen.c | 54 +++++++++++++--------------
arch/x86_64/mm/pageattr-xen.c | 2 -
drivers/pci/msi-xen.c | 60 +++++++++++++++++++-----------
drivers/xen/balloon/balloon.c | 6 ++-
include/asm-i386/mach-xen/asm/pgtable.h | 17 +++-----
include/asm-x86_64/mach-xen/asm/pgtable.h | 19 ++++-----
include/xen/interface/sysctl.h | 35 +++++++++++++++++
7 files changed, 121 insertions(+), 72 deletions(-)
diff -r 2d858799d109 -r 6b0a85eb5155 arch/x86_64/mm/init-xen.c
--- a/arch/x86_64/mm/init-xen.c Thu May 15 16:26:16 2008 +0900
+++ b/arch/x86_64/mm/init-xen.c Tue May 20 11:33:33 2008 +0900
@@ -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) {
diff -r 2d858799d109 -r 6b0a85eb5155 arch/x86_64/mm/pageattr-xen.c
--- a/arch/x86_64/mm/pageattr-xen.c Thu May 15 16:26:16 2008 +0900
+++ b/arch/x86_64/mm/pageattr-xen.c Tue May 20 11:33:33 2008 +0900
@@ -276,7 +276,7 @@ void pte_free(struct page *pte)
}
#endif /* CONFIG_XEN */
-static inline pte_t *lookup_address(unsigned long address)
+pte_t *lookup_address(unsigned long address)
{
pgd_t *pgd = pgd_offset_k(address);
pud_t *pud;
diff -r 2d858799d109 -r 6b0a85eb5155 drivers/pci/msi-xen.c
--- a/drivers/pci/msi-xen.c Thu May 15 16:26:16 2008 +0900
+++ b/drivers/pci/msi-xen.c Tue May 20 11:33:33 2008 +0900
@@ -33,7 +33,6 @@ int msi_register(struct msi_ops *ops)
}
static LIST_HEAD(msi_dev_head);
-static int msi_dev_head_inited = 0;
DEFINE_SPINLOCK(msi_dev_lock);
struct msi_dev_list {
@@ -95,6 +94,23 @@ static int attach_pirq_entry(int pirq, i
list_add_tail(&entry->list, &msi_dev_entry->pirq_list_head);
spin_unlock_irqrestore(&msi_dev_entry->pirq_list_lock, flags);
return 0;
+}
+
+static void detach_pirq_entry(int entry_nr,
+ struct msi_dev_list
*msi_dev_entry)
+{
+ unsigned long flags;
+ struct msi_pirq_entry *pirq_entry;
+
+ list_for_each_entry(pirq_entry, &msi_dev_entry->pirq_list_head, list) {
+ if (pirq_entry->entry_nr == entry_nr) {
+ spin_lock_irqsave(&msi_dev_entry->pirq_list_lock,
flags);
+ list_del(&pirq_entry->list);
+ spin_unlock_irqrestore(&msi_dev_entry->pirq_list_lock,
flags);
+ kfree(pirq_entry);
+ return;
+ }
+ }
}
/*
@@ -379,40 +395,42 @@ static int msix_capability_init(struct p
static int msix_capability_init(struct pci_dev *dev,
struct msix_entry *entries, int nvec)
{
- int pirq, i, pos;
+ int pirq, i, j, mapped, pos;
struct msi_dev_list *msi_dev_entry = get_msi_dev_pirq_list(dev);
- struct msi_pirq_entry *pirq_entry, *tmp;
- unsigned long flags;
+ struct msi_pirq_entry *pirq_entry;
if (!msi_dev_entry)
return -ENOMEM;
- spin_lock_irqsave(&msi_dev_entry->pirq_list_lock, flags);
- if (!list_empty(&msi_dev_entry->pirq_list_head))
- {
- printk(KERN_WARNING "msix pirqs for dev %02x:%02x:%01x are not
freed \
- before acquire again.\n", dev->bus->number,
PCI_SLOT(dev->devfn),
- PCI_FUNC(dev->devfn));
- list_for_each_entry_safe(pirq_entry, tmp,
- &msi_dev_entry->pirq_list_head, list) {
- msi_unmap_pirq(dev, pirq_entry->pirq);
- list_del(&pirq_entry->list);
- kfree(pirq_entry);
- }
- }
- spin_unlock_irqrestore(&msi_dev_entry->pirq_list_lock, flags);
-
/* MSI-X Table Initialization */
for (i = 0; i < nvec; i++) {
+ mapped = 0;
+ list_for_each_entry(pirq_entry, &msi_dev_entry->pirq_list_head,
list) {
+ if (pirq_entry->entry_nr == entries[i].entry) {
+ printk(KERN_WARNING "msix entry %d for dev
%02x:%02x:%01x are \
+ not freed before acquire again.\n",
entries[i].entry,
+ dev->bus->number,
PCI_SLOT(dev->devfn),
+ PCI_FUNC(dev->devfn));
+ (entries + i)->vector = pirq_entry->pirq;
+ mapped = 1;
+ break;
+ }
+ }
+ if (mapped)
+ continue;
pirq = msi_map_vector(dev, entries[i].entry, 0);
if (pirq < 0)
break;
attach_pirq_entry(pirq, entries[i].entry, msi_dev_entry);
(entries + i)->vector = pirq;
}
+
if (i != nvec) {
- msi_unmap_pirq(dev, dev->irq);
- (entries + i)->vector = 0;
+ for (j = --i; j >= 0; j--) {
+ msi_unmap_pirq(dev, entries[j].vector);
+ detach_pirq_entry(entries[j].entry, msi_dev_entry);
+ entries[j].vector = 0;
+ }
return -EBUSY;
}
diff -r 2d858799d109 -r 6b0a85eb5155 drivers/xen/balloon/balloon.c
--- a/drivers/xen/balloon/balloon.c Thu May 15 16:26:16 2008 +0900
+++ b/drivers/xen/balloon/balloon.c Tue May 20 11:33:33 2008 +0900
@@ -197,8 +197,8 @@ static unsigned long minimum_target(void
static unsigned long minimum_target(void)
{
#ifndef CONFIG_XEN
- return 0;
-#else
+#define max_pfn num_physpages
+#endif
unsigned long min_pages, curr_pages = current_target();
#define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
@@ -226,6 +226,8 @@ static unsigned long minimum_target(void
/* Don't enforce growth */
return min(min_pages, curr_pages);
+#ifndef CONFIG_XEN
+#undef max_pfn
#endif
}
diff -r 2d858799d109 -r 6b0a85eb5155 include/asm-i386/mach-xen/asm/pgtable.h
--- a/include/asm-i386/mach-xen/asm/pgtable.h Thu May 15 16:26:16 2008 +0900
+++ b/include/asm-i386/mach-xen/asm/pgtable.h Tue May 20 11:33:33 2008 +0900
@@ -477,19 +477,16 @@ void make_pages_readonly(void *va, unsig
void make_pages_readonly(void *va, unsigned int nr, unsigned int feature);
void make_pages_writable(void *va, unsigned int nr, unsigned int feature);
-#define virt_to_ptep(__va) \
+#define virt_to_ptep(va) \
({ \
- pgd_t *__pgd = pgd_offset_k((unsigned long)(__va)); \
- pud_t *__pud = pud_offset(__pgd, (unsigned long)(__va)); \
- pmd_t *__pmd = pmd_offset(__pud, (unsigned long)(__va)); \
- pte_offset_kernel(__pmd, (unsigned long)(__va)); \
+ pte_t *__ptep = lookup_address((unsigned long)(va)); \
+ BUG_ON(!__ptep || !pte_present(*__ptep)); \
+ __ptep; \
})
-#define arbitrary_virt_to_machine(__va)
\
-({ \
- maddr_t m = (maddr_t)pte_mfn(*virt_to_ptep(__va)) << PAGE_SHIFT;\
- m | ((unsigned long)(__va) & (PAGE_SIZE-1)); \
-})
+#define arbitrary_virt_to_machine(va) \
+ (((maddr_t)pte_mfn(*virt_to_ptep(va)) << PAGE_SHIFT) \
+ | ((unsigned long)(va) & (PAGE_SIZE - 1)))
#endif /* !__ASSEMBLY__ */
diff -r 2d858799d109 -r 6b0a85eb5155 include/asm-x86_64/mach-xen/asm/pgtable.h
--- a/include/asm-x86_64/mach-xen/asm/pgtable.h Thu May 15 16:26:16 2008 +0900
+++ b/include/asm-x86_64/mach-xen/asm/pgtable.h Tue May 20 11:33:33 2008 +0900
@@ -18,19 +18,18 @@ extern pud_t level3_user_pgt[512];
extern void xen_init_pt(void);
-#define virt_to_ptep(__va) \
+extern pte_t *lookup_address(unsigned long address);
+
+#define virt_to_ptep(va) \
({ \
- pgd_t *__pgd = pgd_offset_k((unsigned long)(__va)); \
- pud_t *__pud = pud_offset(__pgd, (unsigned long)(__va)); \
- pmd_t *__pmd = pmd_offset(__pud, (unsigned long)(__va)); \
- pte_offset_kernel(__pmd, (unsigned long)(__va)); \
+ pte_t *__ptep = lookup_address((unsigned long)(va)); \
+ BUG_ON(!__ptep || !pte_present(*__ptep)); \
+ __ptep; \
})
-#define arbitrary_virt_to_machine(__va)
\
-({ \
- maddr_t m = (maddr_t)pte_mfn(*virt_to_ptep(__va)) << PAGE_SHIFT;\
- m | ((unsigned long)(__va) & (PAGE_SIZE-1)); \
-})
+#define arbitrary_virt_to_machine(va) \
+ (((maddr_t)pte_mfn(*virt_to_ptep(va)) << PAGE_SHIFT) \
+ | ((unsigned long)(va) & (PAGE_SIZE - 1)))
#endif
extern pud_t level3_kernel_pgt[512];
diff -r 2d858799d109 -r 6b0a85eb5155 include/xen/interface/sysctl.h
--- a/include/xen/interface/sysctl.h Thu May 15 16:26:16 2008 +0900
+++ b/include/xen/interface/sysctl.h Tue May 20 11:33:33 2008 +0900
@@ -212,6 +212,40 @@ struct xen_sysctl_availheap {
};
typedef struct xen_sysctl_availheap xen_sysctl_availheap_t;
DEFINE_XEN_GUEST_HANDLE(xen_sysctl_availheap_t);
+
+#define XEN_SYSCTL_get_pmstat 10
+struct pm_px_val {
+ uint64_aligned_t freq; /* Px core frequency */
+ uint64_aligned_t residency; /* Px residency time */
+ uint64_aligned_t count; /* Px transition count */
+};
+typedef struct pm_px_val pm_px_val_t;
+DEFINE_XEN_GUEST_HANDLE(pm_px_val_t);
+
+struct pm_px_stat {
+ uint8_t total; /* total Px states */
+ uint8_t usable; /* usable Px states */
+ uint8_t last; /* last Px state */
+ uint8_t cur; /* current Px state */
+ XEN_GUEST_HANDLE_64(uint64) trans_pt; /* Px transition table */
+ XEN_GUEST_HANDLE_64(pm_px_val_t) pt;
+};
+typedef struct pm_px_stat pm_px_stat_t;
+DEFINE_XEN_GUEST_HANDLE(pm_px_stat_t);
+
+struct xen_sysctl_get_pmstat {
+#define PMSTAT_get_max_px 0x11
+#define PMSTAT_get_pxstat 0x12
+#define PMSTAT_reset_pxstat 0x13
+ uint32_t type;
+ uint32_t cpuid;
+ union {
+ struct pm_px_stat getpx;
+ /* other struct for cx, tx, etc */
+ } u;
+};
+typedef struct xen_sysctl_get_pmstat xen_sysctl_get_pmstat_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_get_pmstat_t);
struct xen_sysctl {
uint32_t cmd;
@@ -226,6 +260,7 @@ struct xen_sysctl {
struct xen_sysctl_debug_keys debug_keys;
struct xen_sysctl_getcpuinfo getcpuinfo;
struct xen_sysctl_availheap availheap;
+ struct xen_sysctl_get_pmstat get_pmstat;
uint8_t pad[128];
} u;
};
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|