From 0bb51565d637f86b5b5cb278bef579c45caded88a2d2b9318fcc9dca75b4d95e Mon Sep 17 00:00:00 2001 From: OBS User unknown Date: Mon, 4 May 2009 16:38:09 +0000 Subject: [PATCH] OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/xen?expand=0&rev=73 --- 18406-constify-microcode.patch | 90 - 18412-x86-page-type-preemptible.patch | 1421 ------------- 18420-x86-page-type-preemptible-fix.patch | 51 - 18428-poll-single-port.patch | 235 --- 18446-vtd-dom0-passthrough.patch | 62 - 18456-vtd-dom0-passthrough-cmdline.patch | 91 - 18464-cpu-hotplug.patch | 213 -- 18468-therm-control-msr.patch | 41 - 18471-cpu-hotplug.patch | 27 - 18475-amd-microcode-update.patch | 1660 ---------------- 18481-amd-microcode-update-fix.patch | 37 - 18483-intel-microcode-update.patch | 1766 ----------------- 18484-stubdom-ioemu-makefile.patch | 85 - 18487-microcode-update-irq-context.patch | 149 -- 18488-microcode-free-fix.patch | 29 - 18509-continue-hypercall-on-cpu.patch | 136 -- 18519-microcode-retval.patch | 25 - 18520-per-CPU-GDT.patch | 719 ------- 18521-per-CPU-TSS.patch | 128 -- 18523-per-CPU-misc.patch | 201 -- 18528-dump-evtchn.patch | 113 -- 18539-pirq-vector-mapping.patch | 654 ------ 18547-pirq-vector-mapping-fix.patch | 283 --- 18573-move-pirq-logic.patch | 455 ----- 18574-msi-free-vector.patch | 219 -- 18577-bad-assertion.patch | 21 - 18583-passthrough-locking.patch | 569 ------ 18584-evtchn-lock-rename.patch | 808 -------- 18620-x86-page-type-preemptible-fix.patch | 26 - 18637-vmx-set-dr7.patch | 78 - 18654-xend-vcpus.patch | 44 - 18656-vtd-alloc-checks.patch | 97 - 18661-recursive-spinlocks.patch | 50 - 18720-x86-dom-cleanup.patch | 75 - 18722-x86-fixmap-reserved.patch | 19 - 18723-unmap-dom-page-const.patch | 58 - 18724-i386-highmem-assist.patch | 206 -- 18731-x86-dom-cleanup.patch | 57 - 18735-x86-dom-cleanup.patch | 22 - 18741-x86-dom-cleanup-no-hack.patch | 147 -- 18742-x86-partial-page-ref.patch | 510 ----- 18745-xend-ioport-irq.patch | 99 - 18747-x86-partial-page-ref.patch | 198 -- 18762-vtd-intremap-SMI-RTEs.patch | 78 - 18764-cpu-affinity.patch | 150 -- 18771-reduce-GDT-switching.patch | 347 ---- 18778-msi-irq-fix.patch | 113 -- 18780-cpu-affinity.patch | 21 - 18785-vlapic-lowest-prio.patch | 109 - 18788-vlapic-accel-dom-restore.patch | 35 - 18795-x86-ioapic-guest-write.patch | 29 - 18799-cpu-affinity.patch | 20 - 18805-pv-driver-build.patch | 65 - 18810-shadow-PAT.patch | 42 - 18844-shared-page-EOI.patch | 312 --- 18852-shared-page-EOI-gmfn.patch | 102 - 18870-vtd-flush-per-device.patch | 25 - 18878-x86-cpufreq-less-verbose.patch | 33 - 18879-cpufreq-params.patch | 197 -- 18880-x86-pirq-guest-bind-msg.patch | 29 - 18887-vtd-error-handling.patch | 76 - 18904-x86-local-irq.patch | 95 - 18905-x86-ioapic-boot-panic.patch | 94 - 18929-shadow-no-duplicates.patch | 29 - 18930-xenoprof-dunnington.patch | 27 - 18934-vtd-PCI-X-dev-assign.patch | 212 -- 18937-S3-MSI.patch | 112 -- 18943-amd-32bit-paging-limit.patch | 28 - 18970-vmx-print-features.patch | 44 - 19027-hvmloader-SMBIOS-dev-mem-boundary.patch | 27 - 19032-amd-iommu-pointer-reset.patch | 37 - 19035-MSI-X-proper-enable.patch | 46 - 19038-x86-no-apic.patch | 135 -- 19039-x86-propagate-nolapic.patch | 44 - 19046-cross-bit-coredumping.patch | 391 ---- 19048-cross-bit-coredumping.patch | 37 - 19051-cross-bit-coredumping.patch | 24 - 19072-vmx-pat.patch | 148 -- 19079-snp_ctl-1.patch | 315 --- 19088-x86-page-non-atomic-owner.patch | 146 -- 19089-x86_64-widen-page-refcounts.patch | 445 ----- 19103-x86_64-fold-page-lock.patch | 834 -------- 19151-xend-class-dereg.patch | 14 - 19152-xm-man-page.patch | 13 - 19153-xm-noxen-error.patch | 17 - 19154-snoop-control.patch | 68 - 19198-fix-snoop.patch | 85 - 32on64-extra-mem.patch | 12 +- blktap-error-handling.patch | 248 --- blktap-ioemu-close-fix.patch | 54 - blktap-pv-cdrom.patch | 71 +- blktap.patch | 34 +- blktapctrl-default-to-ioemu.patch | 188 +- block-flags.diff | 6 +- block-iscsi | 6 +- block-losetup-retry.diff | 6 +- bridge-bonding.diff | 28 +- bridge-hostonly.diff | 10 +- bridge-opensuse.patch | 8 +- bridge-record-creation.patch | 10 +- bridge-vlan.diff | 12 +- build-tapdisk-ioemu.patch | 118 +- cdrom-removable.patch | 30 +- checkpoint-rename.patch | 8 +- disable_emulated_device.diff | 8 +- dom-print.patch | 26 +- domUloader.py | 2 +- dump-exec-state.patch | 26 +- hv_tools.patch | 80 +- hv_xen_base.patch | 112 +- hv_xen_extension.patch | 440 ++-- init.xend | 5 +- ...7615-qcow2-fix-alloc_cluster_link_l2.patch | 32 + ioemu-blktap-barriers.patch | 18 +- ioemu-blktap-fix-open.patch | 106 - ioemu-blktap-fv-init.patch | 12 +- ioemu-blktap-image-format.patch | 85 +- ioemu-blktap-zero-size.patch | 109 +- ioemu-debuginfo.patch | 18 +- ioemu-qcow2-multiblock-aio.patch | 108 - ioemu-vnc-resize.patch | 39 +- ioemu-vpc-4gb-fix.patch | 13 - libxen_permissive.patch | 8 +- network-nat-open-SuSEfirewall2-FORWARD.patch | 21 + network-nat.patch | 6 +- network-route.patch | 6 +- old-arbytes.patch | 30 - pv-driver-build.patch | 6 +- pvdrv_emulation_control.patch | 10 +- python2.6-fixes.patch | 23 +- qemu-dm-segfault.patch | 69 +- qemu-img-snapshot.patch | 113 -- qemu-security-etch1.diff | 92 +- reenable-block-protocols.patch | 39 - rpmlint.diff | 13 - serial-split.patch | 8 +- snapshot-ioemu-delete.patch | 41 +- snapshot-ioemu-restore.patch | 46 +- snapshot-ioemu-save.patch | 88 +- snapshot-xend.patch | 177 +- supported_module.diff | 4 +- svm-lmsl.patch | 87 + tapdisk-ioemu-logfile.patch | 22 +- tapdisk-ioemu-shutdown-fix.patch | 89 + tmp_build.patch | 14 +- tools-gdbserver-build.diff | 6 +- tools-kboot.diff | 36 +- tools-xc_kexec.diff | 94 +- udev-rules.patch | 8 +- x86-alloc-cpu-structs.patch | 12 +- x86-cpufreq-report.patch | 29 +- x86-extra-trap-info.patch | 12 +- x86-show-page-walk-early.patch | 54 +- x86_64-5Tb.patch | 153 ++ ...it-p2m.patch => x86_64-note-init-p2m.patch | 127 +- x86_64-page-info-pack.patch | 123 -- x86_64-sh-next-shadow.patch | 132 -- xen-3.3.1-testing-src.tar.bz2 | 3 - xen-3.4.0-testing-src.tar.bz2 | 3 + xen-api-auth.patch | 6 +- xen-changeset.diff | 10 +- xen-config.diff | 23 +- xen-destdir.diff | 228 ++- xen-disable-qemu-monitor.diff | 32 +- xen-domUloader.diff | 110 +- xen-fixme-doc.diff | 12 +- xen-hvm-default-bridge.diff | 44 +- xen-hvm-default-pae.diff | 10 +- xen-ioapic-ack-default.diff | 10 +- xen-ioemu-hvm-pv-support.diff | 231 +-- xen-max-free-mem.diff | 38 +- xen-no-dummy-nfs-ip.diff | 8 +- xen-paths.diff | 20 +- xen-qemu-iscsi-fix.patch | 24 +- xen-rpmoptflags.diff | 12 +- xen-warnings.diff | 52 +- xen-xm-top-needs-root.diff | 8 +- xen-xmexample-vti.diff | 6 +- xen-xmexample.diff | 38 +- xen.changes | 74 + xen.spec | 443 ++--- xenapi-console-protocol.patch | 8 +- xend-config.diff | 24 +- xend-core-dump-loc.diff | 22 +- xend-domain-lock.patch | 574 +++--- xm-test-cleanup.diff | 6 +- xmclone.sh | 56 +- 187 files changed, 2454 insertions(+), 20791 deletions(-) delete mode 100644 18406-constify-microcode.patch delete mode 100644 18412-x86-page-type-preemptible.patch delete mode 100644 18420-x86-page-type-preemptible-fix.patch delete mode 100644 18428-poll-single-port.patch delete mode 100644 18446-vtd-dom0-passthrough.patch delete mode 100644 18456-vtd-dom0-passthrough-cmdline.patch delete mode 100644 18464-cpu-hotplug.patch delete mode 100644 18468-therm-control-msr.patch delete mode 100644 18471-cpu-hotplug.patch delete mode 100644 18475-amd-microcode-update.patch delete mode 100644 18481-amd-microcode-update-fix.patch delete mode 100644 18483-intel-microcode-update.patch delete mode 100644 18484-stubdom-ioemu-makefile.patch delete mode 100644 18487-microcode-update-irq-context.patch delete mode 100644 18488-microcode-free-fix.patch delete mode 100644 18509-continue-hypercall-on-cpu.patch delete mode 100644 18519-microcode-retval.patch delete mode 100644 18520-per-CPU-GDT.patch delete mode 100644 18521-per-CPU-TSS.patch delete mode 100644 18523-per-CPU-misc.patch delete mode 100644 18528-dump-evtchn.patch delete mode 100644 18539-pirq-vector-mapping.patch delete mode 100644 18547-pirq-vector-mapping-fix.patch delete mode 100644 18573-move-pirq-logic.patch delete mode 100644 18574-msi-free-vector.patch delete mode 100644 18577-bad-assertion.patch delete mode 100644 18583-passthrough-locking.patch delete mode 100644 18584-evtchn-lock-rename.patch delete mode 100644 18620-x86-page-type-preemptible-fix.patch delete mode 100644 18637-vmx-set-dr7.patch delete mode 100644 18654-xend-vcpus.patch delete mode 100644 18656-vtd-alloc-checks.patch delete mode 100644 18661-recursive-spinlocks.patch delete mode 100644 18720-x86-dom-cleanup.patch delete mode 100644 18722-x86-fixmap-reserved.patch delete mode 100644 18723-unmap-dom-page-const.patch delete mode 100644 18724-i386-highmem-assist.patch delete mode 100644 18731-x86-dom-cleanup.patch delete mode 100644 18735-x86-dom-cleanup.patch delete mode 100644 18741-x86-dom-cleanup-no-hack.patch delete mode 100644 18742-x86-partial-page-ref.patch delete mode 100644 18745-xend-ioport-irq.patch delete mode 100644 18747-x86-partial-page-ref.patch delete mode 100644 18762-vtd-intremap-SMI-RTEs.patch delete mode 100644 18764-cpu-affinity.patch delete mode 100644 18771-reduce-GDT-switching.patch delete mode 100644 18778-msi-irq-fix.patch delete mode 100644 18780-cpu-affinity.patch delete mode 100644 18785-vlapic-lowest-prio.patch delete mode 100644 18788-vlapic-accel-dom-restore.patch delete mode 100644 18795-x86-ioapic-guest-write.patch delete mode 100644 18799-cpu-affinity.patch delete mode 100644 18805-pv-driver-build.patch delete mode 100644 18810-shadow-PAT.patch delete mode 100644 18844-shared-page-EOI.patch delete mode 100644 18852-shared-page-EOI-gmfn.patch delete mode 100644 18870-vtd-flush-per-device.patch delete mode 100644 18878-x86-cpufreq-less-verbose.patch delete mode 100644 18879-cpufreq-params.patch delete mode 100644 18880-x86-pirq-guest-bind-msg.patch delete mode 100644 18887-vtd-error-handling.patch delete mode 100644 18904-x86-local-irq.patch delete mode 100644 18905-x86-ioapic-boot-panic.patch delete mode 100644 18929-shadow-no-duplicates.patch delete mode 100644 18930-xenoprof-dunnington.patch delete mode 100644 18934-vtd-PCI-X-dev-assign.patch delete mode 100644 18937-S3-MSI.patch delete mode 100644 18943-amd-32bit-paging-limit.patch delete mode 100644 18970-vmx-print-features.patch delete mode 100644 19027-hvmloader-SMBIOS-dev-mem-boundary.patch delete mode 100644 19032-amd-iommu-pointer-reset.patch delete mode 100644 19035-MSI-X-proper-enable.patch delete mode 100644 19038-x86-no-apic.patch delete mode 100644 19039-x86-propagate-nolapic.patch delete mode 100644 19046-cross-bit-coredumping.patch delete mode 100644 19048-cross-bit-coredumping.patch delete mode 100644 19051-cross-bit-coredumping.patch delete mode 100644 19072-vmx-pat.patch delete mode 100644 19079-snp_ctl-1.patch delete mode 100644 19088-x86-page-non-atomic-owner.patch delete mode 100644 19089-x86_64-widen-page-refcounts.patch delete mode 100644 19103-x86_64-fold-page-lock.patch delete mode 100644 19151-xend-class-dereg.patch delete mode 100644 19152-xm-man-page.patch delete mode 100644 19153-xm-noxen-error.patch delete mode 100644 19154-snoop-control.patch delete mode 100644 19198-fix-snoop.patch delete mode 100644 blktap-error-handling.patch delete mode 100644 blktap-ioemu-close-fix.patch create mode 100644 ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch delete mode 100644 ioemu-blktap-fix-open.patch delete mode 100644 ioemu-qcow2-multiblock-aio.patch delete mode 100644 ioemu-vpc-4gb-fix.patch create mode 100644 network-nat-open-SuSEfirewall2-FORWARD.patch delete mode 100644 old-arbytes.patch delete mode 100644 qemu-img-snapshot.patch delete mode 100644 reenable-block-protocols.patch delete mode 100644 rpmlint.diff create mode 100644 svm-lmsl.patch create mode 100644 tapdisk-ioemu-shutdown-fix.patch create mode 100644 x86_64-5Tb.patch rename 19009-x86_64-note-init-p2m.patch => x86_64-note-init-p2m.patch (76%) delete mode 100644 x86_64-page-info-pack.patch delete mode 100644 x86_64-sh-next-shadow.patch delete mode 100644 xen-3.3.1-testing-src.tar.bz2 create mode 100644 xen-3.4.0-testing-src.tar.bz2 diff --git a/18406-constify-microcode.patch b/18406-constify-microcode.patch deleted file mode 100644 index c7c2f98..0000000 --- a/18406-constify-microcode.patch +++ /dev/null @@ -1,90 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1220022665 -3600 -# Node ID 481f0dc6beb0b19cb02354dbe9b4ce068a5f6a18 -# Parent cd078a3d600e6a1bab65e6392a60a832253cff8b -x86: constify microcode hypercall argument - -Linux 2.6.27 marks the data pointer in its firmware struct 'const', -and hence, to avoid a compiler warning, Xen's microcode update -interface should be properly properly constified too. - -Signed-off-by: Jan Beulich - -Index: xen-3.3.1-testing/xen/arch/x86/microcode.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/microcode.c -+++ xen-3.3.1-testing/xen/arch/x86/microcode.c -@@ -124,7 +124,7 @@ static DEFINE_SPINLOCK(microcode_update_ - /* no concurrent ->write()s are allowed on /dev/cpu/microcode */ - static DEFINE_MUTEX(microcode_mutex); - --static void __user *user_buffer; /* user area microcode data buffer */ -+static const void __user *user_buffer; /* user area microcode data buffer */ - static unsigned int user_buffer_size; /* it's size */ - - typedef enum mc_error_code { -@@ -455,7 +455,7 @@ out: - return error; - } - --int microcode_update(XEN_GUEST_HANDLE(void) buf, unsigned long len) -+int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len) - { - int ret; - -Index: xen-3.3.1-testing/xen/arch/x86/platform_hypercall.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/platform_hypercall.c -+++ xen-3.3.1-testing/xen/arch/x86/platform_hypercall.c -@@ -147,8 +147,7 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe - - case XENPF_microcode_update: - { -- extern int microcode_update(XEN_GUEST_HANDLE(void), unsigned long len); -- XEN_GUEST_HANDLE(void) data; -+ XEN_GUEST_HANDLE(const_void) data; - - ret = xsm_microcode(); - if ( ret ) -Index: xen-3.3.1-testing/xen/include/asm-x86/processor.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/processor.h -+++ xen-3.3.1-testing/xen/include/asm-x86/processor.h -@@ -583,6 +583,8 @@ int rdmsr_hypervisor_regs( - int wrmsr_hypervisor_regs( - uint32_t idx, uint32_t eax, uint32_t edx); - -+int microcode_update(XEN_GUEST_HANDLE(const_void), unsigned long len); -+ - #endif /* !__ASSEMBLY__ */ - - #endif /* __ASM_X86_PROCESSOR_H */ -Index: xen-3.3.1-testing/xen/include/public/platform.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/public/platform.h -+++ xen-3.3.1-testing/xen/include/public/platform.h -@@ -97,7 +97,7 @@ DEFINE_XEN_GUEST_HANDLE(xenpf_read_memty - #define XENPF_microcode_update 35 - struct xenpf_microcode_update { - /* IN variables. */ -- XEN_GUEST_HANDLE(void) data; /* Pointer to microcode data */ -+ XEN_GUEST_HANDLE(const_void) data;/* Pointer to microcode data */ - uint32_t length; /* Length of microcode data. */ - }; - typedef struct xenpf_microcode_update xenpf_microcode_update_t; -Index: xen-3.3.1-testing/xen/include/xen/compat.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/xen/compat.h -+++ xen-3.3.1-testing/xen/include/xen/compat.h -@@ -19,7 +19,9 @@ - type *_[0] __attribute__((__packed__)); \ - } __compat_handle_ ## name - --#define DEFINE_COMPAT_HANDLE(name) __DEFINE_COMPAT_HANDLE(name, name) -+#define DEFINE_COMPAT_HANDLE(name) \ -+ __DEFINE_COMPAT_HANDLE(name, name); \ -+ __DEFINE_COMPAT_HANDLE(const_ ## name, const name) - #define COMPAT_HANDLE(name) __compat_handle_ ## name - - /* Is the compat handle a NULL reference? */ diff --git a/18412-x86-page-type-preemptible.patch b/18412-x86-page-type-preemptible.patch deleted file mode 100644 index 07d8999..0000000 --- a/18412-x86-page-type-preemptible.patch +++ /dev/null @@ -1,1421 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1220262725 -3600 -# Node ID 86b956d8cf046d071c828ca9e461311f68fc0c6e -# Parent 7cb51e8484f67e32c1cc169948d63cd5579fd5bf -x86: make {get,put}_page_type() preemptible - -This is only a first step - more call sites need to be hooked up. - -Most of this is really Keir's work, I just took what he handed me and -fixed a few remaining issues. - -Signed-off-by: Jan Beulich -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/domain.c -+++ xen-3.3.1-testing/xen/arch/x86/domain.c -@@ -1646,23 +1646,26 @@ static int relinquish_memory( - - /* - * Forcibly invalidate top-most, still valid page tables at this point -- * to break circular 'linear page table' references. This is okay -- * because MMU structures are not shared across domains and this domain -- * is now dead. Thus top-most valid tables are not in use so a non-zero -- * count means circular reference. -+ * to break circular 'linear page table' references as well as clean up -+ * partially validated pages. This is okay because MMU structures are -+ * not shared across domains and this domain is now dead. Thus top-most -+ * valid tables are not in use so a non-zero count means circular -+ * reference or partially validated. - */ - y = page->u.inuse.type_info; - for ( ; ; ) - { - x = y; -- if ( likely((x & (PGT_type_mask|PGT_validated)) != -- (type|PGT_validated)) ) -+ if ( likely((x & PGT_type_mask) != type) || -+ likely(!(x & (PGT_validated|PGT_partial))) ) - break; - -- y = cmpxchg(&page->u.inuse.type_info, x, x & ~PGT_validated); -+ y = cmpxchg(&page->u.inuse.type_info, x, -+ x & ~(PGT_validated|PGT_partial)); - if ( likely(y == x) ) - { -- free_page_type(page, type); -+ if ( free_page_type(page, x, 0) != 0 ) -+ BUG(); - break; - } - } -Index: xen-3.3.1-testing/xen/arch/x86/mm.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/mm.c -+++ xen-3.3.1-testing/xen/arch/x86/mm.c -@@ -507,11 +507,11 @@ static int alloc_segdesc_page(struct pag - goto fail; - - unmap_domain_page(descs); -- return 1; -+ return 0; - - fail: - unmap_domain_page(descs); -- return 0; -+ return -EINVAL; - } - - -@@ -565,20 +565,23 @@ static int get_page_from_pagenr(unsigned - - static int get_page_and_type_from_pagenr(unsigned long page_nr, - unsigned long type, -- struct domain *d) -+ struct domain *d, -+ int preemptible) - { - struct page_info *page = mfn_to_page(page_nr); -+ int rc; - - if ( unlikely(!get_page_from_pagenr(page_nr, d)) ) -- return 0; -+ return -EINVAL; - -- if ( unlikely(!get_page_type(page, type)) ) -- { -+ rc = (preemptible ? -+ get_page_type_preemptible(page, type) : -+ (get_page_type(page, type) ? 0 : -EINVAL)); -+ -+ if ( rc ) - put_page(page); -- return 0; -- } - -- return 1; -+ return rc; - } - - /* -@@ -754,22 +757,23 @@ get_page_from_l2e( - if ( unlikely((l2e_get_flags(l2e) & L2_DISALLOW_MASK)) ) - { - MEM_LOG("Bad L2 flags %x", l2e_get_flags(l2e) & L2_DISALLOW_MASK); -- return 0; -+ return -EINVAL; - } - -- rc = get_page_and_type_from_pagenr(l2e_get_pfn(l2e), PGT_l1_page_table, d); -- if ( unlikely(!rc) ) -- rc = get_l2_linear_pagetable(l2e, pfn, d); -+ rc = get_page_and_type_from_pagenr( -+ l2e_get_pfn(l2e), PGT_l1_page_table, d, 0); -+ if ( unlikely(rc) && rc != -EAGAIN && -+ get_l2_linear_pagetable(l2e, pfn, d) ) -+ rc = -EINVAL; - - return rc; - } - - --#if CONFIG_PAGING_LEVELS >= 3 - define_get_linear_pagetable(l3); - static int - get_page_from_l3e( -- l3_pgentry_t l3e, unsigned long pfn, struct domain *d) -+ l3_pgentry_t l3e, unsigned long pfn, struct domain *d, int preemptible) - { - int rc; - -@@ -779,22 +783,23 @@ get_page_from_l3e( - if ( unlikely((l3e_get_flags(l3e) & l3_disallow_mask(d))) ) - { - MEM_LOG("Bad L3 flags %x", l3e_get_flags(l3e) & l3_disallow_mask(d)); -- return 0; -+ return -EINVAL; - } - -- rc = get_page_and_type_from_pagenr(l3e_get_pfn(l3e), PGT_l2_page_table, d); -- if ( unlikely(!rc) ) -- rc = get_l3_linear_pagetable(l3e, pfn, d); -+ rc = get_page_and_type_from_pagenr( -+ l3e_get_pfn(l3e), PGT_l2_page_table, d, preemptible); -+ if ( unlikely(rc) && rc != -EAGAIN && rc != -EINTR && -+ get_l3_linear_pagetable(l3e, pfn, d) ) -+ rc = -EINVAL; - - return rc; - } --#endif /* 3 level */ - - #if CONFIG_PAGING_LEVELS >= 4 - define_get_linear_pagetable(l4); - static int - get_page_from_l4e( -- l4_pgentry_t l4e, unsigned long pfn, struct domain *d) -+ l4_pgentry_t l4e, unsigned long pfn, struct domain *d, int preemptible) - { - int rc; - -@@ -804,12 +809,14 @@ get_page_from_l4e( - if ( unlikely((l4e_get_flags(l4e) & L4_DISALLOW_MASK)) ) - { - MEM_LOG("Bad L4 flags %x", l4e_get_flags(l4e) & L4_DISALLOW_MASK); -- return 0; -+ return -EINVAL; - } - -- rc = get_page_and_type_from_pagenr(l4e_get_pfn(l4e), PGT_l3_page_table, d); -- if ( unlikely(!rc) ) -- rc = get_l4_linear_pagetable(l4e, pfn, d); -+ rc = get_page_and_type_from_pagenr( -+ l4e_get_pfn(l4e), PGT_l3_page_table, d, preemptible); -+ if ( unlikely(rc) && rc != -EAGAIN && rc != -EINTR && -+ get_l4_linear_pagetable(l4e, pfn, d) ) -+ rc = -EINVAL; - - return rc; - } -@@ -946,29 +953,35 @@ void put_page_from_l1e(l1_pgentry_t l1e, - * NB. Virtual address 'l2e' maps to a machine address within frame 'pfn'. - * Note also that this automatically deals correctly with linear p.t.'s. - */ --static void put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn) -+static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn) - { - if ( (l2e_get_flags(l2e) & _PAGE_PRESENT) && - (l2e_get_pfn(l2e) != pfn) ) -+ { - put_page_and_type(l2e_get_page(l2e)); -+ return 0; -+ } -+ return 1; - } - - --#if CONFIG_PAGING_LEVELS >= 3 --static void put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn) -+static int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, -+ int preemptible) - { - if ( (l3e_get_flags(l3e) & _PAGE_PRESENT) && - (l3e_get_pfn(l3e) != pfn) ) -- put_page_and_type(l3e_get_page(l3e)); -+ return put_page_and_type_preemptible(l3e_get_page(l3e), preemptible); -+ return 1; - } --#endif - - #if CONFIG_PAGING_LEVELS >= 4 --static void put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn) -+static int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, -+ int preemptible) - { - if ( (l4e_get_flags(l4e) & _PAGE_PRESENT) && - (l4e_get_pfn(l4e) != pfn) ) -- put_page_and_type(l4e_get_page(l4e)); -+ return put_page_and_type_preemptible(l4e_get_page(l4e), preemptible); -+ return 1; - } - #endif - -@@ -977,7 +990,7 @@ static int alloc_l1_table(struct page_in - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); - l1_pgentry_t *pl1e; -- int i; -+ unsigned int i; - - pl1e = map_domain_page(pfn); - -@@ -991,7 +1004,7 @@ static int alloc_l1_table(struct page_in - } - - unmap_domain_page(pl1e); -- return 1; -+ return 0; - - fail: - MEM_LOG("Failure in alloc_l1_table: entry %d", i); -@@ -1000,7 +1013,7 @@ static int alloc_l1_table(struct page_in - put_page_from_l1e(pl1e[i], d); - - unmap_domain_page(pl1e); -- return 0; -+ return -EINVAL; - } - - static int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e) -@@ -1128,47 +1141,53 @@ static void pae_flush_pgd( - # define pae_flush_pgd(mfn, idx, nl3e) ((void)0) - #endif - --static int alloc_l2_table(struct page_info *page, unsigned long type) -+static int alloc_l2_table(struct page_info *page, unsigned long type, -+ int preemptible) - { - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); - l2_pgentry_t *pl2e; -- int i; -+ unsigned int i; -+ int rc = 0; - - pl2e = map_domain_page(pfn); - -- for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) -+ for ( i = page->nr_validated_ptes; i < L2_PAGETABLE_ENTRIES; i++ ) - { -- if ( !is_guest_l2_slot(d, type, i) ) -+ if ( preemptible && i && hypercall_preempt_check() ) -+ { -+ page->nr_validated_ptes = i; -+ rc = -EAGAIN; -+ break; -+ } -+ -+ if ( !is_guest_l2_slot(d, type, i) || -+ (rc = get_page_from_l2e(pl2e[i], pfn, d)) > 0 ) - continue; - -- if ( unlikely(!get_page_from_l2e(pl2e[i], pfn, d)) ) -- goto fail; -- -+ if ( rc < 0 ) -+ { -+ MEM_LOG("Failure in alloc_l2_table: entry %d", i); -+ while ( i-- > 0 ) -+ if ( is_guest_l2_slot(d, type, i) ) -+ put_page_from_l2e(pl2e[i], pfn); -+ break; -+ } -+ - adjust_guest_l2e(pl2e[i], d); - } - - unmap_domain_page(pl2e); -- return 1; -- -- fail: -- MEM_LOG("Failure in alloc_l2_table: entry %d", i); -- while ( i-- > 0 ) -- if ( is_guest_l2_slot(d, type, i) ) -- put_page_from_l2e(pl2e[i], pfn); -- -- unmap_domain_page(pl2e); -- return 0; -+ return rc > 0 ? 0 : rc; - } - -- --#if CONFIG_PAGING_LEVELS >= 3 --static int alloc_l3_table(struct page_info *page) -+static int alloc_l3_table(struct page_info *page, int preemptible) - { - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); - l3_pgentry_t *pl3e; -- int i; -+ unsigned int i; -+ int rc = 0; - - #if CONFIG_PAGING_LEVELS == 3 - /* -@@ -1181,7 +1200,7 @@ static int alloc_l3_table(struct page_in - d->vcpu[0] && d->vcpu[0]->is_initialised ) - { - MEM_LOG("PAE pgd must be below 4GB (0x%lx >= 0x100000)", pfn); -- return 0; -+ return -EINVAL; - } - #endif - -@@ -1197,64 +1216,96 @@ static int alloc_l3_table(struct page_in - if ( is_pv_32on64_domain(d) ) - memset(pl3e + 4, 0, (L3_PAGETABLE_ENTRIES - 4) * sizeof(*pl3e)); - -- for ( i = 0; i < L3_PAGETABLE_ENTRIES; i++ ) -+ for ( i = page->nr_validated_ptes; i < L3_PAGETABLE_ENTRIES; i++ ) - { - if ( is_pv_32bit_domain(d) && (i == 3) ) - { - if ( !(l3e_get_flags(pl3e[i]) & _PAGE_PRESENT) || -- (l3e_get_flags(pl3e[i]) & l3_disallow_mask(d)) || -- !get_page_and_type_from_pagenr(l3e_get_pfn(pl3e[i]), -- PGT_l2_page_table | -- PGT_pae_xen_l2, -- d) ) -- goto fail; -+ (l3e_get_flags(pl3e[i]) & l3_disallow_mask(d)) ) -+ rc = -EINVAL; -+ else -+ rc = get_page_and_type_from_pagenr(l3e_get_pfn(pl3e[i]), -+ PGT_l2_page_table | -+ PGT_pae_xen_l2, -+ d, preemptible); - } -- else if ( !is_guest_l3_slot(i) ) -+ else if ( !is_guest_l3_slot(i) || -+ (rc = get_page_from_l3e(pl3e[i], pfn, d, preemptible)) > 0 ) - continue; -- else if ( unlikely(!get_page_from_l3e(pl3e[i], pfn, d)) ) -- goto fail; -+ -+ if ( rc == -EAGAIN ) -+ { -+ page->nr_validated_ptes = i; -+ page->partial_pte = 1; -+ } -+ else if ( rc == -EINTR && i ) -+ { -+ page->nr_validated_ptes = i; -+ page->partial_pte = 0; -+ rc = -EAGAIN; -+ } -+ if ( rc < 0 ) -+ break; - - adjust_guest_l3e(pl3e[i], d); - } - -- if ( !create_pae_xen_mappings(d, pl3e) ) -- goto fail; -- -- unmap_domain_page(pl3e); -- return 1; -- -- fail: -- MEM_LOG("Failure in alloc_l3_table: entry %d", i); -- while ( i-- > 0 ) -+ if ( rc >= 0 && !create_pae_xen_mappings(d, pl3e) ) -+ rc = -EINVAL; -+ if ( rc < 0 && rc != -EAGAIN && rc != -EINTR ) - { -- if ( !is_guest_l3_slot(i) ) -- continue; -- unadjust_guest_l3e(pl3e[i], d); -- put_page_from_l3e(pl3e[i], pfn); -+ MEM_LOG("Failure in alloc_l3_table: entry %d", i); -+ while ( i-- > 0 ) -+ { -+ if ( !is_guest_l3_slot(i) ) -+ continue; -+ unadjust_guest_l3e(pl3e[i], d); -+ put_page_from_l3e(pl3e[i], pfn, 0); -+ } - } - - unmap_domain_page(pl3e); -- return 0; -+ return rc > 0 ? 0 : rc; - } --#else --#define alloc_l3_table(page) (0) --#endif - - #if CONFIG_PAGING_LEVELS >= 4 --static int alloc_l4_table(struct page_info *page) -+static int alloc_l4_table(struct page_info *page, int preemptible) - { - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); - l4_pgentry_t *pl4e = page_to_virt(page); -- int i; -+ unsigned int i; -+ int rc = 0; - -- for ( i = 0; i < L4_PAGETABLE_ENTRIES; i++ ) -+ for ( i = page->nr_validated_ptes; i < L4_PAGETABLE_ENTRIES; i++ ) - { -- if ( !is_guest_l4_slot(d, i) ) -+ if ( !is_guest_l4_slot(d, i) || -+ (rc = get_page_from_l4e(pl4e[i], pfn, d, preemptible)) > 0 ) - continue; - -- if ( unlikely(!get_page_from_l4e(pl4e[i], pfn, d)) ) -- goto fail; -+ if ( rc == -EAGAIN ) -+ { -+ page->nr_validated_ptes = i; -+ page->partial_pte = 1; -+ } -+ else if ( rc == -EINTR ) -+ { -+ if ( i ) -+ { -+ page->nr_validated_ptes = i; -+ page->partial_pte = 0; -+ rc = -EAGAIN; -+ } -+ } -+ else if ( rc < 0 ) -+ { -+ MEM_LOG("Failure in alloc_l4_table: entry %d", i); -+ while ( i-- > 0 ) -+ if ( is_guest_l4_slot(d, i) ) -+ put_page_from_l4e(pl4e[i], pfn, 0); -+ } -+ if ( rc < 0 ) -+ return rc; - - adjust_guest_l4e(pl4e[i], d); - } -@@ -1269,18 +1320,10 @@ static int alloc_l4_table(struct page_in - l4e_from_page(virt_to_page(d->arch.mm_perdomain_l3), - __PAGE_HYPERVISOR); - -- return 1; -- -- fail: -- MEM_LOG("Failure in alloc_l4_table: entry %d", i); -- while ( i-- > 0 ) -- if ( is_guest_l4_slot(d, i) ) -- put_page_from_l4e(pl4e[i], pfn); -- -- return 0; -+ return rc > 0 ? 0 : rc; - } - #else --#define alloc_l4_table(page) (0) -+#define alloc_l4_table(page, preemptible) (-EINVAL) - #endif - - -@@ -1289,7 +1332,7 @@ static void free_l1_table(struct page_in - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); - l1_pgentry_t *pl1e; -- int i; -+ unsigned int i; - - pl1e = map_domain_page(pfn); - -@@ -1301,74 +1344,114 @@ static void free_l1_table(struct page_in - } - - --static void free_l2_table(struct page_info *page) -+static int free_l2_table(struct page_info *page, int preemptible) - { - #ifdef CONFIG_COMPAT - struct domain *d = page_get_owner(page); - #endif - unsigned long pfn = page_to_mfn(page); - l2_pgentry_t *pl2e; -- int i; -+ unsigned int i = page->nr_validated_ptes - 1; -+ int err = 0; - - pl2e = map_domain_page(pfn); - -- for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) -- if ( is_guest_l2_slot(d, page->u.inuse.type_info, i) ) -- put_page_from_l2e(pl2e[i], pfn); -+ ASSERT(page->nr_validated_ptes); -+ do { -+ if ( is_guest_l2_slot(d, page->u.inuse.type_info, i) && -+ put_page_from_l2e(pl2e[i], pfn) == 0 && -+ preemptible && i && hypercall_preempt_check() ) -+ { -+ page->nr_validated_ptes = i; -+ err = -EAGAIN; -+ } -+ } while ( !err && i-- ); - - unmap_domain_page(pl2e); - -- page->u.inuse.type_info &= ~PGT_pae_xen_l2; --} -- -+ if ( !err ) -+ page->u.inuse.type_info &= ~PGT_pae_xen_l2; - --#if CONFIG_PAGING_LEVELS >= 3 -+ return err; -+} - --static void free_l3_table(struct page_info *page) -+static int free_l3_table(struct page_info *page, int preemptible) - { - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); - l3_pgentry_t *pl3e; -- int i; -+ unsigned int i = page->nr_validated_ptes - !page->partial_pte; -+ int rc = 0; - - #ifdef DOMAIN_DESTRUCT_AVOID_RECURSION - if ( d->arch.relmem == RELMEM_l3 ) -- return; -+ return 0; - #endif - - pl3e = map_domain_page(pfn); - -- for ( i = 0; i < L3_PAGETABLE_ENTRIES; i++ ) -+ do { - if ( is_guest_l3_slot(i) ) - { -- put_page_from_l3e(pl3e[i], pfn); -+ rc = put_page_from_l3e(pl3e[i], pfn, preemptible); -+ if ( rc > 0 ) -+ continue; -+ if ( rc ) -+ break; - unadjust_guest_l3e(pl3e[i], d); - } -+ } while ( i-- ); - - unmap_domain_page(pl3e); --} - --#endif -+ if ( rc == -EAGAIN ) -+ { -+ page->nr_validated_ptes = i; -+ page->partial_pte = 1; -+ } -+ else if ( rc == -EINTR && i < L3_PAGETABLE_ENTRIES - 1 ) -+ { -+ page->nr_validated_ptes = i + 1; -+ page->partial_pte = 0; -+ rc = -EAGAIN; -+ } -+ return rc > 0 ? 0 : rc; -+} - - #if CONFIG_PAGING_LEVELS >= 4 -- --static void free_l4_table(struct page_info *page) -+static int free_l4_table(struct page_info *page, int preemptible) - { - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); - l4_pgentry_t *pl4e = page_to_virt(page); -- int i; -+ unsigned int i = page->nr_validated_ptes - !page->partial_pte; -+ int rc = 0; - - #ifdef DOMAIN_DESTRUCT_AVOID_RECURSION - if ( d->arch.relmem == RELMEM_l4 ) -- return; -+ return 0; - #endif - -- for ( i = 0; i < L4_PAGETABLE_ENTRIES; i++ ) -+ do { - if ( is_guest_l4_slot(d, i) ) -- put_page_from_l4e(pl4e[i], pfn); --} -+ rc = put_page_from_l4e(pl4e[i], pfn, preemptible); -+ } while ( rc >= 0 && i-- ); - -+ if ( rc == -EAGAIN ) -+ { -+ page->nr_validated_ptes = i; -+ page->partial_pte = 1; -+ } -+ else if ( rc == -EINTR && i < L4_PAGETABLE_ENTRIES - 1 ) -+ { -+ page->nr_validated_ptes = i + 1; -+ page->partial_pte = 0; -+ rc = -EAGAIN; -+ } -+ return rc > 0 ? 0 : rc; -+} -+#else -+#define free_l4_table(page, preemptible) (-EINVAL) - #endif - - static void page_lock(struct page_info *page) -@@ -1560,7 +1643,7 @@ static int mod_l2_entry(l2_pgentry_t *pl - return rc; - } - -- if ( unlikely(!get_page_from_l2e(nl2e, pfn, d)) ) -+ if ( unlikely(get_page_from_l2e(nl2e, pfn, d) < 0) ) - return page_unlock(l2pg), 0; - - adjust_guest_l2e(nl2e, d); -@@ -1583,24 +1666,23 @@ static int mod_l2_entry(l2_pgentry_t *pl - return rc; - } - --#if CONFIG_PAGING_LEVELS >= 3 -- - /* Update the L3 entry at pl3e to new value nl3e. pl3e is within frame pfn. */ - static int mod_l3_entry(l3_pgentry_t *pl3e, - l3_pgentry_t nl3e, - unsigned long pfn, -- int preserve_ad) -+ int preserve_ad, -+ int preemptible) - { - l3_pgentry_t ol3e; - struct vcpu *curr = current; - struct domain *d = curr->domain; - struct page_info *l3pg = mfn_to_page(pfn); -- int rc = 1; -+ int rc = 0; - - if ( unlikely(!is_guest_l3_slot(pgentry_ptr_to_slot(pl3e))) ) - { - MEM_LOG("Illegal L3 update attempt in Xen-private area %p", pl3e); -- return 0; -+ return -EINVAL; - } - - /* -@@ -1608,12 +1690,12 @@ static int mod_l3_entry(l3_pgentry_t *pl - * would be a pain to ensure they remain continuously valid throughout. - */ - if ( is_pv_32bit_domain(d) && (pgentry_ptr_to_slot(pl3e) >= 3) ) -- return 0; -+ return -EINVAL; - - page_lock(l3pg); - - if ( unlikely(__copy_from_user(&ol3e, pl3e, sizeof(ol3e)) != 0) ) -- return page_unlock(l3pg), 0; -+ return page_unlock(l3pg), -EFAULT; - - if ( l3e_get_flags(nl3e) & _PAGE_PRESENT ) - { -@@ -1622,7 +1704,7 @@ static int mod_l3_entry(l3_pgentry_t *pl - page_unlock(l3pg); - MEM_LOG("Bad L3 flags %x", - l3e_get_flags(nl3e) & l3_disallow_mask(d)); -- return 0; -+ return -EINVAL; - } - - /* Fast path for identical mapping and presence. */ -@@ -1631,28 +1713,30 @@ static int mod_l3_entry(l3_pgentry_t *pl - adjust_guest_l3e(nl3e, d); - rc = UPDATE_ENTRY(l3, pl3e, ol3e, nl3e, pfn, curr, preserve_ad); - page_unlock(l3pg); -- return rc; -+ return rc ? 0 : -EFAULT; - } - -- if ( unlikely(!get_page_from_l3e(nl3e, pfn, d)) ) -- return page_unlock(l3pg), 0; -+ rc = get_page_from_l3e(nl3e, pfn, d, preemptible); -+ if ( unlikely(rc < 0) ) -+ return page_unlock(l3pg), rc; -+ rc = 0; - - adjust_guest_l3e(nl3e, d); - if ( unlikely(!UPDATE_ENTRY(l3, pl3e, ol3e, nl3e, pfn, curr, - preserve_ad)) ) - { - ol3e = nl3e; -- rc = 0; -+ rc = -EFAULT; - } - } - else if ( unlikely(!UPDATE_ENTRY(l3, pl3e, ol3e, nl3e, pfn, curr, - preserve_ad)) ) - { - page_unlock(l3pg); -- return 0; -+ return -EFAULT; - } - -- if ( likely(rc) ) -+ if ( likely(rc == 0) ) - { - if ( !create_pae_xen_mappings(d, pl3e) ) - BUG(); -@@ -1661,36 +1745,35 @@ static int mod_l3_entry(l3_pgentry_t *pl - } - - page_unlock(l3pg); -- put_page_from_l3e(ol3e, pfn); -+ put_page_from_l3e(ol3e, pfn, 0); - return rc; - } - --#endif -- - #if CONFIG_PAGING_LEVELS >= 4 - - /* Update the L4 entry at pl4e to new value nl4e. pl4e is within frame pfn. */ - static int mod_l4_entry(l4_pgentry_t *pl4e, - l4_pgentry_t nl4e, - unsigned long pfn, -- int preserve_ad) -+ int preserve_ad, -+ int preemptible) - { - struct vcpu *curr = current; - struct domain *d = curr->domain; - l4_pgentry_t ol4e; - struct page_info *l4pg = mfn_to_page(pfn); -- int rc = 1; -+ int rc = 0; - - if ( unlikely(!is_guest_l4_slot(d, pgentry_ptr_to_slot(pl4e))) ) - { - MEM_LOG("Illegal L4 update attempt in Xen-private area %p", pl4e); -- return 0; -+ return -EINVAL; - } - - page_lock(l4pg); - - if ( unlikely(__copy_from_user(&ol4e, pl4e, sizeof(ol4e)) != 0) ) -- return page_unlock(l4pg), 0; -+ return page_unlock(l4pg), -EFAULT; - - if ( l4e_get_flags(nl4e) & _PAGE_PRESENT ) - { -@@ -1699,7 +1782,7 @@ static int mod_l4_entry(l4_pgentry_t *pl - page_unlock(l4pg); - MEM_LOG("Bad L4 flags %x", - l4e_get_flags(nl4e) & L4_DISALLOW_MASK); -- return 0; -+ return -EINVAL; - } - - /* Fast path for identical mapping and presence. */ -@@ -1708,29 +1791,31 @@ static int mod_l4_entry(l4_pgentry_t *pl - adjust_guest_l4e(nl4e, d); - rc = UPDATE_ENTRY(l4, pl4e, ol4e, nl4e, pfn, curr, preserve_ad); - page_unlock(l4pg); -- return rc; -+ return rc ? 0 : -EFAULT; - } - -- if ( unlikely(!get_page_from_l4e(nl4e, pfn, d)) ) -- return page_unlock(l4pg), 0; -+ rc = get_page_from_l4e(nl4e, pfn, d, preemptible); -+ if ( unlikely(rc < 0) ) -+ return page_unlock(l4pg), rc; -+ rc = 0; - - adjust_guest_l4e(nl4e, d); - if ( unlikely(!UPDATE_ENTRY(l4, pl4e, ol4e, nl4e, pfn, curr, - preserve_ad)) ) - { - ol4e = nl4e; -- rc = 0; -+ rc = -EFAULT; - } - } - else if ( unlikely(!UPDATE_ENTRY(l4, pl4e, ol4e, nl4e, pfn, curr, - preserve_ad)) ) - { - page_unlock(l4pg); -- return 0; -+ return -EFAULT; - } - - page_unlock(l4pg); -- put_page_from_l4e(ol4e, pfn); -+ put_page_from_l4e(ol4e, pfn, 0); - return rc; - } - -@@ -1788,9 +1873,11 @@ int get_page(struct page_info *page, str - } - - --static int alloc_page_type(struct page_info *page, unsigned long type) -+static int alloc_page_type(struct page_info *page, unsigned long type, -+ int preemptible) - { - struct domain *owner = page_get_owner(page); -+ int rc; - - /* A page table is dirtied when its type count becomes non-zero. */ - if ( likely(owner != NULL) ) -@@ -1799,30 +1886,65 @@ static int alloc_page_type(struct page_i - switch ( type & PGT_type_mask ) - { - case PGT_l1_page_table: -- return alloc_l1_table(page); -+ alloc_l1_table(page); -+ rc = 0; -+ break; - case PGT_l2_page_table: -- return alloc_l2_table(page, type); -+ rc = alloc_l2_table(page, type, preemptible); -+ break; - case PGT_l3_page_table: -- return alloc_l3_table(page); -+ rc = alloc_l3_table(page, preemptible); -+ break; - case PGT_l4_page_table: -- return alloc_l4_table(page); -+ rc = alloc_l4_table(page, preemptible); -+ break; - case PGT_seg_desc_page: -- return alloc_segdesc_page(page); -+ rc = alloc_segdesc_page(page); -+ break; - default: - printk("Bad type in alloc_page_type %lx t=%" PRtype_info " c=%x\n", - type, page->u.inuse.type_info, - page->count_info); -+ rc = -EINVAL; - BUG(); - } - -- return 0; -+ /* No need for atomic update of type_info here: noone else updates it. */ -+ wmb(); -+ if ( rc == -EAGAIN ) -+ { -+ page->u.inuse.type_info |= PGT_partial; -+ } -+ else if ( rc == -EINTR ) -+ { -+ ASSERT((page->u.inuse.type_info & -+ (PGT_count_mask|PGT_validated|PGT_partial)) == 1); -+ page->u.inuse.type_info &= ~PGT_count_mask; -+ } -+ else if ( rc ) -+ { -+ ASSERT(rc < 0); -+ MEM_LOG("Error while validating mfn %lx (pfn %lx) for type %" -+ PRtype_info ": caf=%08x taf=%" PRtype_info, -+ page_to_mfn(page), get_gpfn_from_mfn(page_to_mfn(page)), -+ type, page->count_info, page->u.inuse.type_info); -+ page->u.inuse.type_info = 0; -+ } -+ else -+ { -+ page->u.inuse.type_info |= PGT_validated; -+ } -+ -+ return rc; - } - - --void free_page_type(struct page_info *page, unsigned long type) -+int free_page_type(struct page_info *page, unsigned long type, -+ int preemptible) - { - struct domain *owner = page_get_owner(page); - unsigned long gmfn; -+ int rc; - - if ( likely(owner != NULL) ) - { -@@ -1842,7 +1964,7 @@ void free_page_type(struct page_info *pa - paging_mark_dirty(owner, page_to_mfn(page)); - - if ( shadow_mode_refcounts(owner) ) -- return; -+ return 0; - - gmfn = mfn_to_gmfn(owner, page_to_mfn(page)); - ASSERT(VALID_M2P(gmfn)); -@@ -1850,42 +1972,80 @@ void free_page_type(struct page_info *pa - } - } - -+ if ( !(type & PGT_partial) ) -+ { -+ page->nr_validated_ptes = 1U << PAGETABLE_ORDER; -+ page->partial_pte = 0; -+ } - switch ( type & PGT_type_mask ) - { - case PGT_l1_page_table: - free_l1_table(page); -+ rc = 0; - break; -- - case PGT_l2_page_table: -- free_l2_table(page); -+ rc = free_l2_table(page, preemptible); - break; -- --#if CONFIG_PAGING_LEVELS >= 3 - case PGT_l3_page_table: -- free_l3_table(page); -- break; -+#if CONFIG_PAGING_LEVELS == 3 -+ if ( !(type & PGT_partial) ) -+ page->nr_validated_ptes = L3_PAGETABLE_ENTRIES; - #endif -- --#if CONFIG_PAGING_LEVELS >= 4 -+ rc = free_l3_table(page, preemptible); -+ break; - case PGT_l4_page_table: -- free_l4_table(page); -+ rc = free_l4_table(page, preemptible); - break; --#endif -- - default: -- printk("%s: type %lx pfn %lx\n",__FUNCTION__, -- type, page_to_mfn(page)); -+ MEM_LOG("type %lx pfn %lx\n", type, page_to_mfn(page)); -+ rc = -EINVAL; - BUG(); - } -+ -+ /* No need for atomic update of type_info here: noone else updates it. */ -+ if ( rc == 0 ) -+ { -+ /* -+ * Record TLB information for flush later. We do not stamp page tables -+ * when running in shadow mode: -+ * 1. Pointless, since it's the shadow pt's which must be tracked. -+ * 2. Shadow mode reuses this field for shadowed page tables to -+ * store flags info -- we don't want to conflict with that. -+ */ -+ if ( !(shadow_mode_enabled(page_get_owner(page)) && -+ (page->count_info & PGC_page_table)) ) -+ page->tlbflush_timestamp = tlbflush_current_time(); -+ wmb(); -+ page->u.inuse.type_info--; -+ } -+ else if ( rc == -EINTR ) -+ { -+ ASSERT(!(page->u.inuse.type_info & -+ (PGT_count_mask|PGT_validated|PGT_partial))); -+ if ( !(shadow_mode_enabled(page_get_owner(page)) && -+ (page->count_info & PGC_page_table)) ) -+ page->tlbflush_timestamp = tlbflush_current_time(); -+ wmb(); -+ page->u.inuse.type_info |= PGT_validated; -+ } -+ else -+ { -+ BUG_ON(rc != -EAGAIN); -+ wmb(); -+ page->u.inuse.type_info |= PGT_partial; -+ } -+ -+ return rc; - } - - --void put_page_type(struct page_info *page) -+static int __put_page_type(struct page_info *page, -+ int preemptible) - { - unsigned long nx, x, y = page->u.inuse.type_info; - -- again: -- do { -+ for ( ; ; ) -+ { - x = y; - nx = x - 1; - -@@ -1894,21 +2054,19 @@ void put_page_type(struct page_info *pag - if ( unlikely((nx & PGT_count_mask) == 0) ) - { - if ( unlikely((nx & PGT_type_mask) <= PGT_l4_page_table) && -- likely(nx & PGT_validated) ) -+ likely(nx & (PGT_validated|PGT_partial)) ) - { - /* - * Page-table pages must be unvalidated when count is zero. The - * 'free' is safe because the refcnt is non-zero and validated - * bit is clear => other ops will spin or fail. - */ -- if ( unlikely((y = cmpxchg(&page->u.inuse.type_info, x, -- x & ~PGT_validated)) != x) ) -- goto again; -+ nx = x & ~(PGT_validated|PGT_partial); -+ if ( unlikely((y = cmpxchg(&page->u.inuse.type_info, -+ x, nx)) != x) ) -+ continue; - /* We cleared the 'valid bit' so we do the clean up. */ -- free_page_type(page, x); -- /* Carry on, but with the 'valid bit' now clear. */ -- x &= ~PGT_validated; -- nx &= ~PGT_validated; -+ return free_page_type(page, x, preemptible); - } - - /* -@@ -1922,25 +2080,33 @@ void put_page_type(struct page_info *pag - (page->count_info & PGC_page_table)) ) - page->tlbflush_timestamp = tlbflush_current_time(); - } -+ -+ if ( likely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) == x) ) -+ break; -+ -+ if ( preemptible && hypercall_preempt_check() ) -+ return -EINTR; - } -- while ( unlikely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) != x) ); -+ -+ return 0; - } - - --int get_page_type(struct page_info *page, unsigned long type) -+static int __get_page_type(struct page_info *page, unsigned long type, -+ int preemptible) - { - unsigned long nx, x, y = page->u.inuse.type_info; - - ASSERT(!(type & ~(PGT_type_mask | PGT_pae_xen_l2))); - -- again: -- do { -+ for ( ; ; ) -+ { - x = y; - nx = x + 1; - if ( unlikely((nx & PGT_count_mask) == 0) ) - { - MEM_LOG("Type count overflow on pfn %lx", page_to_mfn(page)); -- return 0; -+ return -EINVAL; - } - else if ( unlikely((x & PGT_count_mask) == 0) ) - { -@@ -1993,28 +2159,43 @@ int get_page_type(struct page_info *page - /* Don't log failure if it could be a recursive-mapping attempt. */ - if ( ((x & PGT_type_mask) == PGT_l2_page_table) && - (type == PGT_l1_page_table) ) -- return 0; -+ return -EINVAL; - if ( ((x & PGT_type_mask) == PGT_l3_page_table) && - (type == PGT_l2_page_table) ) -- return 0; -+ return -EINVAL; - if ( ((x & PGT_type_mask) == PGT_l4_page_table) && - (type == PGT_l3_page_table) ) -- return 0; -+ return -EINVAL; - MEM_LOG("Bad type (saw %" PRtype_info " != exp %" PRtype_info ") " - "for mfn %lx (pfn %lx)", - x, type, page_to_mfn(page), - get_gpfn_from_mfn(page_to_mfn(page))); -- return 0; -+ return -EINVAL; - } - else if ( unlikely(!(x & PGT_validated)) ) - { -- /* Someone else is updating validation of this page. Wait... */ -- while ( (y = page->u.inuse.type_info) == x ) -- cpu_relax(); -- goto again; -+ if ( !(x & PGT_partial) ) -+ { -+ /* Someone else is updating validation of this page. Wait... */ -+ while ( (y = page->u.inuse.type_info) == x ) -+ { -+ if ( preemptible && hypercall_preempt_check() ) -+ return -EINTR; -+ cpu_relax(); -+ } -+ continue; -+ } -+ /* Type ref count was left at 1 when PGT_partial got set. */ -+ ASSERT((x & PGT_count_mask) == 1); -+ nx = x & ~PGT_partial; - } -+ -+ if ( likely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) == x) ) -+ break; -+ -+ if ( preemptible && hypercall_preempt_check() ) -+ return -EINTR; - } -- while ( unlikely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) != x) ); - - if ( unlikely((x & PGT_type_mask) != type) ) - { -@@ -2032,25 +2213,42 @@ int get_page_type(struct page_info *page - - if ( unlikely(!(nx & PGT_validated)) ) - { -- /* Try to validate page type; drop the new reference on failure. */ -- if ( unlikely(!alloc_page_type(page, type)) ) -+ if ( !(x & PGT_partial) ) - { -- MEM_LOG("Error while validating mfn %lx (pfn %lx) for type %" -- PRtype_info ": caf=%08x taf=%" PRtype_info, -- page_to_mfn(page), get_gpfn_from_mfn(page_to_mfn(page)), -- type, page->count_info, page->u.inuse.type_info); -- /* Noone else can get a reference. We hold the only ref. */ -- page->u.inuse.type_info = 0; -- return 0; -+ page->nr_validated_ptes = 0; -+ page->partial_pte = 0; - } -- -- /* Noone else is updating simultaneously. */ -- __set_bit(_PGT_validated, &page->u.inuse.type_info); -+ return alloc_page_type(page, type, preemptible); - } - -- return 1; -+ return 0; - } - -+void put_page_type(struct page_info *page) -+{ -+ int rc = __put_page_type(page, 0); -+ ASSERT(rc == 0); -+ (void)rc; -+} -+ -+int get_page_type(struct page_info *page, unsigned long type) -+{ -+ int rc = __get_page_type(page, type, 0); -+ if ( likely(rc == 0) ) -+ return 1; -+ ASSERT(rc == -EINVAL); -+ return 0; -+} -+ -+int put_page_type_preemptible(struct page_info *page) -+{ -+ return __put_page_type(page, 1); -+} -+ -+int get_page_type_preemptible(struct page_info *page, unsigned long type) -+{ -+ return __get_page_type(page, type, 1); -+} - - void cleanup_page_cacheattr(struct page_info *page) - { -@@ -2087,7 +2285,7 @@ int new_guest_cr3(unsigned long mfn) - l4e_from_pfn( - mfn, - (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED)), -- pagetable_get_pfn(v->arch.guest_table), 0); -+ pagetable_get_pfn(v->arch.guest_table), 0, 0) == 0; - if ( unlikely(!okay) ) - { - MEM_LOG("Error while installing new compat baseptr %lx", mfn); -@@ -2102,7 +2300,7 @@ int new_guest_cr3(unsigned long mfn) - #endif - okay = paging_mode_refcounts(d) - ? get_page_from_pagenr(mfn, d) -- : get_page_and_type_from_pagenr(mfn, PGT_root_page_table, d); -+ : !get_page_and_type_from_pagenr(mfn, PGT_root_page_table, d, 0); - if ( unlikely(!okay) ) - { - MEM_LOG("Error while installing new baseptr %lx", mfn); -@@ -2276,9 +2474,7 @@ int do_mmuext_op( - { - if ( hypercall_preempt_check() ) - { -- rc = hypercall_create_continuation( -- __HYPERVISOR_mmuext_op, "hihi", -- uops, (count - i) | MMU_UPDATE_PREEMPTED, pdone, foreigndom); -+ rc = -EAGAIN; - break; - } - -@@ -2325,10 +2521,14 @@ int do_mmuext_op( - if ( paging_mode_refcounts(FOREIGNDOM) ) - break; - -- okay = get_page_and_type_from_pagenr(mfn, type, FOREIGNDOM); -+ rc = get_page_and_type_from_pagenr(mfn, type, FOREIGNDOM, 1); -+ okay = !rc; - if ( unlikely(!okay) ) - { -- MEM_LOG("Error while pinning mfn %lx", mfn); -+ if ( rc == -EINTR ) -+ rc = -EAGAIN; -+ else if ( rc != -EAGAIN ) -+ MEM_LOG("Error while pinning mfn %lx", mfn); - break; - } - -@@ -2373,8 +2573,11 @@ int do_mmuext_op( - { - put_page_and_type(page); - put_page(page); -- /* A page is dirtied when its pin status is cleared. */ -- paging_mark_dirty(d, mfn); -+ if ( !rc ) -+ { -+ /* A page is dirtied when its pin status is cleared. */ -+ paging_mark_dirty(d, mfn); -+ } - } - else - { -@@ -2398,8 +2601,8 @@ int do_mmuext_op( - if ( paging_mode_refcounts(d) ) - okay = get_page_from_pagenr(mfn, d); - else -- okay = get_page_and_type_from_pagenr( -- mfn, PGT_root_page_table, d); -+ okay = !get_page_and_type_from_pagenr( -+ mfn, PGT_root_page_table, d, 0); - if ( unlikely(!okay) ) - { - MEM_LOG("Error while installing new mfn %lx", mfn); -@@ -2517,6 +2720,11 @@ int do_mmuext_op( - guest_handle_add_offset(uops, 1); - } - -+ if ( rc == -EAGAIN ) -+ rc = hypercall_create_continuation( -+ __HYPERVISOR_mmuext_op, "hihi", -+ uops, (count - i) | MMU_UPDATE_PREEMPTED, pdone, foreigndom); -+ - process_deferred_ops(); - - perfc_add(num_mmuext_ops, i); -@@ -2576,9 +2784,7 @@ int do_mmu_update( - { - if ( hypercall_preempt_check() ) - { -- rc = hypercall_create_continuation( -- __HYPERVISOR_mmu_update, "hihi", -- ureqs, (count - i) | MMU_UPDATE_PREEMPTED, pdone, foreigndom); -+ rc = -EAGAIN; - break; - } - -@@ -2653,27 +2859,29 @@ int do_mmu_update( - cmd == MMU_PT_UPDATE_PRESERVE_AD); - } - break; --#if CONFIG_PAGING_LEVELS >= 3 - case PGT_l3_page_table: - { - l3_pgentry_t l3e = l3e_from_intpte(req.val); -- okay = mod_l3_entry(va, l3e, mfn, -- cmd == MMU_PT_UPDATE_PRESERVE_AD); -+ rc = mod_l3_entry(va, l3e, mfn, -+ cmd == MMU_PT_UPDATE_PRESERVE_AD, 1); -+ okay = !rc; - } - break; --#endif - #if CONFIG_PAGING_LEVELS >= 4 - case PGT_l4_page_table: - { - l4_pgentry_t l4e = l4e_from_intpte(req.val); -- okay = mod_l4_entry(va, l4e, mfn, -- cmd == MMU_PT_UPDATE_PRESERVE_AD); -+ rc = mod_l4_entry(va, l4e, mfn, -+ cmd == MMU_PT_UPDATE_PRESERVE_AD, 1); -+ okay = !rc; - } - break; - #endif - } - - put_page_type(page); -+ if ( rc == -EINTR ) -+ rc = -EAGAIN; - } - break; - -@@ -2742,6 +2950,11 @@ int do_mmu_update( - guest_handle_add_offset(ureqs, 1); - } - -+ if ( rc == -EAGAIN ) -+ rc = hypercall_create_continuation( -+ __HYPERVISOR_mmu_update, "hihi", -+ ureqs, (count - i) | MMU_UPDATE_PREEMPTED, pdone, foreigndom); -+ - process_deferred_ops(); - - domain_mmap_cache_destroy(&mapcache); -@@ -3621,9 +3834,8 @@ static int ptwr_emulated_update( - nl1e = l1e_from_intpte(val); - if ( unlikely(!get_page_from_l1e(nl1e, d)) ) - { -- if ( (CONFIG_PAGING_LEVELS >= 3) && is_pv_32bit_domain(d) && -- (bytes == 4) && (unaligned_addr & 4) && !do_cmpxchg && -- (l1e_get_flags(nl1e) & _PAGE_PRESENT) ) -+ if ( is_pv_32bit_domain(d) && (bytes == 4) && (unaligned_addr & 4) && -+ !do_cmpxchg && (l1e_get_flags(nl1e) & _PAGE_PRESENT) ) - { - /* - * If this is an upper-half write to a PAE PTE then we assume that -Index: xen-3.3.1-testing/xen/include/asm-x86/mm.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/mm.h -+++ xen-3.3.1-testing/xen/include/asm-x86/mm.h -@@ -59,6 +59,17 @@ struct page_info - u32 tlbflush_timestamp; - - /* -+ * When PGT_partial is true then this field is valid and indicates -+ * that PTEs in the range [0, @nr_validated_ptes) have been validated. -+ * If @partial_pte is true then PTE at @nr_validated_ptes+1 has been -+ * partially validated. -+ */ -+ struct { -+ u16 nr_validated_ptes; -+ bool_t partial_pte; -+ }; -+ -+ /* - * Guest pages with a shadow. This does not conflict with - * tlbflush_timestamp since page table pages are explicitly not - * tracked for TLB-flush avoidance when a guest runs in shadow mode. -@@ -86,9 +97,12 @@ struct page_info - /* PAE only: is this an L2 page directory containing Xen-private mappings? */ - #define _PGT_pae_xen_l2 26 - #define PGT_pae_xen_l2 (1U<<_PGT_pae_xen_l2) -+/* Has this page been *partially* validated for use as its current type? */ -+#define _PGT_partial 25 -+#define PGT_partial (1U<<_PGT_partial) - -- /* 26-bit count of uses of this frame as its current type. */ --#define PGT_count_mask ((1U<<26)-1) -+ /* 25-bit count of uses of this frame as its current type. */ -+#define PGT_count_mask ((1U<<25)-1) - - /* Cleared when the owning guest 'frees' this page. */ - #define _PGC_allocated 31 -@@ -154,7 +168,8 @@ extern unsigned long max_page; - extern unsigned long total_pages; - void init_frametable(void); - --void free_page_type(struct page_info *page, unsigned long type); -+int free_page_type(struct page_info *page, unsigned long type, -+ int preemptible); - int _shadow_mode_refcounts(struct domain *d); - - void cleanup_page_cacheattr(struct page_info *page); -@@ -165,6 +180,8 @@ void put_page(struct page_info *page); - int get_page(struct page_info *page, struct domain *domain); - void put_page_type(struct page_info *page); - int get_page_type(struct page_info *page, unsigned long type); -+int put_page_type_preemptible(struct page_info *page); -+int get_page_type_preemptible(struct page_info *page, unsigned long type); - int get_page_from_l1e(l1_pgentry_t l1e, struct domain *d); - void put_page_from_l1e(l1_pgentry_t l1e, struct domain *d); - -@@ -174,6 +191,19 @@ static inline void put_page_and_type(str - put_page(page); - } - -+static inline int put_page_and_type_preemptible(struct page_info *page, -+ int preemptible) -+{ -+ int rc = 0; -+ -+ if ( preemptible ) -+ rc = put_page_type_preemptible(page); -+ else -+ put_page_type(page); -+ if ( likely(rc == 0) ) -+ put_page(page); -+ return rc; -+} - - static inline int get_page_and_type(struct page_info *page, - struct domain *domain, diff --git a/18420-x86-page-type-preemptible-fix.patch b/18420-x86-page-type-preemptible-fix.patch deleted file mode 100644 index 55cdbe8..0000000 --- a/18420-x86-page-type-preemptible-fix.patch +++ /dev/null @@ -1,51 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1220450168 -3600 -# Node ID c9db93b0660ae644491c862e47744a2349ba630f -# Parent 1e98ea5c860438a227e135701e6439b22826f52f -x86: Fix interpretation of get_l*e_linear_pagetable(). - -Broken by get_page_type() preemption patch (c/s 18412). - -Signed-off-by: Keir Fraser - -Index: xen-3.3.0-testing/xen/arch/x86/mm.c -=================================================================== ---- xen-3.3.0-testing.orig/xen/arch/x86/mm.c -+++ xen-3.3.0-testing/xen/arch/x86/mm.c -@@ -762,9 +762,8 @@ get_page_from_l2e( - - rc = get_page_and_type_from_pagenr( - l2e_get_pfn(l2e), PGT_l1_page_table, d, 0); -- if ( unlikely(rc) && rc != -EAGAIN && -- get_l2_linear_pagetable(l2e, pfn, d) ) -- rc = -EINVAL; -+ if ( unlikely(rc == -EINVAL) && get_l2_linear_pagetable(l2e, pfn, d) ) -+ rc = 0; - - return rc; - } -@@ -788,9 +787,8 @@ get_page_from_l3e( - - rc = get_page_and_type_from_pagenr( - l3e_get_pfn(l3e), PGT_l2_page_table, d, preemptible); -- if ( unlikely(rc) && rc != -EAGAIN && rc != -EINTR && -- get_l3_linear_pagetable(l3e, pfn, d) ) -- rc = -EINVAL; -+ if ( unlikely(rc == -EINVAL) && get_l3_linear_pagetable(l3e, pfn, d) ) -+ rc = 0; - - return rc; - } -@@ -814,9 +812,8 @@ get_page_from_l4e( - - rc = get_page_and_type_from_pagenr( - l4e_get_pfn(l4e), PGT_l3_page_table, d, preemptible); -- if ( unlikely(rc) && rc != -EAGAIN && rc != -EINTR && -- get_l4_linear_pagetable(l4e, pfn, d) ) -- rc = -EINVAL; -+ if ( unlikely(rc == -EINVAL) && get_l4_linear_pagetable(l4e, pfn, d) ) -+ rc = 0; - - return rc; - } diff --git a/18428-poll-single-port.patch b/18428-poll-single-port.patch deleted file mode 100644 index c7efcf3..0000000 --- a/18428-poll-single-port.patch +++ /dev/null @@ -1,235 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1220535506 -3600 -# Node ID ae9b223a675d9ed37cffbc24d0abe83ef2a30ab3 -# Parent 8d982c7a0d303de1200134fcf3a2573f6f4449fa -More efficient implementation of SCHEDOP_poll when polling a single port. -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/common/domain.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/domain.c -+++ xen-3.3.1-testing/xen/common/domain.c -@@ -673,9 +673,11 @@ void vcpu_reset(struct vcpu *v) - - set_bit(_VPF_down, &v->pause_flags); - -+ clear_bit(v->vcpu_id, d->poll_mask); -+ v->poll_evtchn = 0; -+ - v->fpu_initialised = 0; - v->fpu_dirtied = 0; -- v->is_polling = 0; - v->is_initialised = 0; - v->nmi_pending = 0; - v->mce_pending = 0; -Index: xen-3.3.1-testing/xen/common/event_channel.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/event_channel.c -+++ xen-3.3.1-testing/xen/common/event_channel.c -@@ -534,6 +534,7 @@ out: - static int evtchn_set_pending(struct vcpu *v, int port) - { - struct domain *d = v->domain; -+ int vcpuid; - - /* - * The following bit operations must happen in strict order. -@@ -553,15 +554,19 @@ static int evtchn_set_pending(struct vcp - } - - /* Check if some VCPU might be polling for this event. */ -- if ( unlikely(d->is_polling) ) -- { -- d->is_polling = 0; -- smp_mb(); /* check vcpu poll-flags /after/ clearing domain poll-flag */ -- for_each_vcpu ( d, v ) -+ if ( likely(bitmap_empty(d->poll_mask, MAX_VIRT_CPUS)) ) -+ return 0; -+ -+ /* Wake any interested (or potentially interested) pollers. */ -+ for ( vcpuid = find_first_bit(d->poll_mask, MAX_VIRT_CPUS); -+ vcpuid < MAX_VIRT_CPUS; -+ vcpuid = find_next_bit(d->poll_mask, MAX_VIRT_CPUS, vcpuid+1) ) -+ { -+ v = d->vcpu[vcpuid]; -+ if ( ((v->poll_evtchn <= 0) || (v->poll_evtchn == port)) && -+ test_and_clear_bit(vcpuid, d->poll_mask) ) - { -- if ( !v->is_polling ) -- continue; -- v->is_polling = 0; -+ v->poll_evtchn = 0; - vcpu_unblock(v); - } - } -Index: xen-3.3.1-testing/xen/common/schedule.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/schedule.c -+++ xen-3.3.1-testing/xen/common/schedule.c -@@ -198,6 +198,27 @@ void vcpu_wake(struct vcpu *v) - TRACE_2D(TRC_SCHED_WAKE, v->domain->domain_id, v->vcpu_id); - } - -+void vcpu_unblock(struct vcpu *v) -+{ -+ if ( !test_and_clear_bit(_VPF_blocked, &v->pause_flags) ) -+ return; -+ -+ /* Polling period ends when a VCPU is unblocked. */ -+ if ( unlikely(v->poll_evtchn != 0) ) -+ { -+ v->poll_evtchn = 0; -+ /* -+ * We *must* re-clear _VPF_blocked to avoid racing other wakeups of -+ * this VCPU (and it then going back to sleep on poll_mask). -+ * Test-and-clear is idiomatic and ensures clear_bit not reordered. -+ */ -+ if ( test_and_clear_bit(v->vcpu_id, v->domain->poll_mask) ) -+ clear_bit(_VPF_blocked, &v->pause_flags); -+ } -+ -+ vcpu_wake(v); -+} -+ - static void vcpu_migrate(struct vcpu *v) - { - unsigned long flags; -@@ -337,7 +358,7 @@ static long do_poll(struct sched_poll *s - struct vcpu *v = current; - struct domain *d = v->domain; - evtchn_port_t port; -- long rc = 0; -+ long rc; - unsigned int i; - - /* Fairly arbitrary limit. */ -@@ -348,11 +369,24 @@ static long do_poll(struct sched_poll *s - return -EFAULT; - - set_bit(_VPF_blocked, &v->pause_flags); -- v->is_polling = 1; -- d->is_polling = 1; -+ v->poll_evtchn = -1; -+ set_bit(v->vcpu_id, d->poll_mask); - -+#ifndef CONFIG_X86 /* set_bit() implies mb() on x86 */ - /* Check for events /after/ setting flags: avoids wakeup waiting race. */ -- smp_wmb(); -+ smp_mb(); -+ -+ /* -+ * Someone may have seen we are blocked but not that we are polling, or -+ * vice versa. We are certainly being woken, so clean up and bail. Beyond -+ * this point others can be guaranteed to clean up for us if they wake us. -+ */ -+ rc = 0; -+ if ( (v->poll_evtchn == 0) || -+ !test_bit(_VPF_blocked, &v->pause_flags) || -+ !test_bit(v->vcpu_id, d->poll_mask) ) -+ goto out; -+#endif - - rc = 0; - if ( local_events_need_delivery() ) -@@ -373,6 +407,9 @@ static long do_poll(struct sched_poll *s - goto out; - } - -+ if ( sched_poll->nr_ports == 1 ) -+ v->poll_evtchn = port; -+ - if ( sched_poll->timeout != 0 ) - set_timer(&v->poll_timer, sched_poll->timeout); - -@@ -382,7 +419,8 @@ static long do_poll(struct sched_poll *s - return 0; - - out: -- v->is_polling = 0; -+ v->poll_evtchn = 0; -+ clear_bit(v->vcpu_id, d->poll_mask); - clear_bit(_VPF_blocked, &v->pause_flags); - return rc; - } -@@ -764,11 +802,8 @@ static void poll_timer_fn(void *data) - { - struct vcpu *v = data; - -- if ( !v->is_polling ) -- return; -- -- v->is_polling = 0; -- vcpu_unblock(v); -+ if ( test_and_clear_bit(v->vcpu_id, v->domain->poll_mask) ) -+ vcpu_unblock(v); - } - - /* Initialise the data structures. */ -Index: xen-3.3.1-testing/xen/include/xen/sched.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/xen/sched.h -+++ xen-3.3.1-testing/xen/include/xen/sched.h -@@ -106,8 +106,6 @@ struct vcpu - bool_t fpu_initialised; - /* Has the FPU been used since it was last saved? */ - bool_t fpu_dirtied; -- /* Is this VCPU polling any event channels (SCHEDOP_poll)? */ -- bool_t is_polling; - /* Initialization completed for this VCPU? */ - bool_t is_initialised; - /* Currently running on a CPU? */ -@@ -134,6 +132,13 @@ struct vcpu - /* VCPU affinity is temporarily locked from controller changes? */ - bool_t affinity_locked; - -+ /* -+ * > 0: a single port is being polled; -+ * = 0: nothing is being polled (vcpu should be clear in d->poll_mask); -+ * < 0: multiple ports may be being polled. -+ */ -+ int poll_evtchn; -+ - unsigned long pause_flags; - atomic_t pause_count; - -@@ -209,8 +214,6 @@ struct domain - struct domain *target; - /* Is this guest being debugged by dom0? */ - bool_t debugger_attached; -- /* Are any VCPUs polling event channels (SCHEDOP_poll)? */ -- bool_t is_polling; - /* Is this guest dying (i.e., a zombie)? */ - enum { DOMDYING_alive, DOMDYING_dying, DOMDYING_dead } is_dying; - /* Domain is paused by controller software? */ -@@ -218,6 +221,9 @@ struct domain - /* Domain's VCPUs are pinned 1:1 to physical CPUs? */ - bool_t is_pinned; - -+ /* Are any VCPUs polling event channels (SCHEDOP_poll)? */ -+ DECLARE_BITMAP(poll_mask, MAX_VIRT_CPUS); -+ - /* Guest has shut down (inc. reason code)? */ - spinlock_t shutdown_lock; - bool_t is_shutting_down; /* in process of shutting down? */ -@@ -514,6 +520,7 @@ static inline int vcpu_runnable(struct v - atomic_read(&v->domain->pause_count)); - } - -+void vcpu_unblock(struct vcpu *v); - void vcpu_pause(struct vcpu *v); - void vcpu_pause_nosync(struct vcpu *v); - void domain_pause(struct domain *d); -@@ -530,12 +537,6 @@ void vcpu_unlock_affinity(struct vcpu *v - - void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate); - --static inline void vcpu_unblock(struct vcpu *v) --{ -- if ( test_and_clear_bit(_VPF_blocked, &v->pause_flags) ) -- vcpu_wake(v); --} -- - #define IS_PRIV(_d) ((_d)->is_privileged) - #define IS_PRIV_FOR(_d, _t) (IS_PRIV(_d) || ((_d)->target && (_d)->target == (_t))) - diff --git a/18446-vtd-dom0-passthrough.patch b/18446-vtd-dom0-passthrough.patch deleted file mode 100644 index f6364d2..0000000 --- a/18446-vtd-dom0-passthrough.patch +++ /dev/null @@ -1,62 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1220968229 -3600 -# Node ID 5ce9459ce8722a8af89da5a73b0c80a767d5b1ad -# Parent d57e9b29858bddf4651efb002cfdadf978da79c0 -vtd: Enable pass-through translation for Dom0 - -If pass-through field in extended capability register is set, set -pass-through translation type for Dom0, that means DMA requests with -Untranslated addresses are processed as pass-through in Dom0, needn't -translate DMA requests through a multi-level page-table. - -Signed-off-by: Anthony Xu -Signed-off-by: Weidong Han - -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/iommu.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.c -@@ -1089,12 +1089,12 @@ static int domain_context_mapping_one( - } - - spin_lock_irqsave(&iommu->lock, flags); -- --#ifdef CONTEXT_PASSTHRU - if ( ecap_pass_thru(iommu->ecap) && (domain->domain_id == 0) ) -+ { - context_set_translation_type(*context, CONTEXT_TT_PASS_THRU); -+ agaw = level_to_agaw(iommu->nr_pt_levels); -+ } - else --#endif - { - /* Ensure we have pagetables allocated down to leaf PTE. */ - if ( hd->pgd_maddr == 0 ) -@@ -1463,11 +1463,12 @@ int intel_iommu_map_page( - u64 pg_maddr; - int pte_present; - --#ifdef CONTEXT_PASSTHRU -+ drhd = list_entry(acpi_drhd_units.next, typeof(*drhd), list); -+ iommu = drhd->iommu; -+ - /* do nothing if dom0 and iommu supports pass thru */ - if ( ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) ) - return 0; --#endif - - pg_maddr = addr_to_dma_page_maddr(d, (paddr_t)gfn << PAGE_SHIFT_4K, 1); - if ( pg_maddr == 0 ) -@@ -1504,11 +1505,9 @@ int intel_iommu_unmap_page(struct domain - drhd = list_entry(acpi_drhd_units.next, typeof(*drhd), list); - iommu = drhd->iommu; - --#ifdef CONTEXT_PASSTHRU - /* do nothing if dom0 and iommu supports pass thru */ - if ( ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) ) - return 0; --#endif - - dma_pte_clear_one(d, (paddr_t)gfn << PAGE_SHIFT_4K); - diff --git a/18456-vtd-dom0-passthrough-cmdline.patch b/18456-vtd-dom0-passthrough-cmdline.patch deleted file mode 100644 index 3f09e30..0000000 --- a/18456-vtd-dom0-passthrough-cmdline.patch +++ /dev/null @@ -1,91 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1221040389 -3600 -# Node ID 6a37b3d966f90f3c1604c9a3045d033cc5eeb4ea -# Parent b5912430e66c900c2092c035227816f43f7caeb0 -vtd: Add a command line param to enable/disable pass-through feature - -Taking security into accout, it's not suitable to bypass VT-d -translation for Dom0 by default when the pass-through field in -extended capability register is set. This feature is for people/usages -who are not overly worried about security/isolation, but want better -performance. - -This patch adds a command line param that controls if it's enabled or -disabled. - -Signed-off-by: Weidong Han - -Index: xen-3.3.1-testing/xen/drivers/passthrough/iommu.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/iommu.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/iommu.c -@@ -33,11 +33,13 @@ int amd_iov_detect(void); - * pv Enable IOMMU for PV domains - * no-pv Disable IOMMU for PV domains (default) - * force|required Don't boot unless IOMMU is enabled -+ * passthrough Bypass VT-d translation for Dom0 - */ - custom_param("iommu", parse_iommu_param); - int iommu_enabled = 0; - int iommu_pv_enabled = 0; - int force_iommu = 0; -+int iommu_passthrough = 0; - - static void __init parse_iommu_param(char *s) - { -@@ -58,6 +60,8 @@ static void __init parse_iommu_param(cha - iommu_pv_enabled = 0; - else if ( !strcmp(s, "force") || !strcmp(s, "required") ) - force_iommu = 1; -+ else if ( !strcmp(s, "passthrough") ) -+ iommu_passthrough = 1; - - s = ss + 1; - } while ( ss ); -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/iommu.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.c -@@ -1089,7 +1089,8 @@ static int domain_context_mapping_one( - } - - spin_lock_irqsave(&iommu->lock, flags); -- if ( ecap_pass_thru(iommu->ecap) && (domain->domain_id == 0) ) -+ if ( iommu_passthrough && -+ ecap_pass_thru(iommu->ecap) && (domain->domain_id == 0) ) - { - context_set_translation_type(*context, CONTEXT_TT_PASS_THRU); - agaw = level_to_agaw(iommu->nr_pt_levels); -@@ -1467,7 +1468,8 @@ int intel_iommu_map_page( - iommu = drhd->iommu; - - /* do nothing if dom0 and iommu supports pass thru */ -- if ( ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) ) -+ if ( iommu_passthrough && -+ ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) ) - return 0; - - pg_maddr = addr_to_dma_page_maddr(d, (paddr_t)gfn << PAGE_SHIFT_4K, 1); -@@ -1506,7 +1508,8 @@ int intel_iommu_unmap_page(struct domain - iommu = drhd->iommu; - - /* do nothing if dom0 and iommu supports pass thru */ -- if ( ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) ) -+ if ( iommu_passthrough && -+ ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) ) - return 0; - - dma_pte_clear_one(d, (paddr_t)gfn << PAGE_SHIFT_4K); -Index: xen-3.3.1-testing/xen/include/xen/iommu.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/xen/iommu.h -+++ xen-3.3.1-testing/xen/include/xen/iommu.h -@@ -31,6 +31,7 @@ extern int vtd_enabled; - extern int iommu_enabled; - extern int iommu_pv_enabled; - extern int force_iommu; -+extern int iommu_passthrough; - - #define domain_hvm_iommu(d) (&d->arch.hvm_domain.hvm_iommu) - diff --git a/18464-cpu-hotplug.patch b/18464-cpu-hotplug.patch deleted file mode 100644 index c3e312a..0000000 --- a/18464-cpu-hotplug.patch +++ /dev/null @@ -1,213 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1221141982 -3600 -# Node ID 4ffc70556000869d3c301452a99e4e524dd54b07 -# Parent fba8dca321c2b99842af6624f24afb77c472184b -x86: Support CPU hotplug offline. - -Signed-off-by: Shan Haitao -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/irq.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/irq.c -+++ xen-3.3.1-testing/xen/arch/x86/irq.c -@@ -751,9 +751,12 @@ __initcall(setup_dump_irqs); - - void fixup_irqs(cpumask_t map) - { -- unsigned int irq; -+ unsigned int irq, sp; - static int warned; -+ irq_guest_action_t *action; -+ struct pending_eoi *peoi; - -+ /* Direct all future interrupts away from this CPU. */ - for ( irq = 0; irq < NR_IRQS; irq++ ) - { - cpumask_t mask; -@@ -772,8 +775,24 @@ void fixup_irqs(cpumask_t map) - printk("Cannot set affinity for irq %i\n", irq); - } - -+ /* Service any interrupts that beat us in the re-direction race. */ - local_irq_enable(); - mdelay(1); - local_irq_disable(); -+ -+ /* Clean up cpu_eoi_map of every interrupt to exclude this CPU. */ -+ for ( irq = 0; irq < NR_IRQS; irq++ ) -+ { -+ if ( !(irq_desc[irq].status & IRQ_GUEST) ) -+ continue; -+ action = (irq_guest_action_t *)irq_desc[irq].action; -+ cpu_clear(smp_processor_id(), action->cpu_eoi_map); -+ } -+ -+ /* Flush the interrupt EOI stack. */ -+ peoi = this_cpu(pending_eoi); -+ for ( sp = 0; sp < pending_eoi_sp(peoi); sp++ ) -+ peoi[sp].ready = 1; -+ flush_ready_eoi(NULL); - } - #endif -Index: xen-3.3.1-testing/xen/arch/x86/smpboot.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/smpboot.c -+++ xen-3.3.1-testing/xen/arch/x86/smpboot.c -@@ -1224,15 +1224,6 @@ int __cpu_disable(void) - if (cpu == 0) - return -EBUSY; - -- /* -- * Only S3 is using this path, and thus idle vcpus are running on all -- * APs when we are called. To support full cpu hotplug, other -- * notification mechanisms should be introduced (e.g., migrate vcpus -- * off this physical cpu before rendezvous point). -- */ -- if (!is_idle_vcpu(current)) -- return -EINVAL; -- - local_irq_disable(); - clear_local_APIC(); - /* Allow any queued timer interrupts to get serviced */ -@@ -1248,6 +1239,9 @@ int __cpu_disable(void) - fixup_irqs(map); - /* It's now safe to remove this processor from the online map */ - cpu_clear(cpu, cpu_online_map); -+ -+ cpu_disable_scheduler(); -+ - return 0; - } - -@@ -1274,28 +1268,6 @@ static int take_cpu_down(void *unused) - return __cpu_disable(); - } - --/* -- * XXX: One important thing missed here is to migrate vcpus -- * from dead cpu to other online ones and then put whole -- * system into a stop state. It assures a safe environment -- * for a cpu hotplug/remove at normal running state. -- * -- * However for xen PM case, at this point: -- * -> All other domains should be notified with PM event, -- * and then in following states: -- * * Suspend state, or -- * * Paused state, which is a force step to all -- * domains if they do nothing to suspend -- * -> All vcpus of dom0 (except vcpu0) have already beem -- * hot removed -- * with the net effect that all other cpus only have idle vcpu -- * running. In this special case, we can avoid vcpu migration -- * then and system can be considered in a stop state. -- * -- * So current cpu hotplug is a special version for PM specific -- * usage, and need more effort later for full cpu hotplug. -- * (ktian1) -- */ - int cpu_down(unsigned int cpu) - { - int err = 0; -@@ -1306,6 +1278,12 @@ int cpu_down(unsigned int cpu) - goto out; - } - -+ /* Can not offline BSP */ -+ if (cpu == 0) { -+ err = -EINVAL; -+ goto out; -+ } -+ - if (!cpu_online(cpu)) { - err = -EINVAL; - goto out; -Index: xen-3.3.1-testing/xen/common/sched_credit.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/sched_credit.c -+++ xen-3.3.1-testing/xen/common/sched_credit.c -@@ -1107,6 +1107,10 @@ csched_load_balance(int cpu, struct csch - - BUG_ON( cpu != snext->vcpu->processor ); - -+ /* If this CPU is going offline we shouldn't steal work. */ -+ if ( unlikely(!cpu_online(cpu)) ) -+ goto out; -+ - if ( snext->pri == CSCHED_PRI_IDLE ) - CSCHED_STAT_CRANK(load_balance_idle); - else if ( snext->pri == CSCHED_PRI_TS_OVER ) -@@ -1149,6 +1153,7 @@ csched_load_balance(int cpu, struct csch - return speer; - } - -+ out: - /* Failed to find more important work elsewhere... */ - __runq_remove(snext); - return snext; -Index: xen-3.3.1-testing/xen/common/schedule.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/schedule.c -+++ xen-3.3.1-testing/xen/common/schedule.c -@@ -268,6 +268,48 @@ void vcpu_force_reschedule(struct vcpu * - } - } - -+/* -+ * This function is used by cpu_hotplug code from stop_machine context. -+ * Hence we can avoid needing to take the -+ */ -+void cpu_disable_scheduler(void) -+{ -+ struct domain *d; -+ struct vcpu *v; -+ unsigned int cpu = smp_processor_id(); -+ -+ for_each_domain ( d ) -+ { -+ for_each_vcpu ( d, v ) -+ { -+ if ( is_idle_vcpu(v) ) -+ continue; -+ -+ if ( (cpus_weight(v->cpu_affinity) == 1) && -+ cpu_isset(cpu, v->cpu_affinity) ) -+ { -+ printk("Breaking vcpu affinity for domain %d vcpu %d\n", -+ v->domain->domain_id, v->vcpu_id); -+ cpus_setall(v->cpu_affinity); -+ } -+ -+ /* -+ * Migrate single-shot timers to CPU0. A new cpu will automatically -+ * be chosen when the timer is next re-set. -+ */ -+ if ( v->singleshot_timer.cpu == cpu ) -+ migrate_timer(&v->singleshot_timer, 0); -+ -+ if ( v->processor == cpu ) -+ { -+ set_bit(_VPF_migrating, &v->pause_flags); -+ vcpu_sleep_nosync(v); -+ vcpu_migrate(v); -+ } -+ } -+ } -+} -+ - static int __vcpu_set_affinity( - struct vcpu *v, cpumask_t *affinity, - bool_t old_lock_status, bool_t new_lock_status) -Index: xen-3.3.1-testing/xen/include/xen/sched.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/xen/sched.h -+++ xen-3.3.1-testing/xen/include/xen/sched.h -@@ -531,6 +531,7 @@ void domain_unpause_by_systemcontroller( - void cpu_init(void); - - void vcpu_force_reschedule(struct vcpu *v); -+void cpu_disable_scheduler(void); - int vcpu_set_affinity(struct vcpu *v, cpumask_t *affinity); - int vcpu_lock_affinity(struct vcpu *v, cpumask_t *affinity); - void vcpu_unlock_affinity(struct vcpu *v, cpumask_t *affinity); diff --git a/18468-therm-control-msr.patch b/18468-therm-control-msr.patch deleted file mode 100644 index 71b9ad5..0000000 --- a/18468-therm-control-msr.patch +++ /dev/null @@ -1,41 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1221148273 -3600 -# Node ID a5cc38391afb16af6bdae32c5a5f4f9a3a236987 -# Parent d8ce41b79ecc74c00797d73caa56dbdaf02bbd66 -ACPI: Grant access of MSR_IA32_THERM_CONTROL MSR to dom0 - -The purpose is to support dom0 throttling control via MSR. - -Signed-off-by: Wei Gang - -Index: xen-3.3.1-testing/xen/arch/x86/traps.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/traps.c -+++ xen-3.3.1-testing/xen/arch/x86/traps.c -@@ -2160,6 +2160,12 @@ static int emulate_privileged_op(struct - if ( wrmsr_safe(regs->ecx, eax, edx) != 0 ) - goto fail; - break; -+ case MSR_IA32_THERM_CONTROL: -+ if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ) -+ goto fail; -+ if ( wrmsr_safe(regs->ecx, eax, edx) != 0 ) -+ goto fail; -+ break; - default: - if ( wrmsr_hypervisor_regs(regs->ecx, eax, edx) ) - break; -@@ -2236,6 +2242,12 @@ static int emulate_privileged_op(struct - MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL | - MSR_IA32_MISC_ENABLE_XTPR_DISABLE; - break; -+ case MSR_IA32_THERM_CONTROL: -+ if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ) -+ goto fail; -+ if ( rdmsr_safe(regs->ecx, regs->eax, regs->edx) ) -+ goto fail; -+ break; - default: - if ( rdmsr_hypervisor_regs(regs->ecx, &l, &h) ) - { diff --git a/18471-cpu-hotplug.patch b/18471-cpu-hotplug.patch deleted file mode 100644 index 6340f55..0000000 --- a/18471-cpu-hotplug.patch +++ /dev/null @@ -1,27 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1221212419 -3600 -# Node ID 34aed15ba9df804ce037c5f691a9b11058fff2b9 -# Parent f125e481d8b65b81dd794d60a99fb0b823eaee2c -x86, cpu hotplug: flush softirq work when going offline - -From: Haitao Shan -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/domain.c -+++ xen-3.3.1-testing/xen/arch/x86/domain.c -@@ -86,6 +86,12 @@ static void default_idle(void) - - static void play_dead(void) - { -+ /* -+ * Flush pending softirqs if any. They can be queued up before this CPU -+ * was taken out of cpu_online_map in __cpu_disable(). -+ */ -+ do_softirq(); -+ - /* This must be done before dead CPU ack */ - cpu_exit_clear(); - hvm_cpu_down(); diff --git a/18475-amd-microcode-update.patch b/18475-amd-microcode-update.patch deleted file mode 100644 index ab79122..0000000 --- a/18475-amd-microcode-update.patch +++ /dev/null @@ -1,1660 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1221225493 -3600 -# Node ID 15b1c3d4459afd62fb3de04d69c3c09941ac587c -# Parent e827c54462d3ba44ee3d4ca60bbc970c240551da -x86: microcode update support for AMD CPUs - -Microcode update support for AMD CPUs Family10h and Family11h. -It is based on a patch for Linux which is on its way for 2.6.28. - -Signed-off-by: Christoph Egger - -Index: xen-3.3.1-testing/xen/arch/x86/Makefile -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/Makefile -+++ xen-3.3.1-testing/xen/arch/x86/Makefile -@@ -28,6 +28,8 @@ obj-y += msi.o - obj-y += ioport_emulate.o - obj-y += irq.o - obj-y += microcode.o -+obj-y += microcode_amd.o -+obj-y += microcode_intel.o - obj-y += mm.o - obj-y += mpparse.o - obj-y += nmi.o -Index: xen-3.3.1-testing/xen/arch/x86/microcode.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/microcode.c -+++ xen-3.3.1-testing/xen/arch/x86/microcode.c -@@ -1,72 +1,73 @@ - /* -- * Intel CPU Microcode Update Driver for Linux -+ * Intel CPU Microcode Update Driver for Linux - * -- * Copyright (C) 2000-2004 Tigran Aivazian -+ * Copyright (C) 2000-2006 Tigran Aivazian -+ * 2006 Shaohua Li * -+ * This driver allows to upgrade microcode on Intel processors -+ * belonging to IA-32 family - PentiumPro, Pentium II, -+ * Pentium III, Xeon, Pentium 4, etc. - * -- * This driver allows to upgrade microcode on Intel processors -- * belonging to IA-32 family - PentiumPro, Pentium II, -- * Pentium III, Xeon, Pentium 4, etc. -+ * Reference: Section 8.11 of Volume 3a, IA-32 Intel? Architecture -+ * Software Developer's Manual -+ * Order Number 253668 or free download from: - * -- * Reference: Section 8.10 of Volume III, Intel Pentium 4 Manual, -- * Order Number 245472 or free download from: -- * -- * http://developer.intel.com/design/pentium4/manuals/245472.htm -+ * http://developer.intel.com/design/pentium4/manuals/253668.htm - * -- * For more information, go to http://www.urbanmyth.org/microcode -+ * For more information, go to http://www.urbanmyth.org/microcode - * -- * This program is free software; you can redistribute it and/or -- * modify it under the terms of the GNU General Public License -- * as published by the Free Software Foundation; either version -- * 2 of the License, or (at your option) any later version. -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version -+ * 2 of the License, or (at your option) any later version. - * -- * 1.0 16 Feb 2000, Tigran Aivazian -- * Initial release. -- * 1.01 18 Feb 2000, Tigran Aivazian -- * Added read() support + cleanups. -- * 1.02 21 Feb 2000, Tigran Aivazian -- * Added 'device trimming' support. open(O_WRONLY) zeroes -- * and frees the saved copy of applied microcode. -- * 1.03 29 Feb 2000, Tigran Aivazian -- * Made to use devfs (/dev/cpu/microcode) + cleanups. -- * 1.04 06 Jun 2000, Simon Trimmer -- * Added misc device support (now uses both devfs and misc). -- * Added MICROCODE_IOCFREE ioctl to clear memory. -- * 1.05 09 Jun 2000, Simon Trimmer -- * Messages for error cases (non Intel & no suitable microcode). -- * 1.06 03 Aug 2000, Tigran Aivazian -- * Removed ->release(). Removed exclusive open and status bitmap. -- * Added microcode_rwsem to serialize read()/write()/ioctl(). -- * Removed global kernel lock usage. -- * 1.07 07 Sep 2000, Tigran Aivazian -- * Write 0 to 0x8B msr and then cpuid before reading revision, -- * so that it works even if there were no update done by the -- * BIOS. Otherwise, reading from 0x8B gives junk (which happened -- * to be 0 on my machine which is why it worked even when I -- * disabled update by the BIOS) -- * Thanks to Eric W. Biederman for the fix. -- * 1.08 11 Dec 2000, Richard Schaal and -- * Tigran Aivazian -- * Intel Pentium 4 processor support and bugfixes. -- * 1.09 30 Oct 2001, Tigran Aivazian -- * Bugfix for HT (Hyper-Threading) enabled processors -- * whereby processor resources are shared by all logical processors -- * in a single CPU package. -- * 1.10 28 Feb 2002 Asit K Mallick and -- * Tigran Aivazian , -- * Serialize updates as required on HT processors due to speculative -- * nature of implementation. -- * 1.11 22 Mar 2002 Tigran Aivazian -- * Fix the panic when writing zero-length microcode chunk. -- * 1.12 29 Sep 2003 Nitin Kamble , -- * Jun Nakajima -- * Support for the microcode updates in the new format. -- * 1.13 10 Oct 2003 Tigran Aivazian -- * Removed ->read() method and obsoleted MICROCODE_IOCFREE ioctl -- * because we no longer hold a copy of applied microcode -- * in kernel memory. -- * 1.14 25 Jun 2004 Tigran Aivazian -- * Fix sigmatch() macro to handle old CPUs with pf == 0. -- * Thanks to Stuart Swales for pointing out this bug. -+ * 1.0 16 Feb 2000, Tigran Aivazian -+ * Initial release. -+ * 1.01 18 Feb 2000, Tigran Aivazian -+ * Added read() support + cleanups. -+ * 1.02 21 Feb 2000, Tigran Aivazian -+ * Added 'device trimming' support. open(O_WRONLY) zeroes -+ * and frees the saved copy of applied microcode. -+ * 1.03 29 Feb 2000, Tigran Aivazian -+ * Made to use devfs (/dev/cpu/microcode) + cleanups. -+ * 1.04 06 Jun 2000, Simon Trimmer -+ * Added misc device support (now uses both devfs and misc). -+ * Added MICROCODE_IOCFREE ioctl to clear memory. -+ * 1.05 09 Jun 2000, Simon Trimmer -+ * Messages for error cases (non Intel & no suitable microcode). -+ * 1.06 03 Aug 2000, Tigran Aivazian -+ * Removed ->release(). Removed exclusive open and status bitmap. -+ * Added microcode_rwsem to serialize read()/write()/ioctl(). -+ * Removed global kernel lock usage. -+ * 1.07 07 Sep 2000, Tigran Aivazian -+ * Write 0 to 0x8B msr and then cpuid before reading revision, -+ * so that it works even if there were no update done by the -+ * BIOS. Otherwise, reading from 0x8B gives junk (which happened -+ * to be 0 on my machine which is why it worked even when I -+ * disabled update by the BIOS) -+ * Thanks to Eric W. Biederman for the fix. -+ * 1.08 11 Dec 2000, Richard Schaal and -+ * Tigran Aivazian -+ * Intel Pentium 4 processor support and bugfixes. -+ * 1.09 30 Oct 2001, Tigran Aivazian -+ * Bugfix for HT (Hyper-Threading) enabled processors -+ * whereby processor resources are shared by all logical processors -+ * in a single CPU package. -+ * 1.10 28 Feb 2002 Asit K Mallick and -+ * Tigran Aivazian , -+ * Serialize updates as required on HT processors due to -+ * speculative nature of implementation. -+ * 1.11 22 Mar 2002 Tigran Aivazian -+ * Fix the panic when writing zero-length microcode chunk. -+ * 1.12 29 Sep 2003 Nitin Kamble , -+ * Jun Nakajima -+ * Support for the microcode updates in the new format. -+ * 1.13 10 Oct 2003 Tigran Aivazian -+ * Removed ->read() method and obsoleted MICROCODE_IOCFREE ioctl -+ * because we no longer hold a copy of applied microcode -+ * in kernel memory. -+ * 1.14 25 Jun 2004 Tigran Aivazian -+ * Fix sigmatch() macro to handle old CPUs with pf == 0. -+ * Thanks to Stuart Swales for pointing out this bug. - */ - - #include -@@ -76,381 +77,144 @@ - #include - #include - #include -+#include - - #include - #include - #include - #include -- --#define pr_debug(x...) ((void)0) --#define DEFINE_MUTEX(_m) DEFINE_SPINLOCK(_m) --#define mutex_lock(_m) spin_lock(_m) --#define mutex_unlock(_m) spin_unlock(_m) --#define vmalloc(_s) xmalloc_bytes(_s) --#define vfree(_p) xfree(_p) -- --#if 0 --MODULE_DESCRIPTION("Intel CPU (IA-32) Microcode Update Driver"); --MODULE_AUTHOR("Tigran Aivazian "); --MODULE_LICENSE("GPL"); --#endif -+#include - - static int verbose; - boolean_param("microcode.verbose", verbose); - --#define MICROCODE_VERSION "1.14a" -+const struct microcode_ops *microcode_ops; - --#define DEFAULT_UCODE_DATASIZE (2000) /* 2000 bytes */ --#define MC_HEADER_SIZE (sizeof (microcode_header_t)) /* 48 bytes */ --#define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE) /* 2048 bytes */ --#define EXT_HEADER_SIZE (sizeof (struct extended_sigtable)) /* 20 bytes */ --#define EXT_SIGNATURE_SIZE (sizeof (struct extended_signature)) /* 12 bytes */ --#define DWSIZE (sizeof (u32)) --#define get_totalsize(mc) \ -- (((microcode_t *)mc)->hdr.totalsize ? \ -- ((microcode_t *)mc)->hdr.totalsize : DEFAULT_UCODE_TOTALSIZE) --#define get_datasize(mc) \ -- (((microcode_t *)mc)->hdr.datasize ? \ -- ((microcode_t *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE) -- --#define sigmatch(s1, s2, p1, p2) \ -- (((s1) == (s2)) && (((p1) & (p2)) || (((p1) == 0) && ((p2) == 0)))) -- --#define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE) -- --/* serialize access to the physical write to MSR 0x79 */ --static DEFINE_SPINLOCK(microcode_update_lock); -- --/* no concurrent ->write()s are allowed on /dev/cpu/microcode */ --static DEFINE_MUTEX(microcode_mutex); -- --static const void __user *user_buffer; /* user area microcode data buffer */ --static unsigned int user_buffer_size; /* it's size */ -- --typedef enum mc_error_code { -- MC_SUCCESS = 0, -- MC_IGNORED = 1, -- MC_NOTFOUND = 2, -- MC_MARKED = 3, -- MC_ALLOCATED = 4, --} mc_error_code_t; -- --static struct ucode_cpu_info { -- unsigned int sig; -- unsigned int pf, orig_pf; -- unsigned int rev; -- unsigned int cksum; -- mc_error_code_t err; -- microcode_t *mc; --} ucode_cpu_info[NR_CPUS]; -- --static void collect_cpu_info (void *unused) --{ -- int cpu_num = smp_processor_id(); -- struct cpuinfo_x86 *c = cpu_data + cpu_num; -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -- unsigned int val[2]; -- -- uci->sig = uci->pf = uci->rev = uci->cksum = 0; -- uci->err = MC_NOTFOUND; -- uci->mc = NULL; -- -- if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 || -- cpu_has(c, X86_FEATURE_IA64)) { -- printk(KERN_ERR "microcode: CPU%d not a capable Intel processor\n", cpu_num); -- return; -- } else { -- uci->sig = cpuid_eax(0x00000001); -+static DEFINE_SPINLOCK(microcode_mutex); - -- if ((c->x86_model >= 5) || (c->x86 > 6)) { -- /* get processor flags from MSR 0x17 */ -- rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]); -- uci->pf = 1 << ((val[1] >> 18) & 7); -- } -- uci->orig_pf = uci->pf; -- } -+struct ucode_cpu_info ucode_cpu_info[NR_CPUS]; -+ -+struct microcode_buffer { -+ void *buf; -+ size_t size; -+}; -+ -+static struct microcode_buffer microcode_buffer; -+static bool_t microcode_error; - -- wrmsr(MSR_IA32_UCODE_REV, 0, 0); -- /* see notes above for revision 1.07. Apparent chip bug */ -- sync_core(); -- /* get the current revision from MSR 0x8B */ -- rdmsr(MSR_IA32_UCODE_REV, val[0], uci->rev); -- pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n", -- uci->sig, uci->pf, uci->rev); -+static void microcode_fini_cpu(int cpu) -+{ -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ -+ spin_lock(µcode_mutex); -+ microcode_ops->microcode_fini_cpu(cpu); -+ uci->valid = 0; -+ spin_unlock(µcode_mutex); - } - --static inline void mark_microcode_update (int cpu_num, microcode_header_t *mc_header, int sig, int pf, int cksum) -+static int collect_cpu_info(int cpu) - { -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -+ int err = 0; -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - -- pr_debug("Microcode Found.\n"); -- pr_debug(" Header Revision 0x%x\n", mc_header->hdrver); -- pr_debug(" Loader Revision 0x%x\n", mc_header->ldrver); -- pr_debug(" Revision 0x%x \n", mc_header->rev); -- pr_debug(" Date %x/%x/%x\n", -- ((mc_header->date >> 24 ) & 0xff), -- ((mc_header->date >> 16 ) & 0xff), -- (mc_header->date & 0xFFFF)); -- pr_debug(" Signature 0x%x\n", sig); -- pr_debug(" Type 0x%x Family 0x%x Model 0x%x Stepping 0x%x\n", -- ((sig >> 12) & 0x3), -- ((sig >> 8) & 0xf), -- ((sig >> 4) & 0xf), -- ((sig & 0xf))); -- pr_debug(" Processor Flags 0x%x\n", pf); -- pr_debug(" Checksum 0x%x\n", cksum); -- -- if (mc_header->rev < uci->rev) { -- if (uci->err == MC_NOTFOUND) { -- uci->err = MC_IGNORED; -- uci->cksum = mc_header->rev; -- } else if (uci->err == MC_IGNORED && uci->cksum < mc_header->rev) -- uci->cksum = mc_header->rev; -- } else if (mc_header->rev == uci->rev) { -- if (uci->err < MC_MARKED) { -- /* notify the caller of success on this cpu */ -- uci->err = MC_SUCCESS; -- } -- } else if (uci->err != MC_ALLOCATED || mc_header->rev > uci->mc->hdr.rev) { -- pr_debug("microcode: CPU%d found a matching microcode update with " -- " revision 0x%x (current=0x%x)\n", cpu_num, mc_header->rev, uci->rev); -- uci->cksum = cksum; -- uci->pf = pf; /* keep the original mc pf for cksum calculation */ -- uci->err = MC_MARKED; /* found the match */ -- for_each_online_cpu(cpu_num) { -- if (ucode_cpu_info + cpu_num != uci -- && ucode_cpu_info[cpu_num].mc == uci->mc) { -- uci->mc = NULL; -- break; -- } -- } -- if (uci->mc != NULL) { -- vfree(uci->mc); -- uci->mc = NULL; -- } -- } -- return; -+ memset(uci, 0, sizeof(*uci)); -+ err = microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); -+ if (!err) -+ uci->valid = 1; -+ -+ return err; - } - --static int find_matching_ucodes (void) -+static int microcode_resume_cpu(int cpu) - { -- int cursor = 0; -- int error = 0; -+ int err = 0; -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ struct cpu_signature nsig; -+ -+ gdprintk(XENLOG_INFO, "microcode: CPU%d resumed\n", cpu); -+ -+ if (!uci->mc.valid_mc) -+ return -EIO; -+ -+ /* -+ * Let's verify that the 'cached' ucode does belong -+ * to this cpu (a bit of paranoia): -+ */ -+ err = microcode_ops->collect_cpu_info(cpu, &nsig); -+ if (err) { -+ microcode_fini_cpu(cpu); -+ return err; -+ } - -- while (cursor + MC_HEADER_SIZE < user_buffer_size) { -- microcode_header_t mc_header; -- void *newmc = NULL; -- int i, sum, cpu_num, allocated_flag, total_size, data_size, ext_table_size; -- -- if (copy_from_user(&mc_header, user_buffer + cursor, MC_HEADER_SIZE)) { -- printk(KERN_ERR "microcode: error! Can not read user data\n"); -- error = -EFAULT; -- goto out; -- } -+ if (memcmp(&nsig, &uci->cpu_sig, sizeof(nsig))) { -+ microcode_fini_cpu(cpu); -+ /* Should we look for a new ucode here? */ -+ return -EIO; -+ } - -- total_size = get_totalsize(&mc_header); -- if (cursor + total_size > user_buffer_size) { -- printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); -- error = -EINVAL; -- goto out; -- } -+ err = microcode_ops->apply_microcode(cpu); - -- data_size = get_datasize(&mc_header); -- if (data_size + MC_HEADER_SIZE > total_size) { -- printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); -- error = -EINVAL; -- goto out; -- } -+ return err; -+} - -- if (mc_header.ldrver != 1 || mc_header.hdrver != 1) { -- printk(KERN_ERR "microcode: error! Unknown microcode update format\n"); -- error = -EINVAL; -- goto out; -- } -+static int microcode_update_cpu(int cpu, const void *buf, size_t size) -+{ -+ int err = 0; -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - -- for_each_online_cpu(cpu_num) { -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -+ /* We should bind the task to the CPU */ -+ BUG_ON(raw_smp_processor_id() != cpu); - -- if (sigmatch(mc_header.sig, uci->sig, mc_header.pf, uci->orig_pf)) -- mark_microcode_update(cpu_num, &mc_header, mc_header.sig, mc_header.pf, mc_header.cksum); -+ spin_lock(µcode_mutex); -+ /* -+ * Check if the system resume is in progress (uci->valid != NULL), -+ * otherwise just request a firmware: -+ */ -+ if (uci->valid) { -+ err = microcode_resume_cpu(cpu); -+ } else { -+ err = collect_cpu_info(cpu); -+ if (err) -+ goto out; -+ if (uci->valid) { -+ err = microcode_ops->cpu_request_microcode(cpu, buf, size); - } -+ } - -- ext_table_size = total_size - (MC_HEADER_SIZE + data_size); -- if (ext_table_size) { -- struct extended_sigtable ext_header; -- struct extended_signature ext_sig; -- int ext_sigcount; -- -- if ((ext_table_size < EXT_HEADER_SIZE) -- || ((ext_table_size - EXT_HEADER_SIZE) % EXT_SIGNATURE_SIZE)) { -- printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); -- error = -EINVAL; -- goto out; -- } -- if (copy_from_user(&ext_header, user_buffer + cursor -- + MC_HEADER_SIZE + data_size, EXT_HEADER_SIZE)) { -- printk(KERN_ERR "microcode: error! Can not read user data\n"); -- error = -EFAULT; -- goto out; -- } -- if (ext_table_size != exttable_size(&ext_header)) { -- printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); -- error = -EFAULT; -- goto out; -- } -- -- ext_sigcount = ext_header.count; -- -- for (i = 0; i < ext_sigcount; i++) { -- if (copy_from_user(&ext_sig, user_buffer + cursor + MC_HEADER_SIZE + data_size + EXT_HEADER_SIZE -- + EXT_SIGNATURE_SIZE * i, EXT_SIGNATURE_SIZE)) { -- printk(KERN_ERR "microcode: error! Can not read user data\n"); -- error = -EFAULT; -- goto out; -- } -- for_each_online_cpu(cpu_num) { -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -- -- if (sigmatch(ext_sig.sig, uci->sig, ext_sig.pf, uci->orig_pf)) { -- mark_microcode_update(cpu_num, &mc_header, ext_sig.sig, ext_sig.pf, ext_sig.cksum); -- } -- } -- } -- } -- /* now check if any cpu has matched */ -- allocated_flag = 0; -- sum = 0; -- for_each_online_cpu(cpu_num) { -- if (ucode_cpu_info[cpu_num].err == MC_MARKED) { -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -- if (!allocated_flag) { -- allocated_flag = 1; -- newmc = vmalloc(total_size); -- if (!newmc) { -- printk(KERN_ERR "microcode: error! Can not allocate memory\n"); -- error = -ENOMEM; -- goto out; -- } -- if (copy_from_user(newmc + MC_HEADER_SIZE, -- user_buffer + cursor + MC_HEADER_SIZE, -- total_size - MC_HEADER_SIZE)) { -- printk(KERN_ERR "microcode: error! Can not read user data\n"); -- vfree(newmc); -- error = -EFAULT; -- goto out; -- } -- memcpy(newmc, &mc_header, MC_HEADER_SIZE); -- /* check extended table checksum */ -- if (ext_table_size) { -- int ext_table_sum = 0; -- int * ext_tablep = (((void *) newmc) + MC_HEADER_SIZE + data_size); -- i = ext_table_size / DWSIZE; -- while (i--) ext_table_sum += ext_tablep[i]; -- if (ext_table_sum) { -- printk(KERN_WARNING "microcode: aborting, bad extended signature table checksum\n"); -- vfree(newmc); -- error = -EINVAL; -- goto out; -- } -- } -- -- /* calculate the checksum */ -- i = (MC_HEADER_SIZE + data_size) / DWSIZE; -- while (i--) sum += ((int *)newmc)[i]; -- sum -= (mc_header.sig + mc_header.pf + mc_header.cksum); -- } -- ucode_cpu_info[cpu_num].mc = newmc; -- ucode_cpu_info[cpu_num].err = MC_ALLOCATED; /* mc updated */ -- if (sum + uci->sig + uci->pf + uci->cksum != 0) { -- printk(KERN_ERR "microcode: CPU%d aborting, bad checksum\n", cpu_num); -- error = -EINVAL; -- goto out; -- } -- } -- } -- cursor += total_size; /* goto the next update patch */ -- } /* end of while */ - out: -- return error; -+ spin_unlock(µcode_mutex); -+ -+ return err; - } - --static void do_update_one (void * unused) -+static void do_microcode_update_one(void *info) - { -- unsigned long flags; -- unsigned int val[2]; -- int cpu_num = smp_processor_id(); -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -- -- if (uci->mc == NULL) { -- if (verbose) { -- if (uci->err == MC_SUCCESS) -- printk(KERN_INFO "microcode: CPU%d already at revision 0x%x\n", -- cpu_num, uci->rev); -- else -- printk(KERN_INFO "microcode: No new microcode data for CPU%d\n", cpu_num); -- } -- return; -- } -+ int error = 0; - -- /* serialize access to the physical write to MSR 0x79 */ -- spin_lock_irqsave(µcode_update_lock, flags); -+ error = microcode_update_cpu(smp_processor_id(), -+ microcode_buffer.buf, microcode_buffer.size); - -- /* write microcode via MSR 0x79 */ -- wrmsr(MSR_IA32_UCODE_WRITE, -- (unsigned long) uci->mc->bits, -- (unsigned long) uci->mc->bits >> 16 >> 16); -- wrmsr(MSR_IA32_UCODE_REV, 0, 0); -- -- /* see notes above for revision 1.07. Apparent chip bug */ -- sync_core(); -- -- /* get the current revision from MSR 0x8B */ -- rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]); -- -- /* notify the caller of success on this cpu */ -- uci->err = MC_SUCCESS; -- spin_unlock_irqrestore(µcode_update_lock, flags); -- printk(KERN_INFO "microcode: CPU%d updated from revision " -- "0x%x to 0x%x, date = %08x \n", -- cpu_num, uci->rev, val[1], uci->mc->hdr.date); -- return; -+ if (error) -+ microcode_error = error; - } - --static int do_microcode_update (void) -+static int do_microcode_update(void) - { -- int i, error; -+ int error = 0; -+ -+ microcode_error = 0; - -- if (on_each_cpu(collect_cpu_info, NULL, 1, 1) != 0) { -+ if (on_each_cpu(do_microcode_update_one, NULL, 1, 1) != 0) { - printk(KERN_ERR "microcode: Error! Could not run on all processors\n"); - error = -EIO; - goto out; - } - -- if ((error = find_matching_ucodes())) { -- printk(KERN_ERR "microcode: Error in the microcode data\n"); -- goto out_free; -- } -- -- if (on_each_cpu(do_update_one, NULL, 1, 1) != 0) { -- printk(KERN_ERR "microcode: Error! Could not run on all processors\n"); -- error = -EIO; -+ if (microcode_error) { -+ error = microcode_error; -+ goto out; - } - --out_free: -- for_each_online_cpu(i) { -- if (ucode_cpu_info[i].mc) { -- int j; -- void *tmp = ucode_cpu_info[i].mc; -- vfree(tmp); -- for_each_online_cpu(j) { -- if (ucode_cpu_info[j].mc == tmp) -- ucode_cpu_info[j].mc = NULL; -- } -- } -- if (ucode_cpu_info[i].err == MC_IGNORED && verbose) -- printk(KERN_WARNING "microcode: CPU%d not 'upgrading' to earlier revision" -- " 0x%x (current=0x%x)\n", i, ucode_cpu_info[i].cksum, ucode_cpu_info[i].rev); -- } - out: - return error; - } -@@ -458,20 +222,46 @@ out: - int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len) - { - int ret; -+ struct cpuinfo_x86 *c = &boot_cpu_data; - -- if (len != (typeof(user_buffer_size))len) { -+ if (len != (typeof(microcode_buffer.size))len) { - printk(KERN_ERR "microcode: too much data\n"); - return -E2BIG; - } - -- mutex_lock(µcode_mutex); -+ switch (c->x86_vendor) { -+ case X86_VENDOR_AMD: -+ ret = microcode_init_amd(c); -+ break; -+ -+ case X86_VENDOR_INTEL: -+ ret = microcode_init_intel(c); -+ break; -+ default: -+ printk(KERN_ERR "microcode: CPU vendor not supported\n"); -+ ret = -EINVAL; -+ break; -+ } -+ -+ if (ret != 0) -+ return ret; -+ -+ microcode_buffer.buf = xmalloc_array(uint8_t, len); -+ if (!microcode_buffer.buf) -+ return -ENOMEM; -+ -+ ret = copy_from_guest(microcode_buffer.buf, buf, len); -+ if (ret != 0) -+ return ret; - -- user_buffer = buf.p; -- user_buffer_size = len; -+ microcode_buffer.size = len; -+ wmb(); - - ret = do_microcode_update(); - -- mutex_unlock(µcode_mutex); -+ xfree(microcode_buffer.buf); -+ microcode_buffer.buf = NULL; -+ microcode_buffer.size = 0; - - return ret; - } -Index: xen-3.3.1-testing/xen/include/asm-x86/msr-index.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/msr-index.h -+++ xen-3.3.1-testing/xen/include/asm-x86/msr-index.h -@@ -211,6 +211,10 @@ - #define FAM10H_MMIO_CONF_BASE_MASK 0xfffffff - #define FAM10H_MMIO_CONF_BASE_SHIFT 20 - -+/* AMD Microcode MSRs */ -+#define MSR_AMD_PATCHLEVEL 0x0000008b -+#define MSR_AMD_PATCHLOADER 0xc0010020 -+ - /* K6 MSRs */ - #define MSR_K6_EFER 0xc0000080 - #define MSR_K6_STAR 0xc0000081 -Index: xen-3.3.1-testing/xen/include/asm-x86/processor.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/processor.h -+++ xen-3.3.1-testing/xen/include/asm-x86/processor.h -@@ -486,41 +486,6 @@ long set_gdt(struct vcpu *d, - }) - long set_debugreg(struct vcpu *p, int reg, unsigned long value); - --struct microcode_header { -- unsigned int hdrver; -- unsigned int rev; -- unsigned int date; -- unsigned int sig; -- unsigned int cksum; -- unsigned int ldrver; -- unsigned int pf; -- unsigned int datasize; -- unsigned int totalsize; -- unsigned int reserved[3]; --}; -- --struct microcode { -- struct microcode_header hdr; -- unsigned int bits[0]; --}; -- --typedef struct microcode microcode_t; --typedef struct microcode_header microcode_header_t; -- --/* microcode format is extended from prescott processors */ --struct extended_signature { -- unsigned int sig; -- unsigned int pf; -- unsigned int cksum; --}; -- --struct extended_sigtable { -- unsigned int count; -- unsigned int cksum; -- unsigned int reserved[3]; -- struct extended_signature sigs[0]; --}; -- - /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */ - static always_inline void rep_nop(void) - { -Index: xen-3.3.1-testing/xen/arch/x86/microcode_amd.c -=================================================================== ---- /dev/null -+++ xen-3.3.1-testing/xen/arch/x86/microcode_amd.c -@@ -0,0 +1,366 @@ -+/* -+ * AMD CPU Microcode Update Driver for Linux -+ * Copyright (C) 2008 Advanced Micro Devices Inc. -+ * -+ * Author: Peter Oruba -+ * -+ * Based on work by: -+ * Tigran Aivazian -+ * -+ * This driver allows to upgrade microcode on AMD -+ * family 0x10 and 0x11 processors. -+ * -+ * Licensed unter the terms of the GNU General Public -+ * License version 2. See file COPYING for details. -+*/ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+ -+ -+#define pr_debug(x...) ((void)0) -+#define DEFINE_MUTEX(_m) DEFINE_SPINLOCK(_m) -+#define mutex_lock(_m) spin_lock(_m) -+#define mutex_unlock(_m) spin_unlock(_m) -+#define vmalloc(_s) xmalloc_bytes(_s) -+#define vfree(_p) xfree(_p) -+ -+ -+#define UCODE_MAGIC 0x00414d44 -+#define UCODE_EQUIV_CPU_TABLE_TYPE 0x00000000 -+#define UCODE_UCODE_TYPE 0x00000001 -+ -+#define UCODE_MAX_SIZE (2048) -+#define DEFAULT_UCODE_DATASIZE (896) -+#define MC_HEADER_SIZE (sizeof(struct microcode_header_amd)) -+#define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE) -+#define DWSIZE (sizeof(uint32_t)) -+/* For now we support a fixed ucode total size only */ -+#define get_totalsize(mc) \ -+ ((((struct microcode_amd *)mc)->hdr.mc_patch_data_len * 28) \ -+ + MC_HEADER_SIZE) -+ -+/* serialize access to the physical write */ -+static DEFINE_SPINLOCK(microcode_update_lock); -+ -+struct equiv_cpu_entry *equiv_cpu_table; -+ -+static long install_equiv_cpu_table(const void *, uint32_t, long); -+ -+static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig) -+{ -+ struct cpuinfo_x86 *c = &cpu_data[cpu]; -+ -+ memset(csig, 0, sizeof(*csig)); -+ -+ if (c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) { -+ printk(KERN_ERR "microcode: CPU%d not a capable AMD processor\n", -+ cpu); -+ return -1; -+ } -+ -+ asm volatile("movl %1, %%ecx; rdmsr" -+ : "=a" (csig->rev) -+ : "i" (MSR_AMD_PATCHLEVEL) : "ecx"); -+ -+ printk(KERN_INFO "microcode: collect_cpu_info_amd : patch_id=0x%x\n", -+ csig->rev); -+ -+ return 0; -+} -+ -+static int get_matching_microcode_amd(void *mc, int cpu) -+{ -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ struct microcode_header_amd *mc_header = mc; -+ unsigned long total_size = get_totalsize(mc_header); -+ void *new_mc; -+ unsigned int current_cpu_id; -+ unsigned int equiv_cpu_id = 0x00; -+ unsigned int i = 0; -+ -+ /* We should bind the task to the CPU */ -+ BUG_ON(cpu != raw_smp_processor_id()); -+ -+ /* This is a tricky part. We might be called from a write operation -+ * to the device file instead of the usual process of firmware -+ * loading. This routine needs to be able to distinguish both -+ * cases. This is done by checking if there already is a equivalent -+ * CPU table installed. If not, we're written through -+ * /dev/cpu/microcode. -+ * Since we ignore all checks. The error case in which going through -+ * firmware loading and that table is not loaded has already been -+ * checked earlier. -+ */ -+ if (equiv_cpu_table == NULL) { -+ printk(KERN_INFO "microcode: CPU%d microcode update with " -+ "version 0x%x (current=0x%x)\n", -+ cpu, mc_header->patch_id, uci->cpu_sig.rev); -+ goto out; -+ } -+ -+ current_cpu_id = cpuid_eax(0x00000001); -+ -+ while (equiv_cpu_table[i].installed_cpu != 0) { -+ if (current_cpu_id == equiv_cpu_table[i].installed_cpu) { -+ equiv_cpu_id = equiv_cpu_table[i].equiv_cpu; -+ break; -+ } -+ i++; -+ } -+ -+ if (!equiv_cpu_id) { -+ printk(KERN_ERR "microcode: CPU%d cpu_id " -+ "not found in equivalent cpu table \n", cpu); -+ return 0; -+ } -+ -+ if ((mc_header->processor_rev_id[0]) != (equiv_cpu_id & 0xff)) { -+ printk(KERN_INFO -+ "microcode: CPU%d patch does not match " -+ "(patch is %x, cpu extended is %x) \n", -+ cpu, mc_header->processor_rev_id[0], -+ (equiv_cpu_id & 0xff)); -+ return 0; -+ } -+ -+ if ((mc_header->processor_rev_id[1]) != ((equiv_cpu_id >> 16) & 0xff)) { -+ printk(KERN_INFO "microcode: CPU%d patch does not match " -+ "(patch is %x, cpu base id is %x) \n", -+ cpu, mc_header->processor_rev_id[1], -+ ((equiv_cpu_id >> 16) & 0xff)); -+ -+ return 0; -+ } -+ -+ if (mc_header->patch_id <= uci->cpu_sig.rev) -+ return 0; -+ -+ printk(KERN_INFO "microcode: CPU%d found a matching microcode " -+ "update with version 0x%x (current=0x%x)\n", -+ cpu, mc_header->patch_id, uci->cpu_sig.rev); -+ -+out: -+ new_mc = vmalloc(UCODE_MAX_SIZE); -+ if (!new_mc) { -+ printk(KERN_ERR "microcode: error, can't allocate memory\n"); -+ return -ENOMEM; -+ } -+ memset(new_mc, 0, UCODE_MAX_SIZE); -+ -+ /* free previous update file */ -+ vfree(uci->mc.mc_amd); -+ -+ memcpy(new_mc, mc, total_size); -+ -+ uci->mc.mc_amd = new_mc; -+ return 1; -+} -+ -+static int apply_microcode_amd(int cpu) -+{ -+ unsigned long flags; -+ unsigned int eax, edx; -+ unsigned int rev; -+ int cpu_num = raw_smp_processor_id(); -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -+ unsigned long addr; -+ -+ /* We should bind the task to the CPU */ -+ BUG_ON(cpu_num != cpu); -+ -+ if (uci->mc.mc_amd == NULL) -+ return -EINVAL; -+ -+ spin_lock_irqsave(µcode_update_lock, flags); -+ -+ addr = (unsigned long)&uci->mc.mc_amd->hdr.data_code; -+ edx = (unsigned int)((unsigned long)(addr >> 32)); -+ eax = (unsigned int)((unsigned long)(addr & 0xffffffff)); -+ -+ asm volatile("movl %0, %%ecx; wrmsr" : -+ : "i" (MSR_AMD_PATCHLOADER), "a" (eax), "d" (edx) : "ecx"); -+ -+ /* get patch id after patching */ -+ asm volatile("movl %1, %%ecx; rdmsr" -+ : "=a" (rev) -+ : "i" (MSR_AMD_PATCHLEVEL) : "ecx"); -+ -+ spin_unlock_irqrestore(µcode_update_lock, flags); -+ -+ /* check current patch id and patch's id for match */ -+ if (rev != uci->mc.mc_amd->hdr.patch_id) { -+ printk(KERN_ERR "microcode: CPU%d update from revision " -+ "0x%x to 0x%x failed\n", cpu_num, -+ uci->mc.mc_amd->hdr.patch_id, rev); -+ return -EIO; -+ } -+ -+ printk("microcode: CPU%d updated from revision " -+ "0x%x to 0x%x \n", -+ cpu_num, uci->cpu_sig.rev, uci->mc.mc_amd->hdr.patch_id); -+ -+ uci->cpu_sig.rev = rev; -+ -+ return 0; -+} -+ -+static long get_next_ucode_from_buffer_amd(void **mc, const void *buf, -+ unsigned long size, long offset) -+{ -+ struct microcode_header_amd *mc_header; -+ unsigned long total_size; -+ const uint8_t *buf_pos = buf; -+ -+ /* No more data */ -+ if (offset >= size) -+ return 0; -+ -+ if (buf_pos[offset] != UCODE_UCODE_TYPE) { -+ printk(KERN_ERR "microcode: error! " -+ "Wrong microcode payload type field\n"); -+ return -EINVAL; -+ } -+ -+ mc_header = (struct microcode_header_amd *)(&buf_pos[offset+8]); -+ -+ total_size = (unsigned long) (buf_pos[offset+4] + -+ (buf_pos[offset+5] << 8)); -+ -+ printk(KERN_INFO "microcode: size %lu, total_size %lu, offset %ld\n", -+ size, total_size, offset); -+ -+ if (offset + total_size > size) { -+ printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); -+ return -EINVAL; -+ } -+ -+ *mc = vmalloc(UCODE_MAX_SIZE); -+ if (!*mc) { -+ printk(KERN_ERR "microcode: error! " -+ "Can not allocate memory for microcode patch\n"); -+ return -ENOMEM; -+ } -+ -+ memset(*mc, 0, UCODE_MAX_SIZE); -+ memcpy(*mc, (const void *)(buf + offset + 8), total_size); -+ -+ return offset + total_size + 8; -+} -+ -+static long install_equiv_cpu_table(const void *buf, -+ uint32_t size, long offset) -+{ -+ const uint32_t *buf_pos = buf; -+ -+ /* No more data */ -+ if (offset >= size) -+ return 0; -+ -+ if (buf_pos[1] != UCODE_EQUIV_CPU_TABLE_TYPE) { -+ printk(KERN_ERR "microcode: error! " -+ "Wrong microcode equivalnet cpu table type field\n"); -+ return 0; -+ } -+ -+ if (size == 0) { -+ printk(KERN_ERR "microcode: error! " -+ "Wrong microcode equivalnet cpu table length\n"); -+ return 0; -+ } -+ -+ equiv_cpu_table = (struct equiv_cpu_entry *) vmalloc(size); -+ if (!equiv_cpu_table) { -+ printk(KERN_ERR "microcode: error, can't allocate memory for equiv CPU table\n"); -+ return 0; -+ } -+ -+ memset(equiv_cpu_table, 0, size); -+ memcpy(equiv_cpu_table, (const void *)&buf_pos[3], size); -+ -+ return size + 12; /* add header length */ -+} -+ -+static int cpu_request_microcode_amd(int cpu, const void *buf, -+ size_t size) -+{ -+ const uint32_t *buf_pos; -+ long offset = 0; -+ int error = 0; -+ void *mc; -+ -+ /* We should bind the task to the CPU */ -+ BUG_ON(cpu != raw_smp_processor_id()); -+ -+ buf_pos = (const uint32_t *)buf; -+ -+ if (buf_pos[0] != UCODE_MAGIC) { -+ printk(KERN_ERR "microcode: error! Wrong microcode patch file magic\n"); -+ return -EINVAL; -+ } -+ -+ offset = install_equiv_cpu_table(buf, (uint32_t)(buf_pos[2]), offset); -+ if (!offset) { -+ printk(KERN_ERR "microcode: installing equivalent cpu table failed\n"); -+ return -EINVAL; -+ } -+ -+ while ((offset = -+ get_next_ucode_from_buffer_amd(&mc, buf, size, offset)) > 0) { -+ error = get_matching_microcode_amd(mc, cpu); -+ if (error < 0) -+ break; -+ /* -+ * It's possible the data file has multiple matching ucode, -+ * lets keep searching till the latest version -+ */ -+ if (error == 1) { -+ apply_microcode_amd(cpu); -+ error = 0; -+ } -+ vfree(mc); -+ } -+ if (offset > 0) { -+ vfree(mc); -+ vfree(equiv_cpu_table); -+ equiv_cpu_table = NULL; -+ } -+ if (offset < 0) -+ error = offset; -+ -+ return error; -+} -+ -+static void microcode_fini_cpu_amd(int cpu) -+{ -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ -+ vfree(uci->mc.mc_amd); -+ uci->mc.mc_amd = NULL; -+} -+ -+static struct microcode_ops microcode_amd_ops = { -+ .get_matching_microcode = get_matching_microcode_amd, -+ .microcode_sanity_check = NULL, -+ .cpu_request_microcode = cpu_request_microcode_amd, -+ .collect_cpu_info = collect_cpu_info_amd, -+ .apply_microcode = apply_microcode_amd, -+ .microcode_fini_cpu = microcode_fini_cpu_amd, -+}; -+ -+int microcode_init_amd(struct cpuinfo_x86 *c) -+{ -+ microcode_ops = µcode_amd_ops; -+ return 0; -+} -+ -Index: xen-3.3.1-testing/xen/arch/x86/microcode_intel.c -=================================================================== ---- /dev/null -+++ xen-3.3.1-testing/xen/arch/x86/microcode_intel.c -@@ -0,0 +1,425 @@ -+/* -+ * Intel CPU Microcode Update Driver for Linux -+ * -+ * Copyright (C) 2000-2006 Tigran Aivazian -+ * 2006 Shaohua Li * -+ * This driver allows to upgrade microcode on Intel processors -+ * belonging to IA-32 family - PentiumPro, Pentium II, -+ * Pentium III, Xeon, Pentium 4, etc. -+ * -+ * Reference: Section 8.11 of Volume 3a, IA-32 Intel? Architecture -+ * Software Developer's Manual -+ * Order Number 253668 or free download from: -+ * -+ * http://developer.intel.com/design/pentium4/manuals/253668.htm -+ * -+ * For more information, go to http://www.urbanmyth.org/microcode -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version -+ * 2 of the License, or (at your option) any later version. -+ * -+ * 1.0 16 Feb 2000, Tigran Aivazian -+ * Initial release. -+ * 1.01 18 Feb 2000, Tigran Aivazian -+ * Added read() support + cleanups. -+ * 1.02 21 Feb 2000, Tigran Aivazian -+ * Added 'device trimming' support. open(O_WRONLY) zeroes -+ * and frees the saved copy of applied microcode. -+ * 1.03 29 Feb 2000, Tigran Aivazian -+ * Made to use devfs (/dev/cpu/microcode) + cleanups. -+ * 1.04 06 Jun 2000, Simon Trimmer -+ * Added misc device support (now uses both devfs and misc). -+ * Added MICROCODE_IOCFREE ioctl to clear memory. -+ * 1.05 09 Jun 2000, Simon Trimmer -+ * Messages for error cases (non Intel & no suitable microcode). -+ * 1.06 03 Aug 2000, Tigran Aivazian -+ * Removed ->release(). Removed exclusive open and status bitmap. -+ * Added microcode_rwsem to serialize read()/write()/ioctl(). -+ * Removed global kernel lock usage. -+ * 1.07 07 Sep 2000, Tigran Aivazian -+ * Write 0 to 0x8B msr and then cpuid before reading revision, -+ * so that it works even if there were no update done by the -+ * BIOS. Otherwise, reading from 0x8B gives junk (which happened -+ * to be 0 on my machine which is why it worked even when I -+ * disabled update by the BIOS) -+ * Thanks to Eric W. Biederman for the fix. -+ * 1.08 11 Dec 2000, Richard Schaal and -+ * Tigran Aivazian -+ * Intel Pentium 4 processor support and bugfixes. -+ * 1.09 30 Oct 2001, Tigran Aivazian -+ * Bugfix for HT (Hyper-Threading) enabled processors -+ * whereby processor resources are shared by all logical processors -+ * in a single CPU package. -+ * 1.10 28 Feb 2002 Asit K Mallick and -+ * Tigran Aivazian , -+ * Serialize updates as required on HT processors due to -+ * speculative nature of implementation. -+ * 1.11 22 Mar 2002 Tigran Aivazian -+ * Fix the panic when writing zero-length microcode chunk. -+ * 1.12 29 Sep 2003 Nitin Kamble , -+ * Jun Nakajima -+ * Support for the microcode updates in the new format. -+ * 1.13 10 Oct 2003 Tigran Aivazian -+ * Removed ->read() method and obsoleted MICROCODE_IOCFREE ioctl -+ * because we no longer hold a copy of applied microcode -+ * in kernel memory. -+ * 1.14 25 Jun 2004 Tigran Aivazian -+ * Fix sigmatch() macro to handle old CPUs with pf == 0. -+ * Thanks to Stuart Swales for pointing out this bug. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+ -+#define pr_debug(x...) ((void)0) -+#define DEFINE_MUTEX(_m) DEFINE_SPINLOCK(_m) -+#define mutex_lock(_m) spin_lock(_m) -+#define mutex_unlock(_m) spin_unlock(_m) -+#define vmalloc(_s) xmalloc_bytes(_s) -+#define vfree(_p) xfree(_p) -+ -+#if 0 -+MODULE_DESCRIPTION("Microcode Update Driver"); -+MODULE_AUTHOR("Tigran Aivazian "); -+MODULE_LICENSE("GPL"); -+#endif -+ -+#define DEFAULT_UCODE_DATASIZE (2000) -+#define MC_HEADER_SIZE (sizeof(struct microcode_header_intel)) -+#define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE) -+#define EXT_HEADER_SIZE (sizeof(struct extended_sigtable)) -+#define EXT_SIGNATURE_SIZE (sizeof(struct extended_signature)) -+#define DWSIZE (sizeof(u32)) -+#define get_totalsize(mc) \ -+ (((struct microcode_intel *)mc)->hdr.totalsize ? \ -+ ((struct microcode_intel *)mc)->hdr.totalsize : \ -+ DEFAULT_UCODE_TOTALSIZE) -+ -+#define get_datasize(mc) \ -+ (((struct microcode_intel *)mc)->hdr.datasize ? \ -+ ((struct microcode_intel *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE) -+ -+#define sigmatch(s1, s2, p1, p2) \ -+ (((s1) == (s2)) && (((p1) & (p2)) || (((p1) == 0) && ((p2) == 0)))) -+ -+#define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE) -+ -+/* serialize access to the physical write to MSR 0x79 */ -+static DEFINE_SPINLOCK(microcode_update_lock); -+ -+static int collect_cpu_info(int cpu_num, struct cpu_signature *csig) -+{ -+ struct cpuinfo_x86 *c = &cpu_data[cpu_num]; -+ unsigned int val[2]; -+ -+ memset(csig, 0, sizeof(*csig)); -+ -+ if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 || -+ cpu_has(c, X86_FEATURE_IA64)) { -+ printk(KERN_ERR "microcode: CPU%d not a capable Intel " -+ "processor\n", cpu_num); -+ return -1; -+ } -+ -+ csig->sig = cpuid_eax(0x00000001); -+ -+ if ((c->x86_model >= 5) || (c->x86 > 6)) { -+ /* get processor flags from MSR 0x17 */ -+ rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]); -+ csig->pf = 1 << ((val[1] >> 18) & 7); -+ } -+ -+ wrmsr(MSR_IA32_UCODE_REV, 0, 0); -+ /* see notes above for revision 1.07. Apparent chip bug */ -+ sync_core(); -+ /* get the current revision from MSR 0x8B */ -+ rdmsr(MSR_IA32_UCODE_REV, val[0], csig->rev); -+ pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n", -+ csig->sig, csig->pf, csig->rev); -+ -+ return 0; -+} -+ -+static inline int microcode_update_match(int cpu_num, -+ struct microcode_header_intel *mc_header, int sig, int pf) -+{ -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -+ -+ if (!sigmatch(sig, uci->cpu_sig.sig, pf, uci->cpu_sig.pf) -+ || mc_header->rev <= uci->cpu_sig.rev) -+ return 0; -+ return 1; -+} -+ -+static int microcode_sanity_check(void *mc) -+{ -+ struct microcode_header_intel *mc_header = mc; -+ struct extended_sigtable *ext_header = NULL; -+ struct extended_signature *ext_sig; -+ unsigned long total_size, data_size, ext_table_size; -+ int sum, orig_sum, ext_sigcount = 0, i; -+ -+ total_size = get_totalsize(mc_header); -+ data_size = get_datasize(mc_header); -+ if (data_size + MC_HEADER_SIZE > total_size) { -+ printk(KERN_ERR "microcode: error! " -+ "Bad data size in microcode data file\n"); -+ return -EINVAL; -+ } -+ -+ if (mc_header->ldrver != 1 || mc_header->hdrver != 1) { -+ printk(KERN_ERR "microcode: error! " -+ "Unknown microcode update format\n"); -+ return -EINVAL; -+ } -+ ext_table_size = total_size - (MC_HEADER_SIZE + data_size); -+ if (ext_table_size) { -+ if ((ext_table_size < EXT_HEADER_SIZE) -+ || ((ext_table_size - EXT_HEADER_SIZE) % EXT_SIGNATURE_SIZE)) { -+ printk(KERN_ERR "microcode: error! " -+ "Small exttable size in microcode data file\n"); -+ return -EINVAL; -+ } -+ ext_header = mc + MC_HEADER_SIZE + data_size; -+ if (ext_table_size != exttable_size(ext_header)) { -+ printk(KERN_ERR "microcode: error! " -+ "Bad exttable size in microcode data file\n"); -+ return -EFAULT; -+ } -+ ext_sigcount = ext_header->count; -+ } -+ -+ /* check extended table checksum */ -+ if (ext_table_size) { -+ int ext_table_sum = 0; -+ int *ext_tablep = (int *)ext_header; -+ -+ i = ext_table_size / DWSIZE; -+ while (i--) -+ ext_table_sum += ext_tablep[i]; -+ if (ext_table_sum) { -+ printk(KERN_WARNING "microcode: aborting, " -+ "bad extended signature table checksum\n"); -+ return -EINVAL; -+ } -+ } -+ -+ /* calculate the checksum */ -+ orig_sum = 0; -+ i = (MC_HEADER_SIZE + data_size) / DWSIZE; -+ while (i--) -+ orig_sum += ((int *)mc)[i]; -+ if (orig_sum) { -+ printk(KERN_ERR "microcode: aborting, bad checksum\n"); -+ return -EINVAL; -+ } -+ if (!ext_table_size) -+ return 0; -+ /* check extended signature checksum */ -+ for (i = 0; i < ext_sigcount; i++) { -+ ext_sig = (void *)ext_header + EXT_HEADER_SIZE + -+ EXT_SIGNATURE_SIZE * i; -+ sum = orig_sum -+ - (mc_header->sig + mc_header->pf + mc_header->cksum) -+ + (ext_sig->sig + ext_sig->pf + ext_sig->cksum); -+ if (sum) { -+ printk(KERN_ERR "microcode: aborting, bad checksum\n"); -+ return -EINVAL; -+ } -+ } -+ return 0; -+} -+ -+/* -+ * return 0 - no update found -+ * return 1 - found update -+ * return < 0 - error -+ */ -+static int get_matching_microcode(void *mc, int cpu) -+{ -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ struct microcode_header_intel *mc_header = mc; -+ struct extended_sigtable *ext_header; -+ unsigned long total_size = get_totalsize(mc_header); -+ int ext_sigcount, i; -+ struct extended_signature *ext_sig; -+ void *new_mc; -+ -+ if (microcode_update_match(cpu, mc_header, -+ mc_header->sig, mc_header->pf)) -+ goto find; -+ -+ if (total_size <= get_datasize(mc_header) + MC_HEADER_SIZE) -+ return 0; -+ -+ ext_header = mc + get_datasize(mc_header) + MC_HEADER_SIZE; -+ ext_sigcount = ext_header->count; -+ ext_sig = (void *)ext_header + EXT_HEADER_SIZE; -+ for (i = 0; i < ext_sigcount; i++) { -+ if (microcode_update_match(cpu, mc_header, -+ ext_sig->sig, ext_sig->pf)) -+ goto find; -+ ext_sig++; -+ } -+ return 0; -+find: -+ pr_debug("microcode: CPU%d found a matching microcode update with" -+ " version 0x%x (current=0x%x)\n", -+ cpu, mc_header->rev, uci->cpu_sig.rev); -+ new_mc = vmalloc(total_size); -+ if (!new_mc) { -+ printk(KERN_ERR "microcode: error! Can not allocate memory\n"); -+ return -ENOMEM; -+ } -+ -+ /* free previous update file */ -+ vfree(uci->mc.mc_intel); -+ -+ memcpy(new_mc, mc, total_size); -+ uci->mc.mc_intel = new_mc; -+ return 1; -+} -+ -+static int apply_microcode(int cpu) -+{ -+ unsigned long flags; -+ unsigned int val[2]; -+ int cpu_num = raw_smp_processor_id(); -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -+ -+ /* We should bind the task to the CPU */ -+ BUG_ON(cpu_num != cpu); -+ -+ if (uci->mc.mc_intel == NULL) -+ return -EINVAL; -+ -+ /* serialize access to the physical write to MSR 0x79 */ -+ spin_lock_irqsave(µcode_update_lock, flags); -+ -+ /* write microcode via MSR 0x79 */ -+ wrmsr(MSR_IA32_UCODE_WRITE, -+ (unsigned long) uci->mc.mc_intel->bits, -+ (unsigned long) uci->mc.mc_intel->bits >> 16 >> 16); -+ wrmsr(MSR_IA32_UCODE_REV, 0, 0); -+ -+ /* see notes above for revision 1.07. Apparent chip bug */ -+ sync_core(); -+ -+ /* get the current revision from MSR 0x8B */ -+ rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]); -+ -+ spin_unlock_irqrestore(µcode_update_lock, flags); -+ if (val[1] != uci->mc.mc_intel->hdr.rev) { -+ printk(KERN_ERR "microcode: CPU%d update from revision " -+ "0x%x to 0x%x failed\n", cpu_num, uci->cpu_sig.rev, val[1]); -+ return -EIO; -+ } -+ printk(KERN_INFO "microcode: CPU%d updated from revision " -+ "0x%x to 0x%x, date = %04x-%02x-%02x \n", -+ cpu_num, uci->cpu_sig.rev, val[1], -+ uci->mc.mc_intel->hdr.date & 0xffff, -+ uci->mc.mc_intel->hdr.date >> 24, -+ (uci->mc.mc_intel->hdr.date >> 16) & 0xff); -+ uci->cpu_sig.rev = val[1]; -+ -+ return 0; -+} -+ -+static long get_next_ucode_from_buffer(void **mc, const u8 *buf, -+ unsigned long size, long offset) -+{ -+ struct microcode_header_intel *mc_header; -+ unsigned long total_size; -+ -+ /* No more data */ -+ if (offset >= size) -+ return 0; -+ mc_header = (struct microcode_header_intel *)(buf + offset); -+ total_size = get_totalsize(mc_header); -+ -+ if (offset + total_size > size) { -+ printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); -+ return -EINVAL; -+ } -+ -+ *mc = vmalloc(total_size); -+ if (!*mc) { -+ printk(KERN_ERR "microcode: error! Can not allocate memory\n"); -+ return -ENOMEM; -+ } -+ memcpy(*mc, (const void *)(buf + offset), total_size); -+ return offset + total_size; -+} -+ -+/* fake device for request_firmware */ -+extern struct platform_device *microcode_pdev; -+ -+static int cpu_request_microcode(int cpu, const void *buf, size_t size) -+{ -+ long offset = 0; -+ int error = 0; -+ void *mc; -+ -+ /* We should bind the task to the CPU */ -+ BUG_ON(cpu != raw_smp_processor_id()); -+ -+ while ((offset = get_next_ucode_from_buffer(&mc, buf, size, offset)) -+ > 0) { -+ error = microcode_sanity_check(mc); -+ if (error) -+ break; -+ error = get_matching_microcode(mc, cpu); -+ if (error < 0) -+ break; -+ /* -+ * It's possible the data file has multiple matching ucode, -+ * lets keep searching till the latest version -+ */ -+ if (error == 1) { -+ apply_microcode(cpu); -+ error = 0; -+ } -+ vfree(mc); -+ } -+ if (offset > 0) -+ vfree(mc); -+ if (offset < 0) -+ error = offset; -+ -+ return error; -+} -+ -+static void microcode_fini_cpu(int cpu) -+{ -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ -+ vfree(uci->mc.mc_intel); -+ uci->mc.mc_intel = NULL; -+} -+ -+static struct microcode_ops microcode_intel_ops = { -+ .get_matching_microcode = get_matching_microcode, -+ .microcode_sanity_check = microcode_sanity_check, -+ .cpu_request_microcode = cpu_request_microcode, -+ .collect_cpu_info = collect_cpu_info, -+ .apply_microcode = apply_microcode, -+ .microcode_fini_cpu = microcode_fini_cpu, -+}; -+ -+int microcode_init_intel(struct cpuinfo_x86 *c) -+{ -+ microcode_ops = µcode_intel_ops; -+ return 0; -+} -Index: xen-3.3.1-testing/xen/include/asm-x86/microcode.h -=================================================================== ---- /dev/null -+++ xen-3.3.1-testing/xen/include/asm-x86/microcode.h -@@ -0,0 +1,100 @@ -+#ifndef ASM_X86__MICROCODE_H -+#define ASM_X86__MICROCODE_H -+ -+struct cpu_signature; -+ -+struct microcode_ops { -+ long (*microcode_get_next_ucode)(void **mc, long offset); -+ int (*get_matching_microcode)(void *mc, int cpu); -+ int (*microcode_sanity_check)(void *mc); -+ int (*cpu_request_microcode)(int cpu, const void *buf, size_t size); -+ int (*collect_cpu_info)(int cpu_num, struct cpu_signature *csig); -+ int (*apply_microcode)(int cpu); -+ void (*microcode_fini_cpu)(int cpu); -+ void (*clear_patch)(void *data); -+}; -+ -+struct microcode_header_intel { -+ unsigned int hdrver; -+ unsigned int rev; -+ unsigned int date; -+ unsigned int sig; -+ unsigned int cksum; -+ unsigned int ldrver; -+ unsigned int pf; -+ unsigned int datasize; -+ unsigned int totalsize; -+ unsigned int reserved[3]; -+}; -+ -+struct microcode_intel { -+ struct microcode_header_intel hdr; -+ unsigned int bits[0]; -+}; -+ -+/* microcode format is extended from prescott processors */ -+struct extended_signature { -+ unsigned int sig; -+ unsigned int pf; -+ unsigned int cksum; -+}; -+ -+struct extended_sigtable { -+ unsigned int count; -+ unsigned int cksum; -+ unsigned int reserved[3]; -+ struct extended_signature sigs[0]; -+}; -+ -+struct equiv_cpu_entry { -+ unsigned int installed_cpu; -+ unsigned int fixed_errata_mask; -+ unsigned int fixed_errata_compare; -+ unsigned int equiv_cpu; -+}; -+ -+struct microcode_header_amd { -+ unsigned int data_code; -+ unsigned int patch_id; -+ unsigned char mc_patch_data_id[2]; -+ unsigned char mc_patch_data_len; -+ unsigned char init_flag; -+ unsigned int mc_patch_data_checksum; -+ unsigned int nb_dev_id; -+ unsigned int sb_dev_id; -+ unsigned char processor_rev_id[2]; -+ unsigned char nb_rev_id; -+ unsigned char sb_rev_id; -+ unsigned char bios_api_rev; -+ unsigned char reserved1[3]; -+ unsigned int match_reg[8]; -+}; -+ -+struct microcode_amd { -+ struct microcode_header_amd hdr; -+ unsigned int mpb[0]; -+}; -+ -+struct cpu_signature { -+ unsigned int sig; -+ unsigned int pf; -+ unsigned int rev; -+}; -+ -+struct ucode_cpu_info { -+ struct cpu_signature cpu_sig; -+ int valid; -+ union { -+ struct microcode_intel *mc_intel; -+ struct microcode_amd *mc_amd; -+ void *valid_mc; -+ } mc; -+}; -+extern struct ucode_cpu_info ucode_cpu_info[]; -+ -+extern const struct microcode_ops *microcode_ops; -+ -+int microcode_init_amd(struct cpuinfo_x86 *c); -+int microcode_init_intel(struct cpuinfo_x86 *c); -+ -+#endif /* ASM_X86__MICROCODE_H */ diff --git a/18481-amd-microcode-update-fix.patch b/18481-amd-microcode-update-fix.patch deleted file mode 100644 index 9b9c51c..0000000 --- a/18481-amd-microcode-update-fix.patch +++ /dev/null @@ -1,37 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1221489878 -3600 -# Node ID 75c4a603d9cd7f73366986261e1078fce1ead815 -# Parent 59aba2cbbb58111de1aba6b173800d62956cf26f -x86: Fix 32-bit build after AMD microcode update patch. -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/microcode_amd.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/microcode_amd.c -+++ xen-3.3.1-testing/xen/arch/x86/microcode_amd.c -@@ -170,11 +170,10 @@ out: - static int apply_microcode_amd(int cpu) - { - unsigned long flags; -- unsigned int eax, edx; -- unsigned int rev; -+ uint32_t eax, edx, rev; - int cpu_num = raw_smp_processor_id(); - struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -- unsigned long addr; -+ uint64_t addr; - - /* We should bind the task to the CPU */ - BUG_ON(cpu_num != cpu); -@@ -185,8 +184,8 @@ static int apply_microcode_amd(int cpu) - spin_lock_irqsave(µcode_update_lock, flags); - - addr = (unsigned long)&uci->mc.mc_amd->hdr.data_code; -- edx = (unsigned int)((unsigned long)(addr >> 32)); -- eax = (unsigned int)((unsigned long)(addr & 0xffffffff)); -+ edx = (uint32_t)(addr >> 32); -+ eax = (uint32_t)addr; - - asm volatile("movl %0, %%ecx; wrmsr" : - : "i" (MSR_AMD_PATCHLOADER), "a" (eax), "d" (edx) : "ecx"); diff --git a/18483-intel-microcode-update.patch b/18483-intel-microcode-update.patch deleted file mode 100644 index b798d3f..0000000 --- a/18483-intel-microcode-update.patch +++ /dev/null @@ -1,1766 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1221560779 -3600 -# Node ID 087b8b29b6b20165062697305c6651ca2acb7b5b -# Parent 087008dfb00504f8d38ee48e197ea1dc8e5cb203 -x86, microcode: Clean up for Xen coding style, and disable for now -(until allocations in irq context are fixed). - -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/microcode.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/microcode.c -+++ xen-3.3.1-testing/xen/arch/x86/microcode.c -@@ -1,73 +1,24 @@ - /* -- * Intel CPU Microcode Update Driver for Linux -+ * Intel CPU Microcode Update Driver for Linux - * -- * Copyright (C) 2000-2006 Tigran Aivazian -- * 2006 Shaohua Li * -- * This driver allows to upgrade microcode on Intel processors -- * belonging to IA-32 family - PentiumPro, Pentium II, -- * Pentium III, Xeon, Pentium 4, etc. -- * -- * Reference: Section 8.11 of Volume 3a, IA-32 Intel? Architecture -- * Software Developer's Manual -- * Order Number 253668 or free download from: -- * -- * http://developer.intel.com/design/pentium4/manuals/253668.htm -- * -- * For more information, go to http://www.urbanmyth.org/microcode -- * -- * This program is free software; you can redistribute it and/or -- * modify it under the terms of the GNU General Public License -- * as published by the Free Software Foundation; either version -- * 2 of the License, or (at your option) any later version. -- * -- * 1.0 16 Feb 2000, Tigran Aivazian -- * Initial release. -- * 1.01 18 Feb 2000, Tigran Aivazian -- * Added read() support + cleanups. -- * 1.02 21 Feb 2000, Tigran Aivazian -- * Added 'device trimming' support. open(O_WRONLY) zeroes -- * and frees the saved copy of applied microcode. -- * 1.03 29 Feb 2000, Tigran Aivazian -- * Made to use devfs (/dev/cpu/microcode) + cleanups. -- * 1.04 06 Jun 2000, Simon Trimmer -- * Added misc device support (now uses both devfs and misc). -- * Added MICROCODE_IOCFREE ioctl to clear memory. -- * 1.05 09 Jun 2000, Simon Trimmer -- * Messages for error cases (non Intel & no suitable microcode). -- * 1.06 03 Aug 2000, Tigran Aivazian -- * Removed ->release(). Removed exclusive open and status bitmap. -- * Added microcode_rwsem to serialize read()/write()/ioctl(). -- * Removed global kernel lock usage. -- * 1.07 07 Sep 2000, Tigran Aivazian -- * Write 0 to 0x8B msr and then cpuid before reading revision, -- * so that it works even if there were no update done by the -- * BIOS. Otherwise, reading from 0x8B gives junk (which happened -- * to be 0 on my machine which is why it worked even when I -- * disabled update by the BIOS) -- * Thanks to Eric W. Biederman for the fix. -- * 1.08 11 Dec 2000, Richard Schaal and -- * Tigran Aivazian -- * Intel Pentium 4 processor support and bugfixes. -- * 1.09 30 Oct 2001, Tigran Aivazian -- * Bugfix for HT (Hyper-Threading) enabled processors -- * whereby processor resources are shared by all logical processors -- * in a single CPU package. -- * 1.10 28 Feb 2002 Asit K Mallick and -- * Tigran Aivazian , -- * Serialize updates as required on HT processors due to -- * speculative nature of implementation. -- * 1.11 22 Mar 2002 Tigran Aivazian -- * Fix the panic when writing zero-length microcode chunk. -- * 1.12 29 Sep 2003 Nitin Kamble , -- * Jun Nakajima -- * Support for the microcode updates in the new format. -- * 1.13 10 Oct 2003 Tigran Aivazian -- * Removed ->read() method and obsoleted MICROCODE_IOCFREE ioctl -- * because we no longer hold a copy of applied microcode -- * in kernel memory. -- * 1.14 25 Jun 2004 Tigran Aivazian -- * Fix sigmatch() macro to handle old CPUs with pf == 0. -- * Thanks to Stuart Swales for pointing out this bug. -+ * Copyright (C) 2000-2006 Tigran Aivazian -+ * 2006 Shaohua Li * -+ * This driver allows to upgrade microcode on Intel processors -+ * belonging to IA-32 family - PentiumPro, Pentium II, -+ * Pentium III, Xeon, Pentium 4, etc. -+ * -+ * Reference: Section 8.11 of Volume 3a, IA-32 Intel? Architecture -+ * Software Developer's Manual -+ * Order Number 253668 or free download from: -+ * -+ * http://developer.intel.com/design/pentium4/manuals/253668.htm -+ * -+ * For more information, go to http://www.urbanmyth.org/microcode -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version -+ * 2 of the License, or (at your option) any later version. - */ - - #include -@@ -95,8 +46,8 @@ static DEFINE_SPINLOCK(microcode_mutex); - struct ucode_cpu_info ucode_cpu_info[NR_CPUS]; - - struct microcode_buffer { -- void *buf; -- size_t size; -+ void *buf; -+ size_t size; - }; - - static struct microcode_buffer microcode_buffer; -@@ -104,164 +55,157 @@ static bool_t microcode_error; - - static void microcode_fini_cpu(int cpu) - { -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - -- spin_lock(µcode_mutex); -- microcode_ops->microcode_fini_cpu(cpu); -- uci->valid = 0; -- spin_unlock(µcode_mutex); -+ spin_lock(µcode_mutex); -+ microcode_ops->microcode_fini_cpu(cpu); -+ uci->valid = 0; -+ spin_unlock(µcode_mutex); - } - - static int collect_cpu_info(int cpu) - { -- int err = 0; -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ int err = 0; -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - -- memset(uci, 0, sizeof(*uci)); -- err = microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); -- if (!err) -- uci->valid = 1; -+ memset(uci, 0, sizeof(*uci)); -+ err = microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); -+ if ( !err ) -+ uci->valid = 1; - -- return err; -+ return err; - } - - static int microcode_resume_cpu(int cpu) - { -- int err = 0; -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -- struct cpu_signature nsig; -- -- gdprintk(XENLOG_INFO, "microcode: CPU%d resumed\n", cpu); -- -- if (!uci->mc.valid_mc) -- return -EIO; -- -- /* -- * Let's verify that the 'cached' ucode does belong -- * to this cpu (a bit of paranoia): -- */ -- err = microcode_ops->collect_cpu_info(cpu, &nsig); -- if (err) { -- microcode_fini_cpu(cpu); -- return err; -- } -- -- if (memcmp(&nsig, &uci->cpu_sig, sizeof(nsig))) { -- microcode_fini_cpu(cpu); -- /* Should we look for a new ucode here? */ -- return -EIO; -- } -+ int err = 0; -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ struct cpu_signature nsig; -+ -+ gdprintk(XENLOG_INFO, "microcode: CPU%d resumed\n", cpu); -+ -+ if ( !uci->mc.valid_mc ) -+ return -EIO; -+ -+ /* -+ * Let's verify that the 'cached' ucode does belong -+ * to this cpu (a bit of paranoia): -+ */ -+ err = microcode_ops->collect_cpu_info(cpu, &nsig); -+ if ( err ) -+ { -+ microcode_fini_cpu(cpu); -+ return err; -+ } -+ -+ if ( memcmp(&nsig, &uci->cpu_sig, sizeof(nsig)) ) -+ { -+ microcode_fini_cpu(cpu); -+ /* Should we look for a new ucode here? */ -+ return -EIO; -+ } - -- err = microcode_ops->apply_microcode(cpu); -+ err = microcode_ops->apply_microcode(cpu); - -- return err; -+ return err; - } - - static int microcode_update_cpu(int cpu, const void *buf, size_t size) - { -- int err = 0; -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ int err = 0; -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ -+ /* We should bind the task to the CPU */ -+ BUG_ON(raw_smp_processor_id() != cpu); - -- /* We should bind the task to the CPU */ -- BUG_ON(raw_smp_processor_id() != cpu); -+ spin_lock(µcode_mutex); - -- spin_lock(µcode_mutex); -- /* -- * Check if the system resume is in progress (uci->valid != NULL), -- * otherwise just request a firmware: -- */ -- if (uci->valid) { -- err = microcode_resume_cpu(cpu); -- } else { -- err = collect_cpu_info(cpu); -- if (err) -- goto out; -- if (uci->valid) { -- err = microcode_ops->cpu_request_microcode(cpu, buf, size); -- } -- } -+ /* -+ * Check if the system resume is in progress (uci->valid != NULL), -+ * otherwise just request a firmware: -+ */ -+ if ( uci->valid ) -+ { -+ err = microcode_resume_cpu(cpu); -+ } -+ else -+ { -+ err = collect_cpu_info(cpu); -+ if ( !err && uci->valid ) -+ err = microcode_ops->cpu_request_microcode(cpu, buf, size); -+ } - --out: -- spin_unlock(µcode_mutex); -+ spin_unlock(µcode_mutex); - -- return err; -+ return err; - } - - static void do_microcode_update_one(void *info) - { -- int error = 0; -+ int error; - -- error = microcode_update_cpu(smp_processor_id(), -- microcode_buffer.buf, microcode_buffer.size); -+ error = microcode_update_cpu( -+ smp_processor_id(), microcode_buffer.buf, microcode_buffer.size); - -- if (error) -- microcode_error = error; -+ if ( error ) -+ microcode_error = error; - } - - static int do_microcode_update(void) - { -- int error = 0; -+ int error = 0; - -- microcode_error = 0; -+ microcode_error = 0; - -- if (on_each_cpu(do_microcode_update_one, NULL, 1, 1) != 0) { -- printk(KERN_ERR "microcode: Error! Could not run on all processors\n"); -- error = -EIO; -- goto out; -- } -- -- if (microcode_error) { -- error = microcode_error; -- goto out; -- } -+ if ( on_each_cpu(do_microcode_update_one, NULL, 1, 1) != 0 ) -+ { -+ printk(KERN_ERR "microcode: Error! Could not run on all processors\n"); -+ error = -EIO; -+ goto out; -+ } -+ -+ if ( microcode_error ) -+ { -+ error = microcode_error; -+ goto out; -+ } - --out: -- return error; -+ out: -+ return error; - } - - int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len) - { -- int ret; -- struct cpuinfo_x86 *c = &boot_cpu_data; -+ int ret; -+ -+ /* XXX FIXME: No allocations in interrupt context. */ -+ return -EINVAL; -+ -+ if ( len != (typeof(microcode_buffer.size))len ) -+ { -+ printk(KERN_ERR "microcode: too much data\n"); -+ return -E2BIG; -+ } -+ -+ if (microcode_ops == NULL) -+ return -EINVAL; -+ -+ microcode_buffer.buf = xmalloc_array(uint8_t, len); -+ if ( microcode_buffer.buf == NULL ) -+ return -ENOMEM; -+ -+ ret = copy_from_guest(microcode_buffer.buf, buf, len); -+ if ( ret != 0 ) -+ return ret; -+ -+ microcode_buffer.size = len; -+ wmb(); -+ -+ ret = do_microcode_update(); - -- if (len != (typeof(microcode_buffer.size))len) { -- printk(KERN_ERR "microcode: too much data\n"); -- return -E2BIG; -- } -- -- switch (c->x86_vendor) { -- case X86_VENDOR_AMD: -- ret = microcode_init_amd(c); -- break; -- -- case X86_VENDOR_INTEL: -- ret = microcode_init_intel(c); -- break; -- default: -- printk(KERN_ERR "microcode: CPU vendor not supported\n"); -- ret = -EINVAL; -- break; -- } -- -- if (ret != 0) -- return ret; -- -- microcode_buffer.buf = xmalloc_array(uint8_t, len); -- if (!microcode_buffer.buf) -- return -ENOMEM; -- -- ret = copy_from_guest(microcode_buffer.buf, buf, len); -- if (ret != 0) -- return ret; -- -- microcode_buffer.size = len; -- wmb(); -- -- ret = do_microcode_update(); -- -- xfree(microcode_buffer.buf); -- microcode_buffer.buf = NULL; -- microcode_buffer.size = 0; -+ xfree(microcode_buffer.buf); -+ microcode_buffer.buf = NULL; -+ microcode_buffer.size = 0; - -- return ret; -+ return ret; - } -Index: xen-3.3.1-testing/xen/arch/x86/microcode_amd.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/microcode_amd.c -+++ xen-3.3.1-testing/xen/arch/x86/microcode_amd.c -@@ -12,7 +12,7 @@ - * - * Licensed unter the terms of the GNU General Public - * License version 2. See file COPYING for details. --*/ -+ */ - - #include - #include -@@ -27,28 +27,21 @@ - #include - #include - -- - #define pr_debug(x...) ((void)0) --#define DEFINE_MUTEX(_m) DEFINE_SPINLOCK(_m) --#define mutex_lock(_m) spin_lock(_m) --#define mutex_unlock(_m) spin_unlock(_m) --#define vmalloc(_s) xmalloc_bytes(_s) --#define vfree(_p) xfree(_p) -- - - #define UCODE_MAGIC 0x00414d44 - #define UCODE_EQUIV_CPU_TABLE_TYPE 0x00000000 - #define UCODE_UCODE_TYPE 0x00000001 - - #define UCODE_MAX_SIZE (2048) --#define DEFAULT_UCODE_DATASIZE (896) --#define MC_HEADER_SIZE (sizeof(struct microcode_header_amd)) -+#define DEFAULT_UCODE_DATASIZE (896) -+#define MC_HEADER_SIZE (sizeof(struct microcode_header_amd)) - #define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE) --#define DWSIZE (sizeof(uint32_t)) -+#define DWSIZE (sizeof(uint32_t)) - /* For now we support a fixed ucode total size only */ - #define get_totalsize(mc) \ -- ((((struct microcode_amd *)mc)->hdr.mc_patch_data_len * 28) \ -- + MC_HEADER_SIZE) -+ ((((struct microcode_amd *)mc)->hdr.mc_patch_data_len * 28) \ -+ + MC_HEADER_SIZE) - - /* serialize access to the physical write */ - static DEFINE_SPINLOCK(microcode_update_lock); -@@ -57,309 +50,330 @@ struct equiv_cpu_entry *equiv_cpu_table; - - static long install_equiv_cpu_table(const void *, uint32_t, long); - --static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig) -+static int collect_cpu_info(int cpu, struct cpu_signature *csig) - { -- struct cpuinfo_x86 *c = &cpu_data[cpu]; -+ struct cpuinfo_x86 *c = &cpu_data[cpu]; - -- memset(csig, 0, sizeof(*csig)); -+ memset(csig, 0, sizeof(*csig)); - -- if (c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) { -- printk(KERN_ERR "microcode: CPU%d not a capable AMD processor\n", -- cpu); -- return -1; -- } -+ if ( (c->x86_vendor != X86_VENDOR_AMD) || (c->x86 < 0x10) ) -+ { -+ printk(KERN_ERR "microcode: CPU%d not a capable AMD processor\n", -+ cpu); -+ return -1; -+ } - -- asm volatile("movl %1, %%ecx; rdmsr" -- : "=a" (csig->rev) -- : "i" (MSR_AMD_PATCHLEVEL) : "ecx"); -+ asm volatile("movl %1, %%ecx; rdmsr" -+ : "=a" (csig->rev) -+ : "i" (MSR_AMD_PATCHLEVEL) : "ecx"); - -- printk(KERN_INFO "microcode: collect_cpu_info_amd : patch_id=0x%x\n", -- csig->rev); -+ printk(KERN_INFO "microcode: collect_cpu_info: patch_id=0x%x\n", -+ csig->rev); - -- return 0; -+ return 0; - } - --static int get_matching_microcode_amd(void *mc, int cpu) -+static int get_matching_microcode(void *mc, int cpu) - { -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -- struct microcode_header_amd *mc_header = mc; -- unsigned long total_size = get_totalsize(mc_header); -- void *new_mc; -- unsigned int current_cpu_id; -- unsigned int equiv_cpu_id = 0x00; -- unsigned int i = 0; -- -- /* We should bind the task to the CPU */ -- BUG_ON(cpu != raw_smp_processor_id()); -- -- /* This is a tricky part. We might be called from a write operation -- * to the device file instead of the usual process of firmware -- * loading. This routine needs to be able to distinguish both -- * cases. This is done by checking if there already is a equivalent -- * CPU table installed. If not, we're written through -- * /dev/cpu/microcode. -- * Since we ignore all checks. The error case in which going through -- * firmware loading and that table is not loaded has already been -- * checked earlier. -- */ -- if (equiv_cpu_table == NULL) { -- printk(KERN_INFO "microcode: CPU%d microcode update with " -- "version 0x%x (current=0x%x)\n", -- cpu, mc_header->patch_id, uci->cpu_sig.rev); -- goto out; -- } -- -- current_cpu_id = cpuid_eax(0x00000001); -- -- while (equiv_cpu_table[i].installed_cpu != 0) { -- if (current_cpu_id == equiv_cpu_table[i].installed_cpu) { -- equiv_cpu_id = equiv_cpu_table[i].equiv_cpu; -- break; -- } -- i++; -- } -- -- if (!equiv_cpu_id) { -- printk(KERN_ERR "microcode: CPU%d cpu_id " -- "not found in equivalent cpu table \n", cpu); -- return 0; -- } -- -- if ((mc_header->processor_rev_id[0]) != (equiv_cpu_id & 0xff)) { -- printk(KERN_INFO -- "microcode: CPU%d patch does not match " -- "(patch is %x, cpu extended is %x) \n", -- cpu, mc_header->processor_rev_id[0], -- (equiv_cpu_id & 0xff)); -- return 0; -- } -- -- if ((mc_header->processor_rev_id[1]) != ((equiv_cpu_id >> 16) & 0xff)) { -- printk(KERN_INFO "microcode: CPU%d patch does not match " -- "(patch is %x, cpu base id is %x) \n", -- cpu, mc_header->processor_rev_id[1], -- ((equiv_cpu_id >> 16) & 0xff)); -- -- return 0; -- } -- -- if (mc_header->patch_id <= uci->cpu_sig.rev) -- return 0; -- -- printk(KERN_INFO "microcode: CPU%d found a matching microcode " -- "update with version 0x%x (current=0x%x)\n", -- cpu, mc_header->patch_id, uci->cpu_sig.rev); -- --out: -- new_mc = vmalloc(UCODE_MAX_SIZE); -- if (!new_mc) { -- printk(KERN_ERR "microcode: error, can't allocate memory\n"); -- return -ENOMEM; -- } -- memset(new_mc, 0, UCODE_MAX_SIZE); -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ struct microcode_header_amd *mc_header = mc; -+ unsigned long total_size = get_totalsize(mc_header); -+ void *new_mc; -+ unsigned int current_cpu_id; -+ unsigned int equiv_cpu_id = 0x00; -+ unsigned int i = 0; -+ -+ /* We should bind the task to the CPU */ -+ BUG_ON(cpu != raw_smp_processor_id()); -+ -+ /* This is a tricky part. We might be called from a write operation -+ * to the device file instead of the usual process of firmware -+ * loading. This routine needs to be able to distinguish both -+ * cases. This is done by checking if there already is a equivalent -+ * CPU table installed. If not, we're written through -+ * /dev/cpu/microcode. -+ * Since we ignore all checks. The error case in which going through -+ * firmware loading and that table is not loaded has already been -+ * checked earlier. -+ */ -+ if ( equiv_cpu_table == NULL ) -+ { -+ printk(KERN_INFO "microcode: CPU%d microcode update with " -+ "version 0x%x (current=0x%x)\n", -+ cpu, mc_header->patch_id, uci->cpu_sig.rev); -+ goto out; -+ } -+ -+ current_cpu_id = cpuid_eax(0x00000001); -+ -+ while ( equiv_cpu_table[i].installed_cpu != 0 ) -+ { -+ if ( current_cpu_id == equiv_cpu_table[i].installed_cpu ) -+ { -+ equiv_cpu_id = equiv_cpu_table[i].equiv_cpu; -+ break; -+ } -+ i++; -+ } -+ -+ if ( !equiv_cpu_id ) -+ { -+ printk(KERN_ERR "microcode: CPU%d cpu_id " -+ "not found in equivalent cpu table \n", cpu); -+ return 0; -+ } -+ -+ if ( (mc_header->processor_rev_id[0]) != (equiv_cpu_id & 0xff) ) -+ { -+ printk(KERN_INFO -+ "microcode: CPU%d patch does not match " -+ "(patch is %x, cpu extended is %x) \n", -+ cpu, mc_header->processor_rev_id[0], -+ (equiv_cpu_id & 0xff)); -+ return 0; -+ } -+ -+ if ( (mc_header->processor_rev_id[1]) != ((equiv_cpu_id >> 16) & 0xff) ) -+ { -+ printk(KERN_INFO "microcode: CPU%d patch does not match " -+ "(patch is %x, cpu base id is %x) \n", -+ cpu, mc_header->processor_rev_id[1], -+ ((equiv_cpu_id >> 16) & 0xff)); -+ return 0; -+ } -+ -+ if ( mc_header->patch_id <= uci->cpu_sig.rev ) -+ return 0; -+ -+ printk(KERN_INFO "microcode: CPU%d found a matching microcode " -+ "update with version 0x%x (current=0x%x)\n", -+ cpu, mc_header->patch_id, uci->cpu_sig.rev); -+ -+ out: -+ new_mc = xmalloc_bytes(UCODE_MAX_SIZE); -+ if ( new_mc == NULL ) -+ { -+ printk(KERN_ERR "microcode: error, can't allocate memory\n"); -+ return -ENOMEM; -+ } -+ memset(new_mc, 0, UCODE_MAX_SIZE); - -- /* free previous update file */ -- vfree(uci->mc.mc_amd); -+ /* free previous update file */ -+ xfree(uci->mc.mc_amd); - -- memcpy(new_mc, mc, total_size); -+ memcpy(new_mc, mc, total_size); - -- uci->mc.mc_amd = new_mc; -- return 1; -+ uci->mc.mc_amd = new_mc; -+ return 1; - } - --static int apply_microcode_amd(int cpu) -+static int apply_microcode(int cpu) - { -- unsigned long flags; -- uint32_t eax, edx, rev; -- int cpu_num = raw_smp_processor_id(); -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -- uint64_t addr; -- -- /* We should bind the task to the CPU */ -- BUG_ON(cpu_num != cpu); -- -- if (uci->mc.mc_amd == NULL) -- return -EINVAL; -- -- spin_lock_irqsave(µcode_update_lock, flags); -- -- addr = (unsigned long)&uci->mc.mc_amd->hdr.data_code; -- edx = (uint32_t)(addr >> 32); -- eax = (uint32_t)addr; -+ unsigned long flags; -+ uint32_t eax, edx, rev; -+ int cpu_num = raw_smp_processor_id(); -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -+ uint64_t addr; -+ -+ /* We should bind the task to the CPU */ -+ BUG_ON(cpu_num != cpu); -+ -+ if ( uci->mc.mc_amd == NULL ) -+ return -EINVAL; -+ -+ spin_lock_irqsave(µcode_update_lock, flags); -+ -+ addr = (unsigned long)&uci->mc.mc_amd->hdr.data_code; -+ edx = (uint32_t)(addr >> 32); -+ eax = (uint32_t)addr; -+ -+ asm volatile("movl %0, %%ecx; wrmsr" : -+ : "i" (MSR_AMD_PATCHLOADER), "a" (eax), "d" (edx) : "ecx"); -+ -+ /* get patch id after patching */ -+ asm volatile("movl %1, %%ecx; rdmsr" -+ : "=a" (rev) -+ : "i" (MSR_AMD_PATCHLEVEL) : "ecx"); -+ -+ spin_unlock_irqrestore(µcode_update_lock, flags); -+ -+ /* check current patch id and patch's id for match */ -+ if ( rev != uci->mc.mc_amd->hdr.patch_id ) -+ { -+ printk(KERN_ERR "microcode: CPU%d update from revision " -+ "0x%x to 0x%x failed\n", cpu_num, -+ uci->mc.mc_amd->hdr.patch_id, rev); -+ return -EIO; -+ } -+ -+ printk("microcode: CPU%d updated from revision " -+ "0x%x to 0x%x \n", -+ cpu_num, uci->cpu_sig.rev, uci->mc.mc_amd->hdr.patch_id); - -- asm volatile("movl %0, %%ecx; wrmsr" : -- : "i" (MSR_AMD_PATCHLOADER), "a" (eax), "d" (edx) : "ecx"); -+ uci->cpu_sig.rev = rev; - -- /* get patch id after patching */ -- asm volatile("movl %1, %%ecx; rdmsr" -- : "=a" (rev) -- : "i" (MSR_AMD_PATCHLEVEL) : "ecx"); -- -- spin_unlock_irqrestore(µcode_update_lock, flags); -- -- /* check current patch id and patch's id for match */ -- if (rev != uci->mc.mc_amd->hdr.patch_id) { -- printk(KERN_ERR "microcode: CPU%d update from revision " -- "0x%x to 0x%x failed\n", cpu_num, -- uci->mc.mc_amd->hdr.patch_id, rev); -- return -EIO; -- } -- -- printk("microcode: CPU%d updated from revision " -- "0x%x to 0x%x \n", -- cpu_num, uci->cpu_sig.rev, uci->mc.mc_amd->hdr.patch_id); -- -- uci->cpu_sig.rev = rev; -- -- return 0; -+ return 0; - } - - static long get_next_ucode_from_buffer_amd(void **mc, const void *buf, -- unsigned long size, long offset) -+ unsigned long size, long offset) - { -- struct microcode_header_amd *mc_header; -- unsigned long total_size; -- const uint8_t *buf_pos = buf; -- -- /* No more data */ -- if (offset >= size) -- return 0; -- -- if (buf_pos[offset] != UCODE_UCODE_TYPE) { -- printk(KERN_ERR "microcode: error! " -- "Wrong microcode payload type field\n"); -- return -EINVAL; -- } -- -- mc_header = (struct microcode_header_amd *)(&buf_pos[offset+8]); -- -- total_size = (unsigned long) (buf_pos[offset+4] + -- (buf_pos[offset+5] << 8)); -- -- printk(KERN_INFO "microcode: size %lu, total_size %lu, offset %ld\n", -- size, total_size, offset); -- -- if (offset + total_size > size) { -- printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); -- return -EINVAL; -- } -- -- *mc = vmalloc(UCODE_MAX_SIZE); -- if (!*mc) { -- printk(KERN_ERR "microcode: error! " -- "Can not allocate memory for microcode patch\n"); -- return -ENOMEM; -- } -+ struct microcode_header_amd *mc_header; -+ unsigned long total_size; -+ const uint8_t *buf_pos = buf; -+ -+ /* No more data */ -+ if ( offset >= size ) -+ return 0; -+ -+ if ( buf_pos[offset] != UCODE_UCODE_TYPE ) -+ { -+ printk(KERN_ERR "microcode: error! " -+ "Wrong microcode payload type field\n"); -+ return -EINVAL; -+ } -+ -+ mc_header = (struct microcode_header_amd *)(&buf_pos[offset+8]); -+ -+ total_size = (unsigned long) (buf_pos[offset+4] + -+ (buf_pos[offset+5] << 8)); -+ -+ printk(KERN_INFO "microcode: size %lu, total_size %lu, offset %ld\n", -+ size, total_size, offset); -+ -+ if ( (offset + total_size) > size ) -+ { -+ printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); -+ return -EINVAL; -+ } -+ -+ *mc = xmalloc_bytes(UCODE_MAX_SIZE); -+ if ( *mc == NULL ) -+ { -+ printk(KERN_ERR "microcode: error! " -+ "Can not allocate memory for microcode patch\n"); -+ return -ENOMEM; -+ } - -- memset(*mc, 0, UCODE_MAX_SIZE); -- memcpy(*mc, (const void *)(buf + offset + 8), total_size); -+ memset(*mc, 0, UCODE_MAX_SIZE); -+ memcpy(*mc, (const void *)(buf + offset + 8), total_size); - -- return offset + total_size + 8; -+ return offset + total_size + 8; - } - - static long install_equiv_cpu_table(const void *buf, -- uint32_t size, long offset) -+ uint32_t size, long offset) - { -- const uint32_t *buf_pos = buf; -+ const uint32_t *buf_pos = buf; - -- /* No more data */ -- if (offset >= size) -- return 0; -- -- if (buf_pos[1] != UCODE_EQUIV_CPU_TABLE_TYPE) { -- printk(KERN_ERR "microcode: error! " -- "Wrong microcode equivalnet cpu table type field\n"); -- return 0; -- } -- -- if (size == 0) { -- printk(KERN_ERR "microcode: error! " -- "Wrong microcode equivalnet cpu table length\n"); -- return 0; -- } -- -- equiv_cpu_table = (struct equiv_cpu_entry *) vmalloc(size); -- if (!equiv_cpu_table) { -- printk(KERN_ERR "microcode: error, can't allocate memory for equiv CPU table\n"); -- return 0; -- } -+ /* No more data */ -+ if ( offset >= size ) -+ return 0; -+ -+ if ( buf_pos[1] != UCODE_EQUIV_CPU_TABLE_TYPE ) -+ { -+ printk(KERN_ERR "microcode: error! " -+ "Wrong microcode equivalnet cpu table type field\n"); -+ return 0; -+ } -+ -+ if ( size == 0 ) -+ { -+ printk(KERN_ERR "microcode: error! " -+ "Wrong microcode equivalnet cpu table length\n"); -+ return 0; -+ } -+ -+ equiv_cpu_table = xmalloc_bytes(size); -+ if ( equiv_cpu_table == NULL ) -+ { -+ printk(KERN_ERR "microcode: error, can't allocate " -+ "memory for equiv CPU table\n"); -+ return 0; -+ } - -- memset(equiv_cpu_table, 0, size); -- memcpy(equiv_cpu_table, (const void *)&buf_pos[3], size); -+ memset(equiv_cpu_table, 0, size); -+ memcpy(equiv_cpu_table, (const void *)&buf_pos[3], size); - -- return size + 12; /* add header length */ -+ return size + 12; /* add header length */ - } - --static int cpu_request_microcode_amd(int cpu, const void *buf, -- size_t size) -+static int cpu_request_microcode(int cpu, const void *buf, size_t size) - { -- const uint32_t *buf_pos; -- long offset = 0; -- int error = 0; -- void *mc; -- -- /* We should bind the task to the CPU */ -- BUG_ON(cpu != raw_smp_processor_id()); -- -- buf_pos = (const uint32_t *)buf; -- -- if (buf_pos[0] != UCODE_MAGIC) { -- printk(KERN_ERR "microcode: error! Wrong microcode patch file magic\n"); -- return -EINVAL; -- } -- -- offset = install_equiv_cpu_table(buf, (uint32_t)(buf_pos[2]), offset); -- if (!offset) { -- printk(KERN_ERR "microcode: installing equivalent cpu table failed\n"); -- return -EINVAL; -- } -- -- while ((offset = -- get_next_ucode_from_buffer_amd(&mc, buf, size, offset)) > 0) { -- error = get_matching_microcode_amd(mc, cpu); -- if (error < 0) -- break; -- /* -- * It's possible the data file has multiple matching ucode, -- * lets keep searching till the latest version -- */ -- if (error == 1) { -- apply_microcode_amd(cpu); -- error = 0; -- } -- vfree(mc); -- } -- if (offset > 0) { -- vfree(mc); -- vfree(equiv_cpu_table); -- equiv_cpu_table = NULL; -- } -- if (offset < 0) -- error = offset; -+ const uint32_t *buf_pos; -+ long offset = 0; -+ int error = 0; -+ void *mc; -+ -+ /* We should bind the task to the CPU */ -+ BUG_ON(cpu != raw_smp_processor_id()); -+ -+ buf_pos = (const uint32_t *)buf; -+ -+ if ( buf_pos[0] != UCODE_MAGIC ) -+ { -+ printk(KERN_ERR "microcode: error! Wrong " -+ "microcode patch file magic\n"); -+ return -EINVAL; -+ } -+ -+ offset = install_equiv_cpu_table(buf, (uint32_t)(buf_pos[2]), offset); -+ if ( !offset ) -+ { -+ printk(KERN_ERR "microcode: installing equivalent cpu table failed\n"); -+ return -EINVAL; -+ } -+ -+ while ( (offset = -+ get_next_ucode_from_buffer_amd(&mc, buf, size, offset)) > 0 ) -+ { -+ error = get_matching_microcode(mc, cpu); -+ if ( error < 0 ) -+ break; -+ /* -+ * It's possible the data file has multiple matching ucode, -+ * lets keep searching till the latest version -+ */ -+ if ( error == 1 ) -+ { -+ apply_microcode(cpu); -+ error = 0; -+ } -+ xfree(mc); -+ } -+ if ( offset > 0 ) -+ { -+ xfree(mc); -+ xfree(equiv_cpu_table); -+ equiv_cpu_table = NULL; -+ } -+ if ( offset < 0 ) -+ error = offset; - -- return error; -+ return error; - } - --static void microcode_fini_cpu_amd(int cpu) -+static void microcode_fini_cpu(int cpu) - { -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - -- vfree(uci->mc.mc_amd); -- uci->mc.mc_amd = NULL; -+ xfree(uci->mc.mc_amd); -+ uci->mc.mc_amd = NULL; - } - - static struct microcode_ops microcode_amd_ops = { -- .get_matching_microcode = get_matching_microcode_amd, -- .microcode_sanity_check = NULL, -- .cpu_request_microcode = cpu_request_microcode_amd, -- .collect_cpu_info = collect_cpu_info_amd, -- .apply_microcode = apply_microcode_amd, -- .microcode_fini_cpu = microcode_fini_cpu_amd, -+ .get_matching_microcode = get_matching_microcode, -+ .microcode_sanity_check = NULL, -+ .cpu_request_microcode = cpu_request_microcode, -+ .collect_cpu_info = collect_cpu_info, -+ .apply_microcode = apply_microcode, -+ .microcode_fini_cpu = microcode_fini_cpu, - }; - --int microcode_init_amd(struct cpuinfo_x86 *c) -+static __init int microcode_init_amd(void) - { -- microcode_ops = µcode_amd_ops; -- return 0; -+ if ( boot_cpu_data.x86_vendor == X86_VENDOR_AMD ) -+ microcode_ops = µcode_amd_ops; -+ return 0; - } -- -+__initcall(microcode_init_amd); -Index: xen-3.3.1-testing/xen/arch/x86/microcode_intel.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/microcode_intel.c -+++ xen-3.3.1-testing/xen/arch/x86/microcode_intel.c -@@ -1,73 +1,24 @@ - /* -- * Intel CPU Microcode Update Driver for Linux -+ * Intel CPU Microcode Update Driver for Linux - * -- * Copyright (C) 2000-2006 Tigran Aivazian -- * 2006 Shaohua Li * -- * This driver allows to upgrade microcode on Intel processors -- * belonging to IA-32 family - PentiumPro, Pentium II, -- * Pentium III, Xeon, Pentium 4, etc. -+ * Copyright (C) 2000-2006 Tigran Aivazian -+ * 2006 Shaohua Li * -+ * This driver allows to upgrade microcode on Intel processors -+ * belonging to IA-32 family - PentiumPro, Pentium II, -+ * Pentium III, Xeon, Pentium 4, etc. - * -- * Reference: Section 8.11 of Volume 3a, IA-32 Intel? Architecture -- * Software Developer's Manual -- * Order Number 253668 or free download from: -+ * Reference: Section 8.11 of Volume 3a, IA-32 Intel? Architecture -+ * Software Developer's Manual -+ * Order Number 253668 or free download from: - * -- * http://developer.intel.com/design/pentium4/manuals/253668.htm -+ * http://developer.intel.com/design/pentium4/manuals/253668.htm - * -- * For more information, go to http://www.urbanmyth.org/microcode -+ * For more information, go to http://www.urbanmyth.org/microcode - * -- * This program is free software; you can redistribute it and/or -- * modify it under the terms of the GNU General Public License -- * as published by the Free Software Foundation; either version -- * 2 of the License, or (at your option) any later version. -- * -- * 1.0 16 Feb 2000, Tigran Aivazian -- * Initial release. -- * 1.01 18 Feb 2000, Tigran Aivazian -- * Added read() support + cleanups. -- * 1.02 21 Feb 2000, Tigran Aivazian -- * Added 'device trimming' support. open(O_WRONLY) zeroes -- * and frees the saved copy of applied microcode. -- * 1.03 29 Feb 2000, Tigran Aivazian -- * Made to use devfs (/dev/cpu/microcode) + cleanups. -- * 1.04 06 Jun 2000, Simon Trimmer -- * Added misc device support (now uses both devfs and misc). -- * Added MICROCODE_IOCFREE ioctl to clear memory. -- * 1.05 09 Jun 2000, Simon Trimmer -- * Messages for error cases (non Intel & no suitable microcode). -- * 1.06 03 Aug 2000, Tigran Aivazian -- * Removed ->release(). Removed exclusive open and status bitmap. -- * Added microcode_rwsem to serialize read()/write()/ioctl(). -- * Removed global kernel lock usage. -- * 1.07 07 Sep 2000, Tigran Aivazian -- * Write 0 to 0x8B msr and then cpuid before reading revision, -- * so that it works even if there were no update done by the -- * BIOS. Otherwise, reading from 0x8B gives junk (which happened -- * to be 0 on my machine which is why it worked even when I -- * disabled update by the BIOS) -- * Thanks to Eric W. Biederman for the fix. -- * 1.08 11 Dec 2000, Richard Schaal and -- * Tigran Aivazian -- * Intel Pentium 4 processor support and bugfixes. -- * 1.09 30 Oct 2001, Tigran Aivazian -- * Bugfix for HT (Hyper-Threading) enabled processors -- * whereby processor resources are shared by all logical processors -- * in a single CPU package. -- * 1.10 28 Feb 2002 Asit K Mallick and -- * Tigran Aivazian , -- * Serialize updates as required on HT processors due to -- * speculative nature of implementation. -- * 1.11 22 Mar 2002 Tigran Aivazian -- * Fix the panic when writing zero-length microcode chunk. -- * 1.12 29 Sep 2003 Nitin Kamble , -- * Jun Nakajima -- * Support for the microcode updates in the new format. -- * 1.13 10 Oct 2003 Tigran Aivazian -- * Removed ->read() method and obsoleted MICROCODE_IOCFREE ioctl -- * because we no longer hold a copy of applied microcode -- * in kernel memory. -- * 1.14 25 Jun 2004 Tigran Aivazian -- * Fix sigmatch() macro to handle old CPUs with pf == 0. -- * Thanks to Stuart Swales for pointing out this bug. -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version -+ * 2 of the License, or (at your option) any later version. - */ - - #include -@@ -84,35 +35,24 @@ - #include - - #define pr_debug(x...) ((void)0) --#define DEFINE_MUTEX(_m) DEFINE_SPINLOCK(_m) --#define mutex_lock(_m) spin_lock(_m) --#define mutex_unlock(_m) spin_unlock(_m) --#define vmalloc(_s) xmalloc_bytes(_s) --#define vfree(_p) xfree(_p) -- --#if 0 --MODULE_DESCRIPTION("Microcode Update Driver"); --MODULE_AUTHOR("Tigran Aivazian "); --MODULE_LICENSE("GPL"); --#endif - --#define DEFAULT_UCODE_DATASIZE (2000) --#define MC_HEADER_SIZE (sizeof(struct microcode_header_intel)) -+#define DEFAULT_UCODE_DATASIZE (2000) -+#define MC_HEADER_SIZE (sizeof(struct microcode_header_intel)) - #define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE) --#define EXT_HEADER_SIZE (sizeof(struct extended_sigtable)) --#define EXT_SIGNATURE_SIZE (sizeof(struct extended_signature)) --#define DWSIZE (sizeof(u32)) -+#define EXT_HEADER_SIZE (sizeof(struct extended_sigtable)) -+#define EXT_SIGNATURE_SIZE (sizeof(struct extended_signature)) -+#define DWSIZE (sizeof(u32)) - #define get_totalsize(mc) \ -- (((struct microcode_intel *)mc)->hdr.totalsize ? \ -- ((struct microcode_intel *)mc)->hdr.totalsize : \ -- DEFAULT_UCODE_TOTALSIZE) -+ (((struct microcode_intel *)mc)->hdr.totalsize ? \ -+ ((struct microcode_intel *)mc)->hdr.totalsize : \ -+ DEFAULT_UCODE_TOTALSIZE) - - #define get_datasize(mc) \ -- (((struct microcode_intel *)mc)->hdr.datasize ? \ -- ((struct microcode_intel *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE) -+ (((struct microcode_intel *)mc)->hdr.datasize ? \ -+ ((struct microcode_intel *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE) - - #define sigmatch(s1, s2, p1, p2) \ -- (((s1) == (s2)) && (((p1) & (p2)) || (((p1) == 0) && ((p2) == 0)))) -+ (((s1) == (s2)) && (((p1) & (p2)) || (((p1) == 0) && ((p2) == 0)))) - - #define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE) - -@@ -121,125 +61,135 @@ static DEFINE_SPINLOCK(microcode_update_ - - static int collect_cpu_info(int cpu_num, struct cpu_signature *csig) - { -- struct cpuinfo_x86 *c = &cpu_data[cpu_num]; -- unsigned int val[2]; -+ struct cpuinfo_x86 *c = &cpu_data[cpu_num]; -+ unsigned int val[2]; - -- memset(csig, 0, sizeof(*csig)); -+ memset(csig, 0, sizeof(*csig)); - -- if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 || -- cpu_has(c, X86_FEATURE_IA64)) { -- printk(KERN_ERR "microcode: CPU%d not a capable Intel " -- "processor\n", cpu_num); -- return -1; -- } -- -- csig->sig = cpuid_eax(0x00000001); -- -- if ((c->x86_model >= 5) || (c->x86 > 6)) { -- /* get processor flags from MSR 0x17 */ -- rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]); -- csig->pf = 1 << ((val[1] >> 18) & 7); -- } -- -- wrmsr(MSR_IA32_UCODE_REV, 0, 0); -- /* see notes above for revision 1.07. Apparent chip bug */ -- sync_core(); -- /* get the current revision from MSR 0x8B */ -- rdmsr(MSR_IA32_UCODE_REV, val[0], csig->rev); -- pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n", -- csig->sig, csig->pf, csig->rev); -+ if ( (c->x86_vendor != X86_VENDOR_INTEL) || (c->x86 < 6) || -+ cpu_has(c, X86_FEATURE_IA64) ) -+ { -+ printk(KERN_ERR "microcode: CPU%d not a capable Intel " -+ "processor\n", cpu_num); -+ return -1; -+ } -+ -+ csig->sig = cpuid_eax(0x00000001); -+ -+ if ( (c->x86_model >= 5) || (c->x86 > 6) ) -+ { -+ /* get processor flags from MSR 0x17 */ -+ rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]); -+ csig->pf = 1 << ((val[1] >> 18) & 7); -+ } -+ -+ wrmsr(MSR_IA32_UCODE_REV, 0, 0); -+ /* see notes above for revision 1.07. Apparent chip bug */ -+ sync_core(); -+ /* get the current revision from MSR 0x8B */ -+ rdmsr(MSR_IA32_UCODE_REV, val[0], csig->rev); -+ pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n", -+ csig->sig, csig->pf, csig->rev); - -- return 0; -+ return 0; - } - --static inline int microcode_update_match(int cpu_num, -- struct microcode_header_intel *mc_header, int sig, int pf) -+static inline int microcode_update_match( -+ int cpu_num, struct microcode_header_intel *mc_header, int sig, int pf) - { -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; - -- if (!sigmatch(sig, uci->cpu_sig.sig, pf, uci->cpu_sig.pf) -- || mc_header->rev <= uci->cpu_sig.rev) -- return 0; -- return 1; -+ return (sigmatch(sig, uci->cpu_sig.sig, pf, uci->cpu_sig.pf) && -+ (mc_header->rev > uci->cpu_sig.rev)); - } - - static int microcode_sanity_check(void *mc) - { -- struct microcode_header_intel *mc_header = mc; -- struct extended_sigtable *ext_header = NULL; -- struct extended_signature *ext_sig; -- unsigned long total_size, data_size, ext_table_size; -- int sum, orig_sum, ext_sigcount = 0, i; -- -- total_size = get_totalsize(mc_header); -- data_size = get_datasize(mc_header); -- if (data_size + MC_HEADER_SIZE > total_size) { -- printk(KERN_ERR "microcode: error! " -- "Bad data size in microcode data file\n"); -- return -EINVAL; -- } -- -- if (mc_header->ldrver != 1 || mc_header->hdrver != 1) { -- printk(KERN_ERR "microcode: error! " -- "Unknown microcode update format\n"); -- return -EINVAL; -- } -- ext_table_size = total_size - (MC_HEADER_SIZE + data_size); -- if (ext_table_size) { -- if ((ext_table_size < EXT_HEADER_SIZE) -- || ((ext_table_size - EXT_HEADER_SIZE) % EXT_SIGNATURE_SIZE)) { -- printk(KERN_ERR "microcode: error! " -- "Small exttable size in microcode data file\n"); -- return -EINVAL; -- } -- ext_header = mc + MC_HEADER_SIZE + data_size; -- if (ext_table_size != exttable_size(ext_header)) { -- printk(KERN_ERR "microcode: error! " -- "Bad exttable size in microcode data file\n"); -- return -EFAULT; -- } -- ext_sigcount = ext_header->count; -- } -- -- /* check extended table checksum */ -- if (ext_table_size) { -- int ext_table_sum = 0; -- int *ext_tablep = (int *)ext_header; -- -- i = ext_table_size / DWSIZE; -- while (i--) -- ext_table_sum += ext_tablep[i]; -- if (ext_table_sum) { -- printk(KERN_WARNING "microcode: aborting, " -- "bad extended signature table checksum\n"); -- return -EINVAL; -- } -- } -- -- /* calculate the checksum */ -- orig_sum = 0; -- i = (MC_HEADER_SIZE + data_size) / DWSIZE; -- while (i--) -- orig_sum += ((int *)mc)[i]; -- if (orig_sum) { -- printk(KERN_ERR "microcode: aborting, bad checksum\n"); -- return -EINVAL; -- } -- if (!ext_table_size) -- return 0; -- /* check extended signature checksum */ -- for (i = 0; i < ext_sigcount; i++) { -- ext_sig = (void *)ext_header + EXT_HEADER_SIZE + -- EXT_SIGNATURE_SIZE * i; -- sum = orig_sum -- - (mc_header->sig + mc_header->pf + mc_header->cksum) -- + (ext_sig->sig + ext_sig->pf + ext_sig->cksum); -- if (sum) { -- printk(KERN_ERR "microcode: aborting, bad checksum\n"); -- return -EINVAL; -- } -- } -- return 0; -+ struct microcode_header_intel *mc_header = mc; -+ struct extended_sigtable *ext_header = NULL; -+ struct extended_signature *ext_sig; -+ unsigned long total_size, data_size, ext_table_size; -+ int sum, orig_sum, ext_sigcount = 0, i; -+ -+ total_size = get_totalsize(mc_header); -+ data_size = get_datasize(mc_header); -+ if ( (data_size + MC_HEADER_SIZE) > total_size ) -+ { -+ printk(KERN_ERR "microcode: error! " -+ "Bad data size in microcode data file\n"); -+ return -EINVAL; -+ } -+ -+ if ( (mc_header->ldrver != 1) || (mc_header->hdrver != 1) ) -+ { -+ printk(KERN_ERR "microcode: error! " -+ "Unknown microcode update format\n"); -+ return -EINVAL; -+ } -+ ext_table_size = total_size - (MC_HEADER_SIZE + data_size); -+ if ( ext_table_size ) -+ { -+ if ( (ext_table_size < EXT_HEADER_SIZE) || -+ ((ext_table_size - EXT_HEADER_SIZE) % EXT_SIGNATURE_SIZE) ) -+ { -+ printk(KERN_ERR "microcode: error! " -+ "Small exttable size in microcode data file\n"); -+ return -EINVAL; -+ } -+ ext_header = mc + MC_HEADER_SIZE + data_size; -+ if ( ext_table_size != exttable_size(ext_header) ) -+ { -+ printk(KERN_ERR "microcode: error! " -+ "Bad exttable size in microcode data file\n"); -+ return -EFAULT; -+ } -+ ext_sigcount = ext_header->count; -+ } -+ -+ /* check extended table checksum */ -+ if ( ext_table_size ) -+ { -+ int ext_table_sum = 0; -+ int *ext_tablep = (int *)ext_header; -+ -+ i = ext_table_size / DWSIZE; -+ while ( i-- ) -+ ext_table_sum += ext_tablep[i]; -+ if ( ext_table_sum ) -+ { -+ printk(KERN_WARNING "microcode: aborting, " -+ "bad extended signature table checksum\n"); -+ return -EINVAL; -+ } -+ } -+ -+ /* calculate the checksum */ -+ orig_sum = 0; -+ i = (MC_HEADER_SIZE + data_size) / DWSIZE; -+ while ( i-- ) -+ orig_sum += ((int *)mc)[i]; -+ if ( orig_sum ) -+ { -+ printk(KERN_ERR "microcode: aborting, bad checksum\n"); -+ return -EINVAL; -+ } -+ if ( !ext_table_size ) -+ return 0; -+ /* check extended signature checksum */ -+ for ( i = 0; i < ext_sigcount; i++ ) -+ { -+ ext_sig = (void *)ext_header + EXT_HEADER_SIZE + -+ EXT_SIGNATURE_SIZE * i; -+ sum = orig_sum -+ - (mc_header->sig + mc_header->pf + mc_header->cksum) -+ + (ext_sig->sig + ext_sig->pf + ext_sig->cksum); -+ if ( sum ) -+ { -+ printk(KERN_ERR "microcode: aborting, bad checksum\n"); -+ return -EINVAL; -+ } -+ } -+ return 0; - } - - /* -@@ -249,118 +199,123 @@ static int microcode_sanity_check(void * - */ - static int get_matching_microcode(void *mc, int cpu) - { -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -- struct microcode_header_intel *mc_header = mc; -- struct extended_sigtable *ext_header; -- unsigned long total_size = get_totalsize(mc_header); -- int ext_sigcount, i; -- struct extended_signature *ext_sig; -- void *new_mc; -- -- if (microcode_update_match(cpu, mc_header, -- mc_header->sig, mc_header->pf)) -- goto find; -- -- if (total_size <= get_datasize(mc_header) + MC_HEADER_SIZE) -- return 0; -- -- ext_header = mc + get_datasize(mc_header) + MC_HEADER_SIZE; -- ext_sigcount = ext_header->count; -- ext_sig = (void *)ext_header + EXT_HEADER_SIZE; -- for (i = 0; i < ext_sigcount; i++) { -- if (microcode_update_match(cpu, mc_header, -- ext_sig->sig, ext_sig->pf)) -- goto find; -- ext_sig++; -- } -- return 0; --find: -- pr_debug("microcode: CPU%d found a matching microcode update with" -- " version 0x%x (current=0x%x)\n", -- cpu, mc_header->rev, uci->cpu_sig.rev); -- new_mc = vmalloc(total_size); -- if (!new_mc) { -- printk(KERN_ERR "microcode: error! Can not allocate memory\n"); -- return -ENOMEM; -- } -- -- /* free previous update file */ -- vfree(uci->mc.mc_intel); -- -- memcpy(new_mc, mc, total_size); -- uci->mc.mc_intel = new_mc; -- return 1; -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ struct microcode_header_intel *mc_header = mc; -+ struct extended_sigtable *ext_header; -+ unsigned long total_size = get_totalsize(mc_header); -+ int ext_sigcount, i; -+ struct extended_signature *ext_sig; -+ void *new_mc; -+ -+ if ( microcode_update_match(cpu, mc_header, -+ mc_header->sig, mc_header->pf) ) -+ goto find; -+ -+ if ( total_size <= (get_datasize(mc_header) + MC_HEADER_SIZE) ) -+ return 0; -+ -+ ext_header = mc + get_datasize(mc_header) + MC_HEADER_SIZE; -+ ext_sigcount = ext_header->count; -+ ext_sig = (void *)ext_header + EXT_HEADER_SIZE; -+ for ( i = 0; i < ext_sigcount; i++ ) -+ { -+ if ( microcode_update_match(cpu, mc_header, -+ ext_sig->sig, ext_sig->pf) ) -+ goto find; -+ ext_sig++; -+ } -+ return 0; -+ find: -+ pr_debug("microcode: CPU%d found a matching microcode update with" -+ " version 0x%x (current=0x%x)\n", -+ cpu, mc_header->rev, uci->cpu_sig.rev); -+ new_mc = xmalloc_bytes(total_size); -+ if ( new_mc == NULL ) -+ { -+ printk(KERN_ERR "microcode: error! Can not allocate memory\n"); -+ return -ENOMEM; -+ } -+ -+ /* free previous update file */ -+ xfree(uci->mc.mc_intel); -+ -+ memcpy(new_mc, mc, total_size); -+ uci->mc.mc_intel = new_mc; -+ return 1; - } - - static int apply_microcode(int cpu) - { -- unsigned long flags; -- unsigned int val[2]; -- int cpu_num = raw_smp_processor_id(); -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -- -- /* We should bind the task to the CPU */ -- BUG_ON(cpu_num != cpu); -- -- if (uci->mc.mc_intel == NULL) -- return -EINVAL; -- -- /* serialize access to the physical write to MSR 0x79 */ -- spin_lock_irqsave(µcode_update_lock, flags); -- -- /* write microcode via MSR 0x79 */ -- wrmsr(MSR_IA32_UCODE_WRITE, -- (unsigned long) uci->mc.mc_intel->bits, -- (unsigned long) uci->mc.mc_intel->bits >> 16 >> 16); -- wrmsr(MSR_IA32_UCODE_REV, 0, 0); -- -- /* see notes above for revision 1.07. Apparent chip bug */ -- sync_core(); -- -- /* get the current revision from MSR 0x8B */ -- rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]); -- -- spin_unlock_irqrestore(µcode_update_lock, flags); -- if (val[1] != uci->mc.mc_intel->hdr.rev) { -- printk(KERN_ERR "microcode: CPU%d update from revision " -- "0x%x to 0x%x failed\n", cpu_num, uci->cpu_sig.rev, val[1]); -- return -EIO; -- } -- printk(KERN_INFO "microcode: CPU%d updated from revision " -- "0x%x to 0x%x, date = %04x-%02x-%02x \n", -- cpu_num, uci->cpu_sig.rev, val[1], -- uci->mc.mc_intel->hdr.date & 0xffff, -- uci->mc.mc_intel->hdr.date >> 24, -- (uci->mc.mc_intel->hdr.date >> 16) & 0xff); -- uci->cpu_sig.rev = val[1]; -+ unsigned long flags; -+ unsigned int val[2]; -+ int cpu_num = raw_smp_processor_id(); -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; -+ -+ /* We should bind the task to the CPU */ -+ BUG_ON(cpu_num != cpu); -+ -+ if ( uci->mc.mc_intel == NULL ) -+ return -EINVAL; -+ -+ /* serialize access to the physical write to MSR 0x79 */ -+ spin_lock_irqsave(µcode_update_lock, flags); -+ -+ /* write microcode via MSR 0x79 */ -+ wrmsr(MSR_IA32_UCODE_WRITE, -+ (unsigned long) uci->mc.mc_intel->bits, -+ (unsigned long) uci->mc.mc_intel->bits >> 16 >> 16); -+ wrmsr(MSR_IA32_UCODE_REV, 0, 0); -+ -+ /* see notes above for revision 1.07. Apparent chip bug */ -+ sync_core(); -+ -+ /* get the current revision from MSR 0x8B */ -+ rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]); -+ -+ spin_unlock_irqrestore(µcode_update_lock, flags); -+ if ( val[1] != uci->mc.mc_intel->hdr.rev ) -+ { -+ printk(KERN_ERR "microcode: CPU%d update from revision " -+ "0x%x to 0x%x failed\n", cpu_num, uci->cpu_sig.rev, val[1]); -+ return -EIO; -+ } -+ printk(KERN_INFO "microcode: CPU%d updated from revision " -+ "0x%x to 0x%x, date = %04x-%02x-%02x \n", -+ cpu_num, uci->cpu_sig.rev, val[1], -+ uci->mc.mc_intel->hdr.date & 0xffff, -+ uci->mc.mc_intel->hdr.date >> 24, -+ (uci->mc.mc_intel->hdr.date >> 16) & 0xff); -+ uci->cpu_sig.rev = val[1]; - -- return 0; -+ return 0; - } - - static long get_next_ucode_from_buffer(void **mc, const u8 *buf, -- unsigned long size, long offset) -+ unsigned long size, long offset) - { -- struct microcode_header_intel *mc_header; -- unsigned long total_size; -+ struct microcode_header_intel *mc_header; -+ unsigned long total_size; - -- /* No more data */ -- if (offset >= size) -- return 0; -- mc_header = (struct microcode_header_intel *)(buf + offset); -- total_size = get_totalsize(mc_header); -- -- if (offset + total_size > size) { -- printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); -- return -EINVAL; -- } -- -- *mc = vmalloc(total_size); -- if (!*mc) { -- printk(KERN_ERR "microcode: error! Can not allocate memory\n"); -- return -ENOMEM; -- } -- memcpy(*mc, (const void *)(buf + offset), total_size); -- return offset + total_size; -+ /* No more data */ -+ if ( offset >= size ) -+ return 0; -+ mc_header = (struct microcode_header_intel *)(buf + offset); -+ total_size = get_totalsize(mc_header); -+ -+ if ( (offset + total_size) > size ) -+ { -+ printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); -+ return -EINVAL; -+ } -+ -+ *mc = xmalloc_bytes(total_size); -+ if ( *mc == NULL ) -+ { -+ printk(KERN_ERR "microcode: error! Can not allocate memory\n"); -+ return -ENOMEM; -+ } -+ memcpy(*mc, (const void *)(buf + offset), total_size); -+ return offset + total_size; - } - - /* fake device for request_firmware */ -@@ -368,58 +323,61 @@ extern struct platform_device *microcode - - static int cpu_request_microcode(int cpu, const void *buf, size_t size) - { -- long offset = 0; -- int error = 0; -- void *mc; -- -- /* We should bind the task to the CPU */ -- BUG_ON(cpu != raw_smp_processor_id()); -- -- while ((offset = get_next_ucode_from_buffer(&mc, buf, size, offset)) -- > 0) { -- error = microcode_sanity_check(mc); -- if (error) -- break; -- error = get_matching_microcode(mc, cpu); -- if (error < 0) -- break; -- /* -- * It's possible the data file has multiple matching ucode, -- * lets keep searching till the latest version -- */ -- if (error == 1) { -- apply_microcode(cpu); -- error = 0; -- } -- vfree(mc); -- } -- if (offset > 0) -- vfree(mc); -- if (offset < 0) -- error = offset; -+ long offset = 0; -+ int error = 0; -+ void *mc; -+ -+ /* We should bind the task to the CPU */ -+ BUG_ON(cpu != raw_smp_processor_id()); -+ -+ while ( (offset = get_next_ucode_from_buffer(&mc, buf, size, offset)) > 0 ) -+ { -+ error = microcode_sanity_check(mc); -+ if ( error ) -+ break; -+ error = get_matching_microcode(mc, cpu); -+ if ( error < 0 ) -+ break; -+ /* -+ * It's possible the data file has multiple matching ucode, -+ * lets keep searching till the latest version -+ */ -+ if ( error == 1 ) -+ { -+ apply_microcode(cpu); -+ error = 0; -+ } -+ xfree(mc); -+ } -+ if ( offset > 0 ) -+ xfree(mc); -+ if ( offset < 0 ) -+ error = offset; - -- return error; -+ return error; - } - - static void microcode_fini_cpu(int cpu) - { -- struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -+ struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - -- vfree(uci->mc.mc_intel); -- uci->mc.mc_intel = NULL; -+ xfree(uci->mc.mc_intel); -+ uci->mc.mc_intel = NULL; - } - - static struct microcode_ops microcode_intel_ops = { -- .get_matching_microcode = get_matching_microcode, -- .microcode_sanity_check = microcode_sanity_check, -- .cpu_request_microcode = cpu_request_microcode, -- .collect_cpu_info = collect_cpu_info, -- .apply_microcode = apply_microcode, -- .microcode_fini_cpu = microcode_fini_cpu, -+ .get_matching_microcode = get_matching_microcode, -+ .microcode_sanity_check = microcode_sanity_check, -+ .cpu_request_microcode = cpu_request_microcode, -+ .collect_cpu_info = collect_cpu_info, -+ .apply_microcode = apply_microcode, -+ .microcode_fini_cpu = microcode_fini_cpu, - }; - --int microcode_init_intel(struct cpuinfo_x86 *c) -+static __init int microcode_init_intel(void) - { -- microcode_ops = µcode_intel_ops; -- return 0; -+ if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL ) -+ microcode_ops = µcode_intel_ops; -+ return 0; - } -+__initcall(microcode_init_intel); -Index: xen-3.3.1-testing/xen/include/asm-x86/microcode.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/microcode.h -+++ xen-3.3.1-testing/xen/include/asm-x86/microcode.h -@@ -90,11 +90,8 @@ struct ucode_cpu_info { - void *valid_mc; - } mc; - }; --extern struct ucode_cpu_info ucode_cpu_info[]; - -+extern struct ucode_cpu_info ucode_cpu_info[]; - extern const struct microcode_ops *microcode_ops; - --int microcode_init_amd(struct cpuinfo_x86 *c); --int microcode_init_intel(struct cpuinfo_x86 *c); -- - #endif /* ASM_X86__MICROCODE_H */ diff --git a/18484-stubdom-ioemu-makefile.patch b/18484-stubdom-ioemu-makefile.patch deleted file mode 100644 index 1c80bd3..0000000 --- a/18484-stubdom-ioemu-makefile.patch +++ /dev/null @@ -1,85 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1221565466 -3600 -# Node ID f03b0cc33576e4fe3ff6adfd0853addf676c105e -# Parent 087b8b29b6b20165062697305c6651ca2acb7b5b -stubdom/ioemu link farm creation fixes - -Replace the stubdom/ioemu link farm creation in stubdom/Makefile, -with code which arranges that: - * No symlinks are made for output files - in particular, any - symlinks for .d files would be written through by the compiler - and cause damage to the original tree and other strange - behaviours - * All subdirectories are made as local subdirectories rather than - links - * Any interrupted or half-completed creation of the link farm - leaves the directory in a state where the link farming will be - restarted - * We use make's inherent ability to test for the existence of files - rather than using [ -f ... ] at the start of the rule's commands - * The list of files to be excluded from the link farm can be - easily updated -etc. - -This should fix some problems particularly with parallel builds, -or by-hand builds where directories are entered in other than the -usual order. - -Signed-off-by: Ian Jackson - -Index: xen-3.3.1-testing/stubdom/Makefile -=================================================================== ---- xen-3.3.1-testing.orig/stubdom/Makefile -+++ xen-3.3.1-testing/stubdom/Makefile -@@ -164,7 +164,26 @@ lwip-$(XEN_TARGET_ARCH): lwip-$(LWIP_VER - .PHONY: $(CROSS_ROOT) - $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci - --mk-headers-$(XEN_TARGET_ARCH): -+ioemu/linkfarm.stamp: $(XEN_ROOT)/tools/ioemu-dir -+ mkdir -p ioemu -+ifeq ($(CONFIG_QEMU),ioemu) -+ [ -h ioemu/Makefile ] || ( cd ioemu && \ -+ ln -sf ../$(XEN_ROOT)/tools/ioemu/* .) -+else -+ set -e; \ -+ $(absolutify_xen_root); \ -+ cd ioemu; \ -+ src="$$XEN_ROOT/tools/ioemu-dir"; export src; \ -+ (cd $$src && find * -type d -print) | xargs mkdir -p; \ -+ (cd $$src && find * ! -type l -type f $(addprefix ! -name , \ -+ '*.[oda1]' 'config-*' config.mak qemu-dm qemu-img-xen \ -+ '*.html' '*.pod' \ -+ )) | \ -+ while read f; do rm -f "$$f"; ln -s "$$src/$$f" "$$f"; done -+endif -+ touch ioemu/linkfarm.stamp -+ -+mk-headers-$(XEN_TARGET_ARCH): ioemu/linkfarm.stamp - mkdir -p include/xen && \ - ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/xen/include/public/*.h)) include/xen && \ - ln -sf $(addprefix ../../$(XEN_ROOT)/xen/include/public/,arch-ia64 arch-x86 hvm io xsm) include/xen && \ -@@ -183,22 +202,6 @@ mk-headers-$(XEN_TARGET_ARCH): - ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \ - ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \ - ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . ) -- mkdir -p ioemu --ifeq ($(CONFIG_QEMU),ioemu) -- [ -h ioemu/Makefile ] || ( cd ioemu && \ -- ln -sf ../$(XEN_ROOT)/tools/ioemu/* .) --else -- [ -h ioemu/Makefile ] || ( cd ioemu && \ -- ln -sf $(CONFIG_QEMU)/* . && \ -- rm -fr i386-dm && \ -- rm -fr i386-stubdom && \ -- mkdir i386-dm && \ -- mkdir i386-stubdom && \ -- ln -sf $(CONFIG_QEMU)/i386-dm/* i386-dm/ && \ -- ln -sf $(CONFIG_QEMU)/i386-stubdom/* i386-stubdom/ ) --endif -- [ ! -h ioemu/config-host.h ] || rm -f ioemu/config-host.h -- [ ! -h ioemu/config-host.mak ] || rm -f ioemu/config-host.mak - $(MAKE) -C $(MINI_OS) links - touch mk-headers-$(XEN_TARGET_ARCH) - diff --git a/18487-microcode-update-irq-context.patch b/18487-microcode-update-irq-context.patch deleted file mode 100644 index 675bdd1..0000000 --- a/18487-microcode-update-irq-context.patch +++ /dev/null @@ -1,149 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1221568859 -3600 -# Node ID 879330497672d96ee966c9774d21c437895f6839 -# Parent 88445b184dc666fc196cffab19eac75cd9c10b87 -x86, microcode: Do not run microcode update in IRQ context. - -It's unnecessary, and also invalid since the update process tries to -allocate memory. - -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/microcode.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/microcode.c -+++ xen-3.3.1-testing/xen/arch/x86/microcode.c -@@ -45,14 +45,13 @@ static DEFINE_SPINLOCK(microcode_mutex); - - struct ucode_cpu_info ucode_cpu_info[NR_CPUS]; - --struct microcode_buffer { -- void *buf; -- size_t size; -+struct microcode_info { -+ unsigned int cpu; -+ uint32_t buffer_size; -+ int error; -+ char buffer[1]; - }; - --static struct microcode_buffer microcode_buffer; --static bool_t microcode_error; -- - static void microcode_fini_cpu(int cpu) - { - struct ucode_cpu_info *uci = ucode_cpu_info + cpu; -@@ -110,14 +109,12 @@ static int microcode_resume_cpu(int cpu) - return err; - } - --static int microcode_update_cpu(int cpu, const void *buf, size_t size) -+static int microcode_update_cpu(const void *buf, size_t size) - { -- int err = 0; -+ int err; -+ unsigned int cpu = smp_processor_id(); - struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - -- /* We should bind the task to the CPU */ -- BUG_ON(raw_smp_processor_id() != cpu); -- - spin_lock(µcode_mutex); - - /* -@@ -140,72 +137,50 @@ static int microcode_update_cpu(int cpu, - return err; - } - --static void do_microcode_update_one(void *info) -+static long do_microcode_update(void *_info) - { -+ struct microcode_info *info = _info; - int error; - -- error = microcode_update_cpu( -- smp_processor_id(), microcode_buffer.buf, microcode_buffer.size); -+ BUG_ON(info->cpu != smp_processor_id()); - -- if ( error ) -- microcode_error = error; --} -+ error = microcode_update_cpu(info->buffer, info->buffer_size); - --static int do_microcode_update(void) --{ -- int error = 0; -- -- microcode_error = 0; -- -- if ( on_each_cpu(do_microcode_update_one, NULL, 1, 1) != 0 ) -- { -- printk(KERN_ERR "microcode: Error! Could not run on all processors\n"); -- error = -EIO; -- goto out; -- } -+ if ( error ) -+ info->error = error; - -- if ( microcode_error ) -- { -- error = microcode_error; -- goto out; -- } -+ info->cpu = next_cpu(info->cpu, cpu_online_map); -+ if ( info->cpu >= NR_CPUS ) -+ return info->error; - -- out: -- return error; -+ return continue_hypercall_on_cpu(info->cpu, do_microcode_update, info); - } - - int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len) - { - int ret; -+ struct microcode_info *info; - -- /* XXX FIXME: No allocations in interrupt context. */ -- return -EINVAL; -- -- if ( len != (typeof(microcode_buffer.size))len ) -- { -- printk(KERN_ERR "microcode: too much data\n"); -+ if ( len != (uint32_t)len ) - return -E2BIG; -- } - - if (microcode_ops == NULL) - return -EINVAL; - -- microcode_buffer.buf = xmalloc_array(uint8_t, len); -- if ( microcode_buffer.buf == NULL ) -+ info = xmalloc_bytes(sizeof(*info) + len); -+ if ( info == NULL ) - return -ENOMEM; - -- ret = copy_from_guest(microcode_buffer.buf, buf, len); -+ ret = copy_from_guest(info->buffer, buf, len); - if ( ret != 0 ) -+ { -+ xfree(info); - return ret; -+ } - -- microcode_buffer.size = len; -- wmb(); -- -- ret = do_microcode_update(); -- -- xfree(microcode_buffer.buf); -- microcode_buffer.buf = NULL; -- microcode_buffer.size = 0; -+ info->buffer_size = len; -+ info->error = 0; -+ info->cpu = first_cpu(cpu_online_map); - -- return ret; -+ return continue_hypercall_on_cpu(info->cpu, do_microcode_update, info); - } diff --git a/18488-microcode-free-fix.patch b/18488-microcode-free-fix.patch deleted file mode 100644 index 3d33dae..0000000 --- a/18488-microcode-free-fix.patch +++ /dev/null @@ -1,29 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1221569356 -3600 -# Node ID f163138e33402ca565d9886df8ecb21e98f77be6 -# Parent 879330497672d96ee966c9774d21c437895f6839 -x86, microcode: Free microcode_info struct at end of hypercall. -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/microcode.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/microcode.c -+++ xen-3.3.1-testing/xen/arch/x86/microcode.c -@@ -150,10 +150,13 @@ static long do_microcode_update(void *_i - info->error = error; - - info->cpu = next_cpu(info->cpu, cpu_online_map); -- if ( info->cpu >= NR_CPUS ) -- return info->error; -+ if ( info->cpu < NR_CPUS ) -+ return continue_hypercall_on_cpu(info->cpu, do_microcode_update, info); -+ -+ error = info->error; -+ xfree(info); -+ return error; - -- return continue_hypercall_on_cpu(info->cpu, do_microcode_update, info); - } - - int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len) diff --git a/18509-continue-hypercall-on-cpu.patch b/18509-continue-hypercall-on-cpu.patch deleted file mode 100644 index 4dbff08..0000000 --- a/18509-continue-hypercall-on-cpu.patch +++ /dev/null @@ -1,136 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1221657190 -3600 -# Node ID 366c78ff361bafb2271c551c4976e4caedea72b2 -# Parent beb28a3975bd39c93c7934dd5e7ec80c69a86c4a -x86: Allow continue_hypercall_on_cpu() to be called from within an -existing continuation handler. This fix is needed for the new method -of microcode re-programming. - -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/domain.c -+++ xen-3.3.1-testing/xen/arch/x86/domain.c -@@ -1356,6 +1356,7 @@ struct migrate_info { - void *data; - void (*saved_schedule_tail)(struct vcpu *); - cpumask_t saved_affinity; -+ unsigned int nest; - }; - - static void continue_hypercall_on_cpu_helper(struct vcpu *v) -@@ -1363,48 +1364,64 @@ static void continue_hypercall_on_cpu_he - struct cpu_user_regs *regs = guest_cpu_user_regs(); - struct migrate_info *info = v->arch.continue_info; - cpumask_t mask = info->saved_affinity; -+ void (*saved_schedule_tail)(struct vcpu *) = info->saved_schedule_tail; - - regs->eax = info->func(info->data); - -- v->arch.schedule_tail = info->saved_schedule_tail; -- v->arch.continue_info = NULL; -- -- xfree(info); -+ if ( info->nest-- == 0 ) -+ { -+ xfree(info); -+ v->arch.schedule_tail = saved_schedule_tail; -+ v->arch.continue_info = NULL; -+ vcpu_unlock_affinity(v, &mask); -+ } - -- vcpu_unlock_affinity(v, &mask); -- schedule_tail(v); -+ (*saved_schedule_tail)(v); - } - - int continue_hypercall_on_cpu(int cpu, long (*func)(void *data), void *data) - { - struct vcpu *v = current; - struct migrate_info *info; -+ cpumask_t mask = cpumask_of_cpu(cpu); - int rc; - - if ( cpu == smp_processor_id() ) - return func(data); - -- info = xmalloc(struct migrate_info); -+ info = v->arch.continue_info; - if ( info == NULL ) -- return -ENOMEM; -+ { -+ info = xmalloc(struct migrate_info); -+ if ( info == NULL ) -+ return -ENOMEM; - -- info->func = func; -- info->data = data; -- info->saved_schedule_tail = v->arch.schedule_tail; -- info->saved_affinity = cpumask_of_cpu(cpu); -+ rc = vcpu_lock_affinity(v, &mask); -+ if ( rc ) -+ { -+ xfree(info); -+ return rc; -+ } - -- v->arch.schedule_tail = continue_hypercall_on_cpu_helper; -- v->arch.continue_info = info; -+ info->saved_schedule_tail = v->arch.schedule_tail; -+ info->saved_affinity = mask; -+ info->nest = 0; - -- rc = vcpu_lock_affinity(v, &info->saved_affinity); -- if ( rc ) -+ v->arch.schedule_tail = continue_hypercall_on_cpu_helper; -+ v->arch.continue_info = info; -+ } -+ else - { -- v->arch.schedule_tail = info->saved_schedule_tail; -- v->arch.continue_info = NULL; -- xfree(info); -- return rc; -+ BUG_ON(info->nest != 0); -+ rc = vcpu_locked_change_affinity(v, &mask); -+ if ( rc ) -+ return rc; -+ info->nest++; - } - -+ info->func = func; -+ info->data = data; -+ - /* Dummy return value will be overwritten by new schedule_tail. */ - BUG_ON(!test_bit(SCHEDULE_SOFTIRQ, &softirq_pending(smp_processor_id()))); - return 0; -Index: xen-3.3.1-testing/xen/common/schedule.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/schedule.c -+++ xen-3.3.1-testing/xen/common/schedule.c -@@ -360,6 +360,11 @@ int vcpu_lock_affinity(struct vcpu *v, c - return __vcpu_set_affinity(v, affinity, 0, 1); - } - -+int vcpu_locked_change_affinity(struct vcpu *v, cpumask_t *affinity) -+{ -+ return __vcpu_set_affinity(v, affinity, 1, 1); -+} -+ - void vcpu_unlock_affinity(struct vcpu *v, cpumask_t *affinity) - { - cpumask_t online_affinity; -Index: xen-3.3.1-testing/xen/include/xen/sched.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/xen/sched.h -+++ xen-3.3.1-testing/xen/include/xen/sched.h -@@ -534,6 +534,7 @@ void vcpu_force_reschedule(struct vcpu * - void cpu_disable_scheduler(void); - int vcpu_set_affinity(struct vcpu *v, cpumask_t *affinity); - int vcpu_lock_affinity(struct vcpu *v, cpumask_t *affinity); -+int vcpu_locked_change_affinity(struct vcpu *v, cpumask_t *affinity); - void vcpu_unlock_affinity(struct vcpu *v, cpumask_t *affinity); - - void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate); diff --git a/18519-microcode-retval.patch b/18519-microcode-retval.patch deleted file mode 100644 index f024553..0000000 --- a/18519-microcode-retval.patch +++ /dev/null @@ -1,25 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1222087267 -3600 -# Node ID 3c42b5ad0a4f607749426f82ecf11f75d84699c5 -# Parent e61c7833dc9d87eb7fb41f47d2377370aa9a0b46 -x86,amd,microcode: fix hypercall return code - -Make the hypercall return failure if the microcode didn't apply. - -Signed-off-by: Christoph Egger - ---- a/xen/arch/x86/microcode_amd.c -+++ b/xen/arch/x86/microcode_amd.c -@@ -335,10 +335,7 @@ static int cpu_request_microcode(int cpu - * lets keep searching till the latest version - */ - if ( error == 1 ) -- { -- apply_microcode(cpu); -- error = 0; -- } -+ error = apply_microcode(cpu); - xfree(mc); - } - if ( offset > 0 ) diff --git a/18520-per-CPU-GDT.patch b/18520-per-CPU-GDT.patch deleted file mode 100644 index 6e74b93..0000000 --- a/18520-per-CPU-GDT.patch +++ /dev/null @@ -1,719 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1222087617 -3600 -# Node ID 7f1a36b834e183904f069948d3037d50492d98d2 -# Parent 3c42b5ad0a4f607749426f82ecf11f75d84699c5 -x86: make GDT per-CPU - -The major issue with supporting a significantly larger number of -physical CPUs appears to be the use of per-CPU GDT entries - at -present, x86-64 could support only up to 126 CPUs (with code changes -to also use the top-most GDT page, that would be 254). Instead of -trying to go with incremental steps here, by converting the GDT itself -to be per-CPU, limitations in that respect go away entirely. - -Signed-off-by: Jan Beulich - -Index: xen-3.3.1-testing/xen/arch/x86/boot/wakeup.S -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/boot/wakeup.S -+++ xen-3.3.1-testing/xen/arch/x86/boot/wakeup.S -@@ -167,7 +167,7 @@ wakeup_32: - .word 0,0,0 - lgdt_descr: - .word LAST_RESERVED_GDT_BYTE -- .quad gdt_table - FIRST_RESERVED_GDT_BYTE -+ .quad boot_cpu_gdt_table - FIRST_RESERVED_GDT_BYTE - - wakeup_64: - lgdt lgdt_descr(%rip) -Index: xen-3.3.1-testing/xen/arch/x86/boot/x86_32.S -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/boot/x86_32.S -+++ xen-3.3.1-testing/xen/arch/x86/boot/x86_32.S -@@ -78,7 +78,7 @@ idt_descr: - .word 0 - gdt_descr: - .word LAST_RESERVED_GDT_BYTE -- .long gdt_table - FIRST_RESERVED_GDT_BYTE -+ .long boot_cpu_gdt_table - FIRST_RESERVED_GDT_BYTE - - - .align 32 -@@ -94,7 +94,7 @@ ENTRY(idle_pg_table) - #define GUEST_DESC(d) \ - .long ((MACH2PHYS_VIRT_END - 1) >> 12) & 0xffff, \ - ((MACH2PHYS_VIRT_END - 1) >> 12) & (0xf << 16) | (d) --ENTRY(gdt_table) -+ENTRY(boot_cpu_gdt_table) - .quad 0x0000000000000000 /* unused */ - .quad 0x00cf9a000000ffff /* 0xe008 ring 0 4.00GB code at 0x0 */ - .quad 0x00cf92000000ffff /* 0xe010 ring 0 4.00GB data at 0x0 */ -@@ -102,4 +102,6 @@ ENTRY(gdt_table) - GUEST_DESC(0x00c0b200) /* 0xe021 ring 1 3.xxGB data at 0x0 */ - GUEST_DESC(0x00c0fa00) /* 0xe02b ring 3 3.xxGB code at 0x0 */ - GUEST_DESC(0x00c0f200) /* 0xe033 ring 3 3.xxGB data at 0x0 */ -+ .fill (PER_CPU_GDT_ENTRY - FLAT_RING3_DS / 8 - 1), 8, 0 -+ .quad 0x0000910000000000 /* per-CPU entry (limit == cpu) */ - .align PAGE_SIZE,0 -Index: xen-3.3.1-testing/xen/arch/x86/boot/x86_64.S -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/boot/x86_64.S -+++ xen-3.3.1-testing/xen/arch/x86/boot/x86_64.S -@@ -85,7 +85,7 @@ multiboot_ptr: - .word 0 - gdt_descr: - .word LAST_RESERVED_GDT_BYTE -- .quad gdt_table - FIRST_RESERVED_GDT_BYTE -+ .quad boot_cpu_gdt_table - FIRST_RESERVED_GDT_BYTE - - .word 0,0,0 - idt_descr: -@@ -96,7 +96,7 @@ ENTRY(stack_start) - .quad cpu0_stack - - .align PAGE_SIZE, 0 --ENTRY(gdt_table) -+ENTRY(boot_cpu_gdt_table) - .quad 0x0000000000000000 /* unused */ - .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode */ - .quad 0x00cf92000000ffff /* 0xe010 ring 0 data */ -@@ -105,11 +105,13 @@ ENTRY(gdt_table) - .quad 0x00cff2000000ffff /* 0xe02b ring 3 data */ - .quad 0x00affa000000ffff /* 0xe033 ring 3 code, 64-bit mode */ - .quad 0x00cf9a000000ffff /* 0xe038 ring 0 code, compatibility */ -+ .fill (PER_CPU_GDT_ENTRY - __HYPERVISOR_CS32 / 8 - 1), 8, 0 -+ .quad 0x0000910000000000 /* per-CPU entry (limit == cpu) */ - - .align PAGE_SIZE, 0 - /* NB. Even rings != 0 get access to the full 4Gb, as only the */ - /* (compatibility) machine->physical mapping table lives there. */ --ENTRY(compat_gdt_table) -+ENTRY(boot_cpu_compat_gdt_table) - .quad 0x0000000000000000 /* unused */ - .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode */ - .quad 0x00cf92000000ffff /* 0xe010 ring 0 data */ -@@ -118,4 +120,6 @@ ENTRY(compat_gdt_table) - .quad 0x00cffa000000ffff /* 0xe02b ring 3 code, compatibility */ - .quad 0x00cff2000000ffff /* 0xe033 ring 3 data */ - .quad 0x00cf9a000000ffff /* 0xe038 ring 0 code, compatibility */ -+ .fill (PER_CPU_GDT_ENTRY - __HYPERVISOR_CS32 / 8 - 1), 8, 0 -+ .quad 0x0000910000000000 /* per-CPU entry (limit == cpu) */ - .align PAGE_SIZE, 0 -Index: xen-3.3.1-testing/xen/arch/x86/cpu/common.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/cpu/common.c -+++ xen-3.3.1-testing/xen/arch/x86/cpu/common.c -@@ -575,6 +575,9 @@ void __cpuinit cpu_init(void) - if (cpu_has_pat) - wrmsrl(MSR_IA32_CR_PAT, host_pat); - -+ /* Install correct page table. */ -+ write_ptbase(current); -+ - *(unsigned short *)(&gdt_load[0]) = LAST_RESERVED_GDT_BYTE; - *(unsigned long *)(&gdt_load[2]) = GDT_VIRT_START(current); - asm volatile ( "lgdt %0" : "=m" (gdt_load) ); -@@ -605,9 +608,6 @@ void __cpuinit cpu_init(void) - #define CD(register) asm volatile ( "mov %0,%%db" #register : : "r"(0UL) ); - CD(0); CD(1); CD(2); CD(3); /* no db4 and db5 */; CD(6); CD(7); - #undef CD -- -- /* Install correct page table. */ -- write_ptbase(current); - } - - #ifdef CONFIG_HOTPLUG_CPU -Index: xen-3.3.1-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/domain.c -+++ xen-3.3.1-testing/xen/arch/x86/domain.c -@@ -211,7 +211,6 @@ static inline int may_switch_mode(struct - - int switch_native(struct domain *d) - { -- l1_pgentry_t gdt_l1e; - unsigned int vcpuid; - - if ( d == NULL ) -@@ -223,12 +222,8 @@ int switch_native(struct domain *d) - - d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = 0; - -- /* switch gdt */ -- gdt_l1e = l1e_from_page(virt_to_page(gdt_table), PAGE_HYPERVISOR); - for ( vcpuid = 0; vcpuid < MAX_VIRT_CPUS; vcpuid++ ) - { -- d->arch.mm_perdomain_pt[((vcpuid << GDT_LDT_VCPU_SHIFT) + -- FIRST_RESERVED_GDT_PAGE)] = gdt_l1e; - if (d->vcpu[vcpuid]) - release_compat_l4(d->vcpu[vcpuid]); - } -@@ -238,7 +233,6 @@ int switch_native(struct domain *d) - - int switch_compat(struct domain *d) - { -- l1_pgentry_t gdt_l1e; - unsigned int vcpuid; - - if ( d == NULL ) -@@ -250,15 +244,11 @@ int switch_compat(struct domain *d) - - d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = 1; - -- /* switch gdt */ -- gdt_l1e = l1e_from_page(virt_to_page(compat_gdt_table), PAGE_HYPERVISOR); - for ( vcpuid = 0; vcpuid < MAX_VIRT_CPUS; vcpuid++ ) - { - if ( (d->vcpu[vcpuid] != NULL) && - (setup_compat_l4(d->vcpu[vcpuid]) != 0) ) - goto undo_and_fail; -- d->arch.mm_perdomain_pt[((vcpuid << GDT_LDT_VCPU_SHIFT) + -- FIRST_RESERVED_GDT_PAGE)] = gdt_l1e; - } - - domain_set_alloc_bitsize(d); -@@ -267,13 +257,10 @@ int switch_compat(struct domain *d) - - undo_and_fail: - d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = 0; -- gdt_l1e = l1e_from_page(virt_to_page(gdt_table), PAGE_HYPERVISOR); - while ( vcpuid-- != 0 ) - { - if ( d->vcpu[vcpuid] != NULL ) - release_compat_l4(d->vcpu[vcpuid]); -- d->arch.mm_perdomain_pt[((vcpuid << GDT_LDT_VCPU_SHIFT) + -- FIRST_RESERVED_GDT_PAGE)] = gdt_l1e; - } - return -ENOMEM; - } -@@ -322,7 +309,12 @@ int vcpu_initialise(struct vcpu *v) - if ( is_idle_domain(d) ) - { - v->arch.schedule_tail = continue_idle_domain; -- v->arch.cr3 = __pa(idle_pg_table); -+ if ( v->vcpu_id ) -+ v->arch.cr3 = d->vcpu[0]->arch.cr3; -+ else if ( !*idle_vcpu ) -+ v->arch.cr3 = __pa(idle_pg_table); -+ else if ( !(v->arch.cr3 = clone_idle_pagetable(v)) ) -+ return -ENOMEM; - } - - v->arch.guest_context.ctrlreg[4] = -@@ -349,8 +341,7 @@ int arch_domain_create(struct domain *d, - #ifdef __x86_64__ - struct page_info *pg; - #endif -- l1_pgentry_t gdt_l1e; -- int i, vcpuid, pdpt_order, paging_initialised = 0; -+ int i, pdpt_order, paging_initialised = 0; - int rc = -ENOMEM; - - d->arch.hvm_domain.hap_enabled = -@@ -369,18 +360,6 @@ int arch_domain_create(struct domain *d, - goto fail; - memset(d->arch.mm_perdomain_pt, 0, PAGE_SIZE << pdpt_order); - -- /* -- * Map Xen segments into every VCPU's GDT, irrespective of whether every -- * VCPU will actually be used. This avoids an NMI race during context -- * switch: if we take an interrupt after switching CR3 but before switching -- * GDT, and the old VCPU# is invalid in the new domain, we would otherwise -- * try to load CS from an invalid table. -- */ -- gdt_l1e = l1e_from_page(virt_to_page(gdt_table), PAGE_HYPERVISOR); -- for ( vcpuid = 0; vcpuid < MAX_VIRT_CPUS; vcpuid++ ) -- d->arch.mm_perdomain_pt[((vcpuid << GDT_LDT_VCPU_SHIFT) + -- FIRST_RESERVED_GDT_PAGE)] = gdt_l1e; -- - #if defined(__i386__) - - mapcache_domain_init(d); -@@ -1193,9 +1172,12 @@ static void paravirt_ctxt_switch_to(stru - static void __context_switch(void) - { - struct cpu_user_regs *stack_regs = guest_cpu_user_regs(); -- unsigned int cpu = smp_processor_id(); -+ unsigned int i, cpu = smp_processor_id(); - struct vcpu *p = per_cpu(curr_vcpu, cpu); - struct vcpu *n = current; -+ struct desc_struct *gdt; -+ struct page_info *page; -+ struct desc_ptr gdt_desc; - - ASSERT(p != n); - ASSERT(cpus_empty(n->vcpu_dirty_cpumask)); -@@ -1221,14 +1203,30 @@ static void __context_switch(void) - cpu_set(cpu, n->domain->domain_dirty_cpumask); - cpu_set(cpu, n->vcpu_dirty_cpumask); - -+ gdt = !is_pv_32on64_vcpu(n) ? per_cpu(gdt_table, cpu) : -+ per_cpu(compat_gdt_table, cpu); -+ page = virt_to_page(gdt); -+ for (i = 0; i < NR_RESERVED_GDT_PAGES; ++i) -+ { -+ l1e_write(n->domain->arch.mm_perdomain_pt + -+ (n->vcpu_id << GDT_LDT_VCPU_SHIFT) + -+ FIRST_RESERVED_GDT_PAGE + i, -+ l1e_from_page(page + i, __PAGE_HYPERVISOR)); -+ } -+ -+ if ( p->vcpu_id != n->vcpu_id ) -+ { -+ gdt_desc.limit = LAST_RESERVED_GDT_BYTE; -+ gdt_desc.base = (unsigned long)(gdt - FIRST_RESERVED_GDT_ENTRY); -+ asm volatile ( "lgdt %0" : : "m" (gdt_desc) ); -+ } -+ - write_ptbase(n); - - if ( p->vcpu_id != n->vcpu_id ) - { -- char gdt_load[10]; -- *(unsigned short *)(&gdt_load[0]) = LAST_RESERVED_GDT_BYTE; -- *(unsigned long *)(&gdt_load[2]) = GDT_VIRT_START(n); -- asm volatile ( "lgdt %0" : "=m" (gdt_load) ); -+ gdt_desc.base = GDT_VIRT_START(n); -+ asm volatile ( "lgdt %0" : : "m" (gdt_desc) ); - } - - if ( p->domain != n->domain ) -@@ -1279,8 +1277,6 @@ void context_switch(struct vcpu *prev, s - uint64_t efer = read_efer(); - if ( !(efer & EFER_SCE) ) - write_efer(efer | EFER_SCE); -- flush_tlb_one_local(GDT_VIRT_START(next) + -- FIRST_RESERVED_GDT_BYTE); - } - #endif - -Index: xen-3.3.1-testing/xen/arch/x86/domain_build.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/domain_build.c -+++ xen-3.3.1-testing/xen/arch/x86/domain_build.c -@@ -314,24 +314,11 @@ int __init construct_dom0( - #if defined(__x86_64__) - if ( compat32 ) - { -- l1_pgentry_t gdt_l1e; -- - d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = 1; - v->vcpu_info = (void *)&d->shared_info->compat.vcpu_info[0]; - - if ( nr_pages != (unsigned int)nr_pages ) - nr_pages = UINT_MAX; -- -- /* -- * Map compatibility Xen segments into every VCPU's GDT. See -- * arch_domain_create() for further comments. -- */ -- gdt_l1e = l1e_from_page(virt_to_page(compat_gdt_table), -- PAGE_HYPERVISOR); -- for ( i = 0; i < MAX_VIRT_CPUS; i++ ) -- d->arch.mm_perdomain_pt[((i << GDT_LDT_VCPU_SHIFT) + -- FIRST_RESERVED_GDT_PAGE)] = gdt_l1e; -- flush_tlb_one_local(GDT_LDT_VIRT_START + FIRST_RESERVED_GDT_BYTE); - } - #endif - -Index: xen-3.3.1-testing/xen/arch/x86/hvm/vmx/vmcs.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/hvm/vmx/vmcs.c -+++ xen-3.3.1-testing/xen/arch/x86/hvm/vmx/vmcs.c -@@ -446,7 +446,7 @@ static void vmx_set_host_env(struct vcpu - - __vmwrite(HOST_IDTR_BASE, (unsigned long)idt_tables[cpu]); - -- __vmwrite(HOST_TR_SELECTOR, __TSS(cpu) << 3); -+ __vmwrite(HOST_TR_SELECTOR, TSS_ENTRY << 3); - __vmwrite(HOST_TR_BASE, (unsigned long)&init_tss[cpu]); - - __vmwrite(HOST_SYSENTER_ESP, get_stack_bottom()); -Index: xen-3.3.1-testing/xen/arch/x86/setup.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/setup.c -+++ xen-3.3.1-testing/xen/arch/x86/setup.c -@@ -115,6 +115,12 @@ extern void early_cpu_init(void); - extern void vesa_init(void); - extern void vesa_mtrr_init(void); - -+DEFINE_PER_CPU(struct desc_struct *, gdt_table) = boot_cpu_gdt_table; -+#ifdef CONFIG_COMPAT -+DEFINE_PER_CPU(struct desc_struct *, compat_gdt_table) -+ = boot_cpu_compat_gdt_table; -+#endif -+ - struct tss_struct init_tss[NR_CPUS]; - - char __attribute__ ((__section__(".bss.stack_aligned"))) cpu0_stack[STACK_SIZE]; -@@ -224,6 +230,7 @@ static void __init percpu_init_areas(voi - static void __init init_idle_domain(void) - { - struct domain *idle_domain; -+ unsigned int i; - - /* Domain creation requires that scheduler structures are initialised. */ - scheduler_init(); -@@ -236,6 +243,12 @@ static void __init init_idle_domain(void - idle_vcpu[0] = this_cpu(curr_vcpu) = current; - - setup_idle_pagetable(); -+ -+ for (i = 0; i < NR_RESERVED_GDT_PAGES; ++i) -+ idle_domain->arch.mm_perdomain_pt[FIRST_RESERVED_GDT_PAGE + i] = -+ l1e_from_page(virt_to_page(boot_cpu_gdt_table) + i, -+ __PAGE_HYPERVISOR); -+ - } - - static void __init srat_detect_node(int cpu) -@@ -443,7 +456,6 @@ void __init __start_xen(unsigned long mb - parse_video_info(); - - set_current((struct vcpu *)0xfffff000); /* debug sanity */ -- idle_vcpu[0] = current; - set_processor_id(0); /* needed early, for smp_processor_id() */ - if ( cpu_has_efer ) - rdmsrl(MSR_EFER, this_cpu(efer)); -Index: xen-3.3.1-testing/xen/arch/x86/smpboot.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/smpboot.c -+++ xen-3.3.1-testing/xen/arch/x86/smpboot.c -@@ -828,10 +828,15 @@ static int __devinit do_boot_cpu(int api - */ - { - unsigned long boot_error; -+ unsigned int i; - int timeout; - unsigned long start_eip; - unsigned short nmi_high = 0, nmi_low = 0; - struct vcpu *v; -+ struct desc_struct *gdt; -+#ifdef __x86_64__ -+ struct page_info *page; -+#endif - - /* - * Save current MTRR state in case it was changed since early boot -@@ -857,6 +862,37 @@ static int __devinit do_boot_cpu(int api - /* Debug build: detect stack overflow by setting up a guard page. */ - memguard_guard_stack(stack_start.esp); - -+ gdt = per_cpu(gdt_table, cpu); -+ if (gdt == boot_cpu_gdt_table) { -+ i = get_order_from_pages(NR_RESERVED_GDT_PAGES); -+#ifdef __x86_64__ -+#ifdef CONFIG_COMPAT -+ page = alloc_domheap_pages(NULL, i, -+ MEMF_node(cpu_to_node(cpu))); -+ per_cpu(compat_gdt_table, cpu) = gdt = page_to_virt(page); -+ memcpy(gdt, boot_cpu_compat_gdt_table, -+ NR_RESERVED_GDT_PAGES * PAGE_SIZE); -+ gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a = cpu; -+#endif -+ page = alloc_domheap_pages(NULL, i, -+ MEMF_node(cpu_to_node(cpu))); -+ per_cpu(gdt_table, cpu) = gdt = page_to_virt(page); -+#else -+ per_cpu(gdt_table, cpu) = gdt = alloc_xenheap_pages(i); -+#endif -+ memcpy(gdt, boot_cpu_gdt_table, -+ NR_RESERVED_GDT_PAGES * PAGE_SIZE); -+ BUILD_BUG_ON(NR_CPUS > 0x10000); -+ gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a = cpu; -+ } -+ -+ for (i = 0; i < NR_RESERVED_GDT_PAGES; ++i) -+ v->domain->arch.mm_perdomain_pt -+ [(v->vcpu_id << GDT_LDT_VCPU_SHIFT) + -+ FIRST_RESERVED_GDT_PAGE + i] -+ = l1e_from_page(virt_to_page(gdt) + i, -+ __PAGE_HYPERVISOR); -+ - /* - * This grunge runs the startup process for - * the targeted processor. -Index: xen-3.3.1-testing/xen/arch/x86/traps.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/traps.c -+++ xen-3.3.1-testing/xen/arch/x86/traps.c -@@ -2978,13 +2978,13 @@ void set_intr_gate(unsigned int n, void - void set_tss_desc(unsigned int n, void *addr) - { - _set_tssldt_desc( -- gdt_table + __TSS(n) - FIRST_RESERVED_GDT_ENTRY, -+ per_cpu(gdt_table, n) + TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, - (unsigned long)addr, - offsetof(struct tss_struct, __cacheline_filler) - 1, - 9); - #ifdef CONFIG_COMPAT - _set_tssldt_desc( -- compat_gdt_table + __TSS(n) - FIRST_RESERVED_GDT_ENTRY, -+ per_cpu(compat_gdt_table, n) + TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, - (unsigned long)addr, - offsetof(struct tss_struct, __cacheline_filler) - 1, - 11); -Index: xen-3.3.1-testing/xen/arch/x86/x86_32/mm.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/x86_32/mm.c -+++ xen-3.3.1-testing/xen/arch/x86/x86_32/mm.c -@@ -132,6 +132,30 @@ void __init setup_idle_pagetable(void) - __PAGE_HYPERVISOR)); - } - -+unsigned long clone_idle_pagetable(struct vcpu *v) -+{ -+ unsigned int i; -+ struct domain *d = v->domain; -+ l3_pgentry_t *l3_table = v->arch.pae_l3_cache.table[0]; -+ l2_pgentry_t *l2_table = alloc_xenheap_page(); -+ -+ if ( !l2_table ) -+ return 0; -+ -+ memcpy(l3_table, idle_pg_table, L3_PAGETABLE_ENTRIES * sizeof(*l3_table)); -+ l3_table[l3_table_offset(PERDOMAIN_VIRT_START)] = -+ l3e_from_page(virt_to_page(l2_table), _PAGE_PRESENT); -+ -+ copy_page(l2_table, idle_pg_table_l2 + -+ l3_table_offset(PERDOMAIN_VIRT_START) * L2_PAGETABLE_ENTRIES); -+ for ( i = 0; i < PDPT_L2_ENTRIES; ++i ) -+ l2_table[l2_table_offset(PERDOMAIN_VIRT_START) + i] = -+ l2e_from_page(virt_to_page(d->arch.mm_perdomain_pt) + i, -+ __PAGE_HYPERVISOR); -+ -+ return __pa(l3_table); -+} -+ - void __init zap_low_mappings(l2_pgentry_t *dom0_l2) - { - int i; -@@ -186,7 +210,7 @@ void __init subarch_init_memory(void) - { - /* Guest kernel runs in ring 0, not ring 1. */ - struct desc_struct *d; -- d = &gdt_table[(FLAT_RING1_CS >> 3) - FIRST_RESERVED_GDT_ENTRY]; -+ d = &boot_cpu_gdt_table[(FLAT_RING1_CS >> 3) - FIRST_RESERVED_GDT_ENTRY]; - d[0].b &= ~_SEGMENT_DPL; - d[1].b &= ~_SEGMENT_DPL; - } -Index: xen-3.3.1-testing/xen/arch/x86/x86_32/supervisor_mode_kernel.S -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/x86_32/supervisor_mode_kernel.S -+++ xen-3.3.1-testing/xen/arch/x86/x86_32/supervisor_mode_kernel.S -@@ -100,15 +100,10 @@ ENTRY(fixup_ring0_guest_stack) - # %gs:%esi now points to the guest stack before the - # interrupt/exception occured. - -- /* -- * Reverse the __TSS macro, giving us the CPU number. -- * The TSS for this cpu is at init_tss + ( cpu * 128 ). -- */ -- str %ecx -- shrl $3,%ecx # Calculate GDT index for TSS. -- subl $(FIRST_RESERVED_GDT_ENTRY+8),%ecx # %ecx = 2*cpu. -- shll $6,%ecx # Each TSS entry is 0x80 bytes -- addl $init_tss,%ecx # but we have 2*cpu from above. -+ movl $PER_CPU_GDT_ENTRY*8,%ecx -+ lsll %ecx,%ecx -+ shll $7,%ecx # Each TSS entry is 0x80 bytes -+ addl $init_tss,%ecx - - # Load Xen stack from TSS. - movw TSS_ss0(%ecx),%ax -Index: xen-3.3.1-testing/xen/arch/x86/x86_32/traps.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/x86_32/traps.c -+++ xen-3.3.1-testing/xen/arch/x86/x86_32/traps.c -@@ -194,13 +194,15 @@ static unsigned char doublefault_stack[D - - asmlinkage void do_double_fault(void) - { -- struct tss_struct *tss = &doublefault_tss; -- unsigned int cpu = ((tss->back_link>>3)-__FIRST_TSS_ENTRY)>>1; -+ struct tss_struct *tss; -+ unsigned int cpu; - - watchdog_disable(); - - console_force_unlock(); - -+ asm ( "lsll %1, %0" : "=r" (cpu) : "rm" (PER_CPU_GDT_ENTRY << 3) ); -+ - /* Find information saved during fault and dump it to the console. */ - tss = &init_tss[cpu]; - printk("*** DOUBLE FAULT ***\n"); -@@ -325,7 +327,7 @@ void __devinit subarch_percpu_traps_init - tss->eflags = 2; - tss->bitmap = IOBMP_INVALID_OFFSET; - _set_tssldt_desc( -- gdt_table + __DOUBLEFAULT_TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, -+ boot_cpu_gdt_table + __DOUBLEFAULT_TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, - (unsigned long)tss, 235, 9); - - set_task_gate(TRAP_double_fault, __DOUBLEFAULT_TSS_ENTRY<<3); -Index: xen-3.3.1-testing/xen/arch/x86/x86_64/mm.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/x86_64/mm.c -+++ xen-3.3.1-testing/xen/arch/x86/x86_64/mm.c -@@ -21,6 +21,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -206,6 +207,24 @@ void __init setup_idle_pagetable(void) - __PAGE_HYPERVISOR)); - } - -+unsigned long clone_idle_pagetable(struct vcpu *v) -+{ -+ struct domain *d = v->domain; -+ struct page_info *page = alloc_domheap_page(NULL, -+ MEMF_node(vcpu_to_node(v))); -+ l4_pgentry_t *l4_table = page_to_virt(page); -+ -+ if ( !page ) -+ return 0; -+ -+ copy_page(l4_table, idle_pg_table); -+ l4_table[l4_table_offset(PERDOMAIN_VIRT_START)] = -+ l4e_from_page(virt_to_page(d->arch.mm_perdomain_l3), -+ __PAGE_HYPERVISOR); -+ -+ return __pa(l4_table); -+} -+ - void __init zap_low_mappings(void) - { - BUG_ON(num_online_cpus() != 1); -Index: xen-3.3.1-testing/xen/arch/x86/x86_64/traps.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/x86_64/traps.c -+++ xen-3.3.1-testing/xen/arch/x86/x86_64/traps.c -@@ -213,15 +213,14 @@ void show_page_walk(unsigned long addr) - asmlinkage void double_fault(void); - asmlinkage void do_double_fault(struct cpu_user_regs *regs) - { -- unsigned int cpu, tr; -- -- asm volatile ( "str %0" : "=r" (tr) ); -- cpu = ((tr >> 3) - __FIRST_TSS_ENTRY) >> 2; -+ unsigned int cpu; - - watchdog_disable(); - - console_force_unlock(); - -+ asm ( "lsll %1, %0" : "=r" (cpu) : "rm" (PER_CPU_GDT_ENTRY << 3) ); -+ - /* Find information saved during fault and dump it to the console. */ - printk("*** DOUBLE FAULT ***\n"); - print_xen_info(); -Index: xen-3.3.1-testing/xen/include/asm-x86/desc.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/desc.h -+++ xen-3.3.1-testing/xen/include/asm-x86/desc.h -@@ -34,11 +34,9 @@ - #define FLAT_COMPAT_USER_CS FLAT_COMPAT_RING3_CS - #define FLAT_COMPAT_USER_SS FLAT_COMPAT_RING3_SS - --#define __FIRST_TSS_ENTRY (FIRST_RESERVED_GDT_ENTRY + 8) --#define __FIRST_LDT_ENTRY (__FIRST_TSS_ENTRY + 2) -- --#define __TSS(n) (((n)<<2) + __FIRST_TSS_ENTRY) --#define __LDT(n) (((n)<<2) + __FIRST_LDT_ENTRY) -+#define TSS_ENTRY (FIRST_RESERVED_GDT_ENTRY + 8) -+#define LDT_ENTRY (TSS_ENTRY + 2) -+#define PER_CPU_GDT_ENTRY (LDT_ENTRY + 2) - - #elif defined(__i386__) - -@@ -51,17 +49,15 @@ - - #define __DOUBLEFAULT_TSS_ENTRY FIRST_RESERVED_GDT_ENTRY - --#define __FIRST_TSS_ENTRY (FIRST_RESERVED_GDT_ENTRY + 8) --#define __FIRST_LDT_ENTRY (__FIRST_TSS_ENTRY + 1) -- --#define __TSS(n) (((n)<<1) + __FIRST_TSS_ENTRY) --#define __LDT(n) (((n)<<1) + __FIRST_LDT_ENTRY) -+#define TSS_ENTRY (FIRST_RESERVED_GDT_ENTRY + 8) -+#define LDT_ENTRY (TSS_ENTRY + 1) -+#define PER_CPU_GDT_ENTRY (LDT_ENTRY + 1) - - #endif - - #ifndef __ASSEMBLY__ - --#define load_TR(n) __asm__ __volatile__ ("ltr %%ax" : : "a" (__TSS(n)<<3) ) -+#define load_TR(n) __asm__ __volatile__ ("ltr %%ax" : : "a" (TSS_ENTRY<<3) ) - - #if defined(__x86_64__) - #define GUEST_KERNEL_RPL(d) (is_pv_32bit_domain(d) ? 1 : 3) -@@ -205,11 +201,19 @@ do { - - #endif - --extern struct desc_struct gdt_table[]; -+struct desc_ptr { -+ unsigned short limit; -+ unsigned long base; -+} __attribute__((__packed__)) ; -+ -+extern struct desc_struct boot_cpu_gdt_table[]; -+DECLARE_PER_CPU(struct desc_struct *, gdt_table); - #ifdef CONFIG_COMPAT --extern struct desc_struct compat_gdt_table[]; -+extern struct desc_struct boot_cpu_compat_gdt_table[]; -+DECLARE_PER_CPU(struct desc_struct *, compat_gdt_table); - #else --# define compat_gdt_table gdt_table -+# define boot_cpu_compat_gdt_table boot_cpu_gdt_table -+# define per_cpu__compat_gdt_table per_cpu__gdt_table - #endif - - extern void set_intr_gate(unsigned int irq, void * addr); -Index: xen-3.3.1-testing/xen/include/asm-x86/ldt.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/ldt.h -+++ xen-3.3.1-testing/xen/include/asm-x86/ldt.h -@@ -6,7 +6,6 @@ - - static inline void load_LDT(struct vcpu *v) - { -- unsigned int cpu; - struct desc_struct *desc; - unsigned long ents; - -@@ -16,11 +15,11 @@ static inline void load_LDT(struct vcpu - } - else - { -- cpu = smp_processor_id(); -- desc = (!is_pv_32on64_vcpu(v) ? gdt_table : compat_gdt_table) -- + __LDT(cpu) - FIRST_RESERVED_GDT_ENTRY; -+ desc = (!is_pv_32on64_vcpu(v) -+ ? this_cpu(gdt_table) : this_cpu(compat_gdt_table)) -+ + LDT_ENTRY - FIRST_RESERVED_GDT_ENTRY; - _set_tssldt_desc(desc, LDT_VIRT_START(v), ents*8-1, 2); -- __asm__ __volatile__ ( "lldt %%ax" : : "a" (__LDT(cpu)<<3) ); -+ __asm__ __volatile__ ( "lldt %%ax" : : "a" (LDT_ENTRY << 3) ); - } - } - -Index: xen-3.3.1-testing/xen/include/asm-x86/page.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/page.h -+++ xen-3.3.1-testing/xen/include/asm-x86/page.h -@@ -278,6 +278,7 @@ extern unsigned int m2p_compat_vstart; - #endif - void paging_init(void); - void setup_idle_pagetable(void); -+unsigned long clone_idle_pagetable(struct vcpu *); - #endif /* !defined(__ASSEMBLY__) */ - - #define _PAGE_PRESENT 0x001U diff --git a/18521-per-CPU-TSS.patch b/18521-per-CPU-TSS.patch deleted file mode 100644 index 0dabfd9..0000000 --- a/18521-per-CPU-TSS.patch +++ /dev/null @@ -1,128 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1222088424 -3600 -# Node ID 6d3b932cbecac19bf71d7be51e4f4489089ed753 -# Parent 7f1a36b834e183904f069948d3037d50492d98d2 -i386: make double fault TSS per-CPU - -As a follow-up to the per-CPU-GDT patch, this also makes the double -fault TSS (and the associated stack) per-CPU. - -Signed-off-by: Jan Beulich - -Index: xen-3.3.1-testing/xen/arch/x86/boot/x86_32.S -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/boot/x86_32.S -+++ xen-3.3.1-testing/xen/arch/x86/boot/x86_32.S -@@ -95,7 +95,7 @@ ENTRY(idle_pg_table) - .long ((MACH2PHYS_VIRT_END - 1) >> 12) & 0xffff, \ - ((MACH2PHYS_VIRT_END - 1) >> 12) & (0xf << 16) | (d) - ENTRY(boot_cpu_gdt_table) -- .quad 0x0000000000000000 /* unused */ -+ .quad 0x0000000000000000 /* double fault TSS */ - .quad 0x00cf9a000000ffff /* 0xe008 ring 0 4.00GB code at 0x0 */ - .quad 0x00cf92000000ffff /* 0xe010 ring 0 4.00GB data at 0x0 */ - GUEST_DESC(0x00c0ba00) /* 0xe019 ring 1 3.xxGB code at 0x0 */ -Index: xen-3.3.1-testing/xen/arch/x86/smpboot.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/smpboot.c -+++ xen-3.3.1-testing/xen/arch/x86/smpboot.c -@@ -893,6 +893,13 @@ static int __devinit do_boot_cpu(int api - = l1e_from_page(virt_to_page(gdt) + i, - __PAGE_HYPERVISOR); - -+#ifdef __i386__ -+ if (!per_cpu(doublefault_tss, cpu)) { -+ per_cpu(doublefault_tss, cpu) = alloc_xenheap_page(); -+ memset(per_cpu(doublefault_tss, cpu), 0, PAGE_SIZE); -+ } -+#endif -+ - /* - * This grunge runs the startup process for - * the targeted processor. -Index: xen-3.3.1-testing/xen/arch/x86/x86_32/traps.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/x86_32/traps.c -+++ xen-3.3.1-testing/xen/arch/x86/x86_32/traps.c -@@ -188,9 +188,9 @@ void show_page_walk(unsigned long addr) - unmap_domain_page(l1t); - } - --#define DOUBLEFAULT_STACK_SIZE 2048 --static struct tss_struct doublefault_tss; --static unsigned char doublefault_stack[DOUBLEFAULT_STACK_SIZE]; -+DEFINE_PER_CPU(struct tss_struct *, doublefault_tss); -+static unsigned char __attribute__ ((__section__ (".bss.page_aligned"))) -+ boot_cpu_doublefault_space[PAGE_SIZE]; - - asmlinkage void do_double_fault(void) - { -@@ -303,34 +303,36 @@ static void set_task_gate(unsigned int n - - void __devinit subarch_percpu_traps_init(void) - { -- struct tss_struct *tss = &doublefault_tss; -+ struct tss_struct *tss = this_cpu(doublefault_tss); - asmlinkage int hypercall(void); - -- if ( smp_processor_id() != 0 ) -- return; -+ if ( !tss ) -+ { -+ /* The hypercall entry vector is only accessible from ring 1. */ -+ _set_gate(idt_table+HYPERCALL_VECTOR, 14, 1, &hypercall); - -- /* The hypercall entry vector is only accessible from ring 1. */ -- _set_gate(idt_table+HYPERCALL_VECTOR, 14, 1, &hypercall); -+ tss = (void *)boot_cpu_doublefault_space; -+ this_cpu(doublefault_tss) = tss; -+ } - - /* - * Make a separate task for double faults. This will get us debug output if - * we blow the kernel stack. - */ -- memset(tss, 0, sizeof(*tss)); - tss->ds = __HYPERVISOR_DS; - tss->es = __HYPERVISOR_DS; - tss->ss = __HYPERVISOR_DS; -- tss->esp = (unsigned long)&doublefault_stack[DOUBLEFAULT_STACK_SIZE]; -+ tss->esp = (unsigned long)tss + PAGE_SIZE; - tss->__cr3 = __pa(idle_pg_table); - tss->cs = __HYPERVISOR_CS; - tss->eip = (unsigned long)do_double_fault; - tss->eflags = 2; - tss->bitmap = IOBMP_INVALID_OFFSET; - _set_tssldt_desc( -- boot_cpu_gdt_table + __DOUBLEFAULT_TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, -+ this_cpu(gdt_table) + DOUBLEFAULT_TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, - (unsigned long)tss, 235, 9); - -- set_task_gate(TRAP_double_fault, __DOUBLEFAULT_TSS_ENTRY<<3); -+ set_task_gate(TRAP_double_fault, DOUBLEFAULT_TSS_ENTRY << 3); - } - - void init_int80_direct_trap(struct vcpu *v) -Index: xen-3.3.1-testing/xen/include/asm-x86/desc.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/desc.h -+++ xen-3.3.1-testing/xen/include/asm-x86/desc.h -@@ -47,7 +47,7 @@ - #define FLAT_COMPAT_USER_DS FLAT_USER_DS - #define FLAT_COMPAT_USER_SS FLAT_USER_SS - --#define __DOUBLEFAULT_TSS_ENTRY FIRST_RESERVED_GDT_ENTRY -+#define DOUBLEFAULT_TSS_ENTRY FIRST_RESERVED_GDT_ENTRY - - #define TSS_ENTRY (FIRST_RESERVED_GDT_ENTRY + 8) - #define LDT_ENTRY (TSS_ENTRY + 1) -@@ -199,6 +199,8 @@ do { - (((u32)(addr) & 0x00FF0000U) >> 16); \ - } while (0) - -+DECLARE_PER_CPU(struct tss_struct *, doublefault_tss); -+ - #endif - - struct desc_ptr { diff --git a/18523-per-CPU-misc.patch b/18523-per-CPU-misc.patch deleted file mode 100644 index 616f729..0000000 --- a/18523-per-CPU-misc.patch +++ /dev/null @@ -1,201 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1222090651 -3600 -# Node ID c0db74e416626f34cf91b0eefe659bcfe8b43a35 -# Parent ae24b533dc9d0d5ce05b34a1ef72917589b4e63d -Fix misc issues related to allowing support of more CPUs - -This mainly means removing stack variables that (should) depend on -NR_CPUS (other than cpumask_t ones) and adjusting certain array sizes. - -There's at least one open tools issue: The 'xm vcpu-pin' path assumes -a maximum of 64 CPU-s in many places. - -Signed-off-by: Jan Beulich - -Index: xen-3.3.1-testing/xen/arch/x86/nmi.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/nmi.c -+++ xen-3.3.1-testing/xen/arch/x86/nmi.c -@@ -96,7 +96,7 @@ int nmi_active; - - int __init check_nmi_watchdog (void) - { -- unsigned int prev_nmi_count[NR_CPUS]; -+ static unsigned int __initdata prev_nmi_count[NR_CPUS]; - int cpu; - - if ( !nmi_watchdog ) -Index: xen-3.3.1-testing/xen/arch/x86/smpboot.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/smpboot.c -+++ xen-3.3.1-testing/xen/arch/x86/smpboot.c -@@ -1119,7 +1119,7 @@ static void __init smp_boot_cpus(unsigne - Dprintk("CPU present map: %lx\n", physids_coerce(phys_cpu_present_map)); - - kicked = 1; -- for (bit = 0; kicked < NR_CPUS && bit < MAX_APICS; bit++) { -+ for (bit = 0; kicked < NR_CPUS && bit < NR_CPUS; bit++) { - apicid = cpu_present_to_apicid(bit); - /* - * Don't even attempt to start the boot CPU! -Index: xen-3.3.1-testing/xen/arch/x86/x86_32/domain_page.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/x86_32/domain_page.c -+++ xen-3.3.1-testing/xen/arch/x86/x86_32/domain_page.c -@@ -201,6 +201,9 @@ void *map_domain_page_global(unsigned lo - - ASSERT(!in_irq() && local_irq_is_enabled()); - -+ /* At least half the ioremap space should be available to us. */ -+ BUILD_BUG_ON(IOREMAP_VIRT_START + (IOREMAP_MBYTES << 19) >= FIXADDR_START); -+ - spin_lock(&globalmap_lock); - - idx = find_next_zero_bit(inuse, GLOBALMAP_BITS, inuse_cursor); -Index: xen-3.3.1-testing/xen/common/domctl.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/domctl.c -+++ xen-3.3.1-testing/xen/common/domctl.c -@@ -145,16 +145,23 @@ static unsigned int default_vcpu0_locati - { - struct domain *d; - struct vcpu *v; -- unsigned int i, cpu, cnt[NR_CPUS] = { 0 }; -+ unsigned int i, cpu, nr_cpus, *cnt; - cpumask_t cpu_exclude_map; - - /* Do an initial CPU placement. Pick the least-populated CPU. */ -- rcu_read_lock(&domlist_read_lock); -- for_each_domain ( d ) -- for_each_vcpu ( d, v ) -- if ( !test_bit(_VPF_down, &v->pause_flags) ) -- cnt[v->processor]++; -- rcu_read_unlock(&domlist_read_lock); -+ nr_cpus = last_cpu(cpu_possible_map) + 1; -+ cnt = xmalloc_array(unsigned int, nr_cpus); -+ if ( cnt ) -+ { -+ memset(cnt, 0, nr_cpus * sizeof(*cnt)); -+ -+ rcu_read_lock(&domlist_read_lock); -+ for_each_domain ( d ) -+ for_each_vcpu ( d, v ) -+ if ( !test_bit(_VPF_down, &v->pause_flags) ) -+ cnt[v->processor]++; -+ rcu_read_unlock(&domlist_read_lock); -+ } - - /* - * If we're on a HT system, we only auto-allocate to a non-primary HT. We -@@ -172,10 +179,12 @@ static unsigned int default_vcpu0_locati - (cpus_weight(cpu_sibling_map[i]) > 1) ) - continue; - cpus_or(cpu_exclude_map, cpu_exclude_map, cpu_sibling_map[i]); -- if ( cnt[i] <= cnt[cpu] ) -+ if ( !cnt || cnt[i] <= cnt[cpu] ) - cpu = i; - } - -+ xfree(cnt); -+ - return cpu; - } - -Index: xen-3.3.1-testing/xen/common/sched_credit.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/sched_credit.c -+++ xen-3.3.1-testing/xen/common/sched_credit.c -@@ -1258,14 +1258,15 @@ csched_dump_pcpu(int cpu) - struct csched_pcpu *spc; - struct csched_vcpu *svc; - int loop; -+ char cpustr[100]; - - spc = CSCHED_PCPU(cpu); - runq = &spc->runq; - -- printk(" sort=%d, sibling=0x%lx, core=0x%lx\n", -- spc->runq_sort_last, -- cpu_sibling_map[cpu].bits[0], -- cpu_core_map[cpu].bits[0]); -+ cpumask_scnprintf(cpustr, sizeof(cpustr), cpu_sibling_map[cpu]); -+ printk(" sort=%d, sibling=%s, ", spc->runq_sort_last, cpustr); -+ cpumask_scnprintf(cpustr, sizeof(cpustr), cpu_core_map[cpu]); -+ printk("core=%s\n", cpustr); - - /* current VCPU */ - svc = CSCHED_VCPU(per_cpu(schedule_data, cpu).curr); -@@ -1292,6 +1293,7 @@ csched_dump(void) - { - struct list_head *iter_sdom, *iter_svc; - int loop; -+ char idlers_buf[100]; - - printk("info:\n" - "\tncpus = %u\n" -@@ -1317,7 +1319,8 @@ csched_dump(void) - CSCHED_TICKS_PER_TSLICE, - CSCHED_TICKS_PER_ACCT); - -- printk("idlers: 0x%lx\n", csched_priv.idlers.bits[0]); -+ cpumask_scnprintf(idlers_buf, sizeof(idlers_buf), csched_priv.idlers); -+ printk("idlers: %s\n", idlers_buf); - - CSCHED_STATS_PRINTK(); - -Index: xen-3.3.1-testing/xen/common/sched_sedf.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/sched_sedf.c -+++ xen-3.3.1-testing/xen/common/sched_sedf.c -@@ -1298,8 +1298,18 @@ static int sedf_adjust_weights(struct xe - { - struct vcpu *p; - struct domain *d; -- int sumw[NR_CPUS] = { 0 }; -- s_time_t sumt[NR_CPUS] = { 0 }; -+ unsigned int nr_cpus = last_cpu(cpu_possible_map) + 1; -+ int *sumw = xmalloc_array(int, nr_cpus); -+ s_time_t *sumt = xmalloc_array(s_time_t, nr_cpus); -+ -+ if ( !sumw || !sumt ) -+ { -+ xfree(sumt); -+ xfree(sumw); -+ return -ENOMEM; -+ } -+ memset(sumw, 0, nr_cpus * sizeof(*sumw)); -+ memset(sumt, 0, nr_cpus * sizeof(*sumt)); - - /* Sum across all weights. */ - rcu_read_lock(&domlist_read_lock); -@@ -1348,6 +1358,9 @@ static int sedf_adjust_weights(struct xe - } - rcu_read_unlock(&domlist_read_lock); - -+ xfree(sumt); -+ xfree(sumw); -+ - return 0; - } - -@@ -1356,6 +1369,7 @@ static int sedf_adjust_weights(struct xe - static int sedf_adjust(struct domain *p, struct xen_domctl_scheduler_op *op) - { - struct vcpu *v; -+ int rc; - - PRINT(2,"sedf_adjust was called, domain-id %i new period %"PRIu64" " - "new slice %"PRIu64"\nlatency %"PRIu64" extra:%s\n", -@@ -1411,8 +1425,9 @@ static int sedf_adjust(struct domain *p, - } - } - -- if ( sedf_adjust_weights(op) ) -- return -EINVAL; -+ rc = sedf_adjust_weights(op); -+ if ( rc ) -+ return rc; - - for_each_vcpu ( p, v ) - { diff --git a/18528-dump-evtchn.patch b/18528-dump-evtchn.patch deleted file mode 100644 index 605d504..0000000 --- a/18528-dump-evtchn.patch +++ /dev/null @@ -1,113 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1222095059 -3600 -# Node ID 81483e49c74c314ae3ed098c1373dfc3f2d3f31e -# Parent ae29cd95ba7d7f5cdcbb32509575b83e9fb3d43c -Add debug key 'e' for event channel information - -Signed-off-by: Jan Beulich - ---- a/xen/common/event_channel.c -+++ b/xen/common/event_channel.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - #include - - #include -@@ -1046,6 +1047,77 @@ void evtchn_destroy(struct domain *d) - spin_unlock(&d->evtchn_lock); - } - -+static void domain_dump_evtchn_info(struct domain *d) -+{ -+ unsigned int port; -+ -+ printk("Domain %d polling vCPUs: %08lx\n", d->domain_id, d->poll_mask[0]); -+ -+ if ( !spin_trylock(&d->evtchn_lock) ) -+ return; -+ -+ printk("Event channel information for domain %d:\n", -+ d->domain_id); -+ -+ for ( port = 1; port < MAX_EVTCHNS(d); ++port ) -+ { -+ const struct evtchn *chn; -+ -+ if ( !port_is_valid(d, port) ) -+ continue; -+ chn = evtchn_from_port(d, port); -+ if ( chn->state == ECS_FREE ) -+ continue; -+ -+ printk(" %4u[%d/%d]: s=%d n=%d", -+ port, -+ test_bit(port, &shared_info(d, evtchn_pending)), -+ test_bit(port, &shared_info(d, evtchn_mask)), -+ chn->state, chn->notify_vcpu_id); -+ switch ( chn->state ) -+ { -+ case ECS_UNBOUND: -+ printk(" d=%d", chn->u.unbound.remote_domid); -+ break; -+ case ECS_INTERDOMAIN: -+ printk(" d=%d p=%d", -+ chn->u.interdomain.remote_dom->domain_id, -+ chn->u.interdomain.remote_port); -+ break; -+ case ECS_PIRQ: -+ printk(" p=%d", chn->u.pirq); -+ break; -+ case ECS_VIRQ: -+ printk(" v=%d", chn->u.virq); -+ break; -+ } -+ printk(" x=%d\n", chn->consumer_is_xen); -+ } -+ -+ spin_unlock(&d->evtchn_lock); -+} -+ -+static void dump_evtchn_info(unsigned char key) -+{ -+ struct domain *d; -+ -+ printk("'%c' pressed -> dumping event-channel info\n", key); -+ -+ rcu_read_lock(&domlist_read_lock); -+ -+ for_each_domain ( d ) -+ domain_dump_evtchn_info(d); -+ -+ rcu_read_unlock(&domlist_read_lock); -+} -+ -+static int __init dump_evtchn_info_key_init(void) -+{ -+ register_keyhandler('e', dump_evtchn_info, "dump evtchn info"); -+ return 0; -+} -+__initcall(dump_evtchn_info_key_init); -+ - /* - * Local variables: - * mode: C ---- a/xen/common/keyhandler.c -+++ b/xen/common/keyhandler.c -@@ -204,11 +204,11 @@ static void dump_domains(unsigned char k - printk("VCPU information and callbacks for domain %u:\n", - d->domain_id); - for_each_vcpu ( d, v ) { -- printk(" VCPU%d: CPU%d [has=%c] flags=%lx " -+ printk(" VCPU%d: CPU%d [has=%c] flags=%lx poll=%d " - "upcall_pend = %02x, upcall_mask = %02x ", - v->vcpu_id, v->processor, - v->is_running ? 'T':'F', -- v->pause_flags, -+ v->pause_flags, v->poll_evtchn, - vcpu_info(v, evtchn_upcall_pending), - vcpu_info(v, evtchn_upcall_mask)); - cpuset_print(tmpstr, sizeof(tmpstr), v->vcpu_dirty_cpumask); diff --git a/18539-pirq-vector-mapping.patch b/18539-pirq-vector-mapping.patch deleted file mode 100644 index 8f8eabd..0000000 --- a/18539-pirq-vector-mapping.patch +++ /dev/null @@ -1,654 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1222256215 -3600 -# Node ID 31f09a5e24cf8eb8a9d73acc6c23262fe9d463d7 -# Parent 7750906b06b3ebbba529e6d1042d7a2a2712623c -x86: Properly synchronise updates to pirq-to-vector mapping. - -Per-domain irq mappings are now protected by d->evtchn_lock and by the -per-vector irq_desc lock. - -Signed-off-by: Jan Beulich -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/ia64/xen/irq.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/ia64/xen/irq.c -+++ xen-3.3.1-testing/xen/arch/ia64/xen/irq.c -@@ -459,20 +459,24 @@ int pirq_guest_bind(struct vcpu *v, int - return rc; - } - --void pirq_guest_unbind(struct domain *d, int irq) -+int pirq_guest_unbind(struct domain *d, int irq) - { - irq_desc_t *desc = &irq_desc[irq]; - irq_guest_action_t *action; - unsigned long flags; -- int i; -+ int i, rc = 0; - - spin_lock_irqsave(&desc->lock, flags); - - action = (irq_guest_action_t *)desc->action; - -- i = 0; -- while ( action->guest[i] && (action->guest[i] != d) ) -- i++; -+ for ( i = 0; (i < action->nr_guests) && (action->guest[i] != d); i++ ) -+ continue; -+ if ( i == action->nr_guests ) -+ { -+ rc = -EINVAL; -+ goto out; -+ } - memmove(&action->guest[i], &action->guest[i+1], IRQ_MAX_GUESTS-i-1); - action->nr_guests--; - -@@ -492,7 +496,9 @@ void pirq_guest_unbind(struct domain *d, - desc->handler->shutdown(irq); - } - -+ out: - spin_unlock_irqrestore(&desc->lock, flags); -+ return rc; - } - - void -Index: xen-3.3.1-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/domain.c -+++ xen-3.3.1-testing/xen/arch/x86/domain.c -@@ -414,8 +414,6 @@ int arch_domain_create(struct domain *d, - goto fail; - } - -- spin_lock_init(&d->arch.irq_lock); -- - if ( is_hvm_domain(d) ) - { - if ( (rc = hvm_domain_initialise(d)) != 0 ) -Index: xen-3.3.1-testing/xen/arch/x86/io_apic.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/io_apic.c -+++ xen-3.3.1-testing/xen/arch/x86/io_apic.c -@@ -48,22 +48,6 @@ atomic_t irq_mis_count; - int msi_enable = 0; - boolean_param("msi", msi_enable); - --int domain_irq_to_vector(struct domain *d, int irq) --{ -- if ( !msi_enable ) -- return irq_to_vector(irq); -- else -- return d->arch.pirq_vector[irq]; --} -- --int domain_vector_to_irq(struct domain *d, int vector) --{ -- if ( !msi_enable ) -- return vector_to_irq(vector); -- else -- return d->arch.vector_pirq[vector]; --} -- - /* Where if anywhere is the i8259 connect in external int mode */ - static struct { int pin, apic; } ioapic_i8259 = { -1, -1 }; - -@@ -730,7 +714,6 @@ next: - - static struct hw_interrupt_type ioapic_level_type; - static struct hw_interrupt_type ioapic_edge_type; --struct hw_interrupt_type pci_msi_type; - - #define IOAPIC_AUTO -1 - #define IOAPIC_EDGE 0 -Index: xen-3.3.1-testing/xen/arch/x86/irq.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/irq.c -+++ xen-3.3.1-testing/xen/arch/x86/irq.c -@@ -277,6 +277,35 @@ static void __do_IRQ_guest(int vector) - } - } - -+/* -+ * Retrieve Xen irq-descriptor corresponding to a domain-specific irq. -+ * The descriptor is returned locked. This function is safe against changes -+ * to the per-domain irq-to-vector mapping. -+ */ -+static irq_desc_t *domain_spin_lock_irq_desc( -+ struct domain *d, int irq, unsigned long *pflags) -+{ -+ unsigned int vector; -+ unsigned long flags; -+ irq_desc_t *desc; -+ -+ for ( ; ; ) -+ { -+ vector = domain_irq_to_vector(d, irq); -+ if ( vector <= 0 ) -+ return NULL; -+ desc = &irq_desc[vector]; -+ spin_lock_irqsave(&desc->lock, flags); -+ if ( vector == domain_irq_to_vector(d, irq) ) -+ break; -+ spin_unlock_irqrestore(&desc->lock, flags); -+ } -+ -+ if ( pflags != NULL ) -+ *pflags = flags; -+ return desc; -+} -+ - /* Flush all ready EOIs from the top of this CPU's pending-EOI stack. */ - static void flush_ready_eoi(void *unused) - { -@@ -342,11 +371,13 @@ static void __pirq_guest_eoi(struct doma - cpumask_t cpu_eoi_map; - int vector; - -- vector = domain_irq_to_vector(d, irq); -- desc = &irq_desc[vector]; -- action = (irq_guest_action_t *)desc->action; -+ ASSERT(local_irq_is_enabled()); -+ desc = domain_spin_lock_irq_desc(d, irq, NULL); -+ if ( desc == NULL ) -+ return; - -- spin_lock_irq(&desc->lock); -+ action = (irq_guest_action_t *)desc->action; -+ vector = desc - irq_desc; - - ASSERT(!test_bit(irq, d->pirq_mask) || - (action->ack_type != ACKTYPE_NONE)); -@@ -418,7 +449,7 @@ int pirq_acktype(struct domain *d, int i - unsigned int vector; - - vector = domain_irq_to_vector(d, irq); -- if ( vector == 0 ) -+ if ( vector <= 0 ) - return ACKTYPE_NONE; - - desc = &irq_desc[vector]; -@@ -447,13 +478,6 @@ int pirq_acktype(struct domain *d, int i - if ( !strcmp(desc->handler->typename, "XT-PIC") ) - return ACKTYPE_UNMASK; - -- if ( strstr(desc->handler->typename, "MPIC") ) -- { -- if ( desc->status & IRQ_LEVEL ) -- return (desc->status & IRQ_PER_CPU) ? ACKTYPE_EOI : ACKTYPE_UNMASK; -- return ACKTYPE_NONE; /* edge-triggered => no final EOI */ -- } -- - printk("Unknown PIC type '%s' for IRQ %d\n", desc->handler->typename, irq); - BUG(); - -@@ -462,21 +486,18 @@ int pirq_acktype(struct domain *d, int i - - int pirq_shared(struct domain *d, int irq) - { -- unsigned int vector; - irq_desc_t *desc; - irq_guest_action_t *action; - unsigned long flags; - int shared; - -- vector = domain_irq_to_vector(d, irq); -- if ( vector == 0 ) -+ desc = domain_spin_lock_irq_desc(d, irq, &flags); -+ if ( desc == NULL ) - return 0; - -- desc = &irq_desc[vector]; -- -- spin_lock_irqsave(&desc->lock, flags); - action = (irq_guest_action_t *)desc->action; - shared = ((desc->status & IRQ_GUEST) && (action->nr_guests > 1)); -+ - spin_unlock_irqrestore(&desc->lock, flags); - - return shared; -@@ -489,20 +510,17 @@ int pirq_guest_bind(struct vcpu *v, int - irq_guest_action_t *action, *newaction = NULL; - int rc = 0; - cpumask_t cpumask = CPU_MASK_NONE; -+ unsigned long flags; - -- retry: -- vector = domain_irq_to_vector(v->domain, irq); -- if ( vector == 0 ) -- { -- rc = -EINVAL; -- goto out; -- } -- -- desc = &irq_desc[vector]; -+ WARN_ON(!spin_is_locked(&v->domain->evtchn_lock)); - -- spin_lock_irq(&desc->lock); -+ retry: -+ desc = domain_spin_lock_irq_desc(v->domain, irq, &flags); -+ if ( desc == NULL ) -+ return -EINVAL; - - action = (irq_guest_action_t *)desc->action; -+ vector = desc - irq_desc; - - if ( !(desc->status & IRQ_GUEST) ) - { -@@ -517,7 +535,7 @@ int pirq_guest_bind(struct vcpu *v, int - - if ( newaction == NULL ) - { -- spin_unlock_irq(&desc->lock); -+ spin_unlock_irqrestore(&desc->lock, flags); - if ( (newaction = xmalloc(irq_guest_action_t)) != NULL ) - goto retry; - gdprintk(XENLOG_INFO, -@@ -563,7 +581,7 @@ int pirq_guest_bind(struct vcpu *v, int - */ - ASSERT(action->ack_type == ACKTYPE_EOI); - ASSERT(desc->status & IRQ_DISABLED); -- spin_unlock_irq(&desc->lock); -+ spin_unlock_irqrestore(&desc->lock, flags); - cpu_relax(); - goto retry; - } -@@ -579,32 +597,45 @@ int pirq_guest_bind(struct vcpu *v, int - action->guest[action->nr_guests++] = v->domain; - - unlock_out: -- spin_unlock_irq(&desc->lock); -+ spin_unlock_irqrestore(&desc->lock, flags); - out: - if ( newaction != NULL ) - xfree(newaction); - return rc; - } - --void pirq_guest_unbind(struct domain *d, int irq) -+int pirq_guest_unbind(struct domain *d, int irq) - { -- unsigned int vector; -+ int vector; - irq_desc_t *desc; - irq_guest_action_t *action; - cpumask_t cpu_eoi_map; -- int i; -+ int i, rc = 0; - -- vector = domain_irq_to_vector(d, irq); -- desc = &irq_desc[vector]; -- BUG_ON(vector == 0); -+ WARN_ON(!spin_is_locked(&d->evtchn_lock)); - -- spin_lock_irq(&desc->lock); -+ desc = domain_spin_lock_irq_desc(d, irq, &flags); -+ if ( unlikely(desc == NULL) ) -+ { -+ if ( !msi_enable || (vector = -domain_irq_to_vector(d, irq)) == 0 ) -+ return -EINVAL; -+ BUG_ON(vector <= 0); -+ desc = &irq_desc[vector]; -+ spin_lock_irqsave(&desc->lock, flags); -+ d->arch.pirq_vector[irq] = d->arch.vector_pirq[vector] = 0; -+ goto out; -+ } - - action = (irq_guest_action_t *)desc->action; -+ vector = desc - irq_desc; - -- i = 0; -- while ( action->guest[i] && (action->guest[i] != d) ) -- i++; -+ for ( i = 0; (i < action->nr_guests) && (action->guest[i] != d); i++ ) -+ continue; -+ if ( i == action->nr_guests ) -+ { -+ rc = -EINVAL; -+ goto out; -+ } - memmove(&action->guest[i], &action->guest[i+1], IRQ_MAX_GUESTS-i-1); - action->nr_guests--; - -@@ -622,7 +653,7 @@ void pirq_guest_unbind(struct domain *d, - (action->nr_guests != 0) ) - { - cpu_eoi_map = action->cpu_eoi_map; -- spin_unlock_irq(&desc->lock); -+ spin_unlock_irqrestore(&desc->lock, flags); - on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 1, 0); - spin_lock_irq(&desc->lock); - } -@@ -659,7 +690,7 @@ void pirq_guest_unbind(struct domain *d, - if ( !cpus_empty(cpu_eoi_map) ) - { - BUG_ON(action->ack_type != ACKTYPE_EOI); -- spin_unlock_irq(&desc->lock); -+ spin_unlock_irqrestore(&desc->lock, flags); - on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 1, 1); - spin_lock_irq(&desc->lock); - } -@@ -673,9 +704,8 @@ void pirq_guest_unbind(struct domain *d, - desc->handler->shutdown(vector); - - out: -- spin_unlock_irq(&desc->lock); -- if ( action != NULL ) -- xfree(action); -+ spin_unlock_irqrestore(&desc->lock, flags); -+ return rc; - } - - extern void dump_ioapic_irq_info(void); -Index: xen-3.3.1-testing/xen/arch/x86/msi.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/msi.c -+++ xen-3.3.1-testing/xen/arch/x86/msi.c -@@ -728,7 +728,6 @@ void pci_disable_msi(int vector) - __pci_disable_msix(vector); - } - --extern struct hw_interrupt_type pci_msi_type; - static void msi_free_vectors(struct pci_dev* dev) - { - struct msi_desc *entry, *tmp; -Index: xen-3.3.1-testing/xen/arch/x86/physdev.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/physdev.c -+++ xen-3.3.1-testing/xen/arch/x86/physdev.c -@@ -26,17 +26,11 @@ int - ioapic_guest_write( - unsigned long physbase, unsigned int reg, u32 pval); - -- --extern struct hw_interrupt_type pci_msi_type; -- - static int get_free_pirq(struct domain *d, int type, int index) - { - int i; - -- if ( d == NULL ) -- return -EINVAL; -- -- ASSERT(spin_is_locked(&d->arch.irq_lock)); -+ ASSERT(spin_is_locked(&d->evtchn_lock)); - - if ( type == MAP_PIRQ_TYPE_GSI ) - { -@@ -64,11 +58,10 @@ static int map_domain_pirq(struct domain - int ret = 0; - int old_vector, old_pirq; - struct msi_info msi; -+ irq_desc_t *desc; -+ unsigned long flags; - -- if ( d == NULL ) -- return -EINVAL; -- -- ASSERT(spin_is_locked(&d->arch.irq_lock)); -+ ASSERT(spin_is_locked(&d->evtchn_lock)); - - if ( !IS_PRIV(current->domain) ) - return -EPERM; -@@ -88,8 +81,7 @@ static int map_domain_pirq(struct domain - { - dprintk(XENLOG_G_ERR, "dom%d: pirq %d or vector %d already mapped\n", - d->domain_id, pirq, vector); -- ret = -EINVAL; -- goto done; -+ return -EINVAL; - } - - ret = irq_permit_access(d, pirq); -@@ -97,17 +89,14 @@ static int map_domain_pirq(struct domain - { - dprintk(XENLOG_G_ERR, "dom%d: could not permit access to irq %d\n", - d->domain_id, pirq); -- goto done; -+ return ret; - } - -+ desc = &irq_desc[vector]; -+ spin_lock_irqsave(&desc->lock, flags); -+ - if ( map && MAP_PIRQ_TYPE_MSI == map->type ) - { -- irq_desc_t *desc; -- unsigned long flags; -- -- desc = &irq_desc[vector]; -- -- spin_lock_irqsave(&desc->lock, flags); - if ( desc->handler != &no_irq_type ) - dprintk(XENLOG_G_ERR, "dom%d: vector %d in use\n", - d->domain_id, vector); -@@ -120,8 +109,6 @@ static int map_domain_pirq(struct domain - msi.vector = vector; - - ret = pci_enable_msi(&msi); -- -- spin_unlock_irqrestore(&desc->lock, flags); - if ( ret ) - goto done; - } -@@ -130,6 +117,7 @@ static int map_domain_pirq(struct domain - d->arch.vector_pirq[vector] = pirq; - - done: -+ spin_unlock_irqrestore(&desc->lock, flags); - return ret; - } - -@@ -145,11 +133,11 @@ static int unmap_domain_pirq(struct doma - if ( !IS_PRIV(current->domain) ) - return -EINVAL; - -- ASSERT(spin_is_locked(&d->arch.irq_lock)); -+ ASSERT(spin_is_locked(&d->evtchn_lock)); - - vector = d->arch.pirq_vector[pirq]; - -- if ( !vector ) -+ if ( vector <= 0 ) - { - dprintk(XENLOG_G_ERR, "dom%d: pirq %d not mapped\n", - d->domain_id, pirq); -@@ -159,21 +147,35 @@ static int unmap_domain_pirq(struct doma - { - unsigned long flags; - irq_desc_t *desc; -+ bool_t forced_unbind = (pirq_guest_unbind(d, pirq) == 0); -+ -+ if ( forced_unbind ) -+ dprintk(XENLOG_G_WARNING, "dom%d: forcing unbind of pirq %d\n", -+ d->domain_id, pirq); - - desc = &irq_desc[vector]; - spin_lock_irqsave(&desc->lock, flags); -+ -+ BUG_ON(vector != d->arch.pirq_vector[pirq]); -+ - if ( desc->msi_desc ) - pci_disable_msi(vector); - - if ( desc->handler == &pci_msi_type ) -+ desc->handler = &no_irq_type; -+ -+ if ( !forced_unbind ) - { -- /* MSI is not shared, so should be released already */ -- BUG_ON(desc->status & IRQ_GUEST); -- irq_desc[vector].handler = &no_irq_type; -+ d->arch.pirq_vector[pirq] = 0; -+ d->arch.vector_pirq[vector] = 0; -+ } -+ else -+ { -+ d->arch.pirq_vector[pirq] = -vector; -+ d->arch.vector_pirq[vector] = -pirq; - } -- spin_unlock_irqrestore(&desc->lock, flags); - -- d->arch.pirq_vector[pirq] = d->arch.vector_pirq[vector] = 0; -+ spin_unlock_irqrestore(&desc->lock, flags); - } - - ret = irq_deny_access(d, pirq); -@@ -189,7 +191,6 @@ static int physdev_map_pirq(struct physd - { - struct domain *d; - int vector, pirq, ret = 0; -- unsigned long flags; - - /* if msi_enable is not enabled, map always succeeds */ - if ( !msi_enable ) -@@ -250,8 +251,8 @@ static int physdev_map_pirq(struct physd - goto free_domain; - } - -- spin_lock_irqsave(&d->arch.irq_lock, flags); -- if ( map->pirq == -1 ) -+ spin_lock(&d->evtchn_lock); -+ if ( map->pirq < 0 ) - { - if ( d->arch.vector_pirq[vector] ) - { -@@ -259,6 +260,11 @@ static int physdev_map_pirq(struct physd - d->domain_id, map->index, map->pirq, - d->arch.vector_pirq[vector]); - pirq = d->arch.vector_pirq[vector]; -+ if ( pirq < 0 ) -+ { -+ ret = -EBUSY; -+ goto done; -+ } - } - else - { -@@ -291,7 +297,7 @@ static int physdev_map_pirq(struct physd - if ( !ret ) - map->pirq = pirq; - done: -- spin_unlock_irqrestore(&d->arch.irq_lock, flags); -+ spin_unlock(&d->evtchn_lock); - free_domain: - rcu_unlock_domain(d); - return ret; -@@ -300,7 +306,6 @@ free_domain: - static int physdev_unmap_pirq(struct physdev_unmap_pirq *unmap) - { - struct domain *d; -- unsigned long flags; - int ret; - - if ( !msi_enable ) -@@ -323,9 +328,10 @@ static int physdev_unmap_pirq(struct phy - return -ESRCH; - } - -- spin_lock_irqsave(&d->arch.irq_lock, flags); -+ spin_lock(&d->evtchn_lock); - ret = unmap_domain_pirq(d, unmap->pirq); -- spin_unlock_irqrestore(&d->arch.irq_lock, flags); -+ spin_unlock(&d->evtchn_lock); -+ - rcu_unlock_domain(d); - - return ret; -@@ -431,7 +437,6 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H - - case PHYSDEVOP_alloc_irq_vector: { - struct physdev_irq irq_op; -- unsigned long flags; - - ret = -EFAULT; - if ( copy_from_guest(&irq_op, arg, 1) != 0 ) -@@ -456,9 +461,9 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H - - if ( msi_enable ) - { -- spin_lock_irqsave(&dom0->arch.irq_lock, flags); -+ spin_lock(&dom0->evtchn_lock); - ret = map_domain_pirq(dom0, irq_op.irq, irq_op.vector, NULL); -- spin_unlock_irqrestore(&dom0->arch.irq_lock, flags); -+ spin_unlock(&dom0->evtchn_lock); - } - - if ( copy_to_guest(arg, &irq_op, 1) != 0 ) -Index: xen-3.3.1-testing/xen/common/event_channel.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/event_channel.c -+++ xen-3.3.1-testing/xen/common/event_channel.c -@@ -376,7 +376,8 @@ static long __evtchn_close(struct domain - break; - - case ECS_PIRQ: -- pirq_guest_unbind(d1, chn1->u.pirq); -+ if ( pirq_guest_unbind(d1, chn1->u.pirq) != 0 ) -+ BUG(); - d1->pirq_to_evtchn[chn1->u.pirq] = 0; - break; - -Index: xen-3.3.1-testing/xen/include/asm-x86/domain.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/domain.h -+++ xen-3.3.1-testing/xen/include/asm-x86/domain.h -@@ -235,7 +235,7 @@ struct arch_domain - /* Shadow translated domain: P2M mapping */ - pagetable_t phys_table; - -- spinlock_t irq_lock; -+ /* NB. protected by d->evtchn_lock and by irq_desc[vector].lock */ - int vector_pirq[NR_VECTORS]; - int pirq_vector[NR_PIRQS]; - -Index: xen-3.3.1-testing/xen/include/asm-x86/irq.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/irq.h -+++ xen-3.3.1-testing/xen/include/asm-x86/irq.h -@@ -52,6 +52,7 @@ extern atomic_t irq_mis_count; - int pirq_acktype(struct domain *d, int irq); - int pirq_shared(struct domain *d , int irq); - --extern int domain_irq_to_vector(struct domain *d, int irq); --extern int domain_vector_to_irq(struct domain *d, int vector); -+#define domain_irq_to_vector(d, irq) (msi_enable ? (d)->arch.pirq_vector[irq] : irq_to_vector(irq)) -+#define domain_vector_to_irq(d, vec) (msi_enable ? (d)->arch.vector_pirq[vec] : vector_to_irq(vec)) -+ - #endif /* _ASM_HW_IRQ_H */ -Index: xen-3.3.1-testing/xen/include/asm-x86/msi.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/msi.h -+++ xen-3.3.1-testing/xen/include/asm-x86/msi.h -@@ -107,7 +107,7 @@ struct msi_desc { - */ - #define NR_HP_RESERVED_VECTORS 20 - --extern int vector_irq[NR_VECTORS]; -+extern struct hw_interrupt_type pci_msi_type; - - /* - * MSI-X Address Register -Index: xen-3.3.1-testing/xen/include/xen/irq.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/xen/irq.h -+++ xen-3.3.1-testing/xen/include/xen/irq.h -@@ -22,7 +22,6 @@ struct irqaction - #define IRQ_PENDING 4 /* IRQ pending - replay on enable */ - #define IRQ_REPLAY 8 /* IRQ has been replayed but not acked yet */ - #define IRQ_GUEST 16 /* IRQ is handled by guest OS(es) */ --#define IRQ_LEVEL 64 /* IRQ level triggered */ - #define IRQ_PER_CPU 256 /* IRQ is per CPU */ - - /* -@@ -78,7 +77,7 @@ struct vcpu; - extern int pirq_guest_eoi(struct domain *d, int irq); - extern int pirq_guest_unmask(struct domain *d); - extern int pirq_guest_bind(struct vcpu *v, int irq, int will_share); --extern void pirq_guest_unbind(struct domain *d, int irq); -+extern int pirq_guest_unbind(struct domain *d, int irq); - - static inline void set_native_irq_info(int irq, cpumask_t mask) - { diff --git a/18547-pirq-vector-mapping-fix.patch b/18547-pirq-vector-mapping-fix.patch deleted file mode 100644 index 4ea3bee..0000000 --- a/18547-pirq-vector-mapping-fix.patch +++ /dev/null @@ -1,283 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1222349872 -3600 -# Node ID e1507b441be45d6d1cac25a196b53beff857a083 -# Parent ddf62f69611127319e3c756b9fbc82e29f59ef36 -x86: Clean up and fix 18539:31f09a5e24cf8 -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/ia64/xen/irq.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/ia64/xen/irq.c -+++ xen-3.3.1-testing/xen/arch/ia64/xen/irq.c -@@ -459,12 +459,12 @@ int pirq_guest_bind(struct vcpu *v, int - return rc; - } - --int pirq_guest_unbind(struct domain *d, int irq) -+void pirq_guest_unbind(struct domain *d, int irq) - { - irq_desc_t *desc = &irq_desc[irq]; - irq_guest_action_t *action; - unsigned long flags; -- int i, rc = 0; -+ int i; - - spin_lock_irqsave(&desc->lock, flags); - -@@ -472,11 +472,7 @@ int pirq_guest_unbind(struct domain *d, - - for ( i = 0; (i < action->nr_guests) && (action->guest[i] != d); i++ ) - continue; -- if ( i == action->nr_guests ) -- { -- rc = -EINVAL; -- goto out; -- } -+ BUG_ON(i == action->nr_guests); - memmove(&action->guest[i], &action->guest[i+1], IRQ_MAX_GUESTS-i-1); - action->nr_guests--; - -@@ -496,9 +492,7 @@ int pirq_guest_unbind(struct domain *d, - desc->handler->shutdown(irq); - } - -- out: - spin_unlock_irqrestore(&desc->lock, flags); -- return rc; - } - - void -Index: xen-3.3.1-testing/xen/arch/x86/irq.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/irq.c -+++ xen-3.3.1-testing/xen/arch/x86/irq.c -@@ -510,12 +510,12 @@ int pirq_guest_bind(struct vcpu *v, int - irq_guest_action_t *action, *newaction = NULL; - int rc = 0; - cpumask_t cpumask = CPU_MASK_NONE; -- unsigned long flags; - - WARN_ON(!spin_is_locked(&v->domain->evtchn_lock)); -+ BUG_ON(!local_irq_is_enabled()); - - retry: -- desc = domain_spin_lock_irq_desc(v->domain, irq, &flags); -+ desc = domain_spin_lock_irq_desc(v->domain, irq, NULL); - if ( desc == NULL ) - return -EINVAL; - -@@ -535,7 +535,7 @@ int pirq_guest_bind(struct vcpu *v, int - - if ( newaction == NULL ) - { -- spin_unlock_irqrestore(&desc->lock, flags); -+ spin_unlock_irq(&desc->lock); - if ( (newaction = xmalloc(irq_guest_action_t)) != NULL ) - goto retry; - gdprintk(XENLOG_INFO, -@@ -581,7 +581,7 @@ int pirq_guest_bind(struct vcpu *v, int - */ - ASSERT(action->ack_type == ACKTYPE_EOI); - ASSERT(desc->status & IRQ_DISABLED); -- spin_unlock_irqrestore(&desc->lock, flags); -+ spin_unlock_irq(&desc->lock); - cpu_relax(); - goto retry; - } -@@ -597,45 +597,26 @@ int pirq_guest_bind(struct vcpu *v, int - action->guest[action->nr_guests++] = v->domain; - - unlock_out: -- spin_unlock_irqrestore(&desc->lock, flags); -+ spin_unlock_irq(&desc->lock); - out: -- if ( newaction != NULL ) -- xfree(newaction); - return rc; - } - --int pirq_guest_unbind(struct domain *d, int irq) -+static void __pirq_guest_unbind(struct domain *d, int irq, irq_desc_t *desc) - { -- int vector; -- irq_desc_t *desc; -+ unsigned int vector; - irq_guest_action_t *action; - cpumask_t cpu_eoi_map; -- int i, rc = 0; -- -- WARN_ON(!spin_is_locked(&d->evtchn_lock)); -+ int i; - -- desc = domain_spin_lock_irq_desc(d, irq, &flags); -- if ( unlikely(desc == NULL) ) -- { -- if ( !msi_enable || (vector = -domain_irq_to_vector(d, irq)) == 0 ) -- return -EINVAL; -- BUG_ON(vector <= 0); -- desc = &irq_desc[vector]; -- spin_lock_irqsave(&desc->lock, flags); -- d->arch.pirq_vector[irq] = d->arch.vector_pirq[vector] = 0; -- goto out; -- } -+ BUG_ON(!(desc->status & IRQ_GUEST)); - - action = (irq_guest_action_t *)desc->action; - vector = desc - irq_desc; - - for ( i = 0; (i < action->nr_guests) && (action->guest[i] != d); i++ ) - continue; -- if ( i == action->nr_guests ) -- { -- rc = -EINVAL; -- goto out; -- } -+ BUG_ON(i == action->nr_guests); - memmove(&action->guest[i], &action->guest[i+1], IRQ_MAX_GUESTS-i-1); - action->nr_guests--; - -@@ -653,7 +634,7 @@ int pirq_guest_unbind(struct domain *d, - (action->nr_guests != 0) ) - { - cpu_eoi_map = action->cpu_eoi_map; -- spin_unlock_irqrestore(&desc->lock, flags); -+ spin_unlock_irq(&desc->lock); - on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 1, 0); - spin_lock_irq(&desc->lock); - } -@@ -669,7 +650,7 @@ int pirq_guest_unbind(struct domain *d, - if ( action->nr_guests != 0 ) - { - action = NULL; -- goto out; -+ return; - } - - BUG_ON(action->in_flight != 0); -@@ -690,7 +671,7 @@ int pirq_guest_unbind(struct domain *d, - if ( !cpus_empty(cpu_eoi_map) ) - { - BUG_ON(action->ack_type != ACKTYPE_EOI); -- spin_unlock_irqrestore(&desc->lock, flags); -+ spin_unlock_irq(&desc->lock); - on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 1, 1); - spin_lock_irq(&desc->lock); - } -@@ -702,10 +683,63 @@ int pirq_guest_unbind(struct domain *d, - desc->status &= ~IRQ_INPROGRESS; - kill_timer(&irq_guest_eoi_timer[vector]); - desc->handler->shutdown(vector); -+} -+ -+void pirq_guest_unbind(struct domain *d, int irq) -+{ -+ irq_desc_t *desc; -+ int vector; -+ -+ WARN_ON(!spin_is_locked(&d->evtchn_lock)); -+ -+ BUG_ON(!local_irq_is_enabled()); -+ desc = domain_spin_lock_irq_desc(d, irq, NULL); -+ -+ if ( desc == NULL ) -+ { -+ if ( !msi_enable ) -+ return; -+ vector = -domain_irq_to_vector(d, irq); -+ BUG_ON(vector <= 0); -+ desc = &irq_desc[vector]; -+ spin_lock_irq(&desc->lock); -+ d->arch.pirq_vector[irq] = d->arch.vector_pirq[vector] = 0; -+ } -+ else -+ { -+ __pirq_guest_unbind(d, irq, desc); -+ } -+ -+ spin_unlock_irq(&desc->lock); -+} -+ -+int pirq_guest_force_unbind(struct domain *d, int irq) -+{ -+ irq_desc_t *desc; -+ irq_guest_action_t *action; -+ int i, bound = 0; -+ -+ WARN_ON(!spin_is_locked(&d->evtchn_lock)); -+ -+ BUG_ON(!local_irq_is_enabled()); -+ desc = domain_spin_lock_irq_desc(d, irq, NULL); -+ BUG_ON(desc == NULL); -+ -+ if ( !(desc->status & IRQ_GUEST) ) -+ goto out; -+ -+ action = (irq_guest_action_t *)desc->action; -+ for ( i = 0; (i < action->nr_guests) && (action->guest[i] != d); i++ ) -+ continue; -+ if ( i == action->nr_guests ) -+ goto out; -+ -+ bound = 1; -+ __pirq_guest_unbind(d, irq, desc); - - out: -- spin_unlock_irqrestore(&desc->lock, flags); -- return rc; -+ spin_unlock_irq(&desc->lock); -+ return bound; - } - - extern void dump_ioapic_irq_info(void); -Index: xen-3.3.1-testing/xen/arch/x86/physdev.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/physdev.c -+++ xen-3.3.1-testing/xen/arch/x86/physdev.c -@@ -147,7 +147,7 @@ static int unmap_domain_pirq(struct doma - { - unsigned long flags; - irq_desc_t *desc; -- bool_t forced_unbind = (pirq_guest_unbind(d, pirq) == 0); -+ bool_t forced_unbind = pirq_guest_force_unbind(d, pirq); - - if ( forced_unbind ) - dprintk(XENLOG_G_WARNING, "dom%d: forcing unbind of pirq %d\n", -Index: xen-3.3.1-testing/xen/common/event_channel.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/event_channel.c -+++ xen-3.3.1-testing/xen/common/event_channel.c -@@ -376,8 +376,7 @@ static long __evtchn_close(struct domain - break; - - case ECS_PIRQ: -- if ( pirq_guest_unbind(d1, chn1->u.pirq) != 0 ) -- BUG(); -+ pirq_guest_unbind(d1, chn1->u.pirq); - d1->pirq_to_evtchn[chn1->u.pirq] = 0; - break; - -Index: xen-3.3.1-testing/xen/include/asm-x86/irq.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/irq.h -+++ xen-3.3.1-testing/xen/include/asm-x86/irq.h -@@ -55,4 +55,6 @@ int pirq_shared(struct domain *d , int i - #define domain_irq_to_vector(d, irq) (msi_enable ? (d)->arch.pirq_vector[irq] : irq_to_vector(irq)) - #define domain_vector_to_irq(d, vec) (msi_enable ? (d)->arch.vector_pirq[vec] : vector_to_irq(vec)) - -+int pirq_guest_force_unbind(struct domain *d, int irq); -+ - #endif /* _ASM_HW_IRQ_H */ -Index: xen-3.3.1-testing/xen/include/xen/irq.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/xen/irq.h -+++ xen-3.3.1-testing/xen/include/xen/irq.h -@@ -77,7 +77,7 @@ struct vcpu; - extern int pirq_guest_eoi(struct domain *d, int irq); - extern int pirq_guest_unmask(struct domain *d); - extern int pirq_guest_bind(struct vcpu *v, int irq, int will_share); --extern int pirq_guest_unbind(struct domain *d, int irq); -+extern void pirq_guest_unbind(struct domain *d, int irq); - - static inline void set_native_irq_info(int irq, cpumask_t mask) - { diff --git a/18573-move-pirq-logic.patch b/18573-move-pirq-logic.patch deleted file mode 100644 index b9c664e..0000000 --- a/18573-move-pirq-logic.patch +++ /dev/null @@ -1,455 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1223459328 -3600 -# Node ID ed398097c03e16dacb1f3af19fa8faddf2deae1f -# Parent 1f85f7b216b34bfda4911b6a46548478f0e5d682 -x86: Move pirq logic to irq.c. - -Signed-off-by: Yunhong Jiang -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/irq.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/irq.c -+++ xen-3.3.1-testing/xen/arch/x86/irq.c -@@ -14,8 +14,11 @@ - #include - #include - #include --#include -+#include - #include -+#include -+#include -+#include - - /* opt_noirqbalance: If true, software IRQ balancing/affinity is disabled. */ - int opt_noirqbalance = 0; -@@ -742,6 +745,157 @@ int pirq_guest_force_unbind(struct domai - return bound; - } - -+int get_free_pirq(struct domain *d, int type, int index) -+{ -+ int i; -+ -+ ASSERT(spin_is_locked(&d->evtchn_lock)); -+ -+ if ( type == MAP_PIRQ_TYPE_GSI ) -+ { -+ for ( i = 16; i < NR_PIRQS; i++ ) -+ if ( !d->arch.pirq_vector[i] ) -+ break; -+ if ( i == NR_PIRQS ) -+ return -ENOSPC; -+ } -+ else -+ { -+ for ( i = NR_PIRQS - 1; i >= 16; i-- ) -+ if ( !d->arch.pirq_vector[i] ) -+ break; -+ if ( i == 16 ) -+ return -ENOSPC; -+ } -+ -+ return i; -+} -+ -+int map_domain_pirq( -+ struct domain *d, int pirq, int vector, int type, void *data) -+{ -+ int ret = 0; -+ int old_vector, old_pirq; -+ irq_desc_t *desc; -+ unsigned long flags; -+ -+ ASSERT(spin_is_locked(&d->evtchn_lock)); -+ -+ if ( !IS_PRIV(current->domain) ) -+ return -EPERM; -+ -+ if ( pirq < 0 || pirq >= NR_PIRQS || vector < 0 || vector >= NR_VECTORS ) -+ { -+ dprintk(XENLOG_G_ERR, "dom%d: invalid pirq %d or vector %d\n", -+ d->domain_id, pirq, vector); -+ return -EINVAL; -+ } -+ -+ old_vector = d->arch.pirq_vector[pirq]; -+ old_pirq = d->arch.vector_pirq[vector]; -+ -+ if ( (old_vector && (old_vector != vector) ) || -+ (old_pirq && (old_pirq != pirq)) ) -+ { -+ dprintk(XENLOG_G_ERR, "dom%d: pirq %d or vector %d already mapped\n", -+ d->domain_id, pirq, vector); -+ return -EINVAL; -+ } -+ -+ ret = irq_permit_access(d, pirq); -+ if ( ret ) -+ { -+ dprintk(XENLOG_G_ERR, "dom%d: could not permit access to irq %d\n", -+ d->domain_id, pirq); -+ return ret; -+ } -+ -+ desc = &irq_desc[vector]; -+ spin_lock_irqsave(&desc->lock, flags); -+ -+ if ( type == MAP_PIRQ_TYPE_MSI ) -+ { -+ struct msi_info *msi = (struct msi_info *)data; -+ if ( desc->handler != &no_irq_type ) -+ dprintk(XENLOG_G_ERR, "dom%d: vector %d in use\n", -+ d->domain_id, vector); -+ desc->handler = &pci_msi_type; -+ ret = pci_enable_msi(msi); -+ if ( ret ) -+ goto done; -+ } -+ -+ d->arch.pirq_vector[pirq] = vector; -+ d->arch.vector_pirq[vector] = pirq; -+ -+done: -+ spin_unlock_irqrestore(&desc->lock, flags); -+ return ret; -+} -+ -+/* The pirq should have been unbound before this call. */ -+int unmap_domain_pirq(struct domain *d, int pirq) -+{ -+ unsigned long flags; -+ irq_desc_t *desc; -+ int vector, ret = 0; -+ bool_t forced_unbind; -+ -+ if ( (pirq < 0) || (pirq >= NR_PIRQS) ) -+ return -EINVAL; -+ -+ if ( !IS_PRIV(current->domain) ) -+ return -EINVAL; -+ -+ ASSERT(spin_is_locked(&d->evtchn_lock)); -+ -+ vector = d->arch.pirq_vector[pirq]; -+ if ( vector <= 0 ) -+ { -+ dprintk(XENLOG_G_ERR, "dom%d: pirq %d not mapped\n", -+ d->domain_id, pirq); -+ ret = -EINVAL; -+ goto done; -+ } -+ -+ forced_unbind = pirq_guest_force_unbind(d, pirq); -+ if ( forced_unbind ) -+ dprintk(XENLOG_G_WARNING, "dom%d: forcing unbind of pirq %d\n", -+ d->domain_id, pirq); -+ -+ desc = &irq_desc[vector]; -+ spin_lock_irqsave(&desc->lock, flags); -+ -+ BUG_ON(vector != d->arch.pirq_vector[pirq]); -+ -+ if ( desc->msi_desc ) -+ pci_disable_msi(vector); -+ -+ if ( desc->handler == &pci_msi_type ) -+ desc->handler = &no_irq_type; -+ -+ if ( !forced_unbind ) -+ { -+ d->arch.pirq_vector[pirq] = 0; -+ d->arch.vector_pirq[vector] = 0; -+ } -+ else -+ { -+ d->arch.pirq_vector[pirq] = -vector; -+ d->arch.vector_pirq[vector] = -pirq; -+ } -+ -+ spin_unlock_irqrestore(&desc->lock, flags); -+ -+ ret = irq_deny_access(d, pirq); -+ if ( ret ) -+ dprintk(XENLOG_G_ERR, "dom%d: could not deny access to irq %d\n", -+ d->domain_id, pirq); -+ -+ done: -+ return ret; -+} -+ - extern void dump_ioapic_irq_info(void); - - static void dump_irqs(unsigned char key) -Index: xen-3.3.1-testing/xen/arch/x86/physdev.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/physdev.c -+++ xen-3.3.1-testing/xen/arch/x86/physdev.c -@@ -26,171 +26,12 @@ int - ioapic_guest_write( - unsigned long physbase, unsigned int reg, u32 pval); - --static int get_free_pirq(struct domain *d, int type, int index) --{ -- int i; -- -- ASSERT(spin_is_locked(&d->evtchn_lock)); -- -- if ( type == MAP_PIRQ_TYPE_GSI ) -- { -- for ( i = 16; i < NR_PIRQS; i++ ) -- if ( !d->arch.pirq_vector[i] ) -- break; -- if ( i == NR_PIRQS ) -- return -ENOSPC; -- } -- else -- { -- for ( i = NR_PIRQS - 1; i >= 16; i-- ) -- if ( !d->arch.pirq_vector[i] ) -- break; -- if ( i == 16 ) -- return -ENOSPC; -- } -- -- return i; --} -- --static int map_domain_pirq(struct domain *d, int pirq, int vector, -- struct physdev_map_pirq *map) --{ -- int ret = 0; -- int old_vector, old_pirq; -- struct msi_info msi; -- irq_desc_t *desc; -- unsigned long flags; -- -- ASSERT(spin_is_locked(&d->evtchn_lock)); -- -- if ( !IS_PRIV(current->domain) ) -- return -EPERM; -- -- if ( pirq < 0 || pirq >= NR_PIRQS || vector < 0 || vector >= NR_VECTORS ) -- { -- dprintk(XENLOG_G_ERR, "dom%d: invalid pirq %d or vector %d\n", -- d->domain_id, pirq, vector); -- return -EINVAL; -- } -- -- old_vector = d->arch.pirq_vector[pirq]; -- old_pirq = d->arch.vector_pirq[vector]; -- -- if ( (old_vector && (old_vector != vector) ) || -- (old_pirq && (old_pirq != pirq)) ) -- { -- dprintk(XENLOG_G_ERR, "dom%d: pirq %d or vector %d already mapped\n", -- d->domain_id, pirq, vector); -- return -EINVAL; -- } -- -- ret = irq_permit_access(d, pirq); -- if ( ret ) -- { -- dprintk(XENLOG_G_ERR, "dom%d: could not permit access to irq %d\n", -- d->domain_id, pirq); -- return ret; -- } -- -- desc = &irq_desc[vector]; -- spin_lock_irqsave(&desc->lock, flags); -- -- if ( map && MAP_PIRQ_TYPE_MSI == map->type ) -- { -- if ( desc->handler != &no_irq_type ) -- dprintk(XENLOG_G_ERR, "dom%d: vector %d in use\n", -- d->domain_id, vector); -- desc->handler = &pci_msi_type; -- -- msi.bus = map->bus; -- msi.devfn = map->devfn; -- msi.entry_nr = map->entry_nr; -- msi.table_base = map->table_base; -- msi.vector = vector; -- -- ret = pci_enable_msi(&msi); -- if ( ret ) -- goto done; -- } -- -- d->arch.pirq_vector[pirq] = vector; -- d->arch.vector_pirq[vector] = pirq; -- --done: -- spin_unlock_irqrestore(&desc->lock, flags); -- return ret; --} -- --/* The pirq should have been unbound before this call. */ --static int unmap_domain_pirq(struct domain *d, int pirq) --{ -- int ret = 0; -- int vector; -- -- if ( d == NULL || pirq < 0 || pirq >= NR_PIRQS ) -- return -EINVAL; -- -- if ( !IS_PRIV(current->domain) ) -- return -EINVAL; -- -- ASSERT(spin_is_locked(&d->evtchn_lock)); -- -- vector = d->arch.pirq_vector[pirq]; -- -- if ( vector <= 0 ) -- { -- dprintk(XENLOG_G_ERR, "dom%d: pirq %d not mapped\n", -- d->domain_id, pirq); -- ret = -EINVAL; -- } -- else -- { -- unsigned long flags; -- irq_desc_t *desc; -- bool_t forced_unbind = pirq_guest_force_unbind(d, pirq); -- -- if ( forced_unbind ) -- dprintk(XENLOG_G_WARNING, "dom%d: forcing unbind of pirq %d\n", -- d->domain_id, pirq); -- -- desc = &irq_desc[vector]; -- spin_lock_irqsave(&desc->lock, flags); -- -- BUG_ON(vector != d->arch.pirq_vector[pirq]); -- -- if ( desc->msi_desc ) -- pci_disable_msi(vector); -- -- if ( desc->handler == &pci_msi_type ) -- desc->handler = &no_irq_type; -- -- if ( !forced_unbind ) -- { -- d->arch.pirq_vector[pirq] = 0; -- d->arch.vector_pirq[vector] = 0; -- } -- else -- { -- d->arch.pirq_vector[pirq] = -vector; -- d->arch.vector_pirq[vector] = -pirq; -- } -- -- spin_unlock_irqrestore(&desc->lock, flags); -- } -- -- ret = irq_deny_access(d, pirq); -- -- if ( ret ) -- dprintk(XENLOG_G_ERR, "dom%d: could not deny access to irq %d\n", -- d->domain_id, pirq); -- -- return ret; --} -- - static int physdev_map_pirq(struct physdev_map_pirq *map) - { - struct domain *d; - int vector, pirq, ret = 0; -+ struct msi_info _msi; -+ void *map_data = NULL; - - /* if msi_enable is not enabled, map always succeeds */ - if ( !msi_enable ) -@@ -213,6 +54,7 @@ static int physdev_map_pirq(struct physd - goto free_domain; - } - -+ /* Verify or get vector. */ - switch ( map->type ) - { - case MAP_PIRQ_TYPE_GSI: -@@ -227,15 +69,16 @@ static int physdev_map_pirq(struct physd - if ( !vector ) - { - dprintk(XENLOG_G_ERR, "dom%d: map irq with no vector %d\n", -- d->domain_id, map->index); -+ d->domain_id, vector); - ret = -EINVAL; - goto free_domain; - } - break; -+ - case MAP_PIRQ_TYPE_MSI: - vector = map->index; -- if ( vector == -1 ) -- vector = assign_irq_vector(AUTO_ASSIGN); -+ if ( vector == -1 ) -+ vector = assign_irq_vector(AUTO_ASSIGN); - - if ( vector < 0 || vector >= NR_VECTORS ) - { -@@ -244,13 +87,23 @@ static int physdev_map_pirq(struct physd - ret = -EINVAL; - goto free_domain; - } -+ -+ _msi.bus = map->bus; -+ _msi.devfn = map->devfn; -+ _msi.entry_nr = map->entry_nr; -+ _msi.table_base = map->table_base; -+ _msi.vector = vector; -+ map_data = &_msi; - break; -+ - default: -- dprintk(XENLOG_G_ERR, "dom%d: wrong map_pirq type %x\n", d->domain_id, map->type); -+ dprintk(XENLOG_G_ERR, "dom%d: wrong map_pirq type %x\n", -+ d->domain_id, map->type); - ret = -EINVAL; - goto free_domain; - } - -+ /* Verify or get pirq. */ - spin_lock(&d->evtchn_lock); - if ( map->pirq < 0 ) - { -@@ -292,10 +145,10 @@ static int physdev_map_pirq(struct physd - } - - -- ret = map_domain_pirq(d, pirq, vector, map); -- -+ ret = map_domain_pirq(d, pirq, vector, map->type, map_data); - if ( !ret ) - map->pirq = pirq; -+ - done: - spin_unlock(&d->evtchn_lock); - free_domain: -@@ -462,7 +315,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H - if ( msi_enable ) - { - spin_lock(&dom0->evtchn_lock); -- ret = map_domain_pirq(dom0, irq_op.irq, irq_op.vector, NULL); -+ ret = map_domain_pirq(dom0, irq_op.irq, irq_op.vector, -+ MAP_PIRQ_TYPE_GSI, NULL); - spin_unlock(&dom0->evtchn_lock); - } - -Index: xen-3.3.1-testing/xen/include/asm-x86/irq.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/irq.h -+++ xen-3.3.1-testing/xen/include/asm-x86/irq.h -@@ -52,6 +52,11 @@ extern atomic_t irq_mis_count; - int pirq_acktype(struct domain *d, int irq); - int pirq_shared(struct domain *d , int irq); - -+int map_domain_pirq(struct domain *d, int pirq, int vector, int type, -+ void *data); -+int unmap_domain_pirq(struct domain *d, int pirq); -+int get_free_pirq(struct domain *d, int type, int index); -+ - #define domain_irq_to_vector(d, irq) (msi_enable ? (d)->arch.pirq_vector[irq] : irq_to_vector(irq)) - #define domain_vector_to_irq(d, vec) (msi_enable ? (d)->arch.vector_pirq[vec] : vector_to_irq(vec)) - diff --git a/18574-msi-free-vector.patch b/18574-msi-free-vector.patch deleted file mode 100644 index 2901005..0000000 --- a/18574-msi-free-vector.patch +++ /dev/null @@ -1,219 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1223463099 -3600 -# Node ID 51a05fb4c6014059058de48b83a9431e7474a456 -# Parent ed398097c03e16dacb1f3af19fa8faddf2deae1f -x86: Free MSI vector when a pirq is unmapped. - -Signed-off-by: Yunhong Jiang -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/domain.c -+++ xen-3.3.1-testing/xen/arch/x86/domain.c -@@ -459,6 +459,7 @@ void arch_domain_destroy(struct domain * - hvm_domain_destroy(d); - - pci_release_devices(d); -+ free_domain_pirqs(d); - if ( !is_idle_domain(d) ) - iommu_domain_destroy(d); - -Index: xen-3.3.1-testing/xen/arch/x86/i8259.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/i8259.c -+++ xen-3.3.1-testing/xen/arch/x86/i8259.c -@@ -408,6 +408,10 @@ void __init init_IRQ(void) - irq_desc[LEGACY_VECTOR(i)].handler = &i8259A_irq_type; - } - -+ /* Never allocate the hypercall vector or Linux/BSD fast-trap vector. */ -+ vector_irq[HYPERCALL_VECTOR] = NEVER_ASSIGN; -+ vector_irq[0x80] = NEVER_ASSIGN; -+ - apic_intr_init(); - - /* Set the clock to HZ Hz */ -Index: xen-3.3.1-testing/xen/arch/x86/io_apic.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/io_apic.c -+++ xen-3.3.1-testing/xen/arch/x86/io_apic.c -@@ -90,7 +90,8 @@ static struct irq_pin_list { - } irq_2_pin[PIN_MAP_SIZE]; - static int irq_2_pin_free_entry = NR_IRQS; - --int vector_irq[NR_VECTORS] __read_mostly = { [0 ... NR_VECTORS - 1] = -1}; -+int vector_irq[NR_VECTORS] __read_mostly = { -+ [0 ... NR_VECTORS - 1] = FREE_TO_ASSIGN}; - - /* - * The common case is 1:1 IRQ<->pin mappings. Sometimes there are -@@ -669,40 +670,46 @@ static inline int IO_APIC_irq_trigger(in - /* irq_vectors is indexed by the sum of all RTEs in all I/O APICs. */ - u8 irq_vector[NR_IRQ_VECTORS] __read_mostly; - -+int free_irq_vector(int vector) -+{ -+ int irq; -+ -+ BUG_ON((vector > LAST_DYNAMIC_VECTOR) || (vector < FIRST_DYNAMIC_VECTOR)); -+ -+ spin_lock(&vector_lock); -+ if ((irq = vector_irq[vector]) == AUTO_ASSIGN) -+ vector_irq[vector] = FREE_TO_ASSIGN; -+ spin_unlock(&vector_lock); -+ -+ return (irq == AUTO_ASSIGN) ? 0 : -EINVAL; -+} -+ - int assign_irq_vector(int irq) - { -- static unsigned current_vector = FIRST_DYNAMIC_VECTOR, offset = 0; -+ static unsigned current_vector = FIRST_DYNAMIC_VECTOR; - unsigned vector; - - BUG_ON(irq >= NR_IRQ_VECTORS); -+ - spin_lock(&vector_lock); - -- if (irq != AUTO_ASSIGN && IO_APIC_VECTOR(irq) > 0) { -+ if ((irq != AUTO_ASSIGN) && (IO_APIC_VECTOR(irq) > 0)) { - spin_unlock(&vector_lock); - return IO_APIC_VECTOR(irq); - } - --next: -- current_vector += 8; -+ vector = current_vector; -+ while (vector_irq[vector] != FREE_TO_ASSIGN) { -+ if (++vector > LAST_DYNAMIC_VECTOR) -+ vector = FIRST_DYNAMIC_VECTOR; - -- /* Skip the hypercall vector. */ -- if (current_vector == HYPERCALL_VECTOR) -- goto next; -- -- /* Skip the Linux/BSD fast-trap vector. */ -- if (current_vector == 0x80) -- goto next; -- -- if (current_vector > LAST_DYNAMIC_VECTOR) { -- offset++; -- if (!(offset%8)) { -+ if (vector == current_vector) { - spin_unlock(&vector_lock); - return -ENOSPC; - } -- current_vector = FIRST_DYNAMIC_VECTOR + offset; - } - -- vector = current_vector; -+ current_vector = vector; - vector_irq[vector] = irq; - if (irq != AUTO_ASSIGN) - IO_APIC_VECTOR(irq) = vector; -Index: xen-3.3.1-testing/xen/arch/x86/irq.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/irq.c -+++ xen-3.3.1-testing/xen/arch/x86/irq.c -@@ -872,7 +872,10 @@ int unmap_domain_pirq(struct domain *d, - pci_disable_msi(vector); - - if ( desc->handler == &pci_msi_type ) -+ { - desc->handler = &no_irq_type; -+ free_irq_vector(vector); -+ } - - if ( !forced_unbind ) - { -@@ -896,6 +899,24 @@ int unmap_domain_pirq(struct domain *d, - return ret; - } - -+void free_domain_pirqs(struct domain *d) -+{ -+ int i; -+ -+ ASSERT(d->is_dying == DOMDYING_dying); -+ -+ if ( !msi_enable ) -+ return; -+ -+ spin_lock(&d->evtchn_lock); -+ -+ for ( i = 0; i < NR_PIRQS; i++ ) -+ if ( d->arch.pirq_vector[i] > 0 ) -+ unmap_domain_pirq(d, i); -+ -+ spin_unlock(&d->evtchn_lock); -+} -+ - extern void dump_ioapic_irq_info(void); - - static void dump_irqs(unsigned char key) -Index: xen-3.3.1-testing/xen/arch/x86/physdev.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/physdev.c -+++ xen-3.3.1-testing/xen/arch/x86/physdev.c -@@ -83,7 +83,7 @@ static int physdev_map_pirq(struct physd - if ( vector < 0 || vector >= NR_VECTORS ) - { - dprintk(XENLOG_G_ERR, "dom%d: map irq with wrong vector %d\n", -- d->domain_id, map->index); -+ d->domain_id, vector); - ret = -EINVAL; - goto free_domain; - } -@@ -144,13 +144,14 @@ static int physdev_map_pirq(struct physd - pirq = map->pirq; - } - -- - ret = map_domain_pirq(d, pirq, vector, map->type, map_data); -- if ( !ret ) -+ if ( ret == 0 ) - map->pirq = pirq; - - done: - spin_unlock(&d->evtchn_lock); -+ if ( (ret != 0) && (map->type == MAP_PIRQ_TYPE_MSI) && (map->index == -1) ) -+ free_irq_vector(vector); - free_domain: - rcu_unlock_domain(d); - return ret; -Index: xen-3.3.1-testing/xen/include/asm-x86/io_apic.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/io_apic.h -+++ xen-3.3.1-testing/xen/include/asm-x86/io_apic.h -@@ -192,5 +192,6 @@ static inline int ioapic_resume(void) {r - #endif - - extern int assign_irq_vector(int irq); -+extern int free_irq_vector(int vector); - - #endif -Index: xen-3.3.1-testing/xen/include/asm-x86/irq.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/irq.h -+++ xen-3.3.1-testing/xen/include/asm-x86/irq.h -@@ -19,7 +19,9 @@ - - extern int vector_irq[NR_VECTORS]; - extern u8 irq_vector[NR_IRQ_VECTORS]; --#define AUTO_ASSIGN -1 -+#define AUTO_ASSIGN -1 -+#define NEVER_ASSIGN -2 -+#define FREE_TO_ASSIGN -3 - - #define platform_legacy_irq(irq) ((irq) < 16) - -@@ -56,6 +58,7 @@ int map_domain_pirq(struct domain *d, in - void *data); - int unmap_domain_pirq(struct domain *d, int pirq); - int get_free_pirq(struct domain *d, int type, int index); -+void free_domain_pirqs(struct domain *d); - - #define domain_irq_to_vector(d, irq) (msi_enable ? (d)->arch.pirq_vector[irq] : irq_to_vector(irq)) - #define domain_vector_to_irq(d, vec) (msi_enable ? (d)->arch.vector_pirq[vec] : vector_to_irq(vec)) diff --git a/18577-bad-assertion.patch b/18577-bad-assertion.patch deleted file mode 100644 index 203b4f8..0000000 --- a/18577-bad-assertion.patch +++ /dev/null @@ -1,21 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1223470858 -3600 -# Node ID e66cecb66b1ed83b65804d2eb7c3a30f9f1f01d4 -# Parent 5e4e234d58be41401909f160cb9ed2ee0379c6a9 -x86: Remove bogus assertion from free_domain_pirqs(). -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/irq.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/irq.c -+++ xen-3.3.1-testing/xen/arch/x86/irq.c -@@ -903,8 +903,6 @@ void free_domain_pirqs(struct domain *d) - { - int i; - -- ASSERT(d->is_dying == DOMDYING_dying); -- - if ( !msi_enable ) - return; - diff --git a/18583-passthrough-locking.patch b/18583-passthrough-locking.patch deleted file mode 100644 index c66516f..0000000 --- a/18583-passthrough-locking.patch +++ /dev/null @@ -1,569 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1223547292 -3600 -# Node ID a11ad61bdb5b188a8116b533c87c31d6e9bd62d4 -# Parent b8f329d2c074a06b47f3be2b4e0bfe1ac5b232e5 -Fix lock issue for hvm pass-through domain - -This patch protect the hvm_irq_dpci structure with evtchn_lock, thus -the access to domain's pirq_vector mapping is also protected. - -Signed-off-by: Jiang, Yunhong - -Index: xen-3.3.1-testing/xen/arch/x86/hvm/svm/intr.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/hvm/svm/intr.c -+++ xen-3.3.1-testing/xen/arch/x86/hvm/svm/intr.c -@@ -124,9 +124,11 @@ static void svm_dirq_assist(struct vcpu - if ( !test_and_clear_bit(irq, &hvm_irq_dpci->dirq_mask) ) - continue; - -+ spin_lock(&d->evtchn_lock); - if ( test_bit(_HVM_IRQ_DPCI_MSI, &hvm_irq_dpci->mirq[irq].flags) ) - { - hvm_pci_msi_assert(d, irq); -+ spin_unlock(&d->evtchn_lock); - continue; - } - -@@ -137,9 +139,7 @@ static void svm_dirq_assist(struct vcpu - device = digl->device; - intx = digl->intx; - hvm_pci_intx_assert(d, device, intx); -- spin_lock(&hvm_irq_dpci->dirq_lock); - hvm_irq_dpci->mirq[irq].pending++; -- spin_unlock(&hvm_irq_dpci->dirq_lock); - } - - /* -@@ -151,6 +151,7 @@ static void svm_dirq_assist(struct vcpu - */ - set_timer(&hvm_irq_dpci->hvm_timer[domain_irq_to_vector(d, irq)], - NOW() + PT_IRQ_TIME_OUT); -+ spin_unlock(&d->evtchn_lock); - } - } - -Index: xen-3.3.1-testing/xen/arch/x86/hvm/vmsi.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/hvm/vmsi.c -+++ xen-3.3.1-testing/xen/arch/x86/hvm/vmsi.c -@@ -134,7 +134,7 @@ int vmsi_deliver(struct domain *d, int p - "vector=%x trig_mode=%x\n", - dest, dest_mode, delivery_mode, vector, trig_mode); - -- if ( !(hvm_irq_dpci->mirq[pirq].flags & HVM_IRQ_DPCI_MSI) ) -+ if ( !test_bit(_HVM_IRQ_DPCI_MSI, &hvm_irq_dpci->mirq[pirq].flags) ) - { - gdprintk(XENLOG_WARNING, "pirq %x not msi \n", pirq); - return 0; -Index: xen-3.3.1-testing/xen/arch/x86/hvm/vmx/intr.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/hvm/vmx/intr.c -+++ xen-3.3.1-testing/xen/arch/x86/hvm/vmx/intr.c -@@ -127,11 +127,13 @@ static void vmx_dirq_assist(struct vcpu - if ( !test_and_clear_bit(irq, &hvm_irq_dpci->dirq_mask) ) - continue; - -- if ( test_bit(_HVM_IRQ_DPCI_MSI, &hvm_irq_dpci->mirq[irq].flags) ) -- { -- hvm_pci_msi_assert(d, irq); -- continue; -- } -+ spin_lock(&d->evtchn_lock); -+ if ( test_bit(_HVM_IRQ_DPCI_MSI, &hvm_irq_dpci->mirq[irq].flags) ) -+ { -+ hvm_pci_msi_assert(d, irq); -+ spin_unlock(&d->evtchn_lock); -+ continue; -+ } - - stop_timer(&hvm_irq_dpci->hvm_timer[domain_irq_to_vector(d, irq)]); - -@@ -140,9 +142,7 @@ static void vmx_dirq_assist(struct vcpu - device = digl->device; - intx = digl->intx; - hvm_pci_intx_assert(d, device, intx); -- spin_lock(&hvm_irq_dpci->dirq_lock); - hvm_irq_dpci->mirq[irq].pending++; -- spin_unlock(&hvm_irq_dpci->dirq_lock); - } - - /* -@@ -154,6 +154,7 @@ static void vmx_dirq_assist(struct vcpu - */ - set_timer(&hvm_irq_dpci->hvm_timer[domain_irq_to_vector(d, irq)], - NOW() + PT_IRQ_TIME_OUT); -+ spin_unlock(&d->evtchn_lock); - } - } - -Index: xen-3.3.1-testing/xen/arch/x86/irq.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/irq.c -+++ xen-3.3.1-testing/xen/arch/x86/irq.c -@@ -285,7 +285,7 @@ static void __do_IRQ_guest(int vector) - * The descriptor is returned locked. This function is safe against changes - * to the per-domain irq-to-vector mapping. - */ --static irq_desc_t *domain_spin_lock_irq_desc( -+irq_desc_t *domain_spin_lock_irq_desc( - struct domain *d, int irq, unsigned long *pflags) - { - unsigned int vector; -Index: xen-3.3.1-testing/xen/drivers/passthrough/io.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/io.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/io.c -@@ -26,10 +26,14 @@ static void pt_irq_time_out(void *data) - struct hvm_mirq_dpci_mapping *irq_map = data; - unsigned int guest_gsi, machine_gsi = 0; - int vector; -- struct hvm_irq_dpci *dpci = domain_get_irq_dpci(irq_map->dom); -+ struct hvm_irq_dpci *dpci = NULL; - struct dev_intx_gsi_link *digl; - uint32_t device, intx; - -+ spin_lock(&irq_map->dom->evtchn_lock); -+ -+ dpci = domain_get_irq_dpci(irq_map->dom); -+ ASSERT(dpci); - list_for_each_entry ( digl, &irq_map->digl_list, list ) - { - guest_gsi = digl->gsi; -@@ -41,55 +45,65 @@ static void pt_irq_time_out(void *data) - - clear_bit(machine_gsi, dpci->dirq_mask); - vector = domain_irq_to_vector(irq_map->dom, machine_gsi); -- stop_timer(&dpci->hvm_timer[vector]); -- spin_lock(&dpci->dirq_lock); - dpci->mirq[machine_gsi].pending = 0; -- spin_unlock(&dpci->dirq_lock); -+ spin_unlock(&irq_map->dom->evtchn_lock); - pirq_guest_eoi(irq_map->dom, machine_gsi); - } - - int pt_irq_create_bind_vtd( - struct domain *d, xen_domctl_bind_pt_irq_t *pt_irq_bind) - { -- struct hvm_irq_dpci *hvm_irq_dpci = domain_get_irq_dpci(d); -+ struct hvm_irq_dpci *hvm_irq_dpci = NULL; - uint32_t machine_gsi, guest_gsi; - uint32_t device, intx, link; - struct dev_intx_gsi_link *digl; -+ int pirq = pt_irq_bind->machine_irq; -+ -+ if ( pirq < 0 || pirq >= NR_PIRQS ) -+ return -EINVAL; -+ -+ spin_lock(&d->evtchn_lock); - -+ hvm_irq_dpci = domain_get_irq_dpci(d); - if ( hvm_irq_dpci == NULL ) - { - hvm_irq_dpci = xmalloc(struct hvm_irq_dpci); - if ( hvm_irq_dpci == NULL ) -+ { -+ spin_unlock(&d->evtchn_lock); - return -ENOMEM; -- -+ } - memset(hvm_irq_dpci, 0, sizeof(*hvm_irq_dpci)); -- spin_lock_init(&hvm_irq_dpci->dirq_lock); - for ( int i = 0; i < NR_IRQS; i++ ) - INIT_LIST_HEAD(&hvm_irq_dpci->mirq[i].digl_list); -+ } - -- if ( domain_set_irq_dpci(d, hvm_irq_dpci) == 0 ) -- xfree(hvm_irq_dpci); -+ if ( domain_set_irq_dpci(d, hvm_irq_dpci) == 0 ) -+ { -+ xfree(hvm_irq_dpci); -+ spin_unlock(&d->evtchn_lock); -+ return -EINVAL; - } - - if ( pt_irq_bind->irq_type == PT_IRQ_TYPE_MSI ) - { -- int pirq = pt_irq_bind->machine_irq; -- -- if ( pirq < 0 || pirq >= NR_IRQS ) -- return -EINVAL; - -- if ( !(hvm_irq_dpci->mirq[pirq].flags & HVM_IRQ_DPCI_VALID ) ) -+ if ( !test_and_set_bit(pirq, hvm_irq_dpci->mapping)) - { -- hvm_irq_dpci->mirq[pirq].flags |= HVM_IRQ_DPCI_VALID | -- HVM_IRQ_DPCI_MSI ; -+ set_bit(_HVM_IRQ_DPCI_MSI, &hvm_irq_dpci->mirq[pirq].flags); -+ hvm_irq_dpci->mirq[pirq].gmsi.gvec = pt_irq_bind->u.msi.gvec; -+ hvm_irq_dpci->mirq[pirq].gmsi.gflags = pt_irq_bind->u.msi.gflags; -+ hvm_irq_dpci->msi_gvec_pirq[pt_irq_bind->u.msi.gvec] = pirq; -+ /* bind after hvm_irq_dpci is setup to avoid race with irq handler*/ - pirq_guest_bind(d->vcpu[0], pirq, 0); - } -+ else if (hvm_irq_dpci->mirq[pirq].gmsi.gvec != pt_irq_bind->u.msi.gvec -+ ||hvm_irq_dpci->msi_gvec_pirq[pt_irq_bind->u.msi.gvec] != pirq) - -- hvm_irq_dpci->mirq[pirq].flags |= HVM_IRQ_DPCI_VALID |HVM_IRQ_DPCI_MSI ; -- hvm_irq_dpci->mirq[pirq].gmsi.gvec = pt_irq_bind->u.msi.gvec; -- hvm_irq_dpci->mirq[pirq].gmsi.gflags = pt_irq_bind->u.msi.gflags; -- hvm_irq_dpci->msi_gvec_pirq[pt_irq_bind->u.msi.gvec] = pirq; -- -+ { -+ spin_unlock(&d->evtchn_lock); -+ return -EBUSY; -+ } - } - else - { -@@ -102,7 +116,10 @@ int pt_irq_create_bind_vtd( - - digl = xmalloc(struct dev_intx_gsi_link); - if ( !digl ) -+ { -+ spin_unlock(&d->evtchn_lock); - return -ENOMEM; -+ } - - digl->device = device; - digl->intx = intx; -@@ -117,11 +134,11 @@ int pt_irq_create_bind_vtd( - hvm_irq_dpci->girq[guest_gsi].machine_gsi = machine_gsi; - - /* Bind the same mirq once in the same domain */ -- if ( !(hvm_irq_dpci->mirq[machine_gsi].flags & HVM_IRQ_DPCI_VALID) ) -+ if ( !test_and_set_bit(machine_gsi, hvm_irq_dpci->mapping)) - { -- hvm_irq_dpci->mirq[machine_gsi].flags |= HVM_IRQ_DPCI_VALID; - hvm_irq_dpci->mirq[machine_gsi].dom = d; - -+ /* Init timer before binding */ - init_timer(&hvm_irq_dpci->hvm_timer[domain_irq_to_vector(d, machine_gsi)], - pt_irq_time_out, &hvm_irq_dpci->mirq[machine_gsi], 0); - /* Deal with gsi for legacy devices */ -@@ -132,37 +149,45 @@ int pt_irq_create_bind_vtd( - "VT-d irq bind: m_irq = %x device = %x intx = %x\n", - machine_gsi, device, intx); - } -+ spin_unlock(&d->evtchn_lock); - return 0; - } - - int pt_irq_destroy_bind_vtd( - struct domain *d, xen_domctl_bind_pt_irq_t *pt_irq_bind) - { -- struct hvm_irq_dpci *hvm_irq_dpci = domain_get_irq_dpci(d); -+ struct hvm_irq_dpci *hvm_irq_dpci = NULL; - uint32_t machine_gsi, guest_gsi; - uint32_t device, intx, link; - struct list_head *digl_list, *tmp; - struct dev_intx_gsi_link *digl; - -- if ( hvm_irq_dpci == NULL ) -- return 0; -- - machine_gsi = pt_irq_bind->machine_irq; - device = pt_irq_bind->u.pci.device; - intx = pt_irq_bind->u.pci.intx; - guest_gsi = hvm_pci_intx_gsi(device, intx); - link = hvm_pci_intx_link(device, intx); -- hvm_irq_dpci->link_cnt[link]--; - - gdprintk(XENLOG_INFO, - "pt_irq_destroy_bind_vtd: machine_gsi=%d " - "guest_gsi=%d, device=%d, intx=%d.\n", - machine_gsi, guest_gsi, device, intx); -+ spin_lock(&d->evtchn_lock); -+ -+ hvm_irq_dpci = domain_get_irq_dpci(d); -+ -+ if ( hvm_irq_dpci == NULL ) -+ { -+ spin_unlock(&d->evtchn_lock); -+ return -EINVAL; -+ } -+ -+ hvm_irq_dpci->link_cnt[link]--; - memset(&hvm_irq_dpci->girq[guest_gsi], 0, - sizeof(struct hvm_girq_dpci_mapping)); - - /* clear the mirq info */ -- if ( (hvm_irq_dpci->mirq[machine_gsi].flags & HVM_IRQ_DPCI_VALID) ) -+ if ( test_bit(machine_gsi, hvm_irq_dpci->mapping)) - { - list_for_each_safe ( digl_list, tmp, - &hvm_irq_dpci->mirq[machine_gsi].digl_list ) -@@ -185,9 +210,10 @@ int pt_irq_destroy_bind_vtd( - kill_timer(&hvm_irq_dpci->hvm_timer[domain_irq_to_vector(d, machine_gsi)]); - hvm_irq_dpci->mirq[machine_gsi].dom = NULL; - hvm_irq_dpci->mirq[machine_gsi].flags = 0; -+ clear_bit(machine_gsi, hvm_irq_dpci->mapping); - } - } -- -+ spin_unlock(&d->evtchn_lock); - gdprintk(XENLOG_INFO, - "XEN_DOMCTL_irq_unmapping: m_irq = %x device = %x intx = %x\n", - machine_gsi, device, intx); -@@ -199,8 +225,9 @@ int hvm_do_IRQ_dpci(struct domain *d, un - { - struct hvm_irq_dpci *dpci = domain_get_irq_dpci(d); - -+ ASSERT(spin_is_locked(&irq_desc[domain_irq_to_vector(d, mirq)].lock)); - if ( !iommu_enabled || (d == dom0) || !dpci || -- !dpci->mirq[mirq].flags & HVM_IRQ_DPCI_VALID ) -+ !test_bit(mirq, dpci->mapping)) - return 0; - - /* -@@ -218,44 +245,46 @@ int hvm_do_IRQ_dpci(struct domain *d, un - return 1; - } - -- - void hvm_dpci_msi_eoi(struct domain *d, int vector) - { - struct hvm_irq_dpci *hvm_irq_dpci = d->arch.hvm_domain.irq.dpci; -- int pirq; -- unsigned long flags; - irq_desc_t *desc; -+ int pirq; - - if ( !iommu_enabled || (hvm_irq_dpci == NULL) ) - return; - -+ spin_lock(&d->evtchn_lock); - pirq = hvm_irq_dpci->msi_gvec_pirq[vector]; - - if ( ( pirq >= 0 ) && (pirq < NR_PIRQS) && -- (hvm_irq_dpci->mirq[pirq].flags & HVM_IRQ_DPCI_VALID) && -- (hvm_irq_dpci->mirq[pirq].flags & HVM_IRQ_DPCI_MSI) ) -- { -- int vec; -- vec = domain_irq_to_vector(d, pirq); -- desc = &irq_desc[vec]; -- -- spin_lock_irqsave(&desc->lock, flags); -- desc->status &= ~IRQ_INPROGRESS; -- spin_unlock_irqrestore(&desc->lock, flags); -+ test_bit(pirq, hvm_irq_dpci->mapping) && -+ (test_bit(_HVM_IRQ_DPCI_MSI, &hvm_irq_dpci->mirq[pirq].flags))) -+ { -+ BUG_ON(!local_irq_is_enabled()); -+ desc = domain_spin_lock_irq_desc(d, pirq, NULL); -+ if (!desc) -+ { -+ spin_unlock(&d->evtchn_lock); -+ return; -+ } - -- pirq_guest_eoi(d, pirq); -- } -+ desc->status &= ~IRQ_INPROGRESS; -+ spin_unlock_irq(&desc->lock); -+ -+ pirq_guest_eoi(d, pirq); -+ } -+ -+ spin_unlock(&d->evtchn_lock); - } - - void hvm_dpci_eoi(struct domain *d, unsigned int guest_gsi, - union vioapic_redir_entry *ent) - { -- struct hvm_irq_dpci *hvm_irq_dpci = domain_get_irq_dpci(d); -+ struct hvm_irq_dpci *hvm_irq_dpci = NULL; - uint32_t device, intx, machine_gsi; - -- if ( !iommu_enabled || (hvm_irq_dpci == NULL) || -- (guest_gsi >= NR_ISAIRQS && -- !hvm_irq_dpci->girq[guest_gsi].valid) ) -+ if ( !iommu_enabled) - return; - - if ( guest_gsi < NR_ISAIRQS ) -@@ -264,23 +293,34 @@ void hvm_dpci_eoi(struct domain *d, unsi - return; - } - -- machine_gsi = hvm_irq_dpci->girq[guest_gsi].machine_gsi; -+ spin_lock(&d->evtchn_lock); -+ hvm_irq_dpci = domain_get_irq_dpci(d); -+ -+ if((hvm_irq_dpci == NULL) || -+ (guest_gsi >= NR_ISAIRQS && -+ !hvm_irq_dpci->girq[guest_gsi].valid) ) -+ { -+ spin_unlock(&d->evtchn_lock); -+ return; -+ } -+ - device = hvm_irq_dpci->girq[guest_gsi].device; - intx = hvm_irq_dpci->girq[guest_gsi].intx; - hvm_pci_intx_deassert(d, device, intx); - -- spin_lock(&hvm_irq_dpci->dirq_lock); -+ machine_gsi = hvm_irq_dpci->girq[guest_gsi].machine_gsi; - if ( --hvm_irq_dpci->mirq[machine_gsi].pending == 0 ) - { -- spin_unlock(&hvm_irq_dpci->dirq_lock); -- - if ( (ent == NULL) || !ent->fields.mask ) - { -+ /* -+ * No need to get vector lock for timer -+ * since interrupt is still not EOIed -+ */ - stop_timer(&hvm_irq_dpci->hvm_timer[ - domain_irq_to_vector(d, machine_gsi)]); - pirq_guest_eoi(d, machine_gsi); - } - } -- else -- spin_unlock(&hvm_irq_dpci->dirq_lock); -+ spin_unlock(&d->evtchn_lock); - } -Index: xen-3.3.1-testing/xen/drivers/passthrough/pci.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/pci.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/pci.c -@@ -154,7 +154,7 @@ int pci_remove_device(u8 bus, u8 devfn) - - static void pci_clean_dpci_irqs(struct domain *d) - { -- struct hvm_irq_dpci *hvm_irq_dpci = domain_get_irq_dpci(d); -+ struct hvm_irq_dpci *hvm_irq_dpci = NULL; - uint32_t i; - struct list_head *digl_list, *tmp; - struct dev_intx_gsi_link *digl; -@@ -165,13 +165,14 @@ static void pci_clean_dpci_irqs(struct d - if ( !is_hvm_domain(d) && !need_iommu(d) ) - return; - -+ spin_lock(&d->evtchn_lock); -+ hvm_irq_dpci = domain_get_irq_dpci(d); - if ( hvm_irq_dpci != NULL ) - { -- for ( i = 0; i < NR_IRQS; i++ ) -+ for ( i = find_first_bit(hvm_irq_dpci->mapping, NR_PIRQS); -+ i < NR_PIRQS; -+ i = find_next_bit(hvm_irq_dpci->mapping, NR_PIRQS, i + 1) ) - { -- if ( !(hvm_irq_dpci->mirq[i].flags & HVM_IRQ_DPCI_VALID) ) -- continue; -- - pirq_guest_unbind(d, i); - kill_timer(&hvm_irq_dpci->hvm_timer[irq_to_vector(i)]); - -@@ -188,6 +189,7 @@ static void pci_clean_dpci_irqs(struct d - d->arch.hvm_domain.irq.dpci = NULL; - xfree(hvm_irq_dpci); - } -+ spin_unlock(&d->evtchn_lock); - } - - void pci_release_devices(struct domain *d) -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/x86/vtd.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/x86/vtd.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/x86/vtd.c -@@ -85,37 +85,41 @@ int domain_set_irq_dpci(struct domain *d - void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq) - { - struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; -- struct hvm_irq_dpci *dpci = domain_get_irq_dpci(d); -+ struct hvm_irq_dpci *dpci = NULL; - struct dev_intx_gsi_link *digl, *tmp; - int i; - - ASSERT(isairq < NR_ISAIRQS); -- if ( !vtd_enabled || !dpci || -- !test_bit(isairq, dpci->isairq_map) ) -+ if ( !vtd_enabled) - return; - -+ spin_lock(&d->evtchn_lock); -+ -+ dpci = domain_get_irq_dpci(d); -+ -+ if ( !dpci || !test_bit(isairq, dpci->isairq_map) ) -+ { -+ spin_unlock(&d->evtchn_lock); -+ return; -+ } - /* Multiple mirq may be mapped to one isa irq */ -- for ( i = 0; i < NR_IRQS; i++ ) -+ for ( i = find_first_bit(dpci->mapping, NR_PIRQS); -+ i < NR_PIRQS; -+ i = find_next_bit(dpci->mapping, NR_PIRQS, i + 1) ) - { -- if ( !dpci->mirq[i].flags & HVM_IRQ_DPCI_VALID ) -- continue; -- - list_for_each_entry_safe ( digl, tmp, - &dpci->mirq[i].digl_list, list ) - { - if ( hvm_irq->pci_link.route[digl->link] == isairq ) - { - hvm_pci_intx_deassert(d, digl->device, digl->intx); -- spin_lock(&dpci->dirq_lock); - if ( --dpci->mirq[i].pending == 0 ) - { -- spin_unlock(&dpci->dirq_lock); - stop_timer(&dpci->hvm_timer[domain_irq_to_vector(d, i)]); - pirq_guest_eoi(d, i); - } -- else -- spin_unlock(&dpci->dirq_lock); - } - } - } -+ spin_unlock(&d->evtchn_lock); - } -Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/irq.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/hvm/irq.h -+++ xen-3.3.1-testing/xen/include/asm-x86/hvm/irq.h -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -38,8 +39,6 @@ struct dev_intx_gsi_link { - uint8_t link; - }; - --#define HVM_IRQ_DPCI_VALID 0x1 --#define HVM_IRQ_DPCI_MSI 0x2 - #define _HVM_IRQ_DPCI_MSI 0x1 - - struct hvm_gmsi_info { -@@ -64,9 +63,10 @@ struct hvm_girq_dpci_mapping { - - #define NR_ISAIRQS 16 - #define NR_LINK 4 -+/* Protected by domain's evtchn_lock */ - struct hvm_irq_dpci { -- spinlock_t dirq_lock; - /* Machine IRQ to guest device/intx mapping. */ -+ DECLARE_BITMAP(mapping, NR_PIRQS); - struct hvm_mirq_dpci_mapping mirq[NR_IRQS]; - /* Guest IRQ to guest device/intx mapping. */ - struct hvm_girq_dpci_mapping girq[NR_IRQS]; -Index: xen-3.3.1-testing/xen/include/xen/irq.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/xen/irq.h -+++ xen-3.3.1-testing/xen/include/xen/irq.h -@@ -78,6 +78,8 @@ extern int pirq_guest_eoi(struct domain - extern int pirq_guest_unmask(struct domain *d); - extern int pirq_guest_bind(struct vcpu *v, int irq, int will_share); - extern void pirq_guest_unbind(struct domain *d, int irq); -+extern irq_desc_t *domain_spin_lock_irq_desc( -+ struct domain *d, int irq, unsigned long *pflags); - - static inline void set_native_irq_info(int irq, cpumask_t mask) - { diff --git a/18584-evtchn-lock-rename.patch b/18584-evtchn-lock-rename.patch deleted file mode 100644 index 00e4a6c..0000000 --- a/18584-evtchn-lock-rename.patch +++ /dev/null @@ -1,808 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1223547471 -3600 -# Node ID 0033c944318f266a0e367678bf9f46042ae03397 -# Parent a11ad61bdb5b188a8116b533c87c31d6e9bd62d4 -Rename evtchn_lock to event_lock, since it protects more than just -event-channel state now. - -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/hvm/svm/intr.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/hvm/svm/intr.c -+++ xen-3.3.1-testing/xen/arch/x86/hvm/svm/intr.c -@@ -124,11 +124,11 @@ static void svm_dirq_assist(struct vcpu - if ( !test_and_clear_bit(irq, &hvm_irq_dpci->dirq_mask) ) - continue; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - if ( test_bit(_HVM_IRQ_DPCI_MSI, &hvm_irq_dpci->mirq[irq].flags) ) - { - hvm_pci_msi_assert(d, irq); -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - continue; - } - -@@ -151,7 +151,7 @@ static void svm_dirq_assist(struct vcpu - */ - set_timer(&hvm_irq_dpci->hvm_timer[domain_irq_to_vector(d, irq)], - NOW() + PT_IRQ_TIME_OUT); -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - } - } - -Index: xen-3.3.1-testing/xen/arch/x86/hvm/vmx/intr.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/hvm/vmx/intr.c -+++ xen-3.3.1-testing/xen/arch/x86/hvm/vmx/intr.c -@@ -127,11 +127,11 @@ static void vmx_dirq_assist(struct vcpu - if ( !test_and_clear_bit(irq, &hvm_irq_dpci->dirq_mask) ) - continue; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - if ( test_bit(_HVM_IRQ_DPCI_MSI, &hvm_irq_dpci->mirq[irq].flags) ) - { - hvm_pci_msi_assert(d, irq); -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - continue; - } - -@@ -154,7 +154,7 @@ static void vmx_dirq_assist(struct vcpu - */ - set_timer(&hvm_irq_dpci->hvm_timer[domain_irq_to_vector(d, irq)], - NOW() + PT_IRQ_TIME_OUT); -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - } - } - -Index: xen-3.3.1-testing/xen/arch/x86/irq.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/irq.c -+++ xen-3.3.1-testing/xen/arch/x86/irq.c -@@ -514,7 +514,7 @@ int pirq_guest_bind(struct vcpu *v, int - int rc = 0; - cpumask_t cpumask = CPU_MASK_NONE; - -- WARN_ON(!spin_is_locked(&v->domain->evtchn_lock)); -+ WARN_ON(!spin_is_locked(&v->domain->event_lock)); - BUG_ON(!local_irq_is_enabled()); - - retry: -@@ -693,7 +693,7 @@ void pirq_guest_unbind(struct domain *d, - irq_desc_t *desc; - int vector; - -- WARN_ON(!spin_is_locked(&d->evtchn_lock)); -+ WARN_ON(!spin_is_locked(&d->event_lock)); - - BUG_ON(!local_irq_is_enabled()); - desc = domain_spin_lock_irq_desc(d, irq, NULL); -@@ -722,7 +722,7 @@ int pirq_guest_force_unbind(struct domai - irq_guest_action_t *action; - int i, bound = 0; - -- WARN_ON(!spin_is_locked(&d->evtchn_lock)); -+ WARN_ON(!spin_is_locked(&d->event_lock)); - - BUG_ON(!local_irq_is_enabled()); - desc = domain_spin_lock_irq_desc(d, irq, NULL); -@@ -749,7 +749,7 @@ int get_free_pirq(struct domain *d, int - { - int i; - -- ASSERT(spin_is_locked(&d->evtchn_lock)); -+ ASSERT(spin_is_locked(&d->event_lock)); - - if ( type == MAP_PIRQ_TYPE_GSI ) - { -@@ -779,7 +779,7 @@ int map_domain_pirq( - irq_desc_t *desc; - unsigned long flags; - -- ASSERT(spin_is_locked(&d->evtchn_lock)); -+ ASSERT(spin_is_locked(&d->event_lock)); - - if ( !IS_PRIV(current->domain) ) - return -EPERM; -@@ -847,7 +847,7 @@ int unmap_domain_pirq(struct domain *d, - if ( !IS_PRIV(current->domain) ) - return -EINVAL; - -- ASSERT(spin_is_locked(&d->evtchn_lock)); -+ ASSERT(spin_is_locked(&d->event_lock)); - - vector = d->arch.pirq_vector[pirq]; - if ( vector <= 0 ) -@@ -906,13 +906,13 @@ void free_domain_pirqs(struct domain *d) - if ( !msi_enable ) - return; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - for ( i = 0; i < NR_PIRQS; i++ ) - if ( d->arch.pirq_vector[i] > 0 ) - unmap_domain_pirq(d, i); - -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - } - - extern void dump_ioapic_irq_info(void); -Index: xen-3.3.1-testing/xen/arch/x86/physdev.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/physdev.c -+++ xen-3.3.1-testing/xen/arch/x86/physdev.c -@@ -104,7 +104,7 @@ static int physdev_map_pirq(struct physd - } - - /* Verify or get pirq. */ -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - if ( map->pirq < 0 ) - { - if ( d->arch.vector_pirq[vector] ) -@@ -149,7 +149,7 @@ static int physdev_map_pirq(struct physd - map->pirq = pirq; - - done: -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - if ( (ret != 0) && (map->type == MAP_PIRQ_TYPE_MSI) && (map->index == -1) ) - free_irq_vector(vector); - free_domain: -@@ -182,9 +182,9 @@ static int physdev_unmap_pirq(struct phy - return -ESRCH; - } - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - ret = unmap_domain_pirq(d, unmap->pirq); -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - - rcu_unlock_domain(d); - -@@ -315,10 +315,10 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H - - if ( msi_enable ) - { -- spin_lock(&dom0->evtchn_lock); -+ spin_lock(&dom0->event_lock); - ret = map_domain_pirq(dom0, irq_op.irq, irq_op.vector, - MAP_PIRQ_TYPE_GSI, NULL); -- spin_unlock(&dom0->evtchn_lock); -+ spin_unlock(&dom0->event_lock); - } - - if ( copy_to_guest(arg, &irq_op, 1) != 0 ) -Index: xen-3.3.1-testing/xen/common/event_channel.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/event_channel.c -+++ xen-3.3.1-testing/xen/common/event_channel.c -@@ -133,7 +133,7 @@ static long evtchn_alloc_unbound(evtchn_ - if ( rc ) - return rc; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - if ( (port = get_free_port(d)) < 0 ) - ERROR_EXIT_DOM(port, d); -@@ -150,7 +150,7 @@ static long evtchn_alloc_unbound(evtchn_ - alloc->port = port; - - out: -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - rcu_unlock_domain(d); - - return rc; -@@ -174,14 +174,14 @@ static long evtchn_bind_interdomain(evtc - /* Avoid deadlock by first acquiring lock of domain with smaller id. */ - if ( ld < rd ) - { -- spin_lock(&ld->evtchn_lock); -- spin_lock(&rd->evtchn_lock); -+ spin_lock(&ld->event_lock); -+ spin_lock(&rd->event_lock); - } - else - { - if ( ld != rd ) -- spin_lock(&rd->evtchn_lock); -- spin_lock(&ld->evtchn_lock); -+ spin_lock(&rd->event_lock); -+ spin_lock(&ld->event_lock); - } - - if ( (lport = get_free_port(ld)) < 0 ) -@@ -216,9 +216,9 @@ static long evtchn_bind_interdomain(evtc - bind->local_port = lport; - - out: -- spin_unlock(&ld->evtchn_lock); -+ spin_unlock(&ld->event_lock); - if ( ld != rd ) -- spin_unlock(&rd->evtchn_lock); -+ spin_unlock(&rd->event_lock); - - rcu_unlock_domain(rd); - -@@ -244,7 +244,7 @@ static long evtchn_bind_virq(evtchn_bind - ((v = d->vcpu[vcpu]) == NULL) ) - return -ENOENT; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - if ( v->virq_to_evtchn[virq] != 0 ) - ERROR_EXIT(-EEXIST); -@@ -260,7 +260,7 @@ static long evtchn_bind_virq(evtchn_bind - v->virq_to_evtchn[virq] = bind->port = port; - - out: -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - - return rc; - } -@@ -277,7 +277,7 @@ static long evtchn_bind_ipi(evtchn_bind_ - (d->vcpu[vcpu] == NULL) ) - return -ENOENT; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - if ( (port = get_free_port(d)) < 0 ) - ERROR_EXIT(port); -@@ -289,7 +289,7 @@ static long evtchn_bind_ipi(evtchn_bind_ - bind->port = port; - - out: -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - - return rc; - } -@@ -308,7 +308,7 @@ static long evtchn_bind_pirq(evtchn_bind - if ( !irq_access_permitted(d, pirq) ) - return -EPERM; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - if ( d->pirq_to_evtchn[pirq] != 0 ) - ERROR_EXIT(-EEXIST); -@@ -333,7 +333,7 @@ static long evtchn_bind_pirq(evtchn_bind - bind->port = port; - - out: -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - - return rc; - } -@@ -348,7 +348,7 @@ static long __evtchn_close(struct domain - long rc = 0; - - again: -- spin_lock(&d1->evtchn_lock); -+ spin_lock(&d1->event_lock); - - if ( !port_is_valid(d1, port1) ) - { -@@ -404,12 +404,12 @@ static long __evtchn_close(struct domain - - if ( d1 < d2 ) - { -- spin_lock(&d2->evtchn_lock); -+ spin_lock(&d2->event_lock); - } - else if ( d1 != d2 ) - { -- spin_unlock(&d1->evtchn_lock); -- spin_lock(&d2->evtchn_lock); -+ spin_unlock(&d1->event_lock); -+ spin_lock(&d2->event_lock); - goto again; - } - } -@@ -454,11 +454,11 @@ static long __evtchn_close(struct domain - if ( d2 != NULL ) - { - if ( d1 != d2 ) -- spin_unlock(&d2->evtchn_lock); -+ spin_unlock(&d2->event_lock); - put_domain(d2); - } - -- spin_unlock(&d1->evtchn_lock); -+ spin_unlock(&d1->event_lock); - - return rc; - } -@@ -476,11 +476,11 @@ int evtchn_send(struct domain *d, unsign - struct vcpu *rvcpu; - int rport, ret = 0; - -- spin_lock(&ld->evtchn_lock); -+ spin_lock(&ld->event_lock); - - if ( unlikely(!port_is_valid(ld, lport)) ) - { -- spin_unlock(&ld->evtchn_lock); -+ spin_unlock(&ld->event_lock); - return -EINVAL; - } - -@@ -489,7 +489,7 @@ int evtchn_send(struct domain *d, unsign - /* Guest cannot send via a Xen-attached event channel. */ - if ( unlikely(lchn->consumer_is_xen) ) - { -- spin_unlock(&ld->evtchn_lock); -+ spin_unlock(&ld->event_lock); - return -EINVAL; - } - -@@ -527,7 +527,7 @@ int evtchn_send(struct domain *d, unsign - } - - out: -- spin_unlock(&ld->evtchn_lock); -+ spin_unlock(&ld->event_lock); - - return ret; - } -@@ -656,7 +656,7 @@ static long evtchn_status(evtchn_status_ - if ( rc ) - return rc; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - if ( !port_is_valid(d, port) ) - { -@@ -704,7 +704,7 @@ static long evtchn_status(evtchn_status_ - status->vcpu = chn->notify_vcpu_id; - - out: -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - rcu_unlock_domain(d); - - return rc; -@@ -720,7 +720,7 @@ long evtchn_bind_vcpu(unsigned int port, - if ( (vcpu_id >= ARRAY_SIZE(d->vcpu)) || (d->vcpu[vcpu_id] == NULL) ) - return -ENOENT; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - if ( !port_is_valid(d, port) ) - { -@@ -756,7 +756,7 @@ long evtchn_bind_vcpu(unsigned int port, - } - - out: -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - - return rc; - } -@@ -768,11 +768,11 @@ static long evtchn_unmask(evtchn_unmask_ - int port = unmask->port; - struct vcpu *v; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - if ( unlikely(!port_is_valid(d, port)) ) - { -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - return -EINVAL; - } - -@@ -790,7 +790,7 @@ static long evtchn_unmask(evtchn_unmask_ - vcpu_mark_events_pending(v); - } - -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - - return 0; - } -@@ -944,7 +944,7 @@ int alloc_unbound_xen_event_channel( - struct domain *d = local_vcpu->domain; - int port; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - if ( (port = get_free_port(d)) < 0 ) - goto out; -@@ -956,7 +956,7 @@ int alloc_unbound_xen_event_channel( - chn->u.unbound.remote_domid = remote_domid; - - out: -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - - return port; - } -@@ -968,11 +968,11 @@ void free_xen_event_channel( - struct evtchn *chn; - struct domain *d = local_vcpu->domain; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - if ( unlikely(d->is_dying) ) - { -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - return; - } - -@@ -981,7 +981,7 @@ void free_xen_event_channel( - BUG_ON(!chn->consumer_is_xen); - chn->consumer_is_xen = 0; - -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - - (void)__evtchn_close(d, port); - } -@@ -993,7 +993,7 @@ void notify_via_xen_event_channel(int lp - struct domain *ld = current->domain, *rd; - int rport; - -- spin_lock(&ld->evtchn_lock); -+ spin_lock(&ld->event_lock); - - ASSERT(port_is_valid(ld, lport)); - lchn = evtchn_from_port(ld, lport); -@@ -1007,13 +1007,13 @@ void notify_via_xen_event_channel(int lp - evtchn_set_pending(rd->vcpu[rchn->notify_vcpu_id], rport); - } - -- spin_unlock(&ld->evtchn_lock); -+ spin_unlock(&ld->event_lock); - } - - - int evtchn_init(struct domain *d) - { -- spin_lock_init(&d->evtchn_lock); -+ spin_lock_init(&d->event_lock); - if ( get_free_port(d) != 0 ) - return -EINVAL; - evtchn_from_port(d, 0)->state = ECS_RESERVED; -@@ -1027,7 +1027,7 @@ void evtchn_destroy(struct domain *d) - - /* After this barrier no new event-channel allocations can occur. */ - BUG_ON(!d->is_dying); -- spin_barrier(&d->evtchn_lock); -+ spin_barrier(&d->event_lock); - - /* Close all existing event channels. */ - for ( i = 0; port_is_valid(d, i); i++ ) -@@ -1037,14 +1037,14 @@ void evtchn_destroy(struct domain *d) - } - - /* Free all event-channel buckets. */ -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - for ( i = 0; i < NR_EVTCHN_BUCKETS; i++ ) - { - xsm_free_security_evtchn(d->evtchn[i]); - xfree(d->evtchn[i]); - d->evtchn[i] = NULL; - } -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - } - - static void domain_dump_evtchn_info(struct domain *d) -@@ -1053,7 +1053,7 @@ static void domain_dump_evtchn_info(stru - - printk("Domain %d polling vCPUs: %08lx\n", d->domain_id, d->poll_mask[0]); - -- if ( !spin_trylock(&d->evtchn_lock) ) -+ if ( !spin_trylock(&d->event_lock) ) - return; - - printk("Event channel information for domain %d:\n", -@@ -1094,7 +1094,7 @@ static void domain_dump_evtchn_info(stru - printk(" x=%d\n", chn->consumer_is_xen); - } - -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - } - - static void dump_evtchn_info(unsigned char key) -Index: xen-3.3.1-testing/xen/drivers/passthrough/io.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/io.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/io.c -@@ -30,7 +30,7 @@ static void pt_irq_time_out(void *data) - struct dev_intx_gsi_link *digl; - uint32_t device, intx; - -- spin_lock(&irq_map->dom->evtchn_lock); -+ spin_lock(&irq_map->dom->event_lock); - - dpci = domain_get_irq_dpci(irq_map->dom); - ASSERT(dpci); -@@ -46,7 +46,7 @@ static void pt_irq_time_out(void *data) - clear_bit(machine_gsi, dpci->dirq_mask); - vector = domain_irq_to_vector(irq_map->dom, machine_gsi); - dpci->mirq[machine_gsi].pending = 0; -- spin_unlock(&irq_map->dom->evtchn_lock); -+ spin_unlock(&irq_map->dom->event_lock); - pirq_guest_eoi(irq_map->dom, machine_gsi); - } - -@@ -62,7 +62,7 @@ int pt_irq_create_bind_vtd( - if ( pirq < 0 || pirq >= NR_PIRQS ) - return -EINVAL; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - hvm_irq_dpci = domain_get_irq_dpci(d); - if ( hvm_irq_dpci == NULL ) -@@ -70,7 +70,7 @@ int pt_irq_create_bind_vtd( - hvm_irq_dpci = xmalloc(struct hvm_irq_dpci); - if ( hvm_irq_dpci == NULL ) - { -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - return -ENOMEM; - } - memset(hvm_irq_dpci, 0, sizeof(*hvm_irq_dpci)); -@@ -81,7 +81,7 @@ int pt_irq_create_bind_vtd( - if ( domain_set_irq_dpci(d, hvm_irq_dpci) == 0 ) - { - xfree(hvm_irq_dpci); -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - return -EINVAL; - } - -@@ -101,7 +101,7 @@ int pt_irq_create_bind_vtd( - ||hvm_irq_dpci->msi_gvec_pirq[pt_irq_bind->u.msi.gvec] != pirq) - - { -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - return -EBUSY; - } - } -@@ -117,7 +117,7 @@ int pt_irq_create_bind_vtd( - digl = xmalloc(struct dev_intx_gsi_link); - if ( !digl ) - { -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - return -ENOMEM; - } - -@@ -149,7 +149,7 @@ int pt_irq_create_bind_vtd( - "VT-d irq bind: m_irq = %x device = %x intx = %x\n", - machine_gsi, device, intx); - } -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - return 0; - } - -@@ -172,13 +172,13 @@ int pt_irq_destroy_bind_vtd( - "pt_irq_destroy_bind_vtd: machine_gsi=%d " - "guest_gsi=%d, device=%d, intx=%d.\n", - machine_gsi, guest_gsi, device, intx); -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - hvm_irq_dpci = domain_get_irq_dpci(d); - - if ( hvm_irq_dpci == NULL ) - { -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - return -EINVAL; - } - -@@ -213,7 +213,7 @@ int pt_irq_destroy_bind_vtd( - clear_bit(machine_gsi, hvm_irq_dpci->mapping); - } - } -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - gdprintk(XENLOG_INFO, - "XEN_DOMCTL_irq_unmapping: m_irq = %x device = %x intx = %x\n", - machine_gsi, device, intx); -@@ -254,7 +254,7 @@ void hvm_dpci_msi_eoi(struct domain *d, - if ( !iommu_enabled || (hvm_irq_dpci == NULL) ) - return; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - pirq = hvm_irq_dpci->msi_gvec_pirq[vector]; - - if ( ( pirq >= 0 ) && (pirq < NR_PIRQS) && -@@ -265,7 +265,7 @@ void hvm_dpci_msi_eoi(struct domain *d, - desc = domain_spin_lock_irq_desc(d, pirq, NULL); - if (!desc) - { -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - return; - } - -@@ -275,7 +275,7 @@ void hvm_dpci_msi_eoi(struct domain *d, - pirq_guest_eoi(d, pirq); - } - -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - } - - void hvm_dpci_eoi(struct domain *d, unsigned int guest_gsi, -@@ -293,14 +293,14 @@ void hvm_dpci_eoi(struct domain *d, unsi - return; - } - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - hvm_irq_dpci = domain_get_irq_dpci(d); - - if((hvm_irq_dpci == NULL) || - (guest_gsi >= NR_ISAIRQS && - !hvm_irq_dpci->girq[guest_gsi].valid) ) - { -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - return; - } - -@@ -322,5 +322,5 @@ void hvm_dpci_eoi(struct domain *d, unsi - pirq_guest_eoi(d, machine_gsi); - } - } -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - } -Index: xen-3.3.1-testing/xen/drivers/passthrough/pci.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/pci.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/pci.c -@@ -165,7 +165,7 @@ static void pci_clean_dpci_irqs(struct d - if ( !is_hvm_domain(d) && !need_iommu(d) ) - return; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - hvm_irq_dpci = domain_get_irq_dpci(d); - if ( hvm_irq_dpci != NULL ) - { -@@ -189,7 +189,7 @@ static void pci_clean_dpci_irqs(struct d - d->arch.hvm_domain.irq.dpci = NULL; - xfree(hvm_irq_dpci); - } -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - } - - void pci_release_devices(struct domain *d) -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/x86/vtd.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/x86/vtd.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/x86/vtd.c -@@ -93,13 +93,13 @@ void hvm_dpci_isairq_eoi(struct domain * - if ( !vtd_enabled) - return; - -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - - dpci = domain_get_irq_dpci(d); - - if ( !dpci || !test_bit(isairq, dpci->isairq_map) ) - { -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - return; - } - /* Multiple mirq may be mapped to one isa irq */ -@@ -121,5 +121,5 @@ void hvm_dpci_isairq_eoi(struct domain * - } - } - } -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - } -Index: xen-3.3.1-testing/xen/include/asm-x86/domain.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/domain.h -+++ xen-3.3.1-testing/xen/include/asm-x86/domain.h -@@ -235,7 +235,7 @@ struct arch_domain - /* Shadow translated domain: P2M mapping */ - pagetable_t phys_table; - -- /* NB. protected by d->evtchn_lock and by irq_desc[vector].lock */ -+ /* NB. protected by d->event_lock and by irq_desc[vector].lock */ - int vector_pirq[NR_VECTORS]; - int pirq_vector[NR_PIRQS]; - -Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/irq.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/hvm/irq.h -+++ xen-3.3.1-testing/xen/include/asm-x86/hvm/irq.h -@@ -63,7 +63,7 @@ struct hvm_girq_dpci_mapping { - - #define NR_ISAIRQS 16 - #define NR_LINK 4 --/* Protected by domain's evtchn_lock */ -+/* Protected by domain's event_lock */ - struct hvm_irq_dpci { - /* Machine IRQ to guest device/intx mapping. */ - DECLARE_BITMAP(mapping, NR_PIRQS); -Index: xen-3.3.1-testing/xen/include/xen/sched.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/xen/sched.h -+++ xen-3.3.1-testing/xen/include/xen/sched.h -@@ -188,7 +188,7 @@ struct domain - - /* Event channel information. */ - struct evtchn *evtchn[NR_EVTCHN_BUCKETS]; -- spinlock_t evtchn_lock; -+ spinlock_t event_lock; - - struct grant_table *grant_table; - -Index: xen-3.3.1-testing/xen/xsm/acm/acm_simple_type_enforcement_hooks.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/xsm/acm/acm_simple_type_enforcement_hooks.c -+++ xen-3.3.1-testing/xen/xsm/acm/acm_simple_type_enforcement_hooks.c -@@ -248,11 +248,11 @@ ste_init_state(struct acm_sized_buffer * - /* a) check for event channel conflicts */ - for ( bucket = 0; bucket < NR_EVTCHN_BUCKETS; bucket++ ) - { -- spin_lock(&d->evtchn_lock); -+ spin_lock(&d->event_lock); - ports = d->evtchn[bucket]; - if ( ports == NULL) - { -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - break; - } - -@@ -280,7 +280,7 @@ ste_init_state(struct acm_sized_buffer * - printkd("%s: Policy violation in event channel domain " - "%x -> domain %x.\n", - __func__, d->domain_id, rdomid); -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - - acm_array_append_tuple(errors, - ACM_EVTCHN_SHARING_VIOLATION, -@@ -288,7 +288,7 @@ ste_init_state(struct acm_sized_buffer * - goto out; - } - } -- spin_unlock(&d->evtchn_lock); -+ spin_unlock(&d->event_lock); - } - - diff --git a/18620-x86-page-type-preemptible-fix.patch b/18620-x86-page-type-preemptible-fix.patch deleted file mode 100644 index c54e492..0000000 --- a/18620-x86-page-type-preemptible-fix.patch +++ /dev/null @@ -1,26 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1223900120 -3600 -# Node ID a26194601c8f2b223e380bbb7153df7027e8d7f5 -# Parent e4bddd01cb3ebe0c4a72603c722889b22d3943fd -x86: propagate return value of alloc_l1_table() - -A blatant mistake of mine resulted in the return value of -alloc_l1_table() to be ignored with the preemptable page table update -changes. - -Signed-off-by: Jan Beulich - -diff -r e4bddd01cb3e -r a26194601c8f xen/arch/x86/mm.c ---- a/xen/arch/x86/mm.c Mon Oct 13 10:09:09 2008 +0100 -+++ b/xen/arch/x86/mm.c Mon Oct 13 13:15:20 2008 +0100 -@@ -1883,8 +1883,7 @@ static int alloc_page_type(struct page_i - switch ( type & PGT_type_mask ) - { - case PGT_l1_page_table: -- alloc_l1_table(page); -- rc = 0; -+ rc = alloc_l1_table(page); - break; - case PGT_l2_page_table: - rc = alloc_l2_table(page, type, preemptible); diff --git a/18637-vmx-set-dr7.patch b/18637-vmx-set-dr7.patch deleted file mode 100644 index f19253a..0000000 --- a/18637-vmx-set-dr7.patch +++ /dev/null @@ -1,78 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1224147160 -3600 -# Node ID 98ff908a91b7e12d7ddc609853fa1237d1714dec -# Parent 819ab49deef1da3042d2c111d6c99c3de535dae0 -vmx: set DR7 via DOMCTL_setvcpucontext - -This patch is needed for a guest domain debugger -to support hardware watchpoint. - -Signed-off-by: Kouya Shimura - -Index: xen-3.3.1-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/domain.c -+++ xen-3.3.1-testing/xen/arch/x86/domain.c -@@ -575,7 +575,10 @@ int arch_set_info_guest( - v->arch.guest_context.user_regs.eflags |= 2; - - if ( is_hvm_vcpu(v) ) -+ { -+ hvm_set_info_guest(v); - goto out; -+ } - - /* Only CR0.TS is modifiable by guest or admin. */ - v->arch.guest_context.ctrlreg[0] &= X86_CR0_TS; -Index: xen-3.3.1-testing/xen/arch/x86/hvm/vmx/vmx.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/hvm/vmx/vmx.c -+++ xen-3.3.1-testing/xen/arch/x86/hvm/vmx/vmx.c -@@ -1165,6 +1165,13 @@ static void vmx_set_uc_mode(struct vcpu - vpid_sync_all(); - } - -+static void vmx_set_info_guest(struct vcpu *v) -+{ -+ vmx_vmcs_enter(v); -+ __vmwrite(GUEST_DR7, v->arch.guest_context.debugreg[7]); -+ vmx_vmcs_exit(v); -+} -+ - static struct hvm_function_table vmx_function_table = { - .name = "VMX", - .domain_initialise = vmx_domain_initialise, -@@ -1195,7 +1202,8 @@ static struct hvm_function_table vmx_fun - .msr_read_intercept = vmx_msr_read_intercept, - .msr_write_intercept = vmx_msr_write_intercept, - .invlpg_intercept = vmx_invlpg_intercept, -- .set_uc_mode = vmx_set_uc_mode -+ .set_uc_mode = vmx_set_uc_mode, -+ .set_info_guest = vmx_set_info_guest - }; - - static unsigned long *vpid_bitmap; -Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/hvm/hvm.h -+++ xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm.h -@@ -128,6 +128,7 @@ struct hvm_function_table { - int (*msr_write_intercept)(struct cpu_user_regs *regs); - void (*invlpg_intercept)(unsigned long vaddr); - void (*set_uc_mode)(struct vcpu *v); -+ void (*set_info_guest)(struct vcpu *v); - }; - - extern struct hvm_function_table hvm_funcs; -@@ -311,4 +312,10 @@ int hvm_virtual_to_linear_addr( - unsigned int addr_size, - unsigned long *linear_addr); - -+static inline void hvm_set_info_guest(struct vcpu *v) -+{ -+ if ( hvm_funcs.set_info_guest ) -+ return hvm_funcs.set_info_guest(v); -+} -+ - #endif /* __ASM_X86_HVM_HVM_H__ */ diff --git a/18654-xend-vcpus.patch b/18654-xend-vcpus.patch deleted file mode 100644 index b3ef18b..0000000 --- a/18654-xend-vcpus.patch +++ /dev/null @@ -1,44 +0,0 @@ -diff -r 22c89412fc8c tools/python/xen/xend/XendDomainInfo.py ---- a/tools/python/xen/xend/XendDomainInfo.py Wed Oct 15 15:58:09 2008 +0100 -+++ b/tools/python/xen/xend/XendDomainInfo.py Sun Oct 19 22:08:10 2008 -0600 -@@ -1502,23 +1502,18 @@ class XendDomainInfo: - return self.info['VCPUs_max'] - - def setVCpuCount(self, vcpus): -- if vcpus <= 0: -- raise XendError('Invalid VCPUs') -+ def vcpus_valid(n): -+ if vcpus <= 0: -+ raise XendError('Zero or less VCPUs is invalid') -+ if self.domid >= 0 and vcpus > self.info['VCPUs_max']: -+ raise XendError('Cannot set vcpus greater than max vcpus on running domain') -+ vcpus_valid(vcpus) - - self.info['vcpu_avail'] = (1 << vcpus) - 1 - if self.domid >= 0: - self.storeVm('vcpu_avail', self.info['vcpu_avail']) -- # update dom differently depending on whether we are adjusting -- # vcpu number up or down, otherwise _vcpuDomDetails does not -- # disable the vcpus -- if self.info['VCPUs_max'] > vcpus: -- # decreasing -- self._writeDom(self._vcpuDomDetails()) -- self.info['VCPUs_live'] = vcpus -- else: -- # same or increasing -- self.info['VCPUs_live'] = vcpus -- self._writeDom(self._vcpuDomDetails()) -+ self._writeDom(self._vcpuDomDetails()) -+ self.info['VCPUs_live'] = vcpus - else: - if self.info['VCPUs_max'] > vcpus: - # decreasing -@@ -1528,7 +1523,7 @@ class XendDomainInfo: - for c in range(self.info['VCPUs_max'], vcpus): - self.info['cpus'].append(list()) - self.info['VCPUs_max'] = vcpus -- xen.xend.XendDomain.instance().managed_config_save(self) -+ xen.xend.XendDomain.instance().managed_config_save(self) - log.info("Set VCPU count on domain %s to %d", self.info['name_label'], - vcpus) - diff --git a/18656-vtd-alloc-checks.patch b/18656-vtd-alloc-checks.patch deleted file mode 100644 index b7b1f8d..0000000 --- a/18656-vtd-alloc-checks.patch +++ /dev/null @@ -1,97 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1224512379 -3600 -# Node ID 2a25fd94c6f207d5b9066a1d765697a5a680fc42 -# Parent bf84c03c38eebc527786e96af4178f114a5bea41 -VT-d: correct allocation failure checks - -Checking the return value of map_domain_page() (and hence -map_vtd_domain_page()) against NULL is pointless, checking the return -value of alloc_domheap_page() (and thus alloc_pgtable_maddr()) is -mandatory, however. - -Signed-off-by: Jan Beulich - -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/intremap.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/intremap.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/intremap.c -@@ -458,7 +458,7 @@ int intremap_setup(struct iommu *iommu) - { - dprintk(XENLOG_WARNING VTDPREFIX, - "Cannot allocate memory for ir_ctrl->iremap_maddr\n"); -- return -ENODEV; -+ return -ENOMEM; - } - ir_ctrl->iremap_index = -1; - } -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/iommu.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.c -@@ -220,10 +220,10 @@ static u64 addr_to_dma_page_maddr(struct - if ( !alloc ) - break; - maddr = alloc_pgtable_maddr(); -+ if ( !maddr ) -+ break; - dma_set_pte_addr(*pte, maddr); - vaddr = map_vtd_domain_page(maddr); -- if ( !vaddr ) -- break; - - /* - * high level table always sets r/w, last level -@@ -236,8 +236,6 @@ static u64 addr_to_dma_page_maddr(struct - else - { - vaddr = map_vtd_domain_page(pte->val); -- if ( !vaddr ) -- break; - } - - if ( level == 2 ) -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/qinval.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/qinval.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/qinval.c -@@ -430,7 +430,11 @@ int qinval_setup(struct iommu *iommu) - { - qi_ctrl->qinval_maddr = alloc_pgtable_maddr(); - if ( qi_ctrl->qinval_maddr == 0 ) -- panic("Cannot allocate memory for qi_ctrl->qinval_maddr\n"); -+ { -+ dprintk(XENLOG_WARNING VTDPREFIX, -+ "Cannot allocate memory for qi_ctrl->qinval_maddr\n"); -+ return -ENOMEM; -+ } - flush->context = flush_context_qi; - flush->iotlb = flush_iotlb_qi; - } -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/x86/vtd.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/x86/vtd.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/x86/vtd.c -@@ -41,17 +41,19 @@ u64 alloc_pgtable_maddr(void) - { - struct page_info *pg; - u64 *vaddr; -+ unsigned long mfn; - - pg = alloc_domheap_page(NULL, 0); -- vaddr = map_domain_page(page_to_mfn(pg)); -- if ( !vaddr ) -+ if ( !pg ) - return 0; -+ mfn = page_to_mfn(pg); -+ vaddr = map_domain_page(mfn); - memset(vaddr, 0, PAGE_SIZE); - - iommu_flush_cache_page(vaddr); - unmap_domain_page(vaddr); - -- return page_to_maddr(pg); -+ return (u64)mfn << PAGE_SHIFT_4K; - } - - void free_pgtable_maddr(u64 maddr) diff --git a/18661-recursive-spinlocks.patch b/18661-recursive-spinlocks.patch deleted file mode 100644 index 98021db..0000000 --- a/18661-recursive-spinlocks.patch +++ /dev/null @@ -1,50 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1224519405 -3600 -# Node ID 54d74fc0037ce688e79759ca632d3918f7aaa399 -# Parent f4dab783b58b41f2c67a66d6d095887faec3c296 -spinlock: Modify recursive spinlock definitions to support up to 4095 CPUs. -Signed-off-by: Keir Fraser - ---- a/xen/include/asm-x86/spinlock.h -+++ b/xen/include/asm-x86/spinlock.h -@@ -8,11 +8,11 @@ - - typedef struct { - volatile s16 lock; -- s8 recurse_cpu; -- u8 recurse_cnt; -+ u16 recurse_cpu:12; -+ u16 recurse_cnt:4; - } spinlock_t; - --#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { 1, -1, 0 } -+#define SPIN_LOCK_UNLOCKED { 1, 0xfffu, 0 } - - #define spin_lock_init(x) do { *(x) = (spinlock_t) SPIN_LOCK_UNLOCKED; } while(0) - #define spin_is_locked(x) (*(volatile char *)(&(x)->lock) <= 0) -@@ -59,11 +59,15 @@ static inline int _raw_spin_trylock(spin - #define _raw_spin_lock_recursive(_lock) \ - do { \ - int cpu = smp_processor_id(); \ -+ /* Don't allow overflow of recurse_cpu field. */ \ -+ BUILD_BUG_ON(NR_CPUS > 0xfffu); \ - if ( likely((_lock)->recurse_cpu != cpu) ) \ - { \ - spin_lock(_lock); \ - (_lock)->recurse_cpu = cpu; \ - } \ -+ /* We support only fairly shallow recursion, else the counter overflows. */ \ -+ ASSERT((_lock)->recurse_cnt < 0xfu); \ - (_lock)->recurse_cnt++; \ - } while ( 0 ) - -@@ -71,7 +75,7 @@ static inline int _raw_spin_trylock(spin - do { \ - if ( likely(--(_lock)->recurse_cnt == 0) ) \ - { \ -- (_lock)->recurse_cpu = -1; \ -+ (_lock)->recurse_cpu = 0xfffu; \ - spin_unlock(_lock); \ - } \ - } while ( 0 ) diff --git a/18720-x86-dom-cleanup.patch b/18720-x86-dom-cleanup.patch deleted file mode 100644 index 72f6fe9..0000000 --- a/18720-x86-dom-cleanup.patch +++ /dev/null @@ -1,75 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1225113763 0 -# Node ID 11c86c51a697dab2e4a49efe3dda139ea206f423 -# Parent 101e50cffc7825065f4dd39610728a2ba3ea68b4 -x86: fix domain cleanup - -The preemptable page type handling changes modified free_page_type() -behavior without adjusting the call site in relinquish_memory(): Any -type reference left pending when leaving hypercall handlers is -associated with a page reference, and when successful free_page_type() -decrements the type refcount - hence relinquish_memory() must now also -drop the page reference. - -Also, the recursion avoidance during domain shutdown somehow (probably -by me when I merged the patch up to a newer snapshot) got screwed up: -The avoidance logic in mm.c should short circuit levels below the top -one currently being processed, rather than the top one itself. - -Signed-off-by: Jan Beulich - ---- a/xen/arch/x86/domain.c -+++ b/xen/arch/x86/domain.c -@@ -1687,6 +1687,7 @@ static int relinquish_memory( - { - if ( free_page_type(page, x, 0) != 0 ) - BUG(); -+ put_page(page); - break; - } - } ---- a/xen/arch/x86/mm.c -+++ b/xen/arch/x86/mm.c -@@ -1343,7 +1343,7 @@ static void free_l1_table(struct page_in - - static int free_l2_table(struct page_info *page, int preemptible) - { --#ifdef CONFIG_COMPAT -+#if defined(CONFIG_COMPAT) || defined(DOMAIN_DESTRUCT_AVOID_RECURSION) - struct domain *d = page_get_owner(page); - #endif - unsigned long pfn = page_to_mfn(page); -@@ -1351,6 +1351,11 @@ static int free_l2_table(struct page_inf - unsigned int i = page->nr_validated_ptes - 1; - int err = 0; - -+#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION -+ if ( d->arch.relmem == RELMEM_l3 ) -+ return 0; -+#endif -+ - pl2e = map_domain_page(pfn); - - ASSERT(page->nr_validated_ptes); -@@ -1381,7 +1386,7 @@ static int free_l3_table(struct page_inf - int rc = 0; - - #ifdef DOMAIN_DESTRUCT_AVOID_RECURSION -- if ( d->arch.relmem == RELMEM_l3 ) -+ if ( d->arch.relmem == RELMEM_l4 ) - return 0; - #endif - -@@ -1424,11 +1429,6 @@ static int free_l4_table(struct page_inf - unsigned int i = page->nr_validated_ptes - !page->partial_pte; - int rc = 0; - --#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION -- if ( d->arch.relmem == RELMEM_l4 ) -- return 0; --#endif -- - do { - if ( is_guest_l4_slot(d, i) ) - rc = put_page_from_l4e(pl4e[i], pfn, preemptible); diff --git a/18722-x86-fixmap-reserved.patch b/18722-x86-fixmap-reserved.patch deleted file mode 100644 index 32fa665..0000000 --- a/18722-x86-fixmap-reserved.patch +++ /dev/null @@ -1,19 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1225114010 0 -# Node ID 604ffa3cdcc48bbfcfe5e4ccd0af735ddc49d839 -# Parent 15aed96c7b5cd5a435754a57db13cd72b386717a -x86: First fixmap entry (0) is invalid. -Signed-off-by: Jan Beulich -Signed-off-by: Keir Fraser - ---- a/xen/include/asm-x86/fixmap.h -+++ b/xen/include/asm-x86/fixmap.h -@@ -29,6 +29,7 @@ - * from the end of virtual memory backwards. - */ - enum fixed_addresses { -+ FIX_RESERVED, /* Index 0 is reserved since fix_to_virt(0) > FIXADDR_TOP. */ - #ifdef __i386__ - FIX_PAE_HIGHMEM_0, - FIX_PAE_HIGHMEM_END = FIX_PAE_HIGHMEM_0 + NR_CPUS-1, diff --git a/18723-unmap-dom-page-const.patch b/18723-unmap-dom-page-const.patch deleted file mode 100644 index 35018be..0000000 --- a/18723-unmap-dom-page-const.patch +++ /dev/null @@ -1,58 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1225114053 0 -# Node ID 9bbb54fd9181644d2bdd3c7f93c2cba1dac1b719 -# Parent 604ffa3cdcc48bbfcfe5e4ccd0af735ddc49d839 -Constify arguments to unmap_domain_page() etc. - -Signed-off-by: Jan Beulich - ---- a/xen/arch/x86/x86_32/domain_page.c -+++ b/xen/arch/x86/x86_32/domain_page.c -@@ -114,7 +114,7 @@ void *map_domain_page(unsigned long mfn) - return (void *)va; - } - --void unmap_domain_page(void *va) -+void unmap_domain_page(const void *va) - { - unsigned int idx; - struct vcpu *v; -@@ -241,7 +241,7 @@ void *map_domain_page_global(unsigned lo - return (void *)va; - } - --void unmap_domain_page_global(void *va) -+void unmap_domain_page_global(const void *va) - { - unsigned long __va = (unsigned long)va; - l2_pgentry_t *pl2e; ---- a/xen/include/xen/domain_page.h -+++ b/xen/include/xen/domain_page.h -@@ -24,7 +24,7 @@ void *map_domain_page(unsigned long mfn) - * Pass a VA within a page previously mapped in the context of the - * currently-executing VCPU via a call to map_domain_page(). - */ --void unmap_domain_page(void *va); -+void unmap_domain_page(const void *va); - - /* - * Similar to the above calls, except the mapping is accessible in all -@@ -32,7 +32,7 @@ void unmap_domain_page(void *va); - * mappings can also be unmapped from any context. - */ - void *map_domain_page_global(unsigned long mfn); --void unmap_domain_page_global(void *va); -+void unmap_domain_page_global(const void *va); - - #define DMCACHE_ENTRY_VALID 1U - #define DMCACHE_ENTRY_HELD 2U -@@ -75,7 +75,7 @@ map_domain_page_with_cache(unsigned long - } - - static inline void --unmap_domain_page_with_cache(void *va, struct domain_mmap_cache *cache) -+unmap_domain_page_with_cache(const void *va, struct domain_mmap_cache *cache) - { - ASSERT(cache != NULL); - cache->flags &= ~DMCACHE_ENTRY_HELD; diff --git a/18724-i386-highmem-assist.patch b/18724-i386-highmem-assist.patch deleted file mode 100644 index 15891cd..0000000 --- a/18724-i386-highmem-assist.patch +++ /dev/null @@ -1,206 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1225114175 0 -# Node ID 4413d53a8320809e93142ed599a81e1bfe5ae900 -# Parent 9bbb54fd9181644d2bdd3c7f93c2cba1dac1b719 -x86: highmem handling assistance hypercalls - -While looking at the origin of very frequently executed hypercalls I -realized that the high page accessor functions in Linux would be good -candidates to handle in the hypervisor - clearing or copying to/from -a high page is a pretty frequent operation (provided there's enough -memory in the domain). While prior to the first submission I only -measured kernel builds (where the results are not hinting at a -meaningful improvement), I now found time to do a more specific -analysis: page clearing is being improved by about 20%, page copying -doesn't seem to significantly benefit (though that may be an effect of -the simplistic copy_page() implementation Xen currently uses) - -nevertheless I would think that if one function is supported by the -hypervisor, then the other should also be. - -Signed-off-by: Jan Beulich - ---- a/xen/arch/x86/mm.c -+++ b/xen/arch/x86/mm.c -@@ -2431,6 +2431,29 @@ static inline cpumask_t vcpumask_to_pcpu - return pmask; - } - -+#ifdef __i386__ -+static inline void *fixmap_domain_page(unsigned long mfn) -+{ -+ unsigned int cpu = smp_processor_id(); -+ void *ptr = (void *)fix_to_virt(FIX_PAE_HIGHMEM_0 + cpu); -+ -+ l1e_write(fix_pae_highmem_pl1e - cpu, -+ l1e_from_pfn(mfn, __PAGE_HYPERVISOR)); -+ flush_tlb_one_local(ptr); -+ return ptr; -+} -+static inline void fixunmap_domain_page(const void *ptr) -+{ -+ unsigned int cpu = virt_to_fix((unsigned long)ptr) - FIX_PAE_HIGHMEM_0; -+ -+ l1e_write(fix_pae_highmem_pl1e - cpu, l1e_empty()); -+ this_cpu(make_cr3_timestamp) = this_cpu(tlbflush_time); -+} -+#else -+#define fixmap_domain_page(mfn) mfn_to_virt(mfn) -+#define fixunmap_domain_page(ptr) ((void)(ptr)) -+#endif -+ - int do_mmuext_op( - XEN_GUEST_HANDLE(mmuext_op_t) uops, - unsigned int count, -@@ -2700,6 +2723,66 @@ int do_mmuext_op( - break; - } - -+ case MMUEXT_CLEAR_PAGE: -+ { -+ unsigned char *ptr; -+ -+ okay = !get_page_and_type_from_pagenr(mfn, PGT_writable_page, -+ FOREIGNDOM, 0); -+ if ( unlikely(!okay) ) -+ { -+ MEM_LOG("Error while clearing mfn %lx", mfn); -+ break; -+ } -+ -+ /* A page is dirtied when it's being cleared. */ -+ paging_mark_dirty(d, mfn); -+ -+ ptr = fixmap_domain_page(mfn); -+ clear_page(ptr); -+ fixunmap_domain_page(ptr); -+ -+ put_page_and_type(page); -+ break; -+ } -+ -+ case MMUEXT_COPY_PAGE: -+ { -+ const unsigned char *src; -+ unsigned char *dst; -+ unsigned long src_mfn; -+ -+ src_mfn = gmfn_to_mfn(FOREIGNDOM, op.arg2.src_mfn); -+ okay = get_page_from_pagenr(src_mfn, FOREIGNDOM); -+ if ( unlikely(!okay) ) -+ { -+ MEM_LOG("Error while copying from mfn %lx", src_mfn); -+ break; -+ } -+ -+ okay = !get_page_and_type_from_pagenr(mfn, PGT_writable_page, -+ FOREIGNDOM, 0); -+ if ( unlikely(!okay) ) -+ { -+ put_page(mfn_to_page(src_mfn)); -+ MEM_LOG("Error while copying to mfn %lx", mfn); -+ break; -+ } -+ -+ /* A page is dirtied when it's being copied to. */ -+ paging_mark_dirty(d, mfn); -+ -+ src = map_domain_page(src_mfn); -+ dst = fixmap_domain_page(mfn); -+ copy_page(dst, src); -+ fixunmap_domain_page(dst); -+ unmap_domain_page(src); -+ -+ put_page_and_type(page); -+ put_page(mfn_to_page(src_mfn)); -+ break; -+ } -+ - default: - MEM_LOG("Invalid extended pt command 0x%x", op.cmd); - rc = -ENOSYS; ---- a/xen/arch/x86/x86_64/compat/mm.c -+++ b/xen/arch/x86/x86_64/compat/mm.c -@@ -217,6 +217,8 @@ int compat_mmuext_op(XEN_GUEST_HANDLE(mm - case MMUEXT_PIN_L4_TABLE: - case MMUEXT_UNPIN_TABLE: - case MMUEXT_NEW_BASEPTR: -+ case MMUEXT_CLEAR_PAGE: -+ case MMUEXT_COPY_PAGE: - arg1 = XLAT_mmuext_op_arg1_mfn; - break; - default: -@@ -244,6 +246,9 @@ int compat_mmuext_op(XEN_GUEST_HANDLE(mm - case MMUEXT_INVLPG_MULTI: - arg2 = XLAT_mmuext_op_arg2_vcpumask; - break; -+ case MMUEXT_COPY_PAGE: -+ arg2 = XLAT_mmuext_op_arg2_src_mfn; -+ break; - default: - arg2 = -1; - break; ---- a/xen/common/kernel.c -+++ b/xen/common/kernel.c -@@ -222,6 +222,7 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDL - #ifdef CONFIG_X86 - if ( !is_hvm_vcpu(current) ) - fi.submap |= (1U << XENFEAT_mmu_pt_update_preserve_ad) | -+ (1U << XENFEAT_highmem_assist) | - (1U << XENFEAT_gnttab_map_avail_bits); - #endif - break; ---- a/xen/include/public/features.h -+++ b/xen/include/public/features.h -@@ -59,6 +59,9 @@ - /* x86: Does this Xen host support the MMU_PT_UPDATE_PRESERVE_AD hypercall? */ - #define XENFEAT_mmu_pt_update_preserve_ad 5 - -+/* x86: Does this Xen host support the MMU_{CLEAR,COPY}_PAGE hypercall? */ -+#define XENFEAT_highmem_assist 6 -+ - /* - * If set, GNTTABOP_map_grant_ref honors flags to be placed into guest kernel - * available pte bits. ---- a/xen/include/public/xen.h -+++ b/xen/include/public/xen.h -@@ -231,6 +231,13 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); - * cmd: MMUEXT_SET_LDT - * linear_addr: Linear address of LDT base (NB. must be page-aligned). - * nr_ents: Number of entries in LDT. -+ * -+ * cmd: MMUEXT_CLEAR_PAGE -+ * mfn: Machine frame number to be cleared. -+ * -+ * cmd: MMUEXT_COPY_PAGE -+ * mfn: Machine frame number of the destination page. -+ * src_mfn: Machine frame number of the source page. - */ - #define MMUEXT_PIN_L1_TABLE 0 - #define MMUEXT_PIN_L2_TABLE 1 -@@ -247,12 +254,15 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); - #define MMUEXT_FLUSH_CACHE 12 - #define MMUEXT_SET_LDT 13 - #define MMUEXT_NEW_USER_BASEPTR 15 -+#define MMUEXT_CLEAR_PAGE 16 -+#define MMUEXT_COPY_PAGE 17 - - #ifndef __ASSEMBLY__ - struct mmuext_op { - unsigned int cmd; - union { -- /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR */ -+ /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR -+ * CLEAR_PAGE, COPY_PAGE */ - xen_pfn_t mfn; - /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */ - unsigned long linear_addr; -@@ -266,6 +276,8 @@ struct mmuext_op { - #else - void *vcpumask; - #endif -+ /* COPY_PAGE */ -+ xen_pfn_t src_mfn; - } arg2; - }; - typedef struct mmuext_op mmuext_op_t; diff --git a/18731-x86-dom-cleanup.patch b/18731-x86-dom-cleanup.patch deleted file mode 100644 index 757e140..0000000 --- a/18731-x86-dom-cleanup.patch +++ /dev/null @@ -1,57 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1225193120 0 -# Node ID 19549b9766fdd68380ded8efd975c41269ab2801 -# Parent 2c20d026bb55722247c0d9ab81c125118a10346f -x86: Fix circular page reference destruction in relinquish_memory(). - -Tested by Jan Beulich and fixes a memory leak, but there is more to be -done here. - -Signed-off-by: Keir Fraser - ---- a/xen/arch/x86/domain.c -+++ b/xen/arch/x86/domain.c -@@ -1687,7 +1687,6 @@ static int relinquish_memory( - { - if ( free_page_type(page, x, 0) != 0 ) - BUG(); -- put_page(page); - break; - } - } ---- a/xen/arch/x86/mm.c -+++ b/xen/arch/x86/mm.c -@@ -1973,6 +1973,7 @@ int free_page_type(struct page_info *pag - page->nr_validated_ptes = 1U << PAGETABLE_ORDER; - page->partial_pte = 0; - } -+ - switch ( type & PGT_type_mask ) - { - case PGT_l1_page_table: -@@ -1998,6 +1999,15 @@ int free_page_type(struct page_info *pag - BUG(); - } - -+ return rc; -+} -+ -+ -+static int __put_final_page_type( -+ struct page_info *page, unsigned long type, int preemptible) -+{ -+ int rc = free_page_type(page, type, preemptible); -+ - /* No need for atomic update of type_info here: noone else updates it. */ - if ( rc == 0 ) - { -@@ -2062,7 +2072,7 @@ static int __put_page_type(struct page_i - x, nx)) != x) ) - continue; - /* We cleared the 'valid bit' so we do the clean up. */ -- return free_page_type(page, x, preemptible); -+ return __put_final_page_type(page, x, preemptible); - } - - /* diff --git a/18735-x86-dom-cleanup.patch b/18735-x86-dom-cleanup.patch deleted file mode 100644 index 7a169b5..0000000 --- a/18735-x86-dom-cleanup.patch +++ /dev/null @@ -1,22 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1225285777 0 -# Node ID ae100f264f6ad4e828de1ca2d228cccf6ed2bbfd -# Parent 183d2d7adc2f02db63aedaf199e3b006d2e4a053 -x86: Fix relinquish_memory() for PGT_partial pages. - -Original patch by Jan Beulich. - -Signed-off-by: Keir Fraser - ---- a/xen/arch/x86/domain.c -+++ b/xen/arch/x86/domain.c -@@ -1687,6 +1687,8 @@ static int relinquish_memory( - { - if ( free_page_type(page, x, 0) != 0 ) - BUG(); -+ if ( x & PGT_partial ) -+ page->u.inuse.type_info--; - break; - } - } diff --git a/18741-x86-dom-cleanup-no-hack.patch b/18741-x86-dom-cleanup-no-hack.patch deleted file mode 100644 index 7b66581..0000000 --- a/18741-x86-dom-cleanup-no-hack.patch +++ /dev/null @@ -1,147 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1225377468 0 -# Node ID 9e5cf6778a6d1057900c3709f544ac176ddfab67 -# Parent 112e81ae5824e213b181a65f944b729ba270d658 -x86: eliminate domain cleanup hack in favor of using the preemptable -flavors of the respective functions. - -Signed-off-by: Jan Beulich - ---- a/xen/arch/x86/domain.c -+++ b/xen/arch/x86/domain.c -@@ -1639,32 +1639,23 @@ static int relinquish_memory( - } - - if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) ) -- put_page_and_type(page); -+ ret = put_page_and_type_preemptible(page, 1); -+ switch ( ret ) -+ { -+ case 0: -+ break; -+ case -EAGAIN: -+ case -EINTR: -+ set_bit(_PGT_pinned, &page->u.inuse.type_info); -+ put_page(page); -+ goto out; -+ default: -+ BUG(); -+ } - - if ( test_and_clear_bit(_PGC_allocated, &page->count_info) ) - put_page(page); - --#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION -- /* -- * Forcibly drop reference counts of page tables above top most (which -- * were skipped to prevent long latencies due to deep recursion - see -- * the special treatment in free_lX_table()). -- */ -- y = page->u.inuse.type_info; -- if ( (type < PGT_root_page_table) && -- unlikely(((y + PGT_type_mask) & -- (PGT_type_mask|PGT_validated)) == type) ) -- { -- BUG_ON((y & PGT_count_mask) >= -- (page->count_info & PGC_count_mask)); -- while ( y & PGT_count_mask ) -- { -- put_page_and_type(page); -- y = page->u.inuse.type_info; -- } -- } --#endif -- - /* - * Forcibly invalidate top-most, still valid page tables at this point - * to break circular 'linear page table' references as well as clean up -@@ -1685,8 +1676,23 @@ static int relinquish_memory( - x & ~(PGT_validated|PGT_partial)); - if ( likely(y == x) ) - { -- if ( free_page_type(page, x, 0) != 0 ) -+ /* No need for atomic update of type_info here: noone else updates it. */ -+ switch ( ret = free_page_type(page, x, 1) ) -+ { -+ case 0: -+ break; -+ case -EINTR: -+ page->u.inuse.type_info |= PGT_validated; -+ put_page(page); -+ ret = -EAGAIN; -+ goto out; -+ case -EAGAIN: -+ page->u.inuse.type_info |= PGT_partial; -+ put_page(page); -+ goto out; -+ default: - BUG(); -+ } - if ( x & PGT_partial ) - page->u.inuse.type_info--; - break; -@@ -1833,11 +1839,6 @@ int domain_relinquish_resources(struct d - /* fallthrough */ - - case RELMEM_done: --#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION -- ret = relinquish_memory(d, &d->page_list, PGT_l1_page_table); -- if ( ret ) -- return ret; --#endif - break; - - default: ---- a/xen/arch/x86/mm.c -+++ b/xen/arch/x86/mm.c -@@ -1343,7 +1343,7 @@ static void free_l1_table(struct page_in - - static int free_l2_table(struct page_info *page, int preemptible) - { --#if defined(CONFIG_COMPAT) || defined(DOMAIN_DESTRUCT_AVOID_RECURSION) -+#ifdef CONFIG_COMPAT - struct domain *d = page_get_owner(page); - #endif - unsigned long pfn = page_to_mfn(page); -@@ -1351,11 +1351,6 @@ static int free_l2_table(struct page_inf - unsigned int i = page->nr_validated_ptes - 1; - int err = 0; - --#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION -- if ( d->arch.relmem == RELMEM_l3 ) -- return 0; --#endif -- - pl2e = map_domain_page(pfn); - - ASSERT(page->nr_validated_ptes); -@@ -1385,11 +1380,6 @@ static int free_l3_table(struct page_inf - unsigned int i = page->nr_validated_ptes - !page->partial_pte; - int rc = 0; - --#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION -- if ( d->arch.relmem == RELMEM_l4 ) -- return 0; --#endif -- - pl3e = map_domain_page(pfn); - - do { ---- a/xen/include/asm-x86/config.h -+++ b/xen/include/asm-x86/config.h -@@ -41,14 +41,6 @@ - #define CONFIG_HOTPLUG 1 - #define CONFIG_HOTPLUG_CPU 1 - --/* -- * Avoid deep recursion when tearing down pagetables during domain destruction, -- * causing dom0 to become unresponsive and Xen to miss time-critical softirq -- * deadlines. This will ultimately be replaced by built-in preemptibility of -- * get_page_type(). -- */ --#define DOMAIN_DESTRUCT_AVOID_RECURSION 1 -- - #define HZ 100 - - #define OPT_CONSOLE_STR "vga" diff --git a/18742-x86-partial-page-ref.patch b/18742-x86-partial-page-ref.patch deleted file mode 100644 index 800851a..0000000 --- a/18742-x86-partial-page-ref.patch +++ /dev/null @@ -1,510 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1225378404 0 -# Node ID ed30f4efb728980ba84c34fc7fdc7be5f5a4a78e -# Parent 9e5cf6778a6d1057900c3709f544ac176ddfab67 -x86: fix preemptable page type handling - -- retain a page reference when PGT_partial is set on a page (and drop - it when clearing that flag) -- don't drop a page reference never acquired when freeing the page - type - of a page where the allocation of the type got preempted (and never - completed) -- don't acquire a page reference when allocating the page type of a - page where freeing the type got preempted (and never completed, and - hence didn't drop the respective reference) - -Signed-off-by: Jan Beulich - ---- a/xen/arch/x86/domain.c -+++ b/xen/arch/x86/domain.c -@@ -1683,18 +1683,24 @@ static int relinquish_memory( - break; - case -EINTR: - page->u.inuse.type_info |= PGT_validated; -+ if ( x & PGT_partial ) -+ put_page(page); - put_page(page); - ret = -EAGAIN; - goto out; - case -EAGAIN: - page->u.inuse.type_info |= PGT_partial; -- put_page(page); -+ if ( x & PGT_partial ) -+ put_page(page); - goto out; - default: - BUG(); - } - if ( x & PGT_partial ) -+ { - page->u.inuse.type_info--; -+ put_page(page); -+ } - break; - } - } ---- a/xen/arch/x86/mm.c -+++ b/xen/arch/x86/mm.c -@@ -566,19 +566,21 @@ static int get_page_from_pagenr(unsigned - static int get_page_and_type_from_pagenr(unsigned long page_nr, - unsigned long type, - struct domain *d, -+ int partial, - int preemptible) - { - struct page_info *page = mfn_to_page(page_nr); - int rc; - -- if ( unlikely(!get_page_from_pagenr(page_nr, d)) ) -+ if ( likely(partial >= 0) && -+ unlikely(!get_page_from_pagenr(page_nr, d)) ) - return -EINVAL; - - rc = (preemptible ? - get_page_type_preemptible(page, type) : - (get_page_type(page, type) ? 0 : -EINVAL)); - -- if ( rc ) -+ if ( unlikely(rc) && partial >= 0 ) - put_page(page); - - return rc; -@@ -761,7 +763,7 @@ get_page_from_l2e( - } - - rc = get_page_and_type_from_pagenr( -- l2e_get_pfn(l2e), PGT_l1_page_table, d, 0); -+ l2e_get_pfn(l2e), PGT_l1_page_table, d, 0, 0); - if ( unlikely(rc == -EINVAL) && get_l2_linear_pagetable(l2e, pfn, d) ) - rc = 0; - -@@ -772,7 +774,7 @@ get_page_from_l2e( - define_get_linear_pagetable(l3); - static int - get_page_from_l3e( -- l3_pgentry_t l3e, unsigned long pfn, struct domain *d, int preemptible) -+ l3_pgentry_t l3e, unsigned long pfn, struct domain *d, int partial, int preemptible) - { - int rc; - -@@ -786,7 +788,7 @@ get_page_from_l3e( - } - - rc = get_page_and_type_from_pagenr( -- l3e_get_pfn(l3e), PGT_l2_page_table, d, preemptible); -+ l3e_get_pfn(l3e), PGT_l2_page_table, d, partial, preemptible); - if ( unlikely(rc == -EINVAL) && get_l3_linear_pagetable(l3e, pfn, d) ) - rc = 0; - -@@ -797,7 +799,7 @@ get_page_from_l3e( - define_get_linear_pagetable(l4); - static int - get_page_from_l4e( -- l4_pgentry_t l4e, unsigned long pfn, struct domain *d, int preemptible) -+ l4_pgentry_t l4e, unsigned long pfn, struct domain *d, int partial, int preemptible) - { - int rc; - -@@ -811,7 +813,7 @@ get_page_from_l4e( - } - - rc = get_page_and_type_from_pagenr( -- l4e_get_pfn(l4e), PGT_l3_page_table, d, preemptible); -+ l4e_get_pfn(l4e), PGT_l3_page_table, d, partial, preemptible); - if ( unlikely(rc == -EINVAL) && get_l4_linear_pagetable(l4e, pfn, d) ) - rc = 0; - -@@ -961,23 +963,32 @@ static int put_page_from_l2e(l2_pgentry_ - return 1; - } - -+static int __put_page_type(struct page_info *, int preemptible); - - static int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, -- int preemptible) -+ int partial, int preemptible) - { - if ( (l3e_get_flags(l3e) & _PAGE_PRESENT) && - (l3e_get_pfn(l3e) != pfn) ) -+ { -+ if ( unlikely(partial > 0) ) -+ return __put_page_type(l3e_get_page(l3e), preemptible); - return put_page_and_type_preemptible(l3e_get_page(l3e), preemptible); -+ } - return 1; - } - - #if CONFIG_PAGING_LEVELS >= 4 - static int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, -- int preemptible) -+ int partial, int preemptible) - { - if ( (l4e_get_flags(l4e) & _PAGE_PRESENT) && - (l4e_get_pfn(l4e) != pfn) ) -+ { -+ if ( unlikely(partial > 0) ) -+ return __put_page_type(l4e_get_page(l4e), preemptible); - return put_page_and_type_preemptible(l4e_get_page(l4e), preemptible); -+ } - return 1; - } - #endif -@@ -1184,7 +1195,7 @@ static int alloc_l3_table(struct page_in - unsigned long pfn = page_to_mfn(page); - l3_pgentry_t *pl3e; - unsigned int i; -- int rc = 0; -+ int rc = 0, partial = page->partial_pte; - - #if CONFIG_PAGING_LEVELS == 3 - /* -@@ -1213,7 +1224,8 @@ static int alloc_l3_table(struct page_in - if ( is_pv_32on64_domain(d) ) - memset(pl3e + 4, 0, (L3_PAGETABLE_ENTRIES - 4) * sizeof(*pl3e)); - -- for ( i = page->nr_validated_ptes; i < L3_PAGETABLE_ENTRIES; i++ ) -+ for ( i = page->nr_validated_ptes; i < L3_PAGETABLE_ENTRIES; -+ i++, partial = 0 ) - { - if ( is_pv_32bit_domain(d) && (i == 3) ) - { -@@ -1224,16 +1236,17 @@ static int alloc_l3_table(struct page_in - rc = get_page_and_type_from_pagenr(l3e_get_pfn(pl3e[i]), - PGT_l2_page_table | - PGT_pae_xen_l2, -- d, preemptible); -+ d, partial, preemptible); - } - else if ( !is_guest_l3_slot(i) || -- (rc = get_page_from_l3e(pl3e[i], pfn, d, preemptible)) > 0 ) -+ (rc = get_page_from_l3e(pl3e[i], pfn, d, -+ partial, preemptible)) > 0 ) - continue; - - if ( rc == -EAGAIN ) - { - page->nr_validated_ptes = i; -- page->partial_pte = 1; -+ page->partial_pte = partial ?: 1; - } - else if ( rc == -EINTR && i ) - { -@@ -1257,7 +1270,7 @@ static int alloc_l3_table(struct page_in - if ( !is_guest_l3_slot(i) ) - continue; - unadjust_guest_l3e(pl3e[i], d); -- put_page_from_l3e(pl3e[i], pfn, 0); -+ put_page_from_l3e(pl3e[i], pfn, 0, 0); - } - } - -@@ -1272,18 +1285,20 @@ static int alloc_l4_table(struct page_in - unsigned long pfn = page_to_mfn(page); - l4_pgentry_t *pl4e = page_to_virt(page); - unsigned int i; -- int rc = 0; -+ int rc = 0, partial = page->partial_pte; - -- for ( i = page->nr_validated_ptes; i < L4_PAGETABLE_ENTRIES; i++ ) -+ for ( i = page->nr_validated_ptes; i < L4_PAGETABLE_ENTRIES; -+ i++, partial = 0 ) - { - if ( !is_guest_l4_slot(d, i) || -- (rc = get_page_from_l4e(pl4e[i], pfn, d, preemptible)) > 0 ) -+ (rc = get_page_from_l4e(pl4e[i], pfn, d, -+ partial, preemptible)) > 0 ) - continue; - - if ( rc == -EAGAIN ) - { - page->nr_validated_ptes = i; -- page->partial_pte = 1; -+ page->partial_pte = partial ?: 1; - } - else if ( rc == -EINTR ) - { -@@ -1299,7 +1314,7 @@ static int alloc_l4_table(struct page_in - MEM_LOG("Failure in alloc_l4_table: entry %d", i); - while ( i-- > 0 ) - if ( is_guest_l4_slot(d, i) ) -- put_page_from_l4e(pl4e[i], pfn, 0); -+ put_page_from_l4e(pl4e[i], pfn, 0, 0); - } - if ( rc < 0 ) - return rc; -@@ -1377,19 +1392,20 @@ static int free_l3_table(struct page_inf - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); - l3_pgentry_t *pl3e; -- unsigned int i = page->nr_validated_ptes - !page->partial_pte; -- int rc = 0; -+ int rc = 0, partial = page->partial_pte; -+ unsigned int i = page->nr_validated_ptes - !partial; - - pl3e = map_domain_page(pfn); - - do { - if ( is_guest_l3_slot(i) ) - { -- rc = put_page_from_l3e(pl3e[i], pfn, preemptible); -+ rc = put_page_from_l3e(pl3e[i], pfn, partial, preemptible); -+ if ( rc < 0 ) -+ break; -+ partial = 0; - if ( rc > 0 ) - continue; -- if ( rc ) -- break; - unadjust_guest_l3e(pl3e[i], d); - } - } while ( i-- ); -@@ -1399,7 +1415,7 @@ static int free_l3_table(struct page_inf - if ( rc == -EAGAIN ) - { - page->nr_validated_ptes = i; -- page->partial_pte = 1; -+ page->partial_pte = partial ?: -1; - } - else if ( rc == -EINTR && i < L3_PAGETABLE_ENTRIES - 1 ) - { -@@ -1416,18 +1432,21 @@ static int free_l4_table(struct page_inf - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); - l4_pgentry_t *pl4e = page_to_virt(page); -- unsigned int i = page->nr_validated_ptes - !page->partial_pte; -- int rc = 0; -+ int rc = 0, partial = page->partial_pte; -+ unsigned int i = page->nr_validated_ptes - !partial; - - do { - if ( is_guest_l4_slot(d, i) ) -- rc = put_page_from_l4e(pl4e[i], pfn, preemptible); -- } while ( rc >= 0 && i-- ); -+ rc = put_page_from_l4e(pl4e[i], pfn, partial, preemptible); -+ if ( rc < 0 ) -+ break; -+ partial = 0; -+ } while ( i-- ); - - if ( rc == -EAGAIN ) - { - page->nr_validated_ptes = i; -- page->partial_pte = 1; -+ page->partial_pte = partial ?: -1; - } - else if ( rc == -EINTR && i < L4_PAGETABLE_ENTRIES - 1 ) - { -@@ -1703,7 +1722,7 @@ static int mod_l3_entry(l3_pgentry_t *pl - return rc ? 0 : -EFAULT; - } - -- rc = get_page_from_l3e(nl3e, pfn, d, preemptible); -+ rc = get_page_from_l3e(nl3e, pfn, d, 0, preemptible); - if ( unlikely(rc < 0) ) - return page_unlock(l3pg), rc; - rc = 0; -@@ -1732,7 +1751,7 @@ static int mod_l3_entry(l3_pgentry_t *pl - } - - page_unlock(l3pg); -- put_page_from_l3e(ol3e, pfn, 0); -+ put_page_from_l3e(ol3e, pfn, 0, 0); - return rc; - } - -@@ -1781,7 +1800,7 @@ static int mod_l4_entry(l4_pgentry_t *pl - return rc ? 0 : -EFAULT; - } - -- rc = get_page_from_l4e(nl4e, pfn, d, preemptible); -+ rc = get_page_from_l4e(nl4e, pfn, d, 0, preemptible); - if ( unlikely(rc < 0) ) - return page_unlock(l4pg), rc; - rc = 0; -@@ -1802,7 +1821,7 @@ static int mod_l4_entry(l4_pgentry_t *pl - } - - page_unlock(l4pg); -- put_page_from_l4e(ol4e, pfn, 0); -+ put_page_from_l4e(ol4e, pfn, 0, 0); - return rc; - } - -@@ -1866,6 +1885,10 @@ static int alloc_page_type(struct page_i - struct domain *owner = page_get_owner(page); - int rc; - -+ /* Obtain an extra reference to retain if we set PGT_partial. */ -+ if ( preemptible && !get_page(page, owner) ) -+ return -EINVAL; -+ - /* A page table is dirtied when its type count becomes non-zero. */ - if ( likely(owner != NULL) ) - paging_mark_dirty(owner, page_to_mfn(page)); -@@ -1900,8 +1923,13 @@ static int alloc_page_type(struct page_i - if ( rc == -EAGAIN ) - { - page->u.inuse.type_info |= PGT_partial; -+ return -EAGAIN; - } -- else if ( rc == -EINTR ) -+ -+ if ( preemptible ) -+ put_page(page); -+ -+ if ( rc == -EINTR ) - { - ASSERT((page->u.inuse.type_info & - (PGT_count_mask|PGT_validated|PGT_partial)) == 1); -@@ -2029,8 +2057,13 @@ static int __put_final_page_type( - BUG_ON(rc != -EAGAIN); - wmb(); - page->u.inuse.type_info |= PGT_partial; -+ /* Must skip put_page() below. */ -+ preemptible = 0; - } - -+ if ( preemptible ) -+ put_page(page); -+ - return rc; - } - -@@ -2040,6 +2073,10 @@ static int __put_page_type(struct page_i - { - unsigned long nx, x, y = page->u.inuse.type_info; - -+ /* Obtain an extra reference to retain if we set PGT_partial. */ -+ if ( preemptible && !get_page(page, page_get_owner(page)) ) -+ return -EINVAL; -+ - for ( ; ; ) - { - x = y; -@@ -2061,6 +2098,8 @@ static int __put_page_type(struct page_i - if ( unlikely((y = cmpxchg(&page->u.inuse.type_info, - x, nx)) != x) ) - continue; -+ if ( x & PGT_partial ) -+ put_page(page); - /* We cleared the 'valid bit' so we do the clean up. */ - return __put_final_page_type(page, x, preemptible); - } -@@ -2081,9 +2120,16 @@ static int __put_page_type(struct page_i - break; - - if ( preemptible && hypercall_preempt_check() ) -+ { -+ if ( preemptible ) -+ put_page(page); - return -EINTR; -+ } - } - -+ if ( preemptible ) -+ put_page(page); -+ - return 0; - } - -@@ -2187,7 +2233,11 @@ static int __get_page_type(struct page_i - } - - if ( likely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) == x) ) -+ { -+ if ( (x & PGT_partial) && !(nx & PGT_partial) ) -+ put_page(page); - break; -+ } - - if ( preemptible && hypercall_preempt_check() ) - return -EINTR; -@@ -2296,7 +2346,7 @@ int new_guest_cr3(unsigned long mfn) - #endif - okay = paging_mode_refcounts(d) - ? get_page_from_pagenr(mfn, d) -- : !get_page_and_type_from_pagenr(mfn, PGT_root_page_table, d, 0); -+ : !get_page_and_type_from_pagenr(mfn, PGT_root_page_table, d, 0, 0); - if ( unlikely(!okay) ) - { - MEM_LOG("Error while installing new baseptr %lx", mfn); -@@ -2540,7 +2590,7 @@ int do_mmuext_op( - if ( paging_mode_refcounts(FOREIGNDOM) ) - break; - -- rc = get_page_and_type_from_pagenr(mfn, type, FOREIGNDOM, 1); -+ rc = get_page_and_type_from_pagenr(mfn, type, FOREIGNDOM, 0, 1); - okay = !rc; - if ( unlikely(!okay) ) - { -@@ -2621,7 +2671,7 @@ int do_mmuext_op( - okay = get_page_from_pagenr(mfn, d); - else - okay = !get_page_and_type_from_pagenr( -- mfn, PGT_root_page_table, d, 0); -+ mfn, PGT_root_page_table, d, 0, 0); - if ( unlikely(!okay) ) - { - MEM_LOG("Error while installing new mfn %lx", mfn); -@@ -2728,7 +2778,7 @@ int do_mmuext_op( - unsigned char *ptr; - - okay = !get_page_and_type_from_pagenr(mfn, PGT_writable_page, -- FOREIGNDOM, 0); -+ FOREIGNDOM, 0, 0); - if ( unlikely(!okay) ) - { - MEM_LOG("Error while clearing mfn %lx", mfn); -@@ -2761,7 +2811,7 @@ int do_mmuext_op( - } - - okay = !get_page_and_type_from_pagenr(mfn, PGT_writable_page, -- FOREIGNDOM, 0); -+ FOREIGNDOM, 0, 0); - if ( unlikely(!okay) ) - { - put_page(mfn_to_page(src_mfn)); ---- a/xen/include/asm-x86/mm.h -+++ b/xen/include/asm-x86/mm.h -@@ -61,12 +61,36 @@ struct page_info - /* - * When PGT_partial is true then this field is valid and indicates - * that PTEs in the range [0, @nr_validated_ptes) have been validated. -- * If @partial_pte is true then PTE at @nr_validated_ptes+1 has been -- * partially validated. -+ * An extra page reference must be acquired (or not dropped) whenever -+ * PGT_partial gets set, and it must be dropped when the flag gets -+ * cleared. This is so that a get() leaving a page in partially -+ * validated state (where the caller would drop the reference acquired -+ * due to the getting of the type [apparently] failing [-EAGAIN]) -+ * would not accidentally result in a page left with zero general -+ * reference count, but non-zero type reference count (possible when -+ * the partial get() is followed immediately by domain destruction). -+ * Likewise, the ownership of the single type reference for partially -+ * (in-)validated pages is tied to this flag, i.e. the instance -+ * setting the flag must not drop that reference, whereas the instance -+ * clearing it will have to. -+ * -+ * If @partial_pte is positive then PTE at @nr_validated_ptes+1 has -+ * been partially validated. This implies that the general reference -+ * to the page (acquired from get_page_from_lNe()) would be dropped -+ * (again due to the apparent failure) and hence must be re-acquired -+ * when resuming the validation, but must not be dropped when picking -+ * up the page for invalidation. -+ * -+ * If @partial_pte is negative then PTE at @nr_validated_ptes+1 has -+ * been partially invalidated. This is basically the opposite case of -+ * above, i.e. the general reference to the page was not dropped in -+ * put_page_from_lNe() (due to the apparent failure), and hence it -+ * must be dropped when the put operation is resumed (and completes), -+ * but it must not be acquired if picking up the page for validation. - */ - struct { - u16 nr_validated_ptes; -- bool_t partial_pte; -+ s8 partial_pte; - }; - - /* diff --git a/18745-xend-ioport-irq.patch b/18745-xend-ioport-irq.patch deleted file mode 100644 index f45d163..0000000 --- a/18745-xend-ioport-irq.patch +++ /dev/null @@ -1,99 +0,0 @@ -Index: xen-3.3.1-testing/tools/python/xen/xend/server/iopif.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/server/iopif.py -+++ xen-3.3.1-testing/tools/python/xen/xend/server/iopif.py -@@ -45,9 +45,22 @@ def parse_ioport(val): - - class IOPortsController(DevController): - -+ valid_cfg = ['to', 'from', 'uuid'] -+ - def __init__(self, vm): - DevController.__init__(self, vm) - -+ def getDeviceConfiguration(self, devid, transaction = None): -+ result = DevController.getDeviceConfiguration(self, devid, transaction) -+ if transaction is None: -+ devinfo = self.readBackend(devid, *self.valid_cfg) -+ else: -+ devinfo = self.readBackendTxn(transaction, devid, *self.valid_cfg) -+ config = dict(zip(self.valid_cfg, devinfo)) -+ config = dict([(key, val) for key, val in config.items() -+ if val != None]) -+ return config -+ - def getDeviceDetails(self, config): - """@see DevController.getDeviceDetails""" - -@@ -81,4 +94,9 @@ class IOPortsController(DevController): - 'ioports: Failed to configure legacy i/o range: %s - %s' % - (io_from, io_to)) - -- return (None, {}, {}) -+ back = dict([(k, config[k]) for k in self.valid_cfg if k in config]) -+ return (self.allocateDeviceID(), back, {}) -+ -+ def waitForDevice(self, devid): -+ # don't wait for hotplug -+ return -Index: xen-3.3.1-testing/tools/python/xen/xend/server/irqif.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/server/irqif.py -+++ xen-3.3.1-testing/tools/python/xen/xend/server/irqif.py -@@ -39,6 +39,18 @@ class IRQController(DevController): - def __init__(self, vm): - DevController.__init__(self, vm) - -+ valid_cfg = ['irq', 'uuid'] -+ -+ def getDeviceConfiguration(self, devid, transaction = None): -+ result = DevController.getDeviceConfiguration(self, devid, transaction) -+ if transaction is None: -+ devinfo = self.readBackend(devid, *self.valid_cfg) -+ else: -+ devinfo = self.readBackendTxn(transaction, devid, *self.valid_cfg) -+ config = dict(zip(self.valid_cfg, devinfo)) -+ config = dict([(key, val) for key, val in config.items() -+ if val != None]) -+ return config - - def getDeviceDetails(self, config): - """@see DevController.getDeviceDetails""" -@@ -75,4 +87,9 @@ class IRQController(DevController): - if rc < 0: - raise VmError( - 'irq: Failed to map irq %x' % (pirq)) -- return (None, {}, {}) -+ back = dict([(k, config[k]) for k in self.valid_cfg if k in config]) -+ return (self.allocateDeviceID(), back, {}) -+ -+ def waitForDevice(self, devid): -+ # don't wait for hotplug -+ return -Index: xen-3.3.1-testing/tools/python/xen/xm/create.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xm/create.py -+++ xen-3.3.1-testing/tools/python/xen/xm/create.py -@@ -1032,6 +1032,14 @@ def preprocess_ioports(vals): - ioports.append(hexd) - vals.ioports = ioports - -+def preprocess_irq(vals): -+ if not vals.irq: return -+ irq = [] -+ for v in vals.irq: -+ d = repr(v) -+ irq.append(d) -+ vals.irq = irq -+ - def preprocess_vtpm(vals): - if not vals.vtpm: return - vtpms = [] -@@ -1162,6 +1170,7 @@ def preprocess(vals): - preprocess_vscsi(vals) - preprocess_ioports(vals) - preprocess_ip(vals) -+ preprocess_irq(vals) - preprocess_nfs(vals) - preprocess_vnc(vals) - preprocess_vtpm(vals) diff --git a/18747-x86-partial-page-ref.patch b/18747-x86-partial-page-ref.patch deleted file mode 100644 index 2595543..0000000 --- a/18747-x86-partial-page-ref.patch +++ /dev/null @@ -1,198 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1225708322 0 -# Node ID 540483d2a98f3fbabf06961cc0cc52e3c59c245b -# Parent 303b1014f91e5fa0783a5d7095626a47e82db9d0 -x86: simplify page reference handling for partially (in-)validated pages - -Simplify general page reference management for preempted (partially -[in-]validated) pages: Reserve on reference that can be acquired -without the risk of overflowing the reference count, thus allowing to -have a simplified get_page() equivalent that cannot fail (but must be -used with care). - -Doing this conversion pointed out a latent issue in the changes done -previously in this area: The extra reference must be acquired before -the 'normal' reference gets dropped, so the patch fixes this at once -in both the alloc_page_type() and free_page_type() paths (it's really -only the latter that failed to work with the change described above). - -Signed-off-by: Jan Beulich - ---- a/xen/arch/x86/mm.c -+++ b/xen/arch/x86/mm.c -@@ -1856,7 +1856,8 @@ int get_page(struct page_info *page, str - nx = x + 1; - d = nd; - if ( unlikely((x & PGC_count_mask) == 0) || /* Not allocated? */ -- unlikely((nx & PGC_count_mask) == 0) || /* Count overflow? */ -+ /* Keep one spare reference to be acquired by get_page_light(). */ -+ unlikely(((nx + 1) & PGC_count_mask) <= 1) || /* Overflow? */ - unlikely(d != _domain) ) /* Wrong owner? */ - { - if ( !_shadow_mode_refcounts(domain) && !domain->is_dying ) -@@ -1878,6 +1879,28 @@ int get_page(struct page_info *page, str - return 1; - } - -+/* -+ * Special version of get_page() to be used exclusively when -+ * - a page is known to already have a non-zero reference count -+ * - the page does not need its owner to be checked -+ * - it will not be called more than once without dropping the thus -+ * acquired reference again. -+ * Due to get_page() reserving one reference, this call cannot fail. -+ */ -+static void get_page_light(struct page_info *page) -+{ -+ u32 x, nx, y = page->count_info; -+ -+ do { -+ x = y; -+ nx = x + 1; -+ BUG_ON(!(x & PGC_count_mask)); /* Not allocated? */ -+ BUG_ON(!(nx & PGC_count_mask)); /* Overflow? */ -+ y = cmpxchg(&page->count_info, x, nx); -+ } -+ while ( unlikely(y != x) ); -+} -+ - - static int alloc_page_type(struct page_info *page, unsigned long type, - int preemptible) -@@ -1885,10 +1908,6 @@ static int alloc_page_type(struct page_i - struct domain *owner = page_get_owner(page); - int rc; - -- /* Obtain an extra reference to retain if we set PGT_partial. */ -- if ( preemptible && !get_page(page, owner) ) -- return -EINVAL; -- - /* A page table is dirtied when its type count becomes non-zero. */ - if ( likely(owner != NULL) ) - paging_mark_dirty(owner, page_to_mfn(page)); -@@ -1922,14 +1941,10 @@ static int alloc_page_type(struct page_i - wmb(); - if ( rc == -EAGAIN ) - { -+ get_page_light(page); - page->u.inuse.type_info |= PGT_partial; -- return -EAGAIN; - } -- -- if ( preemptible ) -- put_page(page); -- -- if ( rc == -EINTR ) -+ else if ( rc == -EINTR ) - { - ASSERT((page->u.inuse.type_info & - (PGT_count_mask|PGT_validated|PGT_partial)) == 1); -@@ -2044,8 +2059,8 @@ static int __put_final_page_type( - } - else if ( rc == -EINTR ) - { -- ASSERT(!(page->u.inuse.type_info & -- (PGT_count_mask|PGT_validated|PGT_partial))); -+ ASSERT((page->u.inuse.type_info & -+ (PGT_count_mask|PGT_validated|PGT_partial)) == 1); - if ( !(shadow_mode_enabled(page_get_owner(page)) && - (page->count_info & PGC_page_table)) ) - page->tlbflush_timestamp = tlbflush_current_time(); -@@ -2056,14 +2071,10 @@ static int __put_final_page_type( - { - BUG_ON(rc != -EAGAIN); - wmb(); -+ get_page_light(page); - page->u.inuse.type_info |= PGT_partial; -- /* Must skip put_page() below. */ -- preemptible = 0; - } - -- if ( preemptible ) -- put_page(page); -- - return rc; - } - -@@ -2072,10 +2083,7 @@ static int __put_page_type(struct page_i - int preemptible) - { - unsigned long nx, x, y = page->u.inuse.type_info; -- -- /* Obtain an extra reference to retain if we set PGT_partial. */ -- if ( preemptible && !get_page(page, page_get_owner(page)) ) -- return -EINVAL; -+ int rc = 0; - - for ( ; ; ) - { -@@ -2098,10 +2106,11 @@ static int __put_page_type(struct page_i - if ( unlikely((y = cmpxchg(&page->u.inuse.type_info, - x, nx)) != x) ) - continue; -+ /* We cleared the 'valid bit' so we do the clean up. */ -+ rc = __put_final_page_type(page, x, preemptible); - if ( x & PGT_partial ) - put_page(page); -- /* We cleared the 'valid bit' so we do the clean up. */ -- return __put_final_page_type(page, x, preemptible); -+ break; - } - - /* -@@ -2120,17 +2129,10 @@ static int __put_page_type(struct page_i - break; - - if ( preemptible && hypercall_preempt_check() ) -- { -- if ( preemptible ) -- put_page(page); - return -EINTR; -- } - } - -- if ( preemptible ) -- put_page(page); -- -- return 0; -+ return rc; - } - - -@@ -2138,6 +2140,7 @@ static int __get_page_type(struct page_i - int preemptible) - { - unsigned long nx, x, y = page->u.inuse.type_info; -+ int rc = 0; - - ASSERT(!(type & ~(PGT_type_mask | PGT_pae_xen_l2))); - -@@ -2233,11 +2236,7 @@ static int __get_page_type(struct page_i - } - - if ( likely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) == x) ) -- { -- if ( (x & PGT_partial) && !(nx & PGT_partial) ) -- put_page(page); - break; -- } - - if ( preemptible && hypercall_preempt_check() ) - return -EINTR; -@@ -2264,10 +2263,13 @@ static int __get_page_type(struct page_i - page->nr_validated_ptes = 0; - page->partial_pte = 0; - } -- return alloc_page_type(page, type, preemptible); -+ rc = alloc_page_type(page, type, preemptible); - } - -- return 0; -+ if ( (x & PGT_partial) && !(nx & PGT_partial) ) -+ put_page(page); -+ -+ return rc; - } - - void put_page_type(struct page_info *page) diff --git a/18762-vtd-intremap-SMI-RTEs.patch b/18762-vtd-intremap-SMI-RTEs.patch deleted file mode 100644 index b34ebf8..0000000 --- a/18762-vtd-intremap-SMI-RTEs.patch +++ /dev/null @@ -1,78 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1226313701 0 -# Node ID 40668908260c7667cc5a0b75862352016c52e38f -# Parent 832efb028a1dc72fb52edc11c958fd19f8542e48 -vtd: fix interrupt remapping to handle SMI RTE's with uninitialized -reserved fields - -Some BIOS does not zero out reserve fields in IOAPIC RTE's. -clear_IO_APIC() zeroes out all RTE's except for RTE with MSI delivery -type. This is a problem when the host OS converts SMI delivery type -to some other type but leaving the reserved field uninitialized. This -can cause interrupt remapping table out of bound error if "format" -field is 1 and the uninitialized "index" field has a value that that -is larger than the maximum index of interrupt remapping table. - -Signed-off-by: Allen Kay = - -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/dmar.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/dmar.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/dmar.c -@@ -369,7 +369,9 @@ acpi_parse_one_rmrr(struct acpi_dmar_ent - - if ( rmrr->base_address >= rmrr->end_address ) - { -- dprintk(XENLOG_ERR VTDPREFIX, "RMRR is incorrect.\n"); -+ dprintk(XENLOG_ERR VTDPREFIX, -+ "RMRR error: base_addr %"PRIx64" end_address %"PRIx64"\n", -+ rmrr->base_address, rmrr->end_address); - return -EFAULT; - } - -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/intremap.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/intremap.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/intremap.c -@@ -201,7 +201,7 @@ unsigned int io_apic_read_remap_rte( - - remap_rte = (struct IO_APIC_route_remap_entry *) &old_rte; - -- if ( remap_rte->format == 0 ) -+ if ( (remap_rte->format == 0) || (old_rte.delivery_mode == dest_SMI) ) - { - *IO_APIC_BASE(apic) = rte_upper ? (reg + 1) : reg; - return *(IO_APIC_BASE(apic)+4); -@@ -247,6 +247,31 @@ void io_apic_write_remap_rte( - - remap_rte = (struct IO_APIC_route_remap_entry *) &old_rte; - -+ if ( old_rte.delivery_mode == dest_SMI ) -+ { -+ /* Some BIOS does not zero out reserve fields in IOAPIC -+ * RTE's. clear_IO_APIC() zeroes out all RTE's except for RTE -+ * with MSI delivery type. This is a problem when the host -+ * OS converts SMI delivery type to some other type but leaving -+ * the reserved field uninitialized. This can cause interrupt -+ * remapping table out of bound error if "format" field is 1 -+ * and the "index" field has a value that that is larger than -+ * the maximum index of interrupt remapping table. -+ */ -+ if ( remap_rte->format == 1 ) -+ { -+ remap_rte->format = 0; -+ *IO_APIC_BASE(apic) = reg; -+ *(IO_APIC_BASE(apic)+4) = *(((u32 *)&old_rte)+0); -+ *IO_APIC_BASE(apic) = reg + 1; -+ *(IO_APIC_BASE(apic)+4) = *(((u32 *)&old_rte)+1); -+ } -+ -+ *IO_APIC_BASE(apic) = rte_upper ? (reg + 1) : reg; -+ *(IO_APIC_BASE(apic)+4) = value; -+ return; -+ } -+ - /* mask the interrupt while we change the intremap table */ - saved_mask = remap_rte->mask; - remap_rte->mask = 1; diff --git a/18764-cpu-affinity.patch b/18764-cpu-affinity.patch deleted file mode 100644 index 194d4bb..0000000 --- a/18764-cpu-affinity.patch +++ /dev/null @@ -1,150 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1226401587 0 -# Node ID 76e90ac5067ef71f60b68ea0515f7f0466be5dca -# Parent beade55d67fc2c81adaaa552804e0b66dc25becb -xend: Restore CPU affinity on domain resume. - -Move affinity-setting logic into its own function and call from -relevant places. - -From: Jiri Denemark -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -476,6 +476,7 @@ class XendDomainInfo: - if state in (DOM_STATE_SUSPENDED, DOM_STATE_HALTED): - try: - self._constructDomain() -+ self._setCPUAffinity() - self._storeVmDetails() - self._createChannels() - self._createDevices() -@@ -2131,6 +2132,64 @@ class XendDomainInfo: - raise XendError(str(exn)) - - -+ def _setCPUAffinity(self): -+ """ Repin domain vcpus if a restricted cpus list is provided -+ """ -+ -+ def has_cpus(): -+ if self.info['cpus'] is not None: -+ for c in self.info['cpus']: -+ if c: -+ return True -+ return False -+ -+ if has_cpus(): -+ for v in range(0, self.info['VCPUs_max']): -+ if self.info['cpus'][v]: -+ xc.vcpu_setaffinity(self.domid, v, self.info['cpus'][v]) -+ else: -+ def find_relaxed_node(node_list): -+ import sys -+ nr_nodes = info['nr_nodes'] -+ if node_list is None: -+ node_list = range(0, nr_nodes) -+ nodeload = [0] -+ nodeload = nodeload * nr_nodes -+ from xen.xend import XendDomain -+ doms = XendDomain.instance().list('all') -+ for dom in filter (lambda d: d.domid != self.domid, doms): -+ cpuinfo = dom.getVCPUInfo() -+ for vcpu in sxp.children(cpuinfo, 'vcpu'): -+ if sxp.child_value(vcpu, 'online') == 0: continue -+ cpumap = list(sxp.child_value(vcpu,'cpumap')) -+ for i in range(0, nr_nodes): -+ node_cpumask = info['node_to_cpu'][i] -+ for j in node_cpumask: -+ if j in cpumap: -+ nodeload[i] += 1 -+ break -+ for i in range(0, nr_nodes): -+ if len(info['node_to_cpu'][i]) > 0 and i in node_list: -+ nodeload[i] = int(nodeload[i] * 16 / len(info['node_to_cpu'][i])) -+ else: -+ nodeload[i] = sys.maxint -+ index = nodeload.index( min(nodeload) ) -+ return index -+ -+ info = xc.physinfo() -+ if info['nr_nodes'] > 1: -+ node_memory_list = info['node_to_memory'] -+ needmem = self.image.getRequiredAvailableMemory(self.info['memory_dynamic_max']) / 1024 -+ candidate_node_list = [] -+ for i in range(0, info['nr_nodes']): -+ if node_memory_list[i] >= needmem and len(info['node_to_cpu'][i]) > 0: -+ candidate_node_list.append(i) -+ index = find_relaxed_node(candidate_node_list) -+ cpumask = info['node_to_cpu'][index] -+ for v in range(0, self.info['VCPUs_max']): -+ xc.vcpu_setaffinity(self.domid, v, cpumask) -+ -+ - def _initDomain(self): - log.debug('XendDomainInfo.initDomain: %s %s', - self.domid, -@@ -2150,58 +2209,7 @@ class XendDomainInfo: - # repin domain vcpus if a restricted cpus list is provided - # this is done prior to memory allocation to aide in memory - # distribution for NUMA systems. -- def has_cpus(): -- if self.info['cpus'] is not None: -- for c in self.info['cpus']: -- if c: -- return True -- return False -- -- if has_cpus(): -- for v in range(0, self.info['VCPUs_max']): -- if self.info['cpus'][v]: -- xc.vcpu_setaffinity(self.domid, v, self.info['cpus'][v]) -- else: -- def find_relaxed_node(node_list): -- import sys -- nr_nodes = info['nr_nodes'] -- if node_list is None: -- node_list = range(0, nr_nodes) -- nodeload = [0] -- nodeload = nodeload * nr_nodes -- from xen.xend import XendDomain -- doms = XendDomain.instance().list('all') -- for dom in filter (lambda d: d.domid != self.domid, doms): -- cpuinfo = dom.getVCPUInfo() -- for vcpu in sxp.children(cpuinfo, 'vcpu'): -- if sxp.child_value(vcpu, 'online') == 0: continue -- cpumap = list(sxp.child_value(vcpu,'cpumap')) -- for i in range(0, nr_nodes): -- node_cpumask = info['node_to_cpu'][i] -- for j in node_cpumask: -- if j in cpumap: -- nodeload[i] += 1 -- break -- for i in range(0, nr_nodes): -- if len(info['node_to_cpu'][i]) > 0 and i in node_list: -- nodeload[i] = int(nodeload[i] * 16 / len(info['node_to_cpu'][i])) -- else: -- nodeload[i] = sys.maxint -- index = nodeload.index( min(nodeload) ) -- return index -- -- info = xc.physinfo() -- if info['nr_nodes'] > 1: -- node_memory_list = info['node_to_memory'] -- needmem = self.image.getRequiredAvailableMemory(self.info['memory_dynamic_max']) / 1024 -- candidate_node_list = [] -- for i in range(0, info['nr_nodes']): -- if node_memory_list[i] >= needmem and len(info['node_to_cpu'][i]) > 0: -- candidate_node_list.append(i) -- index = find_relaxed_node(candidate_node_list) -- cpumask = info['node_to_cpu'][index] -- for v in range(0, self.info['VCPUs_max']): -- xc.vcpu_setaffinity(self.domid, v, cpumask) -+ self._setCPUAffinity() - - # Use architecture- and image-specific calculations to determine - # the various headrooms necessary, given the raw configured diff --git a/18771-reduce-GDT-switching.patch b/18771-reduce-GDT-switching.patch deleted file mode 100644 index fb81d11..0000000 --- a/18771-reduce-GDT-switching.patch +++ /dev/null @@ -1,347 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1226491295 0 -# Node ID 8e18dd41c6c7bb0980b29393b275c564cfb96437 -# Parent 2bd99c5faa420612544a9d94e298332e0e72a86a -x86: reduce GDT switching - -Both idle and HVM vCPU-s can easily run on the GDT mapped into general -hypervisor space (rather than that placed in per-vCPU virtual space). - -This makes unnecessary some of the additions c/s 18520 did. - -Signed-off-by: Jan Beulich - -Index: xen-3.3.1-testing/xen/arch/x86/cpu/common.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/cpu/common.c -+++ xen-3.3.1-testing/xen/arch/x86/cpu/common.c -@@ -564,7 +564,10 @@ void __cpuinit cpu_init(void) - { - int cpu = smp_processor_id(); - struct tss_struct *t = &init_tss[cpu]; -- char gdt_load[10]; -+ struct desc_ptr gdt_desc = { -+ .base = (unsigned long)(this_cpu(gdt_table) - FIRST_RESERVED_GDT_ENTRY), -+ .limit = LAST_RESERVED_GDT_BYTE -+ }; - - if (cpu_test_and_set(cpu, cpu_initialized)) { - printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); -@@ -578,9 +581,7 @@ void __cpuinit cpu_init(void) - /* Install correct page table. */ - write_ptbase(current); - -- *(unsigned short *)(&gdt_load[0]) = LAST_RESERVED_GDT_BYTE; -- *(unsigned long *)(&gdt_load[2]) = GDT_VIRT_START(current); -- asm volatile ( "lgdt %0" : "=m" (gdt_load) ); -+ asm volatile ( "lgdt %0" : : "m" (gdt_desc) ); - - /* No nested task. */ - asm volatile ("pushf ; andw $0xbfff,(%"__OP"sp) ; popf" ); -Index: xen-3.3.1-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/domain.c -+++ xen-3.3.1-testing/xen/arch/x86/domain.c -@@ -309,12 +309,7 @@ int vcpu_initialise(struct vcpu *v) - if ( is_idle_domain(d) ) - { - v->arch.schedule_tail = continue_idle_domain; -- if ( v->vcpu_id ) -- v->arch.cr3 = d->vcpu[0]->arch.cr3; -- else if ( !*idle_vcpu ) -- v->arch.cr3 = __pa(idle_pg_table); -- else if ( !(v->arch.cr3 = clone_idle_pagetable(v)) ) -- return -ENOMEM; -+ v->arch.cr3 = __pa(idle_pg_table); - } - - v->arch.guest_context.ctrlreg[4] = -@@ -1171,14 +1166,18 @@ static void paravirt_ctxt_switch_to(stru - } - } - -+static inline int need_full_gdt(struct vcpu *v) -+{ -+ return (!is_hvm_vcpu(v) && !is_idle_vcpu(v)); -+} -+ - static void __context_switch(void) - { - struct cpu_user_regs *stack_regs = guest_cpu_user_regs(); -- unsigned int i, cpu = smp_processor_id(); -+ unsigned int cpu = smp_processor_id(); - struct vcpu *p = per_cpu(curr_vcpu, cpu); - struct vcpu *n = current; - struct desc_struct *gdt; -- struct page_info *page; - struct desc_ptr gdt_desc; - - ASSERT(p != n); -@@ -1207,16 +1206,19 @@ static void __context_switch(void) - - gdt = !is_pv_32on64_vcpu(n) ? per_cpu(gdt_table, cpu) : - per_cpu(compat_gdt_table, cpu); -- page = virt_to_page(gdt); -- for (i = 0; i < NR_RESERVED_GDT_PAGES; ++i) -+ if ( need_full_gdt(n) ) - { -- l1e_write(n->domain->arch.mm_perdomain_pt + -- (n->vcpu_id << GDT_LDT_VCPU_SHIFT) + -- FIRST_RESERVED_GDT_PAGE + i, -- l1e_from_page(page + i, __PAGE_HYPERVISOR)); -+ struct page_info *page = virt_to_page(gdt); -+ unsigned int i; -+ for ( i = 0; i < NR_RESERVED_GDT_PAGES; i++ ) -+ l1e_write(n->domain->arch.mm_perdomain_pt + -+ (n->vcpu_id << GDT_LDT_VCPU_SHIFT) + -+ FIRST_RESERVED_GDT_PAGE + i, -+ l1e_from_page(page + i, __PAGE_HYPERVISOR)); - } - -- if ( p->vcpu_id != n->vcpu_id ) -+ if ( need_full_gdt(p) && -+ ((p->vcpu_id != n->vcpu_id) || !need_full_gdt(n)) ) - { - gdt_desc.limit = LAST_RESERVED_GDT_BYTE; - gdt_desc.base = (unsigned long)(gdt - FIRST_RESERVED_GDT_ENTRY); -@@ -1225,8 +1227,10 @@ static void __context_switch(void) - - write_ptbase(n); - -- if ( p->vcpu_id != n->vcpu_id ) -+ if ( need_full_gdt(n) && -+ ((p->vcpu_id != n->vcpu_id) || !need_full_gdt(p)) ) - { -+ gdt_desc.limit = LAST_RESERVED_GDT_BYTE; - gdt_desc.base = GDT_VIRT_START(n); - asm volatile ( "lgdt %0" : : "m" (gdt_desc) ); - } -Index: xen-3.3.1-testing/xen/arch/x86/domain_build.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/domain_build.c -+++ xen-3.3.1-testing/xen/arch/x86/domain_build.c -@@ -707,6 +707,7 @@ int __init construct_dom0( - - /* Install the new page tables. */ - local_irq_disable(); -+ /* We run on dom0's page tables for the final part of the build process. */ - write_ptbase(v); - - /* Copy the OS image and free temporary buffer. */ -@@ -719,11 +720,11 @@ int __init construct_dom0( - (parms.virt_hypercall >= v_end) ) - { - write_ptbase(current); -- local_irq_enable(); - printk("Invalid HYPERCALL_PAGE field in ELF notes.\n"); - return -1; - } -- hypercall_page_initialise(d, (void *)(unsigned long)parms.virt_hypercall); -+ hypercall_page_initialise( -+ d, (void *)(unsigned long)parms.virt_hypercall); - } - - /* Copy the initial ramdisk. */ -@@ -804,7 +805,7 @@ int __init construct_dom0( - xlat_start_info(si, XLAT_start_info_console_dom0); - #endif - -- /* Reinstate the caller's page tables. */ -+ /* Return to idle domain's page tables. */ - write_ptbase(current); - local_irq_enable(); - -Index: xen-3.3.1-testing/xen/arch/x86/hvm/vmx/vmcs.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/hvm/vmx/vmcs.c -+++ xen-3.3.1-testing/xen/arch/x86/hvm/vmx/vmcs.c -@@ -444,6 +444,8 @@ static void vmx_set_host_env(struct vcpu - { - unsigned int cpu = smp_processor_id(); - -+ __vmwrite(HOST_GDTR_BASE, -+ (unsigned long)(this_cpu(gdt_table) - FIRST_RESERVED_GDT_ENTRY)); - __vmwrite(HOST_IDTR_BASE, (unsigned long)idt_tables[cpu]); - - __vmwrite(HOST_TR_SELECTOR, TSS_ENTRY << 3); -@@ -541,9 +543,6 @@ static int construct_vmcs(struct vcpu *v - __vmwrite(IO_BITMAP_A, virt_to_maddr((char *)hvm_io_bitmap + 0)); - __vmwrite(IO_BITMAP_B, virt_to_maddr((char *)hvm_io_bitmap + PAGE_SIZE)); - -- /* Host GDTR base. */ -- __vmwrite(HOST_GDTR_BASE, GDT_VIRT_START(v)); -- - /* Host data selectors. */ - __vmwrite(HOST_SS_SELECTOR, __HYPERVISOR_DS); - __vmwrite(HOST_DS_SELECTOR, __HYPERVISOR_DS); -Index: xen-3.3.1-testing/xen/arch/x86/setup.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/setup.c -+++ xen-3.3.1-testing/xen/arch/x86/setup.c -@@ -230,7 +230,6 @@ static void __init percpu_init_areas(voi - static void __init init_idle_domain(void) - { - struct domain *idle_domain; -- unsigned int i; - - /* Domain creation requires that scheduler structures are initialised. */ - scheduler_init(); -@@ -243,12 +242,6 @@ static void __init init_idle_domain(void - idle_vcpu[0] = this_cpu(curr_vcpu) = current; - - setup_idle_pagetable(); -- -- for (i = 0; i < NR_RESERVED_GDT_PAGES; ++i) -- idle_domain->arch.mm_perdomain_pt[FIRST_RESERVED_GDT_PAGE + i] = -- l1e_from_page(virt_to_page(boot_cpu_gdt_table) + i, -- __PAGE_HYPERVISOR); -- - } - - static void __init srat_detect_node(int cpu) -@@ -456,6 +449,7 @@ void __init __start_xen(unsigned long mb - parse_video_info(); - - set_current((struct vcpu *)0xfffff000); /* debug sanity */ -+ idle_vcpu[0] = current; - set_processor_id(0); /* needed early, for smp_processor_id() */ - if ( cpu_has_efer ) - rdmsrl(MSR_EFER, this_cpu(efer)); -Index: xen-3.3.1-testing/xen/arch/x86/smpboot.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/smpboot.c -+++ xen-3.3.1-testing/xen/arch/x86/smpboot.c -@@ -828,7 +828,7 @@ static int __devinit do_boot_cpu(int api - */ - { - unsigned long boot_error; -- unsigned int i; -+ unsigned int order; - int timeout; - unsigned long start_eip; - unsigned short nmi_high = 0, nmi_low = 0; -@@ -864,21 +864,21 @@ static int __devinit do_boot_cpu(int api - - gdt = per_cpu(gdt_table, cpu); - if (gdt == boot_cpu_gdt_table) { -- i = get_order_from_pages(NR_RESERVED_GDT_PAGES); -+ order = get_order_from_pages(NR_RESERVED_GDT_PAGES); - #ifdef __x86_64__ - #ifdef CONFIG_COMPAT -- page = alloc_domheap_pages(NULL, i, -+ page = alloc_domheap_pages(NULL, order, - MEMF_node(cpu_to_node(cpu))); - per_cpu(compat_gdt_table, cpu) = gdt = page_to_virt(page); - memcpy(gdt, boot_cpu_compat_gdt_table, - NR_RESERVED_GDT_PAGES * PAGE_SIZE); - gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a = cpu; - #endif -- page = alloc_domheap_pages(NULL, i, -+ page = alloc_domheap_pages(NULL, order, - MEMF_node(cpu_to_node(cpu))); - per_cpu(gdt_table, cpu) = gdt = page_to_virt(page); - #else -- per_cpu(gdt_table, cpu) = gdt = alloc_xenheap_pages(i); -+ per_cpu(gdt_table, cpu) = gdt = alloc_xenheap_pages(order); - #endif - memcpy(gdt, boot_cpu_gdt_table, - NR_RESERVED_GDT_PAGES * PAGE_SIZE); -@@ -886,13 +886,6 @@ static int __devinit do_boot_cpu(int api - gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a = cpu; - } - -- for (i = 0; i < NR_RESERVED_GDT_PAGES; ++i) -- v->domain->arch.mm_perdomain_pt -- [(v->vcpu_id << GDT_LDT_VCPU_SHIFT) + -- FIRST_RESERVED_GDT_PAGE + i] -- = l1e_from_page(virt_to_page(gdt) + i, -- __PAGE_HYPERVISOR); -- - #ifdef __i386__ - if (!per_cpu(doublefault_tss, cpu)) { - per_cpu(doublefault_tss, cpu) = alloc_xenheap_page(); -Index: xen-3.3.1-testing/xen/arch/x86/x86_32/mm.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/x86_32/mm.c -+++ xen-3.3.1-testing/xen/arch/x86/x86_32/mm.c -@@ -132,30 +132,6 @@ void __init setup_idle_pagetable(void) - __PAGE_HYPERVISOR)); - } - --unsigned long clone_idle_pagetable(struct vcpu *v) --{ -- unsigned int i; -- struct domain *d = v->domain; -- l3_pgentry_t *l3_table = v->arch.pae_l3_cache.table[0]; -- l2_pgentry_t *l2_table = alloc_xenheap_page(); -- -- if ( !l2_table ) -- return 0; -- -- memcpy(l3_table, idle_pg_table, L3_PAGETABLE_ENTRIES * sizeof(*l3_table)); -- l3_table[l3_table_offset(PERDOMAIN_VIRT_START)] = -- l3e_from_page(virt_to_page(l2_table), _PAGE_PRESENT); -- -- copy_page(l2_table, idle_pg_table_l2 + -- l3_table_offset(PERDOMAIN_VIRT_START) * L2_PAGETABLE_ENTRIES); -- for ( i = 0; i < PDPT_L2_ENTRIES; ++i ) -- l2_table[l2_table_offset(PERDOMAIN_VIRT_START) + i] = -- l2e_from_page(virt_to_page(d->arch.mm_perdomain_pt) + i, -- __PAGE_HYPERVISOR); -- -- return __pa(l3_table); --} -- - void __init zap_low_mappings(l2_pgentry_t *dom0_l2) - { - int i; -Index: xen-3.3.1-testing/xen/arch/x86/x86_64/mm.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/x86_64/mm.c -+++ xen-3.3.1-testing/xen/arch/x86/x86_64/mm.c -@@ -21,7 +21,6 @@ - #include - #include - #include --#include - #include - #include - #include -@@ -207,24 +206,6 @@ void __init setup_idle_pagetable(void) - __PAGE_HYPERVISOR)); - } - --unsigned long clone_idle_pagetable(struct vcpu *v) --{ -- struct domain *d = v->domain; -- struct page_info *page = alloc_domheap_page(NULL, -- MEMF_node(vcpu_to_node(v))); -- l4_pgentry_t *l4_table = page_to_virt(page); -- -- if ( !page ) -- return 0; -- -- copy_page(l4_table, idle_pg_table); -- l4_table[l4_table_offset(PERDOMAIN_VIRT_START)] = -- l4e_from_page(virt_to_page(d->arch.mm_perdomain_l3), -- __PAGE_HYPERVISOR); -- -- return __pa(l4_table); --} -- - void __init zap_low_mappings(void) - { - BUG_ON(num_online_cpus() != 1); -Index: xen-3.3.1-testing/xen/include/asm-x86/page.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/page.h -+++ xen-3.3.1-testing/xen/include/asm-x86/page.h -@@ -278,7 +278,6 @@ extern unsigned int m2p_compat_vstart; - #endif - void paging_init(void); - void setup_idle_pagetable(void); --unsigned long clone_idle_pagetable(struct vcpu *); - #endif /* !defined(__ASSEMBLY__) */ - - #define _PAGE_PRESENT 0x001U diff --git a/18778-msi-irq-fix.patch b/18778-msi-irq-fix.patch deleted file mode 100644 index 32ef067..0000000 --- a/18778-msi-irq-fix.patch +++ /dev/null @@ -1,113 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1226593868 0 -# Node ID a0910b1b5ec0c938f1c46437df6c28cbeff52c68 -# Parent d44ad6db638c1308e5ee4a47509769c3cccbe1e8 -x86: don't disable MSI in order to mask an IRQ - -... as that's not really correct, and there are devices which can't -even cope with that. Instead, check whether an MSI IRQ can be masked, -and if it can't, treat it just like a level triggered IO-APIC IRQ. - -There's one other bug fix in here, correcting an off-by-one error on -the entry_nr range check in __pci_enable_msix(). - -Signed-off-by: Jan Beulich - -# HG changeset patch -# User Keir Fraser -# Date 1232549083 0 -# Node ID af1d9af1a993001bdfdb81d9af1af4fd4a9d3852 -# Parent 033945166a3a5f3078b1e583bc5e50871ef7e801 -x86: Fix unmaskable MSI handling. - -Signed-off-by: Keir Fraser - ---- a/xen/arch/x86/io_apic.c -+++ b/xen/arch/x86/io_apic.c -@@ -1567,11 +1567,14 @@ static unsigned int startup_msi_vector(u - - static void ack_msi_vector(unsigned int vector) - { -- ack_APIC_irq(); -+ if ( msi_maskable_irq(irq_desc[vector].msi_desc) ) -+ ack_APIC_irq(); /* ACKTYPE_NONE */ - } - - static void end_msi_vector(unsigned int vector) - { -+ if ( !msi_maskable_irq(irq_desc[vector].msi_desc) ) -+ ack_APIC_irq(); /* ACKTYPE_EOI */ - } - - static void shutdown_msi_vector(unsigned int vector) ---- a/xen/arch/x86/irq.c -+++ b/xen/arch/x86/irq.c -@@ -463,14 +463,19 @@ int pirq_acktype(struct domain *d, int i - /* - * Edge-triggered IO-APIC and LAPIC interrupts need no final - * acknowledgement: we ACK early during interrupt processing. -- * MSIs are treated as edge-triggered interrupts. - */ - if ( !strcmp(desc->handler->typename, "IO-APIC-edge") || -- !strcmp(desc->handler->typename, "local-APIC-edge") || -- !strcmp(desc->handler->typename, "PCI-MSI") ) -+ !strcmp(desc->handler->typename, "local-APIC-edge") ) - return ACKTYPE_NONE; - - /* -+ * MSIs are treated as edge-triggered interrupts, except -+ * when there is no proper way to mask them. -+ */ -+ if ( desc->handler == &pci_msi_type ) -+ return msi_maskable_irq(desc->msi_desc) ? ACKTYPE_NONE : ACKTYPE_EOI; -+ -+ /* - * Level-triggered IO-APIC interrupts need to be acknowledged on the CPU - * on which they were received. This is because we tickle the LAPIC to EOI. - */ ---- a/xen/arch/x86/msi.c -+++ b/xen/arch/x86/msi.c -@@ -303,6 +303,13 @@ static void msix_flush_writes(unsigned i - } - } - -+int msi_maskable_irq(const struct msi_desc *entry) -+{ -+ BUG_ON(!entry); -+ return entry->msi_attrib.type != PCI_CAP_ID_MSI -+ || entry->msi_attrib.maskbit; -+} -+ - static void msi_set_mask_bit(unsigned int irq, int flag) - { - struct msi_desc *entry = irq_desc[irq].msi_desc; -@@ -323,8 +330,6 @@ static void msi_set_mask_bit(unsigned in - mask_bits &= ~(1); - mask_bits |= flag; - pci_conf_write32(bus, slot, func, pos, mask_bits); -- } else { -- msi_set_enable(entry->dev, !flag); - } - break; - case PCI_CAP_ID_MSIX: -@@ -654,7 +659,7 @@ static int __pci_enable_msix(struct msi_ - pos = pci_find_cap_offset(msi->bus, slot, func, PCI_CAP_ID_MSIX); - control = pci_conf_read16(msi->bus, slot, func, msi_control_reg(pos)); - nr_entries = multi_msix_capable(control); -- if (msi->entry_nr > nr_entries) -+ if (msi->entry_nr >= nr_entries) - { - spin_unlock(&pdev->lock); - return -EINVAL; ---- a/xen/include/asm-x86/msi.h -+++ b/xen/include/asm-x86/msi.h -@@ -97,6 +97,8 @@ struct msi_desc { - int remap_index; /* index in interrupt remapping table */ - }; - -+int msi_maskable_irq(const struct msi_desc *); -+ - /* - * Assume the maximum number of hot plug slots supported by the system is about - * ten. The worstcase is that each of these slots is hot-added with a device, diff --git a/18780-cpu-affinity.patch b/18780-cpu-affinity.patch deleted file mode 100644 index 8b2125c..0000000 --- a/18780-cpu-affinity.patch +++ /dev/null @@ -1,21 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1226672871 0 -# Node ID 85198c4d4da516000d002f66fded65f11ef64ab6 -# Parent 3ba83def85a234d49ac426f46100dc2a6bcda761 -Fix to save CPU affinity for xm save/restore -Signed-off-by: Masaki Kanno - -Index: xen-3.3.1-testing/tools/python/xen/xend/XendConfig.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendConfig.py -@@ -1030,8 +1030,6 @@ class XendConfig(dict): - sxpr.append([name, s]) - - for xenapi, legacy in XENAPI_CFG_TO_LEGACY_CFG.items(): -- if legacy in ('cpus'): # skip this -- continue - if self.has_key(xenapi) and self[xenapi] not in (None, []): - if type(self[xenapi]) == bool: - # convert booleans to ints before making an sxp item diff --git a/18785-vlapic-lowest-prio.patch b/18785-vlapic-lowest-prio.patch deleted file mode 100644 index 67f73fb..0000000 --- a/18785-vlapic-lowest-prio.patch +++ /dev/null @@ -1,109 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1227006996 0 -# Node ID ae891977a4d3f5d8d8330ed3796881867b4d88a8 -# Parent 2604400f75e318dc9f5201e3626213290a89862a -x86, hvm: Implement interrupt routing to least priority processor. -References: bnc#429904 - -Instead of round robin the vcpu with the lowest processor -priority is selected for the interrupt. If multiple vcpus -share the same low priority then interrupts are distributed between -those round robin. - -Signed-off-by: Juergen Gross -Signed-off-by: Keir Fraser - ---- a/xen/arch/x86/hvm/vioapic.c -+++ b/xen/arch/x86/hvm/vioapic.c -@@ -344,8 +344,8 @@ static void vioapic_deliver(struct hvm_h - } - else - #endif -- target = apic_round_robin(vioapic_domain(vioapic), -- vector, deliver_bitmask); -+ target = apic_lowest_prio(vioapic_domain(vioapic), -+ deliver_bitmask); - if ( target != NULL ) - { - ioapic_inj_irq(vioapic, target, vector, trig_mode, delivery_mode); ---- a/xen/arch/x86/hvm/vlapic.c -+++ b/xen/arch/x86/hvm/vlapic.c -@@ -377,26 +377,30 @@ static int vlapic_accept_irq(struct vcpu - } - - /* This function is used by both ioapic and lapic.The bitmap is for vcpu_id. */ --struct vlapic *apic_round_robin( -- struct domain *d, uint8_t vector, uint32_t bitmap) -+struct vlapic *apic_lowest_prio(struct domain *d, uint32_t bitmap) - { -- int next, old; -- struct vlapic *target = NULL; -+ int old = d->arch.hvm_domain.irq.round_robin_prev_vcpu; -+ uint32_t ppr, target_ppr = UINT_MAX; -+ struct vlapic *vlapic, *target = NULL; -+ struct vcpu *v; - -- old = next = d->arch.hvm_domain.irq.round_robin_prev_vcpu; -+ if ( unlikely((v = d->vcpu[old]) == NULL) ) -+ return NULL; - - do { -- if ( ++next == MAX_VIRT_CPUS ) -- next = 0; -- if ( (d->vcpu[next] == NULL) || !test_bit(next, &bitmap) ) -- continue; -- target = vcpu_vlapic(d->vcpu[next]); -- if ( vlapic_enabled(target) ) -- break; -- target = NULL; -- } while ( next != old ); -+ v = v->next_in_list ? : d->vcpu[0]; -+ vlapic = vcpu_vlapic(v); -+ if ( test_bit(v->vcpu_id, &bitmap) && vlapic_enabled(vlapic) && -+ ((ppr = vlapic_get_ppr(vlapic)) < target_ppr) ) -+ { -+ target = vlapic; -+ target_ppr = ppr; -+ } -+ } while ( v->vcpu_id != old ); - -- d->arch.hvm_domain.irq.round_robin_prev_vcpu = next; -+ if ( target != NULL ) -+ d->arch.hvm_domain.irq.round_robin_prev_vcpu = -+ vlapic_vcpu(target)->vcpu_id; - - return target; - } -@@ -456,7 +460,7 @@ static int vlapic_ipi( - - if ( delivery_mode == APIC_DM_LOWEST ) - { -- target = apic_round_robin(vlapic_domain(v), vector, lpr_map); -+ target = apic_lowest_prio(vlapic_domain(v), lpr_map); - if ( target != NULL ) - rc = vlapic_accept_irq(vlapic_vcpu(target), delivery_mode, - vector, level, trig_mode); ---- a/xen/arch/x86/hvm/vmsi.c -+++ b/xen/arch/x86/hvm/vmsi.c -@@ -152,7 +152,7 @@ int vmsi_deliver(struct domain *d, int p - { - case dest_LowestPrio: - { -- target = apic_round_robin(d, vector, deliver_bitmask); -+ target = apic_lowest_prio(d, deliver_bitmask); - if ( target != NULL ) - vmsi_inj_irq(d, target, vector, trig_mode, delivery_mode); - else ---- a/xen/include/asm-x86/hvm/vlapic.h -+++ b/xen/include/asm-x86/hvm/vlapic.h -@@ -93,8 +93,7 @@ void vlapic_msr_set(struct vlapic *vlapi - - int vlapic_accept_pic_intr(struct vcpu *v); - --struct vlapic *apic_round_robin( -- struct domain *d, uint8_t vector, uint32_t bitmap); -+struct vlapic *apic_lowest_prio(struct domain *d, uint32_t bitmap); - - int vlapic_match_logical_addr(struct vlapic *vlapic, uint8_t mda); - diff --git a/18788-vlapic-accel-dom-restore.patch b/18788-vlapic-accel-dom-restore.patch deleted file mode 100644 index bb3dbaf..0000000 --- a/18788-vlapic-accel-dom-restore.patch +++ /dev/null @@ -1,35 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1227023966 0 -# Node ID f09a1d5d4338eab9c593b63b8ae89ddf481a3681 -# Parent ed8524f4a044efbd6d30f9340c6ddfb00f972407 -x86, hvm: Fix domain restore bug with Intel VLAPIC acceleration. - -r18383 mark video memory as ram, and make all valid pages migrated, -including vlapic page (0xFEE00), and share page(0xFFFFF). -An extra memory population for lapic page would override previous -mapping then cause HVM guest with vlapic acceleration hang. - -Signed-off-by: Keir Fraser - ---- a/xen/arch/x86/mm.c -+++ b/xen/arch/x86/mm.c -@@ -1541,6 +1541,7 @@ static int mod_l1_entry(l1_pgentry_t *pl - struct domain *d = curr->domain; - unsigned long mfn; - struct page_info *l1pg = mfn_to_page(gl1mfn); -+ p2m_type_t p2mt; - int rc = 1; - - page_lock(l1pg); -@@ -1558,8 +1559,8 @@ static int mod_l1_entry(l1_pgentry_t *pl - if ( l1e_get_flags(nl1e) & _PAGE_PRESENT ) - { - /* Translate foreign guest addresses. */ -- mfn = gmfn_to_mfn(FOREIGNDOM, l1e_get_pfn(nl1e)); -- if ( unlikely(mfn == INVALID_MFN) ) -+ mfn = mfn_x(gfn_to_mfn(FOREIGNDOM, l1e_get_pfn(nl1e), &p2mt)); -+ if ( !p2m_is_ram(p2mt) || unlikely(mfn == INVALID_MFN) ) - return page_unlock(l1pg), 0; - ASSERT((mfn & ~(PADDR_MASK >> PAGE_SHIFT)) == 0); - nl1e = l1e_from_pfn(mfn, l1e_get_flags(nl1e)); diff --git a/18795-x86-ioapic-guest-write.patch b/18795-x86-ioapic-guest-write.patch deleted file mode 100644 index 57924ce..0000000 --- a/18795-x86-ioapic-guest-write.patch +++ /dev/null @@ -1,29 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1227111099 0 -# Node ID bddd2d344c5425bfd25564bc20f90c3776552c6e -# Parent 4107618ee0d8aceb517f43ffa79197a041ed4bcf -x86: secure ioapic_guest_write() against FREE_TO_ASSIGN irq values - -Signed-off-by: Jan Beulich - ---- a/xen/arch/x86/io_apic.c -+++ b/xen/arch/x86/io_apic.c -@@ -2199,7 +2199,7 @@ int ioapic_guest_write(unsigned long phy - if ( new_rte.vector >= FIRST_DYNAMIC_VECTOR ) - new_irq = vector_irq[new_rte.vector]; - -- if ( (old_irq != new_irq) && (old_irq != -1) && IO_APIC_IRQ(old_irq) ) -+ if ( (old_irq != new_irq) && (old_irq >= 0) && IO_APIC_IRQ(old_irq) ) - { - if ( irq_desc[IO_APIC_VECTOR(old_irq)].action ) - { -@@ -2211,7 +2211,7 @@ int ioapic_guest_write(unsigned long phy - remove_pin_at_irq(old_irq, apic, pin); - } - -- if ( (new_irq != -1) && IO_APIC_IRQ(new_irq) ) -+ if ( (new_irq >= 0) && IO_APIC_IRQ(new_irq) ) - { - if ( irq_desc[IO_APIC_VECTOR(new_irq)].action ) - { diff --git a/18799-cpu-affinity.patch b/18799-cpu-affinity.patch deleted file mode 100644 index 6880e49..0000000 --- a/18799-cpu-affinity.patch +++ /dev/null @@ -1,20 +0,0 @@ -Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -476,7 +476,14 @@ class XendDomainInfo: - if state in (DOM_STATE_SUSPENDED, DOM_STATE_HALTED): - try: - self._constructDomain() -- self._setCPUAffinity() -+ -+ try: -+ self._setCPUAffinity() -+ except: -+ # usually a CPU we want to set affinity to does not exist -+ # we just ignore it so that the domain can still be restored -+ log.warn("Cannot restore CPU affinity") -+ - self._storeVmDetails() - self._createChannels() - self._createDevices() diff --git a/18805-pv-driver-build.patch b/18805-pv-driver-build.patch deleted file mode 100644 index 54088c8..0000000 --- a/18805-pv-driver-build.patch +++ /dev/null @@ -1,65 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1227525080 0 -# Node ID 0b8c6c91c5a408345e6ed650fb9f19e4fa9809b9 -# Parent cd45b5c9561250b999476227dbc7f7ede377d3d4 -pv-on-hvm drivers: build fixes for Linux 2.6.27+ - -Make the drivers build properly in a 2.6.27 environment as well as -against a kernel with pv-ops Xen configured on (in the latter case -more work would be needed to also make the drivers work, as there's a -large number of duplicate exports). - -Portions from Charles Arnold . - -Signed-off-by: Jan Beulich - ---- a/unmodified_drivers/linux-2.6/balloon/Kbuild -+++ b/unmodified_drivers/linux-2.6/balloon/Kbuild -@@ -4,6 +4,5 @@ obj-m = xen-balloon.o - - EXTRA_CFLAGS += -I$(M)/platform-pci - --xen-balloon-objs = --xen-balloon-objs += balloon.o --xen-balloon-objs += sysfs.o -+xen-balloon-y := balloon.o sysfs.o -+xen-balloon-$(CONFIG_XEN_SCRUB_PAGES) += scrub.o ---- a/unmodified_drivers/linux-2.6/mkbuildtree -+++ b/unmodified_drivers/linux-2.6/mkbuildtree -@@ -53,6 +53,7 @@ i[34567]86|x86_64) - ln -sf ${XL}/include/asm-x86/mach-xen/asm/synch_bitops*.h include/asm - ln -sf ${XL}/include/asm-x86/mach-xen/asm/maddr*.h include/asm - ln -sf ${XL}/include/asm-x86/mach-xen/asm/gnttab_dma.h include/asm -+ ln -sf ${XL}/arch/x86/lib/scrub.c balloon - else - if [ $uname = x86_64 ]; then - mkdir -p include/asm-i386 ---- a/unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c -+++ b/unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c -@@ -34,7 +34,11 @@ static void ap_suspend(void *_info) - atomic_dec(&info->nr_spinning); - } - -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) - #define initiate_ap_suspend(i) smp_call_function(ap_suspend, i, 0, 0) -+#else -+#define initiate_ap_suspend(i) smp_call_function(ap_suspend, i, 0) -+#endif - - #else /* !defined(CONFIG_SMP) */ - ---- a/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c -+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c -@@ -14,7 +14,11 @@ EXPORT_SYMBOL(system_state); - - void ctrl_alt_del(void) - { -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) - kill_proc(1, SIGINT, 1); /* interrupt init */ -+#else -+ kill_cad_pid(SIGINT, 1); -+#endif - } - - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8) diff --git a/18810-shadow-PAT.patch b/18810-shadow-PAT.patch deleted file mode 100644 index e19e301..0000000 --- a/18810-shadow-PAT.patch +++ /dev/null @@ -1,42 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1227611877 0 -# Node ID c2a018cdb45d7419aa068c2dc4894e06ec5097e3 -# Parent e7c421510be96f456cd367d125d86f939d27d253 -Fix PSE PAT handling in guest walk. - -Guest walk was currently checking for _PAGE_PSE_PAT flag in -guest_l2e_get_flags(). The problem is that this function only checks -for the first 12 bits of the PDE, while _PAGE_PSE_PAT is actually on bit -12 (that is the 13th bit). This caused _PAGE_PAT bit to never been set on -splintered L1s. - -Signed-off-by: Gianluca Guida - ---- a/xen/arch/x86/mm/shadow/multi.c -+++ b/xen/arch/x86/mm/shadow/multi.c -@@ -484,15 +484,15 @@ guest_walk_tables(struct vcpu *v, unsign - * access controls are enforced in the shadow l2e. */ - int flags = (_PAGE_PRESENT|_PAGE_USER|_PAGE_RW| - _PAGE_ACCESSED|_PAGE_DIRTY); -- /* PSE level 2 entries use bit 12 for PAT; propagate it to bit 7 -- * of the level 1. */ -- if ( (guest_l2e_get_flags(gw->l2e) & _PAGE_PSE_PAT) ) -- flags |= _PAGE_PAT; -- /* Copy the cache-control bits to the l1 as well, because we -- * can't represent PAT in the (non-PSE) shadow l2e. :( -- * This could cause problems if a guest ever maps an area of -- * memory with superpages using more than one caching mode. */ -- flags |= guest_l2e_get_flags(gw->l2e) & (_PAGE_PWT|_PAGE_PCD); -+ /* Import cache-control bits. Note that _PAGE_PAT is actually -+ * _PAGE_PSE, and it is always set. We will clear it in case -+ * _PAGE_PSE_PAT (bit 12, i.e. first bit of gfn) is clear. */ -+ flags |= (guest_l2e_get_flags(gw->l2e) -+ & (_PAGE_PAT|_PAGE_PWT|_PAGE_PCD)); -+ if ( !(gfn_x(start) & 1) ) -+ /* _PAGE_PSE_PAT not set: remove _PAGE_PAT from flags. */ -+ flags &= ~_PAGE_PAT; -+ - /* Increment the pfn by the right number of 4k pages. - * The ~0x1 is to mask out the PAT bit mentioned above. */ - start = _gfn((gfn_x(start) & ~0x1) + guest_l1_table_offset(va)); diff --git a/18844-shared-page-EOI.patch b/18844-shared-page-EOI.patch deleted file mode 100644 index 681bd55..0000000 --- a/18844-shared-page-EOI.patch +++ /dev/null @@ -1,312 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1227878852 0 -# Node ID c820bf73a914f643ab48864629c0559e68ceede1 -# Parent 8dbf23c89cc6a4fbd7b9063b14e706c065ba1678 -x86: add a shared page indicating the need for an EOI notification - -To simplify the interface for the guest, when a guest uses this new -(sub-)hypercall, PHYSDEVOP_eoi behavior changes to unmask the -corresponding event channel at once, avoiding the eventual need for a -second hypercall from the guest. - -Signed-off-by: Jan Beulich -Signed-off-by: Keir Fraser - -18846: -x86: Fix PHYSDEVOP_pirq_eoi_mfn, which I modified and broke. - -Signed-off-by: Keir Fraser - -18851: -x86: Fix mfn_to_virt() to cast MFN to address size. -Signed-off-by: Keir Fraser - -Index: xen-3.3.1-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/domain.c -+++ xen-3.3.1-testing/xen/arch/x86/domain.c -@@ -1812,6 +1812,13 @@ int domain_relinquish_resources(struct d - unmap_vcpu_info(v); - } - -+ if ( d->arch.pirq_eoi_map != NULL ) -+ { -+ unmap_domain_page_global(d->arch.pirq_eoi_map); -+ put_page_and_type(mfn_to_page(d->arch.pirq_eoi_map_mfn)); -+ d->arch.pirq_eoi_map = NULL; -+ } -+ - d->arch.relmem = RELMEM_xen; - /* fallthrough */ - -Index: xen-3.3.1-testing/xen/arch/x86/irq.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/irq.c -+++ xen-3.3.1-testing/xen/arch/x86/irq.c -@@ -18,6 +18,7 @@ - #include - #include - #include -+#include - #include - - /* opt_noirqbalance: If true, software IRQ balancing/affinity is disabled. */ -@@ -206,16 +207,42 @@ struct pending_eoi { - static DEFINE_PER_CPU(struct pending_eoi, pending_eoi[NR_VECTORS]); - #define pending_eoi_sp(p) ((p)[NR_VECTORS-1].vector) - -+static inline void set_pirq_eoi(struct domain *d, unsigned int irq) -+{ -+ if ( d->arch.pirq_eoi_map ) -+ set_bit(irq, d->arch.pirq_eoi_map); -+} -+ -+static inline void clear_pirq_eoi(struct domain *d, unsigned int irq) -+{ -+ if ( d->arch.pirq_eoi_map ) -+ clear_bit(irq, d->arch.pirq_eoi_map); -+} -+ -+static void _irq_guest_eoi(irq_desc_t *desc) -+{ -+ irq_guest_action_t *action = (irq_guest_action_t *)desc->action; -+ unsigned int i, vector = desc - irq_desc; -+ -+ if ( !(desc->status & IRQ_GUEST_EOI_PENDING) ) -+ return; -+ -+ for ( i = 0; i < action->nr_guests; ++i ) -+ clear_pirq_eoi(action->guest[i], -+ domain_vector_to_irq(action->guest[i], vector)); -+ -+ desc->status &= ~(IRQ_INPROGRESS|IRQ_GUEST_EOI_PENDING); -+ desc->handler->enable(vector); -+} -+ - static struct timer irq_guest_eoi_timer[NR_IRQS]; - static void irq_guest_eoi_timer_fn(void *data) - { - irq_desc_t *desc = data; -- unsigned vector = desc - irq_desc; - unsigned long flags; - - spin_lock_irqsave(&desc->lock, flags); -- desc->status &= ~IRQ_INPROGRESS; -- desc->handler->enable(vector); -+ _irq_guest_eoi(desc); - spin_unlock_irqrestore(&desc->lock, flags); - } - -@@ -272,8 +299,22 @@ static void __do_IRQ_guest(int vector) - - if ( already_pending == action->nr_guests ) - { -- desc->handler->disable(vector); - stop_timer(&irq_guest_eoi_timer[vector]); -+ desc->handler->disable(vector); -+ desc->status |= IRQ_GUEST_EOI_PENDING; -+ for ( i = 0; i < already_pending; ++i ) -+ { -+ d = action->guest[i]; -+ set_pirq_eoi(d, domain_vector_to_irq(d, vector)); -+ /* -+ * Could check here whether the guest unmasked the event by now -+ * (or perhaps just re-issue the send_guest_pirq()), and if it -+ * can now accept the event, -+ * - clear all the pirq_eoi bits we already set, -+ * - re-enable the vector, and -+ * - skip the timer setup below. -+ */ -+ } - init_timer(&irq_guest_eoi_timer[vector], - irq_guest_eoi_timer_fn, desc, smp_processor_id()); - set_timer(&irq_guest_eoi_timer[vector], NOW() + MILLISECS(1)); -@@ -382,8 +423,12 @@ static void __pirq_guest_eoi(struct doma - action = (irq_guest_action_t *)desc->action; - vector = desc - irq_desc; - -- ASSERT(!test_bit(irq, d->pirq_mask) || -- (action->ack_type != ACKTYPE_NONE)); -+ if ( action->ack_type == ACKTYPE_NONE ) -+ { -+ ASSERT(!test_bit(irq, d->pirq_mask)); -+ stop_timer(&irq_guest_eoi_timer[vector]); -+ _irq_guest_eoi(desc); -+ } - - if ( unlikely(!test_and_clear_bit(irq, d->pirq_mask)) || - unlikely(--action->in_flight != 0) ) -@@ -604,6 +649,11 @@ int pirq_guest_bind(struct vcpu *v, int - - action->guest[action->nr_guests++] = v->domain; - -+ if ( action->ack_type != ACKTYPE_NONE ) -+ set_pirq_eoi(v->domain, irq); -+ else -+ clear_pirq_eoi(v->domain, irq); -+ - unlock_out: - spin_unlock_irq(&desc->lock); - out: -Index: xen-3.3.1-testing/xen/arch/x86/physdev.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/physdev.c -+++ xen-3.3.1-testing/xen/arch/x86/physdev.c -@@ -204,10 +204,50 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H - ret = -EFAULT; - if ( copy_from_guest(&eoi, arg, 1) != 0 ) - break; -+ ret = -EINVAL; -+ if ( eoi.irq < 0 || eoi.irq >= NR_IRQS ) -+ break; -+ if ( v->domain->arch.pirq_eoi_map ) -+ evtchn_unmask(v->domain->pirq_to_evtchn[eoi.irq]); - ret = pirq_guest_eoi(v->domain, eoi.irq); - break; - } - -+ case PHYSDEVOP_pirq_eoi_mfn: { -+ struct physdev_pirq_eoi_mfn info; -+ -+ BUILD_BUG_ON(NR_IRQS > (PAGE_SIZE * 8)); -+ -+ ret = -EFAULT; -+ if ( copy_from_guest(&info, arg, 1) != 0 ) -+ break; -+ -+ ret = -EINVAL; -+ if ( !mfn_valid(info.mfn) || -+ !get_page_and_type(mfn_to_page(info.mfn), v->domain, -+ PGT_writable_page) ) -+ break; -+ -+ if ( cmpxchg(&v->domain->arch.pirq_eoi_map_mfn, 0, info.mfn) != 0 ) -+ { -+ put_page_and_type(mfn_to_page(info.mfn)); -+ ret = -EBUSY; -+ break; -+ } -+ -+ v->domain->arch.pirq_eoi_map = map_domain_page_global(info.mfn); -+ if ( v->domain->arch.pirq_eoi_map == NULL ) -+ { -+ v->domain->arch.pirq_eoi_map_mfn = 0; -+ put_page_and_type(mfn_to_page(info.mfn)); -+ ret = -ENOSPC; -+ break; -+ } -+ -+ ret = 0; -+ break; -+ } -+ - /* Legacy since 0x00030202. */ - case PHYSDEVOP_IRQ_UNMASK_NOTIFY: { - ret = pirq_guest_unmask(v->domain); -Index: xen-3.3.1-testing/xen/arch/x86/x86_64/physdev.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/x86_64/physdev.c -+++ xen-3.3.1-testing/xen/arch/x86/x86_64/physdev.c -@@ -18,6 +18,9 @@ - #define physdev_eoi compat_physdev_eoi - #define physdev_eoi_t physdev_eoi_compat_t - -+#define physdev_pirq_eoi_mfn compat_physdev_pirq_eoi_mfn -+#define physdev_pirq_eoi_mfn_t physdev_pirq_eoi_mfn_compat_t -+ - #define physdev_set_iobitmap compat_physdev_set_iobitmap - #define physdev_set_iobitmap_t physdev_set_iobitmap_compat_t - -Index: xen-3.3.1-testing/xen/common/event_channel.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/common/event_channel.c -+++ xen-3.3.1-testing/xen/common/event_channel.c -@@ -762,10 +762,9 @@ long evtchn_bind_vcpu(unsigned int port, - } - - --static long evtchn_unmask(evtchn_unmask_t *unmask) -+int evtchn_unmask(unsigned int port) - { - struct domain *d = current->domain; -- int port = unmask->port; - struct vcpu *v; - - spin_lock(&d->event_lock); -@@ -916,7 +915,7 @@ long do_event_channel_op(int cmd, XEN_GU - struct evtchn_unmask unmask; - if ( copy_from_guest(&unmask, arg, 1) != 0 ) - return -EFAULT; -- rc = evtchn_unmask(&unmask); -+ rc = evtchn_unmask(unmask.port); - break; - } - -Index: xen-3.3.1-testing/xen/include/asm-x86/domain.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/domain.h -+++ xen-3.3.1-testing/xen/include/asm-x86/domain.h -@@ -239,6 +239,10 @@ struct arch_domain - int vector_pirq[NR_VECTORS]; - int pirq_vector[NR_PIRQS]; - -+ /* Shared page for notifying that explicit PIRQ EOI is required. */ -+ unsigned long *pirq_eoi_map; -+ unsigned long pirq_eoi_map_mfn; -+ - /* Pseudophysical e820 map (XENMEM_memory_map). */ - struct e820entry e820[3]; - unsigned int nr_e820; -Index: xen-3.3.1-testing/xen/include/public/physdev.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/public/physdev.h -+++ xen-3.3.1-testing/xen/include/public/physdev.h -@@ -41,6 +41,21 @@ typedef struct physdev_eoi physdev_eoi_t - DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t); - - /* -+ * Register a shared page for the hypervisor to indicate whether the guest -+ * must issue PHYSDEVOP_eoi. The semantics of PHYSDEVOP_eoi change slightly -+ * once the guest used this function in that the associated event channel -+ * will automatically get unmasked. The page registered is used as a bit -+ * array indexed by Xen's PIRQ value. -+ */ -+#define PHYSDEVOP_pirq_eoi_mfn 17 -+struct physdev_pirq_eoi_mfn { -+ /* IN */ -+ xen_pfn_t mfn; -+}; -+typedef struct physdev_pirq_eoi_mfn physdev_pirq_eoi_mfn_t; -+DEFINE_XEN_GUEST_HANDLE(physdev_pirq_eoi_mfn_t); -+ -+/* - * Query the status of an IRQ line. - * @arg == pointer to physdev_irq_status_query structure. - */ -Index: xen-3.3.1-testing/xen/include/xen/event.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/xen/event.h -+++ xen-3.3.1-testing/xen/include/xen/event.h -@@ -44,6 +44,9 @@ int evtchn_send(struct domain *d, unsign - /* Bind a local event-channel port to the specified VCPU. */ - long evtchn_bind_vcpu(unsigned int port, unsigned int vcpu_id); - -+/* Unmask a local event-channel port. */ -+int evtchn_unmask(unsigned int port); -+ - /* Allocate/free a Xen-attached event channel port. */ - int alloc_unbound_xen_event_channel( - struct vcpu *local_vcpu, domid_t remote_domid); -Index: xen-3.3.1-testing/xen/include/xen/irq.h -=================================================================== ---- xen-3.3.1-testing.orig/xen/include/xen/irq.h -+++ xen-3.3.1-testing/xen/include/xen/irq.h -@@ -22,6 +22,7 @@ struct irqaction - #define IRQ_PENDING 4 /* IRQ pending - replay on enable */ - #define IRQ_REPLAY 8 /* IRQ has been replayed but not acked yet */ - #define IRQ_GUEST 16 /* IRQ is handled by guest OS(es) */ -+#define IRQ_GUEST_EOI_PENDING 32 /* IRQ was disabled, pending a guest EOI */ - #define IRQ_PER_CPU 256 /* IRQ is per CPU */ - - /* diff --git a/18852-shared-page-EOI-gmfn.patch b/18852-shared-page-EOI-gmfn.patch deleted file mode 100644 index 81b4862..0000000 --- a/18852-shared-page-EOI-gmfn.patch +++ /dev/null @@ -1,102 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1228304687 0 -# Node ID cb526325927c0abac441588b4a69bccd0b99d7b3 -# Parent 9a6153a89d6642555c9ed4dc386d243c3df23eab -physdev: make PHYSDEVOP_pirq_eoi_mfn use of gmfn instead of mfn. - -To pass a page from a guest to hypervisor, gmfn should be used -instead of mfn like grant table and other hypercalls. It's more -consistent. So make use of gmfn instead of mfn for -PHYSDEVOP_pirq_eoi_mfn hypercall. - -Signed-off-by: Isaku Yamahata -Signed-off-by: Keir Fraser - ---- a/xen/arch/x86/physdev.c -+++ b/xen/arch/x86/physdev.c -@@ -14,6 +14,7 @@ - #include - #include - #include -+#include - - #ifndef COMPAT - typedef long ret_t; -@@ -213,8 +214,9 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H - break; - } - -- case PHYSDEVOP_pirq_eoi_mfn: { -- struct physdev_pirq_eoi_mfn info; -+ case PHYSDEVOP_pirq_eoi_gmfn: { -+ struct physdev_pirq_eoi_gmfn info; -+ unsigned long mfn; - - BUILD_BUG_ON(NR_IRQS > (PAGE_SIZE * 8)); - -@@ -223,23 +225,24 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H - break; - - ret = -EINVAL; -- if ( !mfn_valid(info.mfn) || -- !get_page_and_type(mfn_to_page(info.mfn), v->domain, -+ mfn = gmfn_to_mfn(current->domain, info.gmfn); -+ if ( !mfn_valid(mfn) || -+ !get_page_and_type(mfn_to_page(mfn), v->domain, - PGT_writable_page) ) - break; - -- if ( cmpxchg(&v->domain->arch.pirq_eoi_map_mfn, 0, info.mfn) != 0 ) -+ if ( cmpxchg(&v->domain->arch.pirq_eoi_map_mfn, 0, mfn) != 0 ) - { -- put_page_and_type(mfn_to_page(info.mfn)); -+ put_page_and_type(mfn_to_page(mfn)); - ret = -EBUSY; - break; - } - -- v->domain->arch.pirq_eoi_map = map_domain_page_global(info.mfn); -+ v->domain->arch.pirq_eoi_map = map_domain_page_global(mfn); - if ( v->domain->arch.pirq_eoi_map == NULL ) - { - v->domain->arch.pirq_eoi_map_mfn = 0; -- put_page_and_type(mfn_to_page(info.mfn)); -+ put_page_and_type(mfn_to_page(mfn)); - ret = -ENOSPC; - break; - } ---- a/xen/arch/x86/x86_64/physdev.c -+++ b/xen/arch/x86/x86_64/physdev.c -@@ -18,8 +18,8 @@ - #define physdev_eoi compat_physdev_eoi - #define physdev_eoi_t physdev_eoi_compat_t - --#define physdev_pirq_eoi_mfn compat_physdev_pirq_eoi_mfn --#define physdev_pirq_eoi_mfn_t physdev_pirq_eoi_mfn_compat_t -+#define physdev_pirq_eoi_gmfn compat_physdev_pirq_eoi_gmfn -+#define physdev_pirq_eoi_gmfn_t physdev_pirq_eoi_gmfn_compat_t - - #define physdev_set_iobitmap compat_physdev_set_iobitmap - #define physdev_set_iobitmap_t physdev_set_iobitmap_compat_t ---- a/xen/include/public/physdev.h -+++ b/xen/include/public/physdev.h -@@ -47,13 +47,13 @@ DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t); - * will automatically get unmasked. The page registered is used as a bit - * array indexed by Xen's PIRQ value. - */ --#define PHYSDEVOP_pirq_eoi_mfn 17 --struct physdev_pirq_eoi_mfn { -+#define PHYSDEVOP_pirq_eoi_gmfn 17 -+struct physdev_pirq_eoi_gmfn { - /* IN */ -- xen_pfn_t mfn; -+ xen_pfn_t gmfn; - }; --typedef struct physdev_pirq_eoi_mfn physdev_pirq_eoi_mfn_t; --DEFINE_XEN_GUEST_HANDLE(physdev_pirq_eoi_mfn_t); -+typedef struct physdev_pirq_eoi_gmfn physdev_pirq_eoi_gmfn_t; -+DEFINE_XEN_GUEST_HANDLE(physdev_pirq_eoi_gmfn_t); - - /* - * Query the status of an IRQ line. diff --git a/18870-vtd-flush-per-device.patch b/18870-vtd-flush-per-device.patch deleted file mode 100644 index 88a14c1..0000000 --- a/18870-vtd-flush-per-device.patch +++ /dev/null @@ -1,25 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1228474781 0 -# Node ID 99f01b8184c7c16f612731e2a525687dc8d424dc -# Parent 09160c3bd1797fdee111c2837f26a749e0bf9435 -VT-d code cleanup - -This patch narrow context caching flush range from the -domain-selective to the device-selective, when unmapping a device. - -Signed-off-by: Yu Zhao - ---- a/xen/drivers/passthrough/vtd/iommu.c -+++ b/xen/drivers/passthrough/vtd/iommu.c -@@ -1323,7 +1323,9 @@ static int domain_context_unmap_one( - context_clear_entry(*context); - iommu_flush_cache_entry(context); - -- if ( iommu_flush_context_domain(iommu, domain_iommu_domid(domain), 0) ) -+ if ( iommu_flush_context_device(iommu, domain_iommu_domid(domain), -+ (((u16)bus) << 8) | devfn, -+ DMA_CCMD_MASK_NOBIT, 0) ) - iommu_flush_write_buffer(iommu); - else - iommu_flush_iotlb_dsi(iommu, domain_iommu_domid(domain), 0); diff --git a/18878-x86-cpufreq-less-verbose.patch b/18878-x86-cpufreq-less-verbose.patch deleted file mode 100644 index 2883e40..0000000 --- a/18878-x86-cpufreq-less-verbose.patch +++ /dev/null @@ -1,33 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1228490563 0 -# Node ID 3905cbf523b2550f5025df6cc31ac60e48c1706f -# Parent 3db54d2aa8bd7ec8c096fb4fafa068850ff0ff35 -x86/cpufreq: reduce verbosity - -These messages don't exist in powernow's equivalent code, and are -pretty useless anyway, hence just cluttering the logs. - -Signed-off-by: Jan Beulich - ---- a/xen/arch/x86/acpi/cpufreq/cpufreq.c -+++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c -@@ -339,16 +339,10 @@ static int acpi_cpufreq_target(struct cp - - next_perf_state = data->freq_table[next_state].index; - if (perf->state == next_perf_state) { -- if (unlikely(policy->resume)) { -- printk(KERN_INFO "Called after resume, resetting to P%d\n", -- next_perf_state); -+ if (unlikely(policy->resume)) - policy->resume = 0; -- } -- else { -- printk(KERN_INFO "Already at target state (P%d)\n", -- next_perf_state); -+ else - return 0; -- } - } - - switch (data->cpu_feature) { diff --git a/18879-cpufreq-params.patch b/18879-cpufreq-params.patch deleted file mode 100644 index e0ce2dc..0000000 --- a/18879-cpufreq-params.patch +++ /dev/null @@ -1,197 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1228490612 0 -# Node ID de7fd862ada2ed079d0a5c407508eb63bb936992 -# Parent 3905cbf523b2550f5025df6cc31ac60e48c1706f -cpufreq: allow customization of some parameters - -Short of having a way for powersaved to dynamically adjust these -values, at least allow specifying them on the command line. In -particular, always running at an up-threshold of 80% is perhaps nice -for laptop use, but certainly not desirable on servers. On shell -scripts invoking large numbers of short-lived processes I noticed a -50% performance degradation on a dual-socket quad-core Barcelona just -because of the load of an individual core never crossing the 80% -boundary that would have resulted in increasing the frequency. - -(Powersaved on SLE10 sets this on native kernels to 60% or 80%, -depending on whether performance or power reduction is preferred, -*divided* by the number of CPUs, but capped at the lower limit of -20%.) - -Signed-off-by: Jan Beulich - -# HG changeset patch -# User Keir Fraser -# Date 1230557866 0 -# Node ID 4035ea96ae2fafba7a5a4c1e810aa7d591758e8c -# Parent 0af9fbf3f05306d4972cf05e4b6d7be2199a41cb -cpufreq: Fix a cpufreq cmdline parse bug, and change sample_rate unit - -Signed-off-by: Liu Jinsong - ---- a/xen/arch/x86/acpi/cpufreq/cpufreq_ondemand.c -+++ b/xen/arch/x86/acpi/cpufreq/cpufreq_ondemand.c -@@ -22,15 +22,22 @@ - #include - - #define DEF_FREQUENCY_UP_THRESHOLD (80) -+#define MIN_FREQUENCY_UP_THRESHOLD (11) -+#define MAX_FREQUENCY_UP_THRESHOLD (100) - - #define MIN_DBS_INTERVAL (MICROSECS(100)) --#define MIN_SAMPLING_MILLISECS (20) --#define MIN_STAT_SAMPLING_RATE \ -+#define MIN_SAMPLING_RATE_RATIO (2) -+#define MIN_SAMPLING_MILLISECS (MIN_SAMPLING_RATE_RATIO * 10) -+#define MIN_STAT_SAMPLING_RATE \ - (MIN_SAMPLING_MILLISECS * MILLISECS(1)) -+#define MIN_SAMPLING_RATE \ -+ (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) -+#define MAX_SAMPLING_RATE (500 * def_sampling_rate) - #define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) - #define TRANSITION_LATENCY_LIMIT (10 * 1000 ) - - static uint64_t def_sampling_rate; -+static uint64_t usr_sampling_rate; - - /* Sampling types */ - enum {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE}; -@@ -42,11 +49,9 @@ static unsigned int dbs_enable; /* nu - static struct dbs_tuners { - uint64_t sampling_rate; - unsigned int up_threshold; -- unsigned int ignore_nice; - unsigned int powersave_bias; - } dbs_tuners_ins = { - .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, -- .ignore_nice = 0, - .powersave_bias = 0, - }; - -@@ -216,7 +221,20 @@ int cpufreq_governor_dbs(struct cpufreq_ - if (def_sampling_rate < MIN_STAT_SAMPLING_RATE) - def_sampling_rate = MIN_STAT_SAMPLING_RATE; - -- dbs_tuners_ins.sampling_rate = def_sampling_rate; -+ if (!usr_sampling_rate) -+ dbs_tuners_ins.sampling_rate = def_sampling_rate; -+ else if (usr_sampling_rate < MIN_SAMPLING_RATE) { -+ printk(KERN_WARNING "cpufreq/ondemand: " -+ "specified sampling rate too low, using %"PRIu64"\n", -+ MIN_SAMPLING_RATE); -+ dbs_tuners_ins.sampling_rate = MIN_SAMPLING_RATE; -+ } else if (usr_sampling_rate > MAX_SAMPLING_RATE) { -+ printk(KERN_WARNING "cpufreq/ondemand: " -+ "specified sampling rate too high, using %"PRIu64"\n", -+ MAX_SAMPLING_RATE); -+ dbs_tuners_ins.sampling_rate = MAX_SAMPLING_RATE; -+ } else -+ dbs_tuners_ins.sampling_rate = usr_sampling_rate; - } - dbs_timer_init(this_dbs_info); - -@@ -239,3 +257,55 @@ int cpufreq_governor_dbs(struct cpufreq_ - } - return 0; - } -+ -+void __init cpufreq_cmdline_parse(char *str) -+{ -+ do { -+ char *val, *end = strchr(str, ','); -+ -+ if ( end ) -+ *end++ = '\0'; -+ val = strchr(str, '='); -+ if ( val ) -+ *val++ = '\0'; -+ -+ if ( !strcmp(str, "rate") && val ) -+ { -+ usr_sampling_rate = simple_strtoull(val, NULL, 0) * MICROSECS(1); -+ } -+ else if ( !strcmp(str, "threshold") && val ) -+ { -+ unsigned long tmp = simple_strtoul(val, NULL, 0); -+ -+ if ( tmp < MIN_FREQUENCY_UP_THRESHOLD ) -+ { -+ printk(XENLOG_WARNING "cpufreq/ondemand: " -+ "specified threshold too low, using %d\n", -+ MIN_FREQUENCY_UP_THRESHOLD); -+ tmp = MIN_FREQUENCY_UP_THRESHOLD; -+ } -+ else if ( tmp > MAX_FREQUENCY_UP_THRESHOLD ) -+ { -+ printk(XENLOG_WARNING "cpufreq/ondemand: " -+ "specified threshold too high, using %d\n", -+ MAX_FREQUENCY_UP_THRESHOLD); -+ tmp = MAX_FREQUENCY_UP_THRESHOLD; -+ } -+ dbs_tuners_ins.up_threshold = tmp; -+ } -+ else if ( !strcmp(str, "bias") && val ) -+ { -+ unsigned long tmp = simple_strtoul(val, NULL, 0); -+ -+ if ( tmp > 1000 ) -+ { -+ printk(XENLOG_WARNING "cpufreq/ondemand: " -+ "specified bias too high, using 1000\n"); -+ tmp = 1000; -+ } -+ dbs_tuners_ins.powersave_bias = tmp; -+ } -+ -+ str = end; -+ } while ( str ); -+} ---- a/xen/common/domain.c -+++ b/xen/common/domain.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -41,16 +42,25 @@ boolean_param("dom0_vcpus_pin", opt_dom0 - enum cpufreq_controller cpufreq_controller; - static void __init setup_cpufreq_option(char *str) - { -+ char *arg; -+ - if ( !strcmp(str, "dom0-kernel") ) - { - xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX; - cpufreq_controller = FREQCTL_dom0_kernel; - opt_dom0_vcpus_pin = 1; -+ return; - } -- else if ( !strcmp(str, "xen") ) -+ -+ if ( (arg = strpbrk(str, ",:")) != NULL ) -+ *arg++ = '\0'; -+ -+ if ( !strcmp(str, "xen") ) - { - xen_processor_pmbits |= XEN_PROCESSOR_PM_PX; - cpufreq_controller = FREQCTL_xen; -+ if ( arg && *arg ) -+ cpufreq_cmdline_parse(arg); - } - } - custom_param("cpufreq", setup_cpufreq_option); ---- a/xen/include/acpi/cpufreq/cpufreq.h -+++ b/xen/include/acpi/cpufreq/cpufreq.h -@@ -41,6 +41,8 @@ struct cpufreq_policy { - }; - extern struct cpufreq_policy xen_px_policy[NR_CPUS]; - -+void cpufreq_cmdline_parse(char *); -+ - #define CPUFREQ_SHARED_TYPE_NONE (0) /* None */ - #define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */ - #define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */ diff --git a/18880-x86-pirq-guest-bind-msg.patch b/18880-x86-pirq-guest-bind-msg.patch deleted file mode 100644 index e05b715..0000000 --- a/18880-x86-pirq-guest-bind-msg.patch +++ /dev/null @@ -1,29 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1228490652 0 -# Node ID d206692cbcbe33305afc4879a4b3ece44a8aba93 -# Parent de7fd862ada2ed079d0a5c407508eb63bb936992 -x86: make an error message more precise - -... allowing to distinguish whether the to be added or the already -existing PIRQ binding is causing the failure. - -Signed-off-by: Jan Beulich - ---- a/xen/arch/x86/irq.c -+++ b/xen/arch/x86/irq.c -@@ -620,9 +620,11 @@ int pirq_guest_bind(struct vcpu *v, int - } - else if ( !will_share || !action->shareable ) - { -- gdprintk(XENLOG_INFO, "Cannot bind IRQ %d to guest. " -- "Will not share with others.\n", -- irq); -+ gdprintk(XENLOG_INFO, "Cannot bind IRQ %d to guest. %s.\n", -+ irq, -+ will_share ? -+ "Others do not share" : -+ "Will not share with others"); - rc = -EBUSY; - goto unlock_out; - } diff --git a/18887-vtd-error-handling.patch b/18887-vtd-error-handling.patch deleted file mode 100644 index da219f7..0000000 --- a/18887-vtd-error-handling.patch +++ /dev/null @@ -1,76 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1228827329 0 -# Node ID 043aba2b67a195d2c2707f8fd0c05bbbf2078d2a -# Parent f7f8f44b9292a30707bd645739390ef3d0f22232 -VT-d: check return value of pirq_guest_bind() - -The eliminates a hypervisor crash when the respective domain dies or -gets the device hot removed. - -Signed-off-by: Jan Beulich -Reviewed-by: Weidong Han - ---- a/xen/drivers/passthrough/io.c -+++ b/xen/drivers/passthrough/io.c -@@ -57,7 +57,7 @@ int pt_irq_create_bind_vtd( - uint32_t machine_gsi, guest_gsi; - uint32_t device, intx, link; - struct dev_intx_gsi_link *digl; -- int pirq = pt_irq_bind->machine_irq; -+ int rc, pirq = pt_irq_bind->machine_irq; - - if ( pirq < 0 || pirq >= NR_PIRQS ) - return -EINVAL; -@@ -95,7 +95,17 @@ int pt_irq_create_bind_vtd( - hvm_irq_dpci->mirq[pirq].gmsi.gflags = pt_irq_bind->u.msi.gflags; - hvm_irq_dpci->msi_gvec_pirq[pt_irq_bind->u.msi.gvec] = pirq; - /* bind after hvm_irq_dpci is setup to avoid race with irq handler*/ -- pirq_guest_bind(d->vcpu[0], pirq, 0); -+ rc = pirq_guest_bind(d->vcpu[0], pirq, 0); -+ if ( unlikely(rc) ) -+ { -+ hvm_irq_dpci->msi_gvec_pirq[pt_irq_bind->u.msi.gvec] = 0; -+ hvm_irq_dpci->mirq[pirq].gmsi.gflags = 0; -+ hvm_irq_dpci->mirq[pirq].gmsi.gvec = 0; -+ clear_bit(_HVM_IRQ_DPCI_MSI, &hvm_irq_dpci->mirq[pirq].flags); -+ clear_bit(pirq, hvm_irq_dpci->mapping); -+ spin_unlock(&d->event_lock); -+ return rc; -+ } - } - else if (hvm_irq_dpci->mirq[pirq].gmsi.gvec != pt_irq_bind->u.msi.gvec - ||hvm_irq_dpci->msi_gvec_pirq[pt_irq_bind->u.msi.gvec] != pirq) -@@ -136,13 +146,30 @@ int pt_irq_create_bind_vtd( - /* Bind the same mirq once in the same domain */ - if ( !test_and_set_bit(machine_gsi, hvm_irq_dpci->mapping)) - { -+ unsigned int vector = domain_irq_to_vector(d, machine_gsi); -+ - hvm_irq_dpci->mirq[machine_gsi].dom = d; - - /* Init timer before binding */ -- init_timer(&hvm_irq_dpci->hvm_timer[domain_irq_to_vector(d, machine_gsi)], -+ init_timer(&hvm_irq_dpci->hvm_timer[vector], - pt_irq_time_out, &hvm_irq_dpci->mirq[machine_gsi], 0); - /* Deal with gsi for legacy devices */ -- pirq_guest_bind(d->vcpu[0], machine_gsi, BIND_PIRQ__WILL_SHARE); -+ rc = pirq_guest_bind(d->vcpu[0], machine_gsi, BIND_PIRQ__WILL_SHARE); -+ if ( unlikely(rc) ) -+ { -+ kill_timer(&hvm_irq_dpci->hvm_timer[vector]); -+ hvm_irq_dpci->mirq[machine_gsi].dom = NULL; -+ clear_bit(machine_gsi, hvm_irq_dpci->mapping); -+ hvm_irq_dpci->girq[guest_gsi].machine_gsi = 0; -+ hvm_irq_dpci->girq[guest_gsi].intx = 0; -+ hvm_irq_dpci->girq[guest_gsi].device = 0; -+ hvm_irq_dpci->girq[guest_gsi].valid = 0; -+ list_del(&digl->list); -+ hvm_irq_dpci->link_cnt[link]--; -+ spin_unlock(&d->event_lock); -+ xfree(digl); -+ return rc; -+ } - } - - gdprintk(XENLOG_INFO VTDPREFIX, diff --git a/18904-x86-local-irq.patch b/18904-x86-local-irq.patch deleted file mode 100644 index 0e8c4bd..0000000 --- a/18904-x86-local-irq.patch +++ /dev/null @@ -1,95 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1228995360 0 -# Node ID f4c1a347311bbdc7dbf3b1b213719929cf03ede3 -# Parent 68555b9a7d98a6e91b55766e54d8e6d08589b3ac -x86: unify local_irq_XXX() - -This also removes an inconsistency in that x86-64's __save_flags() had -a memory clobber, while x86_32's didn't. - -It further adds type checking since blindly using {pop,push}{l,q} on a -memory operand of unknown size bares the risk of corrupting other -data. - -Finally, it eliminates the redundant (with local_irq_restore()) -__restore_flags() macro and renames __save_flags() to -local_save_flags(), making the naming consistent with Linux (again?). - -Signed-off-by: Jan Beulich - ---- a/xen/include/asm-x86/system.h -+++ b/xen/include/asm-x86/system.h -@@ -1,8 +1,7 @@ - #ifndef __ASM_SYSTEM_H - #define __ASM_SYSTEM_H - --#include --#include -+#include - #include - - #define read_segment_register(name) \ -@@ -171,10 +170,27 @@ static always_inline unsigned long __cmp - /* used when interrupts are already enabled or to shutdown the processor */ - #define halt() asm volatile ( "hlt" : : : "memory" ) - -+#define local_save_flags(x) \ -+({ \ -+ BUILD_BUG_ON(sizeof(x) != sizeof(long)); \ -+ asm volatile ( "pushf" __OS " ; pop" __OS " %0" : "=g" (x)); \ -+}) -+#define local_irq_save(x) \ -+({ \ -+ local_save_flags(x); \ -+ local_irq_disable(); \ -+}) -+#define local_irq_restore(x) \ -+({ \ -+ BUILD_BUG_ON(sizeof(x) != sizeof(long)); \ -+ asm volatile ( "push" __OS " %0 ; popf" __OS \ -+ : : "g" (x) : "memory", "cc" ); \ -+}) -+ - static inline int local_irq_is_enabled(void) - { - unsigned long flags; -- __save_flags(flags); -+ local_save_flags(flags); - return !!(flags & (1<<9)); /* EFLAGS_IF */ - } - ---- a/xen/include/asm-x86/x86_32/system.h -+++ b/xen/include/asm-x86/x86_32/system.h -@@ -101,14 +101,4 @@ static inline void atomic_write64(uint64 - #define mb() \ - asm volatile ( "lock; addl $0,0(%%esp)" : : : "memory" ) - --#define __save_flags(x) \ -- asm volatile ( "pushfl ; popl %0" : "=g" (x) : ) --#define __restore_flags(x) \ -- asm volatile ( "pushl %0 ; popfl" : : "g" (x) : "memory", "cc" ) -- --#define local_irq_save(x) \ -- asm volatile ( "pushfl ; popl %0 ; cli" : "=g" (x) : : "memory" ) --#define local_irq_restore(x) \ -- __restore_flags(x) -- - #endif /* __X86_32_SYSTEM_H__ */ ---- a/xen/include/asm-x86/x86_64/system.h -+++ b/xen/include/asm-x86/x86_64/system.h -@@ -55,14 +55,4 @@ static inline void atomic_write64(uint64 - #define mb() \ - asm volatile ( "mfence" : : : "memory" ) - --#define __save_flags(x) \ -- asm volatile ( "pushfq ; popq %q0" : "=g" (x) : :"memory" ) --#define __restore_flags(x) \ -- asm volatile ( "pushq %0 ; popfq" : : "g" (x) : "memory", "cc" ) -- --#define local_irq_save(x) \ -- asm volatile ( "pushfq ; popq %0 ; cli" : "=g" (x) : : "memory" ) --#define local_irq_restore(x) \ -- __restore_flags(x) -- - #endif /* __X86_64_SYSTEM_H__ */ diff --git a/18905-x86-ioapic-boot-panic.patch b/18905-x86-ioapic-boot-panic.patch deleted file mode 100644 index a8d7329..0000000 --- a/18905-x86-ioapic-boot-panic.patch +++ /dev/null @@ -1,94 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1228995610 0 -# Node ID c15244125a693d2a1ae5e5745a649467394d8dac -# Parent f4c1a347311bbdc7dbf3b1b213719929cf03ede3 -x86: fix the potential of encountering panic "IO-APIC + timer doesn't work! ..." - -Signed-off-by: Jan Beulich - -Linux commit: -http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=4aae07025265151e3f7041dfbf0f529e122de1d8 - -x86: fix "Kernel panic - not syncing: IO-APIC + timer doesn't work!" - -Under rare circumstances we found we could have an IRQ0 entry while we -are in the middle of setting up the local APIC, the i8259A and the -PIT. That is certainly not how it's supposed to work! check_timer() -was supposed to be called with irqs turned off - but this eroded away -sometime in the past. This code would still work most of the time -because this code runs very quickly, but just the right timing -conditions are present and IRQ0 hits in this small, ~30 usecs window, -timer irqs stop and the system does not boot up. Also, given how early -this is during bootup, the hang is very deterministic - but it would -only occur on certain machines (and certain configs). - -The fix was quite simple: disable/restore interrupts properly in this -function. With that in place the test-system now boots up just fine. - -Signed-off-by: Ingo Molnar -Signed-off-by: Thomas Gleixner - ---- a/xen/arch/x86/io_apic.c -+++ b/xen/arch/x86/io_apic.c -@@ -1259,14 +1259,16 @@ static void __init setup_ioapic_ids_from - static int __init timer_irq_works(void) - { - extern unsigned long pit0_ticks; -- unsigned long t1; -+ unsigned long t1, flags; - - t1 = pit0_ticks; - mb(); - -+ local_save_flags(flags); - local_irq_enable(); - /* Let ten ticks pass... */ - mdelay((10 * 1000) / HZ); -+ local_irq_restore(flags); - - /* - * Expect a few ticks at least, to be sure some possible -@@ -1720,6 +1722,9 @@ static inline void check_timer(void) - { - int apic1, pin1, apic2, pin2; - int vector; -+ unsigned long flags; -+ -+ local_irq_save(flags); - - /* - * get/set the timer IRQ vector: -@@ -1761,6 +1766,7 @@ static inline void check_timer(void) - */ - unmask_IO_APIC_irq(0); - if (timer_irq_works()) { -+ local_irq_restore(flags); - if (disable_timer_pin_1 > 0) - clear_IO_APIC_pin(apic1, pin1); - return; -@@ -1778,6 +1784,7 @@ static inline void check_timer(void) - */ - setup_ExtINT_IRQ0_pin(apic2, pin2, vector); - if (timer_irq_works()) { -+ local_irq_restore(flags); - printk("works.\n"); - if (pin1 != -1) - replace_pin_at_irq(0, apic1, pin1, apic2, pin2); -@@ -1805,6 +1812,7 @@ static inline void check_timer(void) - enable_8259A_irq(0); - - if (timer_irq_works()) { -+ local_irq_restore(flags); - printk(" works.\n"); - return; - } -@@ -1820,6 +1828,8 @@ static inline void check_timer(void) - - unlock_ExtINT_logic(); - -+ local_irq_restore(flags); -+ - if (timer_irq_works()) { - printk(" works.\n"); - return; diff --git a/18929-shadow-no-duplicates.patch b/18929-shadow-no-duplicates.patch deleted file mode 100644 index 25b18e2..0000000 --- a/18929-shadow-no-duplicates.patch +++ /dev/null @@ -1,29 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1229599705 0 -# Node ID c2dad16819b54c2c4b2bb0e9e89f71c279eaf156 -# Parent b33b745cd5ec3213feeb1d99e421e79cc5f12370 -x86, shadow: Avoid duplicates in fixup tables. - -Avoid entering duplicates in fixup tables, reducing fixup evictions. - -Signed-off-by: Gianluca Guida - ---- a/xen/arch/x86/mm/shadow/common.c -+++ b/xen/arch/x86/mm/shadow/common.c -@@ -626,6 +626,15 @@ void oos_fixup_add(struct vcpu *v, mfn_t - idx = (idx + 1) % SHADOW_OOS_PAGES; - if ( mfn_x(oos[idx]) == mfn_x(gmfn) ) - { -+ int i; -+ for ( i = 0; i < SHADOW_OOS_FIXUPS; i++ ) -+ { -+ if ( mfn_valid(oos_fixup[idx].smfn[i]) -+ && (mfn_x(oos_fixup[idx].smfn[i]) == mfn_x(smfn)) -+ && (oos_fixup[idx].off[i] == off) ) -+ return; -+ } -+ - next = oos_fixup[idx].next; - - if ( mfn_x(oos_fixup[idx].smfn[next]) != INVALID_MFN ) diff --git a/18930-xenoprof-dunnington.patch b/18930-xenoprof-dunnington.patch deleted file mode 100644 index 79a5890..0000000 --- a/18930-xenoprof-dunnington.patch +++ /dev/null @@ -1,27 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1229599773 0 -# Node ID 768759d4e319f8c46a8558782a9bf1c7982e662d -# Parent c2dad16819b54c2c4b2bb0e9e89f71c279eaf156 -xenoprof: Add support for Intel Dunnington cores. - -Signed-off-by: Xiaowei Yang -Signed-off-by: Ting Zhou - ---- a/xen/arch/x86/oprofile/nmi_int.c -+++ b/xen/arch/x86/oprofile/nmi_int.c -@@ -315,11 +315,10 @@ static int __init ppro_init(char ** cpu_ - case 14: - *cpu_type = "i386/core"; - break; -- case 15: case 23: -- *cpu_type = "i386/core_2"; -- ppro_has_global_ctrl = 1; -- break; -+ case 15: -+ case 23: - case 26: -+ case 29: - *cpu_type = "i386/core_2"; - ppro_has_global_ctrl = 1; - break; diff --git a/18934-vtd-PCI-X-dev-assign.patch b/18934-vtd-PCI-X-dev-assign.patch deleted file mode 100644 index 15658a7..0000000 --- a/18934-vtd-PCI-X-dev-assign.patch +++ /dev/null @@ -1,212 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1229694124 0 -# Node ID d238101c1832ba178bfc00a20b461fcebe21d5df -# Parent 8c35da364ab39605839869d8eb0ac9b831c370f0 -VT-d: Fix PCI-X device assignment - -When assign PCI device, current code just map its bridge and its -secondary bus number and devfn 0. It doesn't work for PCI-x device -assignment, because the request may be the source-id in the original -PCI-X transaction or the source-id provided by the bridge. It needs to -map the device itself, and its upstream bridges till PCIe-to-PCI/PCI-x -bridge. - -In addition, add description for DEV_TYPE_PCIe_BRIDGE and -DEV_TYPE_PCI_BRIDGE for understandability. - -Signed-off-by: Weidong Han - -# HG changeset patch -# User Keir Fraser -# Date 1231154002 0 -# Node ID b3a9bc72624166a230da74c498154ae2cb45eacc -# Parent 9cc632cc6d400685679671b6bbc58dfe4c5e287e -vtd: avoid redundant context mapping - -After changeset 18934 (VT-d: Fix PCI-X device assignment), my assigned -PCI E1000 NIC doesn't work in guest. - -The NIC is 03:00.0. Its parent bridge is: 00:1e.0. -In domain_context_mapping(): - case DEV_TYPE_PCI: - After we domain_context_mapping_one() 03:00.0 and 00:1e.0, the - 'secbus' is 3 and 'bus' is 0, so we domain_context_mapping_one() - 03:00.0 again -- this redundant invocation returns -EINVAL because - we have created the mapping but haven't changed pdev->domain from - Dom0 to a new domain at this time and eventually the - XEN_DOMCTL_assign_device hypercall returns a failure. - -The attached patch detects this case and avoids the redundant -invocation. - -Signed-off-by: Dexuan Cui - ---- a/xen/drivers/passthrough/vtd/iommu.c -+++ b/xen/drivers/passthrough/vtd/iommu.c -@@ -1155,8 +1155,8 @@ static int domain_context_mapping_one( - - enum { - DEV_TYPE_PCIe_ENDPOINT, -- DEV_TYPE_PCIe_BRIDGE, -- DEV_TYPE_PCI_BRIDGE, -+ DEV_TYPE_PCIe_BRIDGE, // PCIe root port, switch -+ DEV_TYPE_PCI_BRIDGE, // PCIe-to-PCI/PCIx bridge, PCI-to-PCI bridge - DEV_TYPE_PCI, - }; - -@@ -1170,7 +1170,8 @@ int pdev_type(u8 bus, u8 devfn) - class_device = pci_conf_read16(bus, d, f, PCI_CLASS_DEVICE); - if ( class_device == PCI_CLASS_BRIDGE_PCI ) - { -- pos = pci_find_next_cap(bus, devfn, PCI_CAPABILITY_LIST, PCI_CAP_ID_EXP); -+ pos = pci_find_next_cap(bus, devfn, -+ PCI_CAPABILITY_LIST, PCI_CAP_ID_EXP); - if ( !pos ) - return DEV_TYPE_PCI_BRIDGE; - creg = pci_conf_read16(bus, d, f, pos + PCI_EXP_FLAGS); -@@ -1219,9 +1220,9 @@ static int domain_context_mapping(struct - { - struct acpi_drhd_unit *drhd; - int ret = 0; -- u16 sec_bus, sub_bus, ob, odf; -+ u16 sec_bus, sub_bus; - u32 type; -- u8 secbus; -+ u8 secbus, secdevfn; - - drhd = acpi_find_matched_drhd_unit(bus, devfn); - if ( !drhd ) -@@ -1231,15 +1232,13 @@ static int domain_context_mapping(struct - switch ( type ) - { - case DEV_TYPE_PCIe_BRIDGE: -+ break; -+ - case DEV_TYPE_PCI_BRIDGE: - sec_bus = pci_conf_read8(bus, PCI_SLOT(devfn), PCI_FUNC(devfn), - PCI_SECONDARY_BUS); - sub_bus = pci_conf_read8(bus, PCI_SLOT(devfn), PCI_FUNC(devfn), - PCI_SUBORDINATE_BUS); -- /*dmar_scope_add_buses(&drhd->scope, sec_bus, sub_bus);*/ -- -- if ( type == DEV_TYPE_PCIe_BRIDGE ) -- break; - - for ( sub_bus &= 0xff; sec_bus <= sub_bus; sec_bus++ ) - { -@@ -1258,26 +1257,28 @@ static int domain_context_mapping(struct - - case DEV_TYPE_PCI: - gdprintk(XENLOG_INFO VTDPREFIX, -- "domain_context_mapping:PCI: bdf = %x:%x.%x\n", -+ "domain_context_mapping:PCI: bdf = %x:%x.%x\n", - bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); - -- ob = bus; odf = devfn; -- if ( !find_pcie_endpoint(&bus, &devfn, &secbus) ) -+ ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn); -+ if ( ret ) -+ break; -+ -+ secbus = bus; -+ secdevfn = devfn; -+ /* dependent devices mapping */ -+ while ( bus2bridge[bus].map ) - { -- gdprintk(XENLOG_WARNING VTDPREFIX, -- "domain_context_mapping:invalid\n"); -- break; -+ secbus = bus; -+ secdevfn = devfn; -+ devfn = bus2bridge[bus].devfn; -+ bus = bus2bridge[bus].bus; -+ ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn); -+ if ( ret ) -+ return ret; - } - -- if ( ob != bus || odf != devfn ) -- gdprintk(XENLOG_INFO VTDPREFIX, -- "domain_context_mapping:map: " -- "bdf = %x:%x.%x -> %x:%x.%x\n", -- ob, PCI_SLOT(odf), PCI_FUNC(odf), -- bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); -- -- ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn); -- if ( secbus != bus ) -+ if ( (secbus != bus) && (secdevfn != 0) ) - /* - * The source-id for transactions on non-PCIe buses seem - * to originate from devfn=0 on the secondary bus behind -@@ -1285,7 +1286,7 @@ static int domain_context_mapping(struct - * these scanarios is not particularly well documented - * anywhere. - */ -- domain_context_mapping_one(domain, drhd->iommu, secbus, 0); -+ ret = domain_context_mapping_one(domain, drhd->iommu, secbus, 0); - break; - - default: -@@ -1339,10 +1340,9 @@ static int domain_context_unmap_one( - static int domain_context_unmap(struct domain *domain, u8 bus, u8 devfn) - { - struct acpi_drhd_unit *drhd; -- u16 sec_bus, sub_bus; - int ret = 0; - u32 type; -- u8 secbus; -+ u8 secbus, secdevfn; - - drhd = acpi_find_matched_drhd_unit(bus, devfn); - if ( !drhd ) -@@ -1353,24 +1353,39 @@ static int domain_context_unmap(struct d - { - case DEV_TYPE_PCIe_BRIDGE: - case DEV_TYPE_PCI_BRIDGE: -- sec_bus = pci_conf_read8(bus, PCI_SLOT(devfn), PCI_FUNC(devfn), -- PCI_SECONDARY_BUS); -- sub_bus = pci_conf_read8(bus, PCI_SLOT(devfn), PCI_FUNC(devfn), -- PCI_SUBORDINATE_BUS); -- /*dmar_scope_remove_buses(&drhd->scope, sec_bus, sub_bus);*/ -- if ( DEV_TYPE_PCI_BRIDGE ) -- ret = domain_context_unmap_one(domain, drhd->iommu, bus, devfn); - break; - - case DEV_TYPE_PCIe_ENDPOINT: -+ gdprintk(XENLOG_INFO VTDPREFIX, -+ "domain_context_unmap:PCIe: bdf = %x:%x.%x\n", -+ bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); - ret = domain_context_unmap_one(domain, drhd->iommu, bus, devfn); - break; - - case DEV_TYPE_PCI: -- if ( find_pcie_endpoint(&bus, &devfn, &secbus) ) -+ gdprintk(XENLOG_INFO VTDPREFIX, -+ "domain_context_unmap:PCI: bdf = %x:%x.%x\n", -+ bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); -+ ret = domain_context_unmap_one(domain, drhd->iommu, bus, devfn); -+ if ( ret ) -+ break; -+ -+ secbus = bus; -+ secdevfn = devfn; -+ /* dependent devices unmapping */ -+ while ( bus2bridge[bus].map ) -+ { -+ secbus = bus; -+ secdevfn = devfn; -+ devfn = bus2bridge[bus].devfn; -+ bus = bus2bridge[bus].bus; - ret = domain_context_unmap_one(domain, drhd->iommu, bus, devfn); -- if ( bus != secbus ) -- domain_context_unmap_one(domain, drhd->iommu, secbus, 0); -+ if ( ret ) -+ return ret; -+ } -+ -+ if ( (secbus != bus) && (secdevfn != 0) ) -+ ret = domain_context_unmap_one(domain, drhd->iommu, secbus, 0); - break; - - default: diff --git a/18937-S3-MSI.patch b/18937-S3-MSI.patch deleted file mode 100644 index d9a538f..0000000 --- a/18937-S3-MSI.patch +++ /dev/null @@ -1,112 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1229698596 0 -# Node ID 2dffa6ceb0af954e7f3a9ad7e993b8aee7b7de65 -# Parent 738513b106fa262a11cc3254cd6dd67afb3a63e7 -Support S3 for MSI interrupt - -From: "Jiang, Yunhong" -Signed-off-by: Keir Fraser - ---- a/xen/arch/x86/msi.c -+++ b/xen/arch/x86/msi.c -@@ -771,3 +771,41 @@ void pci_cleanup_msi(struct pci_dev *pde - msi_free_vectors(pdev); - } - -+int pci_restore_msi_state(struct pci_dev *pdev) -+{ -+ unsigned long flags; -+ int vector; -+ struct msi_desc *entry, *tmp; -+ irq_desc_t *desc; -+ -+ if (!pdev) -+ return -EINVAL; -+ -+ list_for_each_entry_safe( entry, tmp, &pdev->msi_list, list ) -+ { -+ vector = entry->vector; -+ desc = &irq_desc[vector]; -+ -+ spin_lock_irqsave(&desc->lock, flags); -+ -+ ASSERT(desc->msi_desc == entry); -+ -+ if (desc->msi_desc != entry) -+ { -+ dprintk(XENLOG_ERR, "Restore MSI for dev %x:%x not set before?\n", -+ pdev->bus, pdev->devfn); -+ spin_unlock_irqrestore(&desc->lock, flags); -+ return -EINVAL; -+ } -+ -+ msi_set_enable(pdev, 0); -+ write_msi_msg(entry, &entry->msg); -+ -+ msi_set_enable(pdev, 1); -+ msi_set_mask_bit(vector, entry->msi_attrib.masked); -+ spin_unlock_irqrestore(&desc->lock, flags); -+ } -+ -+ return 0; -+} -+ ---- a/xen/arch/x86/physdev.c -+++ b/xen/arch/x86/physdev.c -@@ -427,6 +427,27 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H - break; - } - -+ case PHYSDEVOP_restore_msi: { -+ struct physdev_restore_msi restore_msi; -+ struct pci_dev *pdev; -+ -+ ret = -EPERM; -+ if ( !IS_PRIV(v->domain) ) -+ break; -+ -+ ret = -EFAULT; -+ if ( copy_from_guest(&restore_msi, arg, 1) != 0 ) -+ break; -+ -+ pdev = pci_lock_pdev(restore_msi.bus, restore_msi.devfn); -+ ret = -ENODEV; -+ if ( !pdev ) -+ break; -+ -+ ret = pci_restore_msi_state(pdev); -+ spin_unlock(&pdev->lock); -+ break; -+ } - default: - ret = -ENOSYS; - break; ---- a/xen/include/asm-x86/msi.h -+++ b/xen/include/asm-x86/msi.h -@@ -75,6 +75,7 @@ extern void set_msi_irq_affinity(unsigne - extern int pci_enable_msi(struct msi_info *msi); - extern void pci_disable_msi(int vector); - extern void pci_cleanup_msi(struct pci_dev *pdev); -+extern int pci_restore_msi_state(struct pci_dev *pdev); - - struct msi_desc { - struct { ---- a/xen/include/public/physdev.h -+++ b/xen/include/public/physdev.h -@@ -183,6 +183,15 @@ struct physdev_manage_pci { - typedef struct physdev_manage_pci physdev_manage_pci_t; - DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_t); - -+#define PHYSDEVOP_restore_msi 19 -+struct physdev_restore_msi { -+ /* IN */ -+ uint8_t bus; -+ uint8_t devfn; -+}; -+typedef struct physdev_restore_msi physdev_restore_msi_t; -+DEFINE_XEN_GUEST_HANDLE(physdev_restore_msi_t); -+ - /* - * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op() - * hypercall since 0x00030202. diff --git a/18943-amd-32bit-paging-limit.patch b/18943-amd-32bit-paging-limit.patch deleted file mode 100644 index 81b95c0..0000000 --- a/18943-amd-32bit-paging-limit.patch +++ /dev/null @@ -1,28 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1230557552 0 -# Node ID 0af9fbf3f05306d4972cf05e4b6d7be2199a41cb -# Parent c54d6f871de8f271aaeb571c3b87eae9165e3183 -x86: Do not restrict 32-bit EPT to 4GB. - -Signed-off-by: Xin, Xiaohui - -Index: xen-3.3.1-testing/xen/arch/x86/mm/p2m.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/mm/p2m.c -+++ xen-3.3.1-testing/xen/arch/x86/mm/p2m.c -@@ -935,11 +935,12 @@ guest_physmap_add_entry(struct domain *d - - #if CONFIG_PAGING_LEVELS == 3 - /* -- * 32bit PAE nested paging does not support over 4GB guest due to -+ * 32bit AMD nested paging does not support over 4GB guest due to - * hardware translation limit. This limitation is checked by comparing - * gfn with 0xfffffUL. - */ -- if ( paging_mode_hap(d) && (gfn > 0xfffffUL) ) -+ if ( paging_mode_hap(d) && (gfn > 0xfffffUL) && -+ (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) ) - { - if ( !test_and_set_bool(d->arch.hvm_domain.svm.npt_4gb_warning) ) - dprintk(XENLOG_WARNING, "Dom%d failed to populate memory beyond" diff --git a/18970-vmx-print-features.patch b/18970-vmx-print-features.patch deleted file mode 100644 index 03e9377..0000000 --- a/18970-vmx-print-features.patch +++ /dev/null @@ -1,44 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1231156354 0 -# Node ID 2c5a2e99a1d69d635843955310488fbd5e1bcdd2 -# Parent d6889b3b64231dd4c2cd86ca6e66d0a4ef2d5dfc -vmx: Print advanced features during boot -Signed-off-by: Keir Fraser - ---- a/xen/arch/x86/hvm/vmx/vmcs.c -+++ b/xen/arch/x86/hvm/vmx/vmcs.c -@@ -55,6 +55,25 @@ static DEFINE_PER_CPU(struct list_head, - - static u32 vmcs_revision_id __read_mostly; - -+static void __init vmx_display_features(void) -+{ -+ int printed = 0; -+ -+ printk("VMX: Supported advanced features:\n"); -+ -+#define P(p,s) if ( p ) { printk(" - %s\n", s); printed = 1; } -+ P(cpu_has_vmx_virtualize_apic_accesses, "APIC MMIO access virtualisation"); -+ P(cpu_has_vmx_tpr_shadow, "APIC TPR shadow"); -+ P(cpu_has_vmx_ept, "Extended Page Tables (EPT)"); -+ P(cpu_has_vmx_vpid, "Virtual-Processor Identifiers (VPID)"); -+ P(cpu_has_vmx_vnmi, "Virtual NMI"); -+ P(cpu_has_vmx_msr_bitmap, "MSR direct-access bitmap"); -+#undef P -+ -+ if ( !printed ) -+ printk(" - none\n"); -+} -+ - static u32 adjust_vmx_controls(u32 ctl_min, u32 ctl_opt, u32 msr) - { - u32 vmx_msr_low, vmx_msr_high, ctl = ctl_min | ctl_opt; -@@ -168,6 +187,7 @@ static void vmx_init_vmcs_config(void) - vmx_vmexit_control = _vmx_vmexit_control; - vmx_vmentry_control = _vmx_vmentry_control; - cpu_has_vmx_ins_outs_instr_info = !!(vmx_basic_msr_high & (1U<<22)); -+ vmx_display_features(); - } - else - { diff --git a/19027-hvmloader-SMBIOS-dev-mem-boundary.patch b/19027-hvmloader-SMBIOS-dev-mem-boundary.patch deleted file mode 100644 index 2d2cc3f..0000000 --- a/19027-hvmloader-SMBIOS-dev-mem-boundary.patch +++ /dev/null @@ -1,27 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1231755835 0 -# Node ID 95d8788bf4be2e8b8d2b984e290f5e19eef1a16c -# Parent 59d511c4a8d8ba451afc6ebd88e049fa2addf9f5 -hvmloader: Fix SMBIOS memory device length boundary condition. - -dev_memsize ends up 0 when it shouldn't be on 16G boundary conditions. - -Signed-off-by: Bill Rieske -Signed-off-by: Keir Fraser - -diff -r 59d511c4a8d8 -r 95d8788bf4be tools/firmware/hvmloader/smbios.c ---- a/tools/firmware/hvmloader/smbios.c Mon Jan 12 10:17:12 2009 +0000 -+++ b/tools/firmware/hvmloader/smbios.c Mon Jan 12 10:23:55 2009 +0000 -@@ -118,8 +118,9 @@ write_smbios_tables(void *start, - do_struct(smbios_type_16_init(p, memsize, nr_mem_devs)); - for ( i = 0; i < nr_mem_devs; i++ ) - { -- uint32_t dev_memsize = ((i == (nr_mem_devs - 1)) -- ? (memsize & 0x3fff) : 0x4000); -+ uint32_t dev_memsize = 0x4000; /* all but last covers 16GB */ -+ if ( (i == (nr_mem_devs - 1)) && ((memsize & 0x3fff) != 0) ) -+ dev_memsize = memsize & 0x3fff; /* last dev is <16GB */ - do_struct(smbios_type_17_init(p, dev_memsize, i)); - do_struct(smbios_type_19_init(p, dev_memsize, i)); - do_struct(smbios_type_20_init(p, dev_memsize, i)); diff --git a/19032-amd-iommu-pointer-reset.patch b/19032-amd-iommu-pointer-reset.patch deleted file mode 100644 index 582a294..0000000 --- a/19032-amd-iommu-pointer-reset.patch +++ /dev/null @@ -1,37 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1231859806 0 -# Node ID 73770182aee48e79a2caa441ad1013982deefddb -# Parent 1c6642adaeb204495c95ab86c8aee41587a22928 -AMD IOMMU: Reset tail and head pointer of cmd buffer and event log - -Reset the tail and the head pointers of command buffer and event log -to zero in case that iommu does not reset them after the base -addresses of those buffers are updated. - -Signed-off-by: Wei Wang - ---- a/xen/drivers/passthrough/amd/iommu_init.c -+++ b/xen/drivers/passthrough/amd/iommu_init.c -@@ -195,6 +195,10 @@ static void __init set_iommu_command_buf - IOMMU_CONTROL_COMMAND_BUFFER_ENABLE_MASK, - IOMMU_CONTROL_COMMAND_BUFFER_ENABLE_SHIFT, &entry); - writel(entry, iommu->mmio_base+IOMMU_CONTROL_MMIO_OFFSET); -+ -+ /*reset head and tail pointer */ -+ writel(0x0, iommu->mmio_base + IOMMU_CMD_BUFFER_HEAD_OFFSET); -+ writel(0x0, iommu->mmio_base + IOMMU_CMD_BUFFER_TAIL_OFFSET); - } - - static void __init register_iommu_exclusion_range(struct amd_iommu *iommu) -@@ -259,6 +263,10 @@ static void __init set_iommu_event_log_c - IOMMU_CONTROL_COMP_WAIT_INT_MASK, - IOMMU_CONTROL_COMP_WAIT_INT_SHIFT, &entry); - writel(entry, iommu->mmio_base+IOMMU_CONTROL_MMIO_OFFSET); -+ -+ /*reset head and tail pointer */ -+ writel(0x0, iommu->mmio_base + IOMMU_EVENT_LOG_HEAD_OFFSET); -+ writel(0x0, iommu->mmio_base + IOMMU_EVENT_LOG_TAIL_OFFSET); - } - - static int amd_iommu_read_event_log(struct amd_iommu *iommu, u32 event[]) diff --git a/19035-MSI-X-proper-enable.patch b/19035-MSI-X-proper-enable.patch deleted file mode 100644 index 9945189..0000000 --- a/19035-MSI-X-proper-enable.patch +++ /dev/null @@ -1,46 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1231862027 0 -# Node ID 4f6a2bbdff3fea7db13979ffccb1ae5403ca79c8 -# Parent b169db55faf38fda27985626284c9262aac09784 -x86: Call msix_set_enable for MSI-x interrupt - -For MSI-x, we should call msix_set_enable() instead of -msi_set_enable(). - -Signed-off-by: Jiang Yunhong - ---- a/xen/arch/x86/msi.c -+++ b/xen/arch/x86/msi.c -@@ -702,7 +702,7 @@ static void __pci_disable_msix(int vecto - - pos = pci_find_cap_offset(bus, slot, func, PCI_CAP_ID_MSIX); - control = pci_conf_read16(bus, slot, func, msix_control_reg(pos)); -- msi_set_enable(dev, 0); -+ msix_set_enable(dev, 0); - - BUG_ON(list_empty(&dev->msi_list)); - -@@ -798,11 +798,20 @@ int pci_restore_msi_state(struct pci_dev - return -EINVAL; - } - -- msi_set_enable(pdev, 0); -+ if ( entry->msi_attrib.type == PCI_CAP_ID_MSI ) -+ msi_set_enable(pdev, 0); -+ else if ( entry->msi_attrib.type == PCI_CAP_ID_MSIX ) -+ msix_set_enable(pdev, 0); -+ - write_msi_msg(entry, &entry->msg); - -- msi_set_enable(pdev, 1); - msi_set_mask_bit(vector, entry->msi_attrib.masked); -+ -+ if ( entry->msi_attrib.type == PCI_CAP_ID_MSI ) -+ msi_set_enable(pdev, 1); -+ else if ( entry->msi_attrib.type == PCI_CAP_ID_MSIX ) -+ msix_set_enable(pdev, 1); -+ - spin_unlock_irqrestore(&desc->lock, flags); - } - diff --git a/19038-x86-no-apic.patch b/19038-x86-no-apic.patch deleted file mode 100644 index 65ed50a..0000000 --- a/19038-x86-no-apic.patch +++ /dev/null @@ -1,135 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1231930540 0 -# Node ID 59274c49a0298fd73f60759c0842a293b5816057 -# Parent cc542ebe48539b9ca0534ca241209734234fdff2 -x86: restore ability to work on systems without APIC - -This got broken with the default-enabling of MSI. Apart from fixing -the base issue, the patch also addresses -- the 'i' command crashing where there is no IO-APIC, -- the 'i' command needlessly printing information for all 256 vectors - when the use of IO-APIC(s) is disabled, and -- the need to specify both "nolapic" and "noapic" when "nolapic" alone - should already have the intended effect. - -Signed-off-by: Jan Beulich - ---- a/xen/arch/x86/apic.c -+++ b/xen/arch/x86/apic.c -@@ -40,7 +40,7 @@ - /* - * Knob to control our willingness to enable the local APIC. - */ --int enable_local_apic __initdata = 0; /* -1=force-disable, +1=force-enable */ -+static int enable_local_apic __initdata = 0; /* -1=force-disable, +1=force-enable */ - - /* - * Debug level -@@ -719,7 +719,7 @@ static void apic_pm_activate(void) - static void __init lapic_disable(char *str) - { - enable_local_apic = -1; -- clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability); -+ setup_clear_cpu_cap(X86_FEATURE_APIC); - } - custom_param("nolapic", lapic_disable); - -@@ -852,6 +852,7 @@ void __init init_apic_mappings(void) - if (!smp_found_config && detect_init_APIC()) { - apic_phys = __pa(alloc_xenheap_page()); - clear_page(__va(apic_phys)); -+ msi_enable = 0; - } else - apic_phys = mp_lapic_addr; - -@@ -1280,8 +1281,10 @@ int __init APIC_init_uniprocessor (void) - if (enable_local_apic < 0) - clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability); - -- if (!smp_found_config && !cpu_has_apic) -+ if (!smp_found_config && !cpu_has_apic) { -+ msi_enable = 0; - return -1; -+ } - - /* - * Complain if the BIOS pretends there is one. -@@ -1290,6 +1293,7 @@ int __init APIC_init_uniprocessor (void) - printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n", - boot_cpu_physical_apicid); - clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability); -+ msi_enable = 0; - return -1; - } - ---- a/xen/arch/x86/cpu/common.c -+++ b/xen/arch/x86/cpu/common.c -@@ -29,6 +29,14 @@ struct cpu_dev * cpu_devs[X86_VENDOR_NUM - */ - u64 host_pat = 0x050100070406; - -+static unsigned int __cpuinitdata cleared_caps[NCAPINTS]; -+ -+void __init setup_clear_cpu_cap(unsigned int cap) -+{ -+ __clear_bit(cap, boot_cpu_data.x86_capability); -+ __set_bit(cap, cleared_caps); -+} -+ - static void default_init(struct cpuinfo_x86 * c) - { - /* Not much we can do here... */ -@@ -235,6 +243,7 @@ static void __init early_cpu_detect(void - if (c->x86 >= 0x6) - c->x86_model += ((tfms >> 16) & 0xF) << 4; - c->x86_mask = tfms & 15; -+ cap0 &= ~cleared_caps[0]; - if (cap0 & (1<<19)) - c->x86_cache_alignment = ((misc >> 8) & 0xff) * 8; - c->x86_capability[0] = cap0; /* Added for Xen bootstrap */ -@@ -395,6 +404,9 @@ void __cpuinit identify_cpu(struct cpuin - if (disable_pse) - clear_bit(X86_FEATURE_PSE, c->x86_capability); - -+ for (i = 0 ; i < NCAPINTS ; ++i) -+ c->x86_capability[i] &= ~cleared_caps[i]; -+ - /* If the model name is still unset, do table lookup. */ - if ( !c->x86_model_id[0] ) { - char *p; ---- a/xen/arch/x86/io_apic.c -+++ b/xen/arch/x86/io_apic.c -@@ -87,7 +87,9 @@ int disable_timer_pin_1 __initdata; - - static struct irq_pin_list { - int apic, pin, next; --} irq_2_pin[PIN_MAP_SIZE]; -+} irq_2_pin[PIN_MAP_SIZE] = { -+ [0 ... PIN_MAP_SIZE-1].pin = -1 -+}; - static int irq_2_pin_free_entry = NR_IRQS; - - int vector_irq[NR_VECTORS] __read_mostly = { -@@ -1020,11 +1022,6 @@ static void __init enable_IO_APIC(void) - int i, apic; - unsigned long flags; - -- for (i = 0; i < PIN_MAP_SIZE; i++) { -- irq_2_pin[i].pin = -1; -- irq_2_pin[i].next = 0; -- } -- - /* Initialise dynamic irq_2_pin free list. */ - for (i = NR_IRQS; i < PIN_MAP_SIZE; i++) - irq_2_pin[i].next = i + 1; ---- a/xen/include/asm-x86/processor.h -+++ b/xen/include/asm-x86/processor.h -@@ -191,6 +191,7 @@ extern int phys_proc_id[NR_CPUS]; - extern int cpu_core_id[NR_CPUS]; - - extern void identify_cpu(struct cpuinfo_x86 *); -+extern void setup_clear_cpu_cap(unsigned int); - extern void print_cpu_info(struct cpuinfo_x86 *); - extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); - extern void dodgy_tsc(void); diff --git a/19039-x86-propagate-nolapic.patch b/19039-x86-propagate-nolapic.patch deleted file mode 100644 index 0698444..0000000 --- a/19039-x86-propagate-nolapic.patch +++ /dev/null @@ -1,44 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1231930578 0 -# Node ID 3fb43f23f64ccc1687d1dc348a9eb454397d4887 -# Parent 59274c49a0298fd73f60759c0842a293b5816057 -x86: propagate disabled APIC state to Dom0 - -This in particular eliminates the need to specify "noapic" to Dom0 -when "noapic" is passed to Xen, provided the kernel side gets slightly -modified to make use of this information (Linux side patch cannot -easily be provided for the 2.6.18 tree, but this is being used by our -2.6.27-based one). - -Signed-off-by: Jan Beulich - ---- a/xen/arch/x86/traps.c -+++ b/xen/arch/x86/traps.c -@@ -711,6 +711,8 @@ static void pv_cpuid(struct cpu_user_reg - { - /* Modify Feature Information. */ - __clear_bit(X86_FEATURE_VME, &d); -+ if ( !cpu_has_apic ) -+ __clear_bit(X86_FEATURE_APIC % 32, &d); - __clear_bit(X86_FEATURE_PSE, &d); - __clear_bit(X86_FEATURE_PGE, &d); - __clear_bit(X86_FEATURE_MCE, &d); -@@ -742,6 +744,8 @@ static void pv_cpuid(struct cpu_user_reg - __clear_bit(X86_FEATURE_XTPR % 32, &c); - __clear_bit(X86_FEATURE_PDCM % 32, &c); - __clear_bit(X86_FEATURE_DCA % 32, &c); -+ if ( !cpu_has_apic ) -+ __clear_bit(X86_FEATURE_X2APIC % 32, &c); - __set_bit(X86_FEATURE_HYPERVISOR % 32, &c); - break; - case 0x80000001: -@@ -760,6 +764,8 @@ static void pv_cpuid(struct cpu_user_reg - __clear_bit(X86_FEATURE_RDTSCP % 32, &d); - - __clear_bit(X86_FEATURE_SVME % 32, &c); -+ if ( !cpu_has_apic ) -+ __clear_bit(X86_FEATURE_EXTAPICSPACE % 32, &c); - __clear_bit(X86_FEATURE_OSVW % 32, &c); - __clear_bit(X86_FEATURE_IBS % 32, &c); - __clear_bit(X86_FEATURE_SKINIT % 32, &c); diff --git a/19046-cross-bit-coredumping.patch b/19046-cross-bit-coredumping.patch deleted file mode 100644 index b04c63f..0000000 --- a/19046-cross-bit-coredumping.patch +++ /dev/null @@ -1,391 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1232023062 0 -# Node ID ecf603780f560095c4316169c9473d040f216dfc -# Parent f6a455c9f01db586832c0eb98c14965c045e07ac -libxc: Support cross-bitness guest when core-dumping - -This patch allows core-dumping to work on a cross-bit host/guest -configuration, whereas previously that was not supported. It supports -both PV and FV guests. The core file format generated by the host, -needs to match that of the guest, so an alignment issue is addressed, -along with the p2m frame list handling being done according to the -guest size. - -Signed-off-by: Bruce Rogers - -Index: xen-3.3.1-testing/tools/libxc/xc_core.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/libxc/xc_core.c -+++ xen-3.3.1-testing/tools/libxc/xc_core.c -@@ -58,9 +58,6 @@ - /* number of pages to write at a time */ - #define DUMP_INCREMENT (4 * 1024) - --/* Don't yet support cross-address-size core dump */ --#define guest_width (sizeof (unsigned long)) -- - /* string table */ - struct xc_core_strtab { - char *strings; -@@ -240,7 +237,7 @@ xc_core_ehdr_init(Elf64_Ehdr *ehdr) - ehdr->e_ident[EI_ABIVERSION] = EV_CURRENT; - - ehdr->e_type = ET_CORE; -- ehdr->e_machine = ELF_ARCH_MACHINE; -+ /* e_machine will be filled in later */ - ehdr->e_version = EV_CURRENT; - ehdr->e_entry = 0; - ehdr->e_phoff = 0; -@@ -359,7 +356,8 @@ elfnote_dump_core_header( - } - - static int --elfnote_dump_xen_version(void *args, dumpcore_rtn_t dump_rtn, int xc_handle) -+elfnote_dump_xen_version(void *args, dumpcore_rtn_t dump_rtn, int xc_handle, -+ unsigned int guest_width) - { - int sts; - struct elfnote elfnote; -@@ -371,6 +369,12 @@ elfnote_dump_xen_version(void *args, dum - elfnote.descsz = sizeof(xen_version); - elfnote.type = XEN_ELFNOTE_DUMPCORE_XEN_VERSION; - elfnote_fill_xen_version(xc_handle, &xen_version); -+ if (guest_width < sizeof(unsigned long)) -+ { -+ // 32 bit elf file format differs in pagesize's alignment -+ char *p = (char *)&xen_version.pagesize; -+ memmove(p - 4, p, sizeof(xen_version.pagesize)); -+ } - sts = dump_rtn(args, (char*)&elfnote, sizeof(elfnote)); - if ( sts != 0 ) - return sts; -@@ -396,6 +400,24 @@ elfnote_dump_format_version(void *args, - return dump_rtn(args, (char*)&format_version, sizeof(format_version)); - } - -+static int -+get_guest_width(int xc_handle, -+ uint32_t domid, -+ unsigned int *guest_width) -+{ -+ DECLARE_DOMCTL; -+ -+ memset(&domctl, 0, sizeof(domctl)); -+ domctl.domain = domid; -+ domctl.cmd = XEN_DOMCTL_get_address_size; -+ -+ if ( do_domctl(xc_handle, &domctl) != 0 ) -+ return 1; -+ -+ *guest_width = domctl.u.address_size.size / 8; -+ return 0; -+} -+ - int - xc_domain_dumpcore_via_callback(int xc_handle, - uint32_t domid, -@@ -403,7 +425,8 @@ xc_domain_dumpcore_via_callback(int xc_h - dumpcore_rtn_t dump_rtn) - { - xc_dominfo_t info; -- shared_info_t *live_shinfo = NULL; -+ shared_info_any_t *live_shinfo = NULL; -+ unsigned int guest_width; - - int nr_vcpus = 0; - char *dump_mem, *dump_mem_start = NULL; -@@ -437,6 +460,12 @@ xc_domain_dumpcore_via_callback(int xc_h - uint16_t strtab_idx; - struct xc_core_section_headers *sheaders = NULL; - Elf64_Shdr *shdr; -+ -+ if ( get_guest_width(xc_handle, domid, &guest_width) != 0 ) -+ { -+ PERROR("Could not get address size for domain"); -+ return sts; -+ } - - xc_core_arch_context_init(&arch_ctxt); - if ( (dump_mem_start = malloc(DUMP_INCREMENT*PAGE_SIZE)) == NULL ) -@@ -500,7 +529,7 @@ xc_domain_dumpcore_via_callback(int xc_h - goto out; - } - -- sts = xc_core_arch_map_p2m(xc_handle, &info, live_shinfo, -+ sts = xc_core_arch_map_p2m(xc_handle, guest_width, &info, live_shinfo, - &p2m, &p2m_size); - if ( sts != 0 ) - goto out; -@@ -676,6 +705,7 @@ xc_domain_dumpcore_via_callback(int xc_h - /* write out elf header */ - ehdr.e_shnum = sheaders->num; - ehdr.e_shstrndx = strtab_idx; -+ ehdr.e_machine = ELF_ARCH_MACHINE; - sts = dump_rtn(args, (char*)&ehdr, sizeof(ehdr)); - if ( sts != 0 ) - goto out; -@@ -697,7 +727,7 @@ xc_domain_dumpcore_via_callback(int xc_h - goto out; - - /* elf note section: xen version */ -- sts = elfnote_dump_xen_version(args, dump_rtn, xc_handle); -+ sts = elfnote_dump_xen_version(args, dump_rtn, xc_handle, guest_width); - if ( sts != 0 ) - goto out; - -@@ -757,9 +787,21 @@ xc_domain_dumpcore_via_callback(int xc_h - - if ( !auto_translated_physmap ) - { -- gmfn = p2m[i]; -- if ( gmfn == INVALID_P2M_ENTRY ) -- continue; -+ if ( guest_width >= sizeof(unsigned long) ) -+ { -+ if ( guest_width == sizeof(unsigned long) ) -+ gmfn = p2m[i]; -+ else -+ gmfn = ((uint64_t *)p2m)[i]; -+ if ( gmfn == INVALID_P2M_ENTRY ) -+ continue; -+ } -+ else -+ { -+ gmfn = ((uint32_t *)p2m)[i]; -+ if ( gmfn == (uint32_t)INVALID_P2M_ENTRY ) -+ continue; -+ } - - p2m_array[j].pfn = i; - p2m_array[j].gmfn = gmfn; -@@ -802,7 +844,7 @@ copy_done: - /* When live dump-mode (-L option) is specified, - * guest domain may reduce memory. pad with zero pages. - */ -- IPRINTF("j (%ld) != nr_pages (%ld)", j , nr_pages); -+ IPRINTF("j (%ld) != nr_pages (%ld)", j, nr_pages); - memset(dump_mem_start, 0, PAGE_SIZE); - for (; j < nr_pages; j++) { - sts = dump_rtn(args, dump_mem_start, PAGE_SIZE); -@@ -891,7 +933,7 @@ xc_domain_dumpcore(int xc_handle, - struct dump_args da; - int sts; - -- if ( (da.fd = open(corename, O_CREAT|O_RDWR, S_IWUSR|S_IRUSR)) < 0 ) -+ if ( (da.fd = open(corename, O_CREAT|O_RDWR|O_TRUNC, S_IWUSR|S_IRUSR)) < 0 ) - { - PERROR("Could not open corefile %s", corename); - return -errno; -Index: xen-3.3.1-testing/tools/libxc/xc_core.h -=================================================================== ---- xen-3.3.1-testing.orig/tools/libxc/xc_core.h -+++ xen-3.3.1-testing/tools/libxc/xc_core.h -@@ -136,12 +136,12 @@ int xc_core_arch_auto_translated_physmap - struct xc_core_arch_context; - int xc_core_arch_memory_map_get(int xc_handle, - struct xc_core_arch_context *arch_ctxt, -- xc_dominfo_t *info, shared_info_t *live_shinfo, -+ xc_dominfo_t *info, shared_info_any_t *live_shinfo, - xc_core_memory_map_t **mapp, - unsigned int *nr_entries); --int xc_core_arch_map_p2m(int xc_handle, xc_dominfo_t *info, -- shared_info_t *live_shinfo, xen_pfn_t **live_p2m, -- unsigned long *pfnp); -+int xc_core_arch_map_p2m(int xc_handle, unsigned int guest_width, -+ xc_dominfo_t *info, shared_info_any_t *live_shinfo, -+ xen_pfn_t **live_p2m, unsigned long *pfnp); - - - #if defined (__i386__) || defined (__x86_64__) -Index: xen-3.3.1-testing/tools/libxc/xc_core_ia64.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/libxc/xc_core_ia64.c -+++ xen-3.3.1-testing/tools/libxc/xc_core_ia64.c -@@ -270,7 +270,7 @@ old: - } - - int --xc_core_arch_map_p2m(int xc_handle, xc_dominfo_t *info, -+xc_core_arch_map_p2m(int xc_handle, unsigned int guest_width, xc_dominfo_t *info, - shared_info_t *live_shinfo, xen_pfn_t **live_p2m, - unsigned long *pfnp) - { -Index: xen-3.3.1-testing/tools/libxc/xc_core_x86.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/libxc/xc_core_x86.c -+++ xen-3.3.1-testing/tools/libxc/xc_core_x86.c -@@ -20,9 +20,25 @@ - - #include "xg_private.h" - #include "xc_core.h" -+#include "xc_e820.h" -+ -+#define GET_FIELD(_p, _f) ((guest_width==8) ? ((_p)->x64._f) : ((_p)->x32._f)) -+ -+#ifndef MAX -+#define MAX(_a, _b) ((_a) >= (_b) ? (_a) : (_b)) -+#endif -+ -+int -+xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt, -+ unsigned long pfn) -+{ -+ if ((pfn >= 0xa0 && pfn < 0xc0) /* VGA hole */ -+ || (pfn >= (HVM_BELOW_4G_MMIO_START >> PAGE_SHIFT) -+ && pfn < (1ULL<<32) >> PAGE_SHIFT)) /* MMIO */ -+ return 0; -+ return 1; -+} - --/* Don't yet support cross-address-size core dump */ --#define guest_width (sizeof (unsigned long)) - - static int nr_gpfns(int xc_handle, domid_t domid) - { -@@ -37,7 +53,7 @@ xc_core_arch_auto_translated_physmap(con - - int - xc_core_arch_memory_map_get(int xc_handle, struct xc_core_arch_context *unused, -- xc_dominfo_t *info, shared_info_t *live_shinfo, -+ xc_dominfo_t *info, shared_info_any_t *live_shinfo, - xc_core_memory_map_t **mapp, - unsigned int *nr_entries) - { -@@ -60,17 +76,22 @@ xc_core_arch_memory_map_get(int xc_handl - } - - int --xc_core_arch_map_p2m(int xc_handle, xc_dominfo_t *info, -- shared_info_t *live_shinfo, xen_pfn_t **live_p2m, -+xc_core_arch_map_p2m(int xc_handle, unsigned int guest_width, xc_dominfo_t *info, -+ shared_info_any_t *live_shinfo, xen_pfn_t **live_p2m, - unsigned long *pfnp) - { - /* Double and single indirect references to the live P2M table */ - xen_pfn_t *live_p2m_frame_list_list = NULL; - xen_pfn_t *live_p2m_frame_list = NULL; -+ /* Copies of the above. */ -+ xen_pfn_t *p2m_frame_list_list = NULL; -+ xen_pfn_t *p2m_frame_list = NULL; -+ - uint32_t dom = info->domid; - unsigned long p2m_size = nr_gpfns(xc_handle, info->domid); - int ret = -1; - int err; -+ int i; - - if ( p2m_size < info->nr_pages ) - { -@@ -80,7 +101,7 @@ xc_core_arch_map_p2m(int xc_handle, xc_d - - live_p2m_frame_list_list = - xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ, -- live_shinfo->arch.pfn_to_mfn_frame_list_list); -+ GET_FIELD(live_shinfo, arch.pfn_to_mfn_frame_list_list)); - - if ( !live_p2m_frame_list_list ) - { -@@ -88,9 +109,28 @@ xc_core_arch_map_p2m(int xc_handle, xc_d - goto out; - } - -+ /* Get a local copy of the live_P2M_frame_list_list */ -+ if ( !(p2m_frame_list_list = malloc(PAGE_SIZE)) ) -+ { -+ ERROR("Couldn't allocate p2m_frame_list_list array"); -+ goto out; -+ } -+ memcpy(p2m_frame_list_list, live_p2m_frame_list_list, PAGE_SIZE); -+ -+ /* Canonicalize guest's unsigned long vs ours */ -+ if ( guest_width > sizeof(unsigned long) ) -+ for ( i = 0; i < PAGE_SIZE/sizeof(unsigned long); i++ ) -+ if ( i < PAGE_SIZE/guest_width ) -+ p2m_frame_list_list[i] = ((uint64_t *)p2m_frame_list_list)[i]; -+ else -+ p2m_frame_list_list[i] = 0; -+ else if ( guest_width < sizeof(unsigned long) ) -+ for ( i = PAGE_SIZE/sizeof(unsigned long) - 1; i >= 0; i-- ) -+ p2m_frame_list_list[i] = ((uint32_t *)p2m_frame_list_list)[i]; -+ - live_p2m_frame_list = - xc_map_foreign_pages(xc_handle, dom, PROT_READ, -- live_p2m_frame_list_list, -+ p2m_frame_list_list, - P2M_FLL_ENTRIES); - - if ( !live_p2m_frame_list ) -@@ -99,8 +139,25 @@ xc_core_arch_map_p2m(int xc_handle, xc_d - goto out; - } - -+ /* Get a local copy of the live_P2M_frame_list */ -+ if ( !(p2m_frame_list = malloc(P2M_TOOLS_FL_SIZE)) ) -+ { -+ ERROR("Couldn't allocate p2m_frame_list array"); -+ goto out; -+ } -+ memset(p2m_frame_list, 0, P2M_TOOLS_FL_SIZE); -+ memcpy(p2m_frame_list, live_p2m_frame_list, P2M_GUEST_FL_SIZE); -+ -+ /* Canonicalize guest's unsigned long vs ours */ -+ if ( guest_width > sizeof(unsigned long) ) -+ for ( i = 0; i < P2M_FL_ENTRIES; i++ ) -+ p2m_frame_list[i] = ((uint64_t *)p2m_frame_list)[i]; -+ else if ( guest_width < sizeof(unsigned long) ) -+ for ( i = P2M_FL_ENTRIES - 1; i >= 0; i-- ) -+ p2m_frame_list[i] = ((uint32_t *)p2m_frame_list)[i]; -+ - *live_p2m = xc_map_foreign_pages(xc_handle, dom, PROT_READ, -- live_p2m_frame_list, -+ p2m_frame_list, - P2M_FL_ENTRIES); - - if ( !*live_p2m ) -@@ -122,6 +179,12 @@ out: - if ( live_p2m_frame_list ) - munmap(live_p2m_frame_list, P2M_FLL_ENTRIES * PAGE_SIZE); - -+ if ( p2m_frame_list_list ) -+ free(p2m_frame_list_list); -+ -+ if ( p2m_frame_list ) -+ free(p2m_frame_list); -+ - errno = err; - return ret; - } -Index: xen-3.3.1-testing/tools/libxc/xc_core_x86.h -=================================================================== ---- xen-3.3.1-testing.orig/tools/libxc/xc_core_x86.h -+++ xen-3.3.1-testing/tools/libxc/xc_core_x86.h -@@ -21,15 +21,8 @@ - #ifndef XC_CORE_X86_H - #define XC_CORE_X86_H - --#if defined(__i386__) || defined(__x86_64__) - #define ELF_ARCH_DATA ELFDATA2LSB --#if defined (__i386__) --# define ELF_ARCH_MACHINE EM_386 --#else --# define ELF_ARCH_MACHINE EM_X86_64 --#endif --#endif /* __i386__ or __x86_64__ */ -- -+#define ELF_ARCH_MACHINE (guest_width == 8 ? EM_X86_64 : EM_386) - - struct xc_core_arch_context { - /* nothing */ -@@ -40,8 +33,10 @@ struct xc_core_arch_context { - #define xc_core_arch_context_get(arch_ctxt, ctxt, xc_handle, domid) \ - (0) - #define xc_core_arch_context_dump(arch_ctxt, args, dump_rtn) (0) --#define xc_core_arch_gpfn_may_present(arch_ctxt, i) (1) - -+int -+xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt, -+ unsigned long pfn); - static inline int - xc_core_arch_context_get_shdr(struct xc_core_arch_context *arch_ctxt, - struct xc_core_section_headers *sheaders, diff --git a/19048-cross-bit-coredumping.patch b/19048-cross-bit-coredumping.patch deleted file mode 100644 index 2aeefc6..0000000 --- a/19048-cross-bit-coredumping.patch +++ /dev/null @@ -1,37 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1232023248 0 -# Node ID 04f913ab2049bd0d8f13cdd72a487376d3909f87 -# Parent e98032a016d62c4ee09bb59ab9e0987c2563804a -dump-core: update the documentation - -Signed-off-by: Isaku Yamahata - -Index: xen-3.3.1-testing/docs/misc/dump-core-format.txt -=================================================================== ---- xen-3.3.1-testing.orig/docs/misc/dump-core-format.txt -+++ xen-3.3.1-testing/docs/misc/dump-core-format.txt -@@ -30,8 +30,13 @@ The elf header members are set as follow - e_ident[EI_OSABI] = ELFOSABI_SYSV = 0 - e_type = ET_CORE = 4 - ELFCLASS64 is always used independent of architecture. --e_ident[EI_DATA] and e_flags are set according to the dumping system's --architecture. Other members are set as usual. -+e_ident[EI_DATA] is set as follows -+ For x86 PV domain case, it is set according to the guest configuration -+ (i.e. if guest is 32bit it is set to EM_386 even when the dom0 is 64 bit.) -+ For other domain case (x86 HVM domain case and ia64 domain case), -+ it is set according to the dumping system's architecture. -+e_flags is set according to the dumping system's architecture. -+Other members are set as usual. - - Sections - -------- -@@ -241,3 +246,7 @@ Currently only (major, minor) = (0, 1) i - The format version isn't bumped because analysis tools can distinguish it. - - .xen_ia64_mapped_regs section was made only for ia64 PV domain. - In case of IA64 HVM domain, this section doesn't exist. -+- elf header e_ident[EI_DATA] -+ On x86 PV domain case, it is set according to the guest configuration. -+ I.e. 32-on-64 case, the file will be set EM_386 instead of EM_X86_64. -+ This is the same as 32-on-32 case, so there is no impact on analysis tools. diff --git a/19051-cross-bit-coredumping.patch b/19051-cross-bit-coredumping.patch deleted file mode 100644 index 6f5c345..0000000 --- a/19051-cross-bit-coredumping.patch +++ /dev/null @@ -1,24 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1232106411 0 -# Node ID 71e0b8adeb1f71d0055fabba0e97a4bdbf594c72 -# Parent 40d9d9ff435afee74431102e4e1ac6c7542649bd -ptrace_core: Handle FV cross-bitness. - -Signed-off-by: Bruce Rogers - -Index: xen-3.3.1-testing/tools/libxc/xc_ptrace_core.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/libxc/xc_ptrace_core.c -+++ xen-3.3.1-testing/tools/libxc/xc_ptrace_core.c -@@ -540,7 +540,9 @@ xc_waitdomain_core_elf( - XEN_ELFNOTE_DUMPCORE_XEN_VERSION, - (void**)&xen_version) < 0) - goto out; -- if (xen_version->xen_version.pagesize != PAGE_SIZE) -+ /* shifted case covers 32 bit FV guest core file created on 64 bit Dom0 */ -+ if (xen_version->xen_version.pagesize != PAGE_SIZE && -+ (xen_version->xen_version.pagesize >> 32) != PAGE_SIZE) - goto out; - - /* .note.Xen: format_version */ diff --git a/19072-vmx-pat.patch b/19072-vmx-pat.patch deleted file mode 100644 index e4e9900..0000000 --- a/19072-vmx-pat.patch +++ /dev/null @@ -1,148 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1232623303 0 -# Node ID d52921c18c3d0171bccb4651cca8412f2fff2dd9 -# Parent 9f9ba1a7cc924fbc547e05ea21071becafe5e2c2 -vmx: utilise the GUEST_PAT and HOST_PAT vmcs area - -Signed-off-by: Xin Li -Signed-off-by: Xiaohui Xin - ---- a/xen/arch/x86/hvm/vmx/vmcs.c -+++ b/xen/arch/x86/hvm/vmx/vmcs.c -@@ -166,14 +166,15 @@ static void vmx_init_vmcs_config(void) - #endif - - min = VM_EXIT_ACK_INTR_ON_EXIT; -- opt = 0; -+ opt = VM_EXIT_SAVE_GUEST_PAT | VM_EXIT_LOAD_HOST_PAT; - #ifdef __x86_64__ - min |= VM_EXIT_IA32E_MODE; - #endif - _vmx_vmexit_control = adjust_vmx_controls( - min, opt, MSR_IA32_VMX_EXIT_CTLS); - -- min = opt = 0; -+ min = 0; -+ opt = VM_ENTRY_LOAD_GUEST_PAT; - _vmx_vmentry_control = adjust_vmx_controls( - min, opt, MSR_IA32_VMX_ENTRY_CTLS); - -@@ -518,8 +519,6 @@ static int construct_vmcs(struct vcpu *v - - /* VMCS controls. */ - __vmwrite(PIN_BASED_VM_EXEC_CONTROL, vmx_pin_based_exec_control); -- __vmwrite(VM_EXIT_CONTROLS, vmx_vmexit_control); -- __vmwrite(VM_ENTRY_CONTROLS, vmx_vmentry_control); - - v->arch.hvm_vmx.exec_control = vmx_cpu_based_exec_control; - v->arch.hvm_vmx.secondary_exec_control = vmx_secondary_exec_control; -@@ -533,9 +532,15 @@ static int construct_vmcs(struct vcpu *v - else - { - v->arch.hvm_vmx.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_EPT; -+ vmx_vmexit_control &= ~(VM_EXIT_SAVE_GUEST_PAT | -+ VM_EXIT_LOAD_HOST_PAT); -+ vmx_vmentry_control &= ~VM_ENTRY_LOAD_GUEST_PAT; - } - - __vmwrite(CPU_BASED_VM_EXEC_CONTROL, v->arch.hvm_vmx.exec_control); -+ __vmwrite(VM_EXIT_CONTROLS, vmx_vmexit_control); -+ __vmwrite(VM_ENTRY_CONTROLS, vmx_vmentry_control); -+ - if ( cpu_has_vmx_secondary_exec_control ) - __vmwrite(SECONDARY_VM_EXEC_CONTROL, - v->arch.hvm_vmx.secondary_exec_control); -@@ -557,6 +562,8 @@ static int construct_vmcs(struct vcpu *v - vmx_disable_intercept_for_msr(v, MSR_IA32_SYSENTER_CS); - vmx_disable_intercept_for_msr(v, MSR_IA32_SYSENTER_ESP); - vmx_disable_intercept_for_msr(v, MSR_IA32_SYSENTER_EIP); -+ if ( cpu_has_vmx_pat && paging_mode_hap(d) ) -+ vmx_disable_intercept_for_msr(v, MSR_IA32_CR_PAT); - } - - /* I/O access bitmap. */ -@@ -688,6 +695,21 @@ static int construct_vmcs(struct vcpu *v - __vmwrite(VIRTUAL_PROCESSOR_ID, v->arch.hvm_vmx.vpid); - } - -+ if ( cpu_has_vmx_pat && paging_mode_hap(d) ) -+ { -+ u64 host_pat, guest_pat; -+ -+ rdmsrl(MSR_IA32_CR_PAT, host_pat); -+ guest_pat = 0x7040600070406ULL; -+ -+ __vmwrite(HOST_PAT, host_pat); -+ __vmwrite(GUEST_PAT, guest_pat); -+#ifdef __i386__ -+ __vmwrite(HOST_PAT_HIGH, host_pat >> 32); -+ __vmwrite(GUEST_PAT_HIGH, guest_pat >> 32); -+#endif -+ } -+ - vmx_vmcs_exit(v); - - paging_update_paging_modes(v); /* will update HOST & GUEST_CR3 as reqd */ -@@ -968,6 +990,8 @@ void vmcs_dump_vcpu(struct vcpu *v) - vmx_dump_sel("LDTR", x86_seg_ldtr); - vmx_dump_sel("IDTR", x86_seg_idtr); - vmx_dump_sel("TR", x86_seg_tr); -+ printk("Guest PAT = 0x%08x%08x\n", -+ (uint32_t)vmr(GUEST_PAT_HIGH), (uint32_t)vmr(GUEST_PAT)); - x = (unsigned long long)vmr(TSC_OFFSET_HIGH) << 32; - x |= (uint32_t)vmr(TSC_OFFSET); - printk("TSC Offset = %016llx\n", x); -@@ -1006,6 +1030,8 @@ void vmcs_dump_vcpu(struct vcpu *v) - (unsigned long long)vmr(HOST_SYSENTER_ESP), - (int)vmr(HOST_SYSENTER_CS), - (unsigned long long)vmr(HOST_SYSENTER_EIP)); -+ printk("Host PAT = 0x%08x%08x\n", -+ (uint32_t)vmr(HOST_PAT_HIGH), (uint32_t)vmr(HOST_PAT)); - - printk("*** Control State ***\n"); - printk("PinBased=%08x CPUBased=%08x SecondaryExec=%08x\n", ---- a/xen/include/asm-x86/hvm/vmx/vmcs.h -+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h -@@ -150,11 +150,14 @@ extern u32 vmx_pin_based_exec_control; - - #define VM_EXIT_IA32E_MODE 0x00000200 - #define VM_EXIT_ACK_INTR_ON_EXIT 0x00008000 -+#define VM_EXIT_SAVE_GUEST_PAT 0x00040000 -+#define VM_EXIT_LOAD_HOST_PAT 0x00080000 - extern u32 vmx_vmexit_control; - - #define VM_ENTRY_IA32E_MODE 0x00000200 - #define VM_ENTRY_SMM 0x00000400 - #define VM_ENTRY_DEACT_DUAL_MONITOR 0x00000800 -+#define VM_ENTRY_LOAD_GUEST_PAT 0x00004000 - extern u32 vmx_vmentry_control; - - #define SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES 0x00000001 -@@ -181,6 +184,8 @@ extern bool_t cpu_has_vmx_ins_outs_instr - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT) - #define cpu_has_vmx_vpid \ - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VPID) -+#define cpu_has_vmx_pat \ -+ (vmx_vmentry_control & VM_ENTRY_LOAD_GUEST_PAT) - - /* GUEST_INTERRUPTIBILITY_INFO flags. */ - #define VMX_INTR_SHADOW_STI 0x00000001 -@@ -232,6 +237,8 @@ enum vmcs_field { - VMCS_LINK_POINTER_HIGH = 0x00002801, - GUEST_IA32_DEBUGCTL = 0x00002802, - GUEST_IA32_DEBUGCTL_HIGH = 0x00002803, -+ GUEST_PAT = 0x00002804, -+ GUEST_PAT_HIGH = 0x00002805, - GUEST_PDPTR0 = 0x0000280a, - GUEST_PDPTR0_HIGH = 0x0000280b, - GUEST_PDPTR1 = 0x0000280c, -@@ -240,6 +247,8 @@ enum vmcs_field { - GUEST_PDPTR2_HIGH = 0x0000280f, - GUEST_PDPTR3 = 0x00002810, - GUEST_PDPTR3_HIGH = 0x00002811, -+ HOST_PAT = 0x00002c00, -+ HOST_PAT_HIGH = 0x00002c01, - PIN_BASED_VM_EXEC_CONTROL = 0x00004000, - CPU_BASED_VM_EXEC_CONTROL = 0x00004002, - EXCEPTION_BITMAP = 0x00004004, diff --git a/19079-snp_ctl-1.patch b/19079-snp_ctl-1.patch deleted file mode 100644 index 94b0ca4..0000000 --- a/19079-snp_ctl-1.patch +++ /dev/null @@ -1,315 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1232721749 0 -# Node ID 175a425e9b55e63c240b0a2ad61f5ed251e85ead -# Parent f3240cd3cd2b9d48acf3d82caa2ca1cab1f66325 -EPT/VT-d: Enhance MTRR/PAT virtualization when EPT/VT-d both enabled - -Set effective memory type for EPT according to the VT-d snoop control -capability, and also includes some cleanups for EPT & VT-d both enabled. - -Signed-off-by: Edwin Zhai -Signed-off-by: Xiaohui Xin - ---- a/xen/arch/x86/hvm/mtrr.c -+++ b/xen/arch/x86/hvm/mtrr.c -@@ -702,12 +702,15 @@ HVM_REGISTER_SAVE_RESTORE(MTRR, hvm_save - 1, HVMSR_PER_VCPU); - - uint8_t epte_get_entry_emt( -- struct domain *d, unsigned long gfn, unsigned long mfn) -+ struct domain *d, unsigned long gfn, -+ unsigned long mfn, uint8_t *igmt, int direct_mmio) - { - uint8_t gmtrr_mtype, hmtrr_mtype; - uint32_t type; - struct vcpu *v = current; - -+ *igmt = 0; -+ - if ( (current->domain != d) && ((v = d->vcpu[0]) == NULL) ) - return MTRR_TYPE_WRBACK; - -@@ -723,6 +726,21 @@ uint8_t epte_get_entry_emt( - if ( hvm_get_mem_pinned_cacheattr(d, gfn, &type) ) - return type; - -+ if ( !iommu_enabled ) -+ { -+ *igmt = 1; -+ return MTRR_TYPE_WRBACK; -+ } -+ -+ if ( direct_mmio ) -+ return MTRR_TYPE_UNCACHABLE; -+ -+ if ( iommu_snoop ) -+ { -+ *igmt = 1; -+ return MTRR_TYPE_WRBACK; -+ } -+ - gmtrr_mtype = get_mtrr_type(&v->arch.hvm_vcpu.mtrr, (gfn << PAGE_SHIFT)); - hmtrr_mtype = get_mtrr_type(&mtrr_state, (mfn << PAGE_SHIFT)); - return ((gmtrr_mtype <= hmtrr_mtype) ? gmtrr_mtype : hmtrr_mtype); ---- a/xen/arch/x86/mm/hap/p2m-ept.c -+++ b/xen/arch/x86/mm/hap/p2m-ept.c -@@ -66,6 +66,7 @@ static int ept_set_middle_entry(struct d - list_add_tail(&pg->list, &d->arch.p2m->pages); - - ept_entry->emt = 0; -+ ept_entry->igmt = 0; - ept_entry->sp_avail = 0; - ept_entry->avail1 = 0; - ept_entry->mfn = page_to_mfn(pg); -@@ -114,9 +115,13 @@ static int ept_next_level(struct domain - } - } - -+/* -+ * TODO: ept_set_entry() computes 'need_modify_vtd_table' for itself, -+ * by observing whether any gfn->mfn translations are modified. -+ */ - static int --ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn, -- unsigned int order, p2m_type_t p2mt) -+_ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn, -+ unsigned int order, p2m_type_t p2mt, int need_modify_vtd_table) - { - ept_entry_t *table = NULL; - unsigned long gfn_remainder = gfn, offset = 0; -@@ -124,6 +129,8 @@ ept_set_entry(struct domain *d, unsigned - u32 index; - int i, rv = 0, ret = 0; - int walk_level = order / EPT_TABLE_ORDER; -+ int direct_mmio = (p2mt == p2m_mmio_direct); -+ uint8_t igmt = 0; - - /* we only support 4k and 2m pages now */ - -@@ -157,7 +164,9 @@ ept_set_entry(struct domain *d, unsigned - { - if ( mfn_valid(mfn_x(mfn)) || (p2mt == p2m_mmio_direct) ) - { -- ept_entry->emt = epte_get_entry_emt(d, gfn, mfn_x(mfn)); -+ ept_entry->emt = epte_get_entry_emt(d, gfn, mfn_x(mfn), -+ &igmt, direct_mmio); -+ ept_entry->igmt = igmt; - ept_entry->sp_avail = walk_level ? 1 : 0; - - if ( ret == GUEST_TABLE_SUPER_PAGE ) -@@ -208,7 +217,10 @@ ept_set_entry(struct domain *d, unsigned - { - split_ept_entry = split_table + i; - split_ept_entry->emt = epte_get_entry_emt(d, -- gfn-offset+i, split_mfn+i); -+ gfn-offset+i, split_mfn+i, -+ &igmt, direct_mmio); -+ split_ept_entry->igmt = igmt; -+ - split_ept_entry->sp_avail = 0; - - split_ept_entry->mfn = split_mfn+i; -@@ -223,7 +235,10 @@ ept_set_entry(struct domain *d, unsigned - - /* Set the destinated 4k page as normal */ - split_ept_entry = split_table + offset; -- split_ept_entry->emt = epte_get_entry_emt(d, gfn, mfn_x(mfn)); -+ split_ept_entry->emt = epte_get_entry_emt(d, gfn, mfn_x(mfn), -+ &igmt, direct_mmio); -+ split_ept_entry->igmt = igmt; -+ - split_ept_entry->mfn = mfn_x(mfn); - split_ept_entry->avail1 = p2mt; - ept_p2m_type_to_flags(split_ept_entry, p2mt); -@@ -246,7 +261,8 @@ out: - - /* Now the p2m table is not shared with vt-d page table */ - -- if ( iommu_enabled && is_hvm_domain(d) ) -+ if ( iommu_enabled && is_hvm_domain(d) -+ && need_modify_vtd_table ) - { - if ( p2mt == p2m_ram_rw ) - { -@@ -273,6 +289,17 @@ out: - return rv; - } - -+static int -+ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn, -+ unsigned int order, p2m_type_t p2mt) -+{ -+ /* ept_set_entry() are called from set_entry(), -+ * We should always create VT-d page table acording -+ * to the gfn to mfn translations changes. -+ */ -+ return _ept_set_entry(d, gfn, mfn, order, p2mt, 1); -+} -+ - /* Read ept p2m entries */ - static mfn_t ept_get_entry(struct domain *d, unsigned long gfn, p2m_type_t *t) - { -@@ -393,18 +420,30 @@ void ept_change_entry_emt_with_range(str - * Set emt for super page. - */ - order = EPT_TABLE_ORDER; -- ept_set_entry(d, gfn, _mfn(mfn), order, p2mt); -+ /* vmx_set_uc_mode() dont' touch the gfn to mfn -+ * translations, only modify the emt field of the EPT entries. -+ * so we need not modify the current VT-d page tables. -+ */ -+ _ept_set_entry(d, gfn, _mfn(mfn), order, p2mt, 0); - gfn += 0x1FF; - } - else - { -- /* change emt for partial entries of the 2m area */ -- ept_set_entry(d, gfn, _mfn(mfn), order, p2mt); -+ /* 1)change emt for partial entries of the 2m area. -+ * 2)vmx_set_uc_mode() dont' touch the gfn to mfn -+ * translations, only modify the emt field of the EPT entries. -+ * so we need not modify the current VT-d page tables. -+ */ -+ _ept_set_entry(d, gfn, _mfn(mfn), order, p2mt,0); - gfn = ((gfn >> EPT_TABLE_ORDER) << EPT_TABLE_ORDER) + 0x1FF; - } - } -- else /* gfn assigned with 4k */ -- ept_set_entry(d, gfn, _mfn(mfn), order, p2mt); -+ else /* 1)gfn assigned with 4k -+ * 2)vmx_set_uc_mode() dont' touch the gfn to mfn -+ * translations, only modify the emt field of the EPT entries. -+ * so we need not modify the current VT-d page tables. -+ */ -+ _ept_set_entry(d, gfn, _mfn(mfn), order, p2mt, 0); - } - } - ---- a/xen/drivers/passthrough/iommu.c -+++ b/xen/drivers/passthrough/iommu.c -@@ -40,6 +40,7 @@ int iommu_enabled = 0; - int iommu_pv_enabled = 0; - int force_iommu = 0; - int iommu_passthrough = 0; -+int iommu_snoop = 0; - - static void __init parse_iommu_param(char *s) - { ---- a/xen/drivers/passthrough/vtd/dmar.c -+++ b/xen/drivers/passthrough/vtd/dmar.c -@@ -29,6 +29,7 @@ - #include - #include - #include "dmar.h" -+#include "iommu.h" - - int vtd_enabled = 1; - -@@ -508,6 +509,8 @@ static int __init acpi_parse_dmar(struct - int acpi_dmar_init(void) - { - int rc; -+ struct acpi_drhd_unit *drhd; -+ struct iommu *iommu; - - rc = -ENODEV; - if ( force_iommu ) -@@ -524,7 +527,20 @@ int acpi_dmar_init(void) - if ( list_empty(&acpi_drhd_units) ) - goto fail; - -- printk("Intel VT-d has been enabled\n"); -+ /* Giving that all devices within guest use same io page table, -+ * enable snoop control only if all VT-d engines support it. -+ */ -+ iommu_snoop = 1; -+ for_each_drhd_unit ( drhd ) -+ { -+ iommu = drhd->iommu; -+ if ( !ecap_snp_ctl(iommu->ecap) ) { -+ iommu_snoop = 0; -+ break; -+ } -+ } -+ -+ printk("Intel VT-d has been enabled, snoop_control=%d.\n", iommu_snoop); - - return 0; - ---- a/xen/drivers/passthrough/vtd/iommu.c -+++ b/xen/drivers/passthrough/vtd/iommu.c -@@ -1495,6 +1495,11 @@ int intel_iommu_map_page( - pte_present = dma_pte_present(*pte); - dma_set_pte_addr(*pte, (paddr_t)mfn << PAGE_SHIFT_4K); - dma_set_pte_prot(*pte, DMA_PTE_READ | DMA_PTE_WRITE); -+ -+ /* Set the SNP on leaf page table if Snoop Control available */ -+ if ( iommu_snoop ) -+ dma_set_pte_snp(*pte); -+ - iommu_flush_cache_entry(pte); - unmap_vtd_domain_page(page); - ---- a/xen/drivers/passthrough/vtd/iommu.h -+++ b/xen/drivers/passthrough/vtd/iommu.h -@@ -104,6 +104,7 @@ - #define ecap_ext_intr(e) ((e >> 4) & 0x1) - #define ecap_cache_hints(e) ((e >> 5) & 0x1) - #define ecap_pass_thru(e) ((e >> 6) & 0x1) -+#define ecap_snp_ctl(e) ((e >> 7) & 0x1) - - /* IOTLB_REG */ - #define DMA_TLB_FLUSH_GRANU_OFFSET 60 -@@ -260,10 +261,12 @@ struct dma_pte { - }; - #define DMA_PTE_READ (1) - #define DMA_PTE_WRITE (2) -+#define DMA_PTE_SNP (1 << 11) - #define dma_clear_pte(p) do {(p).val = 0;} while(0) - #define dma_set_pte_readable(p) do {(p).val |= DMA_PTE_READ;} while(0) - #define dma_set_pte_writable(p) do {(p).val |= DMA_PTE_WRITE;} while(0) - #define dma_set_pte_superpage(p) do {(p).val |= (1 << 7);} while(0) -+#define dma_set_pte_snp(p) do {(p).val |= DMA_PTE_SNP;} while(0) - #define dma_set_pte_prot(p, prot) \ - do {(p).val = ((p).val & ~3) | ((prot) & 3); } while (0) - #define dma_pte_addr(p) ((p).val & PAGE_MASK_4K) ---- a/xen/include/asm-x86/hvm/vmx/vmx.h -+++ b/xen/include/asm-x86/hvm/vmx/vmx.h -@@ -33,7 +33,8 @@ typedef union { - u64 r : 1, - w : 1, - x : 1, -- emt : 4, -+ emt : 3, -+ igmt : 1, - sp_avail : 1, - avail1 : 4, - mfn : 45, ---- a/xen/include/asm-x86/mtrr.h -+++ b/xen/include/asm-x86/mtrr.h -@@ -64,9 +64,11 @@ extern int mtrr_del_page(int reg, unsign - extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi); - extern u32 get_pat_flags(struct vcpu *v, u32 gl1e_flags, paddr_t gpaddr, - paddr_t spaddr); --extern uint8_t epte_get_entry_emt(struct domain *d, unsigned long gfn, unsigned long mfn); --extern void ept_change_entry_emt_with_range(struct domain *d, unsigned long start_gfn, -- unsigned long end_gfn); -+extern uint8_t epte_get_entry_emt( -+ struct domain *d, unsigned long gfn, unsigned long mfn, -+ uint8_t *igmt, int direct_mmio); -+extern void ept_change_entry_emt_with_range( -+ struct domain *d, unsigned long start_gfn, unsigned long end_gfn); - extern unsigned char pat_type_2_pte_flags(unsigned char pat_type); - - #endif /* __ASM_X86_MTRR_H__ */ ---- a/xen/include/xen/iommu.h -+++ b/xen/include/xen/iommu.h -@@ -32,6 +32,7 @@ extern int iommu_enabled; - extern int iommu_pv_enabled; - extern int force_iommu; - extern int iommu_passthrough; -+extern int iommu_snoop; - - #define domain_hvm_iommu(d) (&d->arch.hvm_domain.hvm_iommu) - diff --git a/19088-x86-page-non-atomic-owner.patch b/19088-x86-page-non-atomic-owner.patch deleted file mode 100644 index 783d85e..0000000 --- a/19088-x86-page-non-atomic-owner.patch +++ /dev/null @@ -1,146 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1232981779 0 -# Node ID 055c589f4791811797867736857b08fdd0fd6d49 -# Parent c9dc7dcacc1d0c064a131da98a4063fa2cedd716 -x86: No need for CMPXCHG8B on page_info structure. -References: bnc#470949 - -Updates and checks on count_info and page owner can safely be -non-atomic. - -Signed-off-by: Keir Fraser - ---- a/xen/arch/x86/mm.c -+++ b/xen/arch/x86/mm.c -@@ -1887,36 +1887,29 @@ void put_page(struct page_info *page) - - int get_page(struct page_info *page, struct domain *domain) - { -- u32 x, nx, y = page->count_info; -- u32 d, nd = page->u.inuse._domain; -- u32 _domain = pickle_domptr(domain); -+ u32 x, y = page->count_info; - - do { -- x = y; -- nx = x + 1; -- d = nd; -+ x = y; - if ( unlikely((x & PGC_count_mask) == 0) || /* Not allocated? */ - /* Keep one spare reference to be acquired by get_page_light(). */ -- unlikely(((nx + 1) & PGC_count_mask) <= 1) || /* Overflow? */ -- unlikely(d != _domain) ) /* Wrong owner? */ -- { -- if ( !_shadow_mode_refcounts(domain) && !domain->is_dying ) -- gdprintk(XENLOG_INFO, -- "Error pfn %lx: rd=%p, od=%p, caf=%08x, taf=%" -- PRtype_info "\n", -- page_to_mfn(page), domain, unpickle_domptr(d), -- x, page->u.inuse.type_info); -- return 0; -- } -- asm volatile ( -- LOCK_PREFIX "cmpxchg8b %2" -- : "=d" (nd), "=a" (y), -- "=m" (*(volatile u64 *)(&page->count_info)) -- : "0" (d), "1" (x), "c" (d), "b" (nx) ); -+ unlikely(((x + 2) & PGC_count_mask) <= 1) ) /* Overflow? */ -+ goto fail; - } -- while ( unlikely(nd != d) || unlikely(y != x) ); -+ while ( (y = cmpxchg(&page->count_info, x, x + 1)) != x ); - -- return 1; -+ if ( likely(page_get_owner(page) == domain) ) -+ return 1; -+ -+ put_page(page); -+ -+ fail: -+ if ( !_shadow_mode_refcounts(domain) && !domain->is_dying ) -+ gdprintk(XENLOG_INFO, -+ "Error pfn %lx: rd=%p, od=%p, caf=%08x, taf=%" PRtype_info, -+ page_to_mfn(page), domain, page_get_owner(page), -+ y, page->u.inuse.type_info); -+ return 0; - } - - /* -@@ -3438,49 +3431,47 @@ int replace_grant_host_mapping( - int steal_page( - struct domain *d, struct page_info *page, unsigned int memflags) - { -- u32 _d, _nd, x, y; -+ u32 x, y; - - spin_lock(&d->page_alloc_lock); - -+ if ( is_xen_heap_page(page) || (page_get_owner(page) != d) ) -+ goto fail; -+ - /* -- * The tricky bit: atomically release ownership while there is just one -- * benign reference to the page (PGC_allocated). If that reference -- * disappears then the deallocation routine will safely spin. -+ * We require there is just one reference (PGC_allocated). We temporarily -+ * drop this reference now so that we can safely swizzle the owner. - */ -- _d = pickle_domptr(d); -- _nd = page->u.inuse._domain; -- y = page->count_info; -+ y = page->count_info; - do { - x = y; -- if ( unlikely((x & (PGC_count_mask|PGC_allocated)) != -- (1 | PGC_allocated)) || unlikely(_nd != _d) ) -- { -- MEM_LOG("gnttab_transfer: Bad page %p: ed=%p(%u), sd=%p," -- " caf=%08x, taf=%" PRtype_info "\n", -- (void *) page_to_mfn(page), -- d, d->domain_id, unpickle_domptr(_nd), x, -- page->u.inuse.type_info); -- spin_unlock(&d->page_alloc_lock); -- return -1; -- } -- asm volatile ( -- LOCK_PREFIX "cmpxchg8b %2" -- : "=d" (_nd), "=a" (y), -- "=m" (*(volatile u64 *)(&page->count_info)) -- : "0" (_d), "1" (x), "c" (NULL), "b" (x) ); -- } while (unlikely(_nd != _d) || unlikely(y != x)); -+ if ( (x & (PGC_count_mask|PGC_allocated)) != (1 | PGC_allocated) ) -+ goto fail; -+ y = cmpxchg(&page->count_info, x, x & ~PGC_count_mask); -+ } while ( y != x ); - -- /* -- * Unlink from 'd'. At least one reference remains (now anonymous), so -- * noone else is spinning to try to delete this page from 'd'. -- */ -+ /* Swizzle the owner then reinstate the PGC_allocated reference. */ -+ page_set_owner(page, NULL); -+ y = page->count_info; -+ do { -+ x = y; -+ BUG_ON((x & (PGC_count_mask|PGC_allocated)) != PGC_allocated); -+ } while ( (y = cmpxchg(&page->count_info, x, x | 1)) != x ); -+ -+ /* Unlink from original owner. */ - if ( !(memflags & MEMF_no_refcount) ) - d->tot_pages--; - list_del(&page->list); - - spin_unlock(&d->page_alloc_lock); -- - return 0; -+ -+ fail: -+ spin_unlock(&d->page_alloc_lock); -+ MEM_LOG("Bad page %p: ed=%p(%u), sd=%p, caf=%08x, taf=%" PRtype_info, -+ (void *)page_to_mfn(page), d, d->domain_id, -+ page_get_owner(page), page->count_info, page->u.inuse.type_info); -+ return -1; - } - - int do_update_va_mapping(unsigned long va, u64 val64, diff --git a/19089-x86_64-widen-page-refcounts.patch b/19089-x86_64-widen-page-refcounts.patch deleted file mode 100644 index 6e4bae0..0000000 --- a/19089-x86_64-widen-page-refcounts.patch +++ /dev/null @@ -1,445 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1232986782 0 -# Node ID 39517e863cc89a085341e1d53317aaa7ceddd127 -# Parent 055c589f4791811797867736857b08fdd0fd6d49 -x86_64: Widen page counts to avoid overflow. -References: bnc#470949 - -Signed-off-by: Keir Fraser - -# HG changeset patch -# User Keir Fraser -# Date 1232988758 0 -# Node ID 728d1892f0e24c2531df2d61a2d95177400ceb17 -# Parent 90909b81b3b9cf9b303e2bc457580603da3ac7fd -x86: Clean up shadow_page_info after page_info changes. -Signed-off-by: Keir Fraser - -# HG changeset patch -# User Keir Fraser -# Date 1233056759 0 -# Node ID 6e623569455c08b57e43e3355f6809b3a4ba0707 -# Parent 7b56dbd1b439e0996083810489398cb51dc43aa6 -x86: clean up struct page_info - -Remove the now unnecessary (and leading to misalignment of cpumask on -x86-64) 'packed' attributes. - -Signed-off-by: Jan Beulich - ---- a/xen/arch/x86/domain.c -+++ b/xen/arch/x86/domain.c -@@ -143,7 +143,7 @@ void dump_pageframe_info(struct domain * - { - list_for_each_entry ( page, &d->page_list, list ) - { -- printk(" DomPage %p: caf=%08x, taf=%" PRtype_info "\n", -+ printk(" DomPage %p: caf=%08lx, taf=%" PRtype_info "\n", - _p(page_to_mfn(page)), - page->count_info, page->u.inuse.type_info); - } -@@ -151,7 +151,7 @@ void dump_pageframe_info(struct domain * - - list_for_each_entry ( page, &d->xenpage_list, list ) - { -- printk(" XenPage %p: caf=%08x, taf=%" PRtype_info "\n", -+ printk(" XenPage %p: caf=%08lx, taf=%" PRtype_info "\n", - _p(page_to_mfn(page)), - page->count_info, page->u.inuse.type_info); - } ---- a/xen/arch/x86/mm.c -+++ b/xen/arch/x86/mm.c -@@ -714,8 +714,8 @@ get_page_from_l1e( - else if ( pte_flags_to_cacheattr(l1f) != - ((page->count_info >> PGC_cacheattr_base) & 7) ) - { -- uint32_t x, nx, y = page->count_info; -- uint32_t cacheattr = pte_flags_to_cacheattr(l1f); -+ unsigned long x, nx, y = page->count_info; -+ unsigned long cacheattr = pte_flags_to_cacheattr(l1f); - - if ( is_xen_heap_page(page) ) - { -@@ -1869,7 +1869,7 @@ static int mod_l4_entry(l4_pgentry_t *pl - - void put_page(struct page_info *page) - { -- u32 nx, x, y = page->count_info; -+ unsigned long nx, x, y = page->count_info; - - do { - x = y; -@@ -1887,7 +1887,7 @@ void put_page(struct page_info *page) - - int get_page(struct page_info *page, struct domain *domain) - { -- u32 x, y = page->count_info; -+ unsigned long x, y = page->count_info; - - do { - x = y; -@@ -1906,7 +1906,7 @@ int get_page(struct page_info *page, str - fail: - if ( !_shadow_mode_refcounts(domain) && !domain->is_dying ) - gdprintk(XENLOG_INFO, -- "Error pfn %lx: rd=%p, od=%p, caf=%08x, taf=%" PRtype_info, -+ "Error pfn %lx: rd=%p, od=%p, caf=%08lx, taf=%" PRtype_info, - page_to_mfn(page), domain, page_get_owner(page), - y, page->u.inuse.type_info); - return 0; -@@ -1922,7 +1922,7 @@ int get_page(struct page_info *page, str - */ - static void get_page_light(struct page_info *page) - { -- u32 x, nx, y = page->count_info; -+ unsigned long x, nx, y = page->count_info; - - do { - x = y; -@@ -1963,7 +1963,7 @@ static int alloc_page_type(struct page_i - rc = alloc_segdesc_page(page); - break; - default: -- printk("Bad type in alloc_page_type %lx t=%" PRtype_info " c=%x\n", -+ printk("Bad type in alloc_page_type %lx t=%" PRtype_info " c=%lx\n", - type, page->u.inuse.type_info, - page->count_info); - rc = -EINVAL; -@@ -1987,7 +1987,7 @@ static int alloc_page_type(struct page_i - { - ASSERT(rc < 0); - MEM_LOG("Error while validating mfn %lx (pfn %lx) for type %" -- PRtype_info ": caf=%08x taf=%" PRtype_info, -+ PRtype_info ": caf=%08lx taf=%" PRtype_info, - page_to_mfn(page), get_gpfn_from_mfn(page_to_mfn(page)), - type, page->count_info, page->u.inuse.type_info); - page->u.inuse.type_info = 0; -@@ -3144,7 +3144,7 @@ static int create_grant_pte_mapping( - void *va; - unsigned long gmfn, mfn; - struct page_info *page; -- u32 type; -+ unsigned long type; - l1_pgentry_t ol1e; - struct domain *d = v->domain; - -@@ -3205,7 +3205,7 @@ static int destroy_grant_pte_mapping( - void *va; - unsigned long gmfn, mfn; - struct page_info *page; -- u32 type; -+ unsigned long type; - l1_pgentry_t ol1e; - - gmfn = addr >> PAGE_SHIFT; -@@ -3431,7 +3431,7 @@ int replace_grant_host_mapping( - int steal_page( - struct domain *d, struct page_info *page, unsigned int memflags) - { -- u32 x, y; -+ unsigned long x, y; - - spin_lock(&d->page_alloc_lock); - -@@ -3468,7 +3468,7 @@ int steal_page( - - fail: - spin_unlock(&d->page_alloc_lock); -- MEM_LOG("Bad page %p: ed=%p(%u), sd=%p, caf=%08x, taf=%" PRtype_info, -+ MEM_LOG("Bad page %p: ed=%p(%u), sd=%p, caf=%08lx, taf=%" PRtype_info, - (void *)page_to_mfn(page), d, d->domain_id, - page_get_owner(page), page->count_info, page->u.inuse.type_info); - return -1; ---- a/xen/arch/x86/mm/hap/hap.c -+++ b/xen/arch/x86/mm/hap/hap.c -@@ -166,7 +166,7 @@ void hap_free_p2m_page(struct domain *d, - ASSERT(page_get_owner(pg) == d); - /* Should have just the one ref we gave it in alloc_p2m_page() */ - if ( (pg->count_info & PGC_count_mask) != 1 ) -- HAP_ERROR("Odd p2m page count c=%#x t=%"PRtype_info"\n", -+ HAP_ERROR("Odd p2m page count c=%#lx t=%"PRtype_info"\n", - pg->count_info, pg->u.inuse.type_info); - pg->count_info = 0; - /* Free should not decrement domain's total allocation, since ---- a/xen/arch/x86/mm/shadow/common.c -+++ b/xen/arch/x86/mm/shadow/common.c -@@ -1678,7 +1678,7 @@ shadow_free_p2m_page(struct domain *d, s - /* Should have just the one ref we gave it in alloc_p2m_page() */ - if ( (pg->count_info & PGC_count_mask) != 1 ) - { -- SHADOW_ERROR("Odd p2m page count c=%#x t=%"PRtype_info"\n", -+ SHADOW_ERROR("Odd p2m page count c=%#lx t=%"PRtype_info"\n", - pg->count_info, pg->u.inuse.type_info); - } - pg->count_info = 0; -@@ -1796,14 +1796,21 @@ static unsigned int sh_set_allocation(st - sp = list_entry(d->arch.paging.shadow.freelists[order].next, - struct shadow_page_info, list); - list_del(&sp->list); --#if defined(__x86_64__) - /* -- * Re-instate lock field which we overwrite with shadow_page_info. -- * This was safe, since the lock is only used on guest pages. -+ * The pages were allocated anonymously, but the owner field -+ * may get overwritten, so need to clear it here. - */ - for ( j = 0; j < 1U << order; j++ ) -+ { -+ page_set_owner(&((struct page_info *)sp)[j], NULL); -+#if defined(__x86_64__) -+ /* -+ * Re-instate lock field which we overwrite with shadow_page_info. -+ * This was safe, since the lock is only used on guest pages. -+ */ - spin_lock_init(&((struct page_info *)sp)[j].lock); - #endif -+ } - d->arch.paging.shadow.free_pages -= 1 << order; - d->arch.paging.shadow.total_pages -= 1 << order; - free_domheap_pages((struct page_info *)sp, order); -@@ -2516,7 +2523,7 @@ int sh_remove_all_mappings(struct vcpu * - && (page->u.inuse.type_info & PGT_count_mask) == 0) ) - { - SHADOW_ERROR("can't find all mappings of mfn %lx: " -- "c=%08x t=%08lx\n", mfn_x(gmfn), -+ "c=%08lx t=%08lx\n", mfn_x(gmfn), - page->count_info, page->u.inuse.type_info); - } - } -@@ -3591,7 +3598,6 @@ int shadow_track_dirty_vram(struct domai - for ( i = 0; i < nr; i++ ) { - mfn_t mfn = gfn_to_mfn(d, begin_pfn + i, &t); - struct page_info *page; -- u32 count_info; - int dirty = 0; - paddr_t sl1ma = d->dirty_vram->sl1ma[i]; - -@@ -3602,8 +3608,7 @@ int shadow_track_dirty_vram(struct domai - else - { - page = mfn_to_page(mfn); -- count_info = page->u.inuse.type_info & PGT_count_mask; -- switch (count_info) -+ switch (page->u.inuse.type_info & PGT_count_mask) - { - case 0: - /* No guest reference, nothing to track. */ ---- a/xen/arch/x86/mm/shadow/multi.c -+++ b/xen/arch/x86/mm/shadow/multi.c -@@ -1334,9 +1334,8 @@ static inline void shadow_vram_get_l1e(s - if ( (gfn >= d->dirty_vram->begin_pfn) && (gfn < d->dirty_vram->end_pfn) ) { - unsigned long i = gfn - d->dirty_vram->begin_pfn; - struct page_info *page = mfn_to_page(mfn); -- u32 count_info = page->u.inuse.type_info & PGT_count_mask; - -- if ( count_info == 1 ) -+ if ( (page->u.inuse.type_info & PGT_count_mask) == 1 ) - /* Initial guest reference, record it */ - d->dirty_vram->sl1ma[i] = pfn_to_paddr(mfn_x(sl1mfn)) - | ((unsigned long)sl1e & ~PAGE_MASK); -@@ -1362,12 +1361,11 @@ static inline void shadow_vram_put_l1e(s - if ( (gfn >= d->dirty_vram->begin_pfn) && (gfn < d->dirty_vram->end_pfn) ) { - unsigned long i = gfn - d->dirty_vram->begin_pfn; - struct page_info *page = mfn_to_page(mfn); -- u32 count_info = page->u.inuse.type_info & PGT_count_mask; - int dirty = 0; - paddr_t sl1ma = pfn_to_paddr(mfn_x(sl1mfn)) - | ((unsigned long)sl1e & ~PAGE_MASK); - -- if ( count_info == 1 ) { -+ if ( (page->u.inuse.type_info & PGT_count_mask) == 1 ) { - /* Last reference */ - if ( d->dirty_vram->sl1ma[i] == INVALID_PADDR ) { - /* We didn't know it was that one, let's say it is dirty */ ---- a/xen/arch/x86/mm/shadow/private.h -+++ b/xen/arch/x86/mm/shadow/private.h -@@ -201,12 +201,11 @@ struct shadow_page_info - u32 tlbflush_timestamp; - }; - struct { -- unsigned int type:5; /* What kind of shadow is this? */ -- unsigned int pinned:1; /* Is the shadow pinned? */ -- unsigned int count:26; /* Reference count */ -- u32 mbz; /* Must be zero: this is where the -- * owner field lives in page_info */ -- } __attribute__((packed)); -+ unsigned long mbz; /* Must be zero: count_info is here. */ -+ unsigned long type:5; /* What kind of shadow is this? */ -+ unsigned long pinned:1; /* Is the shadow pinned? */ -+ unsigned long count:26; /* Reference count */ -+ }; - union { - /* For unused shadow pages, a list of pages of this order; for - * pinnable shadows, if pinned, a list of other pinned shadows -@@ -229,7 +228,7 @@ static inline void shadow_check_page_str - BUILD_BUG_ON(sizeof (struct shadow_page_info) != - sizeof (struct page_info)); - BUILD_BUG_ON(offsetof(struct shadow_page_info, mbz) != -- offsetof(struct page_info, u.inuse._domain)); -+ offsetof(struct page_info, count_info)); - }; - - /* Shadow type codes */ ---- a/xen/arch/x86/x86_32/mm.c -+++ b/xen/arch/x86/x86_32/mm.c -@@ -159,15 +159,6 @@ void __init subarch_init_memory(void) - unsigned long m2p_start_mfn; - unsigned int i, j; - -- /* -- * We are rather picky about the layout of 'struct page_info'. The -- * count_info and domain fields must be adjacent, as we perform atomic -- * 64-bit operations on them. Also, just for sanity, we assert the size -- * of the structure here. -- */ -- BUILD_BUG_ON(offsetof(struct page_info, u.inuse._domain) != -- (offsetof(struct page_info, count_info) + sizeof(u32))); -- BUILD_BUG_ON((offsetof(struct page_info, count_info) & 7) != 0); - BUILD_BUG_ON(sizeof(struct page_info) != 24); - - /* M2P table is mappable read-only by privileged domains. */ ---- a/xen/arch/x86/x86_64/mm.c -+++ b/xen/arch/x86/x86_64/mm.c -@@ -225,17 +225,6 @@ void __init subarch_init_memory(void) - l3_pgentry_t l3e; - l2_pgentry_t l2e; - -- /* -- * We are rather picky about the layout of 'struct page_info'. The -- * count_info and domain fields must be adjacent, as we perform atomic -- * 64-bit operations on them. -- */ -- BUILD_BUG_ON(offsetof(struct page_info, u.inuse._domain) != -- (offsetof(struct page_info, count_info) + sizeof(u32))); -- BUILD_BUG_ON((offsetof(struct page_info, count_info) & 7) != 0); -- BUILD_BUG_ON(sizeof(struct page_info) != -- (32 + BITS_TO_LONGS(NR_CPUS)*sizeof(long))); -- - /* M2P table is mappable read-only by privileged domains. */ - for ( v = RDWR_MPT_VIRT_START; - v != RDWR_MPT_VIRT_END; ---- a/xen/common/xenoprof.c -+++ b/xen/common/xenoprof.c -@@ -142,8 +142,8 @@ share_xenoprof_page_with_guest(struct do - struct page_info *page = mfn_to_page(mfn + i); - if ( (page->count_info & (PGC_allocated|PGC_count_mask)) != 0 ) - { -- gdprintk(XENLOG_INFO, "mfn 0x%lx page->count_info 0x%x\n", -- mfn + i, page->count_info); -+ gdprintk(XENLOG_INFO, "mfn 0x%lx page->count_info 0x%lx\n", -+ mfn + i, (unsigned long)page->count_info); - return -EBUSY; - } - page_set_owner(page, NULL); ---- a/xen/include/asm-x86/mm.h -+++ b/xen/include/asm-x86/mm.h -@@ -23,7 +23,7 @@ struct page_info - struct list_head list; - - /* Reference count and various PGC_xxx flags and fields. */ -- u32 count_info; -+ unsigned long count_info; - - /* Context-dependent fields follow... */ - union { -@@ -34,7 +34,7 @@ struct page_info - u32 _domain; /* pickled format */ - /* Type reference count and various PGT_xxx flags and fields. */ - unsigned long type_info; -- } __attribute__ ((packed)) inuse; -+ } inuse; - - /* Page is on a free list: ((count_info & PGC_count_mask) == 0). */ - struct { -@@ -42,7 +42,7 @@ struct page_info - u32 order; - /* Mask of possibly-tainted TLBs. */ - cpumask_t cpumask; -- } __attribute__ ((packed)) free; -+ } free; - - } u; - -@@ -102,48 +102,53 @@ struct page_info - }; - }; - -+#define PG_shift(idx) (BITS_PER_LONG - (idx)) -+#define PG_mask(x, idx) (x ## UL << PG_shift(idx)) -+ - /* The following page types are MUTUALLY EXCLUSIVE. */ --#define PGT_none (0U<<29) /* no special uses of this page */ --#define PGT_l1_page_table (1U<<29) /* using this page as an L1 page table? */ --#define PGT_l2_page_table (2U<<29) /* using this page as an L2 page table? */ --#define PGT_l3_page_table (3U<<29) /* using this page as an L3 page table? */ --#define PGT_l4_page_table (4U<<29) /* using this page as an L4 page table? */ --#define PGT_seg_desc_page (5U<<29) /* using this page in a GDT/LDT? */ --#define PGT_writable_page (7U<<29) /* has writable mappings of this page? */ --#define PGT_type_mask (7U<<29) /* Bits 29-31. */ -+#define PGT_none PG_mask(0, 3) /* no special uses of this page */ -+#define PGT_l1_page_table PG_mask(1, 3) /* using as an L1 page table? */ -+#define PGT_l2_page_table PG_mask(2, 3) /* using as an L2 page table? */ -+#define PGT_l3_page_table PG_mask(3, 3) /* using as an L3 page table? */ -+#define PGT_l4_page_table PG_mask(4, 3) /* using as an L4 page table? */ -+#define PGT_seg_desc_page PG_mask(5, 3) /* using this page in a GDT/LDT? */ -+#define PGT_writable_page PG_mask(7, 3) /* has writable mappings? */ -+#define PGT_type_mask PG_mask(7, 3) /* Bits 29-31. */ - - /* Owning guest has pinned this page to its current type? */ --#define _PGT_pinned 28 --#define PGT_pinned (1U<<_PGT_pinned) -+#define _PGT_pinned PG_shift(4) -+#define PGT_pinned PG_mask(1, 4) - /* Has this page been validated for use as its current type? */ --#define _PGT_validated 27 --#define PGT_validated (1U<<_PGT_validated) -+#define _PGT_validated PG_shift(5) -+#define PGT_validated PG_mask(1, 5) - /* PAE only: is this an L2 page directory containing Xen-private mappings? */ --#define _PGT_pae_xen_l2 26 --#define PGT_pae_xen_l2 (1U<<_PGT_pae_xen_l2) -+#define _PGT_pae_xen_l2 PG_shift(6) -+#define PGT_pae_xen_l2 PG_mask(1, 6) - /* Has this page been *partially* validated for use as its current type? */ --#define _PGT_partial 25 --#define PGT_partial (1U<<_PGT_partial) -+#define _PGT_partial PG_shift(7) -+#define PGT_partial PG_mask(1, 7) - -- /* 25-bit count of uses of this frame as its current type. */ --#define PGT_count_mask ((1U<<25)-1) -+ /* Count of uses of this frame as its current type. */ -+#define PGT_count_width PG_shift(7) -+#define PGT_count_mask ((1UL< -# Date 1233072141 0 -# Node ID bcf77bfd1161d1e2693d6762bcd436ad98ec0779 -# Parent dbf53b739af0434adff50172fc071f718b57b450 -x86: Fold page_info lock into type_info. -References: bnc#470949 - -Fix some racey looking code at the same time. - -Signed-off-by: Keir Fraser - ---- a/xen/arch/x86/mm.c -+++ b/xen/arch/x86/mm.c -@@ -202,11 +202,6 @@ void __init init_frametable(void) - } - - memset(frame_table, 0, nr_pages << PAGE_SHIFT); -- --#if defined(__x86_64__) -- for ( i = 0; i < max_page; i ++ ) -- spin_lock_init(&frame_table[i].lock); --#endif - } - - void __init arch_init_memory(void) -@@ -1499,24 +1494,31 @@ static int free_l4_table(struct page_inf - #define free_l4_table(page, preemptible) (-EINVAL) - #endif - --static void page_lock(struct page_info *page) -+static int page_lock(struct page_info *page) - { --#if defined(__i386__) -- while ( unlikely(test_and_set_bit(_PGC_locked, &page->count_info)) ) -- while ( test_bit(_PGC_locked, &page->count_info) ) -+ unsigned long x, nx; -+ -+ do { -+ while ( (x = page->u.inuse.type_info) & PGT_locked ) - cpu_relax(); --#else -- spin_lock(&page->lock); --#endif -+ nx = x + (1 | PGT_locked); -+ if ( !(x & PGT_validated) || -+ !(x & PGT_count_mask) || -+ !(nx & PGT_count_mask) ) -+ return 0; -+ } while ( cmpxchg(&page->u.inuse.type_info, x, nx) != x ); -+ -+ return 1; - } - - static void page_unlock(struct page_info *page) - { --#if defined(__i386__) -- clear_bit(_PGC_locked, &page->count_info); --#else -- spin_unlock(&page->lock); --#endif -+ unsigned long x, nx, y = page->u.inuse.type_info; -+ -+ do { -+ x = y; -+ nx = x - (1 | PGT_locked); -+ } while ( (y = cmpxchg(&page->u.inuse.type_info, x, nx)) != x ); - } - - /* How to write an entry to the guest pagetables. -@@ -1579,19 +1581,15 @@ static int mod_l1_entry(l1_pgentry_t *pl - struct vcpu *curr = current; - struct domain *d = curr->domain; - unsigned long mfn; -- struct page_info *l1pg = mfn_to_page(gl1mfn); - p2m_type_t p2mt; - int rc = 1; - -- page_lock(l1pg); -- - if ( unlikely(__copy_from_user(&ol1e, pl1e, sizeof(ol1e)) != 0) ) -- return page_unlock(l1pg), 0; -+ return 0; - - if ( unlikely(paging_mode_refcounts(d)) ) - { - rc = UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, curr, preserve_ad); -- page_unlock(l1pg); - return rc; - } - -@@ -1600,13 +1598,12 @@ static int mod_l1_entry(l1_pgentry_t *pl - /* Translate foreign guest addresses. */ - mfn = mfn_x(gfn_to_mfn(FOREIGNDOM, l1e_get_pfn(nl1e), &p2mt)); - if ( !p2m_is_ram(p2mt) || unlikely(mfn == INVALID_MFN) ) -- return page_unlock(l1pg), 0; -+ return 0; - ASSERT((mfn & ~(PADDR_MASK >> PAGE_SHIFT)) == 0); - nl1e = l1e_from_pfn(mfn, l1e_get_flags(nl1e)); - - if ( unlikely(l1e_get_flags(nl1e) & l1_disallow_mask(d)) ) - { -- page_unlock(l1pg); - MEM_LOG("Bad L1 flags %x", - l1e_get_flags(nl1e) & l1_disallow_mask(d)); - return 0; -@@ -1618,12 +1615,11 @@ static int mod_l1_entry(l1_pgentry_t *pl - adjust_guest_l1e(nl1e, d); - rc = UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, curr, - preserve_ad); -- page_unlock(l1pg); - return rc; - } - - if ( unlikely(!get_page_from_l1e(nl1e, FOREIGNDOM)) ) -- return page_unlock(l1pg), 0; -+ return 0; - - adjust_guest_l1e(nl1e, d); - if ( unlikely(!UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, curr, -@@ -1636,11 +1632,9 @@ static int mod_l1_entry(l1_pgentry_t *pl - else if ( unlikely(!UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, curr, - preserve_ad)) ) - { -- page_unlock(l1pg); - return 0; - } - -- page_unlock(l1pg); - put_page_from_l1e(ol1e, d); - return rc; - } -@@ -1650,13 +1644,13 @@ static int mod_l1_entry(l1_pgentry_t *pl - static int mod_l2_entry(l2_pgentry_t *pl2e, - l2_pgentry_t nl2e, - unsigned long pfn, -- unsigned long type, - int preserve_ad) - { - l2_pgentry_t ol2e; - struct vcpu *curr = current; - struct domain *d = curr->domain; - struct page_info *l2pg = mfn_to_page(pfn); -+ unsigned long type = l2pg->u.inuse.type_info; - int rc = 1; - - if ( unlikely(!is_guest_l2_slot(d, type, pgentry_ptr_to_slot(pl2e))) ) -@@ -1665,16 +1659,13 @@ static int mod_l2_entry(l2_pgentry_t *pl - return 0; - } - -- page_lock(l2pg); -- - if ( unlikely(__copy_from_user(&ol2e, pl2e, sizeof(ol2e)) != 0) ) -- return page_unlock(l2pg), 0; -+ return 0; - - if ( l2e_get_flags(nl2e) & _PAGE_PRESENT ) - { - if ( unlikely(l2e_get_flags(nl2e) & L2_DISALLOW_MASK) ) - { -- page_unlock(l2pg); - MEM_LOG("Bad L2 flags %x", - l2e_get_flags(nl2e) & L2_DISALLOW_MASK); - return 0; -@@ -1685,12 +1676,11 @@ static int mod_l2_entry(l2_pgentry_t *pl - { - adjust_guest_l2e(nl2e, d); - rc = UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, pfn, curr, preserve_ad); -- page_unlock(l2pg); - return rc; - } - - if ( unlikely(get_page_from_l2e(nl2e, pfn, d) < 0) ) -- return page_unlock(l2pg), 0; -+ return 0; - - adjust_guest_l2e(nl2e, d); - if ( unlikely(!UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, pfn, curr, -@@ -1703,11 +1693,9 @@ static int mod_l2_entry(l2_pgentry_t *pl - else if ( unlikely(!UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, pfn, curr, - preserve_ad)) ) - { -- page_unlock(l2pg); - return 0; - } - -- page_unlock(l2pg); - put_page_from_l2e(ol2e, pfn); - return rc; - } -@@ -1722,7 +1710,6 @@ static int mod_l3_entry(l3_pgentry_t *pl - l3_pgentry_t ol3e; - struct vcpu *curr = current; - struct domain *d = curr->domain; -- struct page_info *l3pg = mfn_to_page(pfn); - int rc = 0; - - if ( unlikely(!is_guest_l3_slot(pgentry_ptr_to_slot(pl3e))) ) -@@ -1738,16 +1725,13 @@ static int mod_l3_entry(l3_pgentry_t *pl - if ( is_pv_32bit_domain(d) && (pgentry_ptr_to_slot(pl3e) >= 3) ) - return -EINVAL; - -- page_lock(l3pg); -- - if ( unlikely(__copy_from_user(&ol3e, pl3e, sizeof(ol3e)) != 0) ) -- return page_unlock(l3pg), -EFAULT; -+ return -EFAULT; - - if ( l3e_get_flags(nl3e) & _PAGE_PRESENT ) - { - if ( unlikely(l3e_get_flags(nl3e) & l3_disallow_mask(d)) ) - { -- page_unlock(l3pg); - MEM_LOG("Bad L3 flags %x", - l3e_get_flags(nl3e) & l3_disallow_mask(d)); - return -EINVAL; -@@ -1758,13 +1742,12 @@ static int mod_l3_entry(l3_pgentry_t *pl - { - adjust_guest_l3e(nl3e, d); - rc = UPDATE_ENTRY(l3, pl3e, ol3e, nl3e, pfn, curr, preserve_ad); -- page_unlock(l3pg); - return rc ? 0 : -EFAULT; - } - - rc = get_page_from_l3e(nl3e, pfn, d, 0, preemptible); - if ( unlikely(rc < 0) ) -- return page_unlock(l3pg), rc; -+ return rc; - rc = 0; - - adjust_guest_l3e(nl3e, d); -@@ -1778,7 +1761,6 @@ static int mod_l3_entry(l3_pgentry_t *pl - else if ( unlikely(!UPDATE_ENTRY(l3, pl3e, ol3e, nl3e, pfn, curr, - preserve_ad)) ) - { -- page_unlock(l3pg); - return -EFAULT; - } - -@@ -1790,7 +1772,6 @@ static int mod_l3_entry(l3_pgentry_t *pl - pae_flush_pgd(pfn, pgentry_ptr_to_slot(pl3e), nl3e); - } - -- page_unlock(l3pg); - put_page_from_l3e(ol3e, pfn, 0, 0); - return rc; - } -@@ -1807,7 +1788,6 @@ static int mod_l4_entry(l4_pgentry_t *pl - struct vcpu *curr = current; - struct domain *d = curr->domain; - l4_pgentry_t ol4e; -- struct page_info *l4pg = mfn_to_page(pfn); - int rc = 0; - - if ( unlikely(!is_guest_l4_slot(d, pgentry_ptr_to_slot(pl4e))) ) -@@ -1816,16 +1796,13 @@ static int mod_l4_entry(l4_pgentry_t *pl - return -EINVAL; - } - -- page_lock(l4pg); -- - if ( unlikely(__copy_from_user(&ol4e, pl4e, sizeof(ol4e)) != 0) ) -- return page_unlock(l4pg), -EFAULT; -+ return -EFAULT; - - if ( l4e_get_flags(nl4e) & _PAGE_PRESENT ) - { - if ( unlikely(l4e_get_flags(nl4e) & L4_DISALLOW_MASK) ) - { -- page_unlock(l4pg); - MEM_LOG("Bad L4 flags %x", - l4e_get_flags(nl4e) & L4_DISALLOW_MASK); - return -EINVAL; -@@ -1836,13 +1813,12 @@ static int mod_l4_entry(l4_pgentry_t *pl - { - adjust_guest_l4e(nl4e, d); - rc = UPDATE_ENTRY(l4, pl4e, ol4e, nl4e, pfn, curr, preserve_ad); -- page_unlock(l4pg); - return rc ? 0 : -EFAULT; - } - - rc = get_page_from_l4e(nl4e, pfn, d, 0, preemptible); - if ( unlikely(rc < 0) ) -- return page_unlock(l4pg), rc; -+ return rc; - rc = 0; - - adjust_guest_l4e(nl4e, d); -@@ -1856,11 +1832,9 @@ static int mod_l4_entry(l4_pgentry_t *pl - else if ( unlikely(!UPDATE_ENTRY(l4, pl4e, ol4e, nl4e, pfn, curr, - preserve_ad)) ) - { -- page_unlock(l4pg); - return -EFAULT; - } - -- page_unlock(l4pg); - put_page_from_l4e(ol4e, pfn, 0, 0); - return rc; - } -@@ -2918,7 +2892,6 @@ int do_mmu_update( - unsigned int cmd, done = 0; - struct vcpu *v = current; - struct domain *d = v->domain; -- unsigned long type_info; - struct domain_mmap_cache mapcache; - - if ( unlikely(count & MMU_UPDATE_PREEMPTED) ) -@@ -2990,24 +2963,9 @@ int do_mmu_update( - (unsigned long)(req.ptr & ~PAGE_MASK)); - page = mfn_to_page(mfn); - -- switch ( (type_info = page->u.inuse.type_info) & PGT_type_mask ) -+ if ( page_lock(page) ) - { -- case PGT_l1_page_table: -- case PGT_l2_page_table: -- case PGT_l3_page_table: -- case PGT_l4_page_table: -- { -- if ( paging_mode_refcounts(d) ) -- { -- MEM_LOG("mmu update on auto-refcounted domain!"); -- break; -- } -- -- if ( unlikely(!get_page_type( -- page, type_info & (PGT_type_mask|PGT_pae_xen_l2))) ) -- goto not_a_pt; -- -- switch ( type_info & PGT_type_mask ) -+ switch ( page->u.inuse.type_info & PGT_type_mask ) - { - case PGT_l1_page_table: - { -@@ -3019,7 +2977,7 @@ int do_mmu_update( - case PGT_l2_page_table: - { - l2_pgentry_t l2e = l2e_from_intpte(req.val); -- okay = mod_l2_entry(va, l2e, mfn, type_info, -+ okay = mod_l2_entry(va, l2e, mfn, - cmd == MMU_PT_UPDATE_PRESERVE_AD); - } - break; -@@ -3041,31 +2999,23 @@ int do_mmu_update( - } - break; - #endif -+ case PGT_writable_page: -+ perfc_incr(writable_mmu_updates); -+ okay = paging_write_guest_entry(v, va, req.val, _mfn(mfn)); -+ break; - } -- -- put_page_type(page); -+ page_unlock(page); - if ( rc == -EINTR ) - rc = -EAGAIN; - } -- break; -- -- default: -- not_a_pt: -+ else if ( get_page_type(page, PGT_writable_page) ) - { -- if ( unlikely(!get_page_type(page, PGT_writable_page)) ) -- break; -- - perfc_incr(writable_mmu_updates); -- - okay = paging_write_guest_entry(v, va, req.val, _mfn(mfn)); -- - put_page_type(page); - } -- break; -- } - - unmap_domain_page_with_cache(va, &mapcache); -- - put_page(page); - break; - -@@ -3144,7 +3094,6 @@ static int create_grant_pte_mapping( - void *va; - unsigned long gmfn, mfn; - struct page_info *page; -- unsigned long type; - l1_pgentry_t ol1e; - struct domain *d = v->domain; - -@@ -3165,21 +3114,23 @@ static int create_grant_pte_mapping( - va = (void *)((unsigned long)va + ((unsigned long)pte_addr & ~PAGE_MASK)); - page = mfn_to_page(mfn); - -- type = page->u.inuse.type_info & PGT_type_mask; -- if ( (type != PGT_l1_page_table) || !get_page_type(page, type) ) -+ if ( !page_lock(page) ) - { -- MEM_LOG("Grant map attempted to update a non-L1 page"); - rc = GNTST_general_error; - goto failed; - } - -- page_lock(page); -+ if ( (page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table ) -+ { -+ page_unlock(page); -+ rc = GNTST_general_error; -+ goto failed; -+ } - - ol1e = *(l1_pgentry_t *)va; - if ( !UPDATE_ENTRY(l1, (l1_pgentry_t *)va, ol1e, nl1e, mfn, v, 0) ) - { - page_unlock(page); -- put_page_type(page); - rc = GNTST_general_error; - goto failed; - } -@@ -3189,8 +3140,6 @@ static int create_grant_pte_mapping( - if ( !paging_mode_refcounts(d) ) - put_page_from_l1e(ol1e, d); - -- put_page_type(page); -- - failed: - unmap_domain_page(va); - put_page(page); -@@ -3205,7 +3154,6 @@ static int destroy_grant_pte_mapping( - void *va; - unsigned long gmfn, mfn; - struct page_info *page; -- unsigned long type; - l1_pgentry_t ol1e; - - gmfn = addr >> PAGE_SHIFT; -@@ -3221,15 +3169,18 @@ static int destroy_grant_pte_mapping( - va = (void *)((unsigned long)va + ((unsigned long)addr & ~PAGE_MASK)); - page = mfn_to_page(mfn); - -- type = page->u.inuse.type_info & PGT_type_mask; -- if ( (type != PGT_l1_page_table) || !get_page_type(page, type) ) -+ if ( !page_lock(page) ) - { -- MEM_LOG("Grant map attempted to update a non-L1 page"); - rc = GNTST_general_error; - goto failed; - } - -- page_lock(page); -+ if ( (page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table ) -+ { -+ page_unlock(page); -+ rc = GNTST_general_error; -+ goto failed; -+ } - - ol1e = *(l1_pgentry_t *)va; - -@@ -3239,7 +3190,6 @@ static int destroy_grant_pte_mapping( - page_unlock(page); - MEM_LOG("PTE entry %lx for address %"PRIx64" doesn't match frame %lx", - (unsigned long)l1e_get_intpte(ol1e), addr, frame); -- put_page_type(page); - rc = GNTST_general_error; - goto failed; - } -@@ -3253,13 +3203,11 @@ static int destroy_grant_pte_mapping( - { - page_unlock(page); - MEM_LOG("Cannot delete PTE entry at %p", va); -- put_page_type(page); - rc = GNTST_general_error; - goto failed; - } - - page_unlock(page); -- put_page_type(page); - - failed: - unmap_domain_page(va); -@@ -3287,21 +3235,40 @@ static int create_grant_va_mapping( - MEM_LOG("Could not find L1 PTE for address %lx", va); - return GNTST_general_error; - } -+ -+ if ( !get_page_from_pagenr(gl1mfn, current->domain) ) -+ { -+ guest_unmap_l1e(v, pl1e); -+ return GNTST_general_error; -+ } -+ - l1pg = mfn_to_page(gl1mfn); -- page_lock(l1pg); -+ if ( !page_lock(l1pg) ) -+ { -+ put_page(l1pg); -+ guest_unmap_l1e(v, pl1e); -+ return GNTST_general_error; -+ } -+ -+ if ( (l1pg->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table ) -+ { -+ page_unlock(l1pg); -+ put_page(l1pg); -+ guest_unmap_l1e(v, pl1e); -+ return GNTST_general_error; -+ } -+ - ol1e = *pl1e; - okay = UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, v, 0); -+ - page_unlock(l1pg); -+ put_page(l1pg); - guest_unmap_l1e(v, pl1e); -- pl1e = NULL; - -- if ( !okay ) -- return GNTST_general_error; -- -- if ( !paging_mode_refcounts(d) ) -+ if ( okay && !paging_mode_refcounts(d) ) - put_page_from_l1e(ol1e, d); - -- return GNTST_okay; -+ return okay ? GNTST_okay : GNTST_general_error; - } - - static int replace_grant_va_mapping( -@@ -3319,31 +3286,48 @@ static int replace_grant_va_mapping( - return GNTST_general_error; - } - -+ if ( !get_page_from_pagenr(gl1mfn, current->domain) ) -+ { -+ rc = GNTST_general_error; -+ goto out; -+ } -+ - l1pg = mfn_to_page(gl1mfn); -- page_lock(l1pg); -+ if ( !page_lock(l1pg) ) -+ { -+ rc = GNTST_general_error; -+ put_page(l1pg); -+ goto out; -+ } -+ -+ if ( (l1pg->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table ) -+ { -+ rc = GNTST_general_error; -+ goto unlock_and_out; -+ } -+ - ol1e = *pl1e; - - /* Check that the virtual address supplied is actually mapped to frame. */ - if ( unlikely(l1e_get_pfn(ol1e) != frame) ) - { -- page_unlock(l1pg); - MEM_LOG("PTE entry %lx for address %lx doesn't match frame %lx", - l1e_get_pfn(ol1e), addr, frame); - rc = GNTST_general_error; -- goto out; -+ goto unlock_and_out; - } - - /* Delete pagetable entry. */ - if ( unlikely(!UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, v, 0)) ) - { -- page_unlock(l1pg); - MEM_LOG("Cannot delete PTE entry at %p", (unsigned long *)pl1e); - rc = GNTST_general_error; -- goto out; -+ goto unlock_and_out; - } - -+ unlock_and_out: - page_unlock(l1pg); -- -+ put_page(l1pg); - out: - guest_unmap_l1e(v, pl1e); - return rc; -@@ -3405,20 +3389,42 @@ int replace_grant_host_mapping( - return GNTST_general_error; - } - -+ if ( !get_page_from_pagenr(gl1mfn, current->domain) ) -+ { -+ guest_unmap_l1e(curr, pl1e); -+ return GNTST_general_error; -+ } -+ - l1pg = mfn_to_page(gl1mfn); -- page_lock(l1pg); -+ if ( !page_lock(l1pg) ) -+ { -+ put_page(l1pg); -+ guest_unmap_l1e(curr, pl1e); -+ return GNTST_general_error; -+ } -+ -+ if ( (l1pg->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table ) -+ { -+ page_unlock(l1pg); -+ put_page(l1pg); -+ guest_unmap_l1e(curr, pl1e); -+ return GNTST_general_error; -+ } -+ - ol1e = *pl1e; - - if ( unlikely(!UPDATE_ENTRY(l1, pl1e, ol1e, l1e_empty(), - gl1mfn, curr, 0)) ) - { - page_unlock(l1pg); -+ put_page(l1pg); - MEM_LOG("Cannot delete PTE entry at %p", (unsigned long *)pl1e); - guest_unmap_l1e(curr, pl1e); - return GNTST_general_error; - } - - page_unlock(l1pg); -+ put_page(l1pg); - guest_unmap_l1e(curr, pl1e); - - rc = replace_grant_va_mapping(addr, frame, ol1e, curr); -@@ -3480,28 +3486,45 @@ int do_update_va_mapping(unsigned long v - l1_pgentry_t val = l1e_from_intpte(val64); - struct vcpu *v = current; - struct domain *d = v->domain; -+ struct page_info *gl1pg; - l1_pgentry_t *pl1e; - unsigned long vmask, bmap_ptr, gl1mfn; - cpumask_t pmask; -- int rc = 0; -+ int rc; - - perfc_incr(calls_to_update_va); - -- if ( unlikely(!access_ok(va, 1) && !paging_mode_external(d)) ) -- return -EINVAL; -- - rc = xsm_update_va_mapping(d, val); - if ( rc ) - return rc; - -+ rc = -EINVAL; - pl1e = guest_map_l1e(v, va, &gl1mfn); -+ if ( unlikely(!pl1e || !get_page_from_pagenr(gl1mfn, d)) ) -+ goto out; - -- if ( unlikely(!pl1e || !mod_l1_entry(pl1e, val, gl1mfn, 0)) ) -- rc = -EINVAL; -+ gl1pg = mfn_to_page(gl1mfn); -+ if ( !page_lock(gl1pg) ) -+ { -+ put_page(gl1pg); -+ goto out; -+ } -+ -+ if ( (gl1pg->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table ) -+ { -+ page_unlock(gl1pg); -+ put_page(gl1pg); -+ goto out; -+ } -+ -+ rc = mod_l1_entry(pl1e, val, gl1mfn, 0) ? 0 : -EINVAL; - -+ page_unlock(gl1pg); -+ put_page(gl1pg); -+ -+ out: - if ( pl1e ) - guest_unmap_l1e(v, pl1e); -- pl1e = NULL; - - process_deferred_ops(); - -@@ -4122,15 +4145,25 @@ int ptwr_do_page_fault(struct vcpu *v, u - - /* Attempt to read the PTE that maps the VA being accessed. */ - guest_get_eff_l1e(v, addr, &pte); -- page = l1e_get_page(pte); - - /* We are looking only for read-only mappings of p.t. pages. */ - if ( ((l1e_get_flags(pte) & (_PAGE_PRESENT|_PAGE_RW)) != _PAGE_PRESENT) || -- !mfn_valid(l1e_get_pfn(pte)) || -- ((page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table) || -- ((page->u.inuse.type_info & PGT_count_mask) == 0) || -- (page_get_owner(page) != d) ) -+ !get_page_from_pagenr(l1e_get_pfn(pte), d) ) -+ goto bail; -+ -+ page = l1e_get_page(pte); -+ if ( !page_lock(page) ) -+ { -+ put_page(page); -+ goto bail; -+ } -+ -+ if ( (page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table ) -+ { -+ page_unlock(page); -+ put_page(page); - goto bail; -+ } - - ptwr_ctxt.ctxt.regs = regs; - ptwr_ctxt.ctxt.force_writeback = 0; -@@ -4139,9 +4172,11 @@ int ptwr_do_page_fault(struct vcpu *v, u - ptwr_ctxt.cr2 = addr; - ptwr_ctxt.pte = pte; - -- page_lock(page); - rc = x86_emulate(&ptwr_ctxt.ctxt, &ptwr_emulate_ops); -+ - page_unlock(page); -+ put_page(page); -+ - if ( rc == X86EMUL_UNHANDLEABLE ) - goto bail; - ---- a/xen/arch/x86/mm/shadow/common.c -+++ b/xen/arch/x86/mm/shadow/common.c -@@ -1685,9 +1685,6 @@ shadow_free_p2m_page(struct domain *d, s - /* Free should not decrement domain's total allocation, since - * these pages were allocated without an owner. */ - page_set_owner(pg, NULL); --#if defined(__x86_64__) -- spin_lock_init(&pg->lock); --#endif - free_domheap_pages(pg, 0); - d->arch.paging.shadow.p2m_pages--; - perfc_decr(shadow_alloc_count); -@@ -1801,16 +1798,7 @@ static unsigned int sh_set_allocation(st - * may get overwritten, so need to clear it here. - */ - for ( j = 0; j < 1U << order; j++ ) -- { - page_set_owner(&((struct page_info *)sp)[j], NULL); --#if defined(__x86_64__) -- /* -- * Re-instate lock field which we overwrite with shadow_page_info. -- * This was safe, since the lock is only used on guest pages. -- */ -- spin_lock_init(&((struct page_info *)sp)[j].lock); --#endif -- } - d->arch.paging.shadow.free_pages -= 1 << order; - d->arch.paging.shadow.total_pages -= 1 << order; - free_domheap_pages((struct page_info *)sp, order); ---- a/xen/include/asm-x86/mm.h -+++ b/xen/include/asm-x86/mm.h -@@ -46,10 +46,6 @@ struct page_info - - } u; - --#if defined(__x86_64__) -- spinlock_t lock; --#endif -- - union { - /* - * Timestamp from 'TLB clock', used to avoid extra safety flushes. -@@ -127,27 +123,25 @@ struct page_info - /* Has this page been *partially* validated for use as its current type? */ - #define _PGT_partial PG_shift(7) - #define PGT_partial PG_mask(1, 7) -+ /* Page is locked? */ -+#define _PGT_locked PG_shift(8) -+#define PGT_locked PG_mask(1, 8) - - /* Count of uses of this frame as its current type. */ --#define PGT_count_width PG_shift(7) -+#define PGT_count_width PG_shift(8) - #define PGT_count_mask ((1UL<domain)) ) -- unmap_domain_page(p); -+ unmap_domain_page(p); - } - - /* Read the guest's l1e that maps this address. */ diff --git a/19151-xend-class-dereg.patch b/19151-xend-class-dereg.patch deleted file mode 100644 index 0c394f4..0000000 --- a/19151-xend-class-dereg.patch +++ /dev/null @@ -1,14 +0,0 @@ -Index: xen-3.3.1-testing/tools/python/xen/xend/XendAPIStore.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendAPIStore.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendAPIStore.py -@@ -33,7 +33,8 @@ def register(uuid, type, inst): - - def deregister(uuid, type): - old = get(uuid, type) -- del __classes[(uuid, type)] -+ if old is not None: -+ del __classes[(uuid, type)] - return old - - def get(uuid, type): diff --git a/19152-xm-man-page.patch b/19152-xm-man-page.patch deleted file mode 100644 index 9c2b8d1..0000000 --- a/19152-xm-man-page.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: xen-3.3.1-testing/docs/man/xm.pod.1 -=================================================================== ---- xen-3.3.1-testing.orig/docs/man/xm.pod.1 -+++ xen-3.3.1-testing/docs/man/xm.pod.1 -@@ -67,6 +67,8 @@ The attached console will perform much l - so running curses based interfaces over the console B. Vi tends to get very odd when using it over this interface. - -+Use the key combination Ctrl+] to detach the domain console. -+ - =item B I [I] [I].. - - The create subcommand requires a config file and can optionally take a diff --git a/19153-xm-noxen-error.patch b/19153-xm-noxen-error.patch deleted file mode 100644 index 2392a5e..0000000 --- a/19153-xm-noxen-error.patch +++ /dev/null @@ -1,17 +0,0 @@ -Index: xen-3.3.1-testing/tools/python/xen/xm/main.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xm/main.py -+++ xen-3.3.1-testing/tools/python/xen/xm/main.py -@@ -58,7 +58,11 @@ from xen.util.acmpolicy import ACM_LABEL - import XenAPI - - import xen.lowlevel.xc --xc = xen.lowlevel.xc.xc() -+try: -+ xc = xen.lowlevel.xc.xc() -+except Exception, ex: -+ print >>sys.stderr, ("Is xen kernel running?") -+ sys.exit(1) - - import inspect - from xen.xend import XendOptions diff --git a/19154-snoop-control.patch b/19154-snoop-control.patch deleted file mode 100644 index f03d099..0000000 --- a/19154-snoop-control.patch +++ /dev/null @@ -1,68 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1233748806 0 -# Node ID 6058887e55d7096f8b32c1f0576c601b080dc879 -# Parent 7e15ccb7bbd88e550ada6a6b86196cc4e5d880b6 -vtd: Add a boot parameter option for snoop control capability for VT-d. -The default is to use snoop control. - -Signed-off-by: Xin, Xiaohui - -Index: xen-3.3.1-testing/xen/drivers/passthrough/iommu.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/iommu.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/iommu.c -@@ -34,6 +34,8 @@ int amd_iov_detect(void); - * no-pv Disable IOMMU for PV domains (default) - * force|required Don't boot unless IOMMU is enabled - * passthrough Bypass VT-d translation for Dom0 -+ * snoop Utilize the snoop control for IOMMU (default) -+ * no-snoop Dont utilize the snoop control for IOMMU - */ - custom_param("iommu", parse_iommu_param); - int iommu_enabled = 0; -@@ -46,6 +48,7 @@ static void __init parse_iommu_param(cha - { - char *ss; - iommu_enabled = 1; -+ iommu_snoop = 1; - - do { - ss = strchr(s, ','); -@@ -63,6 +66,10 @@ static void __init parse_iommu_param(cha - force_iommu = 1; - else if ( !strcmp(s, "passthrough") ) - iommu_passthrough = 1; -+ else if ( !strcmp(s, "snoop") ) -+ iommu_snoop = 1; -+ else if ( !strcmp(s, "no-snoop") ) -+ iommu_snoop = 0; - - s = ss + 1; - } while ( ss ); -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/dmar.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/dmar.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/dmar.c -@@ -530,13 +530,15 @@ int acpi_dmar_init(void) - /* Giving that all devices within guest use same io page table, - * enable snoop control only if all VT-d engines support it. - */ -- iommu_snoop = 1; -- for_each_drhd_unit ( drhd ) -+ if ( iommu_snoop ) - { -- iommu = drhd->iommu; -- if ( !ecap_snp_ctl(iommu->ecap) ) { -- iommu_snoop = 0; -- break; -+ for_each_drhd_unit ( drhd ) -+ { -+ iommu = drhd->iommu; -+ if ( !ecap_snp_ctl(iommu->ecap) ) { -+ iommu_snoop = 0; -+ break; -+ } - } - } - diff --git a/19198-fix-snoop.patch b/19198-fix-snoop.patch deleted file mode 100644 index a1374a9..0000000 --- a/19198-fix-snoop.patch +++ /dev/null @@ -1,85 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1234436057 0 -# Node ID 32b15413749255e0cd518f25d9202759586dcb27 -# Parent 94e12fa57816c26f8b76061f17c33928be202c85 -vtd: move the snoop control detection out of acpi_dmar_init() -where the capability value is not initialized thus we may -get random value. - -Signed-off-by: Xin, Xiaohui - -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/dmar.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/dmar.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/dmar.c -@@ -509,8 +509,6 @@ static int __init acpi_parse_dmar(struct - int acpi_dmar_init(void) - { - int rc; -- struct acpi_drhd_unit *drhd; -- struct iommu *iommu; - - rc = -ENODEV; - if ( force_iommu ) -@@ -527,22 +525,7 @@ int acpi_dmar_init(void) - if ( list_empty(&acpi_drhd_units) ) - goto fail; - -- /* Giving that all devices within guest use same io page table, -- * enable snoop control only if all VT-d engines support it. -- */ -- if ( iommu_snoop ) -- { -- for_each_drhd_unit ( drhd ) -- { -- iommu = drhd->iommu; -- if ( !ecap_snp_ctl(iommu->ecap) ) { -- iommu_snoop = 0; -- break; -- } -- } -- } -- -- printk("Intel VT-d has been enabled, snoop_control=%d.\n", iommu_snoop); -+ printk("Intel VT-d has been enabled\n"); - - return 0; - -Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/iommu.c -+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.c -@@ -1813,6 +1813,24 @@ int intel_vtd_setup(void) - if ( init_vtd_hw() ) - goto error; - -+ /* Giving that all devices within guest use same io page table, -+ * enable snoop control only if all VT-d engines support it. -+ */ -+ -+ if ( iommu_snoop ) -+ { -+ for_each_drhd_unit ( drhd ) -+ { -+ iommu = drhd->iommu; -+ if ( !ecap_snp_ctl(iommu->ecap) ) { -+ iommu_snoop = 0; -+ break; -+ } -+ } -+ } -+ -+ printk("Intel VT-d snoop control %sabled\n", iommu_snoop ? "en" : "dis"); -+ - register_keyhandler('V', dump_iommu_info, "dump iommu info"); - - return 0; -@@ -1821,6 +1839,7 @@ int intel_vtd_setup(void) - for_each_drhd_unit ( drhd ) - iommu_free(drhd); - vtd_enabled = 0; -+ iommu_snoop = 0; - return -ENOMEM; - } - diff --git a/32on64-extra-mem.patch b/32on64-extra-mem.patch index f35e668..6d40a91 100644 --- a/32on64-extra-mem.patch +++ b/32on64-extra-mem.patch @@ -1,13 +1,13 @@ -Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -2273,7 +2273,7 @@ class XendDomainInfo: +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py +@@ -2559,7 +2559,7 @@ class XendDomainInfo: vtd_mem = ((vtd_mem + 1023) / 1024) * 1024 # Make sure there's enough RAM available for the domain -- balloon.free(memory + shadow + vtd_mem) -+ balloon.free(memory + shadow + vtd_mem + 512) +- balloon.free(memory + shadow + vtd_mem, self) ++ balloon.free(memory + shadow + vtd_mem + 512, self) # Set up the shadow memory shadow_cur = xc.shadow_mem_control(self.domid, shadow / 1024) diff --git a/blktap-error-handling.patch b/blktap-error-handling.patch deleted file mode 100644 index e7b1e89..0000000 --- a/blktap-error-handling.patch +++ /dev/null @@ -1,248 +0,0 @@ -Index: xen-3.3.1-testing/tools/blktap/drivers/blktapctrl.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/blktap/drivers/blktapctrl.c -+++ xen-3.3.1-testing/tools/blktap/drivers/blktapctrl.c -@@ -662,9 +662,6 @@ static int blktapctrl_new_blkif(blkif_t - - DPRINTF("Received a poll for a new vbd\n"); - if ( ((blk=blkif->info) != NULL) && (blk->params != NULL) ) { -- if (blktap_interface_create(ctlfd, &major, &minor, blkif) < 0) -- return -1; -- - if (test_path(blk->params, &ptr, &type, &exist, &use_ioemu) != 0) { - DPRINTF("Error in blktap device string(%s).\n", - blk->params); -@@ -693,10 +690,6 @@ static int blktapctrl_new_blkif(blkif_t - blkif->fds[WRITE] = exist->fds[WRITE]; - } - -- add_disktype(blkif, type); -- blkif->major = major; -- blkif->minor = minor; -- - image = (image_t *)malloc(sizeof(image_t)); - blkif->prv = (void *)image; - blkif->ops = &tapdisk_ops; -@@ -720,11 +713,18 @@ static int blktapctrl_new_blkif(blkif_t - goto fail; - } - -+ if (blktap_interface_create(ctlfd, &major, &minor, blkif) < 0) -+ return -1; -+ -+ blkif->major = major; -+ blkif->minor = minor; -+ -+ add_disktype(blkif, type); -+ - } else return -1; - - return 0; - fail: -- ioctl(ctlfd, BLKTAP_IOCTL_FREEINTF, minor); - return -EINVAL; - } - -Index: xen-3.3.1-testing/tools/blktap/lib/xenbus.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/blktap/lib/xenbus.c -+++ xen-3.3.1-testing/tools/blktap/lib/xenbus.c -@@ -48,6 +48,7 @@ - #include - #include - #include -+#include - #include "blktaplib.h" - #include "list.h" - #include "xs_api.h" -@@ -149,6 +150,130 @@ static int backend_remove(struct xs_hand - return 0; - } - -+static int check_sharing(struct xs_handle *h, struct backend_info *be) -+{ -+ char *dom_uuid; -+ char *cur_dom_uuid; -+ char *path; -+ char *mode; -+ char *params; -+ char **domains; -+ char **devices; -+ int i, j; -+ unsigned int num_dom, num_dev; -+ blkif_info_t *info; -+ int ret = 0; -+ -+ /* If the mode contains '!' or doesn't contain 'w' don't check anything */ -+ xs_gather(h, be->backpath, "mode", NULL, &mode, NULL); -+ if (strchr(mode, '!')) -+ goto out; -+ if (strchr(mode, 'w') == NULL) -+ goto out; -+ -+ /* Get the UUID of the domain we want to attach to */ -+ if (asprintf(&path, "/local/domain/%ld", be->frontend_id) == -1) -+ goto fail; -+ xs_gather(h, path, "vm", NULL, &dom_uuid, NULL); -+ free(path); -+ -+ /* Iterate through the devices of all VMs */ -+ domains = xs_directory(h, XBT_NULL, "backend/tap", &num_dom); -+ if (domains == NULL) -+ num_dom = 0; -+ -+ for (i = 0; !ret && (i < num_dom); i++) { -+ -+ /* If it's the same VM, no action needed */ -+ if (asprintf(&path, "/local/domain/%s", domains[i]) == -1) { -+ ret = -1; -+ break; -+ } -+ xs_gather(h, path, "vm", NULL, &cur_dom_uuid, NULL); -+ free(path); -+ -+ if (!strcmp(cur_dom_uuid, dom_uuid)) { -+ free(cur_dom_uuid); -+ continue; -+ } -+ -+ /* Check the devices */ -+ if (asprintf(&path, "backend/tap/%s", domains[i]) == -1) { -+ ret = -1; -+ free(cur_dom_uuid); -+ break; -+ } -+ devices = xs_directory(h, XBT_NULL, path, &num_dev); -+ if (devices == NULL) -+ num_dev = 0; -+ free(path); -+ -+ for (j = 0; !ret && (j < num_dev); j++) { -+ if (asprintf(&path, "backend/tap/%s/%s", domains[i], devices[j]) == -1) { -+ ret = -1; -+ break; -+ } -+ xs_gather(h, path, "params", NULL, ¶ms, NULL); -+ free(path); -+ -+ info = be->blkif->info; -+ if (strcmp(params, info->params)) { -+ ret = -1; -+ } -+ -+ free(params); -+ } -+ -+ free(cur_dom_uuid); -+ free(devices); -+ } -+ free(domains); -+ free(dom_uuid); -+ goto out; -+ -+fail: -+ ret = -1; -+out: -+ free(mode); -+ return ret; -+} -+ -+static int check_image(struct xs_handle *h, struct backend_info *be, -+ const char** errmsg) -+{ -+ const char *path; -+ int mode; -+ blkif_t *blkif = be->blkif; -+ blkif_info_t *info = blkif->info; -+ -+ /* Strip off the image type */ -+ path = strchr(info->params, ':'); -+ if (path == NULL) -+ path = info->params; -+ else -+ path++; -+ -+ /* Check if the image exists and access is permitted */ -+ mode = R_OK; -+ if (!be->readonly) -+ mode |= W_OK; -+ if (access(path, mode)) { -+ if (errno == ENOENT) -+ *errmsg = "File not found."; -+ else -+ *errmsg = "Insufficient file permissions."; -+ return -1; -+ } -+ -+ /* Check that the image is not attached to a different VM */ -+ if (check_sharing(h, be)) { -+ *errmsg = "File already in use by other domain"; -+ return -1; -+ } -+ -+ return 0; -+} -+ - static void ueblktap_setup(struct xs_handle *h, char *bepath) - { - struct backend_info *be; -@@ -156,6 +281,7 @@ static void ueblktap_setup(struct xs_han - int len, er, deverr; - long int pdev = 0, handle; - blkif_info_t *blk; -+ const char* errmsg = NULL; - - be = be_lookup_be(bepath); - if (be == NULL) -@@ -211,6 +337,9 @@ static void ueblktap_setup(struct xs_han - be->pdev = pdev; - } - -+ if (check_image(h, be, &errmsg)) -+ goto fail; -+ - er = blkif_init(be->blkif, handle, be->pdev, be->readonly); - if (er != 0) { - DPRINTF("Unable to open device %s\n",blk->params); -@@ -246,12 +375,21 @@ static void ueblktap_setup(struct xs_han - } - - be->blkif->state = CONNECTED; -+ xs_printf(h, be->backpath, "hotplug-status", "connected"); -+ - DPRINTF("[SETUP] Complete\n\n"); - goto close; - - fail: -- if ( (be != NULL) && (be->blkif != NULL) ) -+ if (be) { -+ if (errmsg == NULL) -+ errmsg = "Setting up the backend failed. See the log " -+ "files in /var/log/xen/ for details."; -+ xs_printf(h, be->backpath, "hotplug-error", errmsg); -+ xs_printf(h, be->backpath, "hotplug-status", "error"); -+ - backend_remove(h, be); -+ } - close: - if (path) - free(path); -@@ -286,7 +424,8 @@ static void ueblktap_probe(struct xs_han - len = strsep_len(bepath, '/', 7); - if (len < 0) - goto free_be; -- bepath[len] = '\0'; -+ if (bepath[len] != '\0') -+ goto free_be; - - be = malloc(sizeof(*be)); - if (!be) { -Index: xen-3.3.1-testing/tools/examples/xen-backend.rules -=================================================================== ---- xen-3.3.1-testing.orig/tools/examples/xen-backend.rules -+++ xen-3.3.1-testing/tools/examples/xen-backend.rules -@@ -1,4 +1,3 @@ --SUBSYSTEM=="xen-backend", KERNEL=="tap*", RUN+="/etc/xen/scripts/blktap $env{ACTION}" - SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xen/scripts/block $env{ACTION}" - SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm $env{ACTION}" - SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} online" diff --git a/blktap-ioemu-close-fix.patch b/blktap-ioemu-close-fix.patch deleted file mode 100644 index f171d65..0000000 --- a/blktap-ioemu-close-fix.patch +++ /dev/null @@ -1,54 +0,0 @@ -Index: xen-3.3.1-testing/tools/blktap/drivers/blktapctrl.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/blktap/drivers/blktapctrl.c -+++ xen-3.3.1-testing/tools/blktap/drivers/blktapctrl.c -@@ -221,6 +221,28 @@ static void add_disktype(blkif_t *blkif, - entry->pprev = pprev; - } - -+static int qemu_instance_has_disks(int domid) -+{ -+ int i; -+ int count = 0; -+ driver_list_entry_t *entry; -+ -+ for (i = 0; i < MAX_DISK_TYPES; i++) { -+ entry = active_disks[i]; -+ while (entry) { -+#ifdef ALWAYS_USE_IOEMU -+ if (entry->blkif->domid == domid) -+#else -+ if ((entry->blkif->domid == domid) && dtypes[i]->use_ioemu) -+#endif -+ count++; -+ entry = entry->next; -+ } -+ } -+ -+ return (count != 0); -+} -+ - static int del_disktype(blkif_t *blkif) - { - driver_list_entry_t *entry, **pprev; -@@ -245,8 +267,20 @@ static int del_disktype(blkif_t *blkif) - DPRINTF("DEL_DISKTYPE: Freeing entry\n"); - free(entry); - -+#ifdef ALWAYS_USE_IOEMU -+ return !qemu_instance_has_disks(blkif->domid); -+#else -+ /* -+ * When using ioemu, all disks of one VM are connected to the same -+ * qemu-dm instance. We may close the file handle only if there is -+ * no other disk left for this domain. -+ */ -+ if (dtypes[type]->use_ioemu) -+ return !qemu_instance_has_disks(blkif->domid); -+ - /* Caller should close() if no single controller, or list is empty. */ - return (!dtypes[type]->single_handler || (active_disks[type] == NULL)); -+#endif - } - - static int write_msg(int fd, int msgtype, void *ptr, void *ptr2) diff --git a/blktap-pv-cdrom.patch b/blktap-pv-cdrom.patch index d9ebf0d..5b6e759 100644 --- a/blktap-pv-cdrom.patch +++ b/blktap-pv-cdrom.patch @@ -1,5 +1,7 @@ +Index: xen-3.4.0-testing/tools/blktap/drivers/block-cdrom.c +=================================================================== --- /dev/null -+++ b/tools/blktap/drivers/block-cdrom.c ++++ xen-3.4.0-testing/tools/blktap/drivers/block-cdrom.c @@ -0,0 +1,536 @@ +/* block-cdrom.c + * @@ -537,8 +539,10 @@ + .td_get_parent_id = tdcdrom_get_parent_id, + .td_validate_parent = tdcdrom_validate_parent +}; +Index: xen-3.4.0-testing/xen/include/public/io/cdromif.h +=================================================================== --- /dev/null -+++ b/xen/include/public/io/cdromif.h ++++ xen-3.4.0-testing/xen/include/public/io/cdromif.h @@ -0,0 +1,120 @@ +/****************************************************************************** + * cdromif.h @@ -660,10 +664,12 @@ + sizeof(struct vcd_generic_command) - sizeof(struct request_sense)) + +#endif ---- a/tools/blktap/drivers/Makefile -+++ b/tools/blktap/drivers/Makefile -@@ -24,8 +24,9 @@ CRYPT_LIB := -lcrypto - $(warning *** libgcrypt not installed: falling back to libcrypto ***) +Index: xen-3.4.0-testing/tools/blktap/drivers/Makefile +=================================================================== +--- xen-3.4.0-testing.orig/tools/blktap/drivers/Makefile ++++ xen-3.4.0-testing/tools/blktap/drivers/Makefile +@@ -20,8 +20,9 @@ CRYPT_LIB := -lcrypto + $(warning === libgcrypt not installed: falling back to libcrypto ===) endif -LDFLAGS_blktapctrl := $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenstore) -L../lib -lblktap @@ -674,7 +680,7 @@ BLK-OBJS-y := block-aio.o BLK-OBJS-y += block-sync.o -@@ -33,6 +34,7 @@ BLK-OBJS-y += block-vmdk.o +@@ -29,6 +30,7 @@ BLK-OBJS-y += block-vmdk.o BLK-OBJS-y += block-ram.o BLK-OBJS-y += block-qcow.o BLK-OBJS-y += block-qcow2.o @@ -682,8 +688,10 @@ BLK-OBJS-y += aes.o BLK-OBJS-y += tapaio.o BLK-OBJS-$(CONFIG_Linux) += blk_linux.o ---- a/tools/blktap/drivers/tapdisk.h -+++ b/tools/blktap/drivers/tapdisk.h +Index: xen-3.4.0-testing/tools/blktap/drivers/tapdisk.h +=================================================================== +--- xen-3.4.0-testing.orig/tools/blktap/drivers/tapdisk.h ++++ xen-3.4.0-testing/tools/blktap/drivers/tapdisk.h @@ -137,6 +137,9 @@ struct tap_disk { int (*td_get_parent_id) (struct disk_driver *dd, struct disk_id *id); int (*td_validate_parent)(struct disk_driver *dd, @@ -702,7 +710,7 @@ /*Define Individual Disk Parameters here */ -@@ -240,6 +244,17 @@ static disk_info_t ioemu_disk = { +@@ -229,6 +233,17 @@ static disk_info_t qcow2_disk = { #endif }; @@ -720,26 +728,30 @@ /*Main disk info array */ static disk_info_t *dtypes[] = { &aio_disk, -@@ -249,6 +264,7 @@ static disk_info_t *dtypes[] = { +@@ -237,6 +252,7 @@ static disk_info_t *dtypes[] = { + &ram_disk, &qcow_disk, &qcow2_disk, - &ioemu_disk, + &cdrom_disk, }; typedef struct driver_list_entry { ---- a/tools/blktap/lib/blktaplib.h -+++ b/tools/blktap/lib/blktaplib.h -@@ -221,6 +221,7 @@ typedef struct msg_pid { +Index: xen-3.4.0-testing/tools/blktap/lib/blktaplib.h +=================================================================== +--- xen-3.4.0-testing.orig/tools/blktap/lib/blktaplib.h ++++ xen-3.4.0-testing/tools/blktap/lib/blktaplib.h +@@ -220,6 +220,7 @@ typedef struct msg_pid { + #define DISK_TYPE_RAM 3 #define DISK_TYPE_QCOW 4 #define DISK_TYPE_QCOW2 5 - #define DISK_TYPE_IOEMU 6 -+#define DISK_TYPE_CDROM 7 ++#define DISK_TYPE_CDROM 6 /* xenstore/xenbus: */ #define DOMNAME "Domain-0" ---- a/xen/include/public/io/blkif.h -+++ b/xen/include/public/io/blkif.h +Index: xen-3.4.0-testing/xen/include/public/io/blkif.h +=================================================================== +--- xen-3.4.0-testing.orig/xen/include/public/io/blkif.h ++++ xen-3.4.0-testing/xen/include/public/io/blkif.h @@ -76,6 +76,10 @@ * "feature-flush-cache" node! */ @@ -751,8 +763,10 @@ /* * Maximum scatter/gather segments per request. ---- a/tools/blktap/drivers/tapdisk.c -+++ b/tools/blktap/drivers/tapdisk.c +Index: xen-3.4.0-testing/tools/blktap/drivers/tapdisk.c +=================================================================== +--- xen-3.4.0-testing.orig/tools/blktap/drivers/tapdisk.c ++++ xen-3.4.0-testing/tools/blktap/drivers/tapdisk.c @@ -735,6 +735,22 @@ static void get_io_request(struct td_sta goto out; } @@ -776,16 +790,15 @@ default: DPRINTF("Unknown block operation\n"); break; ---- a/tools/python/xen/xend/server/BlktapController.py -+++ b/tools/python/xen/xend/server/BlktapController.py -@@ -14,8 +14,8 @@ blktap_disk_types = [ +Index: xen-3.4.0-testing/tools/python/xen/xend/server/BlktapController.py +=================================================================== +--- xen-3.4.0-testing.orig/tools/python/xen/xend/server/BlktapController.py ++++ xen-3.4.0-testing/tools/python/xen/xend/server/BlktapController.py +@@ -14,6 +14,7 @@ blktap_disk_types = [ 'ram', 'qcow', 'qcow2', -- -- 'ioemu' -+ 'ioemu', + 'cdrom', - ] - class BlktapController(BlkifController): + 'ioemu', + 'tapdisk', diff --git a/blktap.patch b/blktap.patch index 3bca351..911167f 100644 --- a/blktap.patch +++ b/blktap.patch @@ -1,11 +1,11 @@ bug #239173 bug #242953 -Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -2618,7 +2618,7 @@ class XendDomainInfo: +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py +@@ -2939,7 +2939,7 @@ class XendDomainInfo: (fn, BOOTLOADER_LOOPBACK_DEVICE)) vbd = { @@ -14,26 +14,26 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py 'device': BOOTLOADER_LOOPBACK_DEVICE, } -Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c +Index: xen-3.4.0-testing/tools/ioemu-remote/xenstore.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/xenstore.c -+++ xen-3.3.1-testing/tools/ioemu-remote/xenstore.c -@@ -151,9 +151,9 @@ void xenstore_parse_domain_config(int hv +--- xen-3.4.0-testing.orig/tools/ioemu-remote/xenstore.c ++++ xen-3.4.0-testing/tools/ioemu-remote/xenstore.c +@@ -311,9 +311,9 @@ void xenstore_parse_domain_config(int hv { - char **e = NULL; - char *buf = NULL, *path; + char **e_danger = NULL; + char *buf = NULL; - char *fpath = NULL, *bpath = NULL, + char *fpath = NULL, *bpath = NULL, *btype = NULL, - *dev = NULL, *params = NULL, *type = NULL, *drv = NULL; + *dev = NULL, *params = NULL, *drv = NULL; - int i, any_hdN = 0, ret; + int i, any_hdN = 0, ret, is_tap; unsigned int len, num, hd_index, pci_devid = 0; BlockDriverState *bs; BlockDriver *format; -@@ -188,6 +188,14 @@ void xenstore_parse_domain_config(int hv - bpath = xs_read(xsh, XBT_NULL, buf, &len); +@@ -353,6 +353,14 @@ void xenstore_parse_domain_config(int hv + e_danger[i]); if (bpath == NULL) - continue; + continue; + /* check to see if type is tap or not */ + if (pasprintf(&buf, "%s/type", bpath) == -1) + continue; @@ -45,11 +45,11 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c /* read the name of the device */ if (pasprintf(&buf, "%s/dev", bpath) == -1) continue; -@@ -432,6 +440,7 @@ void xenstore_parse_domain_config(int hv - free(type); +@@ -662,6 +670,7 @@ void xenstore_parse_domain_config(int hv + free(danger_type); free(params); free(dev); + free(btype); free(bpath); free(buf); - free(path); + free(danger_buf); diff --git a/blktapctrl-default-to-ioemu.patch b/blktapctrl-default-to-ioemu.patch index 0995aa9..07eed79 100644 --- a/blktapctrl-default-to-ioemu.patch +++ b/blktapctrl-default-to-ioemu.patch @@ -1,211 +1,49 @@ -Index: xen-3.3.1-testing/tools/blktap/drivers/blktapctrl.c +Index: xen-3.4.0-testing/tools/blktap/drivers/tapdisk.h =================================================================== ---- xen-3.3.1-testing.orig/tools/blktap/drivers/blktapctrl.c -+++ xen-3.3.1-testing/tools/blktap/drivers/blktapctrl.c -@@ -65,6 +65,8 @@ - #define MAX_RAND_VAL 0xFFFF - #define MAX_ATTEMPTS 10 - -+#undef ALWAYS_USE_IOEMU -+ - int run = 1; - int max_timeout = MAX_TIMEOUT; - int ctlfd = 0; -@@ -148,7 +150,8 @@ static int get_tapdisk_pid(blkif_t *blki - * return 0 on success, -1 on error. - */ - --static int test_path(char *path, char **dev, int *type, blkif_t **blkif) -+static int test_path(char *path, char **dev, int *type, blkif_t **blkif, -+ int* use_ioemu) - { - char *ptr, handle[10]; - int i, size, found = 0; -@@ -174,6 +177,7 @@ static int test_path(char *path, char ** - } - - if (found) { -+ *use_ioemu = dtypes[i]->use_ioemu; - *type = dtypes[i]->idnum; - - if (dtypes[i]->single_handler == 1) { -@@ -185,6 +189,7 @@ static int test_path(char *path, char ** - *blkif = active_disks[dtypes[i] - ->idnum]->blkif; - } -+ - return 0; - } - } -@@ -474,6 +479,7 @@ static int launch_tapdisk_provider(char - return child; - } - -+#ifndef ALWAYS_USE_IOEMU - static int launch_tapdisk(char *wrctldev, char *rdctldev) - { - char *argv[] = { "tapdisk", wrctldev, rdctldev, NULL }; -@@ -483,6 +489,7 @@ static int launch_tapdisk(char *wrctldev - - return 0; - } -+#endif - - static int launch_tapdisk_ioemu(void) - { -@@ -505,7 +512,8 @@ static int connect_qemu(blkif_t *blkif, - static int tapdisk_ioemu_pid = 0; - static int dom0_readfd = 0; - static int dom0_writefd = 0; -- -+ int refresh_pid = 0; -+ - if (asprintf(&rdctldev, BLKTAP_CTRL_DIR "/qemu-read-%d", domid) < 0) - return -1; - -@@ -524,15 +532,23 @@ static int connect_qemu(blkif_t *blkif, - if (tapdisk_ioemu_pid == 0 || kill(tapdisk_ioemu_pid, 0)) { - /* No device model and tapdisk-ioemu doesn't run yet */ - DPRINTF("Launching tapdisk-ioemu\n"); -- tapdisk_ioemu_pid = launch_tapdisk_ioemu(); -+ launch_tapdisk_ioemu(); - - dom0_readfd = open_ctrl_socket(wrctldev); - dom0_writefd = open_ctrl_socket(rdctldev); -+ -+ refresh_pid = 1; - } - - DPRINTF("Using tapdisk-ioemu connection\n"); - blkif->fds[READ] = dom0_readfd; - blkif->fds[WRITE] = dom0_writefd; -+ -+ if (refresh_pid) { -+ get_tapdisk_pid(blkif); -+ tapdisk_ioemu_pid = blkif->tappid; -+ } -+ - } else if (access(rdctldev, R_OK | W_OK) == 0) { - /* Use existing pipe to the device model */ - DPRINTF("Using qemu-dm connection\n"); -@@ -554,6 +570,7 @@ static int connect_qemu(blkif_t *blkif, - return 0; - } - -+#ifndef ALWAYS_USE_IOEMU - /* Launch tapdisk instance */ - static int connect_tapdisk(blkif_t *blkif, int minor) - { -@@ -597,6 +614,7 @@ fail: - - return ret; - } -+#endif - - static int blktapctrl_new_blkif(blkif_t *blkif) - { -@@ -606,13 +624,14 @@ static int blktapctrl_new_blkif(blkif_t - image_t *image; - blkif_t *exist = NULL; - static uint16_t next_cookie = 0; -+ int use_ioemu; - - DPRINTF("Received a poll for a new vbd\n"); - if ( ((blk=blkif->info) != NULL) && (blk->params != NULL) ) { - if (blktap_interface_create(ctlfd, &major, &minor, blkif) < 0) - return -1; - -- if (test_path(blk->params, &ptr, &type, &exist) != 0) { -+ if (test_path(blk->params, &ptr, &type, &exist, &use_ioemu) != 0) { - DPRINTF("Error in blktap device string(%s).\n", - blk->params); - goto fail; -@@ -621,13 +640,18 @@ static int blktapctrl_new_blkif(blkif_t - blkif->cookie = next_cookie++; - - if (!exist) { -- if (type == DISK_TYPE_IOEMU) { -+#ifdef ALWAYS_USE_IOEMU -+ if (connect_qemu(blkif, blkif->domid)) -+ goto fail; -+#else -+ if (use_ioemu) { - if (connect_qemu(blkif, blkif->domid)) - goto fail; - } else { - if (connect_tapdisk(blkif, minor)) - goto fail; - } -+#endif - - } else { - DPRINTF("Process exists!\n"); -Index: xen-3.3.1-testing/tools/blktap/drivers/tapdisk.h -=================================================================== ---- xen-3.3.1-testing.orig/tools/blktap/drivers/tapdisk.h -+++ xen-3.3.1-testing/tools/blktap/drivers/tapdisk.h -@@ -145,6 +145,8 @@ typedef struct disk_info { - char handle[10]; /* xend handle, e.g. 'ram' */ - int single_handler; /* is there a single controller for all */ - /* instances of disk type? */ -+ int use_ioemu; /* backend provider: 0 = tapdisk; 1 = ioemu */ -+ - #ifdef TAPDISK - struct tap_disk *drv; - #endif -@@ -166,6 +168,7 @@ static disk_info_t aio_disk = { +--- xen-3.4.0-testing.orig/tools/blktap/drivers/tapdisk.h ++++ xen-3.4.0-testing/tools/blktap/drivers/tapdisk.h +@@ -168,7 +168,7 @@ static disk_info_t aio_disk = { "raw image (aio)", "aio", 0, +- 0, + 1, #ifdef TAPDISK &tapdisk_aio, #endif -@@ -176,6 +179,7 @@ static disk_info_t sync_disk = { +@@ -179,7 +179,7 @@ static disk_info_t sync_disk = { "raw image (sync)", "sync", 0, +- 0, + 1, #ifdef TAPDISK &tapdisk_sync, #endif -@@ -186,6 +190,7 @@ static disk_info_t vmdk_disk = { +@@ -190,7 +190,7 @@ static disk_info_t vmdk_disk = { "vmware image (vmdk)", "vmdk", 1, +- 0, + 1, #ifdef TAPDISK &tapdisk_vmdk, #endif -@@ -196,6 +201,7 @@ static disk_info_t ram_disk = { - "ramdisk image (ram)", - "ram", - 1, -+ 0, - #ifdef TAPDISK - &tapdisk_ram, - #endif -@@ -206,6 +212,7 @@ static disk_info_t qcow_disk = { +@@ -212,7 +212,7 @@ static disk_info_t qcow_disk = { "qcow disk (qcow)", "qcow", 0, +- 0, + 1, #ifdef TAPDISK &tapdisk_qcow, #endif -@@ -216,6 +223,7 @@ static disk_info_t qcow2_disk = { +@@ -223,7 +223,7 @@ static disk_info_t qcow2_disk = { "qcow2 disk (qcow2)", "qcow2", 0, +- 0, + 1, #ifdef TAPDISK &tapdisk_qcow2, #endif -@@ -226,6 +234,7 @@ static disk_info_t ioemu_disk = { - "ioemu disk", - "ioemu", - 1, -+ 1, - #ifdef TAPDISK - NULL - #endif diff --git a/block-flags.diff b/block-flags.diff index c86ccfc..69a666f 100644 --- a/block-flags.diff +++ b/block-flags.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/examples/block +Index: xen-3.4.0-testing/tools/hotplug/Linux/block =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/block -+++ xen-3.3.1-testing/tools/examples/block +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/block ++++ xen-3.4.0-testing/tools/hotplug/Linux/block @@ -225,11 +225,14 @@ case "$command" in ;; diff --git a/block-iscsi b/block-iscsi index 7958b63..6f14d7f 100644 --- a/block-iscsi +++ b/block-iscsi @@ -23,8 +23,7 @@ find_sdev() unset dev for session in /sys/class/iscsi_session/session*; do if [ "$1" = "`cat $session/targetname`" ]; then - dev=`readlink $session/device/target*/*:0:*/block*` - dev=${dev##*/} + dev=`basename $session/device/target*/*:0:*/block*/*` return fi done @@ -34,8 +33,7 @@ find_sdev_rev() { unset tgt for session in /sys/class/iscsi_session/session*; do - dev=`readlink $session/device/target*/*:0:*/block*` - dev=${dev##*/} + dev=`basename $session/device/target*/*:0:*/block*/*` if [ "$dev" = "$1" ]; then tgt=`cat $session/targetname` return diff --git a/block-losetup-retry.diff b/block-losetup-retry.diff index 4b5520d..ca40a47 100644 --- a/block-losetup-retry.diff +++ b/block-losetup-retry.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/examples/block +Index: xen-3.4.0-testing/tools/hotplug/Linux/block =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/block -+++ xen-3.3.1-testing/tools/examples/block +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/block ++++ xen-3.4.0-testing/tools/hotplug/Linux/block @@ -241,107 +241,111 @@ case "$command" in mount it read-write in a guest domain." fi diff --git a/bridge-bonding.diff b/bridge-bonding.diff index 17636cc..307bccb 100644 --- a/bridge-bonding.diff +++ b/bridge-bonding.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/examples/network-bridge +Index: xen-3.4.0-testing/tools/hotplug/Linux/network-bridge =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/network-bridge -+++ xen-3.3.1-testing/tools/examples/network-bridge +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/network-bridge ++++ xen-3.4.0-testing/tools/hotplug/Linux/network-bridge @@ -241,6 +241,9 @@ op_start () { return fi @@ -12,14 +12,19 @@ Index: xen-3.3.1-testing/tools/examples/network-bridge vlans=$(find_active_vlans "${netdev}") for vlan in $vlans ; do ifdown $vlan ; done -@@ -254,13 +257,27 @@ op_start () { +@@ -258,18 +261,32 @@ op_start () { ip link set ${netdev} down ip addr flush ${netdev} fi - ip link set ${netdev} name ${pdev} - ip link set ${tdev} name ${bridge} - +- - setup_bridge_port ${pdev} + +- # Restore slaves +- if [ -n "${slaves}" ]; then +- ip link set ${pdev} up +- ifenslave ${pdev} ${slaves} + if [ "x${bonded}" = "xyes" ] + then + ip link set ${tdev} name ${bridge} @@ -36,12 +41,17 @@ Index: xen-3.3.1-testing/tools/examples/network-bridge + ip link set ${tdev} name ${bridge} + + setup_bridge_port ${pdev} - -- add_to_bridge2 ${bridge} ${pdev} -- do_ifup ${bridge} ++ ++ # Restore slaves ++ if [ -n "${slaves}" ]; then ++ ip link set ${pdev} up ++ ifenslave ${pdev} ${slaves} ++ fi + add_to_bridge2 ${bridge} ${pdev} + do_ifup ${bridge} -+ fi + fi +- add_to_bridge2 ${bridge} ${pdev} +- do_ifup ${bridge} for vlan in $vlans ; do ifup $vlan ; done diff --git a/bridge-hostonly.diff b/bridge-hostonly.diff index 70ec93c..61ca70d 100644 --- a/bridge-hostonly.diff +++ b/bridge-hostonly.diff @@ -22,11 +22,11 @@ Signed-off-by: Gerd Hoffmann tools/examples/network-bridge | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) -Index: xen-3.2.1-testing/tools/examples/network-bridge +Index: xen-3.4.0-testing/tools/hotplug/Linux/network-bridge =================================================================== ---- xen-3.2.1-testing.orig/tools/examples/network-bridge -+++ xen-3.2.1-testing/tools/examples/network-bridge -@@ -305,6 +305,31 @@ op_stop () { +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/network-bridge ++++ xen-3.4.0-testing/tools/hotplug/Linux/network-bridge +@@ -316,6 +316,31 @@ op_stop () { for vlan in $vlans ; do ifup $vlan ; done } @@ -58,7 +58,7 @@ Index: xen-3.2.1-testing/tools/examples/network-bridge # adds $dev to $bridge but waits for $dev to be in running state first add_to_bridge2() { local bridge=$1 -@@ -330,11 +355,19 @@ add_to_bridge2() { +@@ -341,11 +366,19 @@ add_to_bridge2() { case "$command" in start) diff --git a/bridge-opensuse.patch b/bridge-opensuse.patch index 53005a4..7015561 100644 --- a/bridge-opensuse.patch +++ b/bridge-opensuse.patch @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/tools/examples/network-bridge +Index: xen-3.4.0-testing/tools/hotplug/Linux/network-bridge =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/network-bridge -+++ xen-3.3.1-testing/tools/examples/network-bridge -@@ -253,18 +253,18 @@ op_stop () { +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/network-bridge ++++ xen-3.4.0-testing/tools/hotplug/Linux/network-bridge +@@ -262,18 +262,18 @@ op_stop () { transfer_addrs ${bridge} ${pdev} if ! ifdown ${bridge}; then get_ip_info ${bridge} diff --git a/bridge-record-creation.patch b/bridge-record-creation.patch index 8c78c3d..ca6d6bb 100644 --- a/bridge-record-creation.patch +++ b/bridge-record-creation.patch @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/examples/network-bridge +Index: xen-3.4.0-testing/tools/hotplug/Linux/network-bridge =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/network-bridge -+++ xen-3.3.1-testing/tools/examples/network-bridge +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/network-bridge ++++ xen-3.4.0-testing/tools/hotplug/Linux/network-bridge @@ -249,6 +249,11 @@ op_start () { create_bridge ${tdev} @@ -13,8 +13,8 @@ Index: xen-3.3.1-testing/tools/examples/network-bridge + preiftransfer ${netdev} transfer_addrs ${netdev} ${tdev} - if ! ifdown ${netdev}; then -@@ -313,6 +318,13 @@ op_stop () { + # Remember slaves for bonding interface. +@@ -322,6 +327,13 @@ op_stop () { ip link set ${pdev} name ${netdev} do_ifup ${netdev} diff --git a/bridge-vlan.diff b/bridge-vlan.diff index 34628ed..a2b24bd 100644 --- a/bridge-vlan.diff +++ b/bridge-vlan.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/examples/network-bridge +Index: xen-3.4.0-testing/tools/hotplug/Linux/network-bridge =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/network-bridge -+++ xen-3.3.1-testing/tools/examples/network-bridge +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/network-bridge ++++ xen-3.4.0-testing/tools/hotplug/Linux/network-bridge @@ -191,6 +191,28 @@ antispoofing () { iptables -A FORWARD -m physdev --physdev-in ${pdev} -j ACCEPT } @@ -41,7 +41,7 @@ Index: xen-3.3.1-testing/tools/examples/network-bridge create_bridge ${tdev} preiftransfer ${netdev} -@@ -237,6 +262,8 @@ op_start () { +@@ -246,6 +271,8 @@ op_start () { add_to_bridge2 ${bridge} ${pdev} do_ifup ${bridge} @@ -50,7 +50,7 @@ Index: xen-3.3.1-testing/tools/examples/network-bridge if [ ${antispoof} = 'yes' ] ; then antispoofing fi -@@ -250,6 +277,9 @@ op_stop () { +@@ -259,6 +286,9 @@ op_stop () { return fi @@ -60,7 +60,7 @@ Index: xen-3.3.1-testing/tools/examples/network-bridge transfer_addrs ${bridge} ${pdev} if ! ifdown ${bridge}; then get_ip_info ${bridge} -@@ -265,6 +295,8 @@ op_stop () { +@@ -274,6 +304,8 @@ op_stop () { ip link set ${pdev} down ip link set ${pdev} name ${netdev} do_ifup ${netdev} diff --git a/build-tapdisk-ioemu.patch b/build-tapdisk-ioemu.patch index 38baffd..1da2592 100644 --- a/build-tapdisk-ioemu.patch +++ b/build-tapdisk-ioemu.patch @@ -1,10 +1,27 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/Makefile +From f1ebeae7802a5775422004f62630c42e46dcf664 Mon Sep 17 00:00:00 2001 +From: Kevin Wolf +Date: Tue, 10 Mar 2009 16:32:40 +0100 +Subject: [PATCH 3/6] ioemu: Build tapdisk-ioemu binary + +When changing away from the old ioemu, changes in the Makefiles +resulted in tapdisk-ioemu appearing there, but actually not +being built. This patch re-enables the build of tapdisk-ioemu. + +Signed-off-by: Kevin Wolf +--- + Makefile | 22 +++++++++++++++------- + configure | 2 +- + qemu-tool.c | 2 +- + tapdisk-ioemu.c | 17 ----------------- + 4 files changed, 17 insertions(+), 26 deletions(-) + +Index: xen-3.4.0-testing/tools/ioemu-remote/Makefile =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/Makefile -+++ xen-3.3.1-testing/tools/ioemu-remote/Makefile -@@ -31,13 +31,6 @@ subdir-%: libqemu_common.a +--- xen-3.4.0-testing.orig/tools/ioemu-remote/Makefile ++++ xen-3.4.0-testing/tools/ioemu-remote/Makefile +@@ -46,13 +46,6 @@ $(filter %-user,$(SUBDIR_RULES)): libqem - recurse-all: $(patsubst %,subdir-%, $(TARGET_DIRS)) + recurse-all: $(SUBDIR_RULES) -tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/libxc -tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/blktap/lib @@ -16,9 +33,9 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/Makefile ####################################################################### # BLOCK_OBJS is code used by both qemu system emulation and qemu-img -@@ -46,6 +39,21 @@ BLOCK_OBJS+=block-cow.o block-qcow.o aes - BLOCK_OBJS+=block-dmg.o block-bochs.o block-vpc.o block-vvfat.o - BLOCK_OBJS+=block-qcow2.o block-parallels.o +@@ -71,6 +64,21 @@ endif + BLOCK_OBJS += block-raw-posix.o + endif +####################################################################### +# tapdisk-ioemu @@ -32,22 +49,91 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/Makefile +tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/blktap/lib +tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/xenstore +tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/include -+tapdisk-ioemu: tapdisk-ioemu.o $(BLOCK_OBJS) qemu-img-block.o qemu-img-block-raw-posix.o hw/tapdisk-xen_blktap.o ++tapdisk-ioemu: tapdisk-ioemu.o $(BLOCK_OBJS) qemu-tool.o hw/tapdisk-xen_blktap.o + $(CC) $(LDFLAGS) -o $@ $^ -lz $(LIBS) + ###################################################################### # libqemu_common.a: Target independent part of system emulation. The # long term path is to suppress *all* target specific code in case of -Index: xen-3.3.1-testing/tools/ioemu-remote/configure +Index: xen-3.4.0-testing/tools/ioemu-remote/configure =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/configure -+++ xen-3.3.1-testing/tools/ioemu-remote/configure -@@ -1150,7 +1150,7 @@ fi - - echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h +--- xen-3.4.0-testing.orig/tools/ioemu-remote/configure ++++ xen-3.4.0-testing/tools/ioemu-remote/configure +@@ -1508,7 +1508,7 @@ bsd) + ;; + esac -tools= +tools="tapdisk-ioemu" if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then tools="qemu-img\$(EXESUF) $tools" - fi + if [ "$linux" = "yes" ] ; then +Index: xen-3.4.0-testing/tools/ioemu-remote/qemu-tool.c +=================================================================== +--- xen-3.4.0-testing.orig/tools/ioemu-remote/qemu-tool.c ++++ xen-3.4.0-testing/tools/ioemu-remote/qemu-tool.c +@@ -68,7 +68,7 @@ void qemu_bh_delete(QEMUBH *bh) + qemu_free(bh); + } + +-int qemu_set_fd_handler2(int fd, ++int __attribute__((weak)) qemu_set_fd_handler2(int fd, + IOCanRWHandler *fd_read_poll, + IOHandler *fd_read, + IOHandler *fd_write, +Index: xen-3.4.0-testing/tools/ioemu-remote/tapdisk-ioemu.c +=================================================================== +--- xen-3.4.0-testing.orig/tools/ioemu-remote/tapdisk-ioemu.c ++++ xen-3.4.0-testing/tools/ioemu-remote/tapdisk-ioemu.c +@@ -12,34 +12,12 @@ + + extern void qemu_aio_init(void); + extern void qemu_aio_poll(void); +-extern void bdrv_init(void); +- +-extern void *qemu_mallocz(size_t size); +-extern void qemu_free(void *ptr); + + extern void *fd_start; + + int domid = 0; + FILE* logfile; + +-void term_printf(const char *fmt, ...) +-{ +- va_list ap; +- va_start(ap, fmt); +- vprintf(fmt, ap); +- va_end(ap); +-} +- +-void term_print_filename(const char *filename) +-{ +- term_printf(filename); +-} +- +- +-typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); +-typedef int IOCanRWHandler(void *opaque); +-typedef void IOHandler(void *opaque); +- + typedef struct IOHandlerRecord { + int fd; + IOCanRWHandler *fd_read_poll; +@@ -103,7 +81,6 @@ int main(void) + logfile = stderr; + + bdrv_init(); +- qemu_aio_init(); + init_blktap(); + + /* Daemonize */ +@@ -115,8 +92,6 @@ int main(void) + * completed aio operations. + */ + while (1) { +- qemu_aio_poll(); +- + max_fd = -1; + FD_ZERO(&rfds); + for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) diff --git a/cdrom-removable.patch b/cdrom-removable.patch index 8d48e15..6967ce3 100644 --- a/cdrom-removable.patch +++ b/cdrom-removable.patch @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/python/xen/xend/server/HalDaemon.py +Index: xen-3.4.0-testing/tools/python/xen/xend/server/HalDaemon.py =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/python/xen/xend/server/HalDaemon.py ++++ xen-3.4.0-testing/tools/python/xen/xend/server/HalDaemon.py @@ -0,0 +1,243 @@ +#!/usr/bin/env python +# -*- mode: python; -*- @@ -246,10 +246,10 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/server/HalDaemon.py + print 'Falling off end' + + -Index: xen-3.3.1-testing/tools/python/xen/xend/server/Hald.py +Index: xen-3.4.0-testing/tools/python/xen/xend/server/Hald.py =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/python/xen/xend/server/Hald.py ++++ xen-3.4.0-testing/tools/python/xen/xend/server/Hald.py @@ -0,0 +1,125 @@ +#============================================================================ +# This library is free software; you can redistribute it and/or @@ -376,10 +376,10 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/server/Hald.py + watcher.run() + time.sleep(10) + watcher.shutdown() -Index: xen-3.3.1-testing/tools/python/xen/xend/server/SrvServer.py +Index: xen-3.4.0-testing/tools/python/xen/xend/server/SrvServer.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/server/SrvServer.py -+++ xen-3.3.1-testing/tools/python/xen/xend/server/SrvServer.py +--- xen-3.4.0-testing.orig/tools/python/xen/xend/server/SrvServer.py ++++ xen-3.4.0-testing/tools/python/xen/xend/server/SrvServer.py @@ -56,6 +56,7 @@ from xen.web.SrvDir import SrvDir from SrvRoot import SrvRoot @@ -397,12 +397,12 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/server/SrvServer.py def create(): root = SrvDir() -Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c +Index: xen-3.4.0-testing/tools/ioemu-remote/xenstore.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/xenstore.c -+++ xen-3.3.1-testing/tools/ioemu-remote/xenstore.c -@@ -333,6 +333,19 @@ void xenstore_parse_domain_config(int hv - if (bdrv_open2(bs, params, 0 /* snapshot */, format) < 0) +--- xen-3.4.0-testing.orig/tools/ioemu-remote/xenstore.c ++++ xen-3.4.0-testing/tools/ioemu-remote/xenstore.c +@@ -503,6 +503,19 @@ void xenstore_parse_domain_config(int hv + if (bdrv_open2(bs, params, BDRV_O_CACHE_WB /* snapshot and write-back */, format) < 0) fprintf(stderr, "qemu: could not open vbd '%s' or hard disk image '%s' (drv '%s' format '%s')\n", buf, params, drv ? drv : "?", format ? format->format_name : "0"); } + /* if cdrom pyhsical put a watch on media-present */ @@ -420,8 +420,8 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c + } drives_table[nb_drives].bdrv = bs; - nb_drives++; -@@ -631,6 +644,50 @@ void xenstore_record_dm_state(char *stat + drives_table[nb_drives].used = 1; +@@ -920,6 +933,50 @@ void xenstore_record_dm_state(const char xenstore_record_dm("state", state); } @@ -472,7 +472,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c void xenstore_process_event(void *opaque) { char **vec, *offset, *bpath = NULL, *buf = NULL, *drv = NULL, *image = NULL; -@@ -650,6 +707,11 @@ void xenstore_process_event(void *opaque +@@ -939,6 +996,11 @@ void xenstore_process_event(void *opaque goto out; } diff --git a/checkpoint-rename.patch b/checkpoint-rename.patch index 23c0fc5..46940e4 100644 --- a/checkpoint-rename.patch +++ b/checkpoint-rename.patch @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/tools/python/xen/xend/XendCheckpoint.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendCheckpoint.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendCheckpoint.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendCheckpoint.py -@@ -144,7 +144,7 @@ def save(fd, dominfo, network, live, dst +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendCheckpoint.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendCheckpoint.py +@@ -151,7 +151,7 @@ def save(fd, dominfo, network, live, dst dominfo.destroy() dominfo.testDeviceComplete() try: diff --git a/disable_emulated_device.diff b/disable_emulated_device.diff index 3f4dd7c..80022a2 100644 --- a/disable_emulated_device.diff +++ b/disable_emulated_device.diff @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c +Index: xen-3.4.0-testing/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c =================================================================== ---- xen-3.3.1-testing.orig/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c 2009-01-05 13:27:56.000000000 -0700 -+++ xen-3.3.1-testing/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c 2009-02-24 12:09:53.000000000 -0700 -@@ -296,6 +296,11 @@ +--- xen-3.4.0-testing.orig/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c ++++ xen-3.4.0-testing/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c +@@ -301,6 +301,11 @@ static int __devinit platform_pci_init(s platform_mmio = mmio_addr; platform_mmiolen = mmio_len; diff --git a/dom-print.patch b/dom-print.patch index adc6633..ec48722 100644 --- a/dom-print.patch +++ b/dom-print.patch @@ -1,6 +1,8 @@ ---- a/xen/arch/x86/domain.c -+++ b/xen/arch/x86/domain.c -@@ -135,7 +135,7 @@ void dump_pageframe_info(struct domain * +Index: xen-3.4.0-testing/xen/arch/x86/domain.c +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/domain.c ++++ xen-3.4.0-testing/xen/arch/x86/domain.c +@@ -143,7 +143,7 @@ void dump_pageframe_info(struct domain * printk("Memory pages belonging to domain %u:\n", d->domain_id); @@ -9,9 +11,9 @@ { printk(" DomPage list too long to display\n"); } -@@ -143,6 +143,15 @@ void dump_pageframe_info(struct domain * +@@ -151,6 +151,15 @@ void dump_pageframe_info(struct domain * { - list_for_each_entry ( page, &d->page_list, list ) + page_list_for_each ( page, &d->page_list ) { + if ( d->tot_pages > 16 ) + { @@ -25,17 +27,3 @@ printk(" DomPage %p: caf=%08lx, taf=%" PRtype_info "\n", _p(page_to_mfn(page)), page->count_info, page->u.inuse.type_info); ---- a/xen/common/keyhandler.c -+++ b/xen/common/keyhandler.c -@@ -192,9 +192,9 @@ static void dump_domains(unsigned char k - { - printk("General information for domain %u:\n", d->domain_id); - cpuset_print(tmpstr, sizeof(tmpstr), d->domain_dirty_cpumask); -- printk(" refcnt=%d nr_pages=%d xenheap_pages=%d " -+ printk(" refcnt=%d dying=%d nr_pages=%d xenheap_pages=%d " - "dirty_cpus=%s\n", -- atomic_read(&d->refcnt), -+ atomic_read(&d->refcnt), d->is_dying, - d->tot_pages, d->xenheap_pages, tmpstr); - printk(" handle=%02x%02x%02x%02x-%02x%02x-%02x%02x-" - "%02x%02x-%02x%02x%02x%02x%02x%02x vm_assist=%08lx\n", diff --git a/domUloader.py b/domUloader.py index 43219e5..a46bcaf 100644 --- a/domUloader.py +++ b/domUloader.py @@ -164,7 +164,7 @@ class Wholedisk: for line in fd.readlines(): line = line.strip() verbose_print("kpartx -l: %s" % (line,)) - (pname, params) = line.split(':') + (pname, params) = line.split(' : ') pname = pname.strip() pno = int(traildigits(pname)) #if pname.rfind('/') != -1: diff --git a/dump-exec-state.patch b/dump-exec-state.patch index 42158af..210a4e4 100644 --- a/dump-exec-state.patch +++ b/dump-exec-state.patch @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/xen/arch/ia64/linux-xen/smp.c +Index: xen-3.4.0-testing/xen/arch/ia64/linux-xen/smp.c =================================================================== ---- xen-3.3.1-testing.orig/xen/arch/ia64/linux-xen/smp.c -+++ xen-3.3.1-testing/xen/arch/ia64/linux-xen/smp.c -@@ -175,7 +175,7 @@ handle_IPI (int irq, void *dev_id, struc +--- xen-3.4.0-testing.orig/xen/arch/ia64/linux-xen/smp.c ++++ xen-3.4.0-testing/xen/arch/ia64/linux-xen/smp.c +@@ -190,7 +190,7 @@ handle_IPI (int irq, void *dev_id, struc * At this point the structure may be gone unless * wait is true. */ @@ -11,10 +11,10 @@ Index: xen-3.3.1-testing/xen/arch/ia64/linux-xen/smp.c /* Notify the sending CPU that the task is done. */ mb(); -Index: xen-3.3.1-testing/xen/arch/x86/smp.c +Index: xen-3.4.0-testing/xen/arch/x86/smp.c =================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/smp.c -+++ xen-3.3.1-testing/xen/arch/x86/smp.c +--- xen-3.4.0-testing.orig/xen/arch/x86/smp.c ++++ xen-3.4.0-testing/xen/arch/x86/smp.c @@ -356,7 +356,7 @@ fastcall void smp_call_function_interrup if ( call_data->wait ) @@ -33,10 +33,10 @@ Index: xen-3.3.1-testing/xen/arch/x86/smp.c } irq_exit(); -Index: xen-3.3.1-testing/xen/common/keyhandler.c +Index: xen-3.4.0-testing/xen/common/keyhandler.c =================================================================== ---- xen-3.3.1-testing.orig/xen/common/keyhandler.c -+++ xen-3.3.1-testing/xen/common/keyhandler.c +--- xen-3.4.0-testing.orig/xen/common/keyhandler.c ++++ xen-3.4.0-testing/xen/common/keyhandler.c @@ -91,14 +91,25 @@ static void show_handlers(unsigned char key_table[i].desc); } @@ -83,10 +83,10 @@ Index: xen-3.3.1-testing/xen/common/keyhandler.c on_selected_cpus(cpumask_of_cpu(cpu), __dump_execstate, NULL, 1, 1); } -Index: xen-3.3.1-testing/xen/include/asm-ia64/linux-xen/asm/ptrace.h +Index: xen-3.4.0-testing/xen/include/asm-ia64/linux-xen/asm/ptrace.h =================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-ia64/linux-xen/asm/ptrace.h -+++ xen-3.3.1-testing/xen/include/asm-ia64/linux-xen/asm/ptrace.h +--- xen-3.4.0-testing.orig/xen/include/asm-ia64/linux-xen/asm/ptrace.h ++++ xen-3.4.0-testing/xen/include/asm-ia64/linux-xen/asm/ptrace.h @@ -278,7 +278,7 @@ struct switch_stack { # define ia64_task_regs(t) (((struct pt_regs *) ((char *) (t) + IA64_STK_OFFSET)) - 1) # define ia64_psr(regs) ((struct ia64_psr *) &(regs)->cr_ipsr) diff --git a/hv_tools.patch b/hv_tools.patch index af646cf..18bf7b2 100644 --- a/hv_tools.patch +++ b/hv_tools.patch @@ -1,81 +1,83 @@ -Index: xen-3.3.1-testing/tools/python/xen/lowlevel/xc/xc.c +Index: xen-3.4.0-testing/tools/python/xen/lowlevel/xc/xc.c =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/lowlevel/xc/xc.c -+++ xen-3.3.1-testing/tools/python/xen/lowlevel/xc/xc.c +--- xen-3.4.0-testing.orig/tools/python/xen/lowlevel/xc/xc.c ++++ xen-3.4.0-testing/tools/python/xen/lowlevel/xc/xc.c @@ -890,14 +890,14 @@ static PyObject *pyxc_hvm_build(XcObject int i; #endif char *image; -- int memsize, vcpus = 1, acpi = 0, apic = 1; -+ int memsize, vcpus = 1, acpi = 0, apic = 1, extid = 0; +- int memsize, target=-1, vcpus = 1, acpi = 0, apic = 1; ++ int memsize, target=-1, vcpus = 1, acpi = 0, apic = 1, extid=0; static char *kwd_list[] = { "domid", -- "memsize", "image", "vcpus", "acpi", -+ "memsize", "image", "vcpus", "extid", "acpi", - "apic", NULL }; -- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iii", kwd_list, -+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiii", kwd_list, - &dom, &memsize, -- &image, &vcpus, &acpi, &apic) ) -+ &image, &vcpus, &extid, &acpi, &apic) ) +- "memsize", "image", "target", "vcpus", "acpi", +- "apic", NULL }; +- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiii", kwd_list, +- &dom, &memsize, &image, &target, &vcpus, +- &acpi, &apic) ) ++ "memsize", "image", "target", "vcpus", "extid", ++ "acpi", "apic", NULL }; ++ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiiii", kwd_list, ++ &dom, &memsize, &image, &target, &extid, ++ &vcpus, &acpi, &apic) ) return NULL; - if ( xc_hvm_build(self->xc_handle, dom, memsize, image) != 0 ) -@@ -922,6 +922,7 @@ static PyObject *pyxc_hvm_build(XcObject - va_hvm->checksum = -sum; + if ( target == -1 ) +@@ -923,6 +923,7 @@ static PyObject *pyxc_hvm_build(XcObject + va_hvm->checksum -= sum; munmap(va_map, XC_PAGE_SIZE); #endif + xc_set_hvm_param(self->xc_handle, dom, HVM_PARAM_EXTEND_HYPERVISOR, extid); return Py_BuildValue("{}"); } -Index: xen-3.3.1-testing/tools/python/xen/xend/XendConfig.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendConfig.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendConfig.py -@@ -141,6 +141,7 @@ XENAPI_PLATFORM_CFG_TYPES = { +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendConfig.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendConfig.py +@@ -143,6 +143,7 @@ XENAPI_PLATFORM_CFG_TYPES = { 'monitor': int, 'nographic': int, 'pae' : int, -+ 'extid': int, ++ 'extid': int, 'rtc_timeoffset': int, 'serial': str, 'sdl': int, -Index: xen-3.3.1-testing/tools/python/xen/xend/image.py +Index: xen-3.4.0-testing/tools/python/xen/xend/image.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/image.py -+++ xen-3.3.1-testing/tools/python/xen/xend/image.py -@@ -703,6 +703,7 @@ class HVMImageHandler(ImageHandler): +--- xen-3.4.0-testing.orig/tools/python/xen/xend/image.py ++++ xen-3.4.0-testing/tools/python/xen/xend/image.py +@@ -764,6 +764,7 @@ class HVMImageHandler(ImageHandler): self.apic = int(vmConfig['platform'].get('apic', 0)) self.acpi = int(vmConfig['platform'].get('acpi', 0)) + self.extid = int(vmConfig['platform'].get('extid', 0)) self.guest_os_type = vmConfig['platform'].get('guest_os_type') - -@@ -809,6 +810,7 @@ class HVMImageHandler(ImageHandler): - log.debug("store_evtchn = %d", store_evtchn) - log.debug("memsize = %d", mem_mb) + +@@ -880,6 +881,7 @@ class HVMImageHandler(ImageHandler): + log.debug("memsize = %d", memmax_mb) + log.debug("target = %d", mem_mb) log.debug("vcpus = %d", self.vm.getVCpuCount()) + log.debug("extid = %d", self.extid) log.debug("acpi = %d", self.acpi) log.debug("apic = %d", self.apic) -@@ -816,6 +818,7 @@ class HVMImageHandler(ImageHandler): - image = self.loader, - memsize = mem_mb, +@@ -888,6 +890,7 @@ class HVMImageHandler(ImageHandler): + memsize = memmax_mb, + target = mem_mb, vcpus = self.vm.getVCpuCount(), + extid = self.extid, acpi = self.acpi, apic = self.apic) rc['notes'] = { 'SUSPEND_CANCEL': 1 } -Index: xen-3.3.1-testing/tools/python/xen/xm/create.py +Index: xen-3.4.0-testing/tools/python/xen/xm/create.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xm/create.py -+++ xen-3.3.1-testing/tools/python/xen/xm/create.py -@@ -218,6 +218,10 @@ gopts.var('timer_mode', val='TIMER_MODE' - use="""Timer mode (0=delay virtual time when ticks are missed; - 1=virtual time is always wallclock time.""") +--- xen-3.4.0-testing.orig/tools/python/xen/xm/create.py ++++ xen-3.4.0-testing/tools/python/xen/xm/create.py +@@ -229,6 +229,10 @@ gopts.var('viridian', val='VIRIDIAN', + use="""Expose Viridian interface to x86 HVM guest? + (Default is 0).""") +gopts.var('extid', val='EXTID', + fn=set_int, default=0, @@ -84,7 +86,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xm/create.py gopts.var('acpi', val='ACPI', fn=set_int, default=1, use="Disable or enable ACPI of HVM domain.") -@@ -858,7 +862,7 @@ def configure_vifs(config_devs, vals): +@@ -925,7 +929,7 @@ def configure_vifs(config_devs, vals): def configure_hvm(config_image, vals): """Create the config for HVM devices. """ diff --git a/hv_xen_base.patch b/hv_xen_base.patch index 3202c72..4701c3c 100644 --- a/hv_xen_base.patch +++ b/hv_xen_base.patch @@ -1,9 +1,9 @@ %patch -Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/domain.h +Index: xen-3.4.0-testing/xen/include/asm-x86/hvm/domain.h =================================================================== ---- xen-3.3.1-testing.orig/xen/include/asm-x86/hvm/domain.h 2009-01-05 13:27:58.000000000 -0700 -+++ xen-3.3.1-testing/xen/include/asm-x86/hvm/domain.h 2009-02-12 10:18:31.000000000 -0700 -@@ -82,6 +82,7 @@ +--- xen-3.4.0-testing.orig/xen/include/asm-x86/hvm/domain.h ++++ xen-3.4.0-testing/xen/include/asm-x86/hvm/domain.h +@@ -89,6 +89,7 @@ struct hvm_domain { struct vmx_domain vmx; struct svm_domain svm; }; @@ -11,22 +11,22 @@ Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/domain.h }; #endif /* __ASM_X86_HVM_DOMAIN_H__ */ -Index: xen-3.3.1-testing/xen/arch/x86/hvm/Makefile +Index: xen-3.4.0-testing/xen/arch/x86/hvm/Makefile =================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/hvm/Makefile 2009-01-05 13:27:57.000000000 -0700 -+++ xen-3.3.1-testing/xen/arch/x86/hvm/Makefile 2009-02-12 10:18:31.000000000 -0700 +--- xen-3.4.0-testing.orig/xen/arch/x86/hvm/Makefile ++++ xen-3.4.0-testing/xen/arch/x86/hvm/Makefile @@ -1,5 +1,6 @@ subdir-y += svm subdir-y += vmx -+subdir-y += hyperv ++subdir-y += hyperv obj-y += emulate.o obj-y += hvm.o -Index: xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c +Index: xen-3.4.0-testing/xen/arch/x86/hvm/hvm.c =================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/hvm/hvm.c 2009-02-12 10:18:30.000000000 -0700 -+++ xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c 2009-02-12 10:18:31.000000000 -0700 -@@ -44,6 +44,7 @@ +--- xen-3.4.0-testing.orig/xen/arch/x86/hvm/hvm.c ++++ xen-3.4.0-testing/xen/arch/x86/hvm/hvm.c +@@ -45,6 +45,7 @@ #include #include #include @@ -34,7 +34,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c #include #include #include -@@ -361,6 +362,7 @@ +@@ -373,6 +374,7 @@ void hvm_domain_relinquish_resources(str void hvm_domain_destroy(struct domain *d) { @@ -42,7 +42,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c hvm_funcs.domain_destroy(d); rtc_deinit(d); stdvga_deinit(d); -@@ -662,8 +664,14 @@ +@@ -673,8 +675,14 @@ int hvm_vcpu_initialise(struct vcpu *v) { int rc; @@ -57,7 +57,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c if ( (rc = hvm_funcs.vcpu_initialise(v)) != 0 ) goto fail2; -@@ -710,12 +718,14 @@ +@@ -721,12 +729,14 @@ int hvm_vcpu_initialise(struct vcpu *v) hvm_funcs.vcpu_destroy(v); fail2: vlapic_destroy(v); @@ -72,8 +72,8 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c hvm_vcpu_cacheattr_destroy(v); vlapic_destroy(v); hvm_funcs.vcpu_destroy(v); -@@ -1663,7 +1673,7 @@ - struct vcpu *v = current; +@@ -1678,7 +1688,7 @@ void hvm_cpuid(unsigned int input, unsig + return; if ( cpuid_hypervisor_leaves(input, eax, ebx, ecx, edx) ) - return; @@ -81,7 +81,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c domain_cpuid(v->domain, input, *ecx, eax, ebx, ecx, edx); -@@ -1675,6 +1685,8 @@ +@@ -1690,6 +1700,8 @@ void hvm_cpuid(unsigned int input, unsig if ( vlapic_hw_disabled(vcpu_vlapic(v)) ) __clear_bit(X86_FEATURE_APIC & 31, edx); } @@ -90,16 +90,16 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c } void hvm_rdtsc_intercept(struct cpu_user_regs *regs) -@@ -1765,6 +1777,8 @@ - break; +@@ -1789,6 +1801,8 @@ int hvm_msr_read_intercept(struct cpu_us + break; default: + if (hyperx_intercept_do_msr_read(ecx, regs)) -+ return X86EMUL_OKAY; ++ return X86EMUL_OKAY; return hvm_funcs.msr_read_intercept(regs); } -@@ -1853,6 +1867,8 @@ +@@ -1877,6 +1891,8 @@ int hvm_msr_write_intercept(struct cpu_u break; default: @@ -108,23 +108,23 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c return hvm_funcs.msr_write_intercept(regs); } -@@ -2020,6 +2036,10 @@ +@@ -2044,6 +2060,10 @@ int hvm_do_hypercall(struct cpu_user_reg case 0: break; } -+ if (hyperx_intercept_do_hypercall(regs)) ++ if (hyperx_intercept_do_hypercall(regs)) + { + return HVM_HCALL_completed; + } - if ( (eax >= NR_hypercalls) || !hvm_hypercall32_table[eax] ) - { -@@ -2521,6 +2541,15 @@ + if ( (eax & 0x80000000) && is_viridian_domain(curr->domain) ) + return viridian_hypercall(regs); +@@ -2560,6 +2580,15 @@ long do_hvm_op(unsigned long op, XEN_GUE rc = -EINVAL; break; + case HVM_PARAM_EXTEND_HYPERVISOR: -+ if ((a.value == 1) && hyperv_initialize(d)) ++ if ((a.value == 1) && hyperv_initialize(d)) + { + if (a.value != 1) + rc = -EINVAL; @@ -135,22 +135,13 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c } if ( rc == 0 ) -Index: xen-3.3.1-testing/xen/include/public/arch-x86/hvm/save.h +Index: xen-3.4.0-testing/xen/include/public/arch-x86/hvm/save.h =================================================================== ---- xen-3.3.1-testing.orig/xen/include/public/arch-x86/hvm/save.h 2009-01-05 13:27:58.000000000 -0700 -+++ xen-3.3.1-testing/xen/include/public/arch-x86/hvm/save.h 2009-02-12 10:18:31.000000000 -0700 -@@ -38,7 +38,7 @@ - uint32_t version; /* File format version */ - uint64_t changeset; /* Version of Xen that saved this file */ - uint32_t cpuid; /* CPUID[0x01][%eax] on the saving machine */ -- uint32_t pad0; -+ uint32_t pad0; - }; +--- xen-3.4.0-testing.orig/xen/include/public/arch-x86/hvm/save.h ++++ xen-3.4.0-testing/xen/include/public/arch-x86/hvm/save.h +@@ -432,9 +432,26 @@ struct hvm_viridian_context { - DECLARE_HVM_SAVE_TYPE(HEADER, 1, struct hvm_save_header); -@@ -421,9 +421,23 @@ - - DECLARE_HVM_SAVE_TYPE(MTRR, 14, struct hvm_hw_mtrr); + DECLARE_HVM_SAVE_TYPE(VIRIDIAN, 15, struct hvm_viridian_context); +struct hvm_hyperv_dom { + uint64_t guestid_msr; @@ -158,25 +149,28 @@ Index: xen-3.3.1-testing/xen/include/public/arch-x86/hvm/save.h + uint32_t long_mode; + uint32_t ext_id; +}; -+DECLARE_HVM_SAVE_TYPE(HYPERV_DOM, 15, struct hvm_hyperv_dom); ++ ++DECLARE_HVM_SAVE_TYPE(HYPERV_DOM, 16, struct hvm_hyperv_dom); + +struct hvm_hyperv_cpu { + uint64_t control_msr; + uint64_t version_msr; + uint64_t pad[27]; //KYS: sles10 sp2 compatibility +}; -+DECLARE_HVM_SAVE_TYPE(HYPERV_CPU, 16, struct hvm_hyperv_cpu); ++ ++DECLARE_HVM_SAVE_TYPE(HYPERV_CPU, 17, struct hvm_hyperv_cpu); ++ /* * Largest type-code in use */ --#define HVM_SAVE_CODE_MAX 14 -+#define HVM_SAVE_CODE_MAX 16 +-#define HVM_SAVE_CODE_MAX 15 ++#define HVM_SAVE_CODE_MAX 17 #endif /* __XEN_PUBLIC_HVM_SAVE_X86_H__ */ -Index: xen-3.3.1-testing/xen/arch/x86/hvm/vlapic.c +Index: xen-3.4.0-testing/xen/arch/x86/hvm/vlapic.c =================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/hvm/vlapic.c 2009-02-12 10:18:30.000000000 -0700 -+++ xen-3.3.1-testing/xen/arch/x86/hvm/vlapic.c 2009-02-12 10:18:31.000000000 -0700 +--- xen-3.4.0-testing.orig/xen/arch/x86/hvm/vlapic.c ++++ xen-3.4.0-testing/xen/arch/x86/hvm/vlapic.c @@ -34,6 +34,7 @@ #include #include @@ -185,7 +179,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/vlapic.c #include #include #include -@@ -307,6 +308,7 @@ +@@ -307,6 +308,7 @@ static int vlapic_accept_sipi(struct vcp hvm_vcpu_reset_state(v, trampoline_vector << 8, 0); vcpu_unpause(v); @@ -193,17 +187,17 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/vlapic.c return X86EMUL_OKAY; } -Index: xen-3.3.1-testing/xen/include/public/hvm/params.h +Index: xen-3.4.0-testing/xen/include/public/hvm/params.h =================================================================== ---- xen-3.3.1-testing.orig/xen/include/public/hvm/params.h 2009-01-05 13:27:58.000000000 -0700 -+++ xen-3.3.1-testing/xen/include/public/hvm/params.h 2009-02-12 10:18:31.000000000 -0700 -@@ -93,6 +93,8 @@ - /* ACPI S state: currently support S0 and S3 on x86. */ - #define HVM_PARAM_ACPI_S_STATE 14 +--- xen-3.4.0-testing.orig/xen/include/public/hvm/params.h ++++ xen-3.4.0-testing/xen/include/public/hvm/params.h +@@ -106,6 +106,8 @@ + /* Boolean: Enable aligning all periodic vpts to reduce interrupts */ + #define HVM_PARAM_VPT_ALIGN 16 --#define HVM_NR_PARAMS 15 -+#define HVM_PARAM_EXTEND_HYPERVISOR 15 +-#define HVM_NR_PARAMS 17 ++#define HVM_PARAM_EXTEND_HYPERVISOR 17 + -+#define HVM_NR_PARAMS 16 ++#define HVM_NR_PARAMS 18 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */ diff --git a/hv_xen_extension.patch b/hv_xen_extension.patch index 750c016..e963a41 100644 --- a/hv_xen_extension.patch +++ b/hv_xen_extension.patch @@ -1,8 +1,8 @@ %patch -Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm_extensions.h +Index: xen-3.4.0-testing/xen/include/asm-x86/hvm/hvm_extensions.h =================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm_extensions.h 2009-02-12 10:18:31.000000000 -0700 +--- /dev/null ++++ xen-3.4.0-testing/xen/include/asm-x86/hvm/hvm_extensions.h @@ -0,0 +1,165 @@ +/**************************************************************************** + | @@ -28,13 +28,13 @@ Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm_extensions.h +*/ + +/* -+ * hvm_extensions.h ++ * hvm_extensions.h + * Implement Hyperv extensions. + * Engineering Contact: K. Y. Srinivasan + */ + +#ifndef HVM_EXTENSION_H -+#define HVM_EXTENSION_H ++#define HVM_EXTENSION_H + +#include +#include @@ -70,7 +70,7 @@ Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm_extensions.h + + + -+ ++ +static inline int +hyperx_intercept_domain_create(struct domain *d) +{ @@ -80,10 +80,10 @@ Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm_extensions.h + return (0); +} + -+static inline void ++static inline void +hyperx_intercept_domain_destroy(struct domain *d) +{ -+ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) ++ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) + { + hyperv_dom_destroy(d); + } @@ -93,7 +93,7 @@ Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm_extensions.h +hyperx_intercept_vcpu_initialize(struct vcpu *v) +{ + struct domain *d = v->domain; -+ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) ++ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) + { + return(hyperv_vcpu_initialize(v)); + } @@ -101,21 +101,21 @@ Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm_extensions.h +} + + -+static inline void ++static inline void +hyperx_intercept_vcpu_up(struct vcpu *v) +{ + struct domain *d = current->domain; -+ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) ++ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) + { + hyperv_vcpu_up(v); + } +} -+ -+static inline void ++ ++static inline void +hyperx_intercept_vcpu_destroy(struct vcpu *v) +{ + struct domain *d = v->domain; -+ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) ++ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) + { + hyperv_vcpu_destroy(v); + } @@ -126,7 +126,7 @@ Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm_extensions.h + unsigned int *ecx, unsigned int *edx) +{ + struct domain *d = current->domain; -+ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) ++ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) + { + return(hyperv_do_cpu_id(idx, eax, ebx, ecx, edx)); + } @@ -148,7 +148,7 @@ Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm_extensions.h +hyperx_intercept_do_msr_write(uint32_t idx, struct cpu_user_regs *regs) +{ + struct domain *d = current->domain; -+ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) ++ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) + { + return(hyperv_do_wr_msr(idx, regs)); + } @@ -159,7 +159,7 @@ Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm_extensions.h +hyperx_intercept_do_hypercall(struct cpu_user_regs *regs) +{ + struct domain *d = current->domain; -+ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) ++ if (d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] ==1) + { + return(hyperv_do_hypercall(regs)); + } @@ -169,17 +169,17 @@ Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/hvm_extensions.h +int hyperx_initialize(struct domain *d); + +#endif -Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/Makefile +Index: xen-3.4.0-testing/xen/arch/x86/hvm/hyperv/Makefile =================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/Makefile 2009-02-12 10:18:31.000000000 -0700 +--- /dev/null ++++ xen-3.4.0-testing/xen/arch/x86/hvm/hyperv/Makefile @@ -0,0 +1,2 @@ -+obj-y += hv_intercept.o -+obj-y += hv_hypercall.o -Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_errno.h ++obj-y += hv_intercept.o ++obj-y += hv_hypercall.o +Index: xen-3.4.0-testing/xen/arch/x86/hvm/hyperv/hv_errno.h =================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_errno.h 2009-02-12 10:18:31.000000000 -0700 +--- /dev/null ++++ xen-3.4.0-testing/xen/arch/x86/hvm/hyperv/hv_errno.h @@ -0,0 +1,62 @@ +/**************************************************************************** + | @@ -242,11 +242,11 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_errno.h +#define HV_STATUS_NO_MEMORY_64PAGES 0x0102 +#define HV_STATUS_NO_MEMORY_256PAGES 0x0103 +#define HV_STATUS_NO_MEMORY_1024PAGES 0x0104 -+#endif -Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.c ++#endif +Index: xen-3.4.0-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.c =================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.c 2009-02-12 10:18:31.000000000 -0700 +--- /dev/null ++++ xen-3.4.0-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.c @@ -0,0 +1,153 @@ +/**************************************************************************** + | @@ -273,7 +273,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.c + +/* + * nshypercall.c. -+ * This file implements the hypercall component of the hyperv Shim. ++ * This file implements the hypercall component of the hyperv Shim. + * + * Engineering Contact: K. Y. Srinivasan + */ @@ -314,20 +314,20 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.c +hv_switch_va(hv_vcpu_t *vcpup, int fast, paddr_t input) +{ + paddr_t new_cr3; -+ int ret_val = HV_STATUS_SUCCESS; ++ int ret_val = HV_STATUS_SUCCESS; + + /* -+ * XXXKYS: the spec sys the asID is passed via memory at offset 0 of -+ * the page whose GPA is in the input register. However, it appears ++ * XXXKYS: the spec sys the asID is passed via memory at offset 0 of ++ * the page whose GPA is in the input register. However, it appears + * the current build of longhorn (longhorn-2007-02-06-x86_64-fv-02) -+ * passes the asID in the input register instead. Need to check if ++ * passes the asID in the input register instead. Need to check if + * future builds do this. + * The fast bit defines how the parameter is passed. + */ + if (fast) + { -+ hvm_set_cr3(input); -+ } else ++ hvm_set_cr3(input); ++ } else + { + /* + * Slow path; copy the new value. @@ -335,7 +335,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.c + if (!hvm_copy_from_guest_phys(&new_cr3, input, sizeof(paddr_t))) + hvm_set_cr3(new_cr3); + else -+ ret_val = HV_STATUS_INVALID_PARAMETER; ++ ret_val = HV_STATUS_INVALID_PARAMETER; + } + +#ifdef HV_STATS @@ -345,7 +345,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.c +} + +void -+hv_handle_hypercall(u64 opcode, u64 input, u64 output, ++hv_handle_hypercall(u64 opcode, u64 input, u64 output, + u64 *ret_val) +{ + unsigned short verb; @@ -355,18 +355,18 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.c + hv_partition_t *curp = hv_get_current_partition(); + hv_vcpu_t *vcpup = &curp->vcpu_state[hv_get_current_vcpu_index()]; + u64 partition_id; -+ + -+ fast = (int)((opcode >>16) & 0x1); ++ ++ fast = (int)((opcode >>16) & 0x1); + verb = (short)(opcode & 0xffff); + rep_count = (short)((opcode >>32) & 0xfff); + start_index = (short)((opcode >> 48) & 0xfff); -+ switch (verb) ++ switch (verb) + { + case HV_GET_PARTITION_ID: -+ if (!hv_privilege_check(curp, HV_ACCESS_PARTITION_ID)) ++ if (!hv_privilege_check(curp, HV_ACCESS_PARTITION_ID)) + { -+ *ret_val = ++ *ret_val = + hv_build_hcall_retval(HV_STATUS_ACCESS_DENIED, 0); + return; + } @@ -376,7 +376,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.c + /* + * Invalid output area. + */ -+ *ret_val = ++ *ret_val = + hv_build_hcall_retval(HV_STATUS_INVALID_PARAMETER, 0); + return; + } @@ -395,16 +395,16 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.c + return; + + default: -+ printk("Unkown/Unsupported hypercall: verb is: %d\n", verb); -+ *ret_val = ++ printk("Unkown/Unsupported hypercall: verb is: %d\n", verb); ++ *ret_val = + hv_build_hcall_retval(HV_STATUS_INVALID_HYPERCALL_CODE, 0); + return; + } +} -Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.h +Index: xen-3.4.0-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.h =================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.h 2009-02-12 10:18:31.000000000 -0700 +--- /dev/null ++++ xen-3.4.0-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.h @@ -0,0 +1,46 @@ +/**************************************************************************** + | @@ -452,10 +452,10 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_hypercall.h +#define HV_NOTIFY_LONG_SPIN_WAIT 0x0008 + +#endif /* HV_HYPERCALL_H */ -Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c +Index: xen-3.4.0-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c =================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c 2009-02-12 10:18:31.000000000 -0700 +--- /dev/null ++++ xen-3.4.0-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c @@ -0,0 +1,1008 @@ +/**************************************************************************** + | @@ -482,7 +482,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + +/* + * nsintercept.c. -+ * This file implements the intercepts to support the Hyperv Shim. ++ * This file implements the intercepts to support the Hyperv Shim. + * + * Engineering Contact: K. Y. Srinivasan + */ @@ -529,7 +529,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c +get_virt_from_gmfn(struct domain *d, unsigned long gmfn) +{ + unsigned long mfn = gmfn_to_mfn(d, gmfn); -+ if (mfn == INVALID_MFN) ++ if (mfn == INVALID_MFN) + return (NULL); + return (map_domain_page(mfn)); +} @@ -542,28 +542,28 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + /* + * XXXKYS: Check the trigger mode. + */ -+ if (vlapic_set_irq(vlapic, vector, 1)) ++ if (vlapic_set_irq(vlapic, vector, 1)) + vcpu_kick(v); +} + + -+static inline void ++static inline void +hv_write_guestid_msr(hv_partition_t *curp, hv_vcpu_t *cur_vcpu, u64 msr_content) +{ + curp->guest_id_msr = msr_content; -+ if (curp->guest_id_msr == 0) ++ if (curp->guest_id_msr == 0) + { + /* + * Guest has cleared the guest ID; + * clear the hypercall page. + */ -+ if (curp->hypercall_msr) ++ if (curp->hypercall_msr) + cur_vcpu->flags &= ~HV_VCPU_UP; + } +} + + -+static inline void ++static inline void +hv_write_hypercall_msr(hv_partition_t *curp, + hv_vcpu_t *cur_vcpu, + u64 msr_content) @@ -574,30 +574,30 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + + spin_lock(&curp->lock); + gmfn = (msr_content >> 12); -+ if (curp->guest_id_msr == 0) ++ if (curp->guest_id_msr == 0) + { + /* Nothing to do if the guest is not registered*/ + spin_unlock(&curp->lock); + return; + } + /* -+ * Guest is registered; see if we can turn-on the ++ * Guest is registered; see if we can turn-on the + * hypercall page. -+ * XXXKYS: Can the guest write the GPA in one call and ++ * XXXKYS: Can the guest write the GPA in one call and + * subsequently enable it? Check. For now assume that all the + * info is specified in one call. + */ -+ if (((u32)msr_content & (0x00000001)) == 0) ++ if (((u32)msr_content & (0x00000001)) == 0) + { + /* + * The client is not enabling the hypercall; just -+ * ignore everything. ++ * ignore everything. + */ + spin_unlock(&curp->lock); + return; + } + hypercall_page = get_virt_from_gmfn(d,gmfn); -+ if (hypercall_page == NULL) ++ if (hypercall_page == NULL) + { + /* + * The guest specified a bogus GPA; inject a GP fault @@ -609,9 +609,9 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + } + hv_hypercall_page_initialize(hypercall_page); + unmap_domain_page(hypercall_page); -+ if (hvm_funcs.guest_x86_mode(current) == 8) ++ if (hvm_funcs.guest_x86_mode(current) == 8) + curp->long_mode_guest = 1; -+ else ++ else + curp->long_mode_guest = 0; + curp->hypercall_msr = msr_content; + spin_unlock(&curp->lock); @@ -619,27 +619,27 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c +} + + -+int ++int +hyperv_initialize(struct domain *d) +{ + int i; + printk("Hyperv extensions initialized\n"); -+ if (hyperv_dom_create(d)) ++ if (hyperv_dom_create(d)) + { + printk("Hyperv dom create failed\n"); + return (1); + } -+ for (i=0; i < MAX_VIRT_CPUS; i++) ++ for (i=0; i < MAX_VIRT_CPUS; i++) + { -+ if (d->vcpu[i] != NULL) ++ if (d->vcpu[i] != NULL) + { -+ if (hyperv_vcpu_initialize(d->vcpu[i])) ++ if (hyperv_vcpu_initialize(d->vcpu[i])) + { + int j; -+ for (j= (i-1); j >=0; j--) ++ for (j= (i-1); j >=0; j--) + { + hyperv_vcpu_destroy(d->vcpu[j]); -+ } ++ } + hyperv_dom_destroy(d); + return (1); + } @@ -658,13 +658,13 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c +static inline int +hv_call_from_bios(void) +{ -+ if (hvm_paging_enabled(current)) ++ if (hvm_paging_enabled(current)) + return (0); -+ else ++ else + return (1); +} + -+ ++ +static inline int +hv_os_registered(void) +{ @@ -674,11 +674,11 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + + + -+static inline void ++static inline void +hv_set_partition_privileges(hv_partition_t *hvpp) +{ + /* -+ * This is based on the hypervisor spec under section 5.2.3. ++ * This is based on the hypervisor spec under section 5.2.3. + */ + hvpp->privileges = HV_SHIM_PRIVILEGES; +} @@ -689,13 +689,13 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + /* + *For now we recommend all the features. Need to validate. + */ -+ if ( paging_mode_hap(current->domain)) ++ if ( paging_mode_hap(current->domain)) + /* + * If HAP is enabled; the guest should not use TLB flush + * related enlightenments. + */ + return (USE_CSWITCH_HCALL | USE_APIC_MSRS | USE_RESET_MSR | USE_RELAXED_TIMING); -+ else ++ else + /* + * For now disable TLB flush enlightenments. + */ @@ -714,9 +714,9 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c +{ + unsigned long icr_low, icr_high; + -+ icr_low = vlapic_mmio_handler.read_handler(current, ++ icr_low = vlapic_mmio_handler.read_handler(current, + (vlapic_base_address(vcpu_vlapic(current)) + APIC_ICR), 4, &icr_low); -+ icr_high = vlapic_mmio_handler.read_handler(current, ++ icr_high = vlapic_mmio_handler.read_handler(current, + (vlapic_base_address(vcpu_vlapic(current)) + APIC_ICR2), 4, &icr_high); + *icr_content = (((u64)icr_high<< 32) | icr_low); + @@ -726,8 +726,8 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c +hv_read_tpr(u64 *tpr_content) +{ + -+ vlapic_mmio_handler.read_handler(current, -+ (vlapic_base_address(vcpu_vlapic(current)) + APIC_TASKPRI), ++ vlapic_mmio_handler.read_handler(current, ++ (vlapic_base_address(vcpu_vlapic(current)) + APIC_TASKPRI), + 4, (unsigned long *)&tpr_content); +} + @@ -736,7 +736,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c +{ + u32 eoi = (u32)msr_content; + -+ vlapic_mmio_handler.write_handler(current, ++ vlapic_mmio_handler.write_handler(current, + (vlapic_base_address(vcpu_vlapic(current)) + APIC_EOI), 4, eoi); + +} @@ -748,16 +748,16 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + icr_low = (u32)msr_content; + icr_high = (u32)(msr_content >> 32); + -+ if (icr_high != 0) ++ if (icr_high != 0) + { -+ vlapic_mmio_handler.write_handler(current, -+ (vlapic_base_address(vcpu_vlapic(current)) + APIC_ICR2), 4, ++ vlapic_mmio_handler.write_handler(current, ++ (vlapic_base_address(vcpu_vlapic(current)) + APIC_ICR2), 4, + icr_high); + } -+ if (icr_low != 0) ++ if (icr_low != 0) + { -+ vlapic_mmio_handler.write_handler(current, -+ (vlapic_base_address(vcpu_vlapic(current)) + APIC_ICR), 4, ++ vlapic_mmio_handler.write_handler(current, ++ (vlapic_base_address(vcpu_vlapic(current)) + APIC_ICR), 4, + icr_low); + } + @@ -769,7 +769,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + u32 tpr = (u32)msr_content; + + -+ vlapic_mmio_handler.write_handler(current, ++ vlapic_mmio_handler.write_handler(current, + (vlapic_base_address(vcpu_vlapic(current)) + APIC_TASKPRI), 4, tpr); + +} @@ -782,22 +782,22 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + memset(hypercall_page, 0, PAGE_SIZE); + p = (char *)(hypercall_page) ; + /* -+ * We need to differentiate hypercalls that are to be processed by Xen -+ * from those that need to be processed by the hyperV shim. Xen hypercalls ++ * We need to differentiate hypercalls that are to be processed by Xen ++ * from those that need to be processed by the hyperV shim. Xen hypercalls + * use eax to pass the opcode; set the high order bit in eax for hypercalls + * destined for the hyperV shim (thanks Steven) + */ + *(u8 *)(p + 0) = 0x0d; /* eax or imm32 */ -+ *(u8 *)(p + 1) = 0x00; -+ *(u8 *)(p + 2) = 0x00; -+ *(u8 *)(p + 3) = 0x00; ++ *(u8 *)(p + 1) = 0x00; ++ *(u8 *)(p + 2) = 0x00; ++ *(u8 *)(p + 3) = 0x00; + *(u8 *)(p + 4) = 0x80; /* eax |= HYPERV_HCALL */ + + *(u8 *)(p + 5) = 0x0f; /* vmcall */ + *(u8 *)(p + 6) = 0x01; -+ if (boot_cpu_data.x86_vendor == 0) ++ if (boot_cpu_data.x86_vendor == 0) + *(u8 *)(p + 7) = 0xc1; -+ else ++ else + *(u8 *)(p + 7) = 0xd9; + *(u8 *)(p + 8) = 0xc3; /* ret */ +} @@ -805,7 +805,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c +static inline int +hv_access_time_refcnt(hv_partition_t *curp, u64 *msr_content) +{ -+ if (!hv_privilege_check(curp, HV_ACCESS_TIME_REF_CNT)) ++ if (!hv_privilege_check(curp, HV_ACCESS_TIME_REF_CNT)) + { + /* + * The partition does not have the privilege to @@ -826,7 +826,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + vcpup = &curp->vcpu_state[v->vcpu_id]; + vcpup->flags |= HV_VCPU_UP; +} -+ ++ +int +hyperv_do_hypercall(struct cpu_user_regs *pregs) +{ @@ -834,39 +834,39 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + hv_vcpu_t *vcpup; + int long_mode_guest = curp->long_mode_guest; + -+ if (pregs->_eax & HYPERV_HCALL) ++ if (pregs->_eax & HYPERV_HCALL) + { + u64 opcode, input, output, ret_val; + vcpup = &curp->vcpu_state[hv_get_current_vcpu_index()]; + + pregs->_eax &= ~HYPERV_HCALL; -+ /* ++ /* + * This is an extension hypercall; process it; but first make + * sure that the CPU is in the right state for invoking + * the hypercall - protected mode at CPL 0. + */ -+ if (hv_invalid_cpu_state()) ++ if (hv_invalid_cpu_state()) + { + hvm_inject_exception(TRAP_gp_fault, 0, 0); + ret_val = hv_build_hcall_retval(HV_STATUS_INVALID_VP_STATE, 0); + hv_set_syscall_retval(pregs, long_mode_guest, ret_val); + return (1); + } -+ if (long_mode_guest) ++ if (long_mode_guest) + { + opcode = pregs->ecx; + input = pregs->edx; + output = pregs->r8; -+ } else ++ } else + { -+ opcode = ++ opcode = + ((((u64)pregs->edx) << 32) | ((u64)pregs->eax)); -+ input = ++ input = + ((((u64)pregs->ebx) << 32) | ((u64)pregs->ecx)); -+ output = ++ output = + ((((u64)pregs->edi) << 32) | ((u64)pregs->esi)); + } -+ hv_handle_hypercall(opcode, input, output, &ret_val); ++ hv_handle_hypercall(opcode, input, output, &ret_val); + hv_set_syscall_retval(pregs, long_mode_guest, ret_val); + return (1); + } @@ -876,13 +876,13 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + return (0); +} + -+ -+int ++ ++int +hyperv_dom_create(struct domain *d) +{ + hv_partition_t *hvpp; + hvpp = xmalloc_bytes(sizeof(hv_partition_t)); -+ if (hvpp == NULL) ++ if (hvpp == NULL) + { + printk("Hyprv Dom Create: Memory allocation failed\n"); + return (1); @@ -890,7 +890,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + memset(hvpp, 0, sizeof(*hvpp)); + spin_lock_init(&hvpp->lock); + /* -+ * Set the partition wide privilege; We can start with no privileges ++ * Set the partition wide privilege; We can start with no privileges + * and progressively turn on fancier hypervisor features. + */ + hv_set_partition_privileges(hvpp); @@ -902,7 +902,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + return (0); +} + -+void ++void +hyperv_dom_destroy(struct domain *d) +{ + int i; @@ -911,12 +911,12 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + ASSERT(curp != NULL); +#ifdef HV_STATS + printk("DUMP STATS\n"); -+ for (i=0; i < MAX_VIRT_CPUS; i++) -+ if (d->vcpu[i] != NULL) ++ for (i=0; i < MAX_VIRT_CPUS; i++) ++ if (d->vcpu[i] != NULL) + hv_print_stats(curp, i); -+#endif -+ -+ xfree(d->arch.hvm_domain.hyperv_handle); ++#endif ++ ++ xfree(d->arch.hvm_domain.hyperv_handle); + d->arch.hvm_domain.hyperv_handle = NULL; +} + @@ -927,20 +927,20 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + hv_partition_t *curp = v->domain->arch.hvm_domain.hyperv_handle; + vcpup = &curp->vcpu_state[v->vcpu_id]; + atomic_inc(&curp->vcpus_active); -+ if (v->vcpu_id == 0) ++ if (v->vcpu_id == 0) + vcpup->flags |= HV_VCPU_BOOT_CPU; + /* -+ * Initialize all the synthetic MSRs corresponding to this VCPU. -+ * Note that all state is set to 0 to begin ++ * Initialize all the synthetic MSRs corresponding to this VCPU. ++ * Note that all state is set to 0 to begin + * with. + */ + vcpup->version_msr = 0x00000001; -+ vcpup->xen_vcpu = v; ++ vcpup->xen_vcpu = v; + + return (0); +} + -+void ++void +hyperv_vcpu_destroy(struct vcpu *v) +{ + hv_vcpu_t *vcpup; @@ -951,7 +951,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + vcpup->flags &= ~HV_VCPU_UP; +} + -+static int ++static int +hyperv_vcpu_save(struct domain *d, hvm_domain_context_t *h) +{ + struct vcpu *v; @@ -960,17 +960,17 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + hv_vcpu_t *vcpup; + hv_partition_t *curp = d->arch.hvm_domain.hyperv_handle; + -+ if (curp == NULL) ++ if (curp == NULL) + return 0; -+ -+ for_each_vcpu(d, v) ++ ++ for_each_vcpu(d, v) + { + vcpup = &curp->vcpu_state[v->vcpu_id]; -+ -+ /* -+ * We don't need to save state for a ++ ++ /* ++ * We don't need to save state for a + * vcpu that is down; the restore -+ * code will leave it down if there is nothing saved. ++ * code will leave it down if there is nothing saved. + */ + if ( test_bit(_VPF_down, &v->pause_flags) ) + continue; @@ -983,7 +983,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + return 0; +} + -+static int ++static int +hyperv_vcpu_restore(struct domain *d, hvm_domain_context_t *h) +{ + int vcpuid; @@ -992,13 +992,13 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + hv_vcpu_t *vcpup; + hv_partition_t *curp = d->arch.hvm_domain.hyperv_handle; + -+ if (curp == NULL) ++ if (curp == NULL) + return 0; + /* Which vcpu is this? */ + vcpuid = hvm_load_instance(h); + vcpup = &curp->vcpu_state[vcpuid]; + ASSERT(vcpup != NULL); -+ if ( hvm_load_entry(HYPERV_CPU, h, &ctxt) != 0 ) ++ if ( hvm_load_entry(HYPERV_CPU, h, &ctxt) != 0 ) + return -EINVAL; + + vcpup->control_msr = ctxt.control_msr; @@ -1008,7 +1008,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + return 0; +} + -+static int ++static int +hyperv_dom_save(struct domain *d, hvm_domain_context_t *h) +{ + struct hvm_hyperv_dom ctxt; @@ -1022,27 +1022,27 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + ctxt.hypercall_msr = curp->hypercall_msr; + ctxt.long_mode = curp->long_mode_guest; + ctxt.ext_id = d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR]; -+ return (hvm_save_entry(HYPERV_DOM, 0, h, &ctxt)); ++ return (hvm_save_entry(HYPERV_DOM, 0, h, &ctxt)); +} + -+static int ++static int +hyperv_dom_restore(struct domain *d, hvm_domain_context_t *h) +{ + struct hvm_hyperv_dom ctxt; + hv_partition_t *curp; + void *hypercall_page; + -+ if ( hvm_load_entry(HYPERV_DOM, h, &ctxt) != 0 ) ++ if ( hvm_load_entry(HYPERV_DOM, h, &ctxt) != 0 ) + return -EINVAL; + d->arch.hvm_domain.params[HVM_PARAM_EXTEND_HYPERVISOR] = 1; -+ if (hyperv_initialize(d)) ++ if (hyperv_initialize(d)) + return -EINVAL; + curp = d->arch.hvm_domain.hyperv_handle; + + curp->guest_id_msr = ctxt.guestid_msr; + curp->hypercall_msr = ctxt.hypercall_msr; + /* -+ * We may have migrated from a sles10 host; re-initialize the ++ * We may have migrated from a sles10 host; re-initialize the + * hypercall page. + */ + hypercall_page = get_virt_from_gmfn(d, (curp->hypercall_msr >>12)); @@ -1051,20 +1051,20 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + hv_hypercall_page_initialize(hypercall_page); + unmap_domain_page(hypercall_page); + curp->long_mode_guest = ctxt.long_mode; -+ return 0; ++ return 0; +} + +HVM_REGISTER_SAVE_RESTORE(HYPERV_DOM, hyperv_dom_save, hyperv_dom_restore, + 1, HVMSR_PER_DOM); -+ ++ + +HVM_REGISTER_SAVE_RESTORE(HYPERV_CPU,hyperv_vcpu_save,hyperv_vcpu_restore, + 1, HVMSR_PER_VCPU); + + +static int -+hv_preprocess_cpuid_leaves(unsigned int input, unsigned int *eax, -+ unsigned int *ebx, unsigned int *ecx, ++hv_preprocess_cpuid_leaves(unsigned int input, unsigned int *eax, ++ unsigned int *ebx, unsigned int *ecx, + unsigned int *edx ) +{ + struct domain *d = current->domain; @@ -1072,10 +1072,10 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + + if (extid == 1) { + /* -+ * Enlightened Windows guest; need to remap and handle ++ * Enlightened Windows guest; need to remap and handle + * leaves used by PV front-end drivers. + */ -+ if ((input >= 0x40000000) && (input <= 0x40000005)) ++ if ((input >= 0x40000000) && (input <= 0x40000005)) + return (0); + /* + * PV drivers use cpuid to query the hypervisor for details. On @@ -1085,7 +1085,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + * 4097: VMM Version (corresponds to 0x40000001 on Linux) + * 4098: Hypercall details (corresponds to 0x40000002 on Linux) + */ -+ if ((input >= 0x40001000) && (input <= 0x40001002)) ++ if ((input >= 0x40001000) && (input <= 0x40001002)) + { + /* Get rid of the offset and let xen handle it */ + input -= 0x1000; @@ -1094,12 +1094,12 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + if (input == 0x40000002) + *ebx |= 0x1000; + return (1); -+ } -+ } ++ } ++ } + return (0); +} + -+int ++int +hyperv_do_cpu_id(unsigned int input, unsigned int *eax, unsigned int *ebx, + unsigned int *ecx, unsigned int *edx) +{ @@ -1108,67 +1108,67 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + + /* + * hvmloader uses cpuid to set up a hypercall page; we don't want to -+ * intercept calls coming from the bootstrap (bios) code in the HVM ++ * intercept calls coming from the bootstrap (bios) code in the HVM + * guest; we discriminate based on if paging is enabled or not. + */ -+ if (hv_call_from_bios()) ++ if (hv_call_from_bios()) + /* + * We don't intercept this. + */ + return (0); -+ -+ if (input == 0x00000001) -+ { ++ ++ if (input == 0x00000001) ++ { + *ecx |= 0x80000000; + return (1); -+ } ++ } + -+ if (hv_preprocess_cpuid_leaves(input, eax, ebx, ecx, edx)) ++ if (hv_preprocess_cpuid_leaves(input, eax, ebx, ecx, edx)) + return (1); + idx = (input - 0x40000000); + -+ switch (idx) ++ switch (idx) + { + case 0: + /* -+ * 0x40000000: Hypervisor identification. ++ * 0x40000000: Hypervisor identification. + */ + *eax = 0x40000005; /* For now clamp this */ -+ *ebx = 0x65766f4e; /* "Nove" */ ++ *ebx = 0x65766f4e; /* "Nove" */ + *ecx = 0x68536c6c; /* "llSh" */ -+ *edx = 0x76486d69; /* "imHv" */ ++ *edx = 0x76486d69; /* "imHv" */ + break; + + case 1: + /* -+ * 0x40000001: Hypervisor identification. ++ * 0x40000001: Hypervisor identification. + */ + *eax = 0x31237648; /* "Hv#1*/ -+ *ebx = 0; /* Reserved */ ++ *ebx = 0; /* Reserved */ + *ecx = 0; /* Reserved */ -+ *edx = 0; /* Reserved */ ++ *edx = 0; /* Reserved */ + break; + case 2: + /* -+ * 0x40000002: Guest Info ++ * 0x40000002: Guest Info + */ -+ if (hv_os_registered()) ++ if (hv_os_registered()) + { -+ u64 guest_id = curp->guest_id_msr; ++ u64 guest_id = curp->guest_id_msr; + u32 guest_major, guest_minor; + + guest_major = ((guest_id >> 32) & 0xff); + guest_minor = ((guest_id >> 24) & 0xff); + *eax = (guest_id & 0xffff); /* Build # 15:0 */ -+ *ebx = ++ *ebx = + (guest_major << 16) | (guest_minor); /*Major: 31:16; Minor: 15:0*/ + *ecx = ((guest_id >>16) & 0xff); /*Service Pack/Version: 23:16*/ + /* -+ * Service branch (31:24)|Service number (23:0) ++ * Service branch (31:24)|Service number (23:0) + * Not sure what these numbers are: XXXKYS. + */ + *edx = 0; /*Service branch (31:24)|Service number (23:0) */ -+ } else ++ } else + { + *eax = 0; + *ebx = 0; @@ -1182,7 +1182,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + */ + *eax = HV_SHIM_SUPPORTED_MSRS; + /* We only support AcessSelfPartitionId bit 1 */ -+ *ebx = (HV_SHIM_PRIVILEGES>>32); ++ *ebx = (HV_SHIM_PRIVILEGES>>32); + *ecx = 0; /* Reserved */ + *edx = 0; /*No MWAIT (bit 0), No debugging (bit 1)*/ + break; @@ -1191,7 +1191,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + * 0x40000004: Imlementation recommendations. + */ + *eax = hv_get_recommendations(); -+ *ebx = 2047; ++ *ebx = 2047; + *ebx = 0; /* Reserved */ + *ecx = 0; /* Reserved */ + *edx = 0; /* Reserved */ @@ -1199,7 +1199,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + case 5: + /* + * 0x40000005: Implementation limits. -+ * Currently we retrieve maximum number of vcpus and ++ * Currently we retrieve maximum number of vcpus and + * logical processors (hardware threads) supported. + */ + *eax = hv_get_max_vcpus_supported(); @@ -1237,17 +1237,17 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + + /* + * hvmloader uses rdmsr; we don't want to -+ * intercept calls coming from the bootstrap (bios) code in the HVM ++ * intercept calls coming from the bootstrap (bios) code in the HVM + * guest; we descriminate based on the instruction pointer. + */ -+ if (hv_call_from_bios()) ++ if (hv_call_from_bios()) + /* + * We don't intercept this. + */ + return (0); -+ switch (idx) ++ switch (idx) + { -+ case HV_MSR_GUEST_OS_ID: ++ case HV_MSR_GUEST_OS_ID: + spin_lock(&curp->lock); + regs->eax = (u32)(curp->guest_id_msr & 0xFFFFFFFF); + regs->edx = (u32)(curp->guest_id_msr >> 32); @@ -1315,12 +1315,12 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + case HV_MSR_PVDRV_HCALL: + regs->eax = 0; + regs->edx = 0; -+ break; ++ break; + case HV_MSR_SYSTEM_RESET: + regs->eax = 0; + regs->edx = 0; -+ break; -+ case HV_MSR_APIC_ASSIST_PAGE: ++ break; ++ case HV_MSR_APIC_ASSIST_PAGE: + /* + * For now ignore this. + */ @@ -1329,7 +1329,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + break; + default: + /* -+ * We did not handle the MSR address specified; ++ * We did not handle the MSR address specified; + * let the caller figure out + * What to do. + */ @@ -1355,10 +1355,10 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + + /* + * hvmloader uses wrmsr; we don't want to -+ * intercept calls coming from the bootstrap (bios) code in the HVM ++ * intercept calls coming from the bootstrap (bios) code in the HVM + * guest; we descriminate based on the instruction pointer. + */ -+ if (hv_call_from_bios()) ++ if (hv_call_from_bios()) + /* + * We don't intercept this. + */ @@ -1366,18 +1366,18 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + msr_content = + (u32)regs->eax | ((u64)regs->edx << 32); + -+ switch (idx) ++ switch (idx) + { -+ case HV_MSR_GUEST_OS_ID: ++ case HV_MSR_GUEST_OS_ID: + hv_write_guestid_msr(curp, cur_vcpu, msr_content); -+ break; ++ break; + case HV_MSR_HYPERCALL: + hv_write_hypercall_msr(curp, cur_vcpu, msr_content); + break; + + case HV_MSR_VP_INDEX: + goto msr_write_error; -+ ++ + case HV_MSR_EOI: + if (!hv_privilege_check(curp, HV_ACCESS_APIC_MSRS)) { + goto msr_write_error; @@ -1413,7 +1413,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + if (!hv_privilege_check(curp, HV_ACCESS_SYNC_MSRS)) { + goto msr_write_error; + } -+ cur_vcpu->control_msr = msr_content; ++ cur_vcpu->control_msr = msr_content; + break; + case HV_MSR_SVERSION: + if (!hv_privilege_check(curp, HV_ACCESS_SYNC_MSRS)) { @@ -1424,7 +1424,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + */ + hvm_inject_exception(TRAP_gp_fault, 0, 0); + break; -+ case HV_MSR_TIME_REF_COUNT: ++ case HV_MSR_TIME_REF_COUNT: + /* + * This is a read-only msr. + */ @@ -1435,7 +1435,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + * Establish the hypercall page for PV drivers. + */ + wrmsr_hypervisor_regs(0x40000000, regs->eax, regs->edx); -+ break; ++ break; + case HV_MSR_SYSTEM_RESET: + /* + * Shutdown the domain/partition. @@ -1443,16 +1443,16 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + if (msr_content & 0x1) { + domain_shutdown(d, SHUTDOWN_reboot); + } -+ break; -+ case HV_MSR_APIC_ASSIST_PAGE: ++ break; ++ case HV_MSR_APIC_ASSIST_PAGE: + /* + * For now ignore this. + */ + break; -+ ++ + default: + /* -+ * We did not handle the MSR address; ++ * We did not handle the MSR address; + * let the caller deal with this. + */ + return (0); @@ -1465,10 +1465,10 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_intercept.c + hvm_inject_exception(TRAP_gp_fault, 0, 0); + return (1); +} -Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_shim.h +Index: xen-3.4.0-testing/xen/arch/x86/hvm/hyperv/hv_shim.h =================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_shim.h 2009-02-12 10:18:31.000000000 -0700 +--- /dev/null ++++ xen-3.4.0-testing/xen/arch/x86/hvm/hyperv/hv_shim.h @@ -0,0 +1,285 @@ +/**************************************************************************** + | @@ -1601,26 +1601,26 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_shim.h + * Supported Synthetic MSRs. 0.83 HyperV spec, section 3.4 + * Supported features. + */ -+#define _MSR_VP_RUNTIME 0 ++#define _MSR_VP_RUNTIME 0 +#define MSR_VP_RUNTIME (1U<<_MSR_VP_RUNTIME) -+#define _MSR_TIME_REF_CNT 1 ++#define _MSR_TIME_REF_CNT 1 +#define MSR_TIME_REF_CNT (1U<<_MSR_TIME_REF_CNT) -+#define _MSR_SYN_IC 2 -+#define MSR_SYN_IC (1U<<_MSR_SYN_IC) ++#define _MSR_SYN_IC 2 ++#define MSR_SYN_IC (1U<<_MSR_SYN_IC) +#define _MSR_SYN_TIMER 3 +#define MSR_SYN_TIMER (1U<<_MSR_SYN_TIMER) -+#define _APIC_MSRS 4 ++#define _APIC_MSRS 4 +#define APIC_MSRS (1U<<_APIC_MSRS) -+#define _HYPERCALL_MSRS 5 ++#define _HYPERCALL_MSRS 5 +#define HYPERCALL_MSRS (1U<<_HYPERCALL_MSRS) +#define _MSR_VP_INDEX 6 +#define MSR_VP_INDEX (1U<<_MSR_VP_INDEX) -+#define _RESET_MSR 7 -+#define RESET_MSR (1U<<_RESET_MSR) ++#define _RESET_MSR 7 ++#define RESET_MSR (1U<<_RESET_MSR) + +#define HV_SHIM_SUPPORTED_MSRS \ + (MSR_TIME_REF_CNT|APIC_MSRS|HYPERCALL_MSRS|MSR_VP_INDEX|RESET_MSR) -+ ++ +/* + * MSR for supporting PV drivers on longhorn. + */ @@ -1654,7 +1654,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_shim.h + +typedef struct hv_vcpu { + /* -+ * Per-vcpu state to support the hyperv shim; ++ * Per-vcpu state to support the hyperv shim; + */ + unsigned long flags; + /* @@ -1671,10 +1671,10 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_shim.h + +typedef struct hv_partition { + /* -+ * State maintained on a per guest basis to implement ++ * State maintained on a per guest basis to implement + * the Hyperv shim. + */ -+ s_time_t domain_boot_time; ++ s_time_t domain_boot_time; + spinlock_t lock; + atomic_t vcpus_active; + u64 guest_id_msr; @@ -1699,7 +1699,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_shim.h +#define HV_ACCESS_SYNC_TIMERS (1ULL << 3) +#define HV_ACCESS_APIC_MSRS (1ULL << 4) +#define HV_ACCESS_PARTITION_ID (1ULL << 33) -+ ++ +#define hv_get_current_partition() \ +((current)->domain->arch.hvm_domain.hyperv_handle) + @@ -1711,7 +1711,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_shim.h +{ + int state; + state = hvm_funcs.guest_x86_mode(current); -+ if ((state == 4) || (state == 8)) ++ if ((state == 4) || (state == 8)) + { + return (0); + } @@ -1727,28 +1727,28 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/hyperv/hv_shim.h + return (ret_val); +} + -+static inline void hv_set_syscall_retval(struct cpu_user_regs *pregs, ++static inline void hv_set_syscall_retval(struct cpu_user_regs *pregs, + int long_mode, u64 ret_val) +{ -+ if (long_mode) ++ if (long_mode) + { + pregs->eax = ret_val; -+ } -+ else ++ } ++ else + { + pregs->edx = (u32)(ret_val >> 32); + pregs->eax = (u32)(ret_val); + } +} + -+static inline int ++static inline int +hv_privilege_check(hv_partition_t *curp, u64 flags) +{ + return ((curp->privileges & flags)? 1: 0); +} + +void -+hv_handle_hypercall(u64 opcode, u64 input, u64 output, ++hv_handle_hypercall(u64 opcode, u64 input, u64 output, + u64 *ret_val); + + diff --git a/init.xend b/init.xend index 7e0e613..84144ce 100644 --- a/init.xend +++ b/init.xend @@ -21,8 +21,7 @@ . /etc/rc.status rc_reset -XEND=`ps ax | grep -w xend | grep -w python | awk '{ print $1 }'` -XEND=`echo $XEND` +XEND=`pidofproc /usr/sbin/xend` await_daemons_up() { @@ -115,7 +114,7 @@ case "$1" in if [ ! -z "$XEND" ]; then echo -n "(pid $XEND) " fi - xend status + checkproc /usr/sbin/xend ;; restart|reload) check $1 diff --git a/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch b/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch new file mode 100644 index 0000000..c5e920a --- /dev/null +++ b/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch @@ -0,0 +1,32 @@ +qcow2 corruption: Fix alloc_cluster_link_l2 (Kevin Wolf) + +This patch fixes a qcow2 corruption bug introduced in SVN Rev 5861. L2 tables +are big endian, so entries must be converted before being passed to functions. + +This bug is easy to trigger. The following script will create and destroy a +qcow2 image (the header is gone after three loop iterations): + + #!/bin/bash + qemu-img create -f qcow2 test.qcow 1M + for i in $(seq 1 10); do + qemu-system-x86_64 -hda test.qcow -monitor stdio > /dev/null 2>&1 < + +Index: xen-3.4.0-testing/tools/ioemu-remote/block-qcow2.c +=================================================================== +--- xen-3.4.0-testing.orig/tools/ioemu-remote/block-qcow2.c ++++ xen-3.4.0-testing/tools/ioemu-remote/block-qcow2.c +@@ -916,7 +916,7 @@ static int alloc_cluster_link_l2(BlockDr + goto err; + + for (i = 0; i < j; i++) +- free_any_clusters(bs, old_cluster[i], 1); ++ free_any_clusters(bs, be64_to_cpu(old_cluster[i]), 1); + + ret = 0; + err: diff --git a/ioemu-blktap-barriers.patch b/ioemu-blktap-barriers.patch index 465c890..fe03736 100644 --- a/ioemu-blktap-barriers.patch +++ b/ioemu-blktap-barriers.patch @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c +Index: xen-3.4.0-testing/tools/ioemu-remote/hw/xen_blktap.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_blktap.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c -@@ -357,6 +357,15 @@ static void qemu_send_responses(void* op +--- xen-3.4.0-testing.orig/tools/ioemu-remote/hw/xen_blktap.c ++++ xen-3.4.0-testing/tools/ioemu-remote/hw/xen_blktap.c +@@ -362,6 +362,15 @@ static void qemu_send_responses(void* op } /** @@ -18,7 +18,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c * Callback function for the IO message pipe. Reads requests from the ring * and processes them (call qemu read/write functions). * -@@ -375,6 +384,7 @@ static void handle_blktap_iomsg(void* pr +@@ -380,6 +389,7 @@ static void handle_blktap_iomsg(void* pr blkif_t *blkif = s->blkif; tapdev_info_t *info = s->ring_info; int page_size = getpagesize(); @@ -26,7 +26,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c struct aiocb_info *aiocb_info; -@@ -407,7 +417,7 @@ static void handle_blktap_iomsg(void* pr +@@ -412,7 +422,7 @@ static void handle_blktap_iomsg(void* pr /* Don't allow writes on readonly devices */ if ((s->flags & TD_RDONLY) && @@ -35,7 +35,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c blkif->pending_list[idx].status = BLKIF_RSP_ERROR; goto send_response; } -@@ -428,7 +438,7 @@ static void handle_blktap_iomsg(void* pr +@@ -433,7 +443,7 @@ static void handle_blktap_iomsg(void* pr DPRINTF("Sector request failed:\n"); DPRINTF("%s request, idx [%d,%d] size [%llu], " "sector [%llu,%llu]\n", @@ -44,7 +44,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c "WRITE" : "READ"), idx,i, (long long unsigned) -@@ -441,8 +451,14 @@ static void handle_blktap_iomsg(void* pr +@@ -446,8 +456,14 @@ static void handle_blktap_iomsg(void* pr blkif->pending_list[idx].secs_pending += nsects; @@ -60,7 +60,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c case BLKIF_OP_WRITE: aiocb_info = malloc(sizeof(*aiocb_info)); -@@ -462,6 +478,10 @@ static void handle_blktap_iomsg(void* pr +@@ -467,6 +483,10 @@ static void handle_blktap_iomsg(void* pr DPRINTF("ERROR: bdrv_write() == NULL\n"); goto send_response; } diff --git a/ioemu-blktap-fix-open.patch b/ioemu-blktap-fix-open.patch deleted file mode 100644 index 0ce4ce3..0000000 --- a/ioemu-blktap-fix-open.patch +++ /dev/null @@ -1,106 +0,0 @@ -commit 51259318c6d40d5dd962c92c561826714361120a -Author: Kevin Wolf -Date: Wed Jul 23 10:51:07 2008 +0200 - - qemu-xen: Fix open_disk for blktap disks - - Signed-off-by: Kevin Wolf - -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_blktap.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c -@@ -32,6 +32,11 @@ - #include - #include - -+#ifndef QEMU_TOOL -+#include "qemu-common.h" -+#include "sysemu.h" -+#endif -+ - #include "xen_blktap.h" - #include "block_int.h" - #include "qemu-char.h" -@@ -217,13 +222,15 @@ static int map_new_dev(struct td_state * - - static int open_disk(struct td_state *s, char *path, int readonly) - { -- struct disk_id id; - BlockDriverState* bs; -+ char* devname; -+ static int devnumber = 0; -+ int i; - -- DPRINTF("Opening %s\n", path); -- bs = calloc(1, sizeof(*bs)); -- -- memset(&id, 0, sizeof(struct disk_id)); -+ DPRINTF("Opening %s as blktap%d\n", path, devnumber); -+ asprintf(&devname, "blktap%d", devnumber++); -+ bs = bdrv_new(devname); -+ free(devname); - - if (bdrv_open(bs, path, 0) != 0) { - fprintf(stderr, "Could not open image file %s\n", path); -@@ -237,6 +244,18 @@ static int open_disk(struct td_state *s, - - s->info = ((s->flags & TD_RDONLY) ? VDISK_READONLY : 0); - -+#ifndef QEMU_TOOL -+ for (i = 0; i < MAX_DRIVES + 1; i++) { -+ if (drives_table[i].bdrv == NULL) { -+ drives_table[i].bdrv = bs; -+ drives_table[i].type = IF_BLKTAP; -+ drives_table[i].bus = 0; -+ drives_table[i].unit = 0; -+ break; -+ } -+ } -+#endif -+ - return 0; - } - -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.h -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_blktap.h -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.h -@@ -30,11 +30,6 @@ typedef uint32_t td_flag_t; - - #define TD_RDONLY 1 - --struct disk_id { -- char *name; -- int drivertype; --}; -- - /* This structure represents the state of an active virtual disk. */ - struct td_state { - BlockDriverState* bs; -Index: xen-3.3.1-testing/tools/ioemu-remote/sysemu.h -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/sysemu.h -+++ xen-3.3.1-testing/tools/ioemu-remote/sysemu.h -@@ -116,6 +116,7 @@ extern unsigned int nb_prom_envs; - #endif - - typedef enum { -+ IF_BLKTAP, - IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD - } BlockInterfaceType; - -Index: xen-3.3.1-testing/tools/ioemu-remote/vl.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/vl.c -+++ xen-3.3.1-testing/tools/ioemu-remote/vl.c -@@ -5416,6 +5416,9 @@ static int drive_init(struct drive_opt * - case IF_PFLASH: - case IF_MTD: - break; -+ case IF_BLKTAP: -+ /* Cannot happen - silence gcc warning */ -+ break; - } - if (!file[0]) - return 0; diff --git a/ioemu-blktap-fv-init.patch b/ioemu-blktap-fv-init.patch index bc67327..d958728 100644 --- a/ioemu-blktap-fv-init.patch +++ b/ioemu-blktap-fv-init.patch @@ -1,16 +1,16 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_machine_fv.c +Index: xen-3.4.0-testing/tools/ioemu-remote/hw/xen_machine_fv.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_machine_fv.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_machine_fv.c -@@ -185,6 +185,7 @@ void qemu_invalidate_map_cache(void) +--- xen-3.4.0-testing.orig/tools/ioemu-remote/hw/xen_machine_fv.c ++++ xen-3.4.0-testing/tools/ioemu-remote/hw/xen_machine_fv.c +@@ -266,6 +266,7 @@ void qemu_invalidate_entry(uint8_t *buff #endif /* defined(MAPCACHE) */ +extern void init_blktap(void); static void xen_init_fv(ram_addr_t ram_size, int vga_ram_size, - const char *boot_device, DisplayState *ds, -@@ -210,6 +211,11 @@ static void xen_init_fv(ram_addr_t ram_s + const char *boot_device, +@@ -291,6 +292,11 @@ static void xen_init_fv(ram_addr_t ram_s } #endif diff --git a/ioemu-blktap-image-format.patch b/ioemu-blktap-image-format.patch index 115c476..a0d8ec4 100644 --- a/ioemu-blktap-image-format.patch +++ b/ioemu-blktap-image-format.patch @@ -1,51 +1,25 @@ -Index: xen-3.3.1-testing/tools/blktap/drivers/tapdisk.h +From 5ac882a6d7499e4a36103db071203bf4d1ddfe1f Mon Sep 17 00:00:00 2001 +From: Kevin Wolf +Date: Tue, 10 Mar 2009 16:26:45 +0100 +Subject: [PATCH 2/6] ioemu: Use the image format sent by blktapctrl + +Currently the blktap backend in ioemu lets qemu guess which format an +image is in. This was a security problem and the blktap backend +doesn't work any more since this was fixed in qemu. + +This patch changes ioemu to respect the format it gets from blktapctrl. + +Signed-off-by: Kevin Wolf +--- + hw/xen_blktap.c | 22 +++++++++++++++++++--- + hw/xen_blktap.h | 14 ++++++++++++++ + 2 files changed, 33 insertions(+), 3 deletions(-) + +Index: xen-3.4.0-testing/tools/ioemu-remote/hw/xen_blktap.c =================================================================== ---- xen-3.3.1-testing.orig/tools/blktap/drivers/tapdisk.h -+++ xen-3.3.1-testing/tools/blktap/drivers/tapdisk.h -@@ -159,16 +159,6 @@ extern struct tap_disk tapdisk_ram; - extern struct tap_disk tapdisk_qcow; - extern struct tap_disk tapdisk_qcow2; - --#define MAX_DISK_TYPES 20 -- --#define DISK_TYPE_AIO 0 --#define DISK_TYPE_SYNC 1 --#define DISK_TYPE_VMDK 2 --#define DISK_TYPE_RAM 3 --#define DISK_TYPE_QCOW 4 --#define DISK_TYPE_QCOW2 5 --#define DISK_TYPE_IOEMU 6 -- - - /*Define Individual Disk Parameters here */ - static disk_info_t aio_disk = { -Index: xen-3.3.1-testing/tools/blktap/lib/blktaplib.h -=================================================================== ---- xen-3.3.1-testing.orig/tools/blktap/lib/blktaplib.h -+++ xen-3.3.1-testing/tools/blktap/lib/blktaplib.h -@@ -211,6 +211,17 @@ typedef struct msg_pid { - #define CTLMSG_PID 9 - #define CTLMSG_PID_RSP 10 - -+/* disk driver types */ -+#define MAX_DISK_TYPES 20 -+ -+#define DISK_TYPE_AIO 0 -+#define DISK_TYPE_SYNC 1 -+#define DISK_TYPE_VMDK 2 -+#define DISK_TYPE_RAM 3 -+#define DISK_TYPE_QCOW 4 -+#define DISK_TYPE_QCOW2 5 -+#define DISK_TYPE_IOEMU 6 -+ - /* xenstore/xenbus: */ - #define DOMNAME "Domain-0" - int setup_probe_watch(struct xs_handle *h); -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_blktap.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c -@@ -222,9 +222,10 @@ static int map_new_dev(struct td_state * +--- xen-3.4.0-testing.orig/tools/ioemu-remote/hw/xen_blktap.c ++++ xen-3.4.0-testing/tools/ioemu-remote/hw/xen_blktap.c +@@ -220,9 +220,10 @@ static int map_new_dev(struct td_state * return -1; } @@ -57,7 +31,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c char* devname; static int devnumber = 0; int i; -@@ -234,7 +235,22 @@ static int open_disk(struct td_state *s, +@@ -232,7 +233,22 @@ static int open_disk(struct td_state *s, bs = bdrv_new(devname); free(devname); @@ -81,7 +55,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c fprintf(stderr, "Could not open image file %s\n", path); return -ENOMEM; } -@@ -529,7 +545,7 @@ static void handle_blktap_ctrlmsg(void* +@@ -527,7 +543,7 @@ static void handle_blktap_ctrlmsg(void* s = state_init(); /*Open file*/ @@ -90,13 +64,13 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c msglen = sizeof(msg_hdr_t); msg->type = CTLMSG_IMG_FAIL; msg->len = msglen; -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.h +Index: xen-3.4.0-testing/tools/ioemu-remote/hw/xen_blktap.h =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_blktap.h -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.h -@@ -50,4 +50,19 @@ typedef struct fd_list_entry { - struct fd_list_entry **pprev, *next; - } fd_list_entry_t; +--- xen-3.4.0-testing.orig/tools/ioemu-remote/hw/xen_blktap.h ++++ xen-3.4.0-testing/tools/ioemu-remote/hw/xen_blktap.h +@@ -52,4 +52,18 @@ typedef struct fd_list_entry { + + int init_blktap(void); +typedef struct disk_info { + int idnum; @@ -109,7 +83,6 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.h + { DISK_TYPE_VMDK, &bdrv_vmdk }, + { DISK_TYPE_QCOW, &bdrv_qcow }, + { DISK_TYPE_QCOW2, &bdrv_qcow2 }, -+ { DISK_TYPE_IOEMU, NULL }, + { -1, NULL } +}; + diff --git a/ioemu-blktap-zero-size.patch b/ioemu-blktap-zero-size.patch index ffedb36..c1ff6b7 100644 --- a/ioemu-blktap-zero-size.patch +++ b/ioemu-blktap-zero-size.patch @@ -1,16 +1,22 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c +From cb982fd919a52ff86f01025d0f92225bc7b2a956 Mon Sep 17 00:00:00 2001 +From: Kevin Wolf +Date: Tue, 10 Mar 2009 16:44:31 +0100 +Subject: [PATCH 5/6] ioemu: Fail on too small blktap disks + +The blktap infrastructure doesn't seems to be able to cope with images +that are smaller than a sector, it produced hangs for me. Such an +image isn't really useful anyway, so just fail gracefully. + +Signed-off-by: Kevin Wolf +--- + hw/xen_blktap.c | 6 ++++++ + 1 files changed, 6 insertions(+), 0 deletions(-) + +Index: xen-3.4.0-testing/tools/ioemu-remote/hw/xen_blktap.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_blktap.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c -@@ -67,6 +67,7 @@ int read_fd; - int write_fd; - - static pid_t process; -+int connected_disks = 0; - fd_list_entry_t *fd_start = NULL; - - extern char* get_snapshot_name(int devid); -@@ -260,6 +261,12 @@ static int open_disk(struct td_state *s, +--- xen-3.4.0-testing.orig/tools/ioemu-remote/hw/xen_blktap.c ++++ xen-3.4.0-testing/tools/ioemu-remote/hw/xen_blktap.c +@@ -258,6 +258,12 @@ static int open_disk(struct td_state *s, s->size = bs->total_sectors; s->sector_size = 512; @@ -23,82 +29,11 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c s->info = ((s->flags & TD_RDONLY) ? VDISK_READONLY : 0); #ifndef QEMU_TOOL -@@ -563,6 +570,7 @@ static void handle_blktap_ctrlmsg(void* - - /* Allocate the disk structs */ - s = state_init(); -+ connected_disks++; - - /*Open file*/ - if (s == NULL || open_disk(s, path, msg->drivertype, msg->readonly)) { -@@ -645,7 +653,8 @@ static void handle_blktap_ctrlmsg(void* - case CTLMSG_CLOSE: - s = get_state(msg->cookie); - if (s) unmap_disk(s); -- break; -+ connected_disks--; -+ break; - - case CTLMSG_PID: - memset(buf, 0x00, MSG_SIZE); -Index: xen-3.3.1-testing/tools/ioemu-remote/tapdisk-ioemu.c +Index: xen-3.4.0-testing/tools/python/xen/xend/server/DevController.py =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/tapdisk-ioemu.c -+++ xen-3.3.1-testing/tools/ioemu-remote/tapdisk-ioemu.c -@@ -18,6 +18,7 @@ extern void *qemu_mallocz(size_t size); - extern void qemu_free(void *ptr); - - extern void *fd_start; -+extern int connected_disks; - - int domid = 0; - FILE* logfile; -@@ -98,7 +99,7 @@ int main(void) - int max_fd; - fd_set rfds; - struct timeval tv; -- void *old_fd_start = NULL; -+ int old_connected_disks = 0; - - /* Daemonize */ - if (fork() != 0) -@@ -153,11 +154,17 @@ int main(void) - pioh = &ioh->next; - } - -+ if (old_connected_disks != connected_disks) -+ fprintf(stderr, "connected disks: %d => %d\n", -+ old_connected_disks, connected_disks); -+ - /* Exit when the last image has been closed */ -- if (old_fd_start != NULL && fd_start == NULL) -+ if (old_connected_disks != 0 && connected_disks == 0) { -+ fprintf(stderr, "Last image is closed, exiting.\n"); - exit(0); -+ } - -- old_fd_start = fd_start; -+ old_connected_disks = connected_disks; - } - return 0; - } -Index: xen-3.3.1-testing/tools/examples/blktap -=================================================================== ---- xen-3.3.1-testing.orig/tools/examples/blktap -+++ xen-3.3.1-testing/tools/examples/blktap -@@ -75,6 +75,7 @@ fi - if [ "$command" = 'add' ] - then - [ -e "$file" ] || { fatal $file does not exist; } -+ [ $(stat --format="%s" "$file") -ge 512 ] || { fatal $file is too small; } - - FRONTEND_ID=$(xenstore_read "$XENBUS_PATH/frontend-id") - FRONTEND_UUID=$(xenstore_read "/local/domain/$FRONTEND_ID/vm") -Index: xen-3.3.1-testing/tools/python/xen/xend/server/DevController.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/server/DevController.py -+++ xen-3.3.1-testing/tools/python/xen/xend/server/DevController.py -@@ -182,7 +182,7 @@ class DevController: +--- xen-3.4.0-testing.orig/tools/python/xen/xend/server/DevController.py ++++ xen-3.4.0-testing/tools/python/xen/xend/server/DevController.py +@@ -155,7 +155,7 @@ class DevController: (devid, self.deviceClass)) elif status == Error: diff --git a/ioemu-debuginfo.patch b/ioemu-debuginfo.patch index 5de47e2..bb664d0 100644 --- a/ioemu-debuginfo.patch +++ b/ioemu-debuginfo.patch @@ -1,21 +1,21 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/Makefile +Index: xen-3.4.0-testing/tools/ioemu-remote/Makefile =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/Makefile -+++ xen-3.3.1-testing/tools/ioemu-remote/Makefile -@@ -205,7 +205,7 @@ endif +--- xen-3.4.0-testing.orig/tools/ioemu-remote/Makefile ++++ xen-3.4.0-testing/tools/ioemu-remote/Makefile +@@ -242,7 +242,7 @@ endif install: all $(if $(BUILD_DOCS),install-doc) mkdir -p "$(DESTDIR)$(bindir)" ifneq ($(TOOLS),) - $(INSTALL) -m 755 -s $(TOOLS) "$(DESTDIR)$(bindir)" + $(INSTALL) -m 755 $(TOOLS) "$(DESTDIR)$(bindir)" endif + ifneq ($(BLOBS),) mkdir -p "$(DESTDIR)$(datadir)" - set -e; for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \ -Index: xen-3.3.1-testing/tools/ioemu-remote/Makefile.target +Index: xen-3.4.0-testing/tools/ioemu-remote/Makefile.target =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/Makefile.target -+++ xen-3.3.1-testing/tools/ioemu-remote/Makefile.target -@@ -707,7 +707,7 @@ clean: +--- xen-3.4.0-testing.orig/tools/ioemu-remote/Makefile.target ++++ xen-3.4.0-testing/tools/ioemu-remote/Makefile.target +@@ -754,7 +754,7 @@ clean: install: all install-hook ifneq ($(PROGS),) diff --git a/ioemu-qcow2-multiblock-aio.patch b/ioemu-qcow2-multiblock-aio.patch deleted file mode 100644 index a710d53..0000000 --- a/ioemu-qcow2-multiblock-aio.patch +++ /dev/null @@ -1,108 +0,0 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/block-qcow2.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/block-qcow2.c -+++ xen-3.3.1-testing/tools/ioemu-remote/block-qcow2.c -@@ -808,6 +808,8 @@ static void qcow_aio_read_cb(void *opaqu - BlockDriverState *bs = acb->common.bs; - BDRVQcowState *s = bs->opaque; - int index_in_cluster, n1; -+ uint64_t next; -+ int n; - - acb->hd_aiocb = NULL; - if (ret < 0) { -@@ -846,11 +848,22 @@ static void qcow_aio_read_cb(void *opaqu - acb->cluster_offset = get_cluster_offset(bs, acb->sector_num << 9, - 0, 0, 0, 0); - index_in_cluster = acb->sector_num & (s->cluster_sectors - 1); -- acb->n = s->cluster_sectors - index_in_cluster; -- if (acb->n > acb->nb_sectors) -- acb->n = acb->nb_sectors; - - if (!acb->cluster_offset) { -+ /* seek how many clusters we must read from the base image */ -+ n = s->cluster_sectors; -+ while (n < acb->nb_sectors + index_in_cluster) { -+ next = get_cluster_offset(bs, (acb->sector_num + n) << 9, -+ 0, 0, 0, 0); -+ if (next) -+ break; -+ n += s->cluster_sectors; -+ } -+ n -= index_in_cluster; -+ if (n > acb->nb_sectors) -+ n = acb->nb_sectors; -+ acb->n = n; -+ - if (bs->backing_hd) { - /* read from the base image */ - n1 = backing_read1(bs->backing_hd, acb->sector_num, -@@ -869,6 +882,9 @@ static void qcow_aio_read_cb(void *opaqu - goto redo; - } - } else if (acb->cluster_offset & QCOW_OFLAG_COMPRESSED) { -+ acb->n = s->cluster_sectors - index_in_cluster; -+ if (acb->n > acb->nb_sectors) -+ acb->n = acb->nb_sectors; - /* add AIO support for compressed blocks ? */ - if (decompress_cluster(s, acb->cluster_offset) < 0) - goto fail; -@@ -880,6 +896,22 @@ static void qcow_aio_read_cb(void *opaqu - ret = -EIO; - goto fail; - } -+ -+ /* seek how many clusters we can read */ -+ -+ n = s->cluster_sectors; -+ while (n < acb->nb_sectors + index_in_cluster) { -+ next = get_cluster_offset(bs, (acb->sector_num + n) << 9, -+ 0, 0, 0, 0); -+ if (next != acb->cluster_offset + (n << 9)) -+ break; -+ n += s->cluster_sectors; -+ } -+ n -= index_in_cluster; -+ if (n > acb->nb_sectors) -+ n = acb->nb_sectors; -+ acb->n = n; -+ - acb->hd_aiocb = bdrv_aio_read(s->hd, - (acb->cluster_offset >> 9) + index_in_cluster, - acb->buf, acb->n, qcow_aio_read_cb, acb); -@@ -928,6 +960,9 @@ static void qcow_aio_write_cb(void *opaq - int index_in_cluster; - uint64_t cluster_offset; - const uint8_t *src_buf; -+ uint64_t next; -+ int n; -+ int alloc; - - acb->hd_aiocb = NULL; - -@@ -972,6 +1007,25 @@ static void qcow_aio_write_cb(void *opaq - acb->n, 1, &s->aes_encrypt_key); - src_buf = acb->cluster_data; - } else { -+ -+ /* seek how many clusters we can write */ -+ -+ n = s->cluster_sectors; -+ while(n < acb->nb_sectors + index_in_cluster) { -+ alloc = s->cluster_sectors; -+ if (n + alloc > acb->nb_sectors + index_in_cluster) -+ alloc = acb->nb_sectors + index_in_cluster - n; -+ next = get_cluster_offset(bs, (acb->sector_num + n) << 9, -+ 1, 0, 0, alloc); -+ if (next != cluster_offset + (n << 9)) -+ break; -+ n += alloc; -+ } -+ n -= index_in_cluster; -+ if (n > acb->nb_sectors) -+ n = acb->nb_sectors; -+ acb->n = n; -+ - src_buf = acb->buf; - } - acb->hd_aiocb = bdrv_aio_write(s->hd, diff --git a/ioemu-vnc-resize.patch b/ioemu-vnc-resize.patch index 5ad55e8..bbe5a6d 100644 --- a/ioemu-vnc-resize.patch +++ b/ioemu-vnc-resize.patch @@ -1,35 +1,8 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/vnc.c +Index: xen-3.4.0-testing/tools/ioemu-remote/vnc.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/vnc.c -+++ xen-3.3.1-testing/tools/ioemu-remote/vnc.c -@@ -352,6 +352,11 @@ static void vnc_dpy_update(DisplayState - { - VncState *vs = ds->opaque; - -+ x = MIN(x, vs->width); -+ y = MIN(y, vs->height); -+ w = MIN(w, vs->width - x); -+ h = MIN(h, vs->height - y); -+ - set_bits_in_row(vs, vs->dirty_row, x, y, w, h); - } - -@@ -419,9 +424,13 @@ static void vnc_dpy_resize_shared(Displa - size_changed = ds->width != w || ds->height != h; - ds->width = w; - ds->height = h; -- if (vs->csock != -1 && vs->has_resize && size_changed) { -+ if (size_changed) { - vs->width = ds->width; - vs->height = ds->height; -+ VNC_DEBUG("vs->width = %d, vs->height = %d\n", -+ ds->width, ds->height); -+ } -+ if (vs->csock != -1 && vs->has_resize && size_changed) { - if (vs->update_requested) { - vnc_write_u8(vs, 0); /* msg id */ - vnc_write_u8(vs, 0); -@@ -1808,6 +1817,31 @@ static int protocol_client_msg(VncState +--- xen-3.4.0-testing.orig/tools/ioemu-remote/vnc.c ++++ xen-3.4.0-testing/tools/ioemu-remote/vnc.c +@@ -1713,6 +1713,31 @@ static int protocol_client_msg(VncState } set_encodings(vs, (int32_t *)(data + 4), limit); @@ -48,13 +21,13 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/vnc.c + vnc_write_u8(vs, 0); /* msg id */ + vnc_write_u8(vs, 0); + vnc_write_u16(vs, 1); /* number of rects */ -+ vnc_framebuffer_update(vs, 0, 0, vs->ds->width, vs->ds->height, -223); ++ vnc_framebuffer_update(vs, 0, 0, vs->serverds.width, vs->serverds.height, -223); + + /* Ensure that the new area is updated */ + vnc_write_u8(vs, 0); /* msg id */ + vnc_write_u8(vs, 0); + vnc_write_u16(vs, 1); /* number of rects */ -+ send_framebuffer_update(vs, 0, 0, vs->ds->width, vs->ds->height); ++ send_framebuffer_update(vs, 0, 0, vs->serverds.width, vs->serverds.height); + + vnc_flush(vs); + } diff --git a/ioemu-vpc-4gb-fix.patch b/ioemu-vpc-4gb-fix.patch deleted file mode 100644 index 034b300..0000000 --- a/ioemu-vpc-4gb-fix.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/block-vpc.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/block-vpc.c -+++ xen-3.3.1-testing/tools/ioemu-remote/block-vpc.c -@@ -156,7 +156,7 @@ static inline int seek_to_sector(BlockDr - if (pagetable_index > s->pagetable_entries || s->pagetable[pagetable_index] == 0xffffffff) - return -1; // not allocated - -- bitmap_offset = 512 * s->pagetable[pagetable_index]; -+ bitmap_offset = 512 * (uint64_t) s->pagetable[pagetable_index]; - block_offset = bitmap_offset + 512 + (512 * pageentry_index); - - // printf("sector: %" PRIx64 ", index: %x, offset: %x, bioff: %" PRIx64 ", bloff: %" PRIx64 "\n", diff --git a/libxen_permissive.patch b/libxen_permissive.patch index 9013cdc..de06fa7 100644 --- a/libxen_permissive.patch +++ b/libxen_permissive.patch @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/tools/libxen/src/xen_common.c +Index: xen-3.4.0-testing/tools/libxen/src/xen_common.c =================================================================== ---- xen-3.3.1-testing.orig/tools/libxen/src/xen_common.c -+++ xen-3.3.1-testing/tools/libxen/src/xen_common.c -@@ -902,8 +902,15 @@ static void parse_into(xen_session *s, x +--- xen-3.4.0-testing.orig/tools/libxen/src/xen_common.c ++++ xen-3.4.0-testing/tools/libxen/src/xen_common.c +@@ -904,8 +904,15 @@ static void parse_into(xen_session *s, x 0 != strcmp((char *)value_node->children->name, "struct") || value_node->children->children == NULL) { diff --git a/network-nat-open-SuSEfirewall2-FORWARD.patch b/network-nat-open-SuSEfirewall2-FORWARD.patch new file mode 100644 index 0000000..088eea3 --- /dev/null +++ b/network-nat-open-SuSEfirewall2-FORWARD.patch @@ -0,0 +1,21 @@ +Open SuSEfirewall2 FORWARD rule when use xen nat + +diff -uNrp xen-3.4.0-testing/tools/hotplug/Linux/network-nat xen-3.4.0-testing/tools/hotplug/Linux/network-nat +--- xen-3.4.0-testing/tools/hotplug/Linux/network-nat 2009-04-08 17:31:50.000000000 +0800 ++++ xen-3.4.0-testing/tools/hotplug/Linux/network-nat 2009-04-08 17:33:20.000000000 +0800 +@@ -82,6 +82,7 @@ function dhcp_stop() + op_start() { + echo 1 >/proc/sys/net/ipv4/ip_forward + iptables -t nat -A POSTROUTING -o ${netdev} -j MASQUERADE ++ iptables -P FORWARD ACCEPT + [ "$dhcp" != 'no' ] && dhcp_start + } + +@@ -89,6 +90,7 @@ op_start() { + op_stop() { + [ "$dhcp" != 'no' ] && dhcp_stop + iptables -t nat -D POSTROUTING -o ${netdev} -j MASQUERADE ++ iptables -P FORWARD DROP + } + + diff --git a/network-nat.patch b/network-nat.patch index cb87e55..434c6e7 100644 --- a/network-nat.patch +++ b/network-nat.patch @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/examples/network-nat +Index: xen-3.4.0-testing/tools/hotplug/Linux/network-nat =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/network-nat -+++ xen-3.3.1-testing/tools/examples/network-nat +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/network-nat ++++ xen-3.4.0-testing/tools/hotplug/Linux/network-nat @@ -1,4 +1,4 @@ -#!/bin/bash -x +#!/bin/bash diff --git a/network-route.patch b/network-route.patch index fecb184..6219590 100644 --- a/network-route.patch +++ b/network-route.patch @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/examples/network-route +Index: xen-3.4.0-testing/tools/hotplug/Linux/network-route =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/network-route -+++ xen-3.3.1-testing/tools/examples/network-route +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/network-route ++++ xen-3.4.0-testing/tools/hotplug/Linux/network-route @@ -21,7 +21,7 @@ dir=$(dirname "$0") evalVariables "$@" diff --git a/old-arbytes.patch b/old-arbytes.patch deleted file mode 100644 index 88639da..0000000 --- a/old-arbytes.patch +++ /dev/null @@ -1,30 +0,0 @@ -Index: xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c -=================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/hvm/hvm.c 2009-02-12 09:23:34.000000000 -0700 -+++ xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c 2009-02-12 09:29:19.000000000 -0700 -@@ -544,7 +544,25 @@ - if ( hvm_funcs.load_cpu_ctxt(v, &ctxt) < 0 ) - return -EINVAL; - -+ -+ /* Older Xen versions used to save the segment arbytes directly -+ * from the VMCS on Intel hosts. Detect this and rearrange them -+ * into the struct segment_register format. */ -+ -+#define UNFOLD_ARBYTES(_r) \ -+ if ( (_r & 0xf000) && !(_r & 0x0f00) ) \ -+ _r = ((_r & 0xff) | ((_r >> 4) & 0xf00)) -+ UNFOLD_ARBYTES(ctxt.cs_arbytes); -+ UNFOLD_ARBYTES(ctxt.ds_arbytes); -+ UNFOLD_ARBYTES(ctxt.es_arbytes); -+ UNFOLD_ARBYTES(ctxt.fs_arbytes); -+ UNFOLD_ARBYTES(ctxt.gs_arbytes); -+ UNFOLD_ARBYTES(ctxt.ss_arbytes); -+ UNFOLD_ARBYTES(ctxt.tr_arbytes); -+ UNFOLD_ARBYTES(ctxt.ldtr_arbytes); -+#undef UNFOLD_ARBYTES - seg.limit = ctxt.idtr_limit; -+ - seg.base = ctxt.idtr_base; - hvm_set_segment_register(v, x86_seg_idtr, &seg); - diff --git a/pv-driver-build.patch b/pv-driver-build.patch index 5577b39..221a30e 100644 --- a/pv-driver-build.patch +++ b/pv-driver-build.patch @@ -1,5 +1,7 @@ ---- a/unmodified_drivers/linux-2.6/blkfront/Kbuild -+++ b/unmodified_drivers/linux-2.6/blkfront/Kbuild +Index: xen-3.4.0-testing/unmodified_drivers/linux-2.6/blkfront/Kbuild +=================================================================== +--- xen-3.4.0-testing.orig/unmodified_drivers/linux-2.6/blkfront/Kbuild ++++ xen-3.4.0-testing/unmodified_drivers/linux-2.6/blkfront/Kbuild @@ -3,3 +3,4 @@ include $(M)/overrides.mk obj-m += xen-vbd.o diff --git a/pvdrv_emulation_control.patch b/pvdrv_emulation_control.patch index 5802d0b..13b758b 100644 --- a/pvdrv_emulation_control.patch +++ b/pvdrv_emulation_control.patch @@ -1,12 +1,12 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_platform.c +Index: xen-3.4.0-testing/tools/ioemu-remote/hw/xen_platform.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_platform.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_platform.c -@@ -101,6 +101,19 @@ static void platform_ioport_write(void * +--- xen-3.4.0-testing.orig/tools/ioemu-remote/hw/xen_platform.c ++++ xen-3.4.0-testing/tools/ioemu-remote/hw/xen_platform.c +@@ -356,6 +356,19 @@ static void platform_ioport_write(void * net_tap_shutdown_all(); fprintf(logfile, "Done.\n"); break; -+ case 8: ++ case 8: + if (val ==1 ) { + fprintf(logfile, "Disconnect IDE hard disk...\n"); + ide_unplug_harddisks(); diff --git a/python2.6-fixes.patch b/python2.6-fixes.patch index d269821..2819327 100644 --- a/python2.6-fixes.patch +++ b/python2.6-fixes.patch @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/python/xen/util/acmpolicy.py +Index: xen-3.4.0-testing/tools/python/xen/util/acmpolicy.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/util/acmpolicy.py -+++ xen-3.3.1-testing/tools/python/xen/util/acmpolicy.py +--- xen-3.4.0-testing.orig/tools/python/xen/util/acmpolicy.py ++++ xen-3.4.0-testing/tools/python/xen/util/acmpolicy.py @@ -17,7 +17,10 @@ #============================================================================ @@ -14,10 +14,10 @@ Index: xen-3.3.1-testing/tools/python/xen/util/acmpolicy.py import stat import array import struct -Index: xen-3.3.1-testing/tools/python/xen/xend/XendAPI.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendAPI.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendAPI.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendAPI.py +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendAPI.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendAPI.py @@ -18,7 +18,6 @@ import inspect import os @@ -26,7 +26,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendAPI.py import string import sys import traceback -@@ -116,13 +115,13 @@ event_registrations = {} +@@ -119,7 +118,7 @@ event_registrations = {} def event_register(session, reg_classes): if session not in event_registrations: event_registrations[session] = { @@ -35,10 +35,11 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendAPI.py 'queue' : Queue.Queue(EVENT_QUEUE_LENGTH), 'next-id' : 1 } - if not reg_classes: - reg_classes = classes -- event_registrations[session]['classes'].union_update(reg_classes) -+ event_registrations[session]['classes'].update(reg_classes) +@@ -131,7 +130,6 @@ def event_register(session, reg_classes) + event_registrations[session]['classes'].update(reg_classes) +- def event_unregister(session, unreg_classes): + if session not in event_registrations: + return diff --git a/qemu-dm-segfault.patch b/qemu-dm-segfault.patch index e1b7a4d..d4a7811 100644 --- a/qemu-dm-segfault.patch +++ b/qemu-dm-segfault.patch @@ -1,86 +1,85 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/ide.c +Index: xen-3.4.0-testing/tools/ioemu-remote/hw/ide.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/ide.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/ide.c -@@ -908,8 +908,12 @@ static inline void ide_dma_submit_check( +--- xen-3.4.0-testing.orig/tools/ioemu-remote/hw/ide.c ++++ xen-3.4.0-testing/tools/ioemu-remote/hw/ide.c +@@ -934,8 +934,9 @@ static inline void ide_dma_submit_check( static inline void ide_set_irq(IDEState *s) { - BMDMAState *bm = s->bmdma; -- if (!s->bs) return; /* yikes */ +- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ + BMDMAState *bm; -+ -+ if (!s || !s->bs) return; /* yikes */ -+ ++ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ + bm = s->bmdma; -+ if (!(s->cmd & IDE_CMD_DISABLE_IRQ)) { if (bm) { bm->status |= BM_STATUS_INT; -@@ -1094,15 +1098,13 @@ static void ide_read_dma_cb(void *opaque +@@ -1223,14 +1224,14 @@ static void ide_read_dma_cb(void *opaque int n; int64_t sector_num; -+ if (!s || !s->bs) return; /* yikes */ ++ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ + if (ret < 0) { + dma_buf_commit(s, 1); ide_dma_error(s); return; } -- if (!s->bs) return; /* yikes */ -- -- if (!s->bs) return; /* yikes */ +- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ - n = s->io_buffer_size >> 9; sector_num = ide_get_sector(s); if (n > 0) { -@@ -1222,15 +1224,13 @@ static void ide_write_dma_cb(void *opaqu +@@ -1334,6 +1335,8 @@ static void ide_write_flush_cb(void *opa + BMDMAState *bm = opaque; + IDEState *s = bm->ide_if; + ++ if (!s) return; /* yikes */ ++ + if (ret != 0) { + ide_dma_error(s); + return; +@@ -1365,13 +1368,13 @@ static void ide_write_dma_cb(void *opaqu int n; int64_t sector_num; -+ if (!s || !s->bs) return; /* yikes */ ++ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ + if (ret < 0) { - ide_dma_error(s); - return; + if (ide_handle_write_error(s, -ret, BM_STATUS_DMA_RETRY)) + return; } -- if (!s->bs) return; /* yikes */ -- -- if (!s->bs) return; /* yikes */ +- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ - n = s->io_buffer_size >> 9; sector_num = ide_get_sector(s); if (n > 0) { -@@ -1290,7 +1290,7 @@ static void ide_flush_cb(void *opaque, i +@@ -1428,7 +1431,7 @@ static void ide_flush_cb(void *opaque, i { IDEState *s = opaque; -- if (!s->bs) return; /* yikes */ -+ if (!s || !s->bs) return; /* yikes */ +- if (!s->bs) return; /* ouch! (see below) */ ++ if (!s || !s->bs) return; /* ouch! (see below) */ if (ret) { /* We are completely doomed. The IDE spec does not permit us -@@ -1536,9 +1536,7 @@ static void ide_atapi_cmd_read_dma_cb(vo +@@ -1685,7 +1688,7 @@ static void ide_atapi_cmd_read_dma_cb(vo IDEState *s = bm->ide_if; int data_offset, n; -- if (!s->bs) return; /* yikes */ -- -- if (!s->bs) return; /* yikes */ -+ if (!s || !s->bs) return; /* yikes */ +- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ ++ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ if (ret < 0) { ide_atapi_io_error(s, ret); -@@ -2119,9 +2117,7 @@ static void cdrom_change_cb(void *opaque +@@ -2363,7 +2366,7 @@ static void cdrom_change_cb(void *opaque IDEState *s = opaque; uint64_t nb_sectors; -- if (!s->bs) return; /* yikes */ -- -- if (!s->bs) return; /* yikes */ -+ if (!s || !s->bs) return; /* yikes */ +- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ ++ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ - /* XXX: send interrupt too */ bdrv_get_geometry(s->bs, &nb_sectors); + s->nb_sectors = nb_sectors; diff --git a/qemu-img-snapshot.patch b/qemu-img-snapshot.patch deleted file mode 100644 index a8b2ec2..0000000 --- a/qemu-img-snapshot.patch +++ /dev/null @@ -1,113 +0,0 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/qemu-img.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/qemu-img.c -+++ xen-3.3.1-testing/tools/ioemu-remote/qemu-img.c -@@ -57,6 +57,7 @@ static void help(void) - " commit [-f fmt] filename\n" - " convert [-c] [-e] [-6] [-f fmt] [-O output_fmt] filename [filename2 [...]] output_filename\n" - " info [-f fmt] filename\n" -+ " snapshot [-l|-a snapshot|-d snapshot] filename\n" - "\n" - "Command parameters:\n" - " 'filename' is a disk image filename\n" -@@ -694,6 +695,91 @@ static int img_info(int argc, char **arg - return 0; - } - -+#define SNAPSHOT_LIST 1 -+#define SNAPSHOT_APPLY 2 -+#define SNAPSHOT_DELETE 3 -+ -+static void img_snapshot(int argc, char **argv) -+{ -+ BlockDriverState *bs; -+ char *filename, *snapshot_name = NULL; -+ char c; -+ int ret; -+ int action = 0; -+ -+ /* Parse commandline parameters */ -+ for(;;) { -+ c = getopt(argc, argv, "la:d:h"); -+ if (c == -1) -+ break; -+ switch(c) { -+ case 'h': -+ help(); -+ return; -+ case 'l': -+ if (action) { -+ help(); -+ return; -+ } -+ action = SNAPSHOT_LIST; -+ break; -+ case 'a': -+ if (action) { -+ help(); -+ return; -+ } -+ action = SNAPSHOT_APPLY; -+ snapshot_name = optarg; -+ break; -+ case 'd': -+ if (action) { -+ help(); -+ return; -+ } -+ action = SNAPSHOT_DELETE; -+ snapshot_name = optarg; -+ break; -+ } -+ } -+ -+ if (optind >= argc) -+ help(); -+ filename = argv[optind++]; -+ -+ /* Open the image */ -+ bs = bdrv_new(""); -+ if (!bs) -+ error("Not enough memory"); -+ -+ if (bdrv_open2(bs, filename, 0, NULL) < 0) { -+ error("Could not open '%s'", filename); -+ } -+ -+ /* Perform the requested action */ -+ switch(action) { -+ case SNAPSHOT_LIST: -+ dump_snapshots(bs); -+ break; -+ -+ case SNAPSHOT_APPLY: -+ ret = bdrv_snapshot_goto(bs, snapshot_name); -+ if (ret) -+ error("Could not apply snapshot '%s': %d (%s)", -+ snapshot_name, strerror(ret), ret); -+ break; -+ -+ case SNAPSHOT_DELETE: -+ ret = bdrv_snapshot_delete(bs, snapshot_name); -+ if (ret) -+ error("Could not delete snapshot '%s': %d (%s)", -+ snapshot_name, strerror(ret), ret); -+ break; -+ } -+ -+ /* Cleanup */ -+ bdrv_delete(bs); -+} -+ - int main(int argc, char **argv) - { - const char *cmd; -@@ -711,6 +797,8 @@ int main(int argc, char **argv) - img_convert(argc, argv); - } else if (!strcmp(cmd, "info")) { - img_info(argc, argv); -+ } else if (!strcmp(cmd, "snapshot")) { -+ img_snapshot(argc, argv); - } else { - help(); - } diff --git a/qemu-security-etch1.diff b/qemu-security-etch1.diff index 1e36c10..8492d6b 100644 --- a/qemu-security-etch1.diff +++ b/qemu-security-etch1.diff @@ -1,21 +1,7 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/block.c +Index: xen-3.4.0-testing/tools/ioemu-remote/hw/ne2000.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/block.c -+++ xen-3.3.1-testing/tools/ioemu-remote/block.c -@@ -630,6 +630,9 @@ int bdrv_write(BlockDriverState *bs, int - return 0; - } - } else { -+ unsigned int ns = sector_num * 512; -+ if (ns < 0) -+ return -1; - return drv->bdrv_write(bs, sector_num, buf, nb_sectors); - } - } -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/ne2000.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/ne2000.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/ne2000.c +--- xen-3.4.0-testing.orig/tools/ioemu-remote/hw/ne2000.c ++++ xen-3.4.0-testing/tools/ioemu-remote/hw/ne2000.c @@ -218,7 +218,7 @@ static int ne2000_can_receive(void *opaq NE2000State *s = opaque; @@ -25,11 +11,11 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/ne2000.c return !ne2000_buffer_full(s); } -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/pc.c +Index: xen-3.4.0-testing/tools/ioemu-remote/hw/pc.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/pc.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/pc.c -@@ -387,7 +387,8 @@ static void bochs_bios_write(void *opaqu +--- xen-3.4.0-testing.orig/tools/ioemu-remote/hw/pc.c ++++ xen-3.4.0-testing/tools/ioemu-remote/hw/pc.c +@@ -409,7 +409,8 @@ static void bochs_bios_write(void *opaqu case 0x400: case 0x401: fprintf(stderr, "BIOS panic at rombios.c, line %d\n", val); @@ -39,7 +25,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/pc.c case 0x402: case 0x403: #ifdef DEBUG_BIOS -@@ -410,8 +411,9 @@ static void bochs_bios_write(void *opaqu +@@ -432,8 +433,9 @@ static void bochs_bios_write(void *opaqu /* LGPL'ed VGA BIOS messages */ case 0x501: case 0x502: @@ -50,65 +36,3 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/pc.c case 0x500: case 0x503: #ifdef DEBUG_BIOS -Index: xen-3.3.1-testing/tools/ioemu-remote/target-i386/translate.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/target-i386/translate.c -+++ xen-3.3.1-testing/tools/ioemu-remote/target-i386/translate.c -@@ -5661,6 +5661,7 @@ static target_ulong disas_insn(DisasCont - gen_jmp_im(pc_start - s->cs_base); - gen_op_into(s->pc - pc_start); - break; -+#ifdef WANT_ICEBP - case 0xf1: /* icebp (undocumented, exits to external debugger) */ - if (gen_svm_check_intercept(s, pc_start, SVM_EXIT_ICEBP)) - break; -@@ -5672,6 +5673,7 @@ static target_ulong disas_insn(DisasCont - cpu_set_log(CPU_LOG_INT | CPU_LOG_TB_IN_ASM); - #endif - break; -+#endif /* icebp */ - case 0xfa: /* cli */ - if (!s->vm86) { - if (s->cpl <= s->iopl) { -Index: xen-3.3.1-testing/tools/ioemu-remote/vl.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/vl.c -+++ xen-3.3.1-testing/tools/ioemu-remote/vl.c -@@ -4380,8 +4380,8 @@ typedef struct NetSocketState { - VLANClientState *vc; - int fd; - int state; /* 0 = getting length, 1 = getting data */ -- int index; -- int packet_len; -+ unsigned int index; -+ unsigned int packet_len; - uint8_t buf[4096]; - struct sockaddr_in dgram_dst; /* contains inet host and port destination iff connectionless (SOCK_DGRAM) */ - } NetSocketState; -@@ -4412,7 +4412,8 @@ static void net_socket_receive_dgram(voi - static void net_socket_send(void *opaque) - { - NetSocketState *s = opaque; -- int l, size, err; -+ int size, err; -+ unsigned l; - uint8_t buf1[4096]; - const uint8_t *buf; - -@@ -4451,7 +4452,15 @@ static void net_socket_send(void *opaque - l = s->packet_len - s->index; - if (l > size) - l = size; -- memcpy(s->buf + s->index, buf, l); -+ if (s->index + l <= sizeof(s->buf)) { -+ memcpy(s->buf + s->index, buf, l); -+ } else { -+ fprintf(stderr, "serious error: oversized packet received," -+ "connection terminated.\n"); -+ s->state = 0; -+ goto eoc; -+ } -+ - s->index += l; - buf += l; - size -= l; diff --git a/reenable-block-protocols.patch b/reenable-block-protocols.patch deleted file mode 100644 index bfaca0c..0000000 --- a/reenable-block-protocols.patch +++ /dev/null @@ -1,39 +0,0 @@ -Index: xen-3.3.1-testing/tools/python/xen/xend/server/blkif.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/server/blkif.py -+++ xen-3.3.1-testing/tools/python/xen/xend/server/blkif.py -@@ -18,6 +18,7 @@ - - import re - import string -+import os - - from xen.util import blkif - import xen.util.xsm.xsm as security -@@ -35,6 +36,13 @@ class BlkifController(DevController): - """ - DevController.__init__(self, vm) - -+ def _isValidProtocol(self, protocol): -+ if protocol in ('phy', 'file', 'tap'): -+ return True -+ -+ return os.access('/etc/xen/scripts/block-%s' % protocol, os.X_OK) -+ -+ - def getDeviceDetails(self, config): - """@see DevController.getDeviceDetails""" - uname = config.get('uname', '') -@@ -56,10 +64,8 @@ class BlkifController(DevController): - else: - try: - (typ, params) = string.split(uname, ':', 1) -- if typ not in ('phy', 'file', 'tap'): -- raise VmError( -- 'Block device must have "phy", "file" or "tap" ' -- 'specified to type') -+ if not self._isValidProtocol(typ): -+ raise VmError('Block device type "%s" is invalid.' % typ) - except ValueError: - raise VmError( - 'Block device must have physical details specified') diff --git a/rpmlint.diff b/rpmlint.diff deleted file mode 100644 index 3e4b83f..0000000 --- a/rpmlint.diff +++ /dev/null @@ -1,13 +0,0 @@ -Index: xen-3.3.1-testing/tools/examples/Makefile -=================================================================== ---- xen-3.3.1-testing.orig/tools/examples/Makefile -+++ xen-3.3.1-testing/tools/examples/Makefile -@@ -70,7 +70,7 @@ install-initd: - [ -d $(DESTDIR)/var/adm/fillup-templates ] || $(INSTALL_DIR) $(DESTDIR)/var/adm/fillup-templates/ - $(INSTALL_PROG) $(XEND_INITD) $(DESTDIR)/etc/init.d - $(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)/etc/init.d -- $(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)/var/adm/fillup-templates/ -+ $(INSTALL_DATA) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)/var/adm/fillup-templates/ - - .PHONY: install-configs - install-configs: $(XEN_CONFIGS) diff --git a/serial-split.patch b/serial-split.patch index ae6f5f7..17def81 100644 --- a/serial-split.patch +++ b/serial-split.patch @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/misc/serial-split/Makefile +Index: xen-3.4.0-testing/tools/misc/serial-split/Makefile =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/misc/serial-split/Makefile ++++ xen-3.4.0-testing/tools/misc/serial-split/Makefile @@ -0,0 +1,20 @@ +CC ?= gcc +CFLAGS ?= -Wall -Os @@ -23,10 +23,10 @@ Index: xen-3.3.1-testing/tools/misc/serial-split/Makefile + +%.o: %.c Makefile + $(CC) $(CFLAGS) -c -o $@ $< -Index: xen-3.3.1-testing/tools/misc/serial-split/serial-split.c +Index: xen-3.4.0-testing/tools/misc/serial-split/serial-split.c =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/misc/serial-split/serial-split.c ++++ xen-3.4.0-testing/tools/misc/serial-split/serial-split.c @@ -0,0 +1,422 @@ +/* + * serial-split.c diff --git a/snapshot-ioemu-delete.patch b/snapshot-ioemu-delete.patch index fe5daf9..044ab14 100644 --- a/snapshot-ioemu-delete.patch +++ b/snapshot-ioemu-delete.patch @@ -1,13 +1,12 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c +Index: xen-3.4.0-testing/tools/ioemu-remote/xenstore.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/xenstore.c -+++ xen-3.3.1-testing/tools/ioemu-remote/xenstore.c -@@ -671,6 +671,18 @@ static void xenstore_process_dm_command_ +--- xen-3.4.0-testing.orig/tools/ioemu-remote/xenstore.c ++++ xen-3.4.0-testing/tools/ioemu-remote/xenstore.c +@@ -919,6 +919,18 @@ static void xenstore_process_dm_command_ } snapshot_name = xs_read(xsh, XBT_NULL, path, &len); + } else if (!strncmp(command, "snapshot-delete", len)) { -+ + if (pasprintf(&path, + "/local/domain/0/device-model/%u/parameter", domid) == -1) { + fprintf(logfile, "out of memory reading dm command parameter\n"); @@ -18,23 +17,15 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c + goto out; + if (delete_disk_snapshots(par) == 0) + xenstore_record_dm_state("snapshot-deleted"); ++ free(par); } else if (!strncmp(command, "continue", len)) { fprintf(logfile, "dm-command: continue after state save\n"); xen_pause_requested = 0; -Index: xen-3.3.1-testing/tools/ioemu-remote/xen-vl-extra.c +Index: xen-3.4.0-testing/tools/ioemu-remote/savevm.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/xen-vl-extra.c -+++ xen-3.3.1-testing/tools/ioemu-remote/xen-vl-extra.c -@@ -16,6 +16,8 @@ static int qemu_savevm_state(QEMUFile *f - static int qemu_loadvm_state(QEMUFile *f); - - static int bdrv_can_snapshot(BlockDriverState *bs); -+static int bdrv_has_snapshot(BlockDriverState *bs); -+static BlockDriverState *get_bs_snapshots(void); - static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, - const char *name); - -@@ -166,6 +168,35 @@ the_end: +--- xen-3.4.0-testing.orig/tools/ioemu-remote/savevm.c ++++ xen-3.4.0-testing/tools/ioemu-remote/savevm.c +@@ -1096,6 +1096,35 @@ the_end: return ret; } @@ -67,14 +58,14 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xen-vl-extra.c + return 0; +} + - struct qemu_alarm_timer; - static int unix_start_timer(struct qemu_alarm_timer *t) { return 0; } - static void unix_stop_timer(struct qemu_alarm_timer *t) { } -Index: xen-3.3.1-testing/tools/ioemu-remote/qemu-xen.h + #ifndef CONFIG_DM + + void do_savevm(const char *name) +Index: xen-3.4.0-testing/tools/ioemu-remote/qemu-xen.h =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/qemu-xen.h -+++ xen-3.3.1-testing/tools/ioemu-remote/qemu-xen.h -@@ -22,6 +22,7 @@ enum { +--- xen-3.4.0-testing.orig/tools/ioemu-remote/qemu-xen.h ++++ xen-3.4.0-testing/tools/ioemu-remote/qemu-xen.h +@@ -42,6 +42,7 @@ enum { /* xen-vl-extra.c */ int save_disk_snapshots(const char* name); diff --git a/snapshot-ioemu-restore.patch b/snapshot-ioemu-restore.patch index cc7a3c8..0af9992 100644 --- a/snapshot-ioemu-restore.patch +++ b/snapshot-ioemu-restore.patch @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/tools/blktap/drivers/blktapctrl.c +Index: xen-3.4.0-testing/tools/blktap/drivers/blktapctrl.c =================================================================== ---- xen-3.3.1-testing.orig/tools/blktap/drivers/blktapctrl.c -+++ xen-3.3.1-testing/tools/blktap/drivers/blktapctrl.c -@@ -305,6 +305,7 @@ static int write_msg(int fd, int msgtype +--- xen-3.4.0-testing.orig/tools/blktap/drivers/blktapctrl.c ++++ xen-3.4.0-testing/tools/blktap/drivers/blktapctrl.c +@@ -346,6 +346,7 @@ static int write_msg(int fd, int msgtype msg_dev = (msg_newdev_t *)(buf + sizeof(msg_hdr_t)); msg_dev->devnum = blkif->minor; msg_dev->domid = blkif->domid; @@ -10,10 +10,10 @@ Index: xen-3.3.1-testing/tools/blktap/drivers/blktapctrl.c break; -Index: xen-3.3.1-testing/tools/blktap/lib/blktaplib.h +Index: xen-3.4.0-testing/tools/blktap/lib/blktaplib.h =================================================================== ---- xen-3.3.1-testing.orig/tools/blktap/lib/blktaplib.h -+++ xen-3.3.1-testing/tools/blktap/lib/blktaplib.h +--- xen-3.4.0-testing.orig/tools/blktap/lib/blktaplib.h ++++ xen-3.4.0-testing/tools/blktap/lib/blktaplib.h @@ -189,6 +189,7 @@ typedef struct msg_hdr { typedef struct msg_newdev { uint8_t devnum; @@ -22,11 +22,11 @@ Index: xen-3.3.1-testing/tools/blktap/lib/blktaplib.h } msg_newdev_t; typedef struct msg_pid { -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c +Index: xen-3.4.0-testing/tools/ioemu-remote/hw/xen_blktap.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_blktap.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c -@@ -69,6 +69,8 @@ int write_fd; +--- xen-3.4.0-testing.orig/tools/ioemu-remote/hw/xen_blktap.c ++++ xen-3.4.0-testing/tools/ioemu-remote/hw/xen_blktap.c +@@ -67,6 +67,8 @@ int write_fd; static pid_t process; fd_list_entry_t *fd_start = NULL; @@ -35,7 +35,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c static void handle_blktap_iomsg(void* private); struct aiocb_info { -@@ -502,6 +504,10 @@ static void handle_blktap_ctrlmsg(void* +@@ -500,6 +502,10 @@ static void handle_blktap_ctrlmsg(void* char buf[MSG_SIZE]; @@ -46,7 +46,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c length = read(read_fd, buf, MSG_SIZE); if (length > 0 && length >= sizeof(msg_hdr_t)) -@@ -557,7 +563,39 @@ static void handle_blktap_ctrlmsg(void* +@@ -555,7 +561,39 @@ static void handle_blktap_ctrlmsg(void* if (s != NULL) { ret = ((map_new_dev(s, msg_dev->devnum) == msg_dev->devnum ? 0: -1)); @@ -87,11 +87,11 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c memset(buf, 0x00, MSG_SIZE); msglen = sizeof(msg_hdr_t); -Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c +Index: xen-3.4.0-testing/tools/ioemu-remote/xenstore.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/xenstore.c -+++ xen-3.3.1-testing/tools/ioemu-remote/xenstore.c -@@ -37,6 +37,8 @@ static QEMUTimer *insert_timer = NULL; +--- xen-3.4.0-testing.orig/tools/ioemu-remote/xenstore.c ++++ xen-3.4.0-testing/tools/ioemu-remote/xenstore.c +@@ -38,6 +38,8 @@ static QEMUTimer *insert_timer = NULL; #define UWAIT_MAX (30*1000000) /* thirty seconds */ #define UWAIT (100000) /* 1/10th second */ @@ -100,15 +100,15 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c static int pasprintf(char **buf, const char *fmt, ...) { va_list ap; -@@ -363,8 +365,33 @@ void xenstore_parse_domain_config(int hv +@@ -533,8 +535,33 @@ void xenstore_parse_domain_config(int hv } } pstrcpy(bs->filename, sizeof(bs->filename), params); -- if (bdrv_open2(bs, params, 0 /* snapshot */, format) < 0) -+ if (bdrv_open2(bs, params, 0 /* snapshot */, format) < 0) { +- if (bdrv_open2(bs, params, BDRV_O_CACHE_WB /* snapshot and write-back */, format) < 0) ++ if (bdrv_open2(bs, params, BDRV_O_CACHE_WB /* snapshot and write-back */, format) < 0) { fprintf(stderr, "qemu: could not open vbd '%s' or hard disk image '%s' (drv '%s' format '%s')\n", buf, params, drv ? drv : "?", format ? format->format_name : "0"); + } else { -+ char* snapshot = get_snapshot_name(atoi(e[i])); ++ char* snapshot = get_snapshot_name(atoi(e_danger[i])); + if (snapshot) { + fprintf(stderr, "Using snapshot %s\n", snapshot); + ret = bdrv_snapshot_goto(bs, snapshot); @@ -135,8 +135,8 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c } /* if cdrom pyhsical put a watch on media-present */ if (bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM) { -@@ -474,6 +485,23 @@ void xenstore_parse_domain_config(int hv - return; +@@ -726,6 +753,23 @@ int xenstore_parse_disable_pf_config () + return disable_pf; } + diff --git a/snapshot-ioemu-save.patch b/snapshot-ioemu-save.patch index 6b3fbf0..cb5067d 100644 --- a/snapshot-ioemu-save.patch +++ b/snapshot-ioemu-save.patch @@ -1,28 +1,17 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/xen-vl-extra.c +Index: xen-3.4.0-testing/tools/ioemu-remote/savevm.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/xen-vl-extra.c -+++ xen-3.3.1-testing/tools/ioemu-remote/xen-vl-extra.c -@@ -8,12 +8,18 @@ - * there is only one place where this file is included. */ - - #include "qemu-xen.h" +--- xen-3.4.0-testing.orig/tools/ioemu-remote/savevm.c ++++ xen-3.4.0-testing/tools/ioemu-remote/savevm.c +@@ -28,6 +28,7 @@ + #include "sysemu.h" + #include "qemu-timer.h" + #include "qemu-char.h" +#include "block_int.h" - - /* forward declarations of things in vl.c */ - - static int qemu_savevm_state(QEMUFile *f); - static int qemu_loadvm_state(QEMUFile *f); - -+static int bdrv_can_snapshot(BlockDriverState *bs); -+static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, -+ const char *name); -+ -+ - /* We use simpler state save/load functions for Xen */ - - void do_savevm(const char *name) -@@ -85,6 +91,81 @@ void do_loadvm(const char *name) - vm_start(); + #include "block.h" + #include "audio/audio.h" + #include "migration.h" +@@ -1015,6 +1016,86 @@ static int bdrv_snapshot_find(BlockDrive + return ret; } +int save_disk_snapshots(const char* name) @@ -35,11 +24,16 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xen-vl-extra.c + int i; + int ret = 0; + ++ /* Deal with all aio submit */ ++ qemu_aio_flush(); ++ /* Do fsync at backend fs */ ++ ret = bdrv_flush_all(); ++ if (ret) ++ fprintf(stderr, "Fsync error[%d] when do snapshot[%s]\n", ret, name); ++ + saved_vm_running = vm_running; + vm_stop(0); + -+ qemu_aio_flush(); -+ + /* Ensure that all images support snapshots or are read-only */ + for(i = 0; i < MAX_DRIVES; i++) { + bs = drives_table[i].bdrv; @@ -100,14 +94,14 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xen-vl-extra.c + return ret; +} + - struct qemu_alarm_timer; - static int unix_start_timer(struct qemu_alarm_timer *t) { return 0; } - static void unix_stop_timer(struct qemu_alarm_timer *t) { } -Index: xen-3.3.1-testing/tools/ioemu-remote/i386-dm/helper2.c + #ifndef CONFIG_DM + + void do_savevm(const char *name) +Index: xen-3.4.0-testing/tools/ioemu-remote/i386-dm/helper2.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/i386-dm/helper2.c -+++ xen-3.3.1-testing/tools/ioemu-remote/i386-dm/helper2.c -@@ -101,6 +101,9 @@ int send_vcpu = 0; +--- xen-3.4.0-testing.orig/tools/ioemu-remote/i386-dm/helper2.c ++++ xen-3.4.0-testing/tools/ioemu-remote/i386-dm/helper2.c +@@ -109,6 +109,9 @@ int send_vcpu = 0; #define NR_CPUS 32 evtchn_port_t ioreq_local_port[NR_CPUS]; @@ -117,7 +111,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/i386-dm/helper2.c CPUX86State *cpu_x86_init(const char *cpu_model) { CPUX86State *env; -@@ -547,6 +550,7 @@ int main_loop(void) +@@ -551,6 +554,7 @@ int main_loop(void) int evtchn_fd = xce_handle == -1 ? -1 : xc_evtchn_fd(xce_handle); char *qemu_file; fd_set fds; @@ -125,7 +119,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/i386-dm/helper2.c main_loop_prepare(); -@@ -574,11 +578,43 @@ int main_loop(void) +@@ -578,11 +582,43 @@ int main_loop(void) main_loop_wait(1); /* For the select() on events */ /* Save the device state */ @@ -173,11 +167,11 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/i386-dm/helper2.c /* Wait to be allowed to continue */ while (xen_pause_requested) { -Index: xen-3.3.1-testing/tools/ioemu-remote/qemu-xen.h +Index: xen-3.4.0-testing/tools/ioemu-remote/qemu-xen.h =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/qemu-xen.h -+++ xen-3.3.1-testing/tools/ioemu-remote/qemu-xen.h -@@ -14,6 +14,15 @@ void qemu_invalidate_map_cache(void) +--- xen-3.4.0-testing.orig/tools/ioemu-remote/qemu-xen.h ++++ xen-3.4.0-testing/tools/ioemu-remote/qemu-xen.h +@@ -34,6 +34,15 @@ void qemu_invalidate_map_cache(void) #define mapcache_lock() ((void)0) #define mapcache_unlock() ((void)0) @@ -193,18 +187,18 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/qemu-xen.h /* helper2.c */ extern long time_offset; void timeoffset_get(void); -@@ -43,6 +52,7 @@ int xenstore_fd(void); +@@ -68,6 +77,7 @@ int xenstore_fd(void); void xenstore_process_event(void *opaque); - void xenstore_record_dm(char *subpath, char *state); - void xenstore_record_dm_state(char *state); + void xenstore_record_dm(const char *subpath, const char *state); + void xenstore_record_dm_state(const char *state); +void xenstore_record_dm_error(char *errmsg); void xenstore_check_new_media_present(int timeout); void xenstore_write_vncport(int vnc_display); void xenstore_read_vncpasswd(int domid, char *pwbuf, size_t pwbuflen); -Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c +Index: xen-3.4.0-testing/tools/ioemu-remote/xenstore.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/xenstore.c -+++ xen-3.3.1-testing/tools/ioemu-remote/xenstore.c +--- xen-3.4.0-testing.orig/tools/ioemu-remote/xenstore.c ++++ xen-3.4.0-testing/tools/ioemu-remote/xenstore.c @@ -24,6 +24,7 @@ #include "exec-all.h" @@ -213,7 +207,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c #include "hw.h" #include "pci.h" -@@ -601,6 +602,7 @@ static void xenstore_process_dm_command_ +@@ -849,6 +850,7 @@ static void xenstore_process_dm_command_ { char *path = NULL, *command = NULL, *par = NULL; unsigned int len; @@ -221,7 +215,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c if (pasprintf(&path, "/local/domain/0/device-model/%u/command", domid) == -1) { -@@ -613,7 +615,18 @@ static void xenstore_process_dm_command_ +@@ -861,7 +863,18 @@ static void xenstore_process_dm_command_ if (!strncmp(command, "save", len)) { fprintf(logfile, "dm-command: pause and save state\n"); @@ -241,7 +235,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c } else if (!strncmp(command, "continue", len)) { fprintf(logfile, "dm-command: continue after state save\n"); xen_pause_requested = 0; -@@ -677,6 +690,13 @@ void xenstore_record_dm_state(char *stat +@@ -966,6 +979,13 @@ void xenstore_record_dm_state(const char xenstore_record_dm("state", state); } diff --git a/snapshot-xend.patch b/snapshot-xend.patch index 6dea38f..6642ccf 100644 --- a/snapshot-xend.patch +++ b/snapshot-xend.patch @@ -1,8 +1,17 @@ -Index: xen-3.3.1-testing/tools/python/xen/xend/image.py +Index: xen-3.4.0-testing/tools/python/xen/xend/image.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/image.py -+++ xen-3.3.1-testing/tools/python/xen/xend/image.py -@@ -447,6 +447,12 @@ class ImageHandler: +--- xen-3.4.0-testing.orig/tools/python/xen/xend/image.py ++++ xen-3.4.0-testing/tools/python/xen/xend/image.py +@@ -447,7 +447,7 @@ class ImageHandler: + # have a callback but sadly we don't have Twisted in xend + self.sentinel_thread = thread.start_new_thread(self._sentinel_watch,()) + +- def signalDeviceModel(self, cmd, ret, par = None): ++ def signalDeviceModel(self, cmd, ret, par = None, timeout = True): + if self.device_model is None: + return + # Signal the device model to for action +@@ -470,10 +470,17 @@ class ImageHandler: while state != ret: state = xstransact.Read("/local/domain/0/device-model/%i/state" % self.vm.getDomid()) @@ -13,37 +22,45 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/image.py + raise VmError(msg) + time.sleep(0.1) - count += 1 - if count > 100: -@@ -476,6 +482,10 @@ class ImageHandler: - # but this can easily lead to very rapid restart loops against - # which we currently have no protection +- count += 1 +- if count > 100: +- raise VmError('Timed out waiting for device model action') ++ if timeout: ++ count += 1 ++ if count > 100: ++ raise VmError('Timed out waiting for device model action') + + #resotre orig state + xstransact.Store("/local/domain/0/device-model/%i" +@@ -498,6 +505,10 @@ class ImageHandler: + except: + pass + def snapshotDeviceModel(self, name): + # Signal the device model to perform snapshot operation -+ self.signalDeviceModel('snapshot', 'paused', name) ++ self.signalDeviceModel('snapshot', 'paused', name, False) + def recreate(self): if self.device_model is None: return -Index: xen-3.3.1-testing/tools/python/xen/xend/server/blkif.py +Index: xen-3.4.0-testing/tools/python/xen/xend/server/blkif.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/server/blkif.py -+++ xen-3.3.1-testing/tools/python/xen/xend/server/blkif.py -@@ -84,6 +84,9 @@ class BlkifController(DevController): - if uuid: - back['uuid'] = uuid +--- xen-3.4.0-testing.orig/tools/python/xen/xend/server/blkif.py ++++ xen-3.4.0-testing/tools/python/xen/xend/server/blkif.py +@@ -88,6 +88,9 @@ class BlkifController(DevController): + if bootable != None: + back['bootable'] = str(bootable) + if 'snapshotname' in self.vm.info: + back['snapshot'] = self.vm.info['snapshotname'] + - if security.on() == xsconstants.XS_POLICY_ACM: + if security.on() == xsconstants.XS_POLICY_USE: self.do_access_control(config, uname) -Index: xen-3.3.1-testing/tools/python/xen/xend/server/SrvDomain.py +Index: xen-3.4.0-testing/tools/python/xen/xend/server/SrvDomain.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/server/SrvDomain.py -+++ xen-3.3.1-testing/tools/python/xen/xend/server/SrvDomain.py +--- xen-3.4.0-testing.orig/tools/python/xen/xend/server/SrvDomain.py ++++ xen-3.4.0-testing/tools/python/xen/xend/server/SrvDomain.py @@ -95,6 +95,31 @@ class SrvDomain(SrvDir): def do_save(self, _, req): return self.xd.domain_save(self.dom.domid, req.args['file'][0]) @@ -76,7 +93,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/server/SrvDomain.py def op_dump(self, op, req): self.acceptCommand(req) return req.threadRequest(self.do_dump, op, req) -@@ -230,7 +255,7 @@ class SrvDomain(SrvDir): +@@ -231,7 +256,7 @@ class SrvDomain(SrvDir): def render_GET(self, req): op = req.args.get('op') @@ -85,25 +102,20 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/server/SrvDomain.py return self.perform(req) # -Index: xen-3.3.1-testing/tools/python/xen/xend/XendCheckpoint.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendCheckpoint.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendCheckpoint.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendCheckpoint.py -@@ -65,10 +65,12 @@ def insert_after(list, pred, value): +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendCheckpoint.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendCheckpoint.py +@@ -65,7 +65,7 @@ def insert_after(list, pred, value): return -def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1): +def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1, name=None, diskonly=False): - write_exact(fd, SIGNATURE, "could not write guest state file: signature") - - sxprep = dominfo.sxpr() -+ if name: -+ sxprep.append(['snapshotname', name]) - - if node > -1: - insert_after(sxprep,'vcpus',['node', str(node)]) -@@ -91,52 +93,60 @@ def save(fd, dominfo, network, live, dst + try: + if not os.path.isdir("/var/lib/xen"): + os.makedirs("/var/lib/xen") +@@ -98,52 +98,59 @@ def save(fd, dominfo, network, live, dst image_cfg = dominfo.info.get('image', {}) hvm = dominfo.info.is_hvm() @@ -123,7 +135,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendCheckpoint.py - if line == "suspend": - log.debug("Suspending %d ...", dominfo.getDomid()) - dominfo.shutdown('suspend') -- dominfo.waitForShutdown() +- dominfo.waitForSuspend() - if line in ('suspend', 'suspended'): - dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP2, - domain_name) @@ -161,7 +173,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendCheckpoint.py + # libxenguest; see the comments and/or code in xc_linux_save() for + # more information. + cmd = [xen.util.auxbin.pathTo(XC_SAVE), str(fd), -+ str(dominfo.getDomid()), "0", "0", ++ str(dominfo.getDomid()), "0", "0", + str(int(live) | (int(hvm) << 2)) ] + log.debug("[xc_save]: %s", string.join(cmd)) + @@ -170,7 +182,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendCheckpoint.py + if line == "suspend": + log.debug("Suspending %d ...", dominfo.getDomid()) + dominfo.shutdown('suspend') -+ dominfo.waitForShutdown() ++ dominfo.waitForSuspend() + if line in ('suspend', 'suspended'): + dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP2, + domain_name) @@ -206,11 +218,10 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendCheckpoint.py + + if name: + dominfo.image.snapshotDeviceModel(name) -+ if checkpoint: dominfo.resumeDomain() -@@ -193,6 +203,63 @@ def restore(xd, fd, dominfo = None, paus +@@ -207,6 +214,71 @@ def restore(xd, fd, dominfo = None, paus if othervm is not None and othervm.domid is not None: raise VmError("Domain '%s' already exists with ID '%d'" % (domconfig["name_label"], othervm.domid)) @@ -222,7 +233,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendCheckpoint.py + ret = False + if cur < end: + ret = True -+ ++ + os.lseek(fd, cur, 0) + return ret + except OSError, (errno, strerr): @@ -247,10 +258,13 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendCheckpoint.py + dominfo.waitForDevices() # Wait for backends to set up + except Exception, exn: + log.exception(exn) ++ if lock: ++ XendDomain.instance().domains_lock.acquire() ++ raise + + if lock: + XendDomain.instance().domains_lock.acquire() -+ ++ + + if not contains_state(fd): + # Disk-only snapshot. Just start the vm from config (which should @@ -265,16 +279,21 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendCheckpoint.py + log.debug("### starting domain through XendDomain.create()") + dominfo = xd.domain_create(vmconfig) + -+ wait_devs(dominfo) ++ try: ++ wait_devs(dominfo) ++ except: ++ dominfo.destroy() ++ raise ++ + dominfo.unpause() -+ ++ + # Done if disk only snapshot + return dominfo -+ ++ if dominfo: dominfo.resume() else: -@@ -308,27 +375,8 @@ def restore(xd, fd, dominfo = None, paus +@@ -322,26 +394,7 @@ def restore(xd, fd, dominfo = None, paus dominfo.completeRestore(handler.store_mfn, handler.console_mfn) @@ -298,37 +317,35 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendCheckpoint.py - - if lock: - XendDomain.instance().domains_lock.acquire() -- + wait_devs(dominfo) -+ + if not paused: dominfo.unpause() - -Index: xen-3.3.1-testing/tools/python/xen/xend/XendConfig.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendConfig.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendConfig.py -@@ -209,6 +209,7 @@ XENAPI_CFG_TYPES = { - 'cpuid_check' : dict, +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendConfig.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendConfig.py +@@ -220,6 +220,7 @@ XENAPI_CFG_TYPES = { 'machine_address_size': int, 'suppress_spurious_page_faults': bool0, + 's3_integrity' : int, + 'snapshotname': str, } # List of legacy configuration keys that have no equivalent in the -Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomain.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendDomain.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendDomain.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendDomain.py +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendDomain.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendDomain.py @@ -52,6 +52,7 @@ from xen.xend.xenstore.xstransact import from xen.xend.xenstore.xswatch import xswatch - from xen.util import mkdir + from xen.util import mkdir, rwlock from xen.xend import uuid +from xen.xend import sxp xc = xen.lowlevel.xc.xc() xoptions = XendOptions.instance() -@@ -1400,6 +1401,181 @@ class XendDomain: +@@ -1418,6 +1419,181 @@ class XendDomain: raise XendError("can't write guest state file %s: %s" % (dst, ex[1])) @@ -343,7 +360,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomain.py + @type dst: bool + @rtype: None + @raise XendError: Failed to snapshot domain -+ @raise XendInvalidDomain: Domain is not valid ++ @raise XendInvalidDomain: Domain is not valid + """ + try: + dominfo = self.domain_lookup_nr(domid) @@ -405,7 +422,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomain.py + @param domid: Domain ID or Name + @type domid: int or string. + @rtype: list of snapshot names -+ @raise XendInvalidDomain: Domain is not valid ++ @raise XendInvalidDomain: Domain is not valid + """ + try: + dominfo = self.domain_lookup_nr(domid) @@ -417,7 +434,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomain.py + + if not os.access(snap_path, os.R_OK): + return [] -+ ++ + return os.listdir(snap_path) + + except: @@ -432,7 +449,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomain.py + @type dst: string + @rtype: None + @raise XendError: Failed to apply snapshot -+ @raise XendInvalidDomain: Domain is not valid ++ @raise XendInvalidDomain: Domain is not valid + """ + try: + dominfo = self.domain_lookup_nr(domid) @@ -473,7 +490,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomain.py + @param name: Snapshot name + @type domid: string + @rtype: None -+ @raise XendInvalidDomain: Domain is not valid ++ @raise XendInvalidDomain: Domain is not valid + """ + dominfo = self.domain_lookup_nr(domid) + if not dominfo: @@ -510,11 +527,11 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomain.py def domain_pincpu(self, domid, vcpu, cpumap): """Set which cpus vcpu can use -Index: xen-3.3.1-testing/tools/python/xen/xm/main.py +Index: xen-3.4.0-testing/tools/python/xen/xm/main.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xm/main.py -+++ xen-3.3.1-testing/tools/python/xen/xm/main.py -@@ -126,6 +126,14 @@ SUBCOMMAND_HELP = { +--- xen-3.4.0-testing.orig/tools/python/xen/xm/main.py ++++ xen-3.4.0-testing/tools/python/xen/xm/main.py +@@ -120,6 +120,14 @@ SUBCOMMAND_HELP = { 'Restore a domain from a saved state.'), 'save' : ('[-c] ', 'Save a domain state to restore later.'), @@ -529,7 +546,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xm/main.py 'shutdown' : (' [-waRH]', 'Shutdown a domain.'), 'top' : ('', 'Monitor a host and the domains in real time.'), 'unpause' : ('', 'Unpause a paused domain.'), -@@ -282,6 +290,9 @@ SUBCOMMAND_OPTIONS = { +@@ -276,6 +284,9 @@ SUBCOMMAND_OPTIONS = { 'save': ( ('-c', '--checkpoint', 'Leave domain running after creating snapshot'), ), @@ -539,7 +556,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xm/main.py 'restore': ( ('-p', '--paused', 'Do not unpause domain after restoring it'), ), -@@ -308,6 +319,10 @@ common_commands = [ +@@ -302,6 +313,10 @@ common_commands = [ "restore", "resume", "save", @@ -550,7 +567,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xm/main.py "shell", "shutdown", "start", -@@ -339,6 +354,10 @@ domain_commands = [ +@@ -333,6 +348,10 @@ domain_commands = [ "restore", "resume", "save", @@ -561,14 +578,14 @@ Index: xen-3.3.1-testing/tools/python/xen/xm/main.py "shutdown", "start", "suspend", -@@ -730,6 +749,62 @@ def xm_event_monitor(args): +@@ -724,6 +743,62 @@ def xm_event_monitor(args): # ######################################################################### +def xm_snapshot_create(args): + + arg_check(args, "snapshot-create", 2, 3) -+ ++ + try: + (options, params) = getopt.gnu_getopt(args, 'd', ['diskonly']) + except getopt.GetoptError, opterr: @@ -584,7 +601,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xm/main.py + err("Wrong number of parameters") + usage('snapshot-create') + -+ if serverType == SERVER_XEN_API: ++ if serverType == SERVER_XEN_API: + server.xenapi.VM.snapshot_create(get_single_vm(params[0]), params[1], diskonly) + else: + server.xend.domain.snapshot_create(params[0], params[1], diskonly) @@ -593,7 +610,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xm/main.py + arg_check(args, "snapshot-list", 1, 2) + + snapshots = None -+ if serverType == SERVER_XEN_API: ++ if serverType == SERVER_XEN_API: + snapshots = server.xenapi.VM.snapshot_list(get_single_vm(args[0])) + else: + snapshots = server.xend.domain.snapshot_list(args[0]) @@ -607,16 +624,16 @@ Index: xen-3.3.1-testing/tools/python/xen/xm/main.py + +def xm_snapshot_apply(args): + arg_check(args, "snapshot-apply", 2, 3) -+ -+ if serverType == SERVER_XEN_API: ++ ++ if serverType == SERVER_XEN_API: + server.xenapi.VM.snapshot_apply(get_single_vm(args[0]), args[1]) + else: + server.xend.domain.snapshot_apply(args[0], args[1]) -+ ++ +def xm_snapshot_delete(args): + arg_check(args, "snapshot-delete", 2, 3) -+ -+ if serverType == SERVER_XEN_API: ++ ++ if serverType == SERVER_XEN_API: + server.xenapi.VM.snapshot_delete(get_single_vm(args[0]), args[1]) + else: + server.xend.domain.snapshot_delete(args[0], args[1]) @@ -624,7 +641,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xm/main.py def xm_save(args): arg_check(args, "save", 2, 3) -@@ -2762,6 +2837,10 @@ commands = { +@@ -2853,6 +2928,10 @@ commands = { "restore": xm_restore, "resume": xm_resume, "save": xm_save, diff --git a/supported_module.diff b/supported_module.diff index 1beafc6..2028ea7 100644 --- a/supported_module.diff +++ b/supported_module.diff @@ -2,10 +2,10 @@ Make our PV drivers "Novell supported modules" Signed-off-by: K. Y. Srinivasan -Index: xen-3.3.1-testing/unmodified_drivers/linux-2.6/Module.supported +Index: xen-3.4.0-testing/unmodified_drivers/linux-2.6/Module.supported =================================================================== --- /dev/null -+++ xen-3.3.1-testing/unmodified_drivers/linux-2.6/Module.supported ++++ xen-3.4.0-testing/unmodified_drivers/linux-2.6/Module.supported @@ -0,0 +1,5 @@ +xen-vbd +xen-platform-pci diff --git a/svm-lmsl.patch b/svm-lmsl.patch new file mode 100644 index 0000000..22d736a --- /dev/null +++ b/svm-lmsl.patch @@ -0,0 +1,87 @@ +Index: xen-3.4.0-testing/xen/arch/x86/hvm/hvm.c +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/hvm/hvm.c ++++ xen-3.4.0-testing/xen/arch/x86/hvm/hvm.c +@@ -537,11 +537,12 @@ static int hvm_load_cpu_ctxt(struct doma + return -EINVAL; + } + +- if ( (ctxt.msr_efer & ~(EFER_FFXSE | EFER_LME | EFER_LMA | ++ if ( (ctxt.msr_efer & ~(EFER_FFXSE | EFER_LMSLE | EFER_LME | EFER_LMA | + EFER_NX | EFER_SCE)) || + ((sizeof(long) != 8) && (ctxt.msr_efer & EFER_LME)) || + (!cpu_has_nx && (ctxt.msr_efer & EFER_NX)) || + (!cpu_has_syscall && (ctxt.msr_efer & EFER_SCE)) || ++ (!cpu_has_lmsl && (ctxt.msr_efer & EFER_LMSLE)) || + (!cpu_has_ffxsr && (ctxt.msr_efer & EFER_FFXSE)) || + ((ctxt.msr_efer & (EFER_LME|EFER_LMA)) == EFER_LMA) ) + { +@@ -818,10 +819,11 @@ int hvm_set_efer(uint64_t value) + + value &= ~EFER_LMA; + +- if ( (value & ~(EFER_FFXSE | EFER_LME | EFER_NX | EFER_SCE)) || ++ if ( (value & ~(EFER_FFXSE | EFER_LMSLE | EFER_LME | EFER_NX | EFER_SCE)) || + ((sizeof(long) != 8) && (value & EFER_LME)) || + (!cpu_has_nx && (value & EFER_NX)) || + (!cpu_has_syscall && (value & EFER_SCE)) || ++ (!cpu_has_lmsl && (value & EFER_LMSLE)) || + (!cpu_has_ffxsr && (value & EFER_FFXSE)) ) + { + gdprintk(XENLOG_WARNING, "Trying to set reserved bit in " +Index: xen-3.4.0-testing/xen/arch/x86/hvm/svm/svm.c +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/hvm/svm/svm.c ++++ xen-3.4.0-testing/xen/arch/x86/hvm/svm/svm.c +@@ -53,6 +53,11 @@ + + u32 svm_feature_flags; + ++#ifdef __x86_64__ ++/* indicate whether guest may use EFER.LMSLE */ ++unsigned char cpu_has_lmsl = 0; ++#endif ++ + #define set_segment_register(name, value) \ + asm volatile ( "movw %%ax ,%%" STR(name) "" : : "a" (value) ) + +@@ -875,6 +880,22 @@ int start_svm(struct cpuinfo_x86 *c) + /* Initialize core's ASID handling. */ + svm_asid_init(c); + ++#ifdef __x86_64__ ++ /* ++ * Check whether EFER.LMSLE can be written. ++ * Unfortunately there's no feature bit defined for this. ++ */ ++ eax = read_efer(); ++ edx = read_efer() >> 32; ++ if ( wrmsr_safe(MSR_EFER, eax | EFER_LMSLE, edx) == 0 ) ++ rdmsr(MSR_EFER, eax, edx); ++ if ( eax & EFER_LMSLE ) ++ { ++ cpu_has_lmsl = 1; ++ wrmsr(MSR_EFER, eax ^ EFER_LMSLE, edx); ++ } ++#endif ++ + if ( cpu != 0 ) + return 1; + +Index: xen-3.4.0-testing/xen/include/asm-x86/hvm/hvm.h +=================================================================== +--- xen-3.4.0-testing.orig/xen/include/asm-x86/hvm/hvm.h ++++ xen-3.4.0-testing/xen/include/asm-x86/hvm/hvm.h +@@ -134,6 +134,12 @@ struct hvm_function_table { + extern struct hvm_function_table hvm_funcs; + extern int hvm_enabled; + ++#ifdef __i386__ ++# define cpu_has_lmsl 0 ++#else ++extern unsigned char cpu_has_lmsl; ++#endif ++ + int hvm_domain_initialise(struct domain *d); + void hvm_domain_relinquish_resources(struct domain *d); + void hvm_domain_destroy(struct domain *d); diff --git a/tapdisk-ioemu-logfile.patch b/tapdisk-ioemu-logfile.patch index cf7e019..6f0bad1 100644 --- a/tapdisk-ioemu-logfile.patch +++ b/tapdisk-ioemu-logfile.patch @@ -1,8 +1,21 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/tapdisk-ioemu.c +From 903a145f3eace5e3ae914f0335ab6c4e33635d2f Mon Sep 17 00:00:00 2001 +From: Kevin Wolf +Date: Tue, 10 Mar 2009 16:36:23 +0100 +Subject: [PATCH 4/6] tapdisk-ioemu: Write messages to a logfile + +Typically, tapdisk-ioemu runs as a daemon and messages to stderr are +simply lost. Write them to a logfile instead. + +Signed-off-by: Kevin Wolf +--- + tapdisk-ioemu.c | 19 +++++++++++++------ + 1 files changed, 13 insertions(+), 6 deletions(-) + +Index: xen-3.4.0-testing/tools/ioemu-remote/tapdisk-ioemu.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/tapdisk-ioemu.c -+++ xen-3.3.1-testing/tools/ioemu-remote/tapdisk-ioemu.c -@@ -100,16 +100,23 @@ int main(void) +--- xen-3.4.0-testing.orig/tools/ioemu-remote/tapdisk-ioemu.c ++++ xen-3.4.0-testing/tools/ioemu-remote/tapdisk-ioemu.c +@@ -78,15 +78,22 @@ int main(void) struct timeval tv; void *old_fd_start = NULL; @@ -13,7 +26,6 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/tapdisk-ioemu.c + exit(0); + bdrv_init(); - qemu_aio_init(); init_blktap(); - /* Daemonize */ diff --git a/tapdisk-ioemu-shutdown-fix.patch b/tapdisk-ioemu-shutdown-fix.patch new file mode 100644 index 0000000..8c3e1d9 --- /dev/null +++ b/tapdisk-ioemu-shutdown-fix.patch @@ -0,0 +1,89 @@ +From 9062564d79cb45029403cc998b48410e42ead924 Mon Sep 17 00:00:00 2001 +From: Kevin Wolf +Date: Tue, 10 Mar 2009 16:45:44 +0100 +Subject: [PATCH 6/6] tapdisk-ioemu: Fix shutdown condition + +Even when opening the only image a tapdisk-ioemu instance is +responsible for fails, it can't immediately shut down. blktapctrl +still wants to communicate with tapdisk-ioemu and close the disk. + +This patch changes tapdisk-ioemu to count the connections to +blktapctrl rather than the number of opened disk images. + +Signed-off-by: Kevin Wolf +--- + hw/xen_blktap.c | 5 ++++- + tapdisk-ioemu.c | 13 ++++++++++--- + 2 files changed, 14 insertions(+), 4 deletions(-) + +Index: xen-3.4.0-testing/tools/ioemu-remote/hw/xen_blktap.c +=================================================================== +--- xen-3.4.0-testing.orig/tools/ioemu-remote/hw/xen_blktap.c ++++ xen-3.4.0-testing/tools/ioemu-remote/hw/xen_blktap.c +@@ -65,6 +65,7 @@ int read_fd; + int write_fd; + + static pid_t process; ++int connected_disks = 0; + fd_list_entry_t *fd_start = NULL; + + extern char* get_snapshot_name(int devid); +@@ -547,6 +548,7 @@ static void handle_blktap_ctrlmsg(void* + + /* Allocate the disk structs */ + s = state_init(); ++ connected_disks++; + + /*Open file*/ + if (s == NULL || open_disk(s, path, msg->drivertype, msg->readonly)) { +@@ -629,7 +631,8 @@ static void handle_blktap_ctrlmsg(void* + case CTLMSG_CLOSE: + s = get_state(msg->cookie); + if (s) unmap_disk(s); +- break; ++ connected_disks--; ++ break; + + case CTLMSG_PID: + memset(buf, 0x00, MSG_SIZE); +Index: xen-3.4.0-testing/tools/ioemu-remote/tapdisk-ioemu.c +=================================================================== +--- xen-3.4.0-testing.orig/tools/ioemu-remote/tapdisk-ioemu.c ++++ xen-3.4.0-testing/tools/ioemu-remote/tapdisk-ioemu.c +@@ -14,6 +14,7 @@ extern void qemu_aio_init(void); + extern void qemu_aio_poll(void); + + extern void *fd_start; ++extern int connected_disks; + + int domid = 0; + FILE* logfile; +@@ -76,7 +77,7 @@ int main(void) + int max_fd; + fd_set rfds; + struct timeval tv; +- void *old_fd_start = NULL; ++ int old_connected_disks = 0; + + /* Daemonize */ + if (fork() != 0) +@@ -128,11 +129,17 @@ int main(void) + pioh = &ioh->next; + } + ++ if (old_connected_disks != connected_disks) ++ fprintf(stderr, "connected disks: %d => %d\n", ++ old_connected_disks, connected_disks); ++ + /* Exit when the last image has been closed */ +- if (old_fd_start != NULL && fd_start == NULL) ++ if (old_connected_disks != 0 && connected_disks == 0) { ++ fprintf(stderr, "Last image is closed, exiting.\n"); + exit(0); ++ } + +- old_fd_start = fd_start; ++ old_connected_disks = connected_disks; + } + return 0; + } diff --git a/tmp_build.patch b/tmp_build.patch index 3e8ed97..33a02f1 100644 --- a/tmp_build.patch +++ b/tmp_build.patch @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/tools/xenstore/Makefile +Index: xen-3.4.0-testing/tools/xenstore/Makefile =================================================================== ---- xen-3.3.1-testing.orig/tools/xenstore/Makefile -+++ xen-3.3.1-testing/tools/xenstore/Makefile -@@ -60,6 +60,7 @@ $(CLIENTS_DOMU): xenstore +--- xen-3.4.0-testing.orig/tools/xenstore/Makefile ++++ xen-3.4.0-testing/tools/xenstore/Makefile +@@ -56,6 +56,7 @@ $(CLIENTS_DOMU): xenstore xenstore: xenstore_client.o $(LIBXENSTORE) $(CC) $(CFLAGS) $(LDFLAGS) $< -L. -lxenstore $(SOCKET_LIBS) -o $@ @@ -10,11 +10,11 @@ Index: xen-3.3.1-testing/tools/xenstore/Makefile xenstore-control: xenstore_control.o $(LIBXENSTORE) $(CC) $(CFLAGS) $(LDFLAGS) $< -L. -lxenstore $(SOCKET_LIBS) -o $@ -@@ -108,10 +109,11 @@ install: all +@@ -104,10 +105,11 @@ install: all $(INSTALL_PROG) xenstore-control $(DESTDIR)$(BINDIR) - $(INSTALL_PROG) xenstore $(DESTDIR)/usr/bin + $(INSTALL_PROG) xenstore $(DESTDIR)$(BINDIR) set -e ; for c in $(CLIENTS) ; do \ -- ln -f $(DESTDIR)/usr/bin/xenstore $(DESTDIR)/usr/bin/$${c} ; \ +- ln -f $(DESTDIR)$(BINDIR)/xenstore $(DESTDIR)$(BINDIR)/$${c} ; \ + ln -fs /usr/bin/xenstore $(DESTDIR)/usr/bin/$${c} ; \ done + $(INSTALL_PROG) domu-xenstore $(DESTDIR)/bin diff --git a/tools-gdbserver-build.diff b/tools-gdbserver-build.diff index 747b03a..83ca78b 100644 --- a/tools-gdbserver-build.diff +++ b/tools-gdbserver-build.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/Makefile.in +Index: xen-3.4.0-testing/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/Makefile.in =================================================================== ---- xen-3.3.1-testing.orig/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/Makefile.in -+++ xen-3.3.1-testing/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/Makefile.in +--- xen-3.4.0-testing.orig/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/Makefile.in ++++ xen-3.4.0-testing/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/Makefile.in @@ -90,7 +90,7 @@ INCLUDE_CFLAGS = -I. -I${srcdir} -I$(src GLOBAL_CFLAGS = ${MT_CFLAGS} ${MH_CFLAGS} #PROFILE_CFLAGS = -pg diff --git a/tools-kboot.diff b/tools-kboot.diff index f4cac24..5237815 100644 --- a/tools-kboot.diff +++ b/tools-kboot.diff @@ -13,10 +13,10 @@ Signed-off-by: Gerd Hoffmann tools/kboot/select-kernel | 59 + 9 files changed, 2111 insertions(+) -Index: xen-3.3.1-testing/buildconfigs/linux-defconfig_xenUboot_x86_32 +Index: xen-3.4.0-testing/buildconfigs/linux-defconfig_xenUboot_x86_32 =================================================================== --- /dev/null -+++ xen-3.3.1-testing/buildconfigs/linux-defconfig_xenUboot_x86_32 ++++ xen-3.4.0-testing/buildconfigs/linux-defconfig_xenUboot_x86_32 @@ -0,0 +1,874 @@ +# +# Automatically generated make config: don't edit @@ -892,10 +892,10 @@ Index: xen-3.3.1-testing/buildconfigs/linux-defconfig_xenUboot_x86_32 +CONFIG_X86_NO_TSS=y +CONFIG_X86_NO_IDT=y +CONFIG_KTIME_SCALAR=y -Index: xen-3.3.1-testing/buildconfigs/linux-defconfig_xenUboot_x86_64 +Index: xen-3.4.0-testing/buildconfigs/linux-defconfig_xenUboot_x86_64 =================================================================== --- /dev/null -+++ xen-3.3.1-testing/buildconfigs/linux-defconfig_xenUboot_x86_64 ++++ xen-3.4.0-testing/buildconfigs/linux-defconfig_xenUboot_x86_64 @@ -0,0 +1,653 @@ +# +# Automatically generated make config: don't edit @@ -1550,17 +1550,17 @@ Index: xen-3.3.1-testing/buildconfigs/linux-defconfig_xenUboot_x86_64 +# CONFIG_CRC32 is not set +# CONFIG_LIBCRC32C is not set +CONFIG_ZLIB_INFLATE=y -Index: xen-3.3.1-testing/buildconfigs/mk.linux-2.6-xenUboot +Index: xen-3.4.0-testing/buildconfigs/mk.linux-2.6-xenUboot =================================================================== --- /dev/null -+++ xen-3.3.1-testing/buildconfigs/mk.linux-2.6-xenUboot ++++ xen-3.4.0-testing/buildconfigs/mk.linux-2.6-xenUboot @@ -0,0 +1,2 @@ +EXTRAVERSION = xenUboot +include buildconfigs/mk.linux-2.6-xen -Index: xen-3.3.1-testing/tools/kboot/Makefile +Index: xen-3.4.0-testing/tools/kboot/Makefile =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/kboot/Makefile ++++ xen-3.4.0-testing/tools/kboot/Makefile @@ -0,0 +1,23 @@ +# +# tools/kboot/Makefile @@ -1585,10 +1585,10 @@ Index: xen-3.3.1-testing/tools/kboot/Makefile +kboot.initramfs: mkinitramfs init select-kernel ../xcutils/xc_kexec + sh ./mkinitramfs | tee $@ + -Index: xen-3.3.1-testing/tools/kboot/README +Index: xen-3.4.0-testing/tools/kboot/README =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/kboot/README ++++ xen-3.4.0-testing/tools/kboot/README @@ -0,0 +1,43 @@ + +This is a simple kexec-based boot loader @@ -1633,10 +1633,10 @@ Index: xen-3.3.1-testing/tools/kboot/README + +-- +Gerd Hoffmann -Index: xen-3.3.1-testing/tools/kboot/init +Index: xen-3.4.0-testing/tools/kboot/init =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/kboot/init ++++ xen-3.4.0-testing/tools/kboot/init @@ -0,0 +1,309 @@ +#!/bin/sh + @@ -1947,10 +1947,10 @@ Index: xen-3.3.1-testing/tools/kboot/init +msg "bye ..." +banner "boot $guestos" +xc_kexec -e -Index: xen-3.3.1-testing/tools/kboot/mkinitramfs +Index: xen-3.4.0-testing/tools/kboot/mkinitramfs =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/kboot/mkinitramfs ++++ xen-3.4.0-testing/tools/kboot/mkinitramfs @@ -0,0 +1,111 @@ +#!/bin/sh + @@ -2063,10 +2063,10 @@ Index: xen-3.3.1-testing/tools/kboot/mkinitramfs + echo "file $LIB/$(basename $lib) $lib 0755 0 0" +done +echo -Index: xen-3.3.1-testing/tools/kboot/select-kernel +Index: xen-3.4.0-testing/tools/kboot/select-kernel =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/kboot/select-kernel ++++ xen-3.4.0-testing/tools/kboot/select-kernel @@ -0,0 +1,59 @@ +#!/bin/sh + @@ -2127,10 +2127,10 @@ Index: xen-3.3.1-testing/tools/kboot/select-kernel +msg "using $kernelname" +echo "$kernelname" + -Index: xen-3.3.1-testing/make-kboot +Index: xen-3.4.0-testing/make-kboot =================================================================== --- /dev/null -+++ xen-3.3.1-testing/make-kboot ++++ xen-3.4.0-testing/make-kboot @@ -0,0 +1,37 @@ +#!/bin/sh + diff --git a/tools-xc_kexec.diff b/tools-xc_kexec.diff index ecc8dba..3a257cb 100644 --- a/tools-xc_kexec.diff +++ b/tools-xc_kexec.diff @@ -23,20 +23,20 @@ Signed-off-by: Gerd Hoffmann tools/xcutils/xc_kexec.c | 503 +++++++++++++++ 19 files changed, 4988 insertions(+), 2 deletions(-) -Index: xen-3.3.1-testing/tools/xcutils/Makefile +Index: xen-3.4.0-testing/tools/xcutils/Makefile =================================================================== ---- xen-3.3.1-testing.orig/tools/xcutils/Makefile -+++ xen-3.3.1-testing/tools/xcutils/Makefile -@@ -18,7 +18,7 @@ CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_ - CFLAGS += -Wp,-MD,.$(@F).d - PROG_DEP = .*.d +--- xen-3.4.0-testing.orig/tools/xcutils/Makefile ++++ xen-3.4.0-testing/tools/xcutils/Makefile +@@ -14,7 +14,7 @@ include $(XEN_ROOT)/tools/Rules.mk + CFLAGS += -Werror + CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) -PROGRAMS = xc_restore xc_save readnotes lsevtchn +PROGRAMS = xc_restore xc_save readnotes lsevtchn xc_kexec LDLIBS = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore) -@@ -31,6 +31,11 @@ build: $(PROGRAMS) +@@ -27,6 +27,11 @@ build: $(PROGRAMS) $(PROGRAMS): %: %.o $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@ @@ -48,17 +48,17 @@ Index: xen-3.3.1-testing/tools/xcutils/Makefile .PHONY: install install: build $(INSTALL_DIR) $(DESTDIR)$(PRIVATE_BINDIR) -@@ -41,5 +46,6 @@ install: build +@@ -37,5 +42,6 @@ install: build clean: $(RM) *.o $(PROGRAMS) - $(RM) $(PROG_DEP) + $(RM) $(DEPS) + make -C helper clean - -include $(PROG_DEP) -Index: xen-3.3.1-testing/tools/xcutils/helper/Makefile + -include $(DEPS) +Index: xen-3.4.0-testing/tools/xcutils/helper/Makefile =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/Makefile ++++ xen-3.4.0-testing/tools/xcutils/helper/Makefile @@ -0,0 +1,39 @@ + +XEN_ROOT = ../../.. @@ -99,10 +99,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/Makefile +# dependencies + +$(XEN_TARGET_ARCH)/entry.o: $(XEN_TARGET_ARCH)/entry.S $(XEN_TARGET_ARCH)/offsets.h -Index: xen-3.3.1-testing/tools/xcutils/helper/console.c +Index: xen-3.4.0-testing/tools/xcutils/helper/console.c =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/console.c ++++ xen-3.4.0-testing/tools/xcutils/helper/console.c @@ -0,0 +1,69 @@ +#include + @@ -173,10 +173,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/console.c + + return printed_len; +} -Index: xen-3.3.1-testing/tools/xcutils/helper/ctype.c +Index: xen-3.4.0-testing/tools/xcutils/helper/ctype.c =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/ctype.c ++++ xen-3.4.0-testing/tools/xcutils/helper/ctype.c @@ -0,0 +1,35 @@ +/* + * linux/lib/ctype.c @@ -213,10 +213,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/ctype.c +_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ + +EXPORT_SYMBOL(_ctype); -Index: xen-3.3.1-testing/tools/xcutils/helper/ctype.h +Index: xen-3.4.0-testing/tools/xcutils/helper/ctype.h =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/ctype.h ++++ xen-3.4.0-testing/tools/xcutils/helper/ctype.h @@ -0,0 +1,54 @@ +#ifndef _LINUX_CTYPE_H +#define _LINUX_CTYPE_H @@ -272,10 +272,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/ctype.h +#define toupper(c) __toupper(c) + +#endif -Index: xen-3.3.1-testing/tools/xcutils/helper/helper.h +Index: xen-3.4.0-testing/tools/xcutils/helper/helper.h =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/helper.h ++++ xen-3.4.0-testing/tools/xcutils/helper/helper.h @@ -0,0 +1,107 @@ +#include +#include @@ -384,10 +384,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/helper.h +int sprintf(char * buf, const char *fmt, ...); +int vsscanf(const char * buf, const char * fmt, va_list args); +int sscanf(const char * buf, const char * fmt, ...); -Index: xen-3.3.1-testing/tools/xcutils/helper/main.c +Index: xen-3.4.0-testing/tools/xcutils/helper/main.c =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/main.c ++++ xen-3.4.0-testing/tools/xcutils/helper/main.c @@ -0,0 +1,651 @@ +#include +#include "hypercall.h" @@ -1040,10 +1040,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/main.c + printk("\r\n"); + start_kernel(); +} -Index: xen-3.3.1-testing/tools/xcutils/helper/make-offsets.c +Index: xen-3.4.0-testing/tools/xcutils/helper/make-offsets.c =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/make-offsets.c ++++ xen-3.4.0-testing/tools/xcutils/helper/make-offsets.c @@ -0,0 +1,28 @@ +#include +#include @@ -1073,10 +1073,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/make-offsets.c + vcpu_off("cr3", ctrlreg[3]); + return 0; +} -Index: xen-3.3.1-testing/tools/xcutils/helper/printk.c +Index: xen-3.4.0-testing/tools/xcutils/helper/printk.c =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/printk.c ++++ xen-3.4.0-testing/tools/xcutils/helper/printk.c @@ -0,0 +1,1051 @@ +/* + * linux/kernel/printk.c @@ -2129,10 +2129,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/printk.c + printk_ratelimit_burst); +} +EXPORT_SYMBOL(printk_ratelimit); -Index: xen-3.3.1-testing/tools/xcutils/helper/string.c +Index: xen-3.4.0-testing/tools/xcutils/helper/string.c =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/string.c ++++ xen-3.4.0-testing/tools/xcutils/helper/string.c @@ -0,0 +1,601 @@ +/* + * linux/lib/string.c @@ -2735,10 +2735,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/string.c +} +EXPORT_SYMBOL(memchr); +#endif -Index: xen-3.3.1-testing/tools/xcutils/helper/vsprintf.c +Index: xen-3.4.0-testing/tools/xcutils/helper/vsprintf.c =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/vsprintf.c ++++ xen-3.4.0-testing/tools/xcutils/helper/vsprintf.c @@ -0,0 +1,842 @@ +/* + * linux/lib/vsprintf.c @@ -3582,10 +3582,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/vsprintf.c +} + +EXPORT_SYMBOL(sscanf); -Index: xen-3.3.1-testing/tools/xcutils/helper/x86_32/div64.h +Index: xen-3.4.0-testing/tools/xcutils/helper/x86_32/div64.h =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/x86_32/div64.h ++++ xen-3.4.0-testing/tools/xcutils/helper/x86_32/div64.h @@ -0,0 +1,48 @@ +#ifndef __I386_DIV64 +#define __I386_DIV64 @@ -3635,10 +3635,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/x86_32/div64.h + +} +#endif -Index: xen-3.3.1-testing/tools/xcutils/helper/x86_32/entry.S +Index: xen-3.4.0-testing/tools/xcutils/helper/x86_32/entry.S =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/x86_32/entry.S ++++ xen-3.4.0-testing/tools/xcutils/helper/x86_32/entry.S @@ -0,0 +1,49 @@ +#include "offsets.h" + @@ -3689,10 +3689,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/x86_32/entry.S + nop + .align 4096 +hypercall_end: -Index: xen-3.3.1-testing/tools/xcutils/helper/x86_32/hypercall.h +Index: xen-3.4.0-testing/tools/xcutils/helper/x86_32/hypercall.h =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/x86_32/hypercall.h ++++ xen-3.4.0-testing/tools/xcutils/helper/x86_32/hypercall.h @@ -0,0 +1,359 @@ +/****************************************************************************** + * hypercall.h @@ -4053,10 +4053,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/x86_32/hypercall.h + + +#endif /* __HYPERCALL_H__ */ -Index: xen-3.3.1-testing/tools/xcutils/helper/x86_64/div64.h +Index: xen-3.4.0-testing/tools/xcutils/helper/x86_64/div64.h =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/x86_64/div64.h ++++ xen-3.4.0-testing/tools/xcutils/helper/x86_64/div64.h @@ -0,0 +1,57 @@ +#ifndef _ASM_GENERIC_DIV64_H +#define _ASM_GENERIC_DIV64_H @@ -4115,10 +4115,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/x86_64/div64.h +#endif /* BITS_PER_LONG */ + +#endif /* _ASM_GENERIC_DIV64_H */ -Index: xen-3.3.1-testing/tools/xcutils/helper/x86_64/entry.S +Index: xen-3.4.0-testing/tools/xcutils/helper/x86_64/entry.S =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/x86_64/entry.S ++++ xen-3.4.0-testing/tools/xcutils/helper/x86_64/entry.S @@ -0,0 +1,50 @@ +#include "offsets.h" + @@ -4170,10 +4170,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/x86_64/entry.S + nop + .align 4096 +hypercall_end: -Index: xen-3.3.1-testing/tools/xcutils/helper/x86_64/hypercall.h +Index: xen-3.4.0-testing/tools/xcutils/helper/x86_64/hypercall.h =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/helper/x86_64/hypercall.h ++++ xen-3.4.0-testing/tools/xcutils/helper/x86_64/hypercall.h @@ -0,0 +1,354 @@ +/****************************************************************************** + * hypercall.h @@ -4529,10 +4529,10 @@ Index: xen-3.3.1-testing/tools/xcutils/helper/x86_64/hypercall.h +} + +#endif /* __HYPERCALL_H__ */ -Index: xen-3.3.1-testing/tools/xcutils/kexec-syscall.h +Index: xen-3.4.0-testing/tools/xcutils/kexec-syscall.h =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/kexec-syscall.h ++++ xen-3.4.0-testing/tools/xcutils/kexec-syscall.h @@ -0,0 +1,80 @@ +#ifndef KEXEC_SYSCALL_H +#define KEXEC_SYSCALL_H @@ -4614,10 +4614,10 @@ Index: xen-3.3.1-testing/tools/xcutils/kexec-syscall.h +#define KEXEC_MAX_SEGMENTS 16 + +#endif /* KEXEC_SYSCALL_H */ -Index: xen-3.3.1-testing/tools/xcutils/xc_kexec.c +Index: xen-3.4.0-testing/tools/xcutils/xc_kexec.c =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/xcutils/xc_kexec.c ++++ xen-3.4.0-testing/tools/xcutils/xc_kexec.c @@ -0,0 +1,503 @@ +#include +#include @@ -4629,7 +4629,7 @@ Index: xen-3.3.1-testing/tools/xcutils/xc_kexec.c + +#include +#include -+#include ++#include + +#include "kexec-syscall.h" + diff --git a/udev-rules.patch b/udev-rules.patch index 384d001..6b3fbad 100644 --- a/udev-rules.patch +++ b/udev-rules.patch @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/tools/examples/xen-backend.rules +Index: xen-3.4.0-testing/tools/hotplug/Linux/xen-backend.rules =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/xen-backend.rules -+++ xen-3.3.1-testing/tools/examples/xen-backend.rules -@@ -7,3 +7,4 @@ SUBSYSTEM=="xen-backend", KERNEL=="vscsi +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/xen-backend.rules ++++ xen-3.4.0-testing/tools/hotplug/Linux/xen-backend.rules +@@ -6,3 +6,4 @@ SUBSYSTEM=="xen-backend", KERNEL=="vscsi SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/etc/xen/scripts/xen-hotplug-cleanup" KERNEL=="evtchn", NAME="xen/%k" KERNEL=="blktap[0-9]*", NAME="xen/%k" diff --git a/x86-alloc-cpu-structs.patch b/x86-alloc-cpu-structs.patch index a2e4e1e..73a2787 100644 --- a/x86-alloc-cpu-structs.patch +++ b/x86-alloc-cpu-structs.patch @@ -101,10 +101,10 @@ Index: xen-3.3.1-testing/xen/arch/x86/acpi/cpufreq/powernow.c cpufreq_driver = &powernow_cpufreq_driver; -Index: xen-3.3.1-testing/xen/arch/x86/acpi/cpufreq/utility.c +Index: xen-3.3.1-testing/xen/drivers/cpufreq/utility.c =================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/acpi/cpufreq/utility.c -+++ xen-3.3.1-testing/xen/arch/x86/acpi/cpufreq/utility.c +--- xen-3.3.1-testing.orig/xen/drivers/cpufreq/utility.c ++++ xen-3.3.1-testing/xen/xen/drivers/cpufreq/utility.c @@ -45,10 +45,12 @@ void px_statistic_suspend(void) now = NOW(); @@ -323,10 +323,10 @@ Index: xen-3.3.1-testing/xen/arch/x86/acpi/cpu_idle.c stat->idle_time = v->runstate.time[RUNSTATE_running]; if ( v->is_running ) stat->idle_time += NOW() - v->runstate.state_entry_time; -Index: xen-3.3.1-testing/xen/arch/x86/acpi/pmstat.c +Index: xen-3.3.1-testing/xen/drivers/acpi/pmstat.c =================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/acpi/pmstat.c -+++ xen-3.3.1-testing/xen/arch/x86/acpi/pmstat.c +--- xen-3.3.1-testing.orig/xen/drivers/acpi/pmstat.c ++++ xen-3.3.1-testing/xen/drivers/acpi/pmstat.c @@ -41,7 +41,7 @@ #include #include diff --git a/x86-cpufreq-report.patch b/x86-cpufreq-report.patch index 68e1a2d..a88978a 100644 --- a/x86-cpufreq-report.patch +++ b/x86-cpufreq-report.patch @@ -1,5 +1,7 @@ ---- a/xen/arch/x86/platform_hypercall.c -+++ b/xen/arch/x86/platform_hypercall.c +Index: xen-3.4.0-testing/xen/arch/x86/platform_hypercall.c +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/platform_hypercall.c ++++ xen-3.4.0-testing/xen/arch/x86/platform_hypercall.c @@ -21,7 +21,7 @@ #include #include @@ -9,7 +11,7 @@ #include #include #include "cpu/mtrr/mtrr.h" -@@ -55,6 +55,7 @@ static long cpu_frequency_change_helper( +@@ -56,6 +56,7 @@ static long cpu_frequency_change_helper( ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op) { ret_t ret = 0; @@ -17,7 +19,7 @@ struct xen_platform_op curop, *op = &curop; if ( !IS_PRIV(current->domain) ) -@@ -300,7 +301,6 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe +@@ -313,7 +314,6 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe { uint32_t cpu; uint64_t idletime, now = NOW(); @@ -25,7 +27,7 @@ struct xenctl_cpumap ctlmap; cpumask_t cpumap; XEN_GUEST_HANDLE(uint8) cpumap_bitmap; -@@ -461,6 +461,19 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe +@@ -386,6 +386,20 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe break; } break; @@ -38,16 +40,19 @@ + break; + } + -+ op->u.get_cpu_freq.freq = xen_px_policy[v->processor].cur; ++ op->u.get_cpu_freq.freq = cpufreq_cpu_policy[v->processor] ? ++ cpufreq_cpu_policy[v->processor]->cur : 0; + if ( copy_field_to_guest(u_xenpf_op, op, u.get_cpu_freq.freq) ) + ret = -EFAULT; + break; default: ret = -ENOSYS; ---- a/xen/arch/x86/x86_64/platform_hypercall.c -+++ b/xen/arch/x86/x86_64/platform_hypercall.c -@@ -21,6 +21,8 @@ DEFINE_XEN_GUEST_HANDLE(compat_platform_ +Index: xen-3.4.0-testing/xen/arch/x86/x86_64/platform_hypercall.c +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/x86_64/platform_hypercall.c ++++ xen-3.4.0-testing/xen/arch/x86/x86_64/platform_hypercall.c +@@ -23,6 +23,8 @@ DEFINE_XEN_GUEST_HANDLE(compat_platform_ #define xen_processor_power_t compat_processor_power_t #define set_cx_pminfo compat_set_cx_pminfo @@ -56,8 +61,10 @@ #define xenpf_enter_acpi_sleep compat_pf_enter_acpi_sleep #define COMPAT ---- a/xen/include/public/platform.h -+++ b/xen/include/public/platform.h +Index: xen-3.4.0-testing/xen/include/public/platform.h +=================================================================== +--- xen-3.4.0-testing.orig/xen/include/public/platform.h ++++ xen-3.4.0-testing/xen/include/public/platform.h @@ -312,6 +312,16 @@ struct xenpf_set_processor_pminfo { typedef struct xenpf_set_processor_pminfo xenpf_set_processor_pminfo_t; DEFINE_XEN_GUEST_HANDLE(xenpf_set_processor_pminfo_t); diff --git a/x86-extra-trap-info.patch b/x86-extra-trap-info.patch index 0fd6112..d4dd526 100644 --- a/x86-extra-trap-info.patch +++ b/x86-extra-trap-info.patch @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/xen/arch/x86/x86_32/entry.S +Index: xen-3.4.0-testing/xen/arch/x86/x86_32/entry.S =================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/x86_32/entry.S -+++ xen-3.3.1-testing/xen/arch/x86/x86_32/entry.S +--- xen-3.4.0-testing.orig/xen/arch/x86/x86_32/entry.S ++++ xen-3.4.0-testing/xen/arch/x86/x86_32/entry.S @@ -401,21 +401,33 @@ ring1: /* obtain ss/esp from oldss/olde movl %eax,UREGS_eip+4(%esp) ret @@ -46,10 +46,10 @@ Index: xen-3.3.1-testing/xen/arch/x86/x86_32/entry.S domain_crash_synchronous: pushl $domain_crash_synchronous_string call printk -Index: xen-3.3.1-testing/xen/arch/x86/x86_64/entry.S +Index: xen-3.4.0-testing/xen/arch/x86/x86_64/entry.S =================================================================== ---- xen-3.3.1-testing.orig/xen/arch/x86/x86_64/entry.S -+++ xen-3.3.1-testing/xen/arch/x86/x86_64/entry.S +--- xen-3.4.0-testing.orig/xen/arch/x86/x86_64/entry.S ++++ xen-3.4.0-testing/xen/arch/x86/x86_64/entry.S @@ -419,17 +419,30 @@ create_bounce_frame: movq %rax,UREGS_rip+8(%rsp) ret diff --git a/x86-show-page-walk-early.patch b/x86-show-page-walk-early.patch index 983ecc8..dff7f02 100644 --- a/x86-show-page-walk-early.patch +++ b/x86-show-page-walk-early.patch @@ -1,6 +1,8 @@ ---- a/xen/arch/x86/traps.c -+++ b/xen/arch/x86/traps.c -@@ -1273,6 +1273,7 @@ asmlinkage void do_early_page_fault(stru +Index: xen-3.4.0-testing/xen/arch/x86/traps.c +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/traps.c ++++ xen-3.4.0-testing/xen/arch/x86/traps.c +@@ -1293,6 +1293,7 @@ asmlinkage void do_early_page_fault(stru unsigned long *stk = (unsigned long *)regs; printk("Early fatal page fault at %04x:%p (cr2=%p, ec=%04x)\n", regs->cs, _p(regs->eip), _p(cr2), regs->error_code); @@ -8,8 +10,10 @@ printk("Stack dump: "); while ( ((long)stk & ((PAGE_SIZE - 1) & ~(BYTES_PER_LONG - 1))) != 0 ) printk("%p ", _p(*stk++)); ---- a/xen/arch/x86/x86_32/mm.c -+++ b/xen/arch/x86/x86_32/mm.c +Index: xen-3.4.0-testing/xen/arch/x86/x86_32/mm.c +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/x86_32/mm.c ++++ xen-3.4.0-testing/xen/arch/x86/x86_32/mm.c @@ -38,6 +38,7 @@ extern l1_pgentry_t l1_identmap[L1_PAGET unsigned int PAGE_HYPERVISOR = __PAGE_HYPERVISOR; unsigned int PAGE_HYPERVISOR_NOCACHE = __PAGE_HYPERVISOR_NOCACHE; @@ -27,8 +31,10 @@ /* Fill with an obvious debug pattern. */ for ( i = 0; i < (mpt_size / BYTES_PER_LONG); i++) set_gpfn_from_mfn(i, 0x55555555); ---- a/xen/arch/x86/x86_32/traps.c -+++ b/xen/arch/x86/x86_32/traps.c +Index: xen-3.4.0-testing/xen/arch/x86/x86_32/traps.c +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/x86_32/traps.c ++++ xen-3.4.0-testing/xen/arch/x86/x86_32/traps.c @@ -160,7 +160,8 @@ void show_page_walk(unsigned long addr) l3t += (cr3 & 0xFE0UL) >> 3; l3e = l3t[l3_table_offset(addr)]; @@ -59,17 +65,19 @@ printk(" L1[0x%03lx] = %"PRIpte" %08lx\n", l1_table_offset(addr), l1e_get_intpte(l1e), pfn); unmap_domain_page(l1t); ---- a/xen/arch/x86/x86_64/mm.c -+++ b/xen/arch/x86/x86_64/mm.c -@@ -32,6 +32,7 @@ - #include +Index: xen-3.4.0-testing/xen/arch/x86/x86_64/mm.c +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/x86_64/mm.c ++++ xen-3.4.0-testing/xen/arch/x86/x86_64/mm.c +@@ -33,6 +33,7 @@ + #include #include +int mpt_valid; #ifdef CONFIG_COMPAT unsigned int m2p_compat_vstart = __HYPERVISOR_COMPAT_VIRT_START; #endif -@@ -151,6 +152,8 @@ void __init paging_init(void) +@@ -181,6 +182,8 @@ void __init paging_init(void) l2_ro_mpt++; } @@ -78,9 +86,11 @@ /* Create user-accessible L2 directory to map the MPT for compat guests. */ BUILD_BUG_ON(l4_table_offset(RDWR_MPT_VIRT_START) != l4_table_offset(HIRO_COMPAT_MPT_VIRT_START)); ---- a/xen/arch/x86/x86_64/traps.c -+++ b/xen/arch/x86/x86_64/traps.c -@@ -174,7 +174,8 @@ void show_page_walk(unsigned long addr) +Index: xen-3.4.0-testing/xen/arch/x86/x86_64/traps.c +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/x86_64/traps.c ++++ xen-3.4.0-testing/xen/arch/x86/x86_64/traps.c +@@ -176,7 +176,8 @@ void show_page_walk(unsigned long addr) l4t = mfn_to_virt(mfn); l4e = l4t[l4_table_offset(addr)]; mfn = l4e_get_pfn(l4e); @@ -90,7 +100,7 @@ printk(" L4[0x%03lx] = %"PRIpte" %016lx\n", l4_table_offset(addr), l4e_get_intpte(l4e), pfn); if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) ) -@@ -183,7 +184,8 @@ void show_page_walk(unsigned long addr) +@@ -185,7 +186,8 @@ void show_page_walk(unsigned long addr) l3t = mfn_to_virt(mfn); l3e = l3t[l3_table_offset(addr)]; mfn = l3e_get_pfn(l3e); @@ -100,7 +110,7 @@ printk(" L3[0x%03lx] = %"PRIpte" %016lx%s\n", l3_table_offset(addr), l3e_get_intpte(l3e), pfn, (l3e_get_flags(l3e) & _PAGE_PSE) ? " (PSE)" : ""); -@@ -194,7 +196,8 @@ void show_page_walk(unsigned long addr) +@@ -196,7 +198,8 @@ void show_page_walk(unsigned long addr) l2t = mfn_to_virt(mfn); l2e = l2t[l2_table_offset(addr)]; mfn = l2e_get_pfn(l2e); @@ -110,7 +120,7 @@ printk(" L2[0x%03lx] = %"PRIpte" %016lx %s\n", l2_table_offset(addr), l2e_get_intpte(l2e), pfn, (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : ""); -@@ -205,7 +208,8 @@ void show_page_walk(unsigned long addr) +@@ -207,7 +210,8 @@ void show_page_walk(unsigned long addr) l1t = mfn_to_virt(mfn); l1e = l1t[l1_table_offset(addr)]; mfn = l1e_get_pfn(l1e); @@ -120,9 +130,11 @@ printk(" L1[0x%03lx] = %"PRIpte" %016lx\n", l1_table_offset(addr), l1e_get_intpte(l1e), pfn); } ---- a/xen/include/asm-x86/mm.h -+++ b/xen/include/asm-x86/mm.h -@@ -330,6 +330,7 @@ TYPE_SAFE(unsigned long,mfn); +Index: xen-3.4.0-testing/xen/include/asm-x86/mm.h +=================================================================== +--- xen-3.4.0-testing.orig/xen/include/asm-x86/mm.h ++++ xen-3.4.0-testing/xen/include/asm-x86/mm.h +@@ -411,6 +411,7 @@ TYPE_SAFE(unsigned long,mfn); #define machine_to_phys_mapping ((unsigned long *)RDWR_MPT_VIRT_START) #define INVALID_M2P_ENTRY (~0UL) #define VALID_M2P(_e) (!((_e) & (1UL<<(BITS_PER_LONG-1)))) diff --git a/x86_64-5Tb.patch b/x86_64-5Tb.patch new file mode 100644 index 0000000..fb1c669 --- /dev/null +++ b/x86_64-5Tb.patch @@ -0,0 +1,153 @@ +Index: xen-3.4.0-testing/xen/arch/x86/boot/head.S +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/boot/head.S ++++ xen-3.4.0-testing/xen/arch/x86/boot/head.S +@@ -33,7 +33,7 @@ ENTRY(start) + /* Checksum: must be the negated sum of the first two fields. */ + .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) + +- .section .init.text ++ .section .init.text, "ax" + + .Lbad_cpu_msg: .asciz "ERR: Not a 64-bit CPU!" + .Lbad_ldr_msg: .asciz "ERR: Not a Multiboot bootloader!" +@@ -128,13 +128,13 @@ __start: + loop 1b + /* Initialise L3 xen-map page directory entry. */ + mov $(sym_phys(l2_xenmap)+7),%eax +- mov %eax,sym_phys(l3_xenmap) + (50*8) ++ mov %eax,sym_phys(l3_xenmap) + l3_table_offset(XEN_VIRT_START)*8 + /* Hook identity-map and xen-map L3 tables into PML4. */ + mov $(sym_phys(l3_identmap)+7),%eax + mov %eax,sym_phys(idle_pg_table) + ( 0*8) /* PML4[ 0]: 1:1 map */ +- mov %eax,sym_phys(idle_pg_table) + (262*8) /* PML4[262]: 1:1 map */ ++ mov %eax,sym_phys(idle_pg_table) + l4_table_offset(DIRECTMAP_VIRT_START)*8 + mov $(sym_phys(l3_xenmap)+7),%eax +- mov %eax,sym_phys(idle_pg_table) + (261*8) /* PML4[261]: xen map */ ++ mov %eax,sym_phys(idle_pg_table) + l4_table_offset(XEN_VIRT_START)*8 + #else + /* Initialize low and high mappings of memory with 2MB pages */ + mov $sym_phys(idle_pg_table_l2),%edi +Index: xen-3.4.0-testing/xen/arch/x86/e820.c +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/e820.c ++++ xen-3.4.0-testing/xen/arch/x86/e820.c +@@ -467,15 +467,19 @@ static void __init machine_specific_memo + "can be accessed by Xen in 32-bit mode."); + #else + { +- unsigned long limit, mpt_limit, pft_limit; ++ unsigned long limit, mpt_limit, ro_mpt_limit, pft_limit; + + limit = DIRECTMAP_VIRT_END - DIRECTMAP_VIRT_START; + mpt_limit = ((RDWR_MPT_VIRT_END - RDWR_MPT_VIRT_START) + / sizeof(unsigned long)) << PAGE_SHIFT; ++ ro_mpt_limit = ((RO_MPT_VIRT_END - RO_MPT_VIRT_START) ++ / sizeof(unsigned long)) << PAGE_SHIFT; + pft_limit = ((FRAMETABLE_VIRT_END - FRAMETABLE_VIRT_START) + / sizeof(struct page_info)) << PAGE_SHIFT; + if ( limit > mpt_limit ) + limit = mpt_limit; ++ if ( limit > ro_mpt_limit ) ++ limit = ro_mpt_limit; + if ( limit > pft_limit ) + limit = pft_limit; + clip_to_limit(limit, +Index: xen-3.4.0-testing/xen/include/asm-x86/config.h +=================================================================== +--- xen-3.4.0-testing.orig/xen/include/asm-x86/config.h ++++ xen-3.4.0-testing/xen/include/asm-x86/config.h +@@ -124,10 +124,12 @@ extern unsigned int video_mode, video_fl + #define PML4_ADDR(_slot) \ + ((((_slot ## UL) >> 8) * 0xffff000000000000UL) | \ + (_slot ## UL << PML4_ENTRY_BITS)) ++#define GB(_gb) (_gb ## UL << 30) + #else + #define PML4_ENTRY_BYTES (1 << PML4_ENTRY_BITS) + #define PML4_ADDR(_slot) \ + (((_slot >> 8) * 0xffff000000000000) | (_slot << PML4_ENTRY_BITS)) ++#define GB(_gb) (_gb << 30) + #endif + + /* +@@ -151,21 +153,19 @@ extern unsigned int video_mode, video_fl + * 0xffff828000000000 - 0xffff8283ffffffff [16GB, 2^34 bytes, PML4:261] + * Machine-to-phys translation table. + * 0xffff828400000000 - 0xffff8287ffffffff [16GB, 2^34 bytes, PML4:261] +- * Page-frame information array. +- * 0xffff828800000000 - 0xffff828bffffffff [16GB, 2^34 bytes, PML4:261] + * ioremap()/fixmap area. +- * 0xffff828c00000000 - 0xffff828c3fffffff [1GB, 2^30 bytes, PML4:261] ++ * 0xffff828800000000 - 0xffff82883fffffff [1GB, 2^30 bytes, PML4:261] + * Compatibility machine-to-phys translation table. +- * 0xffff828c40000000 - 0xffff828c7fffffff [1GB, 2^30 bytes, PML4:261] ++ * 0xffff828840000000 - 0xffff82887fffffff [1GB, 2^30 bytes, PML4:261] + * High read-only compatibility machine-to-phys translation table. +- * 0xffff828c80000000 - 0xffff828cbfffffff [1GB, 2^30 bytes, PML4:261] ++ * 0xffff828880000000 - 0xffff8288bfffffff [1GB, 2^30 bytes, PML4:261] + * Xen text, static data, bss. +- * 0xffff828cc0000000 - 0xffff82ffffffffff [461GB, PML4:261] ++ * 0xffff8288c0000000 - 0xffff82ffffffffff [221GB, PML4:261] + * Reserved for future use. +- * 0xffff830000000000 - 0xffff83ffffffffff [1TB, 2^40 bytes, PML4:262-263] ++ * 0xffff82c000000000 - 0xffff82ffffffffff [256GB, 2^38 bytes, PML4:261] ++ * Page-frame information array. ++ * 0xffff830000000000 - 0xffff87ffffffffff [5TB, 5*2^40 bytes, PML4:262-271] + * 1:1 direct mapping of all physical memory. +- * 0xffff840000000000 - 0xffff87ffffffffff [4TB, 2^42 bytes, PML4:264-271] +- * Reserved for future use. + * 0xffff880000000000 - 0xffffffffffffffff [120TB, PML4:272-511] + * Guest-defined use. + * +@@ -206,25 +206,25 @@ extern unsigned int video_mode, video_fl + #define PERDOMAIN_MBYTES ((unsigned long)GDT_LDT_MBYTES) + /* Slot 261: machine-to-phys conversion table (16GB). */ + #define RDWR_MPT_VIRT_START (PML4_ADDR(261)) +-#define RDWR_MPT_VIRT_END (RDWR_MPT_VIRT_START + (16UL<<30)) +-/* Slot 261: page-frame information array (16GB). */ +-#define FRAMETABLE_VIRT_START (RDWR_MPT_VIRT_END) +-#define FRAMETABLE_VIRT_END (FRAMETABLE_VIRT_START + (16UL<<30)) ++#define RDWR_MPT_VIRT_END (RDWR_MPT_VIRT_START + GB(16)) + /* Slot 261: ioremap()/fixmap area (16GB). */ +-#define IOREMAP_VIRT_START (FRAMETABLE_VIRT_END) +-#define IOREMAP_VIRT_END (IOREMAP_VIRT_START + (16UL<<30)) ++#define IOREMAP_VIRT_START RDWR_MPT_VIRT_END ++#define IOREMAP_VIRT_END (IOREMAP_VIRT_START + GB(16)) + /* Slot 261: compatibility machine-to-phys conversion table (1GB). */ + #define RDWR_COMPAT_MPT_VIRT_START IOREMAP_VIRT_END +-#define RDWR_COMPAT_MPT_VIRT_END (RDWR_COMPAT_MPT_VIRT_START + (1UL << 30)) ++#define RDWR_COMPAT_MPT_VIRT_END (RDWR_COMPAT_MPT_VIRT_START + GB(1)) + /* Slot 261: high read-only compat machine-to-phys conversion table (1GB). */ + #define HIRO_COMPAT_MPT_VIRT_START RDWR_COMPAT_MPT_VIRT_END +-#define HIRO_COMPAT_MPT_VIRT_END (HIRO_COMPAT_MPT_VIRT_START + (1UL << 30)) ++#define HIRO_COMPAT_MPT_VIRT_END (HIRO_COMPAT_MPT_VIRT_START + GB(1)) + /* Slot 261: xen text, static data and bss (1GB). */ + #define XEN_VIRT_START (HIRO_COMPAT_MPT_VIRT_END) +-#define XEN_VIRT_END (XEN_VIRT_START + (1UL << 30)) +-/* Slot 262-263: A direct 1:1 mapping of all of physical memory. */ ++#define XEN_VIRT_END (XEN_VIRT_START + GB(1)) ++/* Slot 261: page-frame information array (256GB). */ ++#define FRAMETABLE_VIRT_END DIRECTMAP_VIRT_START ++#define FRAMETABLE_VIRT_START (FRAMETABLE_VIRT_END - GB(256)) ++/* Slot 262-271: A direct 1:1 mapping of all of physical memory. */ + #define DIRECTMAP_VIRT_START (PML4_ADDR(262)) +-#define DIRECTMAP_VIRT_END (DIRECTMAP_VIRT_START + PML4_ENTRY_BYTES*2) ++#define DIRECTMAP_VIRT_END (DIRECTMAP_VIRT_START + PML4_ENTRY_BYTES*10) + + #ifndef __ASSEMBLY__ + +Index: xen-3.4.0-testing/xen/include/asm-x86/x86_64/page.h +=================================================================== +--- xen-3.4.0-testing.orig/xen/include/asm-x86/x86_64/page.h ++++ xen-3.4.0-testing/xen/include/asm-x86/x86_64/page.h +@@ -16,8 +16,8 @@ + #define L4_PAGETABLE_ENTRIES (1< -# Date 1231414359 0 -# Node ID 292919f6123823916f1274f3d512794f72f3e903 -# Parent 97f8d6453fdae1a865a3c875d7b712a494304fb0 -x86-64: guest directed placement of initial p->m map - -By adding another ELF note, the kernel can now direct the hypervisor -(for Dom0) and in the future also the tools (for DomU-s) to place the -initial phys->mach translation table at other than an address -immediately above the kernel/initrd images. This eliminates the size -restriction imposed on this table by Linux (the kernel loads above the --2Gb boundary, and hence the entire initial mapping cannot reach or -even exceed 2Gb). - -There are a few items in this patch I'm not particularly happy with, -but couldn't think of a better solution: -- there is a hidden assumption that pages allocated for the domain are - put on the domain's page list sequentially -- the way backward compatibility is maintained is placing requirements - on the kernel side that make the code somewhat convoluted (because - it - needs to check where the map is actually placed in quite a few - places) -- code is there to use 1Gb mappings for the hypervisor created table, - but lacking a machine with 512G+ memory for immediate testing I - can't - verify this works; I know that 2Mb mappings work, and hence imply - that 1Gb ones would too (of course, if the kernel replaces the table - - like Linux does -, it cannot use 2Mb/1Gb mappings or even try to - re-use the page table entries, but I don't consider this a problem) - -Signed-off-by: Jan Beulich - ---- a/tools/include/xen-foreign/reference.size -+++ b/tools/include/xen-foreign/reference.size +--- 2009-01-08.orig/tools/include/xen-foreign/reference.size 2009-01-08 11:44:11.000000000 +0100 ++++ 2009-01-08/tools/include/xen-foreign/reference.size 2009-01-08 10:56:30.000000000 +0100 @@ -1,7 +1,7 @@ structs | x86_32 x86_64 ia64 @@ -43,8 +9,8 @@ Signed-off-by: Jan Beulich trap_info | 8 16 - pt_fpreg | - - 16 cpu_user_regs | 68 200 - ---- a/xen/arch/x86/domain_build.c -+++ b/xen/arch/x86/domain_build.c +--- 2009-01-08.orig/xen/arch/x86/domain_build.c 2009-01-08 10:56:13.000000000 +0100 ++++ 2009-01-08/xen/arch/x86/domain_build.c 2009-01-08 11:44:42.000000000 +0100 @@ -341,6 +341,12 @@ int __init construct_dom0( #endif } @@ -79,7 +45,7 @@ Signed-off-by: Jan Beulich page = alloc_domheap_pages(d, order, 0); #endif if ( page == NULL ) -@@ -749,8 +762,109 @@ int __init construct_dom0( +@@ -740,8 +753,109 @@ int __init construct_dom0( snprintf(si->magic, sizeof(si->magic), "xen-3.0-x86_%d%s", elf_64bit(&elf) ? 64 : 32, parms.pae ? "p" : ""); @@ -129,7 +95,7 @@ Signed-off-by: Jan Beulich + va += 1UL << L3_PAGETABLE_SHIFT; + continue; + } -+ if ( (page = alloc_domheap_pages(d, 0, 0)) == NULL ) ++ else if ( (page = alloc_domheap_pages(d, 0, 0)) == NULL ) + break; + else + { @@ -157,7 +123,7 @@ Signed-off-by: Jan Beulich + va += 1UL << L2_PAGETABLE_SHIFT; + continue; + } -+ if ( (page = alloc_domheap_pages(d, 0, 0)) == NULL ) ++ else if ( (page = alloc_domheap_pages(d, 0, 0)) == NULL ) + break; + else + { @@ -190,7 +156,7 @@ Signed-off-by: Jan Beulich { mfn = pfn + alloc_spfn; #ifndef NDEBUG -@@ -764,6 +878,26 @@ int __init construct_dom0( +@@ -755,6 +869,26 @@ int __init construct_dom0( ((unsigned int *)vphysmap_start)[pfn] = mfn; set_gpfn_from_mfn(mfn, pfn); } @@ -217,58 +183,19 @@ Signed-off-by: Jan Beulich while ( pfn < nr_pages ) { if ( (page = alloc_chunk(d, nr_pages - d->tot_pages)) == NULL ) ---- a/xen/arch/x86/mm.c -+++ b/xen/arch/x86/mm.c -@@ -948,19 +948,44 @@ void put_page_from_l1e(l1_pgentry_t l1e, - } - - -+static void put_data_page( -+ struct page_info *page, int writeable) -+{ -+ if ( writeable ) -+ put_page_and_type(page); -+ else -+ { -+ BUG_ON((page->u.inuse.type_info & PGT_type_mask) == PGT_seg_desc_page -+ && (page->u.inuse.type_info & PGT_count_mask) != 0); -+ put_page(page); -+ } -+} -+ - /* - * NB. Virtual address 'l2e' maps to a machine address within frame 'pfn'. - * Note also that this automatically deals correctly with linear p.t.'s. - */ - static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn) - { -- if ( (l2e_get_flags(l2e) & _PAGE_PRESENT) && -- (l2e_get_pfn(l2e) != pfn) ) -+ if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || (l2e_get_pfn(l2e) == pfn) ) -+ return 1; -+ -+ if ( unlikely(l2e_get_flags(l2e) & _PAGE_PSE) ) -+ { -+ unsigned long mfn = l2e_get_pfn(l2e); -+ int writeable = l2e_get_flags(l2e) & _PAGE_RW; -+ -+ ASSERT(!(mfn & ((1UL << (L2_PAGETABLE_SHIFT - PAGE_SHIFT)) - 1))); -+ do { -+ put_data_page(mfn_to_page(mfn), writeable); -+ } while ( ++mfn & ((1UL << (L2_PAGETABLE_SHIFT - PAGE_SHIFT)) - 1) ); -+ } -+ else +--- 2009-01-08.orig/xen/arch/x86/mm.c 2009-01-08 11:44:11.000000000 +0100 ++++ 2009-01-08/xen/arch/x86/mm.c 2009-01-08 10:56:30.000000000 +0100 +@@ -1013,7 +1013,8 @@ static int put_page_from_l2e(l2_pgentry_ { - put_page_and_type(l2e_get_page(l2e)); -- return 0; - } -- return 1; + unsigned long mfn = l2e_get_pfn(l2e), m = mfn; + int writeable = l2e_get_flags(l2e) & _PAGE_RW; +- ASSERT(opt_allow_hugepage && !(mfn & (L1_PAGETABLE_ENTRIES-1))); + -+ return 0; - } - - static int __put_page_type(struct page_info *, int preemptible); -@@ -968,14 +993,28 @@ static int __put_page_type(struct page_i ++ ASSERT(!(mfn & (L1_PAGETABLE_ENTRIES-1))); + do { + put_data_page(mfn_to_page(m), writeable); + } while ( m++ < (mfn + (L1_PAGETABLE_ENTRIES-1)) ); +@@ -1031,14 +1032,28 @@ static int __put_page_type(struct page_i static int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, int partial, int preemptible) { @@ -303,8 +230,8 @@ Signed-off-by: Jan Beulich } #if CONFIG_PAGING_LEVELS >= 4 ---- a/xen/common/libelf/libelf-dominfo.c -+++ b/xen/common/libelf/libelf-dominfo.c +--- 2009-01-08.orig/xen/common/libelf/libelf-dominfo.c 2009-01-08 11:44:11.000000000 +0100 ++++ 2009-01-08/xen/common/libelf/libelf-dominfo.c 2009-01-08 10:56:30.000000000 +0100 @@ -90,6 +90,7 @@ int elf_xen_parse_note(struct elf_binary [XEN_ELFNOTE_ENTRY] = { "ENTRY", 0}, [XEN_ELFNOTE_HYPERCALL_PAGE] = { "HYPERCALL_PAGE", 0}, @@ -355,8 +282,8 @@ Signed-off-by: Jan Beulich parms->elf_paddr_offset = UNSET_ADDR; /* Find and parse elf notes. */ ---- a/xen/include/public/elfnote.h -+++ b/xen/include/public/elfnote.h +--- 2009-01-08.orig/xen/include/public/elfnote.h 2009-01-08 11:44:11.000000000 +0100 ++++ 2009-01-08/xen/include/public/elfnote.h 2009-01-08 10:56:30.000000000 +0100 @@ -162,9 +162,20 @@ #define XEN_ELFNOTE_SUSPEND_CANCEL 14 @@ -379,8 +306,8 @@ Signed-off-by: Jan Beulich /* * System information exported through crash notes. ---- a/xen/include/public/libelf.h -+++ b/xen/include/public/libelf.h +--- 2009-01-08.orig/xen/include/public/libelf.h 2009-01-08 11:44:11.000000000 +0100 ++++ 2009-01-08/xen/include/public/libelf.h 2009-01-08 10:56:30.000000000 +0100 @@ -232,6 +232,7 @@ struct elf_dom_parms { uint64_t virt_entry; uint64_t virt_hypercall; @@ -389,8 +316,8 @@ Signed-off-by: Jan Beulich uint64_t elf_paddr_offset; uint32_t f_supported[XENFEAT_NR_SUBMAPS]; uint32_t f_required[XENFEAT_NR_SUBMAPS]; ---- a/xen/include/public/xen.h -+++ b/xen/include/public/xen.h +--- 2009-01-08.orig/xen/include/public/xen.h 2009-01-08 11:44:11.000000000 +0100 ++++ 2009-01-08/xen/include/public/xen.h 2009-01-08 10:56:30.000000000 +0100 @@ -513,6 +513,7 @@ typedef struct shared_info shared_info_t * a. relocated kernel image * b. initial ram disk [mod_start, mod_len] diff --git a/x86_64-page-info-pack.patch b/x86_64-page-info-pack.patch deleted file mode 100644 index e33ed42..0000000 --- a/x86_64-page-info-pack.patch +++ /dev/null @@ -1,123 +0,0 @@ -References: bnc#470949 - ---- a/xen/arch/x86/mm/shadow/common.c -+++ b/xen/arch/x86/mm/shadow/common.c -@@ -1902,7 +1902,7 @@ static void sh_hash_audit_bucket(struct - { - if ( !page_is_out_of_sync(gpg) ) - { -- SHADOW_ERROR("MFN %#lx shadowed (by %#"PRI_mfn")" -+ SHADOW_ERROR("MFN %#x shadowed (by %#"PRI_mfn")" - " and not OOS but has typecount %#lx\n", - sp->backpointer, - mfn_x(shadow_page_to_mfn(sp)), -@@ -1916,7 +1916,7 @@ static void sh_hash_audit_bucket(struct - if ( (gpg->u.inuse.type_info & PGT_type_mask) == PGT_writable_page - && (gpg->u.inuse.type_info & PGT_count_mask) != 0 ) - { -- SHADOW_ERROR("MFN %#lx shadowed (by %#"PRI_mfn")" -+ SHADOW_ERROR("MFN %#x shadowed (by %#"PRI_mfn")" - " but has typecount %#lx\n", - sp->backpointer, mfn_x(shadow_page_to_mfn(sp)), - gpg->u.inuse.type_info); ---- a/xen/arch/x86/mm/shadow/private.h -+++ b/xen/arch/x86/mm/shadow/private.h -@@ -190,7 +190,7 @@ struct shadow_page_info - struct { - union { - /* When in use, guest page we're a shadow of */ -- unsigned long backpointer; -+ unsigned int backpointer; - /* When free, order of the freelist we're on */ - unsigned int order; - }; -@@ -204,12 +204,17 @@ struct shadow_page_info - /* When free, TLB flush time when freed */ - u32 tlbflush_timestamp; - }; -+#ifdef __i386__ -+ unsigned long mbz; /* Must be zero: count_info is here. */ -+#endif - struct { -- unsigned long mbz; /* Must be zero: count_info is here. */ - unsigned long type:5; /* What kind of shadow is this? */ - unsigned long pinned:1; /* Is the shadow pinned? */ - unsigned long count:26; /* Reference count */ - }; -+#ifndef __i386__ -+ unsigned long mbz; /* Must be zero: count_info is here. */ -+#endif - union { - /* For unused shadow pages, a list of pages of this order; for - * pinnable shadows, if pinned, a list of other pinned shadows -@@ -645,7 +650,7 @@ static inline int sh_get_ref(struct vcpu - - if ( unlikely(nx >= 1U<<26) ) - { -- SHADOW_PRINTK("shadow ref overflow, gmfn=%" PRtype_info " smfn=%lx\n", -+ SHADOW_PRINTK("shadow ref overflow, gmfn=%x smfn=%lx\n", - sp->backpointer, mfn_x(smfn)); - return 0; - } ---- a/xen/include/asm-x86/mm.h -+++ b/xen/include/asm-x86/mm.h -@@ -15,7 +15,7 @@ - * 1. 'struct page_info' contains a 'struct list_head list'. - * 2. Provide a PFN_ORDER() macro for accessing the order of a free page. - */ --#define PFN_ORDER(_pfn) ((_pfn)->u.free.order) -+#define PFN_ORDER(_pfn) ((_pfn)->v.free.order) - - struct page_info - { -@@ -30,16 +30,12 @@ struct page_info - - /* Page is in use: ((count_info & PGC_count_mask) != 0). */ - struct { -- /* Owner of this page (NULL if page is anonymous). */ -- u32 _domain; /* pickled format */ - /* Type reference count and various PGT_xxx flags and fields. */ - unsigned long type_info; - } inuse; - - /* Page is on a free list: ((count_info & PGC_count_mask) == 0). */ - struct { -- /* Order-size of the free chunk this page is the head of. */ -- u32 order; - /* Mask of possibly-tainted TLBs. */ - cpumask_t cpumask; - } free; -@@ -47,6 +43,22 @@ struct page_info - } u; - - union { -+ -+ /* Page is in use. */ -+ struct { -+ /* Owner of this page (NULL if page is anonymous). */ -+ u32 _domain; /* pickled format */ -+ } inuse; -+ -+ /* Page is on a free list. */ -+ struct { -+ /* Order-size of the free chunk this page is the head of. */ -+ u32 order; -+ } free; -+ -+ } v; -+ -+ union { - /* - * Timestamp from 'TLB clock', used to avoid extra safety flushes. - * Only valid for: a) free pages, and b) pages with zero type count -@@ -173,8 +185,8 @@ static inline u32 pickle_domptr(struct d - /* OOS fixup entries */ - #define SHADOW_OOS_FIXUPS 2 - --#define page_get_owner(_p) (unpickle_domptr((_p)->u.inuse._domain)) --#define page_set_owner(_p,_d) ((_p)->u.inuse._domain = pickle_domptr(_d)) -+#define page_get_owner(_p) (unpickle_domptr((_p)->v.inuse._domain)) -+#define page_set_owner(_p,_d) ((_p)->v.inuse._domain = pickle_domptr(_d)) - - #define maddr_get_owner(ma) (page_get_owner(maddr_to_page((ma)))) - #define vaddr_get_owner(va) (page_get_owner(virt_to_page((va)))) diff --git a/x86_64-sh-next-shadow.patch b/x86_64-sh-next-shadow.patch deleted file mode 100644 index f29e864..0000000 --- a/x86_64-sh-next-shadow.patch +++ /dev/null @@ -1,132 +0,0 @@ -References: bnc#470949 - ---- a/xen/arch/x86/mm/shadow/common.c -+++ b/xen/arch/x86/mm/shadow/common.c -@@ -1456,6 +1456,22 @@ static __init int shadow_blow_tables_key - __initcall(shadow_blow_tables_keyhandler_init); - #endif /* !NDEBUG */ - -+#ifdef __i386__ -+# define next_shadow(pg) ((pg)->next_shadow) -+# define set_next_shadow(pg, n) ((void)((pg)->next_shadow = (n))) -+#else -+static inline struct shadow_page_info * -+next_shadow(const struct shadow_page_info *sp) -+{ -+ return sp->next_shadow ? mfn_to_shadow_page(_mfn(sp->next_shadow)) : NULL; -+} -+static inline void -+set_next_shadow(struct shadow_page_info *sp, struct shadow_page_info *next) -+{ -+ sp->next_shadow = next ? mfn_x(shadow_page_to_mfn(next)) : 0; -+} -+#endif -+ - /* Allocate another shadow's worth of (contiguous, aligned) pages, - * and fill in the type and backpointer fields of their page_infos. - * Never fails to allocate. */ -@@ -1525,7 +1541,7 @@ mfn_t shadow_alloc(struct domain *d, - sp[i].pinned = 0; - sp[i].count = 0; - sp[i].backpointer = backpointer; -- sp[i].next_shadow = NULL; -+ set_next_shadow(&sp[i], NULL); - perfc_incr(shadow_alloc_count); - } - return shadow_page_to_mfn(sp); -@@ -1865,7 +1881,7 @@ static void sh_hash_audit_bucket(struct - /* Wrong bucket? */ - BUG_ON( sh_hash(sp->backpointer, sp->type) != bucket ); - /* Duplicate entry? */ -- for ( x = sp->next_shadow; x; x = x->next_shadow ) -+ for ( x = next_shadow(sp); x; x = next_shadow(x) ) - BUG_ON( x->backpointer == sp->backpointer && x->type == sp->type ); - /* Follow the backpointer to the guest pagetable */ - if ( sp->type != SH_type_fl1_32_shadow -@@ -1908,7 +1924,7 @@ static void sh_hash_audit_bucket(struct - } - } - /* That entry was OK; on we go */ -- sp = sp->next_shadow; -+ sp = next_shadow(sp); - } - } - -@@ -2002,7 +2018,7 @@ mfn_t shadow_hash_lookup(struct vcpu *v, - /* Delete sp from the list */ - prev->next_shadow = sp->next_shadow; - /* Re-insert it at the head of the list */ -- sp->next_shadow = d->arch.paging.shadow.hash_table[key]; -+ set_next_shadow(sp, d->arch.paging.shadow.hash_table[key]); - d->arch.paging.shadow.hash_table[key] = sp; - } - } -@@ -2013,7 +2029,7 @@ mfn_t shadow_hash_lookup(struct vcpu *v, - return shadow_page_to_mfn(sp); - } - prev = sp; -- sp = sp->next_shadow; -+ sp = next_shadow(sp); - } - - perfc_incr(shadow_hash_lookup_miss); -@@ -2040,7 +2056,7 @@ void shadow_hash_insert(struct vcpu *v, - - /* Insert this shadow at the top of the bucket */ - sp = mfn_to_shadow_page(smfn); -- sp->next_shadow = d->arch.paging.shadow.hash_table[key]; -+ set_next_shadow(sp, d->arch.paging.shadow.hash_table[key]); - d->arch.paging.shadow.hash_table[key] = sp; - - sh_hash_audit_bucket(d, key); -@@ -2067,7 +2083,7 @@ void shadow_hash_delete(struct vcpu *v, - sp = mfn_to_shadow_page(smfn); - if ( d->arch.paging.shadow.hash_table[key] == sp ) - /* Easy case: we're deleting the head item. */ -- d->arch.paging.shadow.hash_table[key] = sp->next_shadow; -+ d->arch.paging.shadow.hash_table[key] = next_shadow(sp); - else - { - /* Need to search for the one we want */ -@@ -2076,15 +2092,15 @@ void shadow_hash_delete(struct vcpu *v, - { - ASSERT(x); /* We can't have hit the end, since our target is - * still in the chain somehwere... */ -- if ( x->next_shadow == sp ) -+ if ( next_shadow(x) == sp ) - { - x->next_shadow = sp->next_shadow; - break; - } -- x = x->next_shadow; -+ x = next_shadow(x); - } - } -- sp->next_shadow = NULL; -+ set_next_shadow(sp, NULL); - - sh_hash_audit_bucket(d, key); - } -@@ -2118,7 +2134,7 @@ static void hash_foreach(struct vcpu *v, - /* WARNING: This is not safe against changes to the hash table. - * The callback *must* return non-zero if it has inserted or - * deleted anything from the hash (lookups are OK, though). */ -- for ( x = d->arch.paging.shadow.hash_table[i]; x; x = x->next_shadow ) -+ for ( x = d->arch.paging.shadow.hash_table[i]; x; x = next_shadow(x) ) - { - if ( callback_mask & (1 << x->type) ) - { ---- a/xen/arch/x86/mm/shadow/private.h -+++ b/xen/arch/x86/mm/shadow/private.h -@@ -196,7 +196,11 @@ struct shadow_page_info - }; - union { - /* When in use, next shadow in this hash chain */ -+#ifdef __i386__ - struct shadow_page_info *next_shadow; -+#else -+ unsigned int next_shadow; -+#endif - /* When free, TLB flush time when freed */ - u32 tlbflush_timestamp; - }; diff --git a/xen-3.3.1-testing-src.tar.bz2 b/xen-3.3.1-testing-src.tar.bz2 deleted file mode 100644 index e809b76..0000000 --- a/xen-3.3.1-testing-src.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1f543d1d4edba442dad168fc9e042120f41a34583bc4689cab18e57537f92807 -size 22695135 diff --git a/xen-3.4.0-testing-src.tar.bz2 b/xen-3.4.0-testing-src.tar.bz2 new file mode 100644 index 0000000..0f9a336 --- /dev/null +++ b/xen-3.4.0-testing-src.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9922e7477ca5425e756c86bb120a998c1f5528e3537295e2fc953b31191df5e0 +size 22574212 diff --git a/xen-api-auth.patch b/xen-api-auth.patch index b308a01..c520942 100644 --- a/xen-api-auth.patch +++ b/xen-api-auth.patch @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/python/xen/xend/XendAuthSessions.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendAuthSessions.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendAuthSessions.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendAuthSessions.py +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendAuthSessions.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendAuthSessions.py @@ -84,7 +84,7 @@ class XendAuthSessions: # if PAM doesn't exist, let's ignore it return False diff --git a/xen-changeset.diff b/xen-changeset.diff index 6bcb688..b5665fb 100644 --- a/xen-changeset.diff +++ b/xen-changeset.diff @@ -1,13 +1,13 @@ -Index: xen-3.3.1-testing/xen/Makefile +Index: xen-3.4.0-testing/xen/Makefile =================================================================== ---- xen-3.3.1-testing.orig/xen/Makefile -+++ xen-3.3.1-testing/xen/Makefile +--- xen-3.4.0-testing.orig/xen/Makefile ++++ xen-3.4.0-testing/xen/Makefile @@ -1,3 +1,4 @@ +export XEN_CHANGESET = unavailable # This is the correct place to edit the build version. # All other places this is stored (eg. compile.h) should be autogenerated. export XEN_VERSION = 3 -@@ -81,7 +82,7 @@ delete-unfresh-files: +@@ -82,7 +83,7 @@ delete-unfresh-files: @rm -f $@1 $@2 # compile.h contains dynamic build info. Rebuilt on every 'make' invocation. @@ -16,7 +16,7 @@ Index: xen-3.3.1-testing/xen/Makefile @sed -e 's/@@date@@/$(shell LC_ALL=C date)/g' \ -e 's/@@time@@/$(shell LC_ALL=C date +%T)/g' \ -e 's/@@whoami@@/$(XEN_WHOAMI)/g' \ -@@ -91,10 +92,9 @@ include/xen/compile.h: include/xen/compi +@@ -92,10 +93,9 @@ include/xen/compile.h: include/xen/compi -e 's/@@version@@/$(XEN_VERSION)/g' \ -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \ -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \ diff --git a/xen-config.diff b/xen-config.diff index 6e6abdb..9392a04 100644 --- a/xen-config.diff +++ b/xen-config.diff @@ -1,24 +1,13 @@ -Index: xen-3.3.1-testing/Config.mk +Index: xen-3.4.0-testing/Config.mk =================================================================== ---- xen-3.3.1-testing.orig/Config.mk -+++ xen-3.3.1-testing/Config.mk -@@ -85,20 +85,20 @@ QEMU_REMOTE=http://xenbits.xensource.com - +--- xen-3.4.0-testing.orig/Config.mk ++++ xen-3.4.0-testing/Config.mk +@@ -117,14 +117,14 @@ QEMU_REMOTE=http://xenbits.xensource.com # Specify which qemu-dm to use. This may be `ioemu' to use the old # Mercurial in-tree version, or a local directory, or a git URL. --# CONFIG_QEMU ?= ioemu + # CONFIG_QEMU ?= ../qemu-xen.git +-CONFIG_QEMU ?= $(QEMU_REMOTE) +CONFIG_QEMU ?= ioemu-remote - # CONFIG_QEMU ?= ../qemu-xen.git --ifeq ($(XEN_TARGET_ARCH),ia64) --CONFIG_QEMU ?= ioemu --else --CONFIG_QEMU ?= $(QEMU_REMOTE) --endif -+# ifeq ($(XEN_TARGET_ARCH),ia64) -+# CONFIG_QEMU ?= ioemu -+# else -+# CONFIG_QEMU ?= $(QEMU_REMOTE) -+# endif # Optional components XENSTAT_XENTOP ?= y diff --git a/xen-destdir.diff b/xen-destdir.diff index 07ae70b..006d4bb 100644 --- a/xen-destdir.diff +++ b/xen-destdir.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/docs/Makefile +Index: xen-3.4.0-testing/docs/Makefile =================================================================== ---- xen-3.3.1-testing.orig/docs/Makefile -+++ xen-3.3.1-testing/docs/Makefile +--- xen-3.4.0-testing.orig/docs/Makefile ++++ xen-3.4.0-testing/docs/Makefile @@ -90,7 +90,8 @@ install: all $(INSTALL_DIR) $(DESTDIR)$(MANDIR) cp -dR man1 $(DESTDIR)$(MANDIR) @@ -22,13 +22,110 @@ Index: xen-3.3.1-testing/docs/Makefile + ln -sf $*.html html.done/$*/index.html + rm -rf html/ + -Index: xen-3.3.1-testing/tools/examples/Makefile +Index: xen-3.4.0-testing/tools/security/Makefile =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/Makefile -+++ xen-3.3.1-testing/tools/examples/Makefile -@@ -47,18 +47,6 @@ XEN_HOTPLUG_SCRIPTS = xen-backend.agent +--- xen-3.4.0-testing.orig/tools/security/Makefile ++++ xen-3.4.0-testing/tools/security/Makefile +@@ -61,7 +61,7 @@ install: all $(ACM_CONFIG_FILE) + $(INSTALL_DIR) $(DESTDIR)$(ACM_SECGEN_CGIDIR) + $(INSTALL_PROG) $(ACM_INST_CGI) $(DESTDIR)$(ACM_SECGEN_CGIDIR) + python python/setup.py install \ +- --prefix="$(PREFIX)" --root="$(DESTDIR)" --force ++ --prefix="/usr" --root="$(DESTDIR)" --force + else + .PHONY: all + all: +Index: xen-3.4.0-testing/tools/pygrub/Makefile +=================================================================== +--- xen-3.4.0-testing.orig/tools/pygrub/Makefile ++++ xen-3.4.0-testing/tools/pygrub/Makefile +@@ -11,7 +11,7 @@ build: + .PHONY: install + install: all + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install \ +- --prefix="$(PREFIX)" --root="$(DESTDIR)" --force ++ --prefix="/usr" --root="$(DESTDIR)" --force + $(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot + + .PHONY: clean +Index: xen-3.4.0-testing/tools/python/Makefile +=================================================================== +--- xen-3.4.0-testing.orig/tools/python/Makefile ++++ xen-3.4.0-testing/tools/python/Makefile +@@ -56,7 +56,7 @@ refresh-po: $(POTFILE) + .PHONY: install + install: install-messages install-dtd + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install \ +- --prefix="$(PREFIX)" --root="$(DESTDIR)" --force ++ --prefix="/usr" --root="$(DESTDIR)" --force + + install-dtd: all + $(INSTALL_DIR) $(DESTDIR)$(DOCDIR) +Index: xen-3.4.0-testing/tools/xenstore/Makefile +=================================================================== +--- xen-3.4.0-testing.orig/tools/xenstore/Makefile ++++ xen-3.4.0-testing/tools/xenstore/Makefile +@@ -10,6 +10,7 @@ CFLAGS += $(CFLAGS_libxenctrl) + + CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm xenstore-chmod + CLIENTS += xenstore-write xenstore-ls ++CLIENTS_DOMU := $(patsubst xenstore-%,domu-xenstore-%,$(CLIENTS)) + + XENSTORED_OBJS = xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o + +@@ -30,7 +31,7 @@ endif + all: libxenstore.so libxenstore.a xenstored clients xs_tdb_dump + + .PHONY: clients +-clients: xenstore $(CLIENTS) xenstore-control ++clients: xenstore $(CLIENTS) $(CLIENTS_DOMU) xenstore-control + + ifeq ($(CONFIG_SunOS),y) + xenstored_probes.h: xenstored_probes.d +@@ -50,6 +51,9 @@ xenstored: $(XENSTORED_OBJS) + $(CLIENTS): xenstore + ln -f xenstore $@ + ++$(CLIENTS_DOMU): xenstore ++ ln -f xenstore $@ ++ + xenstore: xenstore_client.o $(LIBXENSTORE) + $(CC) $(CFLAGS) $(LDFLAGS) $< -L. -lxenstore $(SOCKET_LIBS) -o $@ + +@@ -77,7 +81,7 @@ clean: + rm -f *.a *.o *.opic *.so* xenstored_probes.h + rm -f xenstored xs_random xs_stress xs_crashme + rm -f xs_tdb_dump xenstore-control +- rm -f xenstore $(CLIENTS) ++ rm -f $(CLIENTS) $(CLIENTS_DOMU) + $(RM) $(DEPS) + + .PHONY: TAGS +@@ -92,6 +96,7 @@ tarball: clean + install: all + $(INSTALL_DIR) $(DESTDIR)/var/run/xenstored + $(INSTALL_DIR) $(DESTDIR)/var/lib/xenstored ++ $(INSTALL_DIR) $(DESTDIR)/bin + $(INSTALL_DIR) $(DESTDIR)$(BINDIR) + $(INSTALL_DIR) $(DESTDIR)$(SBINDIR) + $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR) +@@ -101,6 +106,9 @@ install: all + set -e ; for c in $(CLIENTS) ; do \ + ln -f $(DESTDIR)$(BINDIR)/xenstore $(DESTDIR)$(BINDIR)/$${c} ; \ + done ++ for client in $(CLIENTS_DOMU); do \ ++ $(INSTALL_PROG) $$client $(DESTDIR)/bin/$${client/domu-}; \ ++ done + $(INSTALL_DIR) $(DESTDIR)$(LIBDIR) + $(INSTALL_PROG) libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR) + ln -sf libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libxenstore.so.$(MAJOR) +Index: xen-3.4.0-testing/tools/hotplug/Linux/Makefile +=================================================================== +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/Makefile ++++ xen-3.4.0-testing/tools/hotplug/Linux/Makefile +@@ -31,18 +31,6 @@ XEN_HOTPLUG_SCRIPTS = xen-backend.agent UDEV_RULES_DIR = /etc/udev - UDEV_RULES = xen-backend.rules + UDEV_RULES = xen-backend.rules xend.rules -DI = $(if $(DISTDIR),$(shell readlink -f $(DISTDIR)),) -DE = $(if $(DESTDIR),$(shell readlink -f $(DESTDIR)),) @@ -45,16 +142,13 @@ Index: xen-3.3.1-testing/tools/examples/Makefile .PHONY: all all: -@@ -66,7 +54,7 @@ all: +@@ -50,15 +38,15 @@ all: build: .PHONY: install --install: all install-readmes install-initd install-configs install-scripts $(HOTPLUGS) -+install: all install-readmes install-initd install-configs install-scripts install-udev +-install: all install-initd install-scripts $(HOTPLUGS) ++install: all install-initd install-scripts install-udev - .PHONY: install-readmes - install-readmes: -@@ -80,10 +68,10 @@ install-readmes: .PHONY: install-initd install-initd: [ -d $(DESTDIR)/etc/init.d ] || $(INSTALL_DIR) $(DESTDIR)/etc/init.d @@ -65,9 +159,9 @@ Index: xen-3.3.1-testing/tools/examples/Makefile - $(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)/etc/sysconfig/xendomains + $(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)/var/adm/fillup-templates/ - .PHONY: install-configs - install-configs: $(XEN_CONFIGS) -@@ -124,8 +112,7 @@ install-udev: + .PHONY: install-scripts + install-scripts: +@@ -88,8 +76,7 @@ install-udev: $(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)/rules.d set -e; for i in $(UDEV_RULES); \ do \ @@ -77,103 +171,3 @@ Index: xen-3.3.1-testing/tools/examples/Makefile done .PHONY: clean -Index: xen-3.3.1-testing/tools/security/Makefile -=================================================================== ---- xen-3.3.1-testing.orig/tools/security/Makefile -+++ xen-3.3.1-testing/tools/security/Makefile -@@ -64,9 +64,9 @@ install: all $(ACM_CONFIG_FILE) - $(INSTALL_DIR) $(DESTDIR)$(ACM_SECGEN_CGIDIR) - $(INSTALL_PROG) $(ACM_INST_CGI) $(DESTDIR)$(ACM_SECGEN_CGIDIR) - ifndef XEN_PYTHON_NATIVE_INSTALL -- python python/setup.py install --install-lib="$(DESTDIR)$(LIBPATH)/python" -+ python python/setup.py install --install-lib="$(DESTDIR)$(LIBPATH)/python" --prefix="" - else -- python python/setup.py install --root="$(DESTDIR)" -+ python python/setup.py install --root="$(DESTDIR)" --prefix="/usr" - endif - else - .PHONY: all -Index: xen-3.3.1-testing/tools/pygrub/Makefile -=================================================================== ---- xen-3.3.1-testing.orig/tools/pygrub/Makefile -+++ xen-3.3.1-testing/tools/pygrub/Makefile -@@ -16,7 +16,7 @@ install: all - $(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot - else - install: all -- CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" -+ CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --prefix="/usr" - $(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot - endif - -Index: xen-3.3.1-testing/tools/python/Makefile -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/Makefile -+++ xen-3.3.1-testing/tools/python/Makefile -@@ -80,7 +80,7 @@ install: install-messages install-dtd - CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" --force --install-lib="$(DESTDIR)$(LIBPATH)/python" - else - install: install-messages install-dtd -- CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --force -+ CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --prefix="/usr" --force - endif - - install-dtd: all -Index: xen-3.3.1-testing/tools/xenstore/Makefile -=================================================================== ---- xen-3.3.1-testing.orig/tools/xenstore/Makefile -+++ xen-3.3.1-testing/tools/xenstore/Makefile -@@ -14,6 +14,7 @@ DEP = .*.d - - CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm xenstore-chmod - CLIENTS += xenstore-write xenstore-ls -+CLIENTS_DOMU := $(patsubst xenstore-%,domu-xenstore-%,$(CLIENTS)) - - XENSTORED_OBJS = xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o - -@@ -34,7 +35,7 @@ endif - all: libxenstore.so libxenstore.a xenstored clients xs_tdb_dump - - .PHONY: clients --clients: xenstore $(CLIENTS) xenstore-control -+clients: xenstore $(CLIENTS) $(CLIENTS_DOMU) xenstore-control - - ifeq ($(CONFIG_SunOS),y) - xenstored_probes.h: xenstored_probes.d -@@ -54,6 +55,9 @@ xenstored: $(XENSTORED_OBJS) - $(CLIENTS): xenstore - ln -f xenstore $@ - -+$(CLIENTS_DOMU): xenstore -+ ln -f xenstore $@ -+ - xenstore: xenstore_client.o $(LIBXENSTORE) - $(CC) $(CFLAGS) $(LDFLAGS) $< -L. -lxenstore $(SOCKET_LIBS) -o $@ - -@@ -81,7 +85,7 @@ clean: - rm -f *.a *.o *.opic *.so* xenstored_probes.h - rm -f xenstored xs_random xs_stress xs_crashme - rm -f xs_tdb_dump xenstore-control -- rm -f xenstore $(CLIENTS) -+ rm -f $(CLIENTS) $(CLIENTS_DOMU) - $(RM) $(DEP) - - .PHONY: TAGS -@@ -96,6 +100,7 @@ tarball: clean - install: all - $(INSTALL_DIR) $(DESTDIR)/var/run/xenstored - $(INSTALL_DIR) $(DESTDIR)/var/lib/xenstored -+ $(INSTALL_DIR) $(DESTDIR)/bin - $(INSTALL_DIR) $(DESTDIR)$(BINDIR) - $(INSTALL_DIR) $(DESTDIR)$(SBINDIR) - $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR) -@@ -105,6 +110,9 @@ install: all - set -e ; for c in $(CLIENTS) ; do \ - ln -f $(DESTDIR)/usr/bin/xenstore $(DESTDIR)/usr/bin/$${c} ; \ - done -+ for client in $(CLIENTS_DOMU); do \ -+ $(INSTALL_PROG) $$client $(DESTDIR)/bin/$${client/domu-}; \ -+ done - $(INSTALL_DIR) $(DESTDIR)$(LIBDIR) - $(INSTALL_PROG) libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR) - ln -sf libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libxenstore.so.$(MAJOR) diff --git a/xen-disable-qemu-monitor.diff b/xen-disable-qemu-monitor.diff index f95f1c3..1cf8609 100644 --- a/xen-disable-qemu-monitor.diff +++ b/xen-disable-qemu-monitor.diff @@ -5,11 +5,11 @@ the "sendkey" command, among other useful things), remove all console commands that can read/write dom0's state. -Index: xen-3.3.1-testing/tools/ioemu-remote/monitor.c +Index: xen-3.4.0-testing/tools/ioemu-remote/monitor.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/monitor.c -+++ xen-3.3.1-testing/tools/ioemu-remote/monitor.c -@@ -1320,6 +1320,7 @@ static term_cmd_t term_cmds[] = { +--- xen-3.4.0-testing.orig/tools/ioemu-remote/monitor.c ++++ xen-3.4.0-testing/tools/ioemu-remote/monitor.c +@@ -1481,6 +1481,7 @@ static const term_cmd_t term_cmds[] = { "device|all", "commit changes to the disk images (if -snapshot is used) or backing files" }, { "info", "s?", do_info, "subcommand", "show various information about the system state" }, @@ -17,7 +17,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/monitor.c { "q|quit", "", do_quit, "", "quit the emulator" }, { "eject", "-fB", do_eject, -@@ -1332,6 +1333,7 @@ static term_cmd_t term_cmds[] = { +@@ -1493,6 +1494,7 @@ static const term_cmd_t term_cmds[] = { "filename", "output logs to 'filename'" }, { "log", "s", do_log, "item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" }, @@ -25,7 +25,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/monitor.c { "savevm", "s?", do_savevm, "tag|id", "save a VM snapshot. If no tag or id are provided, a new snapshot is created" }, { "loadvm", "s", do_loadvm, -@@ -1361,12 +1363,14 @@ static term_cmd_t term_cmds[] = { +@@ -1522,12 +1524,14 @@ static const term_cmd_t term_cmds[] = { "", "reset the system" }, { "system_powerdown", "", do_system_powerdown, "", "send system power down event" }, @@ -40,7 +40,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/monitor.c #ifdef CONFIG_PHP_DEBUG { "pci_add", "s", do_pci_add, "device", "insert PCI pass-through device by BDF,e.g. (dom, bus, dev, func) by hex '0x0, 0x3, 0x0, 0x0'" }, -@@ -1381,6 +1385,7 @@ static term_cmd_t term_cmds[] = { +@@ -1542,6 +1546,7 @@ static const term_cmd_t term_cmds[] = { "state", "change mouse button state (1=L, 2=M, 4=R)" }, { "mouse_set", "i", do_mouse_set, "index", "set which mouse device receives events" }, @@ -48,26 +48,26 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/monitor.c #ifdef HAS_AUDIO { "wavcapture", "si?i?i?", do_wav_capture, "path [frequency bits channels]", -@@ -1388,6 +1393,7 @@ static term_cmd_t term_cmds[] = { +@@ -1549,6 +1554,7 @@ static const term_cmd_t term_cmds[] = { #endif - { "stopcapture", "i", do_stop_capture, - "capture index", "stop capture" }, + { "stopcapture", "i", do_stop_capture, + "capture index", "stop capture" }, +#endif { "memsave", "lis", do_memory_save, "addr size file", "save to disk virtual memory dump starting at 'addr' of size 'size'", }, { "pmemsave", "lis", do_physical_memory_save, -@@ -1434,6 +1440,7 @@ static term_cmd_t info_cmds[] = { - "", "show kqemu information", }, +@@ -1628,6 +1634,7 @@ static const term_cmd_t info_cmds[] = { + "", "show KVM information", }, { "usb", "", usb_info, "", "show guest USB devices", }, +#ifdef CONFIG_TRUSTED_CLIENT { "usbhost", "", usb_host_info, "", "show host USB devices", }, { "profile", "", do_info_profile, -@@ -1458,6 +1465,7 @@ static term_cmd_t info_cmds[] = { - { "slirp", "", do_info_slirp, - "", "show SLIRP statistics", }, - #endif +@@ -1659,6 +1666,7 @@ static const term_cmd_t info_cmds[] = { + { "migrate", "", do_info_migrate, "", "show migration status" }, + { "balloon", "", do_info_balloon, + "", "show balloon information" }, +#endif { NULL, NULL, }, }; diff --git a/xen-domUloader.diff b/xen-domUloader.diff index e8e4392..8b301ca 100644 --- a/xen-domUloader.diff +++ b/xen-domUloader.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/python/xen/util/blkif.py +Index: xen-3.4.0-testing/tools/python/xen/util/blkif.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/util/blkif.py -+++ xen-3.3.1-testing/tools/python/xen/util/blkif.py +--- xen-3.4.0-testing.orig/tools/python/xen/util/blkif.py ++++ xen-3.4.0-testing/tools/python/xen/util/blkif.py @@ -71,23 +71,24 @@ def blkdev_segment(name): 'type' : 'Disk' } return val @@ -12,7 +12,7 @@ Index: xen-3.3.1-testing/tools/python/xen/util/blkif.py + fn = typ = taptype = None if uname.find(":") != -1: (typ, fn) = uname.split(":", 1) - if typ == "phy" and not fn.startswith("/"): + if typ in ("phy", "drbd") and not fn.startswith("/"): fn = "/dev/%s" %(fn,) if typ == "tap": (taptype, fn) = fn.split(":", 1) @@ -32,11 +32,11 @@ Index: xen-3.3.1-testing/tools/python/xen/util/blkif.py def mount_mode(name): mode = None -Index: xen-3.3.1-testing/tools/python/xen/xend/server/DevController.py +Index: xen-3.4.0-testing/tools/python/xen/xend/server/DevController.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/server/DevController.py -+++ xen-3.3.1-testing/tools/python/xen/xend/server/DevController.py -@@ -620,6 +620,31 @@ class DevController: +--- xen-3.4.0-testing.orig/tools/python/xen/xend/server/DevController.py ++++ xen-3.4.0-testing/tools/python/xen/xend/server/DevController.py +@@ -593,6 +593,31 @@ class DevController: return (Missing, None) @@ -68,22 +68,20 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/server/DevController.py def backendPath(self, backdom, devid): """Construct backend path given the backend domain and device id. -Index: xen-3.3.1-testing/tools/python/xen/xend/XendBootloader.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendBootloader.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendBootloader.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendBootloader.py -@@ -12,8 +12,9 @@ +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendBootloader.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendBootloader.py +@@ -12,7 +12,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import os, select, errno, stat, signal, tty +import os, select, errno, stat, signal, tty, time import random -+import re import shlex from xen.xend import sxp - -@@ -38,8 +39,25 @@ def bootloader(blexec, disk, dom, quiet +@@ -38,8 +38,25 @@ def bootloader(blexec, disk, dom, quiet msg = "Bootloader isn't executable" log.error(msg) raise VmError(msg) @@ -111,25 +109,10 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendBootloader.py log.error(msg) raise VmError(msg) -@@ -184,3 +202,14 @@ def bootloader_tidy(dom): - os.kill(pid, signal.SIGKILL) - - -+def bootfilter(bootloader, bootloader_args, vdisk): -+ """Is this virtual disk ok to boot from?""" -+ if vdisk.endswith(':disk'): -+ vdisk = vdisk[:-5] # temporary work-around for bug 237414 -+ if bootloader.endswith('domUloader.py'): -+ for arg in bootloader_args.split(): -+ if arg.startswith('--entry='): -+ m = re.match(r'^([hsx]v?d[a-z])[0-9]*:[^,]*(,[^,]*)?$', arg[8:]) -+ if m: -+ return vdisk == m.group(1) or vdisk == m.group(2) -+ return True -Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py @@ -35,7 +35,7 @@ from types import StringTypes import xen.lowlevel.xc @@ -139,16 +122,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py import xen.util.xsm.xsm as security from xen.util import xsconstants -@@ -43,7 +43,7 @@ from xen.xend import balloon, sxp, uuid, - from xen.xend import XendOptions, XendNode, XendConfig - - from xen.xend.XendConfig import scrub_password --from xen.xend.XendBootloader import bootloader, bootloader_tidy -+from xen.xend.XendBootloader import bootloader, bootloader_tidy, bootfilter - from xen.xend.XendError import XendError, VmError - from xen.xend.XendDevices import XendDevices - from xen.xend.XendTask import XendTask -@@ -1878,6 +1878,10 @@ class XendDomainInfo: +@@ -2134,6 +2134,10 @@ class XendDomainInfo: deviceClass, config = self.info['devices'].get(dev_uuid) self._waitForDevice(deviceClass, config['devid']) @@ -159,21 +133,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py def _waitForDevice_destroy(self, deviceClass, devid, backpath): return self.getDeviceController(deviceClass).waitForDevice_destroy( devid, backpath) -@@ -2569,8 +2573,11 @@ class XendDomainInfo: - blexec = osdep.pygrub_path - - blcfg = None -- disks = [x for x in self.info['vbd_refs'] -- if self.info['devices'][x][1]['bootable']] -+ disks = [] -+ for x in self.info['vbd_refs']: -+ vdisk = self.info['devices'][x][1]['dev'] -+ if bootfilter(blexec, bootloader_args, vdisk): -+ disks.append(x) - - if not disks: - msg = "Had a bootloader specified, but no disks are bootable" -@@ -2581,13 +2588,10 @@ class XendDomainInfo: +@@ -2892,9 +2896,19 @@ class XendDomainInfo: devtype = devinfo[0] disk = devinfo[1]['uname'] @@ -181,16 +141,22 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py - taptype = blkdev_uname_to_taptype(disk) - mounted = devtype == 'tap' and taptype != 'aio' and taptype != 'sync' and not os.stat(fn).st_rdev + (fn, types) = parse_uname(disk) -+ mounted = (types[0] not in ('file', 'phy')) ++ ++ def _shouldMount(types): ++ if types[0] in ('file', 'phy'): ++ return False ++ if types[0] == 'tap': ++ if types[1] in ('aio', 'sync'): ++ return False ++ else: ++ return True ++ return os.access('/etc/xen/scripts/block-%s' % types[0], os.X_OK) ++ ++ mounted = _shouldMount(types) if mounted: -- # This is a file, not a device. pygrub can cope with a -- # file if it's raw, but if it's QCOW or other such formats -- # used through blktap, then we need to mount it first. -+ # This is not a raw file or device, so we need to mount it first. - - log.info("Mounting %s on %s." % - (fn, BOOTLOADER_LOOPBACK_DEVICE)) -@@ -2599,7 +2603,9 @@ class XendDomainInfo: + # This is a file, not a device. pygrub can cope with a + # file if it's raw, but if it's QCOW or other such formats +@@ -2910,7 +2924,9 @@ class XendDomainInfo: from xen.xend import XendDomain dom0 = XendDomain.instance().privilegedDomain() @@ -201,12 +167,16 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py fn = BOOTLOADER_LOOPBACK_DEVICE try: -@@ -2610,7 +2616,7 @@ class XendDomainInfo: +@@ -2920,8 +2936,10 @@ class XendDomainInfo: + if mounted: log.info("Unmounting %s from %s." % (fn, BOOTLOADER_LOOPBACK_DEVICE)) - +- - dom0.destroyDevice('tap', BOOTLOADER_LOOPBACK_DEVICE) -+ dom0.destroyDevice('tap', BOOTLOADER_LOOPBACK_DEVICE, rm_cfg = True) ++ if devtype == 'tap': ++ dom0.destroyDevice('tap', BOOTLOADER_LOOPBACK_DEVICE) ++ else: ++ dom0.destroyDevice('vbd', BOOTLOADER_LOOPBACK_DEVICE) if blcfg is None: msg = "Had a bootloader specified, but can't find disk" diff --git a/xen-fixme-doc.diff b/xen-fixme-doc.diff index 510d3ec..103c54f 100644 --- a/xen-fixme-doc.diff +++ b/xen-fixme-doc.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/docs/man/xmdomain.cfg.pod.5 +Index: xen-3.4.0-testing/docs/man/xmdomain.cfg.pod.5 =================================================================== ---- xen-3.3.1-testing.orig/docs/man/xmdomain.cfg.pod.5 -+++ xen-3.3.1-testing/docs/man/xmdomain.cfg.pod.5 +--- xen-3.4.0-testing.orig/docs/man/xmdomain.cfg.pod.5 ++++ xen-3.4.0-testing/docs/man/xmdomain.cfg.pod.5 @@ -335,16 +335,10 @@ at hda1, which is the root filesystem. =item I @@ -19,10 +19,10 @@ Index: xen-3.3.1-testing/docs/man/xmdomain.cfg.pod.5 =back =head1 SEE ALSO -Index: xen-3.3.1-testing/docs/man/xm.pod.1 +Index: xen-3.4.0-testing/docs/man/xm.pod.1 =================================================================== ---- xen-3.3.1-testing.orig/docs/man/xm.pod.1 -+++ xen-3.3.1-testing/docs/man/xm.pod.1 +--- xen-3.4.0-testing.orig/docs/man/xm.pod.1 ++++ xen-3.4.0-testing/docs/man/xm.pod.1 @@ -297,7 +297,8 @@ scheduling by the Xen hypervisor. =item B diff --git a/xen-hvm-default-bridge.diff b/xen-hvm-default-bridge.diff index 19f86fa..a6f75cb 100644 --- a/xen-hvm-default-bridge.diff +++ b/xen-hvm-default-bridge.diff @@ -1,9 +1,9 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/vl.c +Index: xen-3.4.0-testing/tools/ioemu-remote/net.h =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/vl.c -+++ xen-3.3.1-testing/tools/ioemu-remote/vl.c -@@ -134,8 +134,8 @@ int inet_aton(const char *cp, struct in_ - #include "exec-all.h" +--- xen-3.4.0-testing.orig/tools/ioemu-remote/net.h ++++ xen-3.4.0-testing/tools/ioemu-remote/net.h +@@ -107,8 +107,8 @@ void net_host_device_add(const char *dev + void net_host_device_remove(int vlan_id, const char *device); #ifndef DEFAULT_NETWORK_SCRIPT -#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" @@ -13,26 +13,28 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/vl.c #endif #ifdef __sun__ #define SMBD_COMMAND "/usr/sfw/sbin/smbd" -@@ -4997,10 +4997,10 @@ static int net_client_init(const char *s - pstrcpy(down_script, sizeof(down_script), DEFAULT_NETWORK_DOWN_SCRIPT); +Index: xen-3.4.0-testing/tools/ioemu-remote/net.c +=================================================================== +--- xen-3.4.0-testing.orig/tools/ioemu-remote/net.c ++++ xen-3.4.0-testing/tools/ioemu-remote/net.c +@@ -1759,9 +1759,10 @@ int net_client_init(const char *device, } if (get_param_value(script_arg, sizeof(script_arg), "scriptarg", p) == 0 && -- get_param_value(script_arg, sizeof(script_arg), "bridge", p) == 0) { /* deprecated; for xend compatibility */ + get_param_value(script_arg, sizeof(script_arg), "bridge", p) == 0) { /* deprecated; for xend compatibility */ - pstrcpy(script_arg, sizeof(script_arg), ""); -- } -- ret = net_tap_init(vlan, ifname, setup_script, down_script, script_arg); -+ get_param_value(script_arg, sizeof(script_arg), "bridge", p) == 0) /* deprecated; for xend compatibility */ -+ ret = net_tap_init(vlan, ifname, setup_script, NULL, NULL); -+ else -+ ret = net_tap_init(vlan, ifname, setup_script, down_script, script_arg); ++ ret = net_tap_init(vlan, device, name, ifname, setup_script, NULL, NULL); ++ } else { ++ ret = net_tap_init(vlan, device, name, ifname, setup_script, down_script, script_arg); + } +- ret = net_tap_init(vlan, device, name, ifname, setup_script, down_script, script_arg); } } else #endif -Index: xen-3.3.1-testing/tools/python/xen/xend/image.py +Index: xen-3.4.0-testing/tools/python/xen/xend/image.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/image.py -+++ xen-3.3.1-testing/tools/python/xen/xend/image.py -@@ -764,14 +764,16 @@ class HVMImageHandler(ImageHandler): +--- xen-3.4.0-testing.orig/tools/python/xen/xend/image.py ++++ xen-3.4.0-testing/tools/python/xen/xend/image.py +@@ -832,14 +832,16 @@ class HVMImageHandler(ImageHandler): mac = devinfo.get('mac') if mac is None: raise VmError("MAC address not specified or generated.") @@ -52,10 +54,10 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/image.py if nics == 0: ret.append("-net") -Index: xen-3.3.1-testing/tools/ioemu-remote/i386-dm/qemu-ifup +Index: xen-3.4.0-testing/tools/ioemu-remote/i386-dm/qemu-ifup =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/i386-dm/qemu-ifup -+++ xen-3.3.1-testing/tools/ioemu-remote/i386-dm/qemu-ifup +--- xen-3.4.0-testing.orig/tools/ioemu-remote/i386-dm/qemu-ifup ++++ xen-3.4.0-testing/tools/ioemu-remote/i386-dm/qemu-ifup @@ -1,36 +1,22 @@ #!/bin/sh diff --git a/xen-hvm-default-pae.diff b/xen-hvm-default-pae.diff index 60e1b21..7083f25 100644 --- a/xen-hvm-default-pae.diff +++ b/xen-hvm-default-pae.diff @@ -1,15 +1,15 @@ PAE must be on for 64-on-64 to work at all. -Index: xen-3.3.1-testing/tools/python/xen/xend/image.py +Index: xen-3.4.0-testing/tools/python/xen/xend/image.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/image.py -+++ xen-3.3.1-testing/tools/python/xen/xend/image.py -@@ -871,7 +871,7 @@ class X86_HVM_ImageHandler(HVMImageHandl +--- xen-3.4.0-testing.orig/tools/python/xen/xend/image.py ++++ xen-3.4.0-testing/tools/python/xen/xend/image.py +@@ -943,7 +943,7 @@ class X86_HVM_ImageHandler(HVMImageHandl def configure(self, vmConfig): HVMImageHandler.configure(self, vmConfig) - self.pae = int(vmConfig['platform'].get('pae', 0)) + self.pae = int(vmConfig['platform'].get('pae', 1)) + self.vramsize = int(vmConfig['platform'].get('videoram',4)) * 1024 def buildDomain(self): - xc.hvm_set_param(self.vm.getDomid(), HVM_PARAM_PAE_ENABLED, self.pae) diff --git a/xen-ioapic-ack-default.diff b/xen-ioapic-ack-default.diff index 3c06a25..08a422b 100644 --- a/xen-ioapic-ack-default.diff +++ b/xen-ioapic-ack-default.diff @@ -1,9 +1,11 @@ Change default IO-APIC ack mode for single IO-APIC systems to old-style. Jan ---- a/xen/arch/x86/io_apic.c -+++ b/xen/arch/x86/io_apic.c -@@ -1354,7 +1354,7 @@ static unsigned int startup_level_ioapic +Index: xen-3.4.0-testing/xen/arch/x86/io_apic.c +=================================================================== +--- xen-3.4.0-testing.orig/xen/arch/x86/io_apic.c ++++ xen-3.4.0-testing/xen/arch/x86/io_apic.c +@@ -1298,7 +1298,7 @@ static unsigned int startup_level_ioapic return 0; /* don't check for pending */ } @@ -12,7 +14,7 @@ Change default IO-APIC ack mode for single IO-APIC systems to old-style. Jan static void setup_ioapic_ack(char *s) { if ( !strcmp(s, "old") ) -@@ -1854,6 +1854,8 @@ void __init setup_IO_APIC(void) +@@ -1802,6 +1802,8 @@ void __init setup_IO_APIC(void) else io_apic_irqs = ~PIC_IRQS; diff --git a/xen-ioemu-hvm-pv-support.diff b/xen-ioemu-hvm-pv-support.diff index 757fccd..db2bd08 100644 --- a/xen-ioemu-hvm-pv-support.diff +++ b/xen-ioemu-hvm-pv-support.diff @@ -1,114 +1,17 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/ide.c +Index: xen-3.4.0-testing/tools/ioemu-remote/hw/xen_platform.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/ide.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/ide.c -@@ -485,6 +485,9 @@ typedef struct PCIIDEState { - } PCIIDEState; - - -+static PCIIDEState *principal_ide_controller; -+extern FILE *logfile; -+ - #if defined(__ia64__) - #include - -@@ -2770,6 +2773,27 @@ static void ide_reset(IDEState *s) - s->media_changed = 0; - } - -+void ide_unplug_harddisks(void) -+{ -+ IDEState *s; -+ int i; -+ -+ if (!principal_ide_controller) { -+ fprintf(logfile, "No principal controller?\n"); -+ return; -+ } -+ for (i = 0; i < 4; i++) { -+ s = principal_ide_controller->ide_if + i; -+ if (!s->bs) -+ continue; /* drive not present */ -+ if (s->is_cdrom) -+ continue; /* cdrom */ -+ /* Is a hard disk, unplug it. */ -+ s->bs = NULL; -+ ide_reset(s); -+ } -+} -+ - struct partition { - uint8_t boot_ind; /* 0x80 - active */ - uint8_t head; /* starting head */ -@@ -3282,6 +3306,10 @@ void pci_cmd646_ide_init(PCIBus *bus, Bl - sizeof(PCIIDEState), - -1, - NULL, NULL); -+ if (principal_ide_controller) -+ abort(); -+ principal_ide_controller = d; -+ - d->type = IDE_TYPE_CMD646; - pci_conf = d->dev.config; - pci_conf[0x00] = 0x95; // CMD646 -@@ -3413,6 +3441,10 @@ void pci_piix3_ide_init(PCIBus *bus, Blo - NULL, NULL); - d->type = IDE_TYPE_PIIX3; - -+ if (principal_ide_controller) -+ abort(); -+ principal_ide_controller = d; -+ - pci_conf = d->dev.config; - pci_conf[0x00] = 0x86; // Intel - pci_conf[0x01] = 0x80; -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/pci.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/pci.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/pci.c -@@ -648,6 +648,28 @@ void pci_nic_init(PCIBus *bus, NICInfo * - } - } - -+void pci_unplug_netifs(void) -+{ -+ PCIBus *bus; -+ int x; -+ -+ /* We only support one PCI bus */ -+ for (bus = first_bus; bus; bus = NULL) { -+ for (x = 0; x < 256; x++) { -+ if (bus->devices[x] && -+ bus->devices[x]->config[0xa] == 0 && -+ bus->devices[x]->config[0xb] == 2) { -+ /* Found a netif. Remove it from the bus. Note that -+ we don't free it here, since there could still be -+ references to it floating around. There are only -+ ever one or two structures leaked, and it's not -+ worth finding them all. */ -+ bus->devices[x] = NULL; -+ } -+ } -+ } -+} -+ - typedef struct { - PCIDevice dev; - PCIBus *bus; -Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_platform.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_platform.c -+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_platform.c -@@ -26,6 +26,8 @@ - #include "hw.h" - #include "pci.h" - #include "irq.h" +--- xen-3.4.0-testing.orig/tools/ioemu-remote/hw/xen_platform.c ++++ xen-3.4.0-testing/tools/ioemu-remote/hw/xen_platform.c +@@ -30,6 +30,8 @@ + #include "qemu-xen.h" + #include "net.h" + #include "xen_platform.h" +#include "sysemu.h" +#include + #include #include - -@@ -71,12 +73,53 @@ static void xen_platform_ioport_writeb(v +@@ -326,11 +328,51 @@ static void xen_platform_ioport_writeb(v } } @@ -147,7 +50,6 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_platform.c + } +} + - static void platform_ioport_map(PCIDevice *pci_dev, int region_num, uint32_t addr, uint32_t size, int type) { + ioport_base = addr; @@ -155,124 +57,9 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_platform.c + register_ioport_write(addr, 16, 4, platform_ioport_write, NULL); +/* PCIXenPlatformState *d = (PCIXenPlatformState *)pci_dev; -+ register_ioport_write(addr, size, 1, xen_platform_ioport_writeb, d); register_ioport_read(addr, size, 1, xen_platform_ioport_readb, d); +*/ } static uint32_t platform_mmio_read(void *opaque, target_phys_addr_t addr) -Index: xen-3.3.1-testing/tools/ioemu-remote/vl.c -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/vl.c -+++ xen-3.3.1-testing/tools/ioemu-remote/vl.c -@@ -259,6 +259,20 @@ static int event_pending = 1; - - #include "xen-vl-extra.c" - -+typedef struct IOHandlerRecord { -+ int fd; -+ IOCanRWHandler *fd_read_poll; -+ IOHandler *fd_read; -+ IOHandler *fd_write; -+ int deleted; -+ void *opaque; -+ /* temporary data */ -+ struct pollfd *ufd; -+ struct IOHandlerRecord *next; -+} IOHandlerRecord; -+ -+static IOHandlerRecord *first_io_handler; -+ - /***********************************************************/ - /* x86 ISA bus support */ - -@@ -4054,6 +4068,7 @@ typedef struct TAPState { - int fd; - char down_script[1024]; - char script_arg[1024]; -+ struct TAPState *next; - } TAPState; - - static void tap_receive(void *opaque, const uint8_t *buf, int size) -@@ -4089,6 +4104,36 @@ static void tap_send(void *opaque) - } - } - -+static TAPState *head_net_tap; -+ -+void net_tap_shutdown_all(void) -+{ -+ struct IOHandlerRecord **pioh, *ioh; -+ -+ while (head_net_tap) { -+ pioh = &first_io_handler; -+ for (;;) { -+ ioh = *pioh; -+ if (ioh == NULL) -+ break; -+ if (ioh->fd == head_net_tap->fd) { -+ *pioh = ioh->next; -+ qemu_free(ioh); -+ break; -+ } -+ pioh = &ioh->next; -+ } -+ if (!ioh) -+ fprintf(stderr, -+ "warning: can't find iohandler for %d to close it properly.\n", -+ head_net_tap->fd); -+ close(head_net_tap->fd); -+ head_net_tap = head_net_tap->next; -+ } -+} -+ -+ -+ - /* fd support */ - - static TAPState *net_tap_fd_init(VLANState *vlan, int fd) -@@ -4100,6 +4145,8 @@ static TAPState *net_tap_fd_init(VLANSta - return NULL; - s->fd = fd; - s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s); -+ s->next = head_net_tap; -+ head_net_tap = s; - qemu_set_fd_handler(s->fd, tap_send, NULL, s); - snprintf(s->vc->info_str, sizeof(s->vc->info_str), "tap: fd=%d", fd); - return s; -@@ -5674,20 +5721,6 @@ static void dumb_display_init(DisplaySta - - #define MAX_IO_HANDLERS 64 - --typedef struct IOHandlerRecord { -- int fd; -- IOCanRWHandler *fd_read_poll; -- IOHandler *fd_read; -- IOHandler *fd_write; -- int deleted; -- void *opaque; -- /* temporary data */ -- struct pollfd *ufd; -- struct IOHandlerRecord *next; --} IOHandlerRecord; -- --static IOHandlerRecord *first_io_handler; -- - /* XXX: fd_read_poll should be suppressed, but an API change is - necessary in the character devices to suppress fd_can_read(). */ - int qemu_set_fd_handler2(int fd, -Index: xen-3.3.1-testing/tools/ioemu-remote/sysemu.h -=================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/sysemu.h -+++ xen-3.3.1-testing/tools/ioemu-remote/sysemu.h -@@ -49,6 +49,9 @@ void do_loadvm(const char *name); - void do_delvm(const char *name); - void do_info_snapshots(void); - -+void net_tap_shutdown_all(void); -+void pci_unplug_netifs(void); -+ - void main_loop_wait(int timeout); - - /* Polling handling */ diff --git a/xen-max-free-mem.diff b/xen-max-free-mem.diff index b5b108c..453ce4d 100644 --- a/xen-max-free-mem.diff +++ b/xen-max-free-mem.diff @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/tools/python/xen/xend/XendNode.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendNode.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendNode.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendNode.py -@@ -650,11 +650,35 @@ class XendNode: +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendNode.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendNode.py +@@ -809,11 +809,35 @@ class XendNode: info['cpu_mhz'] = info['cpu_khz'] / 1000 @@ -43,7 +43,7 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendNode.py ITEM_ORDER = ['nr_cpus', 'nr_nodes', -@@ -665,6 +689,9 @@ class XendNode: +@@ -824,6 +848,9 @@ class XendNode: 'virt_caps', 'total_memory', 'free_memory', @@ -53,10 +53,10 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendNode.py 'node_to_cpu', 'node_to_memory' ] -Index: xen-3.3.1-testing/tools/python/xen/xend/balloon.py +Index: xen-3.4.0-testing/tools/python/xen/xend/balloon.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/balloon.py -+++ xen-3.3.1-testing/tools/python/xen/xend/balloon.py +--- xen-3.4.0-testing.orig/tools/python/xen/xend/balloon.py ++++ xen-3.4.0-testing/tools/python/xen/xend/balloon.py @@ -41,6 +41,8 @@ SLEEP_TIME_GROWTH = 0.1 # label actually shown in the PROC_XEN_BALLOON file. #labels = { 'current' : 'Current allocation', @@ -87,16 +87,16 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/balloon.py + raise VmError('Failed to query maximum target memory allocation of dom0.') + return kb + - def free(need_mem): + def free(need_mem, dominfo): """Balloon out memory from the privileged domain so that there is the specified required amount (in KiB) free. -Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1046,6 +1046,27 @@ class XendDomainInfo: - - return None +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py +@@ -1294,6 +1294,27 @@ class XendDomainInfo: + dev_str_list = dev_str_list + [dev_str] + return dev_str_list + def capAndSetMemoryTarget(self, target): + """Potentially lowers the requested target to the largest possible @@ -122,11 +122,11 @@ Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py def setMemoryTarget(self, target): """Set the memory target of this domain. @param target: In MiB. -Index: xen-3.3.1-testing/tools/python/xen/xend/server/SrvDomain.py +Index: xen-3.4.0-testing/tools/python/xen/xend/server/SrvDomain.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/server/SrvDomain.py -+++ xen-3.3.1-testing/tools/python/xen/xend/server/SrvDomain.py -@@ -171,7 +171,7 @@ class SrvDomain(SrvDir): +--- xen-3.4.0-testing.orig/tools/python/xen/xend/server/SrvDomain.py ++++ xen-3.4.0-testing/tools/python/xen/xend/server/SrvDomain.py +@@ -172,7 +172,7 @@ class SrvDomain(SrvDir): def op_mem_target_set(self, _, req): diff --git a/xen-no-dummy-nfs-ip.diff b/xen-no-dummy-nfs-ip.diff index 2d3a6bd..4c37026 100644 --- a/xen-no-dummy-nfs-ip.diff +++ b/xen-no-dummy-nfs-ip.diff @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/tools/python/xen/xm/create.py +Index: xen-3.4.0-testing/tools/python/xen/xm/create.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xm/create.py -+++ xen-3.3.1-testing/tools/python/xen/xm/create.py -@@ -1081,9 +1081,8 @@ def preprocess_access_control(vals): +--- xen-3.4.0-testing.orig/tools/python/xen/xm/create.py ++++ xen-3.4.0-testing/tools/python/xen/xm/create.py +@@ -1160,9 +1160,8 @@ def preprocess_access_control(vals): def preprocess_ip(vals): if vals.ip or vals.dhcp != 'off': diff --git a/xen-paths.diff b/xen-paths.diff index 297cb79..40ada2c 100644 --- a/xen-paths.diff +++ b/xen-paths.diff @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/tools/python/xen/xm/create.py +Index: xen-3.4.0-testing/tools/python/xen/xm/create.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xm/create.py -+++ xen-3.3.1-testing/tools/python/xen/xm/create.py -@@ -70,7 +70,7 @@ gopts.opt('quiet', short='q', +--- xen-3.4.0-testing.orig/tools/python/xen/xm/create.py ++++ xen-3.4.0-testing/tools/python/xen/xm/create.py +@@ -72,7 +72,7 @@ gopts.opt('quiet', short='q', use="Quiet.") gopts.opt('path', val='PATH', @@ -11,10 +11,10 @@ Index: xen-3.3.1-testing/tools/python/xen/xm/create.py use="Search path for configuration scripts. " "The value of PATH is a colon-separated directory list.") -Index: xen-3.3.1-testing/docs/man/xm.pod.1 +Index: xen-3.4.0-testing/docs/man/xm.pod.1 =================================================================== ---- xen-3.3.1-testing.orig/docs/man/xm.pod.1 -+++ xen-3.3.1-testing/docs/man/xm.pod.1 +--- xen-3.4.0-testing.orig/docs/man/xm.pod.1 ++++ xen-3.4.0-testing/docs/man/xm.pod.1 @@ -77,7 +77,7 @@ in the config file. See L format, and possible options used in either the configfile or for I. @@ -33,10 +33,10 @@ Index: xen-3.3.1-testing/docs/man/xm.pod.1 soon as it is run. =item I -Index: xen-3.3.1-testing/docs/man/xmdomain.cfg.pod.5 +Index: xen-3.4.0-testing/docs/man/xmdomain.cfg.pod.5 =================================================================== ---- xen-3.3.1-testing.orig/docs/man/xmdomain.cfg.pod.5 -+++ xen-3.3.1-testing/docs/man/xmdomain.cfg.pod.5 +--- xen-3.4.0-testing.orig/docs/man/xmdomain.cfg.pod.5 ++++ xen-3.4.0-testing/docs/man/xmdomain.cfg.pod.5 @@ -4,9 +4,9 @@ xmdomain.cfg - xm domain config file for =head1 SYNOPSIS diff --git a/xen-qemu-iscsi-fix.patch b/xen-qemu-iscsi-fix.patch index bb4bef0..f5fc198 100644 --- a/xen-qemu-iscsi-fix.patch +++ b/xen-qemu-iscsi-fix.patch @@ -1,20 +1,20 @@ -Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c +Index: xen-3.4.0-testing/tools/ioemu-remote/xenstore.c =================================================================== ---- xen-3.3.1-testing.orig/tools/ioemu-remote/xenstore.c -+++ xen-3.3.1-testing/tools/ioemu-remote/xenstore.c -@@ -153,7 +153,7 @@ void xenstore_parse_domain_config(int hv - char *buf = NULL, *path; +--- xen-3.4.0-testing.orig/tools/ioemu-remote/xenstore.c ++++ xen-3.4.0-testing/tools/ioemu-remote/xenstore.c +@@ -313,7 +313,7 @@ void xenstore_parse_domain_config(int hv + char *buf = NULL; char *fpath = NULL, *bpath = NULL, *btype = NULL, - *dev = NULL, *params = NULL, *type = NULL, *drv = NULL; + *dev = NULL, *params = NULL, *drv = NULL; - int i, any_hdN = 0, ret, is_tap; + int i, j, any_hdN = 0, ret, is_tap; unsigned int len, num, hd_index, pci_devid = 0; BlockDriverState *bs; BlockDriver *format; -@@ -238,12 +238,7 @@ void xenstore_parse_domain_config(int hv +@@ -400,12 +400,7 @@ void xenstore_parse_domain_config(int hv continue; - free(type); - type = xs_read(xsh, XBT_NULL, buf, &len); + free(danger_type); + danger_type = xs_read(xsh, XBT_NULL, danger_buf, &len); - if (pasprintf(&buf, "%s/params", bpath) == -1) - continue; - free(params); @@ -25,13 +25,13 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c /* read the name of the device */ if (pasprintf(&buf, "%s/type", bpath) == -1) continue; -@@ -251,6 +246,35 @@ void xenstore_parse_domain_config(int hv +@@ -413,6 +408,35 @@ void xenstore_parse_domain_config(int hv drv = xs_read(xsh, XBT_NULL, buf, &len); if (drv == NULL) continue; + + free(params); -+ if (!strcmp(drv,"iscsi")) ++ if (!strcmp(drv,"iscsi")) + { + if (pasprintf(&buf, "%s/node", bpath) == -1) + continue; @@ -50,7 +50,7 @@ Index: xen-3.3.1-testing/tools/ioemu-remote/xenstore.c + } + } + else -+ { ++ { + if (pasprintf(&buf, "%s/params", bpath) == -1) + continue; + params = xs_read(xsh, XBT_NULL, buf, &len); diff --git a/xen-rpmoptflags.diff b/xen-rpmoptflags.diff index 908bd39..7cf8773 100644 --- a/xen-rpmoptflags.diff +++ b/xen-rpmoptflags.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/blktap/drivers/Makefile +Index: xen-3.4.0-testing/tools/blktap/drivers/Makefile =================================================================== ---- xen-3.3.1-testing.orig/tools/blktap/drivers/Makefile -+++ xen-3.3.1-testing/tools/blktap/drivers/Makefile +--- xen-3.4.0-testing.orig/tools/blktap/drivers/Makefile ++++ xen-3.4.0-testing/tools/blktap/drivers/Makefile @@ -5,7 +5,6 @@ IBIN = blktapctrl tapdisk QCOW_UTIL = img2qcow qcow2raw qcow-create LIBAIO_DIR = ../../libaio/src @@ -10,10 +10,10 @@ Index: xen-3.3.1-testing/tools/blktap/drivers/Makefile CFLAGS += -Wno-unused CFLAGS += -I../lib CFLAGS += $(CFLAGS_libxenctrl) -Index: xen-3.3.1-testing/Config.mk +Index: xen-3.4.0-testing/Config.mk =================================================================== ---- xen-3.3.1-testing.orig/Config.mk -+++ xen-3.3.1-testing/Config.mk +--- xen-3.4.0-testing.orig/Config.mk ++++ xen-3.4.0-testing/Config.mk @@ -14,7 +14,7 @@ SHELL ?= /bin/sh # Tools to run on system hosting the build diff --git a/xen-warnings.diff b/xen-warnings.diff index f5f571e..ef5c676 100644 --- a/xen-warnings.diff +++ b/xen-warnings.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/misc/miniterm/miniterm.c +Index: xen-3.4.0-testing/tools/misc/miniterm/miniterm.c =================================================================== ---- xen-3.3.1-testing.orig/tools/misc/miniterm/miniterm.c -+++ xen-3.3.1-testing/tools/misc/miniterm/miniterm.c +--- xen-3.4.0-testing.orig/tools/misc/miniterm/miniterm.c ++++ xen-3.4.0-testing/tools/misc/miniterm/miniterm.c @@ -157,7 +157,7 @@ int main(int argc, char **argv) case 0: close(1); /* stdout not needed */ @@ -35,10 +35,10 @@ Index: xen-3.3.1-testing/tools/misc/miniterm/miniterm.c break; } -Index: xen-3.3.1-testing/tools/libxc/xc_dom_elfloader.c +Index: xen-3.4.0-testing/tools/libxc/xc_dom_elfloader.c =================================================================== ---- xen-3.3.1-testing.orig/tools/libxc/xc_dom_elfloader.c -+++ xen-3.3.1-testing/tools/libxc/xc_dom_elfloader.c +--- xen-3.4.0-testing.orig/tools/libxc/xc_dom_elfloader.c ++++ xen-3.4.0-testing/tools/libxc/xc_dom_elfloader.c @@ -193,8 +193,9 @@ static int xc_dom_load_elf_symtab(struct if ( load ) @@ -50,10 +50,10 @@ Index: xen-3.3.1-testing/tools/libxc/xc_dom_elfloader.c elf_section_start(elf, shdr2), size); } -Index: xen-3.3.1-testing/tools/xenstore/Makefile +Index: xen-3.4.0-testing/tools/xenstore/Makefile =================================================================== ---- xen-3.3.1-testing.orig/tools/xenstore/Makefile -+++ xen-3.3.1-testing/tools/xenstore/Makefile +--- xen-3.4.0-testing.orig/tools/xenstore/Makefile ++++ xen-3.4.0-testing/tools/xenstore/Makefile @@ -4,7 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk MAJOR = 3.0 MINOR = 0 @@ -63,10 +63,10 @@ Index: xen-3.3.1-testing/tools/xenstore/Makefile CFLAGS += -I. CFLAGS += $(CFLAGS_libxenctrl) -Index: xen-3.3.1-testing/tools/xenstore/xenstored_core.c +Index: xen-3.4.0-testing/tools/xenstore/xenstored_core.c =================================================================== ---- xen-3.3.1-testing.orig/tools/xenstore/xenstored_core.c -+++ xen-3.3.1-testing/tools/xenstore/xenstored_core.c +--- xen-3.4.0-testing.orig/tools/xenstore/xenstored_core.c ++++ xen-3.4.0-testing/tools/xenstore/xenstored_core.c @@ -77,8 +77,8 @@ static void check_store(void); int quota_nb_entry_per_domain = 1000; @@ -91,10 +91,10 @@ Index: xen-3.3.1-testing/tools/xenstore/xenstored_core.c break; case 'T': tracefile = optarg; -Index: xen-3.3.1-testing/tools/xenstore/xenstored_domain.c +Index: xen-3.4.0-testing/tools/xenstore/xenstored_domain.c =================================================================== ---- xen-3.3.1-testing.orig/tools/xenstore/xenstored_domain.c -+++ xen-3.3.1-testing/tools/xenstore/xenstored_domain.c +--- xen-3.4.0-testing.orig/tools/xenstore/xenstored_domain.c ++++ xen-3.4.0-testing/tools/xenstore/xenstored_domain.c @@ -212,7 +212,7 @@ void handle_event(void) { evtchn_port_t port; @@ -113,10 +113,10 @@ Index: xen-3.3.1-testing/tools/xenstore/xenstored_domain.c return -1; dom0 = new_domain(NULL, 0, port); -Index: xen-3.3.1-testing/tools/xenstore/xenstored_transaction.c +Index: xen-3.4.0-testing/tools/xenstore/xenstored_transaction.c =================================================================== ---- xen-3.3.1-testing.orig/tools/xenstore/xenstored_transaction.c -+++ xen-3.3.1-testing/tools/xenstore/xenstored_transaction.c +--- xen-3.4.0-testing.orig/tools/xenstore/xenstored_transaction.c ++++ xen-3.4.0-testing/tools/xenstore/xenstored_transaction.c @@ -82,7 +82,7 @@ struct transaction struct list_head changed_domains; }; @@ -126,10 +126,10 @@ Index: xen-3.3.1-testing/tools/xenstore/xenstored_transaction.c static unsigned int generation; /* Return tdb context to use for this connection. */ -Index: xen-3.3.1-testing/tools/xenstore/xenstore_client.c +Index: xen-3.4.0-testing/tools/xenstore/xenstore_client.c =================================================================== ---- xen-3.3.1-testing.orig/tools/xenstore/xenstore_client.c -+++ xen-3.3.1-testing/tools/xenstore/xenstore_client.c +--- xen-3.4.0-testing.orig/tools/xenstore/xenstore_client.c ++++ xen-3.4.0-testing/tools/xenstore/xenstore_client.c @@ -251,7 +251,7 @@ do_chmod(char *path, struct xs_permissio char **xsval = xs_directory(xsh, xth, path, &xsval_n); @@ -139,11 +139,11 @@ Index: xen-3.3.1-testing/tools/xenstore/xenstore_client.c for (i = 0; i < xsval_n; i++) { snprintf(buf, MAX_PATH_LEN, "%s/%s", path, xsval[i]); -Index: xen-3.3.1-testing/tools/libxen/src/xen_common.c +Index: xen-3.4.0-testing/tools/libxen/src/xen_common.c =================================================================== ---- xen-3.3.1-testing.orig/tools/libxen/src/xen_common.c -+++ xen-3.3.1-testing/tools/libxen/src/xen_common.c -@@ -1055,6 +1055,8 @@ static size_t size_of_member(const abstr +--- xen-3.4.0-testing.orig/tools/libxen/src/xen_common.c ++++ xen-3.4.0-testing/tools/libxen/src/xen_common.c +@@ -1057,6 +1057,8 @@ static size_t size_of_member(const abstr default: assert(false); } @@ -152,7 +152,7 @@ Index: xen-3.3.1-testing/tools/libxen/src/xen_common.c } -@@ -1566,6 +1568,8 @@ get_val_as_string(const struct abstract_ +@@ -1568,6 +1570,8 @@ get_val_as_string(const struct abstract_ default: assert(false); } diff --git a/xen-xm-top-needs-root.diff b/xen-xm-top-needs-root.diff index a8551a0..e65700e 100644 --- a/xen-xm-top-needs-root.diff +++ b/xen-xm-top-needs-root.diff @@ -1,11 +1,11 @@ From: Charles Coffing Upstream: no -Index: xen-3.3.1-testing/tools/python/xen/xm/main.py +Index: xen-3.4.0-testing/tools/python/xen/xm/main.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xm/main.py -+++ xen-3.3.1-testing/tools/python/xen/xm/main.py -@@ -1938,6 +1938,10 @@ def xm_debug_keys(args): +--- xen-3.4.0-testing.orig/tools/python/xen/xm/main.py ++++ xen-3.4.0-testing/tools/python/xen/xm/main.py +@@ -1917,6 +1917,10 @@ def xm_debug_keys(args): def xm_top(args): arg_check(args, "top", 0) diff --git a/xen-xmexample-vti.diff b/xen-xmexample-vti.diff index e70058d..f3cf9d8 100644 --- a/xen-xmexample-vti.diff +++ b/xen-xmexample-vti.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/examples/Makefile +Index: xen-3.4.0-testing/tools/examples/Makefile =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/Makefile -+++ xen-3.3.1-testing/tools/examples/Makefile +--- xen-3.4.0-testing.orig/tools/examples/Makefile ++++ xen-3.4.0-testing/tools/examples/Makefile @@ -20,7 +20,6 @@ XEN_CONFIGS += xmexample.hvm-stubdom XEN_CONFIGS += xmexample.hvm-dm XEN_CONFIGS += xmexample.pv-grub diff --git a/xen-xmexample.diff b/xen-xmexample.diff index 4f0a230..686e9fb 100644 --- a/xen-xmexample.diff +++ b/xen-xmexample.diff @@ -1,9 +1,9 @@ Change various example paths in the config files to match SUSE. -Index: xen-3.3.1-testing/tools/examples/xmexample1 +Index: xen-3.4.0-testing/tools/examples/xmexample1 =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/xmexample1 -+++ xen-3.3.1-testing/tools/examples/xmexample1 +--- xen-3.4.0-testing.orig/tools/examples/xmexample1 ++++ xen-3.4.0-testing/tools/examples/xmexample1 @@ -7,11 +7,13 @@ #============================================================================ @@ -43,10 +43,10 @@ Index: xen-3.3.1-testing/tools/examples/xmexample1 #---------------------------------------------------------------------------- # Configure the behaviour when a domain exits. There are three 'reasons' -Index: xen-3.3.1-testing/tools/examples/xmexample2 +Index: xen-3.4.0-testing/tools/examples/xmexample2 =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/xmexample2 -+++ xen-3.3.1-testing/tools/examples/xmexample2 +--- xen-3.4.0-testing.orig/tools/examples/xmexample2 ++++ xen-3.4.0-testing/tools/examples/xmexample2 @@ -35,11 +35,13 @@ xm_vars.var('vmid', xm_vars.check() @@ -86,10 +86,10 @@ Index: xen-3.3.1-testing/tools/examples/xmexample2 #---------------------------------------------------------------------------- # Configure the behaviour when a domain exits. There are three 'reasons' -Index: xen-3.3.1-testing/tools/examples/xmexample3 +Index: xen-3.4.0-testing/tools/examples/xmexample3 =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/xmexample3 -+++ xen-3.3.1-testing/tools/examples/xmexample3 +--- xen-3.4.0-testing.orig/tools/examples/xmexample3 ++++ xen-3.4.0-testing/tools/examples/xmexample3 @@ -35,11 +35,13 @@ xm_vars.var('vmid', xm_vars.check() @@ -109,11 +109,11 @@ Index: xen-3.3.1-testing/tools/examples/xmexample3 # The domain build function. Default is 'linux'. #builder='linux' -Index: xen-3.3.1-testing/tools/examples/xmexample.hvm +Index: xen-3.4.0-testing/tools/examples/xmexample.hvm =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/xmexample.hvm -+++ xen-3.3.1-testing/tools/examples/xmexample.hvm -@@ -73,7 +73,7 @@ vif = [ 'type=ioemu, bridge=xenbr0' ] +--- xen-3.4.0-testing.orig/tools/examples/xmexample.hvm ++++ xen-3.4.0-testing/tools/examples/xmexample.hvm +@@ -81,7 +81,7 @@ vif = [ 'type=ioemu, bridge=xenbr0' ] # and MODE is r for read-only, w for read-write. #disk = [ 'phy:hda1,hda1,r' ] @@ -122,10 +122,10 @@ Index: xen-3.3.1-testing/tools/examples/xmexample.hvm #---------------------------------------------------------------------------- # Configure the behaviour when a domain exits. There are three 'reasons' -Index: xen-3.3.1-testing/docs/man/xmdomain.cfg.pod.5 +Index: xen-3.4.0-testing/docs/man/xmdomain.cfg.pod.5 =================================================================== ---- xen-3.3.1-testing.orig/docs/man/xmdomain.cfg.pod.5 -+++ xen-3.3.1-testing/docs/man/xmdomain.cfg.pod.5 +--- xen-3.4.0-testing.orig/docs/man/xmdomain.cfg.pod.5 ++++ xen-3.4.0-testing/docs/man/xmdomain.cfg.pod.5 @@ -38,13 +38,13 @@ file. The kernel image for the domain. The format of the parameter is the @@ -161,10 +161,10 @@ Index: xen-3.3.1-testing/docs/man/xmdomain.cfg.pod.5 at hda1, which is the root filesystem. =item I -Index: xen-3.3.1-testing/docs/man/xm.pod.1 +Index: xen-3.4.0-testing/docs/man/xm.pod.1 =================================================================== ---- xen-3.3.1-testing.orig/docs/man/xm.pod.1 -+++ xen-3.3.1-testing/docs/man/xm.pod.1 +--- xen-3.4.0-testing.orig/docs/man/xm.pod.1 ++++ xen-3.4.0-testing/docs/man/xm.pod.1 @@ -163,8 +163,8 @@ soon as it is run. =item I diff --git a/xen.changes b/xen.changes index b9c2a91..ac3327b 100644 --- a/xen.changes +++ b/xen.changes @@ -1,3 +1,51 @@ +------------------------------------------------------------------- +Fri Apr 22 17:30:02 CST 2009 - wkong@novell.com + +- Backport two qcow2 patches from qemu org + ioemu-6816-qcow2-revert-6404-6405-6407.patch + ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch + +------------------------------------------------------------------- +Fri Apr 17 16:21:36 CST 2009 - wkong@novell.com +- bnc#477890 - Patch: ioemu-qcow2-enhance-snapshot-create.patch + +------------------------------------------------------------------- +Thu Apr 16 12:13:10 MDT 2009 - jfehlig@novell.com + +- Updated xend-domain-lock.patch + fate#303525, bnc#494892 + +------------------------------------------------------------------- +Thu Apr 9 18:36:23 CST 2009 - wkong@novell.com + +- Remove Patch155: xend-core-dump-loc.diff +- Modify Patch110: xen-domUloader.diff, + remove symbol "bootfilter" + +------------------------------------------------------------------- +Wed Apr 8 17:38:12 CST 2009 - wkong@novell.com + +- PATCH: network-nat-open-SuSEfirewall2-FORWARD.patch + fate#305354, bnc#472107 + Open SuSEfirewall2 FORWARD rule when use xen nat +- PATCH: network-nat-dhcpd-domain-info.patch + Add domain info for nat-dhcpd + +------------------------------------------------------------------- +Thu Apr 2 16:52:04 MDT 2009 - jfehlig@novell.com + +- Fix domUloader to handle block device names with ':' + +------------------------------------------------------------------- +Wed Mar 11 16:28:59 MDT 2009 - jfehlig@novell.com + +- Use pidofproc/checkproc in xend init script + +------------------------------------------------------------------- +Tue Mar 3 16:11:39 CET 2009 - kukuk@suse.de + +- Don't load 8139* driver if xen-vnif works [bnc#480164] + ------------------------------------------------------------------- Fri Feb 27 18:32:01 MST 2009 - carnold@novell.com @@ -5,6 +53,19 @@ Fri Feb 27 18:32:01 MST 2009 - carnold@novell.com SLES 11 VM is invalid. xen_pvdrivers +------------------------------------------------------------------- +Thu Feb 26 15:05:38 MST 2009 - carnold@novell.com + +- bnc#474822 - L3: Win2003 i386 XEN VM can see only 2 TB with a + 4TB LUN. + int13_hardisk-64bit-lba.patch + +------------------------------------------------------------------- +Wed Feb 25 11:52:16 MST 2009 - jfehlig@novell.com + +- bnc#477890 - Destroy domain if snapshot restore fails. + Updated snapshot-xend.patch + ------------------------------------------------------------------- Tue Feb 24 14:13:35 EST 2009 - ksrinivasan@novell.com @@ -15,6 +76,19 @@ Tue Feb 24 14:13:35 EST 2009 - ksrinivasan@novell.com hanging under load. disable_emulated_device.diff +------------------------------------------------------------------- +Tue Feb 24 16:03:35 CET 2009 - kwolf@suse.de + +- bnc#477892 - Disable xend timeout for snapshots + Updated snapshot-xend.patch + +------------------------------------------------------------------- +Tue Feb 24 14:28:52 CET 2009 - kwolf@suse.de + +- bnc#477895 - Fix detaching blktap disks from domains without + device model + Updated blktap-ioemu-close-fix.patch + ------------------------------------------------------------------- Fri Feb 20 11:46:12 CET 2009 - kwolf@suse.de diff --git a/xen.spec b/xen.spec index d986ad9..44702e0 100644 --- a/xen.spec +++ b/xen.spec @@ -1,5 +1,5 @@ # -# spec file for package xen (Version 3.3.1_18546_12) +# spec file for package xen (Version 3.4.0_19590_01) # # Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -20,12 +20,12 @@ Name: xen ExclusiveArch: %ix86 x86_64 -%define xvers 3.3 +%define xvers 3.4 %define xvermaj 3 -%define changeset 18546 -%define xen_build_dir xen-3.3.1-testing -%define with_kmp 1 -BuildRequires: LibVNCServer-devel SDL-devel automake bin86 curl-devel dev86 graphviz latex2html libjpeg-devel libxml2-devel ncurses-devel openssl openssl-devel pciutils-devel python-devel transfig +%define changeset 19590 +%define xen_build_dir xen-3.4.0-testing +%define with_kmp 0 +BuildRequires: LibVNCServer-devel SDL-devel automake bin86 curl-devel dev86 graphviz latex2html libjpeg-devel libxml2-devel ncurses-devel openssl openssl-devel pciutils-devel python-devel texinfo transfig %if %suse_version >= 1030 BuildRequires: texlive texlive-latex %else @@ -37,14 +37,14 @@ BuildRequires: glibc-32bit glibc-devel-32bit %if %{?with_kmp}0 BuildRequires: kernel-source kernel-syms module-init-tools xorg-x11 %endif -Version: 3.3.1_18546_12 -Release: 2 +Version: 3.4.0_19590_01 +Release: 1 License: GPL v2 only Group: System/Kernel AutoReqProv: on PreReq: %insserv_prereq %fillup_prereq Summary: Xen Virtualization: Hypervisor (aka VMM aka Microkernel) -Source0: xen-3.3.1-testing-src.tar.bz2 +Source0: xen-3.4.0-testing-src.tar.bz2 Source2: README.SuSE Source3: boot.xen Source4: boot.local.xenU @@ -70,113 +70,24 @@ Source24: xenapiusers # sysconfig hook script for Xen Source25: xen-updown.sh # Upstream patches -Patch0: 18406-constify-microcode.patch -Patch1: 18412-x86-page-type-preemptible.patch -Patch2: 18420-x86-page-type-preemptible-fix.patch -Patch3: 18428-poll-single-port.patch -Patch4: 18446-vtd-dom0-passthrough.patch -Patch5: 18456-vtd-dom0-passthrough-cmdline.patch -Patch6: 18464-cpu-hotplug.patch -Patch7: 18468-therm-control-msr.patch -Patch8: 18471-cpu-hotplug.patch -Patch9: 18475-amd-microcode-update.patch -Patch10: 18481-amd-microcode-update-fix.patch -Patch11: 18483-intel-microcode-update.patch -Patch12: 18484-stubdom-ioemu-makefile.patch -Patch13: 18487-microcode-update-irq-context.patch -Patch14: 18488-microcode-free-fix.patch -Patch15: 18509-continue-hypercall-on-cpu.patch -Patch16: 18519-microcode-retval.patch -Patch17: 18520-per-CPU-GDT.patch -Patch18: 18521-per-CPU-TSS.patch -Patch19: 18523-per-CPU-misc.patch -Patch20: 18528-dump-evtchn.patch -Patch21: 18539-pirq-vector-mapping.patch -Patch22: 18547-pirq-vector-mapping-fix.patch -Patch23: 18573-move-pirq-logic.patch -Patch24: 18574-msi-free-vector.patch -Patch25: 18577-bad-assertion.patch -Patch26: 18583-passthrough-locking.patch -Patch27: 18584-evtchn-lock-rename.patch -Patch28: 18620-x86-page-type-preemptible-fix.patch -Patch29: 18637-vmx-set-dr7.patch -Patch30: 18654-xend-vcpus.patch -Patch31: 18656-vtd-alloc-checks.patch -Patch32: 18661-recursive-spinlocks.patch -Patch33: 18720-x86-dom-cleanup.patch -Patch34: 18722-x86-fixmap-reserved.patch -Patch35: 18723-unmap-dom-page-const.patch -Patch36: 18724-i386-highmem-assist.patch -Patch37: 18731-x86-dom-cleanup.patch -Patch38: 18735-x86-dom-cleanup.patch -Patch39: 18741-x86-dom-cleanup-no-hack.patch -Patch40: 18742-x86-partial-page-ref.patch -Patch41: 18745-xend-ioport-irq.patch -Patch42: 18747-x86-partial-page-ref.patch -Patch43: 18762-vtd-intremap-SMI-RTEs.patch -Patch44: 18771-reduce-GDT-switching.patch -Patch45: 18778-msi-irq-fix.patch -Patch46: 18764-cpu-affinity.patch -Patch47: 18780-cpu-affinity.patch -Patch48: 18785-vlapic-lowest-prio.patch -Patch49: 18788-vlapic-accel-dom-restore.patch -Patch50: 18795-x86-ioapic-guest-write.patch -Patch51: 18799-cpu-affinity.patch -Patch52: 18805-pv-driver-build.patch -Patch53: 18810-shadow-PAT.patch -Patch54: 18844-shared-page-EOI.patch -Patch55: 18852-shared-page-EOI-gmfn.patch -Patch56: 18870-vtd-flush-per-device.patch -Patch57: 18878-x86-cpufreq-less-verbose.patch -Patch58: 18879-cpufreq-params.patch -Patch59: 18880-x86-pirq-guest-bind-msg.patch -Patch60: 18887-vtd-error-handling.patch -Patch61: 18904-x86-local-irq.patch -Patch62: 18905-x86-ioapic-boot-panic.patch -Patch63: 18929-shadow-no-duplicates.patch -Patch64: 18930-xenoprof-dunnington.patch -Patch65: 18934-vtd-PCI-X-dev-assign.patch -Patch66: 18937-S3-MSI.patch -Patch67: 18943-amd-32bit-paging-limit.patch -Patch68: 18970-vmx-print-features.patch -Patch69: 19009-x86_64-note-init-p2m.patch -Patch70: 19027-hvmloader-SMBIOS-dev-mem-boundary.patch -Patch71: 19032-amd-iommu-pointer-reset.patch -Patch72: 19035-MSI-X-proper-enable.patch -Patch73: 19038-x86-no-apic.patch -Patch74: 19039-x86-propagate-nolapic.patch -Patch75: 19046-cross-bit-coredumping.patch -Patch76: 19048-cross-bit-coredumping.patch -Patch77: 19051-cross-bit-coredumping.patch -Patch78: 19072-vmx-pat.patch -Patch79: 19079-snp_ctl-1.patch -Patch80: 19088-x86-page-non-atomic-owner.patch -Patch81: 19089-x86_64-widen-page-refcounts.patch -Patch82: 19103-x86_64-fold-page-lock.patch -Patch83: 19151-xend-class-dereg.patch -Patch84: 19152-xm-man-page.patch -Patch85: 19153-xm-noxen-error.patch -Patch86: 19154-snoop-control.patch -Patch87: 19198-fix-snoop.patch -Patch88: old-arbytes.patch # Our patches Patch100: xen-config.diff Patch101: xend-config.diff Patch102: xen-destdir.diff Patch103: xen-rpmoptflags.diff Patch104: xen-warnings.diff -Patch106: xen-changeset.diff -Patch107: xen-paths.diff -Patch108: xen-xmexample.diff -Patch109: xen-xmexample-vti.diff -Patch110: xen-fixme-doc.diff -Patch111: xen-domUloader.diff -Patch112: xen-no-dummy-nfs-ip.diff -Patch113: serial-split.patch -Patch114: xen-xm-top-needs-root.diff -Patch115: xen-tightvnc-args.diff -Patch116: xen-max-free-mem.diff -Patch119: xen-ioapic-ack-default.diff +Patch105: xen-changeset.diff +Patch106: xen-paths.diff +Patch107: xen-xmexample.diff +Patch108: xen-xmexample-vti.diff +Patch109: xen-fixme-doc.diff +Patch110: xen-domUloader.diff +Patch111: xen-no-dummy-nfs-ip.diff +Patch112: serial-split.patch +Patch113: xen-xm-top-needs-root.diff +Patch114: xen-tightvnc-args.diff +Patch115: xen-max-free-mem.diff +Patch116: xen-ioapic-ack-default.diff Patch120: block-losetup-retry.diff Patch121: block-flags.diff Patch122: xen-hvm-default-bridge.diff @@ -189,7 +100,6 @@ Patch133: xenapi-console-protocol.patch Patch134: xen-disable-qemu-monitor.diff Patch135: supported_module.diff Patch136: qemu-security-etch1.diff -Patch137: rpmlint.diff Patch140: cdrom-removable.patch Patch150: bridge-opensuse.patch Patch151: bridge-vlan.diff @@ -198,8 +108,8 @@ Patch153: bridge-hostonly.diff Patch154: bridge-record-creation.patch Patch155: xend-core-dump-loc.diff Patch156: blktap.patch -Patch157: xen-api-auth.patch -Patch158: xen-qemu-iscsi-fix.patch +Patch157: xen-qemu-iscsi-fix.patch +Patch158: xen-api-auth.patch Patch159: tools-gdbserver-build.diff Patch160: network-route.patch # Needs to go upstream sometime, when python 2.6 is widespread @@ -208,51 +118,52 @@ Patch162: udev-rules.patch Patch163: ioemu-vnc-resize.patch # Needs to go upstream Patch164: checkpoint-rename.patch -Patch165: reenable-block-protocols.patch -Patch166: network-nat.patch -Patch167: ioemu-debuginfo.patch +Patch165: network-nat.patch +Patch166: ioemu-debuginfo.patch # Patches for snapshot support -Patch170: qemu-img-snapshot.patch -Patch171: ioemu-blktap-fix-open.patch -Patch172: snapshot-ioemu-save.patch -Patch173: snapshot-ioemu-restore.patch -Patch174: snapshot-ioemu-delete.patch -Patch175: snapshot-xend.patch -Patch180: ioemu-qcow2-multiblock-aio.patch -Patch181: ioemu-blktap-image-format.patch -Patch182: build-tapdisk-ioemu.patch -Patch183: blktapctrl-default-to-ioemu.patch -Patch184: ioemu-blktap-barriers.patch -Patch185: tapdisk-ioemu-logfile.patch -Patch186: blktap-ioemu-close-fix.patch -Patch187: ioemu-blktap-zero-size.patch -Patch188: blktap-error-handling.patch -Patch189: ioemu-blktap-fv-init.patch -Patch190: ioemu-vpc-4gb-fix.patch -Patch191: qemu-dm-segfault.patch +Patch200: snapshot-ioemu-save.patch +Patch201: snapshot-ioemu-restore.patch +Patch202: snapshot-ioemu-delete.patch +Patch203: snapshot-xend.patch +# ioemu part of blktap patch series +Patch210: ioemu-blktap-fv-init.patch +Patch211: ioemu-blktap-image-format.patch +Patch212: build-tapdisk-ioemu.patch +Patch213: tapdisk-ioemu-logfile.patch +Patch214: ioemu-blktap-zero-size.patch +Patch215: tapdisk-ioemu-shutdown-fix.patch +# More random patches +Patch220: qemu-dm-segfault.patch +Patch221: blktapctrl-default-to-ioemu.patch +Patch222: ioemu-blktap-barriers.patch # Jim's domain lock patch -Patch200: xend-domain-lock.patch +Patch300: xend-domain-lock.patch # Patches from Jan -Patch240: dump-exec-state.patch -Patch241: x86-show-page-walk-early.patch -Patch242: x86-extra-trap-info.patch -Patch243: x86-alloc-cpu-structs.patch -Patch244: 32on64-extra-mem.patch -Patch245: msi-enable.patch -# PV Driver Patches -Patch350: pv-driver-build.patch -Patch351: xen-ioemu-hvm-pv-support.diff -Patch352: pvdrv_emulation_control.patch -Patch353: blktap-pv-cdrom.patch -Patch354: x86-cpufreq-report.patch -Patch355: dom-print.patch -Patch356: x86_64-sh-next-shadow.patch -Patch357: x86_64-page-info-pack.patch -Patch358: disable_emulated_device.diff +Patch340: x86_64-note-init-p2m.patch +Patch341: x86-cpufreq-report.patch +Patch342: dump-exec-state.patch +Patch343: dom-print.patch +Patch344: pv-driver-build.patch +Patch345: x86-show-page-walk-early.patch +Patch346: x86-extra-trap-info.patch +Patch347: svm-lmsl.patch +Patch348: x86_64-5Tb.patch +# Other patches +Patch400: x86-alloc-cpu-structs.patch +Patch401: 32on64-extra-mem.patch +Patch402: msi-enable.patch +Patch403: xen-ioemu-hvm-pv-support.diff +Patch404: pvdrv_emulation_control.patch +Patch405: blktap-pv-cdrom.patch +Patch406: network-nat-open-SuSEfirewall2-FORWARD.patch +Patch407: ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch +%if %{?with_kmp}0 +Patch450: disable_emulated_device.diff +%endif # novell_shim patches -Patch400: hv_tools.patch -Patch401: hv_xen_base.patch -Patch402: hv_xen_extension.patch +Patch500: hv_tools.patch +Patch501: hv_xen_base.patch +Patch502: hv_xen_extension.patch Patch999: tmp_build.patch Url: http://www.cl.cam.ac.uk/Research/SRG/netos/xen/ BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -585,100 +496,12 @@ Authors: %prep %setup -q -n %xen_build_dir -%patch0 -p1 -%patch1 -p1 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 -%patch5 -p1 -%patch6 -p1 -%patch7 -p1 -%patch8 -p1 -%patch9 -p1 -%patch10 -p1 -%patch11 -p1 -%patch12 -p1 -%patch13 -p1 -%patch14 -p1 -%patch15 -p1 -%patch16 -p1 -%patch17 -p1 -%patch18 -p1 -%patch19 -p1 -%patch20 -p1 -%patch21 -p1 -%patch22 -p1 -%patch23 -p1 -%patch24 -p1 -%patch25 -p1 -%patch26 -p1 -%patch27 -p1 -%patch28 -p1 -%patch29 -p1 -%patch30 -p1 -%patch31 -p1 -%patch32 -p1 -%patch33 -p1 -%patch34 -p1 -%patch35 -p1 -%patch36 -p1 -%patch37 -p1 -%patch38 -p1 -%patch39 -p1 -%patch40 -p1 -%patch41 -p1 -%patch42 -p1 -%patch43 -p1 -%patch44 -p1 -%patch45 -p1 -%patch46 -p1 -%patch47 -p1 -%patch48 -p1 -%patch49 -p1 -%patch50 -p1 -%patch51 -p1 -%patch52 -p1 -%patch53 -p1 -%patch54 -p1 -%patch55 -p1 -%patch56 -p1 -%patch57 -p1 -%patch58 -p1 -%patch59 -p1 -%patch60 -p1 -%patch61 -p1 -%patch62 -p1 -%patch63 -p1 -%patch64 -p1 -%patch65 -p1 -%patch66 -p1 -%patch67 -p1 -%patch68 -p1 -%patch69 -p1 -%patch70 -p1 -%patch71 -p1 -%patch72 -p1 -%patch73 -p1 -%patch74 -p1 -%patch75 -p1 -%patch76 -p1 -%patch77 -p1 -%patch78 -p1 -%patch79 -p1 -%patch80 -p1 -%patch81 -p1 -%patch82 -p1 -%patch83 -p1 -%patch84 -p1 -%patch85 -p1 -%patch86 -p1 -%patch87 -p1 -%patch88 -p1 %patch100 -p1 %patch101 -p1 %patch102 -p1 %patch103 -p1 %patch104 -p1 +%patch105 -p1 %patch106 -p1 %patch107 -p1 %patch108 -p1 @@ -687,10 +510,9 @@ Authors: %patch111 -p1 %patch112 -p1 %patch113 -p1 -%patch114 -p1 +#%patch114 -p1 - vnc patch, may no longer be applicable. %patch115 -p1 %patch116 -p1 -%patch119 -p1 %patch120 -p1 %patch121 -p1 %patch122 -p1 @@ -703,12 +525,11 @@ Authors: %patch134 -p1 %patch135 -p1 %patch136 -p1 -%patch137 -p1 %patch140 -p1 %patch150 -p1 %patch151 -p1 %patch152 -p1 -#%patch153 -p1 hostonly +#%patch153 -p1 - hostonly %patch154 -p1 %patch155 -p1 %patch156 -p1 @@ -722,45 +543,44 @@ Authors: %patch164 -p1 %patch165 -p1 %patch166 -p1 -%patch167 -p1 -%patch170 -p1 -%patch171 -p1 -%patch172 -p1 -%patch173 -p1 -%patch174 -p1 -%patch175 -p1 -%patch180 -p1 -%patch181 -p1 -%patch182 -p1 -%patch183 -p1 -%patch184 -p1 -%patch185 -p1 -%patch186 -p1 -%patch187 -p1 -%patch188 -p1 -%patch189 -p1 -%patch190 -p1 -%patch191 -p1 %patch200 -p1 -%patch240 -p1 -%patch241 -p1 -%patch242 -p1 -%patch243 -p1 -%patch244 -p1 -%patch245 -p1 -%patch350 -p1 -%patch351 -p1 -%patch352 -p1 -%patch353 -p1 -%patch354 -p1 -%patch355 -p1 -%patch356 -p1 -%patch357 -p1 -%patch358 -p1 -%ifarch x86_64 -%patch400 -p1 +%patch201 -p1 +%patch202 -p1 +%patch203 -p1 +%patch210 -p1 +%patch211 -p1 +%patch212 -p1 +%patch213 -p1 +%patch214 -p1 +%patch215 -p1 +%patch220 -p1 +%patch221 -p1 +%patch222 -p1 +%patch300 -p1 +#%patch340 -p1 - Port Later if needed +%patch341 -p1 +%patch342 -p1 +%patch343 -p1 +%patch344 -p1 +%patch345 -p1 +%patch346 -p1 +%patch347 -p1 +%patch348 -p1 +#%patch400 -p1 - Major Port or not needed %patch401 -p1 -%patch402 -p1 +#%patch402 -p1 - Needed? +%patch403 -p1 +%patch404 -p1 +%patch405 -p1 +%patch406 -p1 +%patch407 -p1 +%if %{?with_kmp}0 +%patch450 -p1 +%endif +%ifarch x86_64 +%patch500 -p1 +%patch501 -p1 +%patch502 -p1 %endif %patch999 -p1 @@ -884,6 +704,7 @@ install -m644 %SOURCE9 %SOURCE10 $RPM_BUILD_ROOT/etc/xen/examples/ # scripts rm -f $RPM_BUILD_ROOT/etc/xen/scripts/block-*nbd install -m755 %SOURCE11 %SOURCE12 %SOURCE13 %SOURCE16 %SOURCE17 $RPM_BUILD_ROOT/etc/xen/scripts/ +ln -s /etc/xen/scripts/xen-monitor $RPM_BUILD_ROOT/etc/xen/scripts/set-lock # Xen API remote authentication files install -d $RPM_BUILD_ROOT/etc/pam.d install -m644 %SOURCE23 $RPM_BUILD_ROOT/etc/pam.d/xen-api @@ -914,6 +735,7 @@ install -m755 %SOURCE8 $RPM_BUILD_ROOT/usr/lib/xen/boot/ # udev support mkdir -p $RPM_BUILD_ROOT/etc/udev/rules.d mv $RPM_BUILD_ROOT/etc/udev/rules.d/xen-backend.rules $RPM_BUILD_ROOT/etc/udev/rules.d/40-xen.rules +mv $RPM_BUILD_ROOT/etc/udev/rules.d/xend.rules $RPM_BUILD_ROOT/etc/udev/rules.d/40-xend.rules #%find_lang xen-vm # po files are misnamed upstream # Clean up unpackaged files rm -rf $RPM_BUILD_ROOT/%{_datadir}/doc/xen/qemu/ @@ -922,10 +744,12 @@ rm -rf $RPM_BUILD_ROOT/%{_defaultdocdir}/xen/ps rm -rf $RPM_BUILD_ROOT/usr/share/xen/man/man1/qemu/qemu* rm -f $RPM_BUILD_ROOT/usr/share/xen/qemu/openbios-sparc32 rm -f $RPM_BUILD_ROOT/usr/share/xen/qemu/openbios-sparc64 +rm -f $RPM_BUILD_ROOT/usr/share/xen/qemu/openbios-ppc rm -f $RPM_BUILD_ROOT/usr/sbin/netfix rm -f $RPM_BUILD_ROOT/%pysite/*.egg-info rm -rf $RPM_BUILD_ROOT/html rm -rf $RPM_BUILD_ROOT/usr/share/doc/xen/README.* +rm -f $RPM_BUILD_ROOT/usr/share/doc/xen/create.dtd rm -f $RPM_BUILD_ROOT/%{_libdir}/xen/bin/qemu-dm.debug %files @@ -959,6 +783,7 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/xen/bin/qemu-dm.debug /usr/bin/xentrace* /usr/bin/pygrub /usr/bin/qemu-img-xen +/usr/bin/qemu-nbd-xen /usr/bin/tapdisk-ioemu /usr/bin/gdbserver-xen /usr/sbin/blktapctrl @@ -980,7 +805,7 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/xen/bin/qemu-dm.debug %dir /usr/lib/xen/bin %endif %dir /usr/lib/xen/boot -%{_datadir}/xen/*.dtd +#%{_datadir}/xen/*.dtd %{_libdir}/xen/bin/readnotes %{_libdir}/xen/bin/xc_restore %{_libdir}/xen/bin/xc_save @@ -1022,6 +847,7 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/xen/bin/qemu-dm.debug %dir /etc/udev %dir /etc/udev/rules.d /etc/udev/rules.d/40-xen.rules +/etc/udev/rules.d/40-xend.rules /etc/sysconfig/network/scripts/xen-updown.sh /etc/sysconfig/network/if-up.d/xen /etc/sysconfig/network/if-down.d/xen @@ -1037,10 +863,12 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/xen/bin/qemu-dm.debug %dir %{_datadir}/xen %dir %{_datadir}/xen/man %dir %{_datadir}/xen/man/man1 +%dir %{_datadir}/xen/man/man8 %dir %{_datadir}/xen/qemu %dir %{_datadir}/xen/qemu/keymaps %{_datadir}/xen/qemu/* %{_datadir}/xen/man/man1/* +%{_datadir}/xen/man/man8/* %{_libdir}/xen/bin/qemu-dm %ifarch x86_64 /usr/lib/xen/bin/qemu-dm @@ -1108,10 +936,42 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/xen/bin/qemu-dm.debug /sbin/ldconfig %changelog +* Wed Apr 22 2009 wkong@novell.com +- Backport two qcow2 patches from qemu org + ioemu-6816-qcow2-revert-6404-6405-6407.patch + ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch +* Fri Apr 17 2009 wkong@novell.com +- bnc#477890 - Patch: ioemu-qcow2-enhance-snapshot-create.patch +* Thu Apr 16 2009 jfehlig@novell.com +- Updated xend-domain-lock.patch + fate#303525, bnc#494892 +* Thu Apr 09 2009 wkong@novell.com +- Remove Patch155: xend-core-dump-loc.diff +- Modify Patch110: xen-domUloader.diff, + remove symbol "bootfilter" +* Wed Apr 08 2009 wkong@novell.com +- PATCH: network-nat-open-SuSEfirewall2-FORWARD.patch + fate#305354, bnc#472107 + Open SuSEfirewall2 FORWARD rule when use xen nat +- PATCH: network-nat-dhcpd-domain-info.patch + Add domain info for nat-dhcpd +* Thu Apr 02 2009 jfehlig@novell.com +- Fix domUloader to handle block device names with ':' +* Wed Mar 11 2009 jfehlig@novell.com +- Use pidofproc/checkproc in xend init script +* Tue Mar 03 2009 kukuk@suse.de +- Don't load 8139* driver if xen-vnif works [bnc#480164] * Fri Feb 27 2009 carnold@novell.com - bnc#480164 - Default network proposal in fully virtualized SLES 11 VM is invalid. xen_pvdrivers +* Thu Feb 26 2009 carnold@novell.com +- bnc#474822 - L3: Win2003 i386 XEN VM can see only 2 TB with a + 4TB LUN. + int13_hardisk-64bit-lba.patch +* Wed Feb 25 2009 jfehlig@novell.com +- bnc#477890 - Destroy domain if snapshot restore fails. + Updated snapshot-xend.patch * Tue Feb 24 2009 ksrinivasan@novell.com - bnc#470238 - SLE11 32FV guest is hanging during certification tests. @@ -1119,6 +979,13 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/xen/bin/qemu-dm.debug bnc#469598 - SLES11 RC2 64bit Xen - SLES11 full virt guests hanging under load. disable_emulated_device.diff +* Tue Feb 24 2009 kwolf@suse.de +- bnc#477892 - Disable xend timeout for snapshots + Updated snapshot-xend.patch +* Tue Feb 24 2009 kwolf@suse.de +- bnc#477895 - Fix detaching blktap disks from domains without + device model + Updated blktap-ioemu-close-fix.patch * Fri Feb 20 2009 kwolf@suse.de - bnc#472390 - Enable debuginfo for ioemu ioemu-debuginfo.patch @@ -1290,7 +1157,7 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/xen/bin/qemu-dm.debug vcpus > VCPUs_max on running domain. * Tue Oct 21 2008 carnold@novell.com - Update to changeset 18455. -* Thu Oct 16 2008 olh@suse.de +* Fri Oct 17 2008 olh@suse.de - add ExclusiveArch x86 x86_64 * Wed Oct 15 2008 jfehlig@novell.com - bnc#433722 - Fix handling of default bridge in qemu-ifup. @@ -1567,7 +1434,7 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/xen/bin/qemu-dm.debug - #298176: Do not enable NX if CPU/BIOS does not support it - #289569: Modify network-bridge to handle vlan - #297295: Fix bridge setup: stop using getcfg -* Mon Aug 06 2007 olh@suse.de +* Tue Aug 07 2007 olh@suse.de - remove inclusion of linux/compiler.h and linux/string.h remove ExclusiveArch and fix prep section for quilt setup *.spec * Thu Aug 02 2007 jfehlig@novell.com @@ -2846,7 +2713,7 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/xen/bin/qemu-dm.debug - tgif not needed any more. * Tue Mar 01 2005 garloff@suse.de - Include serial-split from Charles Coffing. -* Mon Feb 28 2005 garloff@suse.de +* Tue Mar 01 2005 garloff@suse.de - Update xen to latest snapshot. * Mon Feb 21 2005 garloff@suse.de - Update README.SuSE. diff --git a/xenapi-console-protocol.patch b/xenapi-console-protocol.patch index e74d9f5..c3d2f7f 100644 --- a/xenapi-console-protocol.patch +++ b/xenapi-console-protocol.patch @@ -1,8 +1,8 @@ -Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -3247,6 +3247,14 @@ class XendDomainInfo: +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py +@@ -3570,6 +3570,14 @@ class XendDomainInfo: if not config.has_key('backend'): config['backend'] = "00000000-0000-0000-0000-000000000000" diff --git a/xend-config.diff b/xend-config.diff index 5afb622..bd97ece 100644 --- a/xend-config.diff +++ b/xend-config.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/examples/init.d/sysconfig.xendomains +Index: xen-3.4.0-testing/tools/hotplug/Linux/init.d/sysconfig.xendomains =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/init.d/sysconfig.xendomains -+++ xen-3.3.1-testing/tools/examples/init.d/sysconfig.xendomains +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/init.d/sysconfig.xendomains ++++ xen-3.4.0-testing/tools/hotplug/Linux/init.d/sysconfig.xendomains @@ -1,4 +1,4 @@ -## Path: System/xen +## Path: System/Virtualization @@ -27,11 +27,11 @@ Index: xen-3.3.1-testing/tools/examples/init.d/sysconfig.xendomains ## Type: integer ## Default: 300 -Index: xen-3.3.1-testing/tools/examples/xend-config.sxp +Index: xen-3.4.0-testing/tools/examples/xend-config.sxp =================================================================== ---- xen-3.3.1-testing.orig/tools/examples/xend-config.sxp -+++ xen-3.3.1-testing/tools/examples/xend-config.sxp -@@ -54,11 +54,12 @@ +--- xen-3.4.0-testing.orig/tools/examples/xend-config.sxp ++++ xen-3.4.0-testing/tools/examples/xend-config.sxp +@@ -58,11 +58,12 @@ #(xend-http-server no) @@ -44,9 +44,9 @@ Index: xen-3.3.1-testing/tools/examples/xend-config.sxp #(xend-relocation-server no) -(xend-relocation-server yes) #(xend-relocation-ssl-server no) + #(xend-udev-event-server no) - #(xend-unix-path /var/lib/xend/xend-socket) -@@ -140,7 +141,8 @@ +@@ -145,7 +146,8 @@ # # (network-script 'network-bridge netdev=eth1') # @@ -56,7 +56,7 @@ Index: xen-3.3.1-testing/tools/examples/xend-config.sxp # # (network-script 'network-bridge bridge=') # -@@ -149,7 +151,12 @@ +@@ -154,7 +156,12 @@ # two fake interfaces per guest domain. To do things like this, write # yourself a wrapper script, and call network-bridge from it, as appropriate. # @@ -64,13 +64,13 @@ Index: xen-3.3.1-testing/tools/examples/xend-config.sxp +# SuSE users note: +# On openSUSE >= 11.1 and SLES >= 11, networks should be configured using +# native platform tool - YaST. vif-bridge and qemu-ifup can be used to -+# connect vifs to the YaST-managed networks. ++# connect vifs to the YaST-managed networks. +#(network-script network-bridge) +(network-script ) # The script used to control virtual interfaces. This can be overridden on a # per-vif basis when creating a domain or a configuring a new vif. The -@@ -181,7 +188,7 @@ +@@ -186,7 +193,7 @@ # dom0-min-mem is the lowest permissible memory level (in MB) for dom0. # This is a minimum both for auto-ballooning (as enabled by # enable-dom0-ballooning below) and for xm mem-set when applied to dom0. diff --git a/xend-core-dump-loc.diff b/xend-core-dump-loc.diff index c2f3277..f325310 100644 --- a/xend-core-dump-loc.diff +++ b/xend-core-dump-loc.diff @@ -1,13 +1,13 @@ -Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py +Index: xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1867,7 +1867,7 @@ class XendDomainInfo: - try: - if not corefile: - this_time = time.strftime("%Y-%m%d-%H%M.%S", time.localtime()) -- corefile = "/var/xen/dump/%s-%s.%s.core" % (this_time, -+ corefile = "/var/lib/xen/dump/%s-%s.%s.core" % (this_time, - self.info['name_label'], self.domid) +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py +@@ -2117,7 +2117,7 @@ class XendDomainInfo: + + if not corefile: + this_time = time.strftime("%Y-%m%d-%H%M.%S", time.localtime()) +- corefile = "/var/xen/dump/%s-%s.%s.core" % (this_time, ++ corefile = "/var/lib/xen/dump/%s-%s.%s.core" % (this_time, + self.info['name_label'], self.domid) - if os.path.isdir(corefile): + if os.path.isdir(corefile): diff --git a/xend-domain-lock.patch b/xend-domain-lock.patch index 3156cbe..83550a2 100644 --- a/xend-domain-lock.patch +++ b/xend-domain-lock.patch @@ -1,12 +1,272 @@ -Index: xen-3.3.1-testing/tools/examples/domain-lock +Index: xen-3.4.0-testing/tools/examples/xend-config.sxp +=================================================================== +--- xen-3.4.0-testing.orig/tools/examples/xend-config.sxp ++++ xen-3.4.0-testing/tools/examples/xend-config.sxp +@@ -260,4 +260,64 @@ + + # Path where persistent domain configuration is stored. + # Default is /var/lib/xend/domains/ ++# + #(xend-domains-path /var/lib/xend/domains) ++ ++# Domain Locking ++# In a multihost environment, domain locking prevents simultaneously ++# running a domain on more than one host. ++# ++# If enabled, xend will execute a external lock utility (defined below) ++# on each domain start and stop event. Disabled by default. Set to yes ++# to enable domain locking. ++# ++#(xend-domain-lock no) ++ ++# Path where domain lock is stored if xend-domain-lock is enabled. ++# Note: This path must be accessible to all VM Servers participating ++# in domain locking, e.g. by specifying a shared mount point. ++# Lock is placed in //. ++# Default is /var/lib/xend/domains/ ++# ++#(xend-domain-lock-path /var/lib/xend/domains) ++ ++# External locking utility called by xend for acquiring/releasing ++# domain lock. By default /etc/xen/scripts/domain-lock will be used ++# if xend-domain-lock is set to yes. Set to path of custom locking ++# utility to override the default. ++# ++# Synopsis of lock-util: ++# lock-util [-l|-u] -n -i -p path" ++# -l Acquire (create) lock ++# -u Remove lock ++# -n vm-name Name of domain ++# -i vm-id Id or UUID of domain ++# -p phy-host Name of physical host (dom0) ++# path // ++# Return 0 on success, non-zero on error. ++# ++# lock-util [-s] path" ++# -s Lock status. If lock is acquired, print any contents ++# on stdout and return 0. Return non-zero if lock is ++# available. ++# path // ++# If lock is acquired, print any contents on stdout and return 0. ++# Return non-zero if lock is available. ++# ++# Default lock-util behavior: ++# On domain start event, domain-lock will create and flock(1) ++# ///lock. Every two seconds it ++# will write , , , and to the lock. ++# is running counter. ++# On domain stop event, domain-lock will unlock and remove ++# ///lock. ++# ++# Note: If xend-domain-lock-path is a cluster-unaware file system, ++# administrator intervention may be required to remove stale ++# locks. Consider two hosts using NFS for xend-domain-lock-path ++# when HostA, running vm1, crashes. HostB could not acquire a ++# lock for vm1 since the NFS server holds an exclusive lock ++# acquired by HostA. The lock file must be manually removed ++# before starting vm1 on HostA. ++# ++#(xend-domain-lock-utility domain-lock) +Index: xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py +=================================================================== +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendDomainInfo.py +@@ -30,11 +30,13 @@ import threading + import re + import copy + import os ++import stat ++import shutil + import traceback + from types import StringTypes + + import xen.lowlevel.xc +-from xen.util import asserts ++from xen.util import asserts, mkdir + from xen.util.blkif import parse_uname + import xen.util.xsm.xsm as security + from xen.util import xsconstants +@@ -452,6 +454,7 @@ class XendDomainInfo: + + if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, XEN_API_VM_POWER_STATE_SUSPENDED, XEN_API_VM_POWER_STATE_CRASHED): + try: ++ self.acquire_running_lock(); + XendTask.log_progress(0, 30, self._constructDomain) + XendTask.log_progress(31, 60, self._initDomain) + +@@ -2626,6 +2629,11 @@ class XendDomainInfo: + + self._stateSet(DOM_STATE_HALTED) + self.domid = None # Do not push into _stateSet()! ++ ++ try: ++ self.release_running_lock() ++ except: ++ log.exception("Failed to release domain lock.") + finally: + self.refresh_shutdown_lock.release() + +@@ -3992,6 +4000,74 @@ class XendDomainInfo: + def has_device(self, dev_class, dev_uuid): + return (dev_uuid in self.info['%s_refs' % dev_class.lower()]) + ++ # Return name of host contained in lock file. ++ def get_lock_host(self, path): ++ fin = os.popen(xoptions.get_xend_domain_lock_utility() + \ ++ ' -s ' + path, 'r') ++ hostname = "unknown" ++ ++ try: ++ tokens = fin.readline().split() ++ for token in tokens: ++ item = token.split('=') ++ if item[0] == 'host': ++ hostname = item[1] ++ return hostname ++ finally: ++ fin.close() ++ ++ # Acquire a lock for the domain. No-op if domain locking is turned off. ++ def acquire_running_lock(self): ++ if not xoptions.get_xend_domain_lock(): ++ return ++ ++ log.debug("Acquiring lock for domain %s" % self.info['name_label']) ++ path = xoptions.get_xend_domain_lock_path() ++ path = os.path.join(path, self.get_uuid()) ++ ++ try: ++ if not os.path.exists(path): ++ mkdir.parents(path, stat.S_IRWXU) ++ except: ++ log.exception("%s could not be created." % path) ++ raise XendError("%s could not be created." % path) ++ ++ status = os.system('%s -l -p %s -n %s -i %s %s' % \ ++ (xoptions.get_xend_domain_lock_utility(), \ ++ XendNode.instance().get_name(), \ ++ self.info['name_label'], \ ++ self.info['uuid'], \ ++ path)) ++ if status != 0: ++ log.debug("Failed to aqcuire lock: status = %d" % status) ++ raise XendError("The VM is locked and appears to be running on host %s." % self.get_lock_host(path)) ++ ++ # Release lock for domain. No-op if domain locking is turned off. ++ def release_running_lock(self, name = None): ++ if not xoptions.get_xend_domain_lock(): ++ return ++ ++ dom_name = self.info['name_label'] ++ if name: ++ dom_name = name ++ log.debug("Releasing lock for domain %s" % dom_name) ++ ++ path = xoptions.get_xend_domain_lock_path() ++ path = os.path.join(path, self.get_uuid()) ++ status = os.system('%s -u -p %s -n %s -i %s %s' % \ ++ (xoptions.get_xend_domain_lock_utility(), \ ++ XendNode.instance().get_name(), \ ++ dom_name, \ ++ self.info['uuid'], \ ++ path)) ++ if status != 0: ++ log.exception("Failed to release lock: status = %s" % status) ++ try: ++ if len(os.listdir(path)) == 0: ++ shutil.rmtree(path) ++ except: ++ log.exception("Failed to remove unmanaged directory %s." % path) ++ + def __str__(self): + return '' % \ + (str(self.domid), self.info['name_label'], +Index: xen-3.4.0-testing/tools/python/xen/xend/XendOptions.py +=================================================================== +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendOptions.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendOptions.py +@@ -141,6 +141,17 @@ class XendOptions: + """Default rotation count of qemu-dm log file.""" + qemu_dm_logrotate_count = 10 + ++ """Default for the flag indicating whether xend should create ++ a lock file for domains when they are started.""" ++ xend_domain_lock = 'no' ++ ++ """Default domain lock storage path.""" ++ xend_domain_lock_path_default = '/var/lib/xend/domains' ++ ++ """Default script to acquire/release domain lock""" ++ xend_domain_lock_utility = osdep.scripts_dir + "/domain-lock" ++ ++ + def __init__(self): + self.configure() + +@@ -368,6 +379,19 @@ class XendOptions: + return self.get_config_int("qemu-dm-logrotate-count", + self.qemu_dm_logrotate_count) + ++ def get_xend_domain_lock(self): ++ """Get the flag indicating whether xend should create a lock file ++ for domains when they are started.""" ++ return self.get_config_bool("xend-domain-lock", self.xend_domain_lock) ++ ++ def get_xend_domain_lock_path(self): ++ """ Get the path for domain lock storage ++ """ ++ return self.get_config_string("xend-domain-lock-path", self.xend_domain_lock_path_default) ++ ++ def get_xend_domain_lock_utility(self): ++ return self.get_config_string('xend-domain-lock-utility', self.xend_domain_lock_utility) ++ + + class XendOptionsFile(XendOptions): + +Index: xen-3.4.0-testing/tools/python/xen/xend/XendCheckpoint.py +=================================================================== +--- xen-3.4.0-testing.orig/tools/python/xen/xend/XendCheckpoint.py ++++ xen-3.4.0-testing/tools/python/xen/xend/XendCheckpoint.py +@@ -117,6 +117,7 @@ def save(fd, dominfo, network, live, dst + dominfo.shutdown('suspend') + dominfo.waitForSuspend() + if line in ('suspend', 'suspended'): ++ dominfo.release_running_lock(domain_name) + dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP2, + domain_name) + log.info("Domain %d suspended.", dominfo.getDomid()) +@@ -399,6 +400,7 @@ def restore(xd, fd, dominfo = None, paus + if not paused: + dominfo.unpause() + ++ dominfo.acquire_running_lock() + return dominfo + except: + dominfo.destroy() +Index: xen-3.4.0-testing/tools/hotplug/Linux/Makefile +=================================================================== +--- xen-3.4.0-testing.orig/tools/hotplug/Linux/Makefile ++++ xen-3.4.0-testing/tools/hotplug/Linux/Makefile +@@ -20,6 +20,7 @@ XEN_SCRIPTS += vtpm vtpm-delete + XEN_SCRIPTS += xen-hotplug-cleanup + XEN_SCRIPTS += external-device-migrate + XEN_SCRIPTS += vscsi ++XEN_SCRIPTS += domain-lock xen-monitor + XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh + XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh + XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh vtpm-hotplug-common.sh +Index: xen-3.4.0-testing/tools/hotplug/Linux/domain-lock =================================================================== --- /dev/null -+++ xen-3.3.1-testing/tools/examples/domain-lock ++++ xen-3.4.0-testing/tools/hotplug/Linux/domain-lock @@ -0,0 +1,83 @@ +#!/bin/bash + ++basedir=$(dirname "$0") ++ +usage() { -+ echo "usage: domain-lock [-l|-u|-s] [-n ] [-i ] [-p ] path" ++ echo "usage: domain-lock [-l|-u] -n -i -p path" ++ echo "usage: domain-lock [-s] path" + echo "" + echo "-l lock" + echo "-u unlock" @@ -18,29 +278,24 @@ Index: xen-3.3.1-testing/tools/examples/domain-lock + exit 1 +} + -+create_lock() { -+ local path=$1 -+ local name=$2 -+ local uuid=$3 -+ local host=$4 -+ -+ path=$path/lock -+ cat > $path < on domain -+# startup and removed when domain is stopped. By default, a lock file -+# is not created. Set to yes to enable lock file creation. -+# Note that external locking mechanisms are no substitute for a cluster -+# environment that protects shared resources, but may be useful in -+# some circumstances nonetheless. -+# -+#(xend-domain-lock no) ++basedir=$(dirname "$0") ++HA_TICK=2 + -+# Path where domain lock is stored if xend-domain-lock is enabled. -+# Note: This path must be accessible to all VM Servers participating -+# in domain locking, e.g. by specifying a shared mount point. -+# Lock is placed in /. -+# Default is /var/lib/xend/domains/ -+# -+#(xend-domain-lock-path /var/lib/xend/domains) ++monitor() { ++ local path=$1 ++ local name=$2 ++ local uuid=$3 ++ local host=$4 ++ local count=0 ++ path=$path/lock + -+# External locking utility for acquiring/releasing domain lock. -+# By default /etc/xen/scripts/domain-lock will be used if -+# xend-domain-lock is set to yes. Set to path of custom -+# locking utility to override the default. Synopsis: -+# -+# lock-util <-l | -u | -s> [-n ] [-i ] [-p ] path -+# -+# Utility should return zero on success, non-zero on error. -+# -l lock Acquire (create) lock file -+# -u unlock Remove lock file -+# -s status Default action. If lock file exists, print contents on -+# stdout and return 0) -+# -p phy-host Name of physical host (dom0) -+# -n vm-name Name of domain -+# -i vm-id Id or UUID of domain -+# path A unique location for external lock must be specified -+# -+# The /etc/xen/scripts/domain-lock default utility will create -+# //lock and write , , -+# and (if supplied) to the lock file in that order. -+# -+#(xend-domain-lock-utility domain-lock) -Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -30,11 +30,13 @@ import threading - import re - import copy - import os -+import stat -+import shutil - import traceback - from types import StringTypes - - import xen.lowlevel.xc --from xen.util import asserts -+from xen.util import asserts, mkdir - from xen.util.blkif import parse_uname - import xen.util.xsm.xsm as security - from xen.util import xsconstants -@@ -443,6 +445,7 @@ class XendDomainInfo: - - if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, XEN_API_VM_POWER_STATE_SUSPENDED, XEN_API_VM_POWER_STATE_CRASHED): - try: -+ self.acquire_running_lock(); - XendTask.log_progress(0, 30, self._constructDomain) - XendTask.log_progress(31, 60, self._initDomain) - -@@ -475,6 +478,7 @@ class XendDomainInfo: - state = self._stateGet() - if state in (DOM_STATE_SUSPENDED, DOM_STATE_HALTED): - try: -+ self.acquire_running_lock(); - self._constructDomain() - - try: -@@ -2339,6 +2343,11 @@ class XendDomainInfo: - - self._stateSet(DOM_STATE_HALTED) - self.domid = None # Do not push into _stateSet()! ++ while : ++ do ++ echo "name=$name uuid=$uuid host=$host count=$count" > $path ++ count=$(($count+1)) ++ sleep $HA_TICK ++ done& ++} + -+ try: -+ self.release_running_lock() -+ except: -+ log.exception("Failed to release domain lock.") - finally: - self.refresh_shutdown_lock.release() - -@@ -3560,6 +3569,74 @@ class XendDomainInfo: - def has_device(self, dev_class, dev_uuid): - return (dev_uuid in self.info['%s_refs' % dev_class.lower()]) - -+ # Check if domain has a lock file present -+ def is_dom_locked(self, path): -+ status = os.system('%s -s %s' % \ -+ (xoptions.get_xend_domain_lock_utility(), \ -+ path)) ++create_lock() { ++ local path=$1/lock ++ local rc=0 + -+ return status == 0 ++ [ -f $path ] || touch $path ++ flock -x -w $HA_TICK $path $basedir/xen-monitor $* ++ rc=$? ++ if [ $rc -eq 1 ]; then ++ echo `cat $path` ++ exit 1 ++ else ++ exit $rc ++ fi ++} + -+ # Return name of host contained in lock file. Host should be last -+ # entry in the lock file. -+ def get_lock_host(self, path): -+ fin = os.popen(xoptions.get_xend_domain_lock_utility() + \ -+ ' -s ' + path, 'r') -+ hostname = "unknown" -+ -+ try: -+ line = fin.readline() -+ hostname = line.split()[-1] -+ return hostname -+ finally: -+ fin.close() -+ -+ # Acquire a lock for the domain. No-op if domain locking is turned off. -+ def acquire_running_lock(self): -+ if not xoptions.get_xend_domain_lock(): -+ return -+ -+ path = xoptions.get_xend_domain_lock_path() -+ path = os.path.join(path, self.get_uuid()) -+ -+ if self.is_dom_locked(path): -+ raise XendError("The VM is locked and appears to be running on host %s." % self.get_lock_host(path)) -+ -+ try: -+ if not os.path.exists(path): -+ mkdir.parents(path, stat.S_IRWXU) -+ except: -+ log.exception("%s could not be created." % path) -+ raise XendError("%s could not be created." % path) -+ -+ status = os.system('%s -l -p %s -n %s -i %s %s' % \ -+ (xoptions.get_xend_domain_lock_utility(), \ -+ XendNode.instance().get_name(), \ -+ self.info['name_label'], \ -+ self.info['uuid'], \ -+ path)) -+ if status != 0: -+ raise XendError('Acquire running lock failed: %s' % status) -+ -+ # Release lock for domain. Should be called at end of domain cleanup -+ def release_running_lock(self): -+ if not xoptions.get_xend_domain_lock(): -+ return -+ -+ path = xoptions.get_xend_domain_lock_path() -+ path = os.path.join(path, self.get_uuid()) -+ status = os.system('%s -u %s' % \ -+ (xoptions.get_xend_domain_lock_utility(), \ -+ path)) -+ if status != 0: -+ log.exception("Release running lock failed: %s" % status) -+ try: -+ if len(os.listdir(path)) == 0: -+ shutil.rmtree(path) -+ except: -+ log.exception("Failed to remove unmanaged directory %s." % path) -+ -+ - def __str__(self): - return '' % \ - (str(self.domid), self.info['name_label'], -Index: xen-3.3.1-testing/tools/python/xen/xend/XendDomain.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendDomain.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendDomain.py -@@ -1299,6 +1299,7 @@ class XendDomain: - POWER_STATE_NAMES[DOM_STATE_RUNNING], - POWER_STATE_NAMES[dominfo._stateGet()]) - -+ dominfo.release_running_lock(); - """ The following call may raise a XendError exception """ - dominfo.testMigrateDevices(True, dst) - -Index: xen-3.3.1-testing/tools/python/xen/xend/XendOptions.py -=================================================================== ---- xen-3.3.1-testing.orig/tools/python/xen/xend/XendOptions.py -+++ xen-3.3.1-testing/tools/python/xen/xend/XendOptions.py -@@ -135,6 +135,17 @@ class XendOptions: - """Default rotation count of qemu-dm log file.""" - qemu_dm_logrotate_count = 10 - -+ """Default for the flag indicating whether xend should create -+ a lock file for domains when they are started.""" -+ xend_domain_lock = 'no' -+ -+ """Default domain lock storage path.""" -+ xend_domain_lock_path_default = '/var/lib/xend/domains' -+ -+ """Default script to acquire/release domain lock""" -+ xend_domain_lock_utility = osdep.scripts_dir + "/domain-lock" -+ -+ - def __init__(self): - self.configure() - -@@ -358,6 +369,19 @@ class XendOptions: - return self.get_config_int("qemu-dm-logrotate-count", - self.qemu_dm_logrotate_count) - -+ def get_xend_domain_lock(self): -+ """Get the flag indicating whether xend should create a lock file -+ for domains when they are started.""" -+ return self.get_config_bool("xend-domain-lock", self.xend_domain_lock) -+ -+ def get_xend_domain_lock_path(self): -+ """ Get the path for domain lock storage -+ """ -+ return self.get_config_string("xend-domain-lock-path", self.xend_domain_lock_path_default) -+ -+ def get_xend_domain_lock_utility(self): -+ return self.get_config_string('xend-domain-lock-utility', self.xend_domain_lock_utility) -+ - - class XendOptionsFile(XendOptions): - -Index: xen-3.3.1-testing/tools/examples/Makefile -=================================================================== ---- xen-3.3.1-testing.orig/tools/examples/Makefile -+++ xen-3.3.1-testing/tools/examples/Makefile -@@ -35,6 +35,7 @@ XEN_SCRIPTS += vtpm vtpm-delete - XEN_SCRIPTS += xen-hotplug-cleanup - XEN_SCRIPTS += external-device-migrate - XEN_SCRIPTS += vscsi -+XEN_SCRIPTS += domain-lock - XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh - XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh - XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh vtpm-hotplug-common.sh ++if [ $0 = "$basedir/set-lock" ]; then ++ create_lock $* ++elif [ $0 = "$basedir/xen-monitor" ]; then ++ monitor $* ++fi diff --git a/xm-test-cleanup.diff b/xm-test-cleanup.diff index dc978f5..1198721 100644 --- a/xm-test-cleanup.diff +++ b/xm-test-cleanup.diff @@ -1,7 +1,7 @@ -Index: xen-3.3.1-testing/tools/xm-test/tests/save/01_save_basic_pos.py +Index: xen-3.4.0-testing/tools/xm-test/tests/save/01_save_basic_pos.py =================================================================== ---- xen-3.3.1-testing.orig/tools/xm-test/tests/save/01_save_basic_pos.py -+++ xen-3.3.1-testing/tools/xm-test/tests/save/01_save_basic_pos.py +--- xen-3.4.0-testing.orig/tools/xm-test/tests/save/01_save_basic_pos.py ++++ xen-3.4.0-testing/tools/xm-test/tests/save/01_save_basic_pos.py @@ -35,3 +35,9 @@ if s != 0: # Make sure it's gone if isDomainRunning(domain.getName()): diff --git a/xmclone.sh b/xmclone.sh index 3a51af4..0223a75 100644 --- a/xmclone.sh +++ b/xmclone.sh @@ -23,7 +23,7 @@ # # Defaults # -VERSION=0.4.4 +VERSION=0.4.5 XEN_CONFIGS=/etc/xen/vm/ XEN_BASE=/var/lib/xen/images/ SOURCE= @@ -426,6 +426,18 @@ then [ -z "$IP" ] && break done + if [ -z "$MASK" ] + then + echo "You have not specified a network mask in bits. Please enter one now. Default is 24 " + read -p "Network mask? " MASK + fi + while [ -n "$MASK" ] && [ "${MASK/**/ok}" != "ok" ] + do + echo "The Network mask you specified is invalid. If you wish, enter a new one now." + read -p "Network mask? " MASK + [ -z "$MASK" ] && MASK=24 + done + if [ -z "$MAC" ] then newMAC="" @@ -461,6 +473,7 @@ then else HOSTNAME= IP= + MASK= MAC= fi @@ -646,12 +659,27 @@ then pushd "$tmpdir" > /dev/null + # + # Find out if we are looking at SLE10 + # + SLE10= + if [ -f etc/SuSE-release ] + then + OSVER=`cat etc/SuSE-release | sed -n 1p | awk -F'(' '{ print $1 }' | sed 's/ $//g'` + if [ "$OSVER" == "openSUSE 10" -o \ + "$OSVER" == "SUSE Linux Enterprise Server 10" -o \ + "$OSVER" == "SUSE Linux Enterprise Desktop 10" ] + then + SLE10=1 + fi + fi + # # Change the Network Configuration in the mounted image file # if [ -n "$MAC" ] then - if [ -d etc/sysconfig/network/ ] + if [ "$SLE10" -a -d etc/sysconfig/network/ ] then echo "Changing the Network configuration in the newly copied image." pushd "etc/sysconfig/network/" > /dev/null @@ -672,13 +700,19 @@ then if [ -d etc/udev/rules.d/ ] then - # The 30-net_persistent_names.rules file - # controls which interface to use. + # The 30-net_persistent_names.rules or 70-persistent-net.rules + # file controls which interface to use. # By removing the SUBSYSTEM== lines, we force # the system to recreate it. pushd "etc/udev/rules.d/" > /dev/null - sed -i -e "/SUBSYSTEM==/d" \ - 30-net_persistent_names.rules + if [ "$SLE10" ] + then + sed -i -e "/SUBSYSTEM==/d" \ + 30-net_persistent_names.rules + else + sed -i -e "/SUBSYSTEM==/d" \ + 70-persistent-net.rules + fi popd > /dev/null fi fi @@ -693,8 +727,14 @@ then echo "Modify the IP Address of the new domU." pushd "etc/sysconfig/network/" > /dev/null - sed -i -e "s,^IPADDR=.*$,IPADDR=$IP," \ - ifcfg-eth-id-$MAC + if [ "$SLE10" ] + then + sed -i -e "s,^IPADDR=.*$,IPADDR=$IP," \ + ifcfg-eth-id-$MAC + else + sed -i -e "s,^IPADDR=.*$,IPADDR=$IP/$MASK," \ + ifcfg-eth0 + fi popd > /dev/null fi fi