From 2a4ad3da255d5eb96e7e5b215a2d2213f92cced2e5b96d026227c800532e461f Mon Sep 17 00:00:00 2001 From: OBS User buildservice-autocommit Date: Thu, 21 Apr 2011 10:07:55 +0000 Subject: [PATCH 1/4] Updating link to change in openSUSE:Factory/xen revision 132.0 OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=3dd8450c8f49ee2e81f8cbcaf99cdde4 --- xen.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen.spec b/xen.spec index ebd6f55..d5e05fe 100644 --- a/xen.spec +++ b/xen.spec @@ -80,7 +80,7 @@ BuildRequires: glibc-devel BuildRequires: kernel-source kernel-syms module-init-tools xorg-x11 %endif Version: 4.1.0_01 -Release: 7 +Release: 9 License: GPLv2+ Group: System/Kernel AutoReqProv: on From 833c8a5dc8cd2c0b899017edf1484bb0a66691b10f7f1de706223aad9fe6b861 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Thu, 21 Apr 2011 14:34:47 +0000 Subject: [PATCH 2/4] - bnc#685189: update vif-route-ifup.patch to use correct variable after upstream commit 22910:d4bc41a8cecb OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=114 --- vif-route-ifup.patch | 84 ++++++++++++++++++++++++-------------------- xen.changes | 6 ++++ 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/vif-route-ifup.patch b/vif-route-ifup.patch index ea75bce..3124b8d 100644 --- a/vif-route-ifup.patch +++ b/vif-route-ifup.patch @@ -1,42 +1,9 @@ -Index: xen-4.1.0-testing/tools/hotplug/Linux/vif-route-ifup -=================================================================== ---- /dev/null -+++ xen-4.1.0-testing/tools/hotplug/Linux/vif-route-ifup -@@ -0,0 +1,34 @@ -+#!/bin/bash -+#============================================================================ -+# /etc/xen/vif-route-ifup -+# -+# Script for configuring a vif in routed mode. -+# The hotplugging system will call this script if it is specified either in -+# the device configuration given to Xend, or the default Xend configuration -+# in /etc/xen/xend-config.sxp. If the script is specified in neither of those -+# places, then vif-bridge is the default. -+# -+# Usage: -+# vif-route-ifup (add|remove|online|offline) -+# -+# Environment vars: -+# vif vif interface name (required). -+#============================================================================ -+ -+dir=$(dirname "$0") -+. "$dir/vif-common.sh" -+ -+case "$command" in -+ online) -+ ifup ${vif} -+ ;; -+ offline) -+ do_without_error ifdown ${vif} -+ ;; -+esac -+ -+log debug "Successful vif-route-ifup $command for $vif." -+if [ "$command" = "online" ] -+then -+ success -+fi +--- + tools/examples/xend-config.sxp | 20 ++++++++++++++++++++ + tools/hotplug/Linux/Makefile | 2 +- + tools/hotplug/Linux/vif-route-ifup | 34 ++++++++++++++++++++++++++++++++++ + 3 files changed, 55 insertions(+), 1 deletion(-) + Index: xen-4.1.0-testing/tools/examples/xend-config.sxp =================================================================== --- xen-4.1.0-testing.orig/tools/examples/xend-config.sxp @@ -81,3 +48,42 @@ Index: xen-4.1.0-testing/tools/hotplug/Linux/Makefile XEN_SCRIPTS += network-nat vif-nat XEN_SCRIPTS += vif2 XEN_SCRIPTS += vif-setup +Index: xen-4.1.0-testing/tools/hotplug/Linux/vif-route-ifup +=================================================================== +--- /dev/null ++++ xen-4.1.0-testing/tools/hotplug/Linux/vif-route-ifup +@@ -0,0 +1,34 @@ ++#!/bin/bash ++#============================================================================ ++# /etc/xen/vif-route-ifup ++# ++# Script for configuring a vif in routed mode. ++# The hotplugging system will call this script if it is specified either in ++# the device configuration given to Xend, or the default Xend configuration ++# in /etc/xen/xend-config.sxp. If the script is specified in neither of those ++# places, then vif-bridge is the default. ++# ++# Usage: ++# vif-route-ifup (add|remove|online|offline) ++# ++# Environment vars: ++# dev vif interface name (required). ++#============================================================================ ++ ++dir=$(dirname "$0") ++. "$dir/vif-common.sh" ++ ++case "$command" in ++ online) ++ ifup ${dev} ++ ;; ++ offline) ++ do_without_error ifdown ${dev} ++ ;; ++esac ++ ++log debug "Successful vif-route-ifup $command for ${dev}." ++if [ "$command" = "online" ] ++then ++ success ++fi diff --git a/xen.changes b/xen.changes index 1af670e..5850500 100644 --- a/xen.changes +++ b/xen.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Apr 21 16:30:30 CEST 2011 - ohering@suse.de + +- bnc#685189: update vif-route-ifup.patch to use correct variable + after upstream commit 22910:d4bc41a8cecb + ------------------------------------------------------------------- Wed Apr 20 17:50:04 CEST 2011 - ohering@suse.de From 4c736090127fce9b1772e5abbe7b6104c345b77442f1489905ced564e6cf5447 Mon Sep 17 00:00:00 2001 From: Charles Arnold Date: Tue, 3 May 2011 17:51:18 +0000 Subject: [PATCH 3/4] - Upstream patches from Jan 22998-x86-get_page_from_l1e-retcode.patch 22999-x86-mod_l1_entry-retcode.patch 23000-x86-mod_l2_entry-retcode.patch 23096-x86-hpet-no-cpumask_lock.patch 23099-x86-rwlock-scalability.patch 23103-x86-pirq-guest-eoi-check.patch 23127-vtd-bios-settings.patch 23153-x86-amd-clear-DramModEn.patch 23154-x86-amd-iorr-no-rdwr.patch 23199-amd-iommu-unmapped-intr-fault.patch 23200-amd-iommu-intremap-sync.patch 23228-x86-conditional-write_tsc.patch - update xenalyze to revision 98 * Unify setting of vcpu data type * Unify record size checks * Fix cr3_switch not to access hvm struct before it's initialized - add xenalyze.gcc46.patch to fix unused-but-set-variable errors - bnc#688473 - VUL-0: potential buffer overflow in tools cve-2011-1583-4.0.patch - hotplug.losetup.patch correct dev:inode detection and use variable expansion OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=115 --- 22998-x86-get_page_from_l1e-retcode.patch | 236 ++++++++++++++++++ 22999-x86-mod_l1_entry-retcode.patch | 114 +++++++++ 23000-x86-mod_l2_entry-retcode.patch | 210 ++++++++++++++++ 23096-x86-hpet-no-cpumask_lock.patch | 93 +++++++ 23099-x86-rwlock-scalability.patch | 290 ++++++++++++++++++++++ 23103-x86-pirq-guest-eoi-check.patch | 25 ++ 23127-vtd-bios-settings.patch | 194 +++++++++++++++ 23153-x86-amd-clear-DramModEn.patch | 57 +++++ 23154-x86-amd-iorr-no-rdwr.patch | 51 ++++ 23199-amd-iommu-unmapped-intr-fault.patch | 25 ++ 23200-amd-iommu-intremap-sync.patch | 179 +++++++++++++ 23228-x86-conditional-write_tsc.patch | 220 ++++++++++++++++ 32on64-extra-mem.patch | 2 +- cve-2011-1583-4.1.patch | 217 ++++++++++++++++ hotplug.losetup.patch | 34 +++ xen.changes | 38 +++ xen.spec | 148 ++++++----- xenalyze.gcc46.patch | 122 +++++++++ xenalyze.hg.tar.bz2 | 4 +- 19 files changed, 2198 insertions(+), 61 deletions(-) create mode 100644 22998-x86-get_page_from_l1e-retcode.patch create mode 100644 22999-x86-mod_l1_entry-retcode.patch create mode 100644 23000-x86-mod_l2_entry-retcode.patch create mode 100644 23096-x86-hpet-no-cpumask_lock.patch create mode 100644 23099-x86-rwlock-scalability.patch create mode 100644 23103-x86-pirq-guest-eoi-check.patch create mode 100644 23127-vtd-bios-settings.patch create mode 100644 23153-x86-amd-clear-DramModEn.patch create mode 100644 23154-x86-amd-iorr-no-rdwr.patch create mode 100644 23199-amd-iommu-unmapped-intr-fault.patch create mode 100644 23200-amd-iommu-intremap-sync.patch create mode 100644 23228-x86-conditional-write_tsc.patch create mode 100644 cve-2011-1583-4.1.patch create mode 100644 hotplug.losetup.patch create mode 100644 xenalyze.gcc46.patch diff --git a/22998-x86-get_page_from_l1e-retcode.patch b/22998-x86-get_page_from_l1e-retcode.patch new file mode 100644 index 0000000..eeb31b6 --- /dev/null +++ b/22998-x86-get_page_from_l1e-retcode.patch @@ -0,0 +1,236 @@ +References: bnc#675363 + +# HG changeset patch +# User Keir Fraser +# Date 1299687371 0 +# Node ID e9fab50d7b61d151d51a4b1088930c9e1ca2da47 +# Parent 5f28dcea13555f7ab948c9cb95de3e79e0fbfc4b +x86: make get_page_from_l1e() return a proper error code + +... so that the guest can actually know the reason for the (hypercall) +failure. + +ptwr_do_page_fault() could propagate the error indicator received from +get_page_from_l1e() back to the guest in the high half of the error +code (entry_vector), provided we're sure all existing guests can deal +with that (or indicate so by means of a to-be-added guest feature +flag). Alternatively, a second virtual status register (like CR2) +could be introduced. + +Signed-off-by: Jan Beulich + +--- a/xen/arch/x86/mm/shadow/multi.c ++++ b/xen/arch/x86/mm/shadow/multi.c +@@ -872,7 +872,7 @@ shadow_get_page_from_l1e(shadow_l1e_t sl + // If a privileged domain is attempting to install a map of a page it does + // not own, we let it succeed anyway. + // +- if ( unlikely(!res) && ++ if ( unlikely(res < 0) && + !shadow_mode_translate(d) && + mfn_valid(mfn = shadow_l1e_get_mfn(sl1e)) && + (owner = page_get_owner(mfn_to_page(mfn))) && +@@ -883,11 +883,11 @@ shadow_get_page_from_l1e(shadow_l1e_t sl + SHADOW_PRINTK("privileged domain %d installs map of mfn %05lx " + "which is owned by domain %d: %s\n", + d->domain_id, mfn_x(mfn), owner->domain_id, +- res ? "success" : "failed"); ++ res >= 0 ? "success" : "failed"); + } + + /* Okay, it might still be a grant mapping PTE. Try it. */ +- if ( unlikely(!res) && ++ if ( unlikely(res < 0) && + (type == p2m_grant_map_rw || + (type == p2m_grant_map_ro && + !(shadow_l1e_get_flags(sl1e) & _PAGE_RW))) ) +@@ -900,7 +900,7 @@ shadow_get_page_from_l1e(shadow_l1e_t sl + res = get_page_from_l1e(sl1e, d, page_get_owner(mfn_to_page(mfn))); + } + +- if ( unlikely(!res) ) ++ if ( unlikely(res < 0) ) + { + perfc_incr(shadow_get_page_fail); + SHADOW_PRINTK("failed: l1e=" SH_PRI_pte "\n"); +@@ -1229,15 +1229,15 @@ static int shadow_set_l1e(struct vcpu *v + TRACE_SHADOW_PATH_FLAG(TRCE_SFLAG_SHADOW_L1_GET_REF); + switch ( shadow_get_page_from_l1e(new_sl1e, d, new_type) ) + { +- case 0: ++ default: + /* Doesn't look like a pagetable. */ + flags |= SHADOW_SET_ERROR; + new_sl1e = shadow_l1e_empty(); + break; +- case -1: ++ case 1: + shadow_l1e_remove_flags(new_sl1e, _PAGE_RW); + /* fall through */ +- default: ++ case 0: + shadow_vram_get_l1e(new_sl1e, sl1e, sl1mfn, d); + break; + } +--- a/xen/arch/x86/mm.c ++++ b/xen/arch/x86/mm.c +@@ -799,12 +799,12 @@ get_page_from_l1e( + bool_t write; + + if ( !(l1f & _PAGE_PRESENT) ) +- return 1; ++ return 0; + + if ( unlikely(l1f & l1_disallow_mask(l1e_owner)) ) + { + MEM_LOG("Bad L1 flags %x", l1f & l1_disallow_mask(l1e_owner)); +- return 0; ++ return -EINVAL; + } + + if ( !mfn_valid(mfn) || +@@ -821,18 +821,21 @@ get_page_from_l1e( + if ( !iomem_access_permitted(pg_owner, mfn, mfn) ) + { + if ( mfn != (PADDR_MASK >> PAGE_SHIFT) ) /* INVALID_MFN? */ ++ { + MEM_LOG("Non-privileged (%u) attempt to map I/O space %08lx", + pg_owner->domain_id, mfn); +- return 0; ++ return -EPERM; ++ } ++ return -EINVAL; + } + + if ( !(l1f & _PAGE_RW) || IS_PRIV(pg_owner) || + !rangeset_contains_singleton(mmio_ro_ranges, mfn) ) +- return 1; ++ return 0; + dprintk(XENLOG_G_WARNING, + "d%d: Forcing read-only access to MFN %lx\n", + l1e_owner->domain_id, mfn); +- return -1; ++ return 1; + } + + if ( unlikely(real_pg_owner != pg_owner) ) +@@ -863,6 +866,7 @@ get_page_from_l1e( + { + unsigned long x, nx, y = page->count_info; + unsigned long cacheattr = pte_flags_to_cacheattr(l1f); ++ int err; + + if ( is_xen_heap_page(page) ) + { +@@ -870,7 +874,7 @@ get_page_from_l1e( + put_page_type(page); + put_page(page); + MEM_LOG("Attempt to change cache attributes of Xen heap page"); +- return 0; ++ return -EACCES; + } + + do { +@@ -878,7 +882,8 @@ get_page_from_l1e( + nx = (x & ~PGC_cacheattr_mask) | (cacheattr << PGC_cacheattr_base); + } while ( (y = cmpxchg(&page->count_info, x, nx)) != x ); + +- if ( unlikely(update_xen_mappings(mfn, cacheattr) != 0) ) ++ err = update_xen_mappings(mfn, cacheattr); ++ if ( unlikely(err) ) + { + cacheattr = y & PGC_cacheattr_mask; + do { +@@ -894,11 +899,11 @@ get_page_from_l1e( + " from L1 entry %" PRIpte ") for %d", + mfn, get_gpfn_from_mfn(mfn), + l1e_get_intpte(l1e), l1e_owner->domain_id); +- return 0; ++ return err; + } + } + +- return 1; ++ return 0; + + could_not_pin: + MEM_LOG("Error getting mfn %lx (pfn %lx) from L1 entry %" PRIpte +@@ -907,7 +912,7 @@ get_page_from_l1e( + l1e_get_intpte(l1e), l1e_owner->domain_id, pg_owner->domain_id); + if ( real_pg_owner != NULL ) + put_page(page); +- return 0; ++ return -EBUSY; + } + + +@@ -1197,17 +1202,20 @@ static int alloc_l1_table(struct page_in + unsigned long pfn = page_to_mfn(page); + l1_pgentry_t *pl1e; + unsigned int i; ++ int ret = 0; + + pl1e = map_domain_page(pfn); + + for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) + { + if ( is_guest_l1_slot(i) ) +- switch ( get_page_from_l1e(pl1e[i], d, d) ) ++ switch ( ret = get_page_from_l1e(pl1e[i], d, d) ) + { +- case 0: ++ default: + goto fail; +- case -1: ++ case 0: ++ break; ++ case 1: + l1e_remove_flags(pl1e[i], _PAGE_RW); + break; + } +@@ -1225,7 +1233,7 @@ static int alloc_l1_table(struct page_in + put_page_from_l1e(pl1e[i], d); + + unmap_domain_page(pl1e); +- return -EINVAL; ++ return ret; + } + + static int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e) +@@ -1794,11 +1802,13 @@ static int mod_l1_entry(l1_pgentry_t *pl + return rc; + } + +- switch ( get_page_from_l1e(nl1e, pt_dom, pg_dom) ) ++ switch ( rc = get_page_from_l1e(nl1e, pt_dom, pg_dom) ) + { +- case 0: ++ default: + return 0; +- case -1: ++ case 0: ++ break; ++ case 1: + l1e_remove_flags(nl1e, _PAGE_RW); + break; + } +@@ -4948,7 +4958,7 @@ static int ptwr_emulated_update( + nl1e = l1e_from_intpte(val); + switch ( get_page_from_l1e(nl1e, d, d) ) + { +- case 0: ++ default: + if ( is_pv_32bit_domain(d) && (bytes == 4) && (unaligned_addr & 4) && + !do_cmpxchg && (l1e_get_flags(nl1e) & _PAGE_PRESENT) ) + { +@@ -4968,7 +4978,9 @@ static int ptwr_emulated_update( + return X86EMUL_UNHANDLEABLE; + } + break; +- case -1: ++ case 0: ++ break; ++ case 1: + l1e_remove_flags(nl1e, _PAGE_RW); + break; + } diff --git a/22999-x86-mod_l1_entry-retcode.patch b/22999-x86-mod_l1_entry-retcode.patch new file mode 100644 index 0000000..81655d1 --- /dev/null +++ b/22999-x86-mod_l1_entry-retcode.patch @@ -0,0 +1,114 @@ +References: bnc#675363 + +# HG changeset patch +# User Jan Beulich +# Date 1299687409 0 +# Node ID 82b5f8d12903e140f957ae8d13d66e44be076b05 +# Parent e9fab50d7b61d151d51a4b1088930c9e1ca2da47 +x86: make mod_l1_entry() return a proper error code + +... again is so that the guest can actually know the reason for the +(hypercall) failure. + +Signed-off-by: Jan Beulich + +--- a/xen/arch/x86/mm.c ++++ b/xen/arch/x86/mm.c +@@ -1765,15 +1765,16 @@ static int mod_l1_entry(l1_pgentry_t *pl + struct domain *pt_dom = pt_vcpu->domain; + unsigned long mfn; + p2m_type_t p2mt; +- int rc = 1; ++ int rc = 0; + + if ( unlikely(__copy_from_user(&ol1e, pl1e, sizeof(ol1e)) != 0) ) +- return 0; ++ return -EFAULT; + + if ( unlikely(paging_mode_refcounts(pt_dom)) ) + { +- rc = UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, preserve_ad); +- return rc; ++ if ( UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, preserve_ad) ) ++ return 0; ++ return -EBUSY; + } + + if ( l1e_get_flags(nl1e) & _PAGE_PRESENT ) +@@ -1782,7 +1783,7 @@ static int mod_l1_entry(l1_pgentry_t *pl + mfn = mfn_x(gfn_to_mfn(p2m_get_hostp2m(pg_dom), + l1e_get_pfn(nl1e), &p2mt)); + if ( !p2m_is_ram(p2mt) || unlikely(mfn == INVALID_MFN) ) +- return 0; ++ return -EINVAL; + ASSERT((mfn & ~(PADDR_MASK >> PAGE_SHIFT)) == 0); + nl1e = l1e_from_pfn(mfn, l1e_get_flags(nl1e)); + +@@ -1790,22 +1791,23 @@ static int mod_l1_entry(l1_pgentry_t *pl + { + MEM_LOG("Bad L1 flags %x", + l1e_get_flags(nl1e) & l1_disallow_mask(pt_dom)); +- return 0; ++ return -EINVAL; + } + + /* Fast path for identical mapping, r/w and presence. */ + if ( !l1e_has_changed(ol1e, nl1e, _PAGE_RW | _PAGE_PRESENT) ) + { + adjust_guest_l1e(nl1e, pt_dom); +- rc = UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, +- preserve_ad); +- return rc; ++ if ( UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, ++ preserve_ad) ) ++ return 0; ++ return -EBUSY; + } + + switch ( rc = get_page_from_l1e(nl1e, pt_dom, pg_dom) ) + { + default: +- return 0; ++ return rc; + case 0: + break; + case 1: +@@ -1818,13 +1820,13 @@ static int mod_l1_entry(l1_pgentry_t *pl + preserve_ad)) ) + { + ol1e = nl1e; +- rc = 0; ++ rc = -EBUSY; + } + } + else if ( unlikely(!UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, + preserve_ad)) ) + { +- return 0; ++ return -EBUSY; + } + + put_page_from_l1e(ol1e, pt_dom); +@@ -3516,9 +3518,10 @@ int do_mmu_update( + } + #endif + +- okay = mod_l1_entry(va, l1e, mfn, +- cmd == MMU_PT_UPDATE_PRESERVE_AD, v, +- pg_owner); ++ rc = mod_l1_entry(va, l1e, mfn, ++ cmd == MMU_PT_UPDATE_PRESERVE_AD, v, ++ pg_owner); ++ okay = !rc; + } + break; + case PGT_l2_page_table: +@@ -4300,7 +4303,7 @@ static int __do_update_va_mapping( + goto out; + } + +- rc = mod_l1_entry(pl1e, val, gl1mfn, 0, v, pg_owner) ? 0 : -EINVAL; ++ rc = mod_l1_entry(pl1e, val, gl1mfn, 0, v, pg_owner); + + page_unlock(gl1pg); + put_page(gl1pg); diff --git a/23000-x86-mod_l2_entry-retcode.patch b/23000-x86-mod_l2_entry-retcode.patch new file mode 100644 index 0000000..e8a7633 --- /dev/null +++ b/23000-x86-mod_l2_entry-retcode.patch @@ -0,0 +1,210 @@ +# HG changeset patch +# User Jan Beulich +# Date 1299687446 0 +# Node ID d428fa67abaa0db20b915a697f1d5ba16e554185 +# Parent 82b5f8d12903e140f957ae8d13d66e44be076b05 +x86: make mod_l2_entry() return a proper error code + +... so that finally all mod_lN_entry() functions behave identically, +allowing some cleanup in do_mmu_update() (which no longer needs to +track both an okay status and an error code). + +Signed-off-by: Jan Beulich + +--- a/xen/arch/x86/mm.c ++++ b/xen/arch/x86/mm.c +@@ -1845,16 +1845,16 @@ static int mod_l2_entry(l2_pgentry_t *pl + struct domain *d = vcpu->domain; + struct page_info *l2pg = mfn_to_page(pfn); + unsigned long type = l2pg->u.inuse.type_info; +- int rc = 1; ++ int rc = 0; + + if ( unlikely(!is_guest_l2_slot(d, type, pgentry_ptr_to_slot(pl2e))) ) + { + MEM_LOG("Illegal L2 update attempt in Xen-private area %p", pl2e); +- return 0; ++ return -EPERM; + } + + if ( unlikely(__copy_from_user(&ol2e, pl2e, sizeof(ol2e)) != 0) ) +- return 0; ++ return -EFAULT; + + if ( l2e_get_flags(nl2e) & _PAGE_PRESENT ) + { +@@ -1862,32 +1862,33 @@ static int mod_l2_entry(l2_pgentry_t *pl + { + MEM_LOG("Bad L2 flags %x", + l2e_get_flags(nl2e) & L2_DISALLOW_MASK); +- return 0; ++ return -EINVAL; + } + + /* Fast path for identical mapping and presence. */ + if ( !l2e_has_changed(ol2e, nl2e, _PAGE_PRESENT) ) + { + adjust_guest_l2e(nl2e, d); +- rc = UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, pfn, vcpu, preserve_ad); +- return rc; ++ if ( UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, pfn, vcpu, preserve_ad) ) ++ return 0; ++ return -EBUSY; + } + +- if ( unlikely(get_page_from_l2e(nl2e, pfn, d) < 0) ) +- return 0; ++ if ( unlikely((rc = get_page_from_l2e(nl2e, pfn, d)) < 0) ) ++ return rc; + + adjust_guest_l2e(nl2e, d); + if ( unlikely(!UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, pfn, vcpu, + preserve_ad)) ) + { + ol2e = nl2e; +- rc = 0; ++ rc = -EBUSY; + } + } + else if ( unlikely(!UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, pfn, vcpu, + preserve_ad)) ) + { +- return 0; ++ return -EBUSY; + } + + put_page_from_l2e(ol2e, pfn); +@@ -3367,7 +3368,7 @@ int do_mmu_update( + void *va; + unsigned long gpfn, gmfn, mfn; + struct page_info *page; +- int rc = 0, okay = 1, i = 0; ++ int rc = 0, i = 0; + unsigned int cmd, done = 0, pt_dom; + struct vcpu *v = current; + struct domain *d = v->domain, *pt_owner = d, *pg_owner; +@@ -3434,7 +3435,6 @@ int do_mmu_update( + } + + cmd = req.ptr & (sizeof(l1_pgentry_t)-1); +- okay = 0; + + switch ( cmd ) + { +@@ -3451,6 +3451,7 @@ int do_mmu_update( + rc = xsm_mmu_normal_update(d, pg_owner, req.val); + if ( rc ) + break; ++ rc = -EINVAL; + + req.ptr -= cmd; + gmfn = req.ptr >> PAGE_SHIFT; +@@ -3521,7 +3522,6 @@ int do_mmu_update( + rc = mod_l1_entry(va, l1e, mfn, + cmd == MMU_PT_UPDATE_PRESERVE_AD, v, + pg_owner); +- okay = !rc; + } + break; + case PGT_l2_page_table: +@@ -3545,13 +3545,12 @@ int do_mmu_update( + else if ( p2m_ram_shared == l2e_p2mt ) + { + MEM_LOG("Unexpected attempt to map shared page.\n"); +- rc = -EINVAL; + break; + } + + +- okay = mod_l2_entry(va, l2e, mfn, +- cmd == MMU_PT_UPDATE_PRESERVE_AD, v); ++ rc = mod_l2_entry(va, l2e, mfn, ++ cmd == MMU_PT_UPDATE_PRESERVE_AD, v); + } + break; + case PGT_l3_page_table: +@@ -3575,13 +3574,11 @@ int do_mmu_update( + else if ( p2m_ram_shared == l3e_p2mt ) + { + MEM_LOG("Unexpected attempt to map shared page.\n"); +- rc = -EINVAL; + break; + } + + rc = mod_l3_entry(va, l3e, mfn, + cmd == MMU_PT_UPDATE_PRESERVE_AD, 1, v); +- okay = !rc; + } + break; + #if CONFIG_PAGING_LEVELS >= 4 +@@ -3607,20 +3604,18 @@ int do_mmu_update( + else if ( p2m_ram_shared == l4e_p2mt ) + { + MEM_LOG("Unexpected attempt to map shared page.\n"); +- rc = -EINVAL; + break; + } + + rc = mod_l4_entry(va, l4e, mfn, + cmd == MMU_PT_UPDATE_PRESERVE_AD, 1, v); +- okay = !rc; + } + break; + #endif + case PGT_writable_page: + perfc_incr(writable_mmu_updates); +- okay = paging_write_guest_entry( +- v, va, req.val, _mfn(mfn)); ++ if ( paging_write_guest_entry(v, va, req.val, _mfn(mfn)) ) ++ rc = 0; + break; + } + page_unlock(page); +@@ -3630,8 +3625,8 @@ int do_mmu_update( + else if ( get_page_type(page, PGT_writable_page) ) + { + perfc_incr(writable_mmu_updates); +- okay = paging_write_guest_entry( +- v, va, req.val, _mfn(mfn)); ++ if ( paging_write_guest_entry(v, va, req.val, _mfn(mfn)) ) ++ rc = 0; + put_page_type(page); + } + +@@ -3652,17 +3647,18 @@ int do_mmu_update( + if ( unlikely(!get_page_from_pagenr(mfn, pg_owner)) ) + { + MEM_LOG("Could not get page for mach->phys update"); ++ rc = -EINVAL; + break; + } + + if ( unlikely(paging_mode_translate(pg_owner)) ) + { + MEM_LOG("Mach-phys update on auto-translate guest"); ++ rc = -EINVAL; + break; + } + + set_gpfn_from_mfn(mfn, gpfn); +- okay = 1; + + paging_mark_dirty(pg_owner, mfn); + +@@ -3672,15 +3668,11 @@ int do_mmu_update( + default: + MEM_LOG("Invalid page update command %x", cmd); + rc = -ENOSYS; +- okay = 0; + break; + } + +- if ( unlikely(!okay) ) +- { +- rc = rc ? rc : -EINVAL; ++ if ( unlikely(rc) ) + break; +- } + + guest_handle_add_offset(ureqs, 1); + } diff --git a/23096-x86-hpet-no-cpumask_lock.patch b/23096-x86-hpet-no-cpumask_lock.patch new file mode 100644 index 0000000..52fde78 --- /dev/null +++ b/23096-x86-hpet-no-cpumask_lock.patch @@ -0,0 +1,93 @@ +# HG changeset patch +# User Jan Beulich +# Date 1301043797 0 +# Node ID a65612bcbb921e98a8843157bf365e4ab16e8144 +# Parent 941119d58655f2b2df86d9ecc4cb502bbc5e783c +x86/hpet: eliminate cpumask_lock + +According to the (now getting removed) comment in struct +hpet_event_channel, this was to prevent accessing a CPU's +timer_deadline after it got cleared from cpumask. This can be done +without a lock altogether - hpet_broadcast_exit() can simply clear +the bit, and handle_hpet_broadcast() can read timer_deadline before +looking at the mask a second time (the cpumask bit was already +found set by the surrounding loop). + +Signed-off-by: Jan Beulich +Acked-by: Gang Wei + +--- a/xen/arch/x86/hpet.c ++++ b/xen/arch/x86/hpet.c +@@ -34,18 +34,6 @@ struct hpet_event_channel + int shift; + s_time_t next_event; + cpumask_t cpumask; +- /* +- * cpumask_lock is used to prevent hpet intr handler from accessing other +- * cpu's timer_deadline after the other cpu's mask was cleared -- +- * mask cleared means cpu waken up, then accessing timer_deadline from +- * other cpu is not safe. +- * It is not used for protecting cpumask, so set ops needn't take it. +- * Multiple cpus clear cpumask simultaneously is ok due to the atomic +- * feature of cpu_clear, so hpet_broadcast_exit() can take read lock for +- * clearing cpumask, and handle_hpet_broadcast() have to take write lock +- * for read cpumask & access timer_deadline. +- */ +- rwlock_t cpumask_lock; + spinlock_t lock; + void (*event_handler)(struct hpet_event_channel *); + +@@ -208,17 +196,18 @@ again: + /* find all expired events */ + for_each_cpu_mask(cpu, ch->cpumask) + { +- write_lock_irq(&ch->cpumask_lock); ++ s_time_t deadline; + +- if ( cpu_isset(cpu, ch->cpumask) ) +- { +- if ( per_cpu(timer_deadline, cpu) <= now ) +- cpu_set(cpu, mask); +- else if ( per_cpu(timer_deadline, cpu) < next_event ) +- next_event = per_cpu(timer_deadline, cpu); +- } ++ rmb(); ++ deadline = per_cpu(timer_deadline, cpu); ++ rmb(); ++ if ( !cpu_isset(cpu, ch->cpumask) ) ++ continue; + +- write_unlock_irq(&ch->cpumask_lock); ++ if ( deadline <= now ) ++ cpu_set(cpu, mask); ++ else if ( deadline < next_event ) ++ next_event = deadline; + } + + /* wakeup the cpus which have an expired event. */ +@@ -598,7 +587,6 @@ void hpet_broadcast_init(void) + hpet_events[i].shift = 32; + hpet_events[i].next_event = STIME_MAX; + spin_lock_init(&hpet_events[i].lock); +- rwlock_init(&hpet_events[i].cpumask_lock); + wmb(); + hpet_events[i].event_handler = handle_hpet_broadcast; + } +@@ -634,7 +622,6 @@ void hpet_broadcast_init(void) + legacy_hpet_event.idx = 0; + legacy_hpet_event.flags = 0; + spin_lock_init(&legacy_hpet_event.lock); +- rwlock_init(&legacy_hpet_event.cpumask_lock); + wmb(); + legacy_hpet_event.event_handler = handle_hpet_broadcast; + +@@ -713,9 +700,7 @@ void hpet_broadcast_exit(void) + if ( !reprogram_timer(this_cpu(timer_deadline)) ) + raise_softirq(TIMER_SOFTIRQ); + +- read_lock_irq(&ch->cpumask_lock); + cpu_clear(cpu, ch->cpumask); +- read_unlock_irq(&ch->cpumask_lock); + + if ( ch != &legacy_hpet_event ) + { diff --git a/23099-x86-rwlock-scalability.patch b/23099-x86-rwlock-scalability.patch new file mode 100644 index 0000000..d14995d --- /dev/null +++ b/23099-x86-rwlock-scalability.patch @@ -0,0 +1,290 @@ +# HG changeset patch +# User Keir Fraser +# Date 1301126601 0 +# Node ID 612171ff82ea51aaf65d98fd1a551eb8d50fb481 +# Parent c9f745c153ec8c3775e2ee03adc3cb30370b84f6 +rwlock: Allow to scale to 2^31-1 readers on x86. + +Also rework to match the 'trylock' style of raw function used for +spinlocks. + +Inspired by Jan Beulich's patch to do similar improved scaling. + +Signed-off-by: Keir Fraser + +# HG changeset patch +# User Keir Fraser +# Date 1301214635 -3600 +# Node ID 0bc1c4746c8939337f693a513fd837fc03477db1 +# Parent 48dac730a93b27ff60a340564e9a7afd7f9385f4 +x86_32: Fix _raw_read_trylock() build on some gcc versions. + +Was broken by 23099:612171ff82ea. + +A bool_t is a single byte, and needs a 'q' register constraint. Avoid +the whole issue by changing the variable to an int, and explicitly +specify the operand suffix as 'l' for good measure. + +Signed-off-by: Keir Fraser + +--- a/xen/common/spinlock.c ++++ b/xen/common/spinlock.c +@@ -234,7 +234,11 @@ void _spin_unlock_recursive(spinlock_t * + void _read_lock(rwlock_t *lock) + { + check_lock(&lock->debug); +- _raw_read_lock(&lock->raw); ++ while ( unlikely(!_raw_read_trylock(&lock->raw)) ) ++ { ++ while ( likely(_raw_rw_is_write_locked(&lock->raw)) ) ++ cpu_relax(); ++ } + preempt_disable(); + } + +@@ -243,7 +247,13 @@ void _read_lock_irq(rwlock_t *lock) + ASSERT(local_irq_is_enabled()); + local_irq_disable(); + check_lock(&lock->debug); +- _raw_read_lock(&lock->raw); ++ while ( unlikely(!_raw_read_trylock(&lock->raw)) ) ++ { ++ local_irq_enable(); ++ while ( likely(_raw_rw_is_write_locked(&lock->raw)) ) ++ cpu_relax(); ++ local_irq_disable(); ++ } + preempt_disable(); + } + +@@ -252,11 +262,26 @@ unsigned long _read_lock_irqsave(rwlock_ + unsigned long flags; + local_irq_save(flags); + check_lock(&lock->debug); +- _raw_read_lock(&lock->raw); ++ while ( unlikely(!_raw_read_trylock(&lock->raw)) ) ++ { ++ local_irq_restore(flags); ++ while ( likely(_raw_rw_is_write_locked(&lock->raw)) ) ++ cpu_relax(); ++ local_irq_save(flags); ++ } + preempt_disable(); + return flags; + } + ++int _read_trylock(rwlock_t *lock) ++{ ++ check_lock(&lock->debug); ++ if ( !_raw_read_trylock(&lock->raw) ) ++ return 0; ++ preempt_disable(); ++ return 1; ++} ++ + void _read_unlock(rwlock_t *lock) + { + preempt_enable(); +@@ -280,7 +305,11 @@ void _read_unlock_irqrestore(rwlock_t *l + void _write_lock(rwlock_t *lock) + { + check_lock(&lock->debug); +- _raw_write_lock(&lock->raw); ++ while ( unlikely(!_raw_write_trylock(&lock->raw)) ) ++ { ++ while ( likely(_raw_rw_is_locked(&lock->raw)) ) ++ cpu_relax(); ++ } + preempt_disable(); + } + +@@ -289,7 +318,13 @@ void _write_lock_irq(rwlock_t *lock) + ASSERT(local_irq_is_enabled()); + local_irq_disable(); + check_lock(&lock->debug); +- _raw_write_lock(&lock->raw); ++ while ( unlikely(!_raw_write_trylock(&lock->raw)) ) ++ { ++ local_irq_enable(); ++ while ( likely(_raw_rw_is_locked(&lock->raw)) ) ++ cpu_relax(); ++ local_irq_disable(); ++ } + preempt_disable(); + } + +@@ -298,7 +333,13 @@ unsigned long _write_lock_irqsave(rwlock + unsigned long flags; + local_irq_save(flags); + check_lock(&lock->debug); +- _raw_write_lock(&lock->raw); ++ while ( unlikely(!_raw_write_trylock(&lock->raw)) ) ++ { ++ local_irq_restore(flags); ++ while ( likely(_raw_rw_is_locked(&lock->raw)) ) ++ cpu_relax(); ++ local_irq_save(flags); ++ } + preempt_disable(); + return flags; + } +--- a/xen/include/asm-ia64/linux-xen/asm/spinlock.h ++++ b/xen/include/asm-ia64/linux-xen/asm/spinlock.h +@@ -35,17 +35,6 @@ typedef struct { + } raw_rwlock_t; + #define _RAW_RW_LOCK_UNLOCKED /*(raw_rwlock_t)*/ { 0, 0 } + +-#define _raw_read_lock(rw) \ +-do { \ +- raw_rwlock_t *__read_lock_ptr = (rw); \ +- \ +- while (unlikely(ia64_fetchadd(1, (int *) __read_lock_ptr, acq) < 0)) { \ +- ia64_fetchadd(-1, (int *) __read_lock_ptr, rel); \ +- while (*(volatile int *)__read_lock_ptr < 0) \ +- cpu_relax(); \ +- } \ +-} while (0) +- + #define _raw_read_unlock(rw) \ + do { \ + raw_rwlock_t *__read_lock_ptr = (rw); \ +@@ -53,20 +42,6 @@ do { \ + } while (0) + + #ifdef ASM_SUPPORTED +-#define _raw_write_lock(rw) \ +-do { \ +- __asm__ __volatile__ ( \ +- "mov ar.ccv = r0\n" \ +- "dep r29 = -1, r0, 31, 1;;\n" \ +- "1:\n" \ +- "ld4 r2 = [%0];;\n" \ +- "cmp4.eq p0,p7 = r0,r2\n" \ +- "(p7) br.cond.spnt.few 1b \n" \ +- "cmpxchg4.acq r2 = [%0], r29, ar.ccv;;\n" \ +- "cmp4.eq p0,p7 = r0, r2\n" \ +- "(p7) br.cond.spnt.few 1b;;\n" \ +- :: "r"(rw) : "ar.ccv", "p7", "r2", "r29", "memory"); \ +-} while(0) + + #define _raw_write_trylock(rw) \ + ({ \ +@@ -82,16 +57,6 @@ do { \ + + #else /* !ASM_SUPPORTED */ + +-#define _raw_write_lock(l) \ +-({ \ +- __u64 ia64_val, ia64_set_val = ia64_dep_mi(-1, 0, 31, 1); \ +- __u32 *ia64_write_lock_ptr = (__u32 *) (l); \ +- do { \ +- while (*ia64_write_lock_ptr) \ +- ia64_barrier(); \ +- ia64_val = ia64_cmpxchg4_acq(ia64_write_lock_ptr, ia64_set_val, 0); \ +- } while (ia64_val); \ +-}) + + #define _raw_write_trylock(rw) \ + ({ \ +--- a/xen/include/asm-x86/spinlock.h ++++ b/xen/include/asm-x86/spinlock.h +@@ -35,51 +35,29 @@ typedef struct { + volatile int lock; + } raw_rwlock_t; + +-#define RW_LOCK_BIAS 0x01000000 +-#define _RAW_RW_LOCK_UNLOCKED /*(raw_rwlock_t)*/ { RW_LOCK_BIAS } ++#define RW_WRITE_BIAS 0x7fffffff ++#define _RAW_RW_LOCK_UNLOCKED /*(raw_rwlock_t)*/ { 0 } + +-static always_inline void _raw_read_lock(raw_rwlock_t *rw) ++static always_inline int _raw_read_trylock(raw_rwlock_t *rw) + { +- asm volatile ( +- "1: lock; decl %0 \n" +- " jns 3f \n" +- " lock; incl %0 \n" +- "2: rep; nop \n" +- " cmpl $1,%0 \n" +- " js 2b \n" +- " jmp 1b \n" +- "3:" +- : "=m" (rw->lock) : : "memory" ); +-} ++ int acquired; + +-static always_inline void _raw_write_lock(raw_rwlock_t *rw) +-{ + asm volatile ( +- "1: lock; subl %1,%0 \n" +- " jz 3f \n" +- " lock; addl %1,%0 \n" +- "2: rep; nop \n" +- " cmpl %1,%0 \n" +- " jne 2b \n" ++ " lock; decl %0 \n" ++ " jns 2f \n" ++ "1: .subsection 1 \n" ++ "2: lock; incl %0 \n" ++ " decl %1 \n" + " jmp 1b \n" +- "3:" +- : "=m" (rw->lock) : "i" (RW_LOCK_BIAS) : "memory" ); ++ " .subsection 0 \n" ++ : "=m" (rw->lock), "=r" (acquired) : "1" (1) : "memory" ); ++ ++ return acquired; + } + + static always_inline int _raw_write_trylock(raw_rwlock_t *rw) + { +- int rc; +- +- asm volatile ( +- " lock; subl %2,%0 \n" +- " jz 1f \n" +- " lock; addl %2,%0 \n" +- " dec %1 \n" +- "1:" +- : "=m" (rw->lock), "=r" (rc) : "i" (RW_LOCK_BIAS), "1" (1) +- : "memory" ); +- +- return rc; ++ return (cmpxchg(&rw->lock, 0, RW_WRITE_BIAS) == 0); + } + + static always_inline void _raw_read_unlock(raw_rwlock_t *rw) +@@ -92,11 +70,11 @@ static always_inline void _raw_read_unlo + static always_inline void _raw_write_unlock(raw_rwlock_t *rw) + { + asm volatile ( +- "lock ; addl %1,%0" +- : "=m" ((rw)->lock) : "i" (RW_LOCK_BIAS) : "memory" ); ++ "lock ; subl %1,%0" ++ : "=m" ((rw)->lock) : "i" (RW_WRITE_BIAS) : "memory" ); + } + +-#define _raw_rw_is_locked(x) ((x)->lock < RW_LOCK_BIAS) +-#define _raw_rw_is_write_locked(x) ((x)->lock <= 0) ++#define _raw_rw_is_locked(x) ((x)->lock != 0) ++#define _raw_rw_is_write_locked(x) ((x)->lock > 0) + + #endif /* __ASM_SPINLOCK_H */ +--- a/xen/include/xen/spinlock.h ++++ b/xen/include/xen/spinlock.h +@@ -157,6 +157,7 @@ unsigned long _read_lock_irqsave(rwlock_ + void _read_unlock(rwlock_t *lock); + void _read_unlock_irq(rwlock_t *lock); + void _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags); ++int _read_trylock(rwlock_t *lock); + + void _write_lock(rwlock_t *lock); + void _write_lock_irq(rwlock_t *lock); +@@ -210,6 +211,7 @@ int _rw_is_write_locked(rwlock_t *lock); + #define read_unlock(l) _read_unlock(l) + #define read_unlock_irq(l) _read_unlock_irq(l) + #define read_unlock_irqrestore(l, f) _read_unlock_irqrestore(l, f) ++#define read_trylock(l) _read_trylock(l) + + #define write_lock(l) _write_lock(l) + #define write_lock_irq(l) _write_lock_irq(l) diff --git a/23103-x86-pirq-guest-eoi-check.patch b/23103-x86-pirq-guest-eoi-check.patch new file mode 100644 index 0000000..f582b2f --- /dev/null +++ b/23103-x86-pirq-guest-eoi-check.patch @@ -0,0 +1,25 @@ +# HG changeset patch +# User Keir Fraser +# Date 1301132521 0 +# Node ID 48dac730a93b27ff60a340564e9a7afd7f9385f4 +# Parent 8f001d864fefac689b7662bc9979eaddf4fd6e9c +x86: __pirq_guest_eoi() must check it is called for a fully +guest-bound irq before accessing desc->action. + +Signed-off-by: Keir Fraser + +--- a/xen/arch/x86/irq.c ++++ b/xen/arch/x86/irq.c +@@ -1022,6 +1022,12 @@ static void __pirq_guest_eoi(struct doma + if ( desc == NULL ) + return; + ++ if ( !(desc->status & IRQ_GUEST) ) ++ { ++ spin_unlock_irq(&desc->lock); ++ return; ++ } ++ + action = (irq_guest_action_t *)desc->action; + irq = desc - irq_desc; + diff --git a/23127-vtd-bios-settings.patch b/23127-vtd-bios-settings.patch new file mode 100644 index 0000000..a94635d --- /dev/null +++ b/23127-vtd-bios-settings.patch @@ -0,0 +1,194 @@ +# HG changeset patch +# User Allen Kay +# Date 1301755765 -3600 +# Node ID 1046830079376a4b29fcad0cd037a834e808ed06 +# Parent 89c23f58aa986092da0c9a7dfac1c41befbe1f3f +[VTD] check BIOS settings before enabling interrupt remapping or x2apic + +Check flags field in ACPI DMAR structure before enabling interrupt +remapping or x2apic. This allows platform vendors to disable +interrupt remapping or x2apic features if on board BIOS does not +support them. + +Signed-off-by: Allen Kay + +# HG changeset patch +# User Allen Kay +# Date 1302077462 -3600 +# Node ID c7916d6f4dfba9d6c7eeb0fc2796068d75e2fb4a +# Parent 42fa70e0761bbb0596618ca5323664f31a2faa76 +[VTD] Fixes to ACPI DMAR flag checks. + + * platform_supports_{intremap,x2apic} should not be marked __init as + they are used during S3 resume. + * DMAR flags should be taken from the table passed to + acpi_parse_dmar() -- this is the trusted copy of the DMAR, when + running in TXT mode. + +Signed-off-by: Allen Kay + +--- a/xen/arch/x86/apic.c ++++ b/xen/arch/x86/apic.c +@@ -531,7 +531,7 @@ static void resume_x2apic(void) + mask_8259A(); + mask_IO_APIC_setup(ioapic_entries); + +- iommu_enable_IR(); ++ iommu_enable_x2apic_IR(); + __enable_x2apic(); + + restore_IO_APIC_setup(ioapic_entries); +@@ -751,7 +751,7 @@ int lapic_suspend(void) + + local_irq_save(flags); + disable_local_APIC(); +- iommu_disable_IR(); ++ iommu_disable_x2apic_IR(); + local_irq_restore(flags); + return 0; + } +@@ -997,7 +997,7 @@ void __init x2apic_bsp_setup(void) + mask_8259A(); + mask_IO_APIC_setup(ioapic_entries); + +- if ( iommu_enable_IR() ) ++ if ( iommu_enable_x2apic_IR() ) + { + if ( x2apic_enabled ) + panic("Interrupt remapping could not be enabled while " +--- a/xen/drivers/passthrough/vtd/dmar.c ++++ b/xen/drivers/passthrough/vtd/dmar.c +@@ -46,6 +46,7 @@ LIST_HEAD(acpi_rmrr_units); + LIST_HEAD(acpi_atsr_units); + LIST_HEAD(acpi_rhsa_units); + ++static int __read_mostly dmar_flags; + static u64 igd_drhd_address; + u8 dmar_host_address_width; + +@@ -682,6 +683,7 @@ static int __init acpi_parse_dmar(struct + int ret = 0; + + dmar = (struct acpi_table_dmar *)table; ++ dmar_flags = dmar->flags; + + if ( !iommu_enabled ) + { +@@ -802,3 +804,22 @@ void acpi_dmar_zap(void) + dmar_table->signature[0] = 'X'; + dmar_table->checksum -= 'X'-'D'; + } ++ ++int platform_supports_intremap(void) ++{ ++ unsigned int flags = 0; ++ ++ flags = DMAR_INTR_REMAP; ++ return ((dmar_flags & flags) == DMAR_INTR_REMAP); ++} ++ ++int platform_supports_x2apic(void) ++{ ++ unsigned int flags = 0; ++ ++ if (!cpu_has_x2apic) ++ return 0; ++ ++ flags = DMAR_INTR_REMAP | DMAR_X2APIC_OPT_OUT; ++ return ((dmar_flags & flags) == DMAR_INTR_REMAP); ++} +--- a/xen/drivers/passthrough/vtd/extern.h ++++ b/xen/drivers/passthrough/vtd/extern.h +@@ -87,5 +87,7 @@ void vtd_ops_preamble_quirk(struct iommu + void vtd_ops_postamble_quirk(struct iommu* iommu); + void me_wifi_quirk(struct domain *domain, u8 bus, u8 devfn, int map); + void pci_vtd_quirk(struct pci_dev *pdev); ++int platform_supports_intremap(void); ++int platform_supports_x2apic(void); + + #endif // _VTD_EXTERN_H_ +--- a/xen/drivers/passthrough/vtd/intremap.c ++++ b/xen/drivers/passthrough/vtd/intremap.c +@@ -735,6 +735,13 @@ int enable_intremap(struct iommu *iommu, + + ASSERT(ecap_intr_remap(iommu->ecap) && iommu_intremap); + ++ if ( !platform_supports_intremap() ) ++ { ++ dprintk(XENLOG_ERR VTDPREFIX, ++ "Platform firmware does not support interrupt remapping\n"); ++ return -EINVAL; ++ } ++ + ir_ctrl = iommu_ir_ctrl(iommu); + sts = dmar_readl(iommu->reg, DMAR_GSTS_REG); + +@@ -821,10 +828,10 @@ out: + } + + /* +- * This function is used to enable Interrutp remapping when ++ * This function is used to enable Interrupt remapping when + * enable x2apic + */ +-int iommu_enable_IR(void) ++int iommu_enable_x2apic_IR(void) + { + struct acpi_drhd_unit *drhd; + struct iommu *iommu; +@@ -832,6 +839,9 @@ int iommu_enable_IR(void) + if ( !iommu_supports_eim() ) + return -1; + ++ if ( !platform_supports_x2apic() ) ++ return -1; ++ + for_each_drhd_unit ( drhd ) + { + struct qi_ctrl *qi_ctrl = NULL; +@@ -881,7 +891,7 @@ int iommu_enable_IR(void) + * This function is used to disable Interrutp remapping when + * suspend local apic + */ +-void iommu_disable_IR(void) ++void iommu_disable_x2apic_IR(void) + { + struct acpi_drhd_unit *drhd; + +--- a/xen/drivers/passthrough/vtd/iommu.c ++++ b/xen/drivers/passthrough/vtd/iommu.c +@@ -2014,7 +2014,7 @@ static int init_vtd_hw(void) + if ( enable_intremap(iommu, 0) != 0 ) + { + dprintk(XENLOG_WARNING VTDPREFIX, +- "Failed to enable Interrupt Remapping!\n"); ++ "Interrupt Remapping not enabled\n"); + break; + } + } +--- a/xen/drivers/passthrough/vtd/iommu.h ++++ b/xen/drivers/passthrough/vtd/iommu.h +@@ -22,6 +22,10 @@ + + #include + ++/* DMAR Flags bits */ ++#define DMAR_INTR_REMAP 0x1 ++#define DMAR_X2APIC_OPT_OUT 0x2 ++ + /* + * Intel IOMMU register specification per version 1.0 public spec. + */ +--- a/xen/include/xen/iommu.h ++++ b/xen/include/xen/iommu.h +@@ -63,8 +63,8 @@ struct iommu { + + int iommu_setup(void); + int iommu_supports_eim(void); +-int iommu_enable_IR(void); +-void iommu_disable_IR(void); ++int iommu_enable_x2apic_IR(void); ++void iommu_disable_x2apic_IR(void); + + int iommu_add_device(struct pci_dev *pdev); + int iommu_remove_device(struct pci_dev *pdev); diff --git a/23153-x86-amd-clear-DramModEn.patch b/23153-x86-amd-clear-DramModEn.patch new file mode 100644 index 0000000..0051c07 --- /dev/null +++ b/23153-x86-amd-clear-DramModEn.patch @@ -0,0 +1,57 @@ +# HG changeset patch +# User Wei Huang +# Date 1302076891 -3600 +# Node ID 8fb61c9ebe499b576687907d164da07802414925 +# Parent 97763efc41f9b664cf6f7db653c9c3f51e50b358 +x86, amd, MTRR: correct DramModEn bit of SYS_CFG MSR + +Some buggy BIOS might set SYS_CFG DramModEn bit to 1, which can cause +unexpected behavior on AMD platforms. This patch clears DramModEn bit +if it is 1. + +Signed-off-by: Wei Huang + +--- a/xen/arch/x86/cpu/amd.c ++++ b/xen/arch/x86/cpu/amd.c +@@ -318,6 +318,32 @@ static void check_disable_c1e(unsigned i + on_each_cpu(disable_c1e, NULL, 1); + } + ++/* ++ * BIOS is expected to clear MtrrFixDramModEn bit. According to AMD BKDG : ++ * "The MtrrFixDramModEn bit should be set to 1 during BIOS initalization of ++ * the fixed MTRRs, then cleared to 0 for operation." ++ */ ++static void check_syscfg_dram_mod_en(void) ++{ ++ uint64_t syscfg; ++ static bool_t printed = 0; ++ ++ if (!((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && ++ (boot_cpu_data.x86 >= 0x0f))) ++ return; ++ ++ rdmsrl(MSR_K8_SYSCFG, syscfg); ++ if (!(syscfg & K8_MTRRFIXRANGE_DRAM_MODIFY)) ++ return; ++ ++ if (!test_and_set_bool(printed)) ++ printk(KERN_ERR "MTRR: SYSCFG[MtrrFixDramModEn] not " ++ "cleared by BIOS, clearing this bit\n"); ++ ++ syscfg &= ~K8_MTRRFIXRANGE_DRAM_MODIFY; ++ wrmsrl(MSR_K8_SYSCFG, syscfg); ++} ++ + static void __devinit init_amd(struct cpuinfo_x86 *c) + { + u32 l, h; +@@ -587,6 +613,8 @@ static void __devinit init_amd(struct cp + disable_c1_ramping(); + + set_cpuidmask(c); ++ ++ check_syscfg_dram_mod_en(); + } + + static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 * c, unsigned int size) diff --git a/23154-x86-amd-iorr-no-rdwr.patch b/23154-x86-amd-iorr-no-rdwr.patch new file mode 100644 index 0000000..6f42f83 --- /dev/null +++ b/23154-x86-amd-iorr-no-rdwr.patch @@ -0,0 +1,51 @@ +# HG changeset patch +# User Wei Huang +# Date 1302076933 -3600 +# Node ID 42fa70e0761bbb0596618ca5323664f31a2faa76 +# Parent 8fb61c9ebe499b576687907d164da07802414925 +x86, amd, MTRR: remove k8_enable_fixed_iorrs() + +AMD64 defines two special bits (bit 3 and 4) RdMem and WrMem in fixed +MTRR type. Their values are supposed to be 0 after BIOS hands the +control to OS according to AMD BKDG. Unless OS specificially turn them +on, they are kept 0 all the time. As a result, k8_enable_fixed_iorrs() +is unnecessary and removed from upstream kernel (see +https://patchwork.kernel.org/patch/11425/). This patch does the same +thing. + +Signed-off-by: Wei Huang + +--- a/xen/arch/x86/cpu/mtrr/generic.c ++++ b/xen/arch/x86/cpu/mtrr/generic.c +@@ -116,20 +116,6 @@ void mtrr_wrmsr(unsigned int msr, uint64 + } + + /** +- * Enable and allow read/write of extended fixed-range MTRR bits on K8 CPUs +- * see AMD publication no. 24593, chapter 3.2.1 for more information +- */ +-static inline void k8_enable_fixed_iorrs(void) +-{ +- uint64_t msr_content; +- +- rdmsrl(MSR_K8_SYSCFG, msr_content); +- mtrr_wrmsr(MSR_K8_SYSCFG, msr_content +- | K8_MTRRFIXRANGE_DRAM_ENABLE +- | K8_MTRRFIXRANGE_DRAM_MODIFY); +-} +- +-/** + * Checks and updates an fixed-range MTRR if it differs from the value it + * should have. If K8 extenstions are wanted, update the K8 SYSCFG MSR also. + * see AMD publication no. 24593, chapter 7.8.1, page 233 for more information +@@ -145,10 +131,6 @@ static void set_fixed_range(int msr, int + val = ((uint64_t)msrwords[1] << 32) | msrwords[0]; + + if (msr_content != val) { +- if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD && +- boot_cpu_data.x86 == 15 && +- ((msrwords[0] | msrwords[1]) & K8_MTRR_RDMEM_WRMEM_MASK)) +- k8_enable_fixed_iorrs(); + mtrr_wrmsr(msr, val); + *changed = TRUE; + } diff --git a/23199-amd-iommu-unmapped-intr-fault.patch b/23199-amd-iommu-unmapped-intr-fault.patch new file mode 100644 index 0000000..6f066f5 --- /dev/null +++ b/23199-amd-iommu-unmapped-intr-fault.patch @@ -0,0 +1,25 @@ +# HG changeset patch +# User Wei Wang +# Date 1302610857 -3600 +# Node ID dbd98ab2f87facba8117bb881fa2ea5dfdb92960 +# Parent 697ac895c11c6d5d82524de56796cee98fded2a5 +amd iommu: Unmapped interrupt should generate IO page faults. + +This helps us to debug interrupt issues. + +Signed-off-by: Wei Wang + +--- a/xen/drivers/passthrough/amd/iommu_map.c ++++ b/xen/drivers/passthrough/amd/iommu_map.c +@@ -327,8 +327,9 @@ void amd_iommu_set_intremap_table(u32 *d + set_field_in_reg_u32(0xB, entry, + IOMMU_DEV_TABLE_INT_TABLE_LENGTH_MASK, + IOMMU_DEV_TABLE_INT_TABLE_LENGTH_SHIFT, &entry); +- /* ignore unmapped interrupts */ +- set_field_in_reg_u32(IOMMU_CONTROL_ENABLED, entry, ++ ++ /* unmapped interrupt results io page faults*/ ++ set_field_in_reg_u32(IOMMU_CONTROL_DISABLED, entry, + IOMMU_DEV_TABLE_INT_TABLE_IGN_UNMAPPED_MASK, + IOMMU_DEV_TABLE_INT_TABLE_IGN_UNMAPPED_SHIFT, &entry); + set_field_in_reg_u32(int_valid ? IOMMU_CONTROL_ENABLED : diff --git a/23200-amd-iommu-intremap-sync.patch b/23200-amd-iommu-intremap-sync.patch new file mode 100644 index 0000000..972adcc --- /dev/null +++ b/23200-amd-iommu-intremap-sync.patch @@ -0,0 +1,179 @@ +References: bnc#680824 + +# HG changeset patch +# User Wei Wang +# Date 1302611179 -3600 +# Node ID 995a0c01a076e9c4fb124c090bc146a10d76bc7b +# Parent dbd98ab2f87facba8117bb881fa2ea5dfdb92960 +AMD IOMMU: Fix an interrupt remapping issue + +Some device could generate bogus interrupts if an IO-APIC RTE and an +iommu interrupt remapping entry are not consistent during 2 adjacent +64bits IO-APIC RTE updates. For example, if the 2nd operation updates +destination bits in RTE for SATA device and unmask it, in some case, +SATA device will assert ioapic pin to generate interrupt immediately +using new destination but iommu could still translate it into the old +destination, then dom0 would be confused. To fix that, we sync up +interrupt remapping entry with IO-APIC IRE on every 32 bits operation +and forward IOAPIC RTE updates after interrupt. + +Signed-off-by: Wei Wang +Acked-by: Jan Beulich + +--- a/xen/drivers/passthrough/amd/iommu_intr.c ++++ b/xen/drivers/passthrough/amd/iommu_intr.c +@@ -117,8 +117,7 @@ void invalidate_interrupt_table(struct a + static void update_intremap_entry_from_ioapic( + int bdf, + struct amd_iommu *iommu, +- struct IO_APIC_route_entry *ioapic_rte, +- unsigned int rte_upper, unsigned int value) ++ struct IO_APIC_route_entry *ioapic_rte) + { + unsigned long flags; + u32* entry; +@@ -130,28 +129,26 @@ static void update_intremap_entry_from_i + + req_id = get_intremap_requestor_id(bdf); + lock = get_intremap_lock(req_id); +- /* only remap interrupt vector when lower 32 bits in ioapic ire changed */ +- if ( likely(!rte_upper) ) +- { +- delivery_mode = rte->delivery_mode; +- vector = rte->vector; +- dest_mode = rte->dest_mode; +- dest = rte->dest.logical.logical_dest; + +- spin_lock_irqsave(lock, flags); +- offset = get_intremap_offset(vector, delivery_mode); +- entry = (u32*)get_intremap_entry(req_id, offset); ++ delivery_mode = rte->delivery_mode; ++ vector = rte->vector; ++ dest_mode = rte->dest_mode; ++ dest = rte->dest.logical.logical_dest; + +- update_intremap_entry(entry, vector, delivery_mode, dest_mode, dest); +- spin_unlock_irqrestore(lock, flags); ++ spin_lock_irqsave(lock, flags); + +- if ( iommu->enabled ) +- { +- spin_lock_irqsave(&iommu->lock, flags); +- invalidate_interrupt_table(iommu, req_id); +- flush_command_buffer(iommu); +- spin_unlock_irqrestore(&iommu->lock, flags); +- } ++ offset = get_intremap_offset(vector, delivery_mode); ++ entry = (u32*)get_intremap_entry(req_id, offset); ++ update_intremap_entry(entry, vector, delivery_mode, dest_mode, dest); ++ ++ spin_unlock_irqrestore(lock, flags); ++ ++ if ( iommu->enabled ) ++ { ++ spin_lock_irqsave(&iommu->lock, flags); ++ invalidate_interrupt_table(iommu, req_id); ++ flush_command_buffer(iommu); ++ spin_unlock_irqrestore(&iommu->lock, flags); + } + } + +@@ -199,7 +196,8 @@ int __init amd_iommu_setup_ioapic_remapp + spin_lock_irqsave(lock, flags); + offset = get_intremap_offset(vector, delivery_mode); + entry = (u32*)get_intremap_entry(req_id, offset); +- update_intremap_entry(entry, vector, delivery_mode, dest_mode, dest); ++ update_intremap_entry(entry, vector, ++ delivery_mode, dest_mode, dest); + spin_unlock_irqrestore(lock, flags); + + if ( iommu->enabled ) +@@ -217,16 +215,17 @@ int __init amd_iommu_setup_ioapic_remapp + void amd_iommu_ioapic_update_ire( + unsigned int apic, unsigned int reg, unsigned int value) + { +- struct IO_APIC_route_entry ioapic_rte = { 0 }; +- unsigned int rte_upper = (reg & 1) ? 1 : 0; ++ struct IO_APIC_route_entry old_rte = { 0 }; ++ struct IO_APIC_route_entry new_rte = { 0 }; ++ unsigned int rte_lo = (reg & 1) ? reg - 1 : reg; + int saved_mask, bdf; + struct amd_iommu *iommu; + +- *IO_APIC_BASE(apic) = reg; +- *(IO_APIC_BASE(apic)+4) = value; +- + if ( !iommu_intremap ) ++ { ++ __io_apic_write(apic, reg, value); + return; ++ } + + /* get device id of ioapic devices */ + bdf = ioapic_bdf[IO_APIC_ID(apic)]; +@@ -235,30 +234,49 @@ void amd_iommu_ioapic_update_ire( + { + AMD_IOMMU_DEBUG("Fail to find iommu for ioapic device id = 0x%x\n", + bdf); ++ __io_apic_write(apic, reg, value); + return; + } +- if ( rte_upper ) +- return; + +- /* read both lower and upper 32-bits of rte entry */ +- *IO_APIC_BASE(apic) = reg; +- *(((u32 *)&ioapic_rte) + 0) = *(IO_APIC_BASE(apic)+4); +- *IO_APIC_BASE(apic) = reg + 1; +- *(((u32 *)&ioapic_rte) + 1) = *(IO_APIC_BASE(apic)+4); ++ /* save io-apic rte lower 32 bits */ ++ *((u32 *)&old_rte) = __io_apic_read(apic, rte_lo); ++ saved_mask = old_rte.mask; ++ ++ if ( reg == rte_lo ) ++ { ++ *((u32 *)&new_rte) = value; ++ /* read upper 32 bits from io-apic rte */ ++ *(((u32 *)&new_rte) + 1) = __io_apic_read(apic, reg + 1); ++ } ++ else ++ { ++ *((u32 *)&new_rte) = *((u32 *)&old_rte); ++ *(((u32 *)&new_rte) + 1) = value; ++ } + + /* mask the interrupt while we change the intremap table */ +- saved_mask = ioapic_rte.mask; +- ioapic_rte.mask = 1; +- *IO_APIC_BASE(apic) = reg; +- *(IO_APIC_BASE(apic)+4) = *(((int *)&ioapic_rte)+0); +- ioapic_rte.mask = saved_mask; ++ if ( !saved_mask ) ++ { ++ old_rte.mask = 1; ++ __io_apic_write(apic, rte_lo, *((u32 *)&old_rte)); ++ } + +- update_intremap_entry_from_ioapic( +- bdf, iommu, &ioapic_rte, rte_upper, value); ++ /* Update interrupt remapping entry */ ++ update_intremap_entry_from_ioapic(bdf, iommu, &new_rte); ++ ++ /* Forward write access to IO-APIC RTE */ ++ __io_apic_write(apic, reg, value); ++ ++ /* For lower bits access, return directly to avoid double writes */ ++ if ( reg == rte_lo ) ++ return; + + /* unmask the interrupt after we have updated the intremap table */ +- *IO_APIC_BASE(apic) = reg; +- *(IO_APIC_BASE(apic)+4) = *(((u32 *)&ioapic_rte)+0); ++ if ( !saved_mask ) ++ { ++ old_rte.mask = saved_mask; ++ __io_apic_write(apic, rte_lo, *((u32 *)&old_rte)); ++ } + } + + static void update_intremap_entry_from_msi_msg( diff --git a/23228-x86-conditional-write_tsc.patch b/23228-x86-conditional-write_tsc.patch new file mode 100644 index 0000000..ab3b82f --- /dev/null +++ b/23228-x86-conditional-write_tsc.patch @@ -0,0 +1,220 @@ +References: bnc#623680 + +# HG changeset patch +# User Keir Fraser +# Date 1302853928 -3600 +# Node ID 1329d99b4f161b7617a667f601077cc92559f248 +# Parent b5165fb66b56d9438d77b475eaa9db67318d1ea1 +x86: don't write_tsc() non-zero values on CPUs updating only the lower 32 bits + +This means suppressing the uses in time_calibration_tsc_rendezvous(), +cstate_restore_tsc(), and synchronize_tsc_slave(), and fixes a boot +hang of Linux Dom0 when loading processor.ko on such systems that +have support for C states above C1. + +Signed-off-by: Jan Beulich +Signed-off-by: Keir Fraser + +--- a/xen/arch/x86/acpi/cpu_idle.c ++++ b/xen/arch/x86/acpi/cpu_idle.c +@@ -1099,3 +1099,7 @@ void cpuidle_disable_deep_cstate(void) + hpet_disable_legacy_broadcast(); + } + ++bool_t cpuidle_using_deep_cstate(void) ++{ ++ return xen_cpuidle && max_cstate > (local_apic_timer_c2_ok ? 2 : 1); ++} +--- a/xen/arch/x86/hpet.c ++++ b/xen/arch/x86/hpet.c +@@ -634,6 +634,9 @@ void hpet_disable_legacy_broadcast(void) + u32 cfg; + unsigned long flags; + ++ if ( !legacy_hpet_event.shift ) ++ return; ++ + spin_lock_irqsave(&legacy_hpet_event.lock, flags); + + legacy_hpet_event.flags |= HPET_EVT_DISABLE; +--- a/xen/arch/x86/smpboot.c ++++ b/xen/arch/x86/smpboot.c +@@ -41,6 +41,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -134,6 +135,12 @@ static void smp_store_cpu_info(int id) + ; + } + ++/* ++ * TSC's upper 32 bits can't be written in earlier CPUs (before ++ * Prescott), there is no way to resync one AP against BP. ++ */ ++bool_t disable_tsc_sync; ++ + static atomic_t tsc_count; + static uint64_t tsc_value; + static cpumask_t tsc_sync_cpu_mask; +@@ -142,6 +149,9 @@ static void synchronize_tsc_master(unsig + { + unsigned int i; + ++ if ( disable_tsc_sync ) ++ return; ++ + if ( boot_cpu_has(X86_FEATURE_TSC_RELIABLE) && + !cpu_isset(slave, tsc_sync_cpu_mask) ) + return; +@@ -163,6 +173,9 @@ static void synchronize_tsc_slave(unsign + { + unsigned int i; + ++ if ( disable_tsc_sync ) ++ return; ++ + if ( boot_cpu_has(X86_FEATURE_TSC_RELIABLE) && + !cpu_isset(slave, tsc_sync_cpu_mask) ) + return; +--- a/xen/arch/x86/time.c ++++ b/xen/arch/x86/time.c +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -682,6 +683,8 @@ void cstate_restore_tsc(void) + if ( boot_cpu_has(X86_FEATURE_NONSTOP_TSC) ) + return; + ++ ASSERT(boot_cpu_has(X86_FEATURE_TSC_RELIABLE)); ++ + write_tsc(stime2tsc(read_platform_stime())); + } + +@@ -1384,6 +1387,66 @@ void init_percpu_time(void) + } + } + ++/* ++ * On certain older Intel CPUs writing the TSC MSR clears the upper 32 bits. ++ * Obviously we must not use write_tsc() on such CPUs. ++ * ++ * Additionally, AMD specifies that being able to write the TSC MSR is not an ++ * architectural feature (but, other than their manual says, also cannot be ++ * determined from CPUID bits). ++ */ ++static void __init tsc_check_writability(void) ++{ ++ const char *what = NULL; ++ uint64_t tsc; ++ ++ /* ++ * If all CPUs are reported as synchronised and in sync, we never write ++ * the TSCs (except unavoidably, when a CPU is physically hot-plugged). ++ * Hence testing for writability is pointless and even harmful. ++ */ ++ if ( boot_cpu_has(X86_FEATURE_TSC_RELIABLE) ) ++ return; ++ ++ rdtscll(tsc); ++ if ( wrmsr_safe(MSR_IA32_TSC, 0) == 0 ) ++ { ++ uint64_t tmp, tmp2; ++ rdtscll(tmp2); ++ write_tsc(tsc | (1ULL << 32)); ++ rdtscll(tmp); ++ if ( ABS((s64)tmp - (s64)tmp2) < (1LL << 31) ) ++ what = "only partially"; ++ } ++ else ++ { ++ what = "not"; ++ } ++ ++ /* Nothing to do if the TSC is fully writable. */ ++ if ( !what ) ++ { ++ /* ++ * Paranoia - write back original TSC value. However, APs get synced ++ * with BSP as they are brought up, so this doesn't much matter. ++ */ ++ write_tsc(tsc); ++ return; ++ } ++ ++ printk(XENLOG_WARNING "TSC %s writable\n", what); ++ ++ /* time_calibration_tsc_rendezvous() must not be used */ ++ setup_clear_cpu_cap(X86_FEATURE_CONSTANT_TSC); ++ ++ /* cstate_restore_tsc() must not be used (or do nothing) */ ++ if ( !boot_cpu_has(X86_FEATURE_NONSTOP_TSC) ) ++ cpuidle_disable_deep_cstate(); ++ ++ /* synchronize_tsc_slave() must do nothing */ ++ disable_tsc_sync = 1; ++} ++ + /* Late init function (after all CPUs are booted). */ + int __init init_xen_time(void) + { +@@ -1400,6 +1463,8 @@ int __init init_xen_time(void) + setup_clear_cpu_cap(X86_FEATURE_TSC_RELIABLE); + } + ++ tsc_check_writability(); ++ + /* If we have constant-rate TSCs then scale factor can be shared. */ + if ( boot_cpu_has(X86_FEATURE_CONSTANT_TSC) ) + { +@@ -1451,7 +1516,7 @@ static int disable_pit_irq(void) + * XXX dom0 may rely on RTC interrupt delivery, so only enable + * hpet_broadcast if FSB mode available or if force_hpet_broadcast. + */ +- if ( xen_cpuidle && !boot_cpu_has(X86_FEATURE_ARAT) ) ++ if ( cpuidle_using_deep_cstate() && !boot_cpu_has(X86_FEATURE_ARAT) ) + { + hpet_broadcast_init(); + if ( !hpet_broadcast_is_available() ) +--- a/xen/include/asm-x86/setup.h ++++ b/xen/include/asm-x86/setup.h +@@ -4,7 +4,6 @@ + #include + + extern bool_t early_boot; +-extern s8 xen_cpuidle; + extern unsigned long xenheap_initial_phys_start; + + void init_done(void); +--- a/xen/include/asm-x86/time.h ++++ b/xen/include/asm-x86/time.h +@@ -24,6 +24,8 @@ + + typedef u64 cycles_t; + ++extern bool_t disable_tsc_sync; ++ + static inline cycles_t get_cycles(void) + { + cycles_t c; +--- a/xen/include/xen/cpuidle.h ++++ b/xen/include/xen/cpuidle.h +@@ -85,7 +85,10 @@ struct cpuidle_governor + void (*reflect) (struct acpi_processor_power *dev); + }; + ++extern s8 xen_cpuidle; + extern struct cpuidle_governor *cpuidle_current_governor; ++ ++bool_t cpuidle_using_deep_cstate(void); + void cpuidle_disable_deep_cstate(void); + + extern void cpuidle_wakeup_mwait(cpumask_t *mask); diff --git a/32on64-extra-mem.patch b/32on64-extra-mem.patch index 5098f21..8064718 100644 --- a/32on64-extra-mem.patch +++ b/32on64-extra-mem.patch @@ -2,7 +2,7 @@ Index: xen-4.1.0-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== --- xen-4.1.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py +++ xen-4.1.0-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -2912,7 +2912,7 @@ class XendDomainInfo: +@@ -2913,7 +2913,7 @@ class XendDomainInfo: self.guest_bitsize = self.image.getBitSize() # Make sure there's enough RAM available for the domain diff --git a/cve-2011-1583-4.1.patch b/cve-2011-1583-4.1.patch new file mode 100644 index 0000000..1d2c4a3 --- /dev/null +++ b/cve-2011-1583-4.1.patch @@ -0,0 +1,217 @@ +diff -r dbf2ddf652dc tools/libxc/xc_dom_bzimageloader.c +--- a/tools/libxc/xc_dom_bzimageloader.c Thu Apr 07 15:26:58 2011 +0100 ++++ b/tools/libxc/xc_dom_bzimageloader.c Thu Apr 21 12:05:57 2011 +0100 +@@ -82,8 +82,29 @@ static int xc_try_bzip2_decode( + for ( ; ; ) + { + ret = BZ2_bzDecompress(&stream); +- if ( (stream.avail_out == 0) || (ret != BZ_OK) ) ++ if ( ret == BZ_STREAM_END ) + { ++ DOMPRINTF("BZIP2: Saw data stream end"); ++ retval = 0; ++ break; ++ } ++ if ( ret != BZ_OK ) ++ { ++ DOMPRINTF("BZIP2: error %d", ret); ++ free(out_buf); ++ goto bzip2_cleanup; ++ } ++ ++ if ( stream.avail_out == 0 ) ++ { ++ /* Protect against output buffer overflow */ ++ if ( outsize > INT_MAX / 2 ) ++ { ++ DOMPRINTF("BZIP2: output buffer overflow"); ++ free(out_buf); ++ goto bzip2_cleanup; ++ } ++ + tmp_buf = realloc(out_buf, outsize * 2); + if ( tmp_buf == NULL ) + { +@@ -97,16 +118,18 @@ static int xc_try_bzip2_decode( + stream.avail_out = (outsize * 2) - outsize; + outsize *= 2; + } +- +- if ( ret != BZ_OK ) ++ else if ( stream.avail_in == 0 ) + { +- if ( ret == BZ_STREAM_END ) +- { +- DOMPRINTF("BZIP2: Saw data stream end"); +- retval = 0; +- break; +- } +- DOMPRINTF("BZIP2: error"); ++ /* ++ * If there is output buffer available then this indicates ++ * that BZ2_bzDecompress would like more input data to be ++ * provided. However our complete input buffer is in ++ * memory and provided upfront so if avail_in is zero this ++ * actually indicates a truncated input. ++ */ ++ DOMPRINTF("BZIP2: not enough input"); ++ free(out_buf); ++ goto bzip2_cleanup; + } + } + +@@ -180,31 +203,14 @@ static int xc_try_lzma_decode( + for ( ; ; ) + { + ret = lzma_code(&stream, action); +- if ( (stream.avail_out == 0) || (ret != LZMA_OK) ) ++ if ( ret == LZMA_STREAM_END ) + { +- tmp_buf = realloc(out_buf, outsize * 2); +- if ( tmp_buf == NULL ) +- { +- DOMPRINTF("LZMA: Failed to realloc memory"); +- free(out_buf); +- goto lzma_cleanup; +- } +- out_buf = tmp_buf; +- +- stream.next_out = out_buf + outsize; +- stream.avail_out = (outsize * 2) - outsize; +- outsize *= 2; ++ DOMPRINTF("LZMA: Saw data stream end"); ++ retval = 0; ++ break; + } +- + if ( ret != LZMA_OK ) + { +- if ( ret == LZMA_STREAM_END ) +- { +- DOMPRINTF("LZMA: Saw data stream end"); +- retval = 0; +- break; +- } +- + switch ( ret ) + { + case LZMA_MEM_ERROR: +@@ -238,7 +244,32 @@ static int xc_try_lzma_decode( + } + DOMPRINTF("%s: LZMA decompression error %s", + __FUNCTION__, msg); +- break; ++ free(out_buf); ++ goto lzma_cleanup; ++ } ++ ++ if ( stream.avail_out == 0 ) ++ { ++ /* Protect against output buffer overflow */ ++ if ( outsize > INT_MAX / 2 ) ++ { ++ DOMPRINTF("LZMA: output buffer overflow"); ++ free(out_buf); ++ goto lzma_cleanup; ++ } ++ ++ tmp_buf = realloc(out_buf, outsize * 2); ++ if ( tmp_buf == NULL ) ++ { ++ DOMPRINTF("LZMA: Failed to realloc memory"); ++ free(out_buf); ++ goto lzma_cleanup; ++ } ++ out_buf = tmp_buf; ++ ++ stream.next_out = out_buf + outsize; ++ stream.avail_out = (outsize * 2) - outsize; ++ outsize *= 2; + } + } + +@@ -489,18 +520,18 @@ struct setup_header { + + extern struct xc_dom_loader elf_loader; + +-static unsigned int payload_offset(struct setup_header *hdr) ++static int check_magic(struct xc_dom_image *dom, const void *magic, size_t len) + { +- unsigned int off; ++ if (len > dom->kernel_size) ++ return 0; + +- off = (hdr->setup_sects + 1) * 512; +- off += hdr->payload_offset; +- return off; ++ return (memcmp(dom->kernel_blob, magic, len) == 0); + } + + static int xc_dom_probe_bzimage_kernel(struct xc_dom_image *dom) + { + struct setup_header *hdr; ++ uint64_t payload_offset, payload_length; + int ret; + + if ( dom->kernel_blob == NULL ) +@@ -533,10 +564,30 @@ static int xc_dom_probe_bzimage_kernel(s + return -EINVAL; + } + +- dom->kernel_blob = dom->kernel_blob + payload_offset(hdr); +- dom->kernel_size = hdr->payload_length; + +- if ( memcmp(dom->kernel_blob, "\037\213", 2) == 0 ) ++ /* upcast to 64 bits to avoid overflow */ ++ /* setup_sects is u8 and so cannot overflow */ ++ payload_offset = (hdr->setup_sects + 1) * 512; ++ payload_offset += hdr->payload_offset; ++ payload_length = hdr->payload_length; ++ ++ if ( payload_offset >= dom->kernel_size ) ++ { ++ xc_dom_panic(dom->xch, XC_INVALID_KERNEL, "%s: payload offset overflow", ++ __FUNCTION__); ++ return -EINVAL; ++ } ++ if ( (payload_offset + payload_length) > dom->kernel_size ) ++ { ++ xc_dom_panic(dom->xch, XC_INVALID_KERNEL, "%s: payload length overflow", ++ __FUNCTION__); ++ return -EINVAL; ++ } ++ ++ dom->kernel_blob = dom->kernel_blob + payload_offset; ++ dom->kernel_size = payload_length; ++ ++ if ( check_magic(dom, "\037\213", 2) ) + { + ret = xc_dom_try_gunzip(dom, &dom->kernel_blob, &dom->kernel_size); + if ( ret == -1 ) +@@ -546,7 +597,7 @@ static int xc_dom_probe_bzimage_kernel(s + return -EINVAL; + } + } +- else if ( memcmp(dom->kernel_blob, "\102\132\150", 3) == 0 ) ++ else if ( check_magic(dom, "\102\132\150", 3) ) + { + ret = xc_try_bzip2_decode(dom, &dom->kernel_blob, &dom->kernel_size); + if ( ret < 0 ) +@@ -557,7 +608,7 @@ static int xc_dom_probe_bzimage_kernel(s + return -EINVAL; + } + } +- else if ( memcmp(dom->kernel_blob, "\135\000", 2) == 0 ) ++ else if ( check_magic(dom, "\135\000", 2) ) + { + ret = xc_try_lzma_decode(dom, &dom->kernel_blob, &dom->kernel_size); + if ( ret < 0 ) +@@ -568,7 +619,7 @@ static int xc_dom_probe_bzimage_kernel(s + return -EINVAL; + } + } +- else if ( memcmp(dom->kernel_blob, "\x89LZO", 5) == 0 ) ++ else if ( check_magic(dom, "\x89LZO", 5) ) + { + ret = xc_try_lzo1x_decode(dom, &dom->kernel_blob, &dom->kernel_size); + if ( ret < 0 ) diff --git a/hotplug.losetup.patch b/hotplug.losetup.patch new file mode 100644 index 0000000..3451a97 --- /dev/null +++ b/hotplug.losetup.patch @@ -0,0 +1,34 @@ +Improve busy loop device detection after changeset 22773:02c0af2bf280 + +The intention is not to find the file to be mounted in the losetup -a +output. What matters are existing mounted files with the same dev:inode +as the new file. So the fix is to apply variable expansion which +happens only without double quotes. Otherwise $dev will contain +newlines for hardlinked files, as mentioned in the commit message from +the changeset above. + +losetup -a does also truncate long filenames to 62 chars due to ioctl +limitations. This part is fixed with 2.6.37 where the filename can be +obtained from sysfs. As a result very long filenames will be missed. + +Signed-off-by: Olaf Hering + +--- + tools/hotplug/Linux/block | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +Index: xen-4.1.0-testing/tools/hotplug/Linux/block +=================================================================== +--- xen-4.1.0-testing.orig/tools/hotplug/Linux/block ++++ xen-4.1.0-testing/tools/hotplug/Linux/block +@@ -280,8 +280,8 @@ mount it read-write in a guest domain." + fi + + shared_list=$(losetup -a | +- sed -n -e "s@^\([^:]\+\)\(:[[:blank:]]\[${dev}\]:${inode}[[:blank:]](${file})\)@\1@p" ) +- for dev in "$shared_list" ++ sed -n -e "s@^\([^:]\+\)\(:[[:blank:]]\[${dev}\]:${inode}[[:blank:]](.*)\)@\1@p" ) ++ for dev in $shared_list + do + if [ -n "$dev" ] + then diff --git a/xen.changes b/xen.changes index 5850500..9e4a44b 100644 --- a/xen.changes +++ b/xen.changes @@ -1,3 +1,41 @@ +------------------------------------------------------------------- +Tue May 3 11:11:05 MDT 2011 - carnold@novell.com + +- Upstream patches from Jan + 22998-x86-get_page_from_l1e-retcode.patch + 22999-x86-mod_l1_entry-retcode.patch + 23000-x86-mod_l2_entry-retcode.patch + 23096-x86-hpet-no-cpumask_lock.patch + 23099-x86-rwlock-scalability.patch + 23103-x86-pirq-guest-eoi-check.patch + 23127-vtd-bios-settings.patch + 23153-x86-amd-clear-DramModEn.patch + 23154-x86-amd-iorr-no-rdwr.patch + 23199-amd-iommu-unmapped-intr-fault.patch + 23200-amd-iommu-intremap-sync.patch + 23228-x86-conditional-write_tsc.patch + +------------------------------------------------------------------- +Mon May 2 12:42:16 CEST 2011 - ohering@suse.de + +- update xenalyze to revision 98 + * Unify setting of vcpu data type + * Unify record size checks + * Fix cr3_switch not to access hvm struct before it's initialized +- add xenalyze.gcc46.patch to fix unused-but-set-variable errors + +------------------------------------------------------------------- +Thu Apr 28 14:12:13 MDT 2011 - jfehlig@novell.com + +- bnc#688473 - VUL-0: potential buffer overflow in tools + cve-2011-1583-4.0.patch + +------------------------------------------------------------------- +Thu Apr 28 17:18:57 CEST 2011 - ohering@suse.de + +- hotplug.losetup.patch + correct dev:inode detection and use variable expansion + ------------------------------------------------------------------- Thu Apr 21 16:30:30 CEST 2011 - ohering@suse.de diff --git a/xen.spec b/xen.spec index d5e05fe..2659aa2 100644 --- a/xen.spec +++ b/xen.spec @@ -1,5 +1,5 @@ # -# spec file for package xen +# spec file for package xen (Version 4.1.0_01) # # Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -31,39 +31,39 @@ ExclusiveArch: %ix86 x86_64 %else %define with_xend 1 %endif -BuildRequires: LibVNCServer-devel -BuildRequires: SDL-devel -BuildRequires: automake -BuildRequires: bin86 -BuildRequires: curl-devel -BuildRequires: dev86 -BuildRequires: graphviz -BuildRequires: latex2html -BuildRequires: libjpeg-devel -BuildRequires: libxml2-devel -BuildRequires: ncurses-devel -BuildRequires: openssl -BuildRequires: openssl-devel -BuildRequires: pciutils-devel -BuildRequires: python-devel -BuildRequires: texinfo -BuildRequires: transfig -BuildRequires: libbz2-devel +BuildRequires: LibVNCServer-devel +BuildRequires: SDL-devel +BuildRequires: automake +BuildRequires: bin86 +BuildRequires: curl-devel +BuildRequires: dev86 +BuildRequires: graphviz +BuildRequires: latex2html +BuildRequires: libjpeg-devel +BuildRequires: libxml2-devel +BuildRequires: ncurses-devel +BuildRequires: openssl +BuildRequires: openssl-devel +BuildRequires: pciutils-devel +BuildRequires: python-devel +BuildRequires: texinfo +BuildRequires: transfig +BuildRequires: libbz2-devel %if %suse_version >= 1120 -BuildRequires: xz-devel +BuildRequires: xz-devel %endif %if %suse_version <= 1110 -BuildRequires: pmtools +BuildRequires: pmtools %else -BuildRequires: acpica +BuildRequires: acpica %endif %if %suse_version >= 1030 -BuildRequires: texlive -BuildRequires: texlive-latex +BuildRequires: texlive +BuildRequires: texlive-latex %else -BuildRequires: te_ams -BuildRequires: te_latex -BuildRequires: tetex +BuildRequires: te_ams +BuildRequires: te_latex +BuildRequires: tetex %endif %ifarch x86_64 BuildRequires: glibc-32bit glibc-devel-32bit @@ -80,7 +80,7 @@ BuildRequires: glibc-devel BuildRequires: kernel-source kernel-syms module-init-tools xorg-x11 %endif Version: 4.1.0_01 -Release: 9 +Release: 1 License: GPLv2+ Group: System/Kernel AutoReqProv: on @@ -117,9 +117,22 @@ Source24: xenapiusers # sysconfig hook script for Xen Source25: xen-updown.sh Source99: baselibs.conf -# http://xenbits.xensource.com/ext/xenalyze.hg +# http://xenbits.xensource.com/ext/xenalyze Source20000: xenalyze.hg.tar.bz2 # Upstream patches +Patch0: cve-2011-1583-4.1.patch +Patch1: 22998-x86-get_page_from_l1e-retcode.patch +Patch2: 22999-x86-mod_l1_entry-retcode.patch +Patch3: 23000-x86-mod_l2_entry-retcode.patch +Patch4: 23096-x86-hpet-no-cpumask_lock.patch +Patch5: 23099-x86-rwlock-scalability.patch +Patch6: 23103-x86-pirq-guest-eoi-check.patch +Patch7: 23127-vtd-bios-settings.patch +Patch8: 23153-x86-amd-clear-DramModEn.patch +Patch9: 23154-x86-amd-iorr-no-rdwr.patch +Patch10: 23199-amd-iommu-unmapped-intr-fault.patch +Patch11: 23200-amd-iommu-intremap-sync.patch +Patch12: 23228-x86-conditional-write_tsc.patch # Upstream qemu patches # Our patches Patch300: xen-config.diff @@ -172,7 +185,7 @@ Patch370: xend-sysconfig.patch Patch371: domu-usb-controller.patch Patch372: usb-list.patch Patch373: xend-devid-or-name.patch -Patch374: suspend_evtchn_lock.patch +Patch374: suspend_evtchn_lock.patch # Patches for snapshot support Patch400: snapshot-ioemu-save.patch Patch401: snapshot-ioemu-restore.patch @@ -208,6 +221,7 @@ Patch440: bdrv_default_rwflag.patch Patch442: xen-minimum-restart-time.patch Patch443: vif-bridge.mtu.patch Patch444: xentrace.dynamic_sized_tbuf.patch +Patch445: hotplug.losetup.patch # Jim's domain lock patch Patch450: xend-domain-lock.patch # Hypervisor and PV driver Patches @@ -228,34 +242,36 @@ Patch651: ioemu-disable-scsi.patch Patch652: ioemu-disable-emulated-ide-if-pv.patch Patch700: hv_extid_compatibility.patch # FATE 310510 -Patch10001: xenpaging.tools_xenpaging_cleanup.patch -Patch10002: xenpaging.pageout_policy.patch -Patch10003: xenpaging.get_paged_frame.patch -Patch10004: xenpaging.makefile.patch -Patch10010: xenpaging.policy_linear.patch -Patch10011: xenpaging.pagefile.patch -Patch10012: xenpaging.xenpaging_init.patch -Patch10013: xenpaging.mem_paging_tool_qemu_flush_cache.patch -Patch10014: xenpaging.machine_to_phys_mapping.patch -Patch10015: xenpaging.populate_only_if_paged.patch -Patch10017: xenpaging.autostart.patch -Patch10018: xenpaging.signal_handling.patch -Patch10019: xenpaging.MRU_SIZE.patch -Patch10020: xenpaging.guest_remove_page.patch -Patch10021: xenpaging.mem_event_check_ring-free_requests.patch -Patch10022: xenpaging.blacklist.patch -Patch10023: xenpaging.autostart_delay.patch -Patch10024: xenpaging.page_already_populated.patch -Patch10025: xenpaging.notify_policy_only_once.patch -Patch10026: xenpaging.num_pages_equal_max_pages.patch -Patch10027: xenpaging.p2m_mem_paging_populate_if_p2m_ram_paged.patch -Patch10028: xenpaging.HVMCOPY_gfn_paged_out.patch -Patch10029: xenpaging.optimize_p2m_mem_paging_populate.patch -Patch10030: xenpaging.paging_prep_enomem.patch -Patch10031: xenpaging.print-arguments.patch -Patch10032: xenpaging.no_domain_id.patch -Patch10033: xenpaging.runtime_mru_size.patch -Patch10040: xenpaging.doc.patch +Patch10001: xenpaging.tools_xenpaging_cleanup.patch +Patch10002: xenpaging.pageout_policy.patch +Patch10003: xenpaging.get_paged_frame.patch +Patch10004: xenpaging.makefile.patch +Patch10010: xenpaging.policy_linear.patch +Patch10011: xenpaging.pagefile.patch +Patch10012: xenpaging.xenpaging_init.patch +Patch10013: xenpaging.mem_paging_tool_qemu_flush_cache.patch +Patch10014: xenpaging.machine_to_phys_mapping.patch +Patch10015: xenpaging.populate_only_if_paged.patch +Patch10017: xenpaging.autostart.patch +Patch10018: xenpaging.signal_handling.patch +Patch10019: xenpaging.MRU_SIZE.patch +Patch10020: xenpaging.guest_remove_page.patch +Patch10021: xenpaging.mem_event_check_ring-free_requests.patch +Patch10022: xenpaging.blacklist.patch +Patch10023: xenpaging.autostart_delay.patch +Patch10024: xenpaging.page_already_populated.patch +Patch10025: xenpaging.notify_policy_only_once.patch +Patch10026: xenpaging.num_pages_equal_max_pages.patch +Patch10027: xenpaging.p2m_mem_paging_populate_if_p2m_ram_paged.patch +Patch10028: xenpaging.HVMCOPY_gfn_paged_out.patch +Patch10029: xenpaging.optimize_p2m_mem_paging_populate.patch +Patch10030: xenpaging.paging_prep_enomem.patch +Patch10031: xenpaging.print-arguments.patch +Patch10032: xenpaging.no_domain_id.patch +Patch10033: xenpaging.runtime_mru_size.patch +Patch10040: xenpaging.doc.patch +# xenalyze +Patch20000: xenalyze.gcc46.patch # Build patch Patch99999: tmp_build.patch Url: http://www.cl.cam.ac.uk/Research/SRG/netos/xen/ @@ -588,7 +604,21 @@ Authors: %prep %setup -q -n %xen_build_dir -a 1 -a 20000 +%patch20000 -p1 tar xfj %{SOURCE2} -C $RPM_BUILD_DIR/%{xen_build_dir}/tools +%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 %patch300 -p1 %patch301 -p1 %patch302 -p1 @@ -671,6 +701,7 @@ tar xfj %{SOURCE2} -C $RPM_BUILD_DIR/%{xen_build_dir}/tools %patch442 -p1 %patch443 -p1 %patch444 -p1 +%patch445 -p1 %patch450 -p1 %patch500 -p1 %patch501 -p1 @@ -718,6 +749,7 @@ tar xfj %{SOURCE2} -C $RPM_BUILD_DIR/%{xen_build_dir}/tools #%patch10040 -p1 %patch99999 -p1 + %build XEN_EXTRAVERSION=%version-%release XEN_EXTRAVERSION=${XEN_EXTRAVERSION#%{xvers}} diff --git a/xenalyze.gcc46.patch b/xenalyze.gcc46.patch new file mode 100644 index 0000000..880a565 --- /dev/null +++ b/xenalyze.gcc46.patch @@ -0,0 +1,122 @@ +gcc -I../xen/include -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -g -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -mno-tls-direct-seg-refs -Werror -o xenalyze xenalyze.c +xenalyze.c: In function 'weighted_percentile': +xenalyze.c:2017:9: error: variable 'progress' set but not used [-Werror=unused-but-set-variable] +xenalyze.c: In function 'self_weighted_percentile': +xenalyze.c:2105:9: error: variable 'progress' set but not used [-Werror=unused-but-set-variable] +xenalyze.c: In function 'interval_domain_short_summary_output': +xenalyze.c:2729:15: error: variable 'interval_cycles' set but not used [-Werror=unused-but-set-variable] +xenalyze.c: In function 'hvm_generic_dump': +xenalyze.c:4675:15: error: variable 'd' set but not used [-Werror=unused-but-set-variable] +xenalyze.c: In function 'sched_runstate_process': +xenalyze.c:6883:9: error: variable 'old_runstate' set but not used [-Werror=unused-but-set-variable] +xenalyze.c:6882:11: error: variable 'runstate_tsc' set but not used [-Werror=unused-but-set-variable] +xenalyze.c: In function 'cmd_parser': +xenalyze.c:9253:24: error: variable 'p' set but not used [-Werror=unused-but-set-variable] +cc1: all warnings being treated as errors + +--- + xenalyze.hg/xenalyze.c | 21 --------------------- + 1 file changed, 21 deletions(-) + +Index: xen-4.1.0-testing/xenalyze.hg/xenalyze.c +=================================================================== +--- xen-4.1.0-testing.orig/xenalyze.hg/xenalyze.c ++++ xen-4.1.0-testing/xenalyze.hg/xenalyze.c +@@ -2016,8 +2016,6 @@ float weighted_percentile(float * A, /* + float X, t1; + unsigned long long t2; + +- int progress; +- + /* Calculate total weight */ + N_weight=0; + +@@ -2078,15 +2076,11 @@ float weighted_percentile(float * A, /* + } + } while (I <= J); /* Keep going until our pointers meet or pass */ + +- progress = 0; +- + /* Re-adjust L and R, based on which element we're looking for */ + if(J_weighttotal_time.interval.cycles; +- + interval_time_output(); + + interval_cycle_percent_output(&d->total_time.interval); +@@ -4663,7 +4648,6 @@ void hvm_generic_dump(struct record_info + } *cr = (typeof(cr))ri->d; + + char *evt_string, evt_number[256]; +- unsigned *d; + int i, evt, is_64 = 0; + + evt = ri->event - TRC_HVM_HANDLER; +@@ -4683,7 +4667,6 @@ void hvm_generic_dump(struct record_info + evt_string = evt_number; + } + +- d = ri->d; + printf("%s%s %s%s [", + prefix, + ri->dump_header, +@@ -6867,8 +6850,6 @@ void sched_runstate_process(struct pcpu_ + } sevt; + int perfctrs; + struct last_oldstate_struct last_oldstate; +- tsc_t runstate_tsc; +- int old_runstate; + + switch(_sevt.lo) + { +@@ -6938,8 +6919,6 @@ void sched_runstate_process(struct pcpu_ + * be reset, it will be reset below. */ + last_oldstate = v->runstate.last_oldstate; + v->runstate.last_oldstate.wrong = RUNSTATE_INIT; +- runstate_tsc = v->runstate.tsc; +- old_runstate = v->runstate.state; + + /* Close vmexits when the putative reason for blocking / &c stops. + * This way, we don't account cpu contention to some other overhead. */ diff --git a/xenalyze.hg.tar.bz2 b/xenalyze.hg.tar.bz2 index cc5f911..36a39ea 100644 --- a/xenalyze.hg.tar.bz2 +++ b/xenalyze.hg.tar.bz2 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:870743ab79d34e066a9b090e6555e9fe626165e9d7de28b6a6af136a2b8c4095 -size 118364 +oid sha256:6f1d68fa351de9e0d67790b038f791fec6c159530e59f1d9d03ba47f94f1095e +size 118689 From 462ca58fee09c03ae91a8c5aa33523d92f793c2119d531c2437d0e594bba5cb1 Mon Sep 17 00:00:00 2001 From: James Fehlig Date: Tue, 10 May 2011 16:44:09 +0000 Subject: [PATCH 4/4] - bnc#691256 - move modprobe of xen backend modules from xend to xencommons initscript tmp-initscript-modprobe.patch - bnc#691738 - Xen does not find device create with npiv block xen-qemu-iscsi-fix.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=116 --- bdrv_open2_flags_2.patch | 2 +- init.xend | 13 ------------- ioemu-disable-emulated-ide-if-pv.patch | 2 +- snapshot-ioemu-delete.patch | 2 +- snapshot-ioemu-restore.patch | 4 ++-- snapshot-ioemu-save.patch | 6 +++--- tmp-initscript-modprobe.patch | 23 +++++++++++++++++++++++ xen-qemu-iscsi-fix.patch | 13 +++++++++++++ xen.changes | 13 +++++++++++++ xen.spec | 2 ++ 10 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 tmp-initscript-modprobe.patch diff --git a/bdrv_open2_flags_2.patch b/bdrv_open2_flags_2.patch index e299095..38b4045 100644 --- a/bdrv_open2_flags_2.patch +++ b/bdrv_open2_flags_2.patch @@ -70,7 +70,7 @@ Index: xen-4.1.0-testing/tools/ioemu-qemu-xen/xenstore.c pstrcpy(bs->filename, sizeof(bs->filename), params); } #else -@@ -710,7 +723,7 @@ void xenstore_parse_domain_config(int hv +@@ -716,7 +729,7 @@ void xenstore_parse_domain_config(int hv fprintf(stderr, "Using file %s in read-%s mode\n", bs->filename, is_readonly ? "only" : "write"); diff --git a/init.xend b/init.xend index 63c7002..14deb6e 100644 --- a/init.xend +++ b/init.xend @@ -81,19 +81,6 @@ case "$1" in else cleanup fi - # Load XEN backend modules - # Sidenote: They could be loaded later: - # - netbk and blkbk when the dom0 hotplug events occur - # (in xen-network-common.sh and block-common.sh) - # - xenblk when xend prepares for bootloader - # but for now it's safest to have them loaded when xend starts in dom0. - modprobe evtchn 2>/dev/null || true - modprobe blktap 2>/dev/null || true - modprobe blkbk 2>/dev/null || true - modprobe xenblk 2>/dev/null || true - modprobe netbk 2>/dev/null || true - modprobe gntdev 2>/dev/null || true - modprobe usbbk 2>/dev/null || true xend start await_daemons_up ;; diff --git a/ioemu-disable-emulated-ide-if-pv.patch b/ioemu-disable-emulated-ide-if-pv.patch index 1bd2e8b..1abd9b8 100644 --- a/ioemu-disable-emulated-ide-if-pv.patch +++ b/ioemu-disable-emulated-ide-if-pv.patch @@ -49,7 +49,7 @@ Index: xen-4.1.0-testing/tools/ioemu-qemu-xen/xenstore.c { char **e_danger = NULL; char *buf = NULL; -@@ -754,15 +754,19 @@ void xenstore_parse_domain_config(int hv +@@ -760,15 +760,19 @@ void xenstore_parse_domain_config(int hv #endif diff --git a/snapshot-ioemu-delete.patch b/snapshot-ioemu-delete.patch index 6b3eb2a..1fef3db 100644 --- a/snapshot-ioemu-delete.patch +++ b/snapshot-ioemu-delete.patch @@ -2,7 +2,7 @@ Index: xen-4.1.0-testing/tools/ioemu-qemu-xen/xenstore.c =================================================================== --- xen-4.1.0-testing.orig/tools/ioemu-qemu-xen/xenstore.c +++ xen-4.1.0-testing/tools/ioemu-qemu-xen/xenstore.c -@@ -972,6 +972,18 @@ static void xenstore_process_dm_command_ +@@ -978,6 +978,18 @@ static void xenstore_process_dm_command_ } snapshot_name = xs_read(xsh, XBT_NULL, path, &len); diff --git a/snapshot-ioemu-restore.patch b/snapshot-ioemu-restore.patch index c49bf4d..c39f73b 100644 --- a/snapshot-ioemu-restore.patch +++ b/snapshot-ioemu-restore.patch @@ -11,7 +11,7 @@ Index: xen-4.1.0-testing/tools/ioemu-qemu-xen/xenstore.c static int pasprintf(char **buf, const char *fmt, ...) { va_list ap; -@@ -708,8 +710,33 @@ void xenstore_parse_domain_config(int hv +@@ -714,8 +716,33 @@ void xenstore_parse_domain_config(int hv fprintf(stderr, "Using file %s in read-%s mode\n", bs->filename, is_readonly ? "only" : "write"); @@ -46,7 +46,7 @@ Index: xen-4.1.0-testing/tools/ioemu-qemu-xen/xenstore.c } #endif -@@ -839,6 +866,23 @@ int xenstore_parse_disable_pf_config () +@@ -845,6 +872,23 @@ int xenstore_parse_disable_pf_config () return disable_pf; } diff --git a/snapshot-ioemu-save.patch b/snapshot-ioemu-save.patch index ea37458..b0b89a3 100644 --- a/snapshot-ioemu-save.patch +++ b/snapshot-ioemu-save.patch @@ -207,7 +207,7 @@ Index: xen-4.1.0-testing/tools/ioemu-qemu-xen/xenstore.c #include "console.h" #include "hw.h" -@@ -899,6 +900,7 @@ static void xenstore_process_dm_command_ +@@ -905,6 +906,7 @@ static void xenstore_process_dm_command_ { char *path = NULL, *command = NULL, *par = NULL; unsigned int len; @@ -215,7 +215,7 @@ Index: xen-4.1.0-testing/tools/ioemu-qemu-xen/xenstore.c if (pasprintf(&path, "/local/domain/0/device-model/%u/command", domid) == -1) { -@@ -914,7 +916,18 @@ static void xenstore_process_dm_command_ +@@ -920,7 +922,18 @@ static void xenstore_process_dm_command_ if (!strncmp(command, "save", len)) { fprintf(logfile, "dm-command: pause and save state\n"); @@ -235,7 +235,7 @@ Index: xen-4.1.0-testing/tools/ioemu-qemu-xen/xenstore.c } else if (!strncmp(command, "continue", len)) { fprintf(logfile, "dm-command: continue after state save\n"); xen_pause_requested = 0; -@@ -1077,6 +1090,13 @@ static void xenstore_process_vcpu_set_ev +@@ -1083,6 +1096,13 @@ static void xenstore_process_vcpu_set_ev return; } diff --git a/tmp-initscript-modprobe.patch b/tmp-initscript-modprobe.patch new file mode 100644 index 0000000..38dd881 --- /dev/null +++ b/tmp-initscript-modprobe.patch @@ -0,0 +1,23 @@ +Index: xen-4.1.0-testing/tools/hotplug/Linux/init.d/xencommons +=================================================================== +--- xen-4.1.0-testing.orig/tools/hotplug/Linux/init.d/xencommons ++++ xen-4.1.0-testing/tools/hotplug/Linux/init.d/xencommons +@@ -45,6 +45,18 @@ do_start () { + local time=0 + local timeout=30 + ++ # Load XEN backend modules ++ # NB: They could be loaded later, e.g. when dom0 hotplug events occur, ++ # but for now it's safest to have them loaded here. ++ modprobe evtchn 2>/dev/null || true ++ modprobe gntdev 2>/dev/null || true ++ modprobe blktap 2>/dev/null || true ++ modprobe blkbk 2>/dev/null || true ++ modprobe netbk 2>/dev/null || true ++ modprobe usbbk 2>/dev/null || true ++ # xenblk (frontend module) is needed in dom0, allowing it to use vbds ++ modprobe xenblk 2>/dev/null || true ++ + if ! `xenstore-read -s / >/dev/null 2>&1` + then + test -z "$XENSTORED_ROOTDIR" || XENSTORED_ROOTDIR="/var/lib/xenstored" diff --git a/xen-qemu-iscsi-fix.patch b/xen-qemu-iscsi-fix.patch index e0b9815..b80a68d 100644 --- a/xen-qemu-iscsi-fix.patch +++ b/xen-qemu-iscsi-fix.patch @@ -61,3 +61,16 @@ Index: xen-4.1.0-testing/tools/ioemu-qemu-xen/xenstore.c /* Obtain blktap sub-type prefix */ if ((!strcmp(drv, "tap") || !strcmp(drv, "qdisk")) && params[0]) { char *offset = strchr(params, ':'); +@@ -657,6 +681,12 @@ void xenstore_parse_domain_config(int hv + format = &bdrv_host_device; + else + format = &bdrv_raw; ++ } else if (!strcmp(drv,"iscsi")) { ++ format = &bdrv_raw; ++ } else if (!strcmp(drv,"npiv")) { ++ format = &bdrv_raw; ++ } else if (!strcmp(drv,"dmmd")) { ++ format = &bdrv_raw; + } else { + format = bdrv_find_format(drv); + if (!format) { diff --git a/xen.changes b/xen.changes index 9e4a44b..74c721e 100644 --- a/xen.changes +++ b/xen.changes @@ -1,3 +1,16 @@ +------------------------------------------------------------------- +Tue May 10 08:53:27 MDT 2011 - jfehlig@novell.com + +- bnc#691256 - move modprobe of xen backend modules from xend to + xencommons initscript + tmp-initscript-modprobe.patch + +------------------------------------------------------------------- +Mon May 9 16:26:06 MDT 2011 - jfehlig@novell.com + +- bnc#691738 - Xen does not find device create with npiv block + xen-qemu-iscsi-fix.patch + ------------------------------------------------------------------- Tue May 3 11:11:05 MDT 2011 - carnold@novell.com diff --git a/xen.spec b/xen.spec index 2659aa2..393b10b 100644 --- a/xen.spec +++ b/xen.spec @@ -273,6 +273,7 @@ Patch10040: xenpaging.doc.patch # xenalyze Patch20000: xenalyze.gcc46.patch # Build patch +Patch99998: tmp-initscript-modprobe.patch Patch99999: tmp_build.patch Url: http://www.cl.cam.ac.uk/Research/SRG/netos/xen/ BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -747,6 +748,7 @@ tar xfj %{SOURCE2} -C $RPM_BUILD_DIR/%{xen_build_dir}/tools #%patch10032 -p1 #%patch10033 -p1 #%patch10040 -p1 +%patch99998 -p1 %patch99999 -p1