# HG changeset patch
# User awilliam@xxxxxxxxxxxx
# Date 1166561381 25200
# Node ID 37309be2686190a25aa11241ac1a754437faca9d
# Parent baa07859f24f0687b4eef5a84422f4b6a747ded9
# Parent c3b455c4676c6446cd541d4c67a521609d046ddb
merge with xen-ia64-unstable.hg
---
.hgignore | 1
config/x86_32.mk | 1
config/x86_64.mk | 1
linux-2.6-xen-sparse/arch/ia64/kernel/asm-offsets.c | 1
linux-2.6-xen-sparse/arch/ia64/kernel/gate.S | 9
linux-2.6-xen-sparse/arch/ia64/xen/hypercall.S | 14
linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c | 2
linux-2.6-xen-sparse/arch/ia64/xen/xenivt.S | 27 +
linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c | 102 +++++-
linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h | 3
linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h | 3
tools/ioemu/target-i386-dm/exec-dm.c | 35 +-
tools/python/xen/xend/XendAPI.py | 5
tools/python/xen/xend/XendCheckpoint.py | 9
tools/python/xen/xend/XendConfig.py | 85 +++--
tools/python/xen/xend/XendDomain.py | 20 -
tools/python/xen/xend/XendDomainInfo.py | 5
tools/python/xen/xend/server/netif.py | 2
tools/python/xen/xend/server/vfbif.py | 40 +-
tools/python/xen/xm/XenAPI.py | 14
tools/python/xen/xm/create.py | 4
tools/python/xen/xm/main.py | 10
tools/xenfb/vncfb.c | 106 ++++++-
tools/xm-test/lib/XmTestLib/acm.py | 2
xen/arch/ia64/asm-offsets.c | 2
xen/arch/ia64/asm-xsi-offsets.c | 1
xen/arch/ia64/xen/faults.c | 3
xen/arch/ia64/xen/hyperprivop.S | 296 +-------------------
xen/arch/ia64/xen/ivt.S | 2
xen/arch/ia64/xen/vcpu.c | 1
xen/common/page_alloc.c | 12
xen/common/xenoprof.c | 2
xen/include/asm-ia64/linux-xen/asm/pgtable.h | 5
xen/include/xen/elfcore.h | 4
34 files changed, 420 insertions(+), 409 deletions(-)
diff -r baa07859f24f -r 37309be26861 .hgignore
--- a/.hgignore Tue Dec 19 13:21:24 2006 -0700
+++ b/.hgignore Tue Dec 19 13:49:41 2006 -0700
@@ -229,3 +229,4 @@
^unmodified_drivers/linux-2.6/.*\.cmd$
^unmodified_drivers/linux-2.6/.*\.ko$
^unmodified_drivers/linux-2.6/.*\.mod\.c$
+^LibVNCServer.*
diff -r baa07859f24f -r 37309be26861 config/x86_32.mk
--- a/config/x86_32.mk Tue Dec 19 13:21:24 2006 -0700
+++ b/config/x86_32.mk Tue Dec 19 13:49:41 2006 -0700
@@ -1,4 +1,5 @@ CONFIG_X86 := y
CONFIG_X86 := y
+CONFIG_X86_32 := y
CONFIG_X86_$(XEN_OS) := y
CONFIG_HVM := y
diff -r baa07859f24f -r 37309be26861 config/x86_64.mk
--- a/config/x86_64.mk Tue Dec 19 13:21:24 2006 -0700
+++ b/config/x86_64.mk Tue Dec 19 13:49:41 2006 -0700
@@ -1,4 +1,5 @@ CONFIG_X86 := y
CONFIG_X86 := y
+CONFIG_X86_64 := y
CONFIG_X86_$(XEN_OS) := y
CONFIG_HVM := y
diff -r baa07859f24f -r 37309be26861
linux-2.6-xen-sparse/arch/ia64/kernel/asm-offsets.c
--- a/linux-2.6-xen-sparse/arch/ia64/kernel/asm-offsets.c Tue Dec 19
13:21:24 2006 -0700
+++ b/linux-2.6-xen-sparse/arch/ia64/kernel/asm-offsets.c Tue Dec 19
13:49:41 2006 -0700
@@ -280,7 +280,6 @@ void foo(void)
DEFINE_MAPPED_REG_OFS(XSI_IHA_OFS, iha);
DEFINE_MAPPED_REG_OFS(XSI_ITIR_OFS, itir);
DEFINE_MAPPED_REG_OFS(XSI_PSR_IC_OFS, interrupt_collection_enabled);
- DEFINE_MAPPED_REG_OFS(XSI_PEND_OFS, pending_interruption);
DEFINE_MAPPED_REG_OFS(XSI_INCOMPL_REGFR_OFS, incomplete_regframe);
DEFINE_MAPPED_REG_OFS(XSI_BANKNUM_OFS, banknum);
DEFINE_MAPPED_REG_OFS(XSI_BANK0_R16_OFS, bank0_regs[0]);
diff -r baa07859f24f -r 37309be26861
linux-2.6-xen-sparse/arch/ia64/kernel/gate.S
--- a/linux-2.6-xen-sparse/arch/ia64/kernel/gate.S Tue Dec 19 13:21:24
2006 -0700
+++ b/linux-2.6-xen-sparse/arch/ia64/kernel/gate.S Tue Dec 19 13:49:41
2006 -0700
@@ -128,9 +128,9 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
;;
#ifdef CONFIG_XEN_IA64_VDSO_PARAVIRT
// r20 = 1
- // r22 = &vcpu->evtchn_mask
+ // r22 = &vcpu->vcpu_info->evtchn_upcall_mask
// r23 = &vpsr.ic
- // r24 = &vcpu->pending_interruption
+ // r24 = &vcpu->vcpu_info->evtchn_upcall_pending
// r25 = tmp
// r28 = &running_on_xen
// r30 = running_on_xen
@@ -144,8 +144,11 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
#define isRaw p13
LOAD_RUNNING_ON_XEN(r28)
movl r22=XSI_PSR_I_ADDR
+ ;;
+ ld8 r22=[r22]
+ ;;
movl r23=XSI_PSR_IC
- movl r24=XSI_PSR_I_ADDR+(XSI_PEND_OFS-XSI_PSR_I_ADDR_OFS)
+ adds r24=-1,r22
mov r20=1
;;
ld4 r30=[r28]
diff -r baa07859f24f -r 37309be26861
linux-2.6-xen-sparse/arch/ia64/xen/hypercall.S
--- a/linux-2.6-xen-sparse/arch/ia64/xen/hypercall.S Tue Dec 19 13:21:24
2006 -0700
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/hypercall.S Tue Dec 19 13:49:41
2006 -0700
@@ -356,8 +356,6 @@ END(xen_send_ipi)
// Those are vdso specialized.
// In fsys mode, call, ret can't be used.
GLOBAL_ENTRY(xen_rsm_be_i)
- ld8 r22=[r22]
- ;;
st1 [r22]=r20
st4 [r23]=r0
XEN_HYPER_RSM_BE
@@ -380,23 +378,23 @@ END(xen_get_psr)
END(xen_get_psr)
// see xen_ssm_i() in privop.h
- // r22 = &vcpu->evtchn_mask
+ // r22 = &vcpu->vcpu_info->evtchn_upcall_mask
// r23 = &vpsr.ic
- // r24 = &vcpu->pending_interruption
+ // r24 = &vcpu->vcpu_info->evtchn_upcall_pending
// r25 = tmp
// r31 = tmp
// p11 = tmp
// p14 = tmp
#define XEN_SET_PSR_I \
- ld4 r31=[r22]; \
- ld4 r25=[r24]; \
+ ld1 r31=[r22]; \
+ ld1 r25=[r24]; \
;; \
- st4 [r22]=r0; \
+ st1 [r22]=r0; \
cmp.ne.unc p14,p0=r0,r31; \
;; \
(p14) cmp.ne.unc p11,p0=r0,r25; \
;; \
-(p11) st4 [r22]=r20; \
+(p11) st1 [r22]=r20; \
(p11) st4 [r23]=r0; \
(p11) XEN_HYPER_SSM_I;
diff -r baa07859f24f -r 37309be26861
linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c Tue Dec 19 13:21:24
2006 -0700
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c Tue Dec 19 13:49:41
2006 -0700
@@ -60,7 +60,7 @@ contiguous_bitmap_init(unsigned long end
contiguous_bitmap_init(unsigned long end_pfn)
{
unsigned long size = (end_pfn + 2 * BITS_PER_LONG) >> 3;
- contiguous_bitmap = alloc_bootmem_low_pages(size);
+ contiguous_bitmap = alloc_bootmem_pages(size);
BUG_ON(!contiguous_bitmap);
memset(contiguous_bitmap, 0, size);
}
diff -r baa07859f24f -r 37309be26861 linux-2.6-xen-sparse/arch/ia64/xen/xenivt.S
--- a/linux-2.6-xen-sparse/arch/ia64/xen/xenivt.S Tue Dec 19 13:21:24
2006 -0700
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/xenivt.S Tue Dec 19 13:49:41
2006 -0700
@@ -737,10 +737,10 @@ xen_page_fault:
;;
(p15) ld8 r3=[r3]
;;
-(p15) st1 [r3]=r0,XSI_PEND_OFS-XSI_PSR_I_ADDR_OFS // if (p15) vpsr.i = 1
+(p15) st1 [r3]=r0,-1 // if (p15) vpsr.i = 1
mov r14=r0
;;
-(p15) ld4 r14=[r3] // if (pending_interrupts)
+(p15) ld1 r14=[r3] // if (pending_events)
adds r3=8,r2 // re-set up second base pointer
;;
(p15) cmp.ne p15,p0=r14,r0
@@ -1170,10 +1170,10 @@ 1:
#ifdef CONFIG_XEN
(p15) ld8 r16=[r16] // vpsr.i
;;
-(p15) st1 [r16]=r0,XSI_PEND_OFS-XSI_PSR_I_ADDR_OFS // if (p15) vpsr.i = 1
+(p15) st1 [r16]=r0,-1 // if (p15) vpsr.i = 1
mov r2=r0
;;
-(p15) ld4 r2=[r16] // if (pending_interrupts)
+(p15) ld1 r2=[r16] // if (pending_events)
;;
cmp.ne p6,p0=r2,r0
;;
@@ -2159,13 +2159,22 @@ GLOBAL_ENTRY(xen_event_callback)
;;
SAVE_REST
;;
+1:
alloc r14=ar.pfs,0,0,1,0 // must be first in an insn group
add out0=16,sp // pass pointer to pt_regs as first arg
;;
- srlz.d // make sure we see the effect of cr.ivr
- movl r14=ia64_leave_kernel
- ;;
- mov rp=r14
- br.call.sptk.many b6=evtchn_do_upcall
+ br.call.sptk.many b0=evtchn_do_upcall
+ ;;
+ movl r20=XSI_PSR_I_ADDR
+ ;;
+ ld8 r20=[r20]
+ ;;
+ adds r20=-1,r20 // vcpu_info->evtchn_upcall_pending
+ ;;
+ ld1 r20=[r20]
+ ;;
+ cmp.ne p6,p0=r20,r0 // if there are pending events,
+ (p6) br.spnt.few 1b // call evtchn_do_upcall again.
+ br.sptk.many ia64_leave_kernel
END(xen_event_callback)
#endif
diff -r baa07859f24f -r 37309be26861
linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c
--- a/linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c Tue Dec 19 13:21:24
2006 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c Tue Dec 19 13:49:41
2006 -0700
@@ -49,8 +49,9 @@ struct xenfb_info
struct timer_list refresh;
int dirty;
int x1, y1, x2, y2; /* dirty rectangle,
- protected by mm_lock */
- spinlock_t mm_lock;
+ protected by dirty_lock */
+ spinlock_t dirty_lock;
+ struct mutex mm_lock;
int nr_pages;
struct page **pages;
struct list_head mappings; /* protected by mm_lock */
@@ -63,6 +64,70 @@ struct xenfb_info
struct xenbus_device *xbdev;
};
+
+/*
+ * How the locks work together
+ *
+ * There are two locks: spinlock dirty_lock protecting the dirty
+ * rectangle, and mutex mm_lock protecting mappings.
+ *
+ * The problem is that dirty rectangle and mappings aren't
+ * independent: the dirty rectangle must cover all faulted pages in
+ * mappings. We need to prove that our locking maintains this
+ * invariant.
+ *
+ * There are several kinds of critical regions:
+ *
+ * 1. Holding only dirty_lock: xenfb_refresh(). May run in
+ * interrupts. Extends the dirty rectangle. Trivially preserves
+ * invariant.
+ *
+ * 2. Holding only mm_lock: xenfb_mmap() and xenfb_vm_close(). Touch
+ * only mappings. The former creates unfaulted pages. Preserves
+ * invariant. The latter removes pages. Preserves invariant.
+ *
+ * 3. Holding both locks: xenfb_vm_nopage(). Extends the dirty
+ * rectangle and updates mappings consistently. Preserves
+ * invariant.
+ *
+ * 4. The ugliest one: xenfb_update_screen(). Clear the dirty
+ * rectangle and update mappings consistently.
+ *
+ * We can't simply hold both locks, because zap_page_range() cannot
+ * be called with a spinlock held.
+ *
+ * Therefore, we first clear the dirty rectangle with both locks
+ * held. Then we unlock dirty_lock and update the mappings.
+ * Critical regions that hold only dirty_lock may interfere with
+ * that. This can only be region 1: xenfb_refresh(). But that
+ * just extends the dirty rectangle, which can't harm the
+ * invariant.
+ *
+ * But FIXME: the invariant is too weak. It misses that the fault
+ * record in mappings must be consistent with the mapping of pages in
+ * the associated address space! do_no_page() updates the PTE after
+ * xenfb_vm_nopage() returns, i.e. outside the critical region. This
+ * allows the following race:
+ *
+ * X writes to some address in the Xen frame buffer
+ * Fault - call do_no_page()
+ * call xenfb_vm_nopage()
+ * grab mm_lock
+ * map->faults++;
+ * release mm_lock
+ * return back to do_no_page()
+ * (preempted, or SMP)
+ * Xen worker thread runs.
+ * grab mm_lock
+ * look at mappings
+ * find this mapping, zaps its pages (but page not in pte yet)
+ * clear map->faults
+ * releases mm_lock
+ * (back to X process)
+ * put page in X's pte
+ *
+ * Oh well, we wont be updating the writes to this page anytime soon.
+ */
static int xenfb_fps = 20;
static unsigned long xenfb_mem_len = XENFB_WIDTH * XENFB_HEIGHT * XENFB_DEPTH
/ 8;
@@ -105,6 +170,7 @@ static int xenfb_queue_full(struct xenfb
static void xenfb_update_screen(struct xenfb_info *info)
{
+ unsigned long flags;
int y1, y2, x1, x2;
struct xenfb_mapping *map;
@@ -113,14 +179,16 @@ static void xenfb_update_screen(struct x
if (xenfb_queue_full(info))
return;
- spin_lock(&info->mm_lock);
-
+ mutex_lock(&info->mm_lock);
+
+ spin_lock_irqsave(&info->dirty_lock, flags);
y1 = info->y1;
y2 = info->y2;
x1 = info->x1;
x2 = info->x2;
info->x1 = info->y1 = INT_MAX;
info->x2 = info->y2 = 0;
+ spin_unlock_irqrestore(&info->dirty_lock, flags);
list_for_each_entry(map, &info->mappings, link) {
if (!map->faults)
@@ -130,7 +198,7 @@ static void xenfb_update_screen(struct x
map->faults = 0;
}
- spin_unlock(&info->mm_lock);
+ mutex_unlock(&info->mm_lock);
xenfb_do_update(info, x1, y1, x2 - x1, y2 - y1);
}
@@ -213,9 +281,11 @@ static void xenfb_refresh(struct xenfb_i
static void xenfb_refresh(struct xenfb_info *info,
int x1, int y1, int w, int h)
{
- spin_lock(&info->mm_lock);
+ unsigned long flags;
+
+ spin_lock_irqsave(&info->dirty_lock, flags);
__xenfb_refresh(info, x1, y1, w, h);
- spin_unlock(&info->mm_lock);
+ spin_unlock_irqrestore(&info->dirty_lock, flags);
}
static void xenfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
@@ -253,12 +323,12 @@ static void xenfb_vm_close(struct vm_are
struct xenfb_mapping *map = vma->vm_private_data;
struct xenfb_info *info = map->info;
- spin_lock(&info->mm_lock);
+ mutex_lock(&info->mm_lock);
if (atomic_dec_and_test(&map->map_refs)) {
list_del(&map->link);
kfree(map);
}
- spin_unlock(&info->mm_lock);
+ mutex_unlock(&info->mm_lock);
}
static struct page *xenfb_vm_nopage(struct vm_area_struct *vma,
@@ -267,13 +337,15 @@ static struct page *xenfb_vm_nopage(stru
struct xenfb_mapping *map = vma->vm_private_data;
struct xenfb_info *info = map->info;
int pgnr = (vaddr - vma->vm_start) >> PAGE_SHIFT;
+ unsigned long flags;
struct page *page;
int y1, y2;
if (pgnr >= info->nr_pages)
return NOPAGE_SIGBUS;
- spin_lock(&info->mm_lock);
+ mutex_lock(&info->mm_lock);
+ spin_lock_irqsave(&info->dirty_lock, flags);
page = info->pages[pgnr];
get_page(page);
map->faults++;
@@ -283,7 +355,8 @@ static struct page *xenfb_vm_nopage(stru
if (y2 > info->fb_info->var.yres)
y2 = info->fb_info->var.yres;
__xenfb_refresh(info, 0, y1, info->fb_info->var.xres, y2 - y1);
- spin_unlock(&info->mm_lock);
+ spin_unlock_irqrestore(&info->dirty_lock, flags);
+ mutex_unlock(&info->mm_lock);
if (type)
*type = VM_FAULT_MINOR;
@@ -323,9 +396,9 @@ static int xenfb_mmap(struct fb_info *fb
map->info = info;
atomic_set(&map->map_refs, 1);
- spin_lock(&info->mm_lock);
+ mutex_lock(&info->mm_lock);
list_add(&map->link, &info->mappings);
- spin_unlock(&info->mm_lock);
+ mutex_unlock(&info->mm_lock);
vma->vm_ops = &xenfb_vm_ops;
vma->vm_flags |= (VM_DONTEXPAND | VM_RESERVED);
@@ -382,7 +455,8 @@ static int __devinit xenfb_probe(struct
info->xbdev = dev;
info->irq = -1;
info->x1 = info->y1 = INT_MAX;
- spin_lock_init(&info->mm_lock);
+ spin_lock_init(&info->dirty_lock);
+ mutex_init(&info->mm_lock);
init_waitqueue_head(&info->wq);
init_timer(&info->refresh);
info->refresh.function = xenfb_timer;
diff -r baa07859f24f -r 37309be26861
linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Tue Dec 19
13:21:24 2006 -0700
+++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Tue Dec 19
13:49:41 2006 -0700
@@ -215,7 +215,8 @@ asmlinkage int xprintk(const char *fmt,
#endif /* CONFIG_XEN || CONFIG_VMX_GUEST */
#ifdef CONFIG_XEN_PRIVILEGED_GUEST
-#define is_initial_xendomain() (xen_start_info->flags & SIF_INITDOMAIN)
+#define is_initial_xendomain() \
+ (is_running_on_xen() ? xen_start_info->flags & SIF_INITDOMAIN : 0)
#else
#define is_initial_xendomain() 0
#endif
diff -r baa07859f24f -r 37309be26861
linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h Tue Dec 19
13:21:24 2006 -0700
+++ b/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h Tue Dec 19
13:49:41 2006 -0700
@@ -113,7 +113,8 @@ extern void xen_set_eflag(unsigned long)
({ XSI_PSR_I = (uint8_t)(_val) ? 0 : 1; })
#define xen_set_virtual_psr_ic(_val) \
({ XEN_MAPPEDREGS->interrupt_collection_enabled = _val ? 1 : 0; })
-#define xen_get_virtual_pend() (XEN_MAPPEDREGS->pending_interruption)
+#define xen_get_virtual_pend() \
+ (*(((uint8_t *)XEN_MAPPEDREGS->interrupt_mask_addr) - 1))
/* Hyperprivops are "break" instructions with a well-defined API.
* In particular, the virtual psr.ic bit must be off; in this way
diff -r baa07859f24f -r 37309be26861 tools/ioemu/target-i386-dm/exec-dm.c
--- a/tools/ioemu/target-i386-dm/exec-dm.c Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/ioemu/target-i386-dm/exec-dm.c Tue Dec 19 13:49:41 2006 -0700
@@ -128,10 +128,28 @@ FILE *logfile;
FILE *logfile;
int loglevel;
+
+#if defined(__i386__) || defined(__x86_64__)
+#define MAPCACHE
+#endif
+
+#ifdef MAPCACHE
+static pthread_mutex_t mapcache_mutex;
+#define mapcache_lock() pthread_mutex_lock(&mapcache_mutex)
+#define mapcache_unlock() pthread_mutex_unlock(&mapcache_mutex)
+#else
+#define mapcache_lock() ( (void)0 )
+#define mapcache_unlock() ( (void)0 )
+#endif
+
+
void cpu_exec_init(CPUState *env)
{
CPUState **penv;
int cpu_index;
+#ifdef MAPCACHE
+ pthread_mutexattr_t mxattr;
+#endif
env->next_cpu = NULL;
penv = &first_cpu;
@@ -145,6 +163,14 @@ void cpu_exec_init(CPUState *env)
/* alloc dirty bits array */
phys_ram_dirty = qemu_malloc(phys_ram_size >> TARGET_PAGE_BITS);
+
+#ifdef MAPCACHE
+ /* setup memory access mutex to protect mapcache */
+ pthread_mutexattr_init(&mxattr);
+ pthread_mutexattr_settype(&mxattr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&mapcache_mutex, &mxattr);
+ pthread_mutexattr_destroy(&mxattr);
+#endif
}
/* enable or disable low levels log */
@@ -440,10 +466,7 @@ void cpu_physical_memory_rw(target_phys_
uint8_t *ptr;
uint32_t val;
-#if defined(__i386__) || defined(__x86_64__)
- static pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
- pthread_mutex_lock(&mutex);
-#endif
+ mapcache_lock();
while (len > 0) {
/* How much can we copy before the next page boundary? */
@@ -510,9 +533,7 @@ void cpu_physical_memory_rw(target_phys_
addr += l;
}
-#if defined(__i386__) || defined(__x86_64__)
- pthread_mutex_unlock(&mutex);
-#endif
+ mapcache_unlock();
}
#endif
diff -r baa07859f24f -r 37309be26861 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/python/xen/xend/XendAPI.py Tue Dec 19 13:49:41 2006 -0700
@@ -663,7 +663,10 @@ class XendAPI:
XendDomain.instance().get_vm_by_uuid(vm_ref).info[name])
def VM_set(self, name, session, vm_ref, value):
- XendDomain.instance().get_vm_by_uuid(vm_ref).info[name] = value
+ xd = XendDomain.instance()
+ dominfo = xd.get_vm_by_uuid(vm_ref)
+ dominfo.info[name] = value
+ xd.managed_config_save(dominfo)
return xen_api_success_void()
# attributes (ro)
diff -r baa07859f24f -r 37309be26861 tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/python/xen/xend/XendCheckpoint.py Tue Dec 19 13:49:41 2006 -0700
@@ -218,18 +218,17 @@ def forkHelper(cmd, fd, inputHandler, cl
log.debug('%s', line)
inputHandler(line, child.tochild)
- thread.join()
-
except IOError, exn:
raise XendError('Error reading from child process for %s: %s' %
(cmd, exn))
finally:
child.fromchild.close()
- child.childerr.close()
if not closeToChild:
child.tochild.close()
-
- status = child.wait()
+ thread.join()
+ child.childerr.close()
+ status = child.wait()
+
if status >> 8 == 127:
raise XendError("%s failed: popen failed" % string.join(cmd))
elif status != 0:
diff -r baa07859f24f -r 37309be26861 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/python/xen/xend/XendConfig.py Tue Dec 19 13:49:41 2006 -0700
@@ -15,6 +15,7 @@
# Copyright (C) 2006 XenSource Ltd
#============================================================================
+import logging
import re
import time
import types
@@ -23,9 +24,12 @@ from xen.xend import uuid
from xen.xend import uuid
from xen.xend.XendError import VmError
from xen.xend.XendDevices import XendDevices
-from xen.xend.XendLogging import log
from xen.xend.PrettyPrint import prettyprintstring
from xen.xend.XendConstants import DOM_STATE_HALTED
+
+log = logging.getLogger("xend.XendConfig")
+log.setLevel(logging.WARN)
+
"""
XendConfig API
@@ -81,6 +85,7 @@ XENAPI_CFG_TO_LEGACY_CFG = {
XENAPI_CFG_TO_LEGACY_CFG = {
'uuid': 'uuid',
'vcpus_number': 'vcpus',
+ 'cpus': 'cpus',
'memory_static_min': 'memory',
'memory_static_max': 'maxmem',
'name_label': 'name',
@@ -182,18 +187,18 @@ LEGACY_CFG_TYPES = {
'shadow_memory': int,
'maxmem': int,
'start_time': float,
- 'cpu_cap': int,
- 'cpu_weight': int,
+ 'cpu_cap': int,
+ 'cpu_weight': int,
'cpu_time': float,
- 'features': str,
- 'localtime': int,
- 'name': str,
- 'on_poweroff': str,
- 'on_reboot': str,
- 'on_crash': str,
- 'on_xend_stop': str,
+ 'features': str,
+ 'localtime': int,
+ 'name': str,
+ 'on_poweroff': str,
+ 'on_reboot': str,
+ 'on_crash': str,
+ 'on_xend_stop': str,
'on_xend_start': str,
- 'online_vcpus': int,
+ 'online_vcpus': int,
}
# Values that should be stored in xenstore's /vm/<uuid> that is used
@@ -430,8 +435,12 @@ class XendConfig(dict):
"""
cfg = {}
- # First step is to convert deprecated options to
- # current equivalents.
+ for key, typ in XENAPI_CFG_TYPES.items():
+ val = sxp.child_value(sxp_cfg, key)
+ if val is not None:
+ cfg[key] = typ(val)
+
+ # Convert deprecated options to current equivalents.
restart = sxp.child_value(sxp_cfg, 'restart')
if restart:
@@ -574,7 +583,14 @@ class XendConfig(dict):
"""Read in an SXP Configuration object and
populate at much of the Xen API with valid values.
"""
+ log.debug('_sxp_to_xapi(%s)' % scrub_password(sxp_cfg))
+
cfg = self._parse_sxp(sxp_cfg)
+
+ for key, typ in XENAPI_CFG_TYPES.items():
+ val = cfg.get(key)
+ if val is not None:
+ self[key] = typ(val)
# Convert parameters that can be directly mapped from
# the Legacy Config to Xen API Config
@@ -590,9 +606,13 @@ class XendConfig(dict):
except KeyError:
pass
- self['PV_bootloader'] = cfg.get('bootloader', '')
- self['PV_bootloader_args'] = cfg.get('bootloader_args', '')
-
+ def update_with(n, o):
+ if not self.get(n):
+ self[n] = cfg.get(o, '')
+
+ update_with('PV_bootloader', 'bootloader')
+ update_with('PV_bootloader_args', 'bootloader_args')
+
image_sxp = sxp.child_value(sxp_cfg, 'image', [])
if image_sxp:
self.update_with_image_sxp(image_sxp)
@@ -634,6 +654,8 @@ class XendConfig(dict):
values are that not related directly supported in
the Xen API.
"""
+
+ log.debug('_sxp_to_xapi_unsupported(%s)' % scrub_password(sxp_cfg))
# Parse and convert parameters used to configure
# the image (as well as HVM images)
@@ -748,6 +770,9 @@ class XendConfig(dict):
@param xapi: Xen API VM Struct
@type xapi: dict
"""
+
+ log.debug('update_with_xenapi_config: %s' % scrub_password(xapi))
+
for key, val in xapi.items():
type_conv = XENAPI_CFG_TYPES.get(key)
if type_conv is None:
@@ -760,11 +785,8 @@ class XendConfig(dict):
self.validate()
- def to_xml(self):
- """Return an XML string representing the configuration."""
- pass
-
- def to_sxp(self, domain = None, ignore_devices = False, ignore = []):
+ def to_sxp(self, domain = None, ignore_devices = False, ignore = [],
+ legacy_only = True):
""" Get SXP representation of this config object.
Incompat: removed store_mfn, console_mfn
@@ -784,6 +806,11 @@ class XendConfig(dict):
if domain.getDomid() is not None:
sxpr.append(['domid', domain.getDomid()])
+
+ if not legacy_only:
+ for name in XENAPI_CFG_TYPES.keys():
+ if name in self and self[name] not in (None, []):
+ sxpr.append([name, str(self[name])])
for xenapi, legacy in XENAPI_CFG_TO_LEGACY_CFG.items():
if self.has_key(xenapi) and self[xenapi] not in (None, []):
@@ -1044,12 +1071,12 @@ class XendConfig(dict):
"""Returns a backwards compatible image SXP expression that is
used in xenstore's /vm/<uuid>/image value and xm list."""
image = [self['image'].get('type', 'linux')]
- if self.has_key('kernel_kernel'):
- image.append(['kernel', self['kernel_kernel']])
- if self.has_key('kernel_initrd') and self['kernel_initrd']:
- image.append(['ramdisk', self['kernel_initrd']])
- if self.has_key('kernel_args') and self['kernel_args']:
- image.append(['args', self['kernel_args']])
+ if self.has_key('PV_kernel'):
+ image.append(['kernel', self['PV_kernel']])
+ if self.has_key('PV_ramdisk') and self['PV_ramdisk']:
+ image.append(['ramdisk', self['PV_ramdisk']])
+ if self.has_key('PV_args') and self['PV_args']:
+ image.append(['args', self['PV_args']])
for arg, conv in LEGACY_IMAGE_CFG:
if self['image'].has_key(arg):
@@ -1069,8 +1096,10 @@ class XendConfig(dict):
return image
def update_with_image_sxp(self, image_sxp):
- # Convert Legacy "image" config to Xen API kernel_*
+ # Convert Legacy "image" config to Xen API PV_*
# configuration
+ log.debug("update_with_image_sxp(%s)" % scrub_password(image_sxp))
+
self['PV_kernel'] = sxp.child_value(image_sxp, 'kernel','')
self['PV_ramdisk'] = sxp.child_value(image_sxp, 'ramdisk','')
kernel_args = sxp.child_value(image_sxp, 'args', '')
diff -r baa07859f24f -r 37309be26861 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/python/xen/xend/XendDomain.py Tue Dec 19 13:49:41 2006 -0700
@@ -26,6 +26,7 @@ import stat
import stat
import shutil
import socket
+import tempfile
import threading
import xen.lowlevel.xc
@@ -280,16 +281,21 @@ class XendDomain:
make_or_raise(domain_config_dir)
try:
- sxp_cache_file = open(self._managed_config_path(dom_uuid),'w')
- prettyprint(dominfo.sxpr(), sxp_cache_file, width = 78)
- sxp_cache_file.close()
+ fd, fn = tempfile.mkstemp()
+ f = os.fdopen(fd, 'w+b')
+ try:
+ prettyprint(dominfo.sxpr(legacy_only = False), f,
+ width = 78)
+ finally:
+ f.close()
+ try:
+ os.rename(fn, self._managed_config_path(dom_uuid))
+ except:
+ log.exception("Renaming %s" % fn)
+ os.remove(fn)
except:
log.exception("Error occurred saving configuration file " +
"to %s" % domain_config_dir)
- try:
- self._managed_domain_remove(dom_uuid)
- except:
- pass
raise XendError("Failed to save configuration file to: %s" %
domain_config_dir)
else:
diff -r baa07859f24f -r 37309be26861 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/python/xen/xend/XendDomainInfo.py Tue Dec 19 13:49:41 2006 -0700
@@ -1800,9 +1800,10 @@ class XendDomainInfo:
log.trace("XendDomainInfo.update done on domain %s: %s",
str(self.domid), self.info)
- def sxpr(self, ignore_store = False):
+ def sxpr(self, ignore_store = False, legacy_only = True):
result = self.info.to_sxp(domain = self,
- ignore_devices = ignore_store)
+ ignore_devices = ignore_store,
+ legacy_only = legacy_only)
if not ignore_store and self.dompath:
vnc_port = self.readDom('console/vnc-port')
diff -r baa07859f24f -r 37309be26861 tools/python/xen/xend/server/netif.py
--- a/tools/python/xen/xend/server/netif.py Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/python/xen/xend/server/netif.py Tue Dec 19 13:49:41 2006 -0700
@@ -140,7 +140,7 @@ class NetifController(DevController):
script = os.path.join(xroot.network_script_dir,
config.get('script', xroot.get_vif_script()))
- typ = config.get('type')
+ typ = config.get('type')
bridge = config.get('bridge')
mac = config.get('mac')
vifname = config.get('vifname')
diff -r baa07859f24f -r 37309be26861 tools/python/xen/xend/server/vfbif.py
--- a/tools/python/xen/xend/server/vfbif.py Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/python/xen/xend/server/vfbif.py Tue Dec 19 13:49:41 2006 -0700
@@ -1,4 +1,5 @@ from xen.xend.server.DevController impor
from xen.xend.server.DevController import DevController
+from xen.xend.XendLogging import log
from xen.xend.XendError import VmError
import xen.xend
@@ -12,6 +13,9 @@ def spawn_detached(path, args, env):
else:
os.waitpid(p, 0)
+CONFIG_ENTRIES = ['type', 'vncdisplay', 'vnclisten', 'vncpasswd', 'vncunused',
+ 'display', 'xauthority']
+
class VfbifController(DevController):
"""Virtual frame buffer controller. Handles all vfb devices for a domain.
Note that we only support a single vfb per domain at the moment.
@@ -19,28 +23,42 @@ class VfbifController(DevController):
def __init__(self, vm):
DevController.__init__(self, vm)
- self.config = {}
def getDeviceDetails(self, config):
"""@see DevController.getDeviceDetails"""
- devid = 0
- back = {}
- front = {}
- return (devid, back, front)
+
+ back = dict([(k, config[k]) for k in CONFIG_ENTRIES
+ if config.has_key(k)])
+
+ return (0, back, {})
+
def getDeviceConfiguration(self, devid):
- r = DevController.getDeviceConfiguration(self, devid)
- for (k,v) in self.config.iteritems():
- r[k] = v
- return r
-
+ result = DevController.getDeviceConfiguration(self, devid)
+
+ devinfo = self.readBackend(devid, *CONFIG_ENTRIES)
+ return dict([(CONFIG_ENTRIES[i], devinfo[i])
+ for i in range(len(CONFIG_ENTRIES))
+ if devinfo[i] is not None])
+
+
def createDevice(self, config):
DevController.createDevice(self, config)
- self.config = config
std_args = [ "--domid", "%d" % self.vm.getDomid(),
"--title", self.vm.getName() ]
t = config.get("type", None)
if t == "vnc":
+ passwd = None
+ if config.has_key("vncpasswd"):
+ passwd = config["vncpasswd"]
+ else:
+ passwd = xen.xend.XendRoot.instance().get_vncpasswd_default()
+ if passwd:
+ self.vm.storeVm("vncpasswd", passwd)
+ log.debug("Stored a VNC password for vfb access")
+ else:
+ log.debug("No VNC passwd configured for vfb access")
+
# Try to start the vnc backend
args = [xen.util.auxbin.pathTo("xen-vncfb")]
if config.has_key("vncunused"):
diff -r baa07859f24f -r 37309be26861 tools/python/xen/xm/XenAPI.py
--- a/tools/python/xen/xm/XenAPI.py Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/python/xen/xm/XenAPI.py Tue Dec 19 13:49:41 2006 -0700
@@ -83,20 +83,24 @@ class Session(xen.util.xmlrpclib2.Server
def xenapi_request(self, methodname, params):
- full_params = (self._session,) + params
- return _parse_result(getattr(self, methodname)(*full_params))
+ if methodname.startswith('login'):
+ self._login(methodname, params)
+ return None
+ else:
+ full_params = (self._session,) + params
+ return _parse_result(getattr(self, methodname)(*full_params))
- def _login(self, method, username, password):
+ def _login(self, method, params):
self._session = _parse_result(
- getattr(self, 'session.%s' % method)(username, password))
+ getattr(self, 'session.%s' % method)(*params))
def __getattr__(self, name):
if name == 'xenapi':
return _Dispatcher(self.xenapi_request, None)
elif name.startswith('login'):
- return lambda u, p: self._login(name, u, p)
+ return lambda *params: self._login(name, params)
else:
return xen.util.xmlrpclib2.ServerProxy.__getattr__(self, name)
diff -r baa07859f24f -r 37309be26861 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/python/xen/xm/create.py Tue Dec 19 13:49:41 2006 -0700
@@ -284,7 +284,7 @@ gopts.var('usbport', val='PATH',
use="""Add a physical USB port to a domain, as specified by the path
to that port. This option may be repeated to add more than one
port.""")
-gopts.var('vfb',
val="type={vnc,sdl},vncunused=1,vncdisplay=N,vnclisten=ADDR,display=DISPLAY,xauthority=XAUTHORITY",
+gopts.var('vfb',
val="type={vnc,sdl},vncunused=1,vncdisplay=N,vnclisten=ADDR,display=DISPLAY,xauthority=XAUTHORITY,vncpasswd=PASSWORD",
fn=append_value, default=[],
use="""Make the domain a framebuffer backend.
The backend type should be either sdl or vnc.
@@ -584,7 +584,7 @@ def configure_vfbs(config_devs, vals):
d['type'] = 'sdl'
for (k,v) in d.iteritems():
if not k in [ 'vnclisten', 'vncunused', 'vncdisplay', 'display',
- 'xauthority', 'type' ]:
+ 'xauthority', 'type', 'vncpasswd' ]:
err("configuration option %s unknown to vfbs" % k)
config.append([k,v])
if not d.has_key("display") and os.environ.has_key("DISPLAY"):
diff -r baa07859f24f -r 37309be26861 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/python/xen/xm/main.py Tue Dec 19 13:49:41 2006 -0700
@@ -558,7 +558,7 @@ class Shell(cmd.Cmd):
ok, res = _run_cmd(lambda x: server.xenapi_request(words[0],
tuple(x)),
words[0], words[1:])
- if ok and res != '':
+ if ok and res is not None and res != '':
pprint.pprint(res)
else:
print '*** Unknown command: %s' % words[0]
@@ -1556,7 +1556,11 @@ def detach(args, command, deviceClass):
def xm_block_detach(args):
- detach(args, 'block-detach', 'vbd')
+ try:
+ detach(args, 'block-detach', 'vbd')
+ return
+ except:
+ pass
detach(args, 'block-detach', 'tap')
@@ -1798,7 +1802,7 @@ def _run_cmd(cmd, cmd_name, args):
except OptionError, e:
err(str(e))
_usage(cmd_name)
- print e.usage()
+ print e.usage
except security.ACMError, e:
err(str(e))
except:
diff -r baa07859f24f -r 37309be26861 tools/xenfb/vncfb.c
--- a/tools/xenfb/vncfb.c Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/xenfb/vncfb.c Tue Dec 19 13:49:41 2006 -0700
@@ -148,6 +148,10 @@ static int xk2linux[0x10000] = {
[XK_plus] = KEY_EQUAL,
};
+static int btnmap[] = {
+ BTN_LEFT, BTN_MIDDLE, BTN_RIGHT, BTN_FORWARD, BTN_BACK
+};
+
static void on_kbd_event(rfbBool down, rfbKeySym keycode, rfbClientPtr cl)
{
/*
@@ -184,8 +188,11 @@ static void on_ptr_event(int buttonMask,
down = buttonMask & (1 << i);
if (down == last_down)
continue;
- /* FIXME this assumes buttons are numbered the same; verify
they are */
- if (xenfb_send_key(xenfb, down != 0, BTN_MOUSE + i) < 0)
+ if (i >= sizeof(btnmap) / sizeof(*btnmap))
+ break;
+ if (btnmap[i] == 0)
+ break;
+ if (xenfb_send_key(xenfb, down != 0, btnmap[i]) < 0)
fprintf(stderr, "Button %d %s lost (%s)\n",
i, down ? "down" : "up", strerror(errno));
}
@@ -205,15 +212,10 @@ static void on_ptr_event(int buttonMask,
last_y = y;
}
-static void xenstore_write_vncport(int port, int domid)
-{
- char *buf = NULL, *path;
+static void xenstore_write_vncport(struct xs_handle *xsh, int port, int domid)
+{
+ char *buf, *path;
char portstr[10];
- struct xs_handle *xsh = NULL;
-
- xsh = xs_daemon_open();
- if (xsh == NULL)
- return;
path = xs_get_domain_path(xsh, domid);
if (path == NULL) {
@@ -240,6 +242,56 @@ static void xenstore_write_vncport(int p
free(buf);
}
+
+static int xenstore_read_vncpasswd(struct xs_handle *xsh, int domid, char
*pwbuf, int pwbuflen)
+{
+ char buf[256], *path, *uuid = NULL, *passwd = NULL;
+ unsigned int len, rc = 0;
+
+ if (xsh == NULL) {
+ return -1;
+ }
+
+ path = xs_get_domain_path(xsh, domid);
+ if (path == NULL) {
+ fprintf(stderr, "xs_get_domain_path() error\n");
+ return -1;
+ }
+
+ snprintf(buf, 256, "%s/vm", path);
+ uuid = xs_read(xsh, XBT_NULL, buf, &len);
+ if (uuid == NULL) {
+ fprintf(stderr, "xs_read(): uuid get error\n");
+ free(path);
+ return -1;
+ }
+
+ snprintf(buf, 256, "%s/vncpasswd", uuid);
+ passwd = xs_read(xsh, XBT_NULL, buf, &len);
+ if (passwd == NULL) {
+ free(uuid);
+ free(path);
+ return rc;
+ }
+
+ strncpy(pwbuf, passwd, pwbuflen-1);
+ pwbuf[pwbuflen-1] = '\0';
+
+ fprintf(stderr, "Got a VNC password read from XenStore\n");
+
+ passwd[0] = '\0';
+ snprintf(buf, 256, "%s/vncpasswd", uuid);
+ if (xs_write(xsh, XBT_NULL, buf, passwd, len) == 0) {
+ fprintf(stderr, "xs_write() vncpasswd failed\n");
+ rc = -1;
+ }
+
+ free(passwd);
+ free(uuid);
+ free(path);
+
+ return rc;
+}
static void vnc_update(struct xenfb *xenfb, int x, int y, int w, int h)
{
@@ -274,6 +326,10 @@ int main(int argc, char **argv)
char portstr[10];
char *endp;
int r;
+ struct xs_handle *xsh;
+ char vncpasswd[1024];
+
+ vncpasswd[0] = '\0';
while ((opt = getopt_long(argc, argv, "d:p:t:u", options,
NULL)) != -1) {
@@ -346,6 +402,19 @@ int main(int argc, char **argv)
exit(1);
}
+ xsh = xs_daemon_open();
+ if (xsh == NULL) {
+ fprintf(stderr, "cannot open connection to xenstore\n");
+ exit(1);
+ }
+
+
+ if (xenstore_read_vncpasswd(xsh, domid, vncpasswd,
sizeof(vncpasswd)/sizeof(char)) < 0) {
+ fprintf(stderr, "cannot read VNC password from xenstore\n");
+ exit(1);
+ }
+
+
server = rfbGetScreen(&fake_argc, fake_argv,
xenfb->width, xenfb->height,
8, 3, xenfb->depth / 8);
@@ -360,6 +429,21 @@ int main(int argc, char **argv)
if (unused)
server->autoPort = true;
+ if (vncpasswd[0]) {
+ char **passwds = malloc(sizeof(char**)*2);
+ if (!passwds) {
+ fprintf(stderr, "cannot allocate memory (%s)\n",
strerror(errno));
+ exit(1);
+ }
+ fprintf(stderr, "Registered password\n");
+ passwds[0] = vncpasswd;
+ passwds[1] = NULL;
+
+ server->authPasswdData = passwds;
+ server->passwordCheck = rfbCheckPasswordByList;
+ } else {
+ fprintf(stderr, "Running with no password\n");
+ }
server->serverFormat.redShift = 16;
server->serverFormat.greenShift = 8;
server->serverFormat.blueShift = 0;
@@ -372,7 +456,7 @@ int main(int argc, char **argv)
rfbRunEventLoop(server, -1, true);
- xenstore_write_vncport(server->port, domid);
+ xenstore_write_vncport(xsh, server->port, domid);
for (;;) {
FD_ZERO(&readfds);
diff -r baa07859f24f -r 37309be26861 tools/xm-test/lib/XmTestLib/acm.py
--- a/tools/xm-test/lib/XmTestLib/acm.py Tue Dec 19 13:21:24 2006 -0700
+++ b/tools/xm-test/lib/XmTestLib/acm.py Tue Dec 19 13:49:41 2006 -0700
@@ -57,6 +57,8 @@ def ACMLabelResources(resources):
# Applications may label resources explicitly by calling this function
def ACMLabelResource(resource, label='red'):
+ if not isACMEnabled():
+ return
if acm_verbose:
print "labeling resource %s with label %s" % (resource, label)
if not ACM_LABEL_RESOURCES:
diff -r baa07859f24f -r 37309be26861 xen/arch/ia64/asm-offsets.c
--- a/xen/arch/ia64/asm-offsets.c Tue Dec 19 13:21:24 2006 -0700
+++ b/xen/arch/ia64/asm-offsets.c Tue Dec 19 13:49:41 2006 -0700
@@ -41,6 +41,8 @@ void foo(void)
DEFINE(VCPU_VTM_OFFSET_OFS, offsetof(struct vcpu,
arch.arch_vmx.vtm.vtm_offset));
DEFINE(VCPU_VTM_LAST_ITC_OFS, offsetof(struct vcpu,
arch.arch_vmx.vtm.last_itc));
DEFINE(VCPU_VRR0_OFS, offsetof(struct vcpu, arch.arch_vmx.vrr[0]));
+ DEFINE(VCPU_ITR0_OFS, offsetof(struct vcpu, arch.itrs[0]));
+ DEFINE(VCPU_CALLBACK_OFS, offsetof(struct vcpu,
arch.event_callback_ip));
#ifdef VTI_DEBUG
DEFINE(IVT_CUR_OFS, offsetof(struct vcpu, arch.arch_vmx.ivt_current));
DEFINE(IVT_DBG_OFS, offsetof(struct vcpu, arch.arch_vmx.ivt_debug));
diff -r baa07859f24f -r 37309be26861 xen/arch/ia64/asm-xsi-offsets.c
--- a/xen/arch/ia64/asm-xsi-offsets.c Tue Dec 19 13:21:24 2006 -0700
+++ b/xen/arch/ia64/asm-xsi-offsets.c Tue Dec 19 13:49:41 2006 -0700
@@ -62,7 +62,6 @@ void foo(void)
DEFINE_MAPPED_REG_OFS(XSI_ITV_OFS, itv);
DEFINE_MAPPED_REG_OFS(XSI_PTA_OFS, pta);
DEFINE_MAPPED_REG_OFS(XSI_PSR_IC_OFS, interrupt_collection_enabled);
- DEFINE_MAPPED_REG_OFS(XSI_PEND_OFS, pending_interruption);
DEFINE_MAPPED_REG_OFS(XSI_INCOMPL_REGFR_OFS, incomplete_regframe);
DEFINE_MAPPED_REG_OFS(XSI_METAPHYS_OFS, metaphysical_mode);
DEFINE_MAPPED_REG_OFS(XSI_BANKNUM_OFS, banknum);
diff -r baa07859f24f -r 37309be26861 xen/arch/ia64/xen/faults.c
--- a/xen/arch/ia64/xen/faults.c Tue Dec 19 13:21:24 2006 -0700
+++ b/xen/arch/ia64/xen/faults.c Tue Dec 19 13:49:41 2006 -0700
@@ -605,6 +605,9 @@ ia64_handle_reflection(unsigned long ifa
check_lazy_cover = 1;
vector = IA64_DATA_ACCESS_RIGHTS_VECTOR;
break;
+ case 24:
+ vector = IA64_GENEX_VECTOR;
+ break;
case 25:
vector = IA64_DISABLED_FPREG_VECTOR;
break;
diff -r baa07859f24f -r 37309be26861 xen/arch/ia64/xen/hyperprivop.S
--- a/xen/arch/ia64/xen/hyperprivop.S Tue Dec 19 13:21:24 2006 -0700
+++ b/xen/arch/ia64/xen/hyperprivop.S Tue Dec 19 13:49:41 2006 -0700
@@ -37,8 +37,10 @@
# define FAST_BREAK
# undef FAST_ACCESS_REFLECT //XXX TODO fast_access_reflect
// doesn't support dom0 vp yet.
-# define FAST_RFI
-# define FAST_SSM_I
+//# define FAST_RFI
+// TODO: Since we use callback to deliver interrupt,
+// FAST_SSM_I needs to be rewritten.
+//# define FAST_SSM_I
# define FAST_PTC_GA
# undef RFI_TO_INTERRUPT // not working yet
#endif
@@ -87,29 +89,13 @@ GLOBAL_ENTRY(fast_hyperprivop)
cmp.eq p7,p6=HYPERPRIVOP_SSM_I,r17
(p7) br.sptk.many hyper_ssm_i;;
- // FIXME. This algorithm gives up (goes to the slow path) if there
- // are ANY interrupts pending, even if they are currently
- // undeliverable. This should be improved later...
- adds r20=XSI_PEND_OFS-XSI_PSR_IC_OFS,r18 ;;
- ld4 r20=[r20] ;;
- cmp.eq p7,p0=r0,r20
-(p7) br.cond.sptk.many 1f
- movl r20=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
- ld8 r20=[r20];;
- adds r21=IA64_VCPU_IRR0_OFFSET,r20;
- adds r22=IA64_VCPU_IRR0_OFFSET+8,r20;;
- ld8 r23=[r21],16; ld8 r24=[r22],16;;
- ld8 r21=[r21]; ld8 r22=[r22];;
- or r23=r23,r24; or r21=r21,r22;;
- or r20=r23,r21;;
-1: // when we get to here r20=~=interrupts pending
// Check pending event indication
-(p7) movl r20=THIS_CPU(current_psr_i_addr);;
-(p7) ld8 r20=[r20]
- ;;
-(p7) adds r20=-1,r20 // evtchn_upcall_pending
- ;;
-(p7) ld1 r20=[r20]
+ adds r20=XSI_PSR_I_ADDR_OFS-XSI_PSR_IC_OFS, r18;;
+ ld8 r20=[r20]
+ ;;
+ ld1 r22=[r20],-1 // evtchn_upcall_mask
+ ;;
+ ld1 r20=[r20] // evtchn_upcall_pending
;;
// HYPERPRIVOP_RFI?
@@ -117,12 +103,10 @@ 1: // when we get to here r20=~=interrup
(p7) br.sptk.many hyper_rfi
;;
- // HYPERPRIVOP_GET_IVR?
- cmp.eq p7,p6=HYPERPRIVOP_GET_IVR,r17
-(p7) br.sptk.many hyper_get_ivr
- ;;
-
+ // if event enabled and there are pending events
cmp.ne p7,p0=r20,r0
+ ;;
+ cmp.eq.and p7,p0=r22,r0
(p7) br.spnt.many dispatch_break_fault
;;
@@ -139,21 +123,6 @@ 1: // when we get to here r20=~=interrup
// HYPERPRIVOP_RSM_DT?
cmp.eq p7,p6=HYPERPRIVOP_RSM_DT,r17
(p7) br.sptk.many hyper_rsm_dt
- ;;
-
- // HYPERPRIVOP_GET_TPR?
- cmp.eq p7,p6=HYPERPRIVOP_GET_TPR,r17
-(p7) br.sptk.many hyper_get_tpr
- ;;
-
- // HYPERPRIVOP_SET_TPR?
- cmp.eq p7,p6=HYPERPRIVOP_SET_TPR,r17
-(p7) br.sptk.many hyper_set_tpr
- ;;
-
- // HYPERPRIVOP_EOI?
- cmp.eq p7,p6=HYPERPRIVOP_EOI,r17
-(p7) br.sptk.many hyper_eoi
;;
// HYPERPRIVOP_SET_ITM?
@@ -425,10 +394,11 @@ GLOBAL_ENTRY(fast_tick_reflect)
ld8 r23=[r21];;
or r22=r22,r23;;
st8 [r21]=r22;;
- // set PSCB(pending_interruption)!
- adds r20=XSI_PEND_OFS-XSI_PSR_IC_OFS,r18 ;;
- st4 [r20]=r25;;
-
+ // set evtchn_upcall_pending!
+ adds r20=XSI_PSR_I_ADDR_OFS-XSI_PSR_IC_OFS,r18;;
+ ld8 r20=[r20];;
+ adds r20=-1,r20;; // evtchn_upcall_pending
+ st1 [r20]=r25;;
// if interrupted at pl0, we're done
extr.u r16=r17,IA64_PSR_CPL0_BIT,2;;
cmp.eq p6,p0=r16,r0;;
@@ -1464,236 +1434,6 @@ 1: extr.u r26=r24,41,2 ;;
rfi
;;
END(hyper_rsm_dt)
-
-ENTRY(hyper_get_tpr)
-#ifdef FAST_HYPERPRIVOP_CNT
- movl r20=FAST_HYPERPRIVOP_PERFC(HYPERPRIVOP_GET_TPR);;
- ld4 r21=[r20];;
- adds r21=1,r21;;
- st4 [r20]=r21;;
-#endif
- mov r24=cr.ipsr
- mov r25=cr.iip;;
- adds r20=XSI_TPR_OFS-XSI_PSR_IC_OFS,r18 ;;
- ld8 r8=[r20];;
- extr.u r26=r24,41,2 ;;
- cmp.eq p6,p7=2,r26 ;;
-(p6) mov r26=0
-(p6) adds r25=16,r25
-(p7) adds r26=1,r26
- ;;
- dep r24=r26,r24,41,2
- ;;
- mov cr.ipsr=r24
- mov cr.iip=r25
- mov pr=r31,-1 ;;
- rfi
- ;;
-END(hyper_get_tpr)
-
-// if we get to here, there are no interrupts pending so we
-// can change virtual tpr to any value without fear of provoking
-// (or accidentally missing) delivering an interrupt
-ENTRY(hyper_set_tpr)
-#ifdef FAST_HYPERPRIVOP_CNT
- movl r20=FAST_HYPERPRIVOP_PERFC(HYPERPRIVOP_SET_TPR);;
- ld4 r21=[r20];;
- adds r21=1,r21;;
- st4 [r20]=r21;;
-#endif
- mov r24=cr.ipsr
- mov r25=cr.iip;;
- movl r27=0xff00;;
- adds r20=XSI_TPR_OFS-XSI_PSR_IC_OFS,r18 ;;
- andcm r8=r8,r27;;
- st8 [r20]=r8;;
- extr.u r26=r24,41,2 ;;
- cmp.eq p6,p7=2,r26 ;;
-(p6) mov r26=0
-(p6) adds r25=16,r25
-(p7) adds r26=1,r26
- ;;
- dep r24=r26,r24,41,2
- ;;
- mov cr.ipsr=r24
- mov cr.iip=r25
- mov pr=r31,-1 ;;
- rfi
- ;;
-END(hyper_set_tpr)
-
-ENTRY(hyper_get_ivr)
-#ifdef FAST_HYPERPRIVOP_CNT
- movl r22=FAST_HYPERPRIVOP_PERFC(HYPERPRIVOP_GET_IVR);;
- ld4 r21=[r22];;
- adds r21=1,r21;;
- st4 [r22]=r21;;
-#endif
- mov r8=15;;
- // when we get to here r20=~=interrupts pending
- cmp.eq p7,p0=r20,r0;;
-(p7) adds r20=XSI_PEND_OFS-XSI_PSR_IC_OFS,r18 ;;
-(p7) st4 [r20]=r0;;
-(p7) br.spnt.many 1f ;;
- movl r30=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
- ld8 r30=[r30];;
- adds r24=IA64_VCPU_INSVC3_OFFSET,r30;;
- mov r25=192
- adds r22=IA64_VCPU_IRR3_OFFSET,r30;;
- ld8 r23=[r22];;
- cmp.eq p6,p0=r23,r0;;
-(p6) adds r22=-8,r22;;
-(p6) adds r24=-8,r24;;
-(p6) adds r25=-64,r25;;
-(p6) ld8 r23=[r22];;
-(p6) cmp.eq p6,p0=r23,r0;;
-(p6) adds r22=-8,r22;;
-(p6) adds r24=-8,r24;;
-(p6) adds r25=-64,r25;;
-(p6) ld8 r23=[r22];;
-(p6) cmp.eq p6,p0=r23,r0;;
-(p6) adds r22=-8,r22;;
-(p6) adds r24=-8,r24;;
-(p6) adds r25=-64,r25;;
-(p6) ld8 r23=[r22];;
-(p6) cmp.eq p6,p0=r23,r0;;
- cmp.eq p6,p0=r23,r0
-(p6) br.cond.spnt.few 1f; // this is actually an error
- // r22 points to non-zero element of irr, r23 has value
- // r24 points to corr element of insvc, r25 has elt*64
- ld8 r26=[r24];;
- cmp.geu p6,p0=r26,r23
-(p6) br.cond.spnt.many 1f;
- // not masked by insvc, get vector number
- shr.u r26=r23,1;;
- or r26=r23,r26;;
- shr.u r27=r26,2;;
- or r26=r26,r27;;
- shr.u r27=r26,4;;
- or r26=r26,r27;;
- shr.u r27=r26,8;;
- or r26=r26,r27;;
- shr.u r27=r26,16;;
- or r26=r26,r27;;
- shr.u r27=r26,32;;
- or r26=r26,r27;;
- andcm r26=0xffffffffffffffff,r26;;
- popcnt r26=r26;;
- sub r26=63,r26;;
- // r26 now contains the bit index (mod 64)
- mov r27=1;;
- shl r27=r27,r26;;
- // r27 now contains the (within the proper word) bit mask
- add r26=r25,r26
- // r26 now contains the vector [0..255]
- adds r20=XSI_TPR_OFS-XSI_PSR_IC_OFS,r18 ;;
- ld8 r20=[r20] ;;
- extr.u r28=r20,16,1
- extr.u r29=r20,4,4 ;;
- cmp.ne p6,p0=r28,r0 // if tpr.mmi is set, return SPURIOUS
-(p6) br.cond.spnt.few 1f;
- shl r29=r29,4;;
- adds r29=15,r29;;
- cmp.ge p6,p0=r29,r26
-(p6) br.cond.spnt.few 1f;
- // OK, have an unmasked vector to process/return
- ld8 r25=[r24];;
- or r25=r25,r27;;
- st8 [r24]=r25;;
- ld8 r25=[r22];;
- andcm r25=r25,r27;;
- st8 [r22]=r25;;
- mov r8=r26;;
- // if its a clock tick, remember itm to avoid delivering it twice
- adds r20=XSI_ITV_OFS-XSI_PSR_IC_OFS,r18 ;;
- ld8 r20=[r20];;
- extr.u r20=r20,0,8;;
- cmp.eq p6,p0=r20,r8
- adds r22=IA64_VCPU_DOMAIN_ITM_LAST_OFFSET,r30
- adds r23=IA64_VCPU_DOMAIN_ITM_OFFSET,r30;;
- ld8 r23=[r23];;
-(p6) st8 [r22]=r23;;
- // all done
-1: mov r24=cr.ipsr
- mov r25=cr.iip;;
- extr.u r26=r24,41,2 ;;
- cmp.eq p6,p7=2,r26 ;;
-(p6) mov r26=0
-(p6) adds r25=16,r25
-(p7) adds r26=1,r26
- ;;
- dep r24=r26,r24,41,2
- ;;
- mov cr.ipsr=r24
- mov cr.iip=r25
- mov pr=r31,-1 ;;
- rfi
- ;;
-END(hyper_get_ivr)
-
-ENTRY(hyper_eoi)
- // when we get to here r20=~=interrupts pending
- cmp.ne p7,p0=r20,r0
-(p7) br.spnt.many dispatch_break_fault ;;
-#ifdef FAST_HYPERPRIVOP_CNT
- movl r20=FAST_HYPERPRIVOP_PERFC(HYPERPRIVOP_EOI);;
- ld4 r21=[r20];;
- adds r21=1,r21;;
- st4 [r20]=r21;;
-#endif
- movl r22=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
- ld8 r22=[r22];;
- adds r22=IA64_VCPU_INSVC3_OFFSET,r22;;
- ld8 r23=[r22];;
- cmp.eq p6,p0=r23,r0;;
-(p6) adds r22=-8,r22;;
-(p6) ld8 r23=[r22];;
-(p6) cmp.eq p6,p0=r23,r0;;
-(p6) adds r22=-8,r22;;
-(p6) ld8 r23=[r22];;
-(p6) cmp.eq p6,p0=r23,r0;;
-(p6) adds r22=-8,r22;;
-(p6) ld8 r23=[r22];;
-(p6) cmp.eq p6,p0=r23,r0;;
- cmp.eq p6,p0=r23,r0
-(p6) br.cond.spnt.few 1f; // this is actually an error
- // r22 points to non-zero element of insvc, r23 has value
- shr.u r24=r23,1;;
- or r24=r23,r24;;
- shr.u r25=r24,2;;
- or r24=r24,r25;;
- shr.u r25=r24,4;;
- or r24=r24,r25;;
- shr.u r25=r24,8;;
- or r24=r24,r25;;
- shr.u r25=r24,16;;
- or r24=r24,r25;;
- shr.u r25=r24,32;;
- or r24=r24,r25;;
- andcm r24=0xffffffffffffffff,r24;;
- popcnt r24=r24;;
- sub r24=63,r24;;
- // r24 now contains the bit index
- mov r25=1;;
- shl r25=r25,r24;;
- andcm r23=r23,r25;;
- st8 [r22]=r23;;
-1: mov r24=cr.ipsr
- mov r25=cr.iip;;
- extr.u r26=r24,41,2 ;;
- cmp.eq p6,p7=2,r26 ;;
-(p6) mov r26=0
-(p6) adds r25=16,r25
-(p7) adds r26=1,r26
- ;;
- dep r24=r26,r24,41,2
- ;;
- mov cr.ipsr=r24
- mov cr.iip=r25
- mov pr=r31,-1 ;;
- rfi
- ;;
-END(hyper_eoi)
ENTRY(hyper_set_itm)
// when we get to here r20=~=interrupts pending
diff -r baa07859f24f -r 37309be26861 xen/arch/ia64/xen/ivt.S
--- a/xen/arch/ia64/xen/ivt.S Tue Dec 19 13:21:24 2006 -0700
+++ b/xen/arch/ia64/xen/ivt.S Tue Dec 19 13:49:41 2006 -0700
@@ -1737,6 +1737,8 @@ ENTRY(general_exception)
#ifdef XEN
cmp4.ge p6,p0=0x20,r16
(p6) br.sptk.many dispatch_privop_fault
+ ;;
+ FAULT_OR_REFLECT(24)
#else
cmp4.eq p6,p0=0,r16
(p6) br.sptk.many dispatch_illegal_op_fault
diff -r baa07859f24f -r 37309be26861 xen/arch/ia64/xen/vcpu.c
--- a/xen/arch/ia64/xen/vcpu.c Tue Dec 19 13:21:24 2006 -0700
+++ b/xen/arch/ia64/xen/vcpu.c Tue Dec 19 13:49:41 2006 -0700
@@ -2162,6 +2162,7 @@ vcpu_itc_no_srlz(VCPU * vcpu, u64 IorD,
BUG_ON(logps > PAGE_SHIFT);
vcpu_tlb_track_insert_or_dirty(vcpu, vaddr, entry);
psr = ia64_clear_ic();
+ pte &= ~(_PAGE_RV2 | _PAGE_RV1); // Mask out the reserved bits.
ia64_itc(IorD, vaddr, pte, ps); // FIXME: look for bigger mappings
ia64_set_psr(psr);
// ia64_srlz_i(); // no srls req'd, will rfi later
diff -r baa07859f24f -r 37309be26861 xen/common/page_alloc.c
--- a/xen/common/page_alloc.c Tue Dec 19 13:21:24 2006 -0700
+++ b/xen/common/page_alloc.c Tue Dec 19 13:49:41 2006 -0700
@@ -490,15 +490,15 @@ void scrub_heap_pages(void)
for ( mfn = first_valid_mfn; mfn < max_page; mfn++ )
{
+ process_pending_timers();
+
+ /* Quick lock-free check. */
+ if ( allocated_in_map(mfn) )
+ continue;
+
/* Every 100MB, print a progress dot. */
if ( (mfn % ((100*1024*1024)/PAGE_SIZE)) == 0 )
printk(".");
-
- process_pending_timers();
-
- /* Quick lock-free check. */
- if ( allocated_in_map(mfn) )
- continue;
spin_lock_irq(&heap_lock);
diff -r baa07859f24f -r 37309be26861 xen/common/xenoprof.c
--- a/xen/common/xenoprof.c Tue Dec 19 13:21:24 2006 -0700
+++ b/xen/common/xenoprof.c Tue Dec 19 13:49:41 2006 -0700
@@ -384,7 +384,7 @@ static int add_passive_list(XEN_GUEST_HA
d->xenoprof->domain_type = XENOPROF_DOMAIN_PASSIVE;
passive.nbuf = d->xenoprof->nbuf;
passive.bufsize = d->xenoprof->bufsize;
- if ( !shadow_mode_translate(d) )
+ if ( !shadow_mode_translate(current->domain) )
passive.buf_gmaddr = __pa(d->xenoprof->rawbuf);
else
xenoprof_shared_gmfn_with_guest(
diff -r baa07859f24f -r 37309be26861
xen/include/asm-ia64/linux-xen/asm/pgtable.h
--- a/xen/include/asm-ia64/linux-xen/asm/pgtable.h Tue Dec 19 13:21:24
2006 -0700
+++ b/xen/include/asm-ia64/linux-xen/asm/pgtable.h Tue Dec 19 13:49:41
2006 -0700
@@ -39,6 +39,11 @@
#define _PAGE_P (1 << _PAGE_P_BIT) /* page present
bit */
#define _PAGE_MA_WB (0x0 << 2) /* write back memory attribute
*/
#ifdef XEN
+#define _PAGE_RV1_BIT 1
+#define _PAGE_RV2_BIT 50
+#define _PAGE_RV1 (__IA64_UL(1) << _PAGE_RV1_BIT) /* reserved bit
*/
+#define _PAGE_RV2 (__IA64_UL(3) << _PAGE_RV2_BIT) /* reserved
bits */
+
#define _PAGE_MA_ST (0x1 << 2) /* is reserved for software use
*/
#endif
#define _PAGE_MA_UC (0x4 << 2) /* uncacheable memory attribute
*/
diff -r baa07859f24f -r 37309be26861 xen/include/xen/elfcore.h
--- a/xen/include/xen/elfcore.h Tue Dec 19 13:21:24 2006 -0700
+++ b/xen/include/xen/elfcore.h Tue Dec 19 13:49:41 2006 -0700
@@ -87,7 +87,7 @@ typedef struct
desctype desc; \
PAD32(sizeof(desctype)); \
} desc; \
- } type
+ } __attribute__ ((packed)) type
#define CORE_STR "CORE"
#define CORE_STR_LEN 5 /* including terminating zero */
@@ -119,7 +119,7 @@ typedef struct {
crash_note_core_t core;
crash_note_xen_core_t xen_regs;
crash_note_xen_info_t xen_info;
-} crash_note_t;
+} __attribute__ ((packed)) crash_note_t;
#define setup_crash_note(np, member, str, str_len, id) \
np->member.note.note.note.namesz = str_len; \
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|