Skip to content

Commit

Permalink
Merge branch 'upstream/for-linus' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/jeremy/xen

* 'upstream/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen: (23 commits)
  xen/events: Use PIRQ instead of GSI value when unmapping MSI/MSI-X irqs.
  xen: set IO permission early (before early_cpu_init())
  xen: re-enable boot-time ballooning
  xen/balloon: make sure we only include remaining extra ram
  xen/balloon: the balloon_lock is useless
  xen: add extra pages to balloon
  xen: make evtchn's name less generic
  xen/evtchn: the evtchn device is non-seekable
  Revert "xen/privcmd: create address space to allow writable mmaps"
  xen/events: use locked set|clear_bit() for cpu_evtchn_mask
  xen/evtchn: clear secondary CPUs' cpu_evtchn_mask[] after restore
  xen/xenfs: update xenfs_mount for new prototype
  xen: fix header export to userspace
  xen: implement XENMEM_machphys_mapping
  xen: set vma flag VM_PFNMAP in the privcmd mmap file_op
  xen: xenfs: privcmd: check put_user() return code
  xen/evtchn: add missing static
  xen/evtchn: Fix name of Xen event-channel device
  xen/evtchn: don't do unbind_from_irqhandler under spinlock
  xen/evtchn: remove spurious barrier
  ...
  • Loading branch information
Linus Torvalds committed Nov 23, 2010
2 parents 3cbaa0f + 9b83215 commit a4ec046
Show file tree
Hide file tree
Showing 16 changed files with 186 additions and 126 deletions.
6 changes: 3 additions & 3 deletions arch/x86/include/asm/xen/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ DEFINE_GUEST_HANDLE(void);
#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
#endif

#ifndef machine_to_phys_mapping
#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
#endif
#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START)
#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END)
#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>__MACH2PHYS_SHIFT)

/* Maximum number of virtual CPUs in multi-processor guests. */
#define MAX_VIRT_CPUS 32
Expand Down
5 changes: 5 additions & 0 deletions arch/x86/include/asm/xen/interface_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
/* And the trap vector is... */
#define TRAP_INSTR "int $0x82"

#define __MACH2PHYS_VIRT_START 0xF5800000
#define __MACH2PHYS_VIRT_END 0xF6800000

#define __MACH2PHYS_SHIFT 2

/*
* Virtual addresses beyond this are not modifiable by guest OSes. The
* machine->physical mapping table starts at this address, read-only.
Expand Down
13 changes: 1 addition & 12 deletions arch/x86/include/asm/xen/interface_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,7 @@
#define __HYPERVISOR_VIRT_END 0xFFFF880000000000
#define __MACH2PHYS_VIRT_START 0xFFFF800000000000
#define __MACH2PHYS_VIRT_END 0xFFFF804000000000

#ifndef HYPERVISOR_VIRT_START
#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
#define HYPERVISOR_VIRT_END mk_unsigned_long(__HYPERVISOR_VIRT_END)
#endif

#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START)
#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END)
#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>3)
#ifndef machine_to_phys_mapping
#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
#endif
#define __MACH2PHYS_SHIFT 3

/*
* int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base)
Expand Down
7 changes: 4 additions & 3 deletions arch/x86/include/asm/xen/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <linux/types.h>
#include <linux/spinlock.h>
#include <linux/pfn.h>
#include <linux/mm.h>

#include <asm/uaccess.h>
#include <asm/page.h>
Expand Down Expand Up @@ -35,6 +36,8 @@ typedef struct xpaddr {
#define MAX_DOMAIN_PAGES \
((unsigned long)((u64)CONFIG_XEN_MAX_DOMAIN_MEMORY * 1024 * 1024 * 1024 / PAGE_SIZE))

extern unsigned long *machine_to_phys_mapping;
extern unsigned int machine_to_phys_order;

extern unsigned long get_phys_to_machine(unsigned long pfn);
extern bool set_phys_to_machine(unsigned long pfn, unsigned long mfn);
Expand Down Expand Up @@ -69,10 +72,8 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
if (xen_feature(XENFEAT_auto_translated_physmap))
return mfn;

#if 0
if (unlikely((mfn >> machine_to_phys_order) != 0))
return max_mapnr;
#endif
return ~0;

pfn = 0;
/*
Expand Down
19 changes: 18 additions & 1 deletion arch/x86/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info);
enum xen_domain_type xen_domain_type = XEN_NATIVE;
EXPORT_SYMBOL_GPL(xen_domain_type);

unsigned long *machine_to_phys_mapping = (void *)MACH2PHYS_VIRT_START;
EXPORT_SYMBOL(machine_to_phys_mapping);
unsigned int machine_to_phys_order;
EXPORT_SYMBOL(machine_to_phys_order);

struct start_info *xen_start_info;
EXPORT_SYMBOL_GPL(xen_start_info);

Expand Down Expand Up @@ -1090,13 +1095,17 @@ static void __init xen_setup_stackprotector(void)
/* First C function to be called on Xen boot */
asmlinkage void __init xen_start_kernel(void)
{
struct physdev_set_iopl set_iopl;
int rc;
pgd_t *pgd;

if (!xen_start_info)
return;

xen_domain_type = XEN_PV_DOMAIN;

xen_setup_machphys_mapping();

/* Install Xen paravirt ops */
pv_info = xen_info;
pv_init_ops = xen_init_ops;
Expand Down Expand Up @@ -1202,10 +1211,18 @@ asmlinkage void __init xen_start_kernel(void)
#else
pv_info.kernel_rpl = 0;
#endif

/* set the limit of our address space */
xen_reserve_top();

/* We used to do this in xen_arch_setup, but that is too late on AMD
* were early_cpu_init (run before ->arch_setup()) calls early_amd_init
* which pokes 0xcf8 port.
*/
set_iopl.iopl = 1;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
if (rc != 0)
xen_raw_printk("physdev_op failed %d\n", rc);

#ifdef CONFIG_X86_32
/* set up basic CPUID stuff */
cpu_detect(&new_cpu_data);
Expand Down
17 changes: 16 additions & 1 deletion arch/x86/xen/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,20 @@ static __init void xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
set_page_prot(pmd, PAGE_KERNEL_RO);
}

void __init xen_setup_machphys_mapping(void)
{
struct xen_machphys_mapping mapping;
unsigned long machine_to_phys_nr_ents;

if (HYPERVISOR_memory_op(XENMEM_machphys_mapping, &mapping) == 0) {
machine_to_phys_mapping = (unsigned long *)mapping.v_start;
machine_to_phys_nr_ents = mapping.max_mfn + 1;
} else {
machine_to_phys_nr_ents = MACH2PHYS_NR_ENTRIES;
}
machine_to_phys_order = fls(machine_to_phys_nr_ents - 1);
}

#ifdef CONFIG_X86_64
static void convert_pfn_mfn(void *v)
{
Expand Down Expand Up @@ -2627,7 +2641,8 @@ int xen_remap_domain_mfn_range(struct vm_area_struct *vma,

prot = __pgprot(pgprot_val(prot) | _PAGE_IOMAP);

vma->vm_flags |= VM_IO | VM_RESERVED | VM_PFNMAP;
BUG_ON(!((vma->vm_flags & (VM_PFNMAP | VM_RESERVED | VM_IO)) ==
(VM_PFNMAP | VM_RESERVED | VM_IO)));

rmd.mfn = mfn;
rmd.prot = prot;
Expand Down
11 changes: 1 addition & 10 deletions arch/x86/xen/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ char * __init xen_memory_setup(void)
else
extra_pages = 0;

if (!xen_initial_domain())
xen_add_extra_mem(extra_pages);
xen_add_extra_mem(extra_pages);

return "Xen";
}
Expand Down Expand Up @@ -337,9 +336,6 @@ void __cpuinit xen_enable_syscall(void)

void __init xen_arch_setup(void)
{
struct physdev_set_iopl set_iopl;
int rc;

xen_panic_handler_init();

HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
Expand All @@ -356,11 +352,6 @@ void __init xen_arch_setup(void)
xen_enable_sysenter();
xen_enable_syscall();

set_iopl.iopl = 1;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
if (rc != 0)
printk(KERN_INFO "physdev_op failed %d\n", rc);

#ifdef CONFIG_ACPI
if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
Expand Down
5 changes: 4 additions & 1 deletion drivers/xen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ obj-$(CONFIG_BLOCK) += biomerge.o
obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
obj-$(CONFIG_XEN_XENCOMM) += xencomm.o
obj-$(CONFIG_XEN_BALLOON) += balloon.o
obj-$(CONFIG_XEN_DEV_EVTCHN) += evtchn.o
obj-$(CONFIG_XEN_DEV_EVTCHN) += xen-evtchn.o
obj-$(CONFIG_XENFS) += xenfs/
obj-$(CONFIG_XEN_SYS_HYPERVISOR) += sys-hypervisor.o
obj-$(CONFIG_XEN_PLATFORM_PCI) += platform-pci.o
obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o
obj-$(CONFIG_XEN_DOM0) += pci.o

xen-evtchn-y := evtchn.o

32 changes: 17 additions & 15 deletions drivers/xen/balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <asm/pgtable.h>
#include <asm/uaccess.h>
#include <asm/tlb.h>
#include <asm/e820.h>

#include <asm/xen/hypervisor.h>
#include <asm/xen/hypercall.h>
Expand Down Expand Up @@ -119,7 +120,7 @@ static void scrub_page(struct page *page)
}

/* balloon_append: add the given page to the balloon. */
static void balloon_append(struct page *page)
static void __balloon_append(struct page *page)
{
/* Lowmem is re-populated first, so highmem pages go at list tail. */
if (PageHighMem(page)) {
Expand All @@ -130,7 +131,11 @@ static void balloon_append(struct page *page)
list_add(&page->lru, &ballooned_pages);
balloon_stats.balloon_low++;
}
}

static void balloon_append(struct page *page)
{
__balloon_append(page);
totalram_pages--;
}

Expand Down Expand Up @@ -191,7 +196,7 @@ static unsigned long current_target(void)

static int increase_reservation(unsigned long nr_pages)
{
unsigned long pfn, i, flags;
unsigned long pfn, i;
struct page *page;
long rc;
struct xen_memory_reservation reservation = {
Expand All @@ -203,8 +208,6 @@ static int increase_reservation(unsigned long nr_pages)
if (nr_pages > ARRAY_SIZE(frame_list))
nr_pages = ARRAY_SIZE(frame_list);

spin_lock_irqsave(&xen_reservation_lock, flags);

page = balloon_first_page();
for (i = 0; i < nr_pages; i++) {
BUG_ON(page == NULL);
Expand Down Expand Up @@ -247,14 +250,12 @@ static int increase_reservation(unsigned long nr_pages)
balloon_stats.current_pages += rc;

out:
spin_unlock_irqrestore(&xen_reservation_lock, flags);

return rc < 0 ? rc : rc != nr_pages;
}

static int decrease_reservation(unsigned long nr_pages)
{
unsigned long pfn, i, flags;
unsigned long pfn, i;
struct page *page;
int need_sleep = 0;
int ret;
Expand Down Expand Up @@ -292,8 +293,6 @@ static int decrease_reservation(unsigned long nr_pages)
kmap_flush_unused();
flush_tlb_all();

spin_lock_irqsave(&xen_reservation_lock, flags);

/* No more mappings: invalidate P2M and add to balloon. */
for (i = 0; i < nr_pages; i++) {
pfn = mfn_to_pfn(frame_list[i]);
Expand All @@ -308,8 +307,6 @@ static int decrease_reservation(unsigned long nr_pages)

balloon_stats.current_pages -= nr_pages;

spin_unlock_irqrestore(&xen_reservation_lock, flags);

return need_sleep;
}

Expand Down Expand Up @@ -395,7 +392,7 @@ static struct notifier_block xenstore_notifier;

static int __init balloon_init(void)
{
unsigned long pfn;
unsigned long pfn, extra_pfn_end;
struct page *page;

if (!xen_pv_domain())
Expand All @@ -416,10 +413,15 @@ static int __init balloon_init(void)
register_balloon(&balloon_sysdev);

/* Initialise the balloon with excess memory space. */
for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
extra_pfn_end = min(e820_end_of_ram_pfn(),
(unsigned long)PFN_DOWN(xen_extra_mem_start + xen_extra_mem_size));
for (pfn = PFN_UP(xen_extra_mem_start);
pfn < extra_pfn_end;
pfn++) {
page = pfn_to_page(pfn);
if (!PageReserved(page))
balloon_append(page);
/* totalram_pages doesn't include the boot-time
balloon extension, so don't subtract from it. */
__balloon_append(page);
}

target_watch.callback = watch_target;
Expand Down
13 changes: 8 additions & 5 deletions drivers/xen/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,25 +278,28 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)
cpumask_copy(irq_to_desc(irq)->affinity, cpumask_of(cpu));
#endif

__clear_bit(chn, cpu_evtchn_mask(cpu_from_irq(irq)));
__set_bit(chn, cpu_evtchn_mask(cpu));
clear_bit(chn, cpu_evtchn_mask(cpu_from_irq(irq)));
set_bit(chn, cpu_evtchn_mask(cpu));

irq_info[irq].cpu = cpu;
}

static void init_evtchn_cpu_bindings(void)
{
int i;
#ifdef CONFIG_SMP
struct irq_desc *desc;
int i;

/* By default all event channels notify CPU#0. */
for_each_irq_desc(i, desc) {
cpumask_copy(desc->affinity, cpumask_of(0));
}
#endif

memset(cpu_evtchn_mask(0), ~0, sizeof(struct cpu_evtchn_s));
for_each_possible_cpu(i)
memset(cpu_evtchn_mask(i),
(i == 0) ? ~0 : 0, sizeof(struct cpu_evtchn_s));

}

static inline void clear_evtchn(int port)
Expand Down Expand Up @@ -752,7 +755,7 @@ int xen_destroy_irq(int irq)
goto out;

if (xen_initial_domain()) {
unmap_irq.pirq = info->u.pirq.gsi;
unmap_irq.pirq = info->u.pirq.pirq;
unmap_irq.domid = DOMID_SELF;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_unmap_pirq, &unmap_irq);
if (rc) {
Expand Down
Loading

0 comments on commit a4ec046

Please sign in to comment.