rpms/kernel-xen-2.6/devel linux-2.6-efika-not-chrp.patch, NONE, 1.1 linux-2.6-nfs-client-mounts-hang.patch, NONE, 1.1 linux-2.6-smp-boot-delay.patch, NONE, 1.1 linux-2.6-xen-0004-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch, 1.3, 1.4 linux-2.6-xen-0005-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch, NONE, 1.1 linux-2.6-xen-0006-xen-Enable-Xen-console-by-default-in-domU.patch, NONE, 1.1 linux-2.6-xen-0007-xen-Module-autoprobing-support-for-frontend-drivers.patch, 1.7, 1.8 linux-2.6-xen-0008-xen-Add-compatibility-aliases-for-frontend-drivers.patch, 1.7, 1.8 linux-2.6-xen-0009-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch, 1.6, 1.7 linux-2.6-xen-0010-xen-Add-a-vmlinuz-target.patch, 1.6, 1.7 linux-2.6-xen-0011-xen-Add-empty-xenctrl-module.patch, 1.6, 1.7 linux-2.6-xen-0012-xen-Add-proc-xen-capabilities.patch, 1.6, 1.7 linux-2.6-xen-0013-xen-Add-proc-xen-privcmd.patch, 1.6, 1.7 linux-2.6-xen-0014-xen-Add-proc-xen-xenbus.patch, 1.6, 1.7 linux-2.6-xen-0015-xen-Add-Xen-s-sys-hypervisor-interface.patch, 1.6, 1.7 linux-2.6-xen-0016-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch, 1.6, 1.7 linux-2.6-xen-0017-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch, 1.7, 1.8 linux-2.6-xen-0018-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch, 1.4, 1.5 linux-2.6-xen-0019-xen-expose-set_pte_vaddr-and-make-xen-use-it.patch, NONE, 1.1 linux-2.6-xen-0020-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch, NONE, 1.1 linux-2.6-xen-0021-x86_64-Expose-set_pte_vaddr.patch, NONE, 1.1 linux-2.6-xen-0022-x86_64-Split-set_pte_vaddr.patch, NONE, 1.1 linux-2.6-xen-0023-x86_64-Add-clear_fixmap.patch, NONE, 1.1 linux-2.6-xen-0024-xen-x86_64-Make-set_fixmap-a-paravirt-op-on-64-bi.patch, NONE, 1.1 linux-2.6-xen-0025-xen-x86_64-Hack-to-set-vsyscall-pages-on-user-space.patch, NONE, 1.1 linux-2.6-xen-0026-Handle-VSYSCALL_FIRST_PAGE-on-xen_set_pte.patch, NONE, 1.1 linux-2.6-xen-0027-DMI-Define-dmi_scan_machine-as-no-op-if-CONFIG_DM.patch, NONE, 1.1 linux-2.6-xen-0028-ACPI-thermal-Compile-without-CONFIG_DMI.patch, NONE, 1.1 linux-2.6-xen-0029-xen-x86_64-Remove-the-640K-1M-hole-and-disable-DMI.patch, NONE, 1.1 linux-2.6-xen-0030-xen-x86_64-Add-update_va_mapping-64-bit-code.patch, NONE, 1.1 linux-2.6-xen-0031-x86_64-Add-sync_cmpxchg.patch, NONE, 1.1 linux-2.6-xen-0032-xen-x86_64-Implement-HYPERVISOR-MULTI-_update_desc.patch, NONE, 1.1 linux-2.6-xen-0033-xen-x86_64-Add-hacky-64-bit-x86_-read-write-_percpu.patch, NONE, 1.1 linux-2.6-xen-0034-xen-x86_64-Use-x86_read_percpu-only-to-refer-to-a.patch, NONE, 1.1 linux-2.6-xen-0035-Better-implementation-of-pte-functions.patch, NONE, 1.1 linux-2.6-xen-0036-Add-FIX_PARAVIRT_BOOTAP-to-fixmap_64.h-too.patch, NONE, 1.1 linux-2.6-xen-0037-Add-gate_offset-and-gate_segment-macros.patch, NONE, 1.1 linux-2.6-xen-0038-xen_write_idt_entry-and-cvt_gate_to_trap.patch, NONE, 1.1 linux-2.6-xen-0039-typedefs-for-pte_val-and-friends.patch, NONE, 1.1 linux-2.6-xen-0040-x86_64-implementation-of-some-page.h-macros.patch, NONE, 1.1 linux-2.6-xen-0041-Chainsaw-style-ifdefs.patch, NONE, 1.1 linux-2.6-xen-0042-xen-Make-xen_pte_val-generic.patch, NONE, 1.1 linux-2.6-xen-0043-More-chainsaw-ifdefs.patch, NONE, 1.1 linux-2.6-xen-0044-Chainsaw-ifdefs-on-assembly-percpu-handling.patch, NONE, 1.1 linux-2.6-xen-0045-x86_64-percpu-assembly-macros.patch, NONE, 1.1 linux-2.6-xen-0046-Some-xen-asm.S-x86_64-code.patch, NONE, 1.1 linux-2.6-xen-0047-Chainsaw-party-SPLITME.patch, NONE, 1.1 linux-2.6-xen-0048-xen-asm.S-x86_64-notes.patch, NONE, 1.1 linux-2.6-xen-0049-xen-x86_64-Make-hypercall-assembly-code-work.patch, NONE, 1.1 linux-2.6-xen-0050-xen-x86_64-pda-initialization.patch, NONE, 1.1 linux-2.6-xen-0051-Disable-discover_ebda-under-paravirt.patch, NONE, 1.1 linux-2.6-xen-0052-Disable-early_printk-by-default.patch, NONE, 1.1 linux-2.6-xen-0053-xen-Set-__HYPERVISOR_VIRT_START-for-x86_64.patch, NONE, 1.1 linux-2.6-xen-0054-Set-__PAGE_OFFSET-as-required-by-Xen.patch, NONE, 1.1 linux-2.6-xen-0055-DEBUG-Add-xprintk-to-log-directly-via-hypercall-fo.patch, NONE, 1.1 linux-2.6-xen-0056-Use-__pgd-on-mk_kernel_pgd.patch, NONE, 1.1 linux-2.6-xen-0057-Include-user-page-tables-on-head_64.S.patch, NONE, 1.1 linux-2.6-xen-0058-Avoid-using-mk_unsigned_long.patch, NONE, 1.1 linux-2.6-xen-0059-Lots-of-unrelated-changes.patch, NONE, 1.1 linux-2.6-xen-0060-Hack-disable-vsmp.patch, NONE, 1.1 linux-2.6-xen-0061-Export-early_make_page_readonly.patch, NONE, 1.1 linux-2.6-xen-0062-Disable-multicalls.c-too-verbose-debugging.patch, NONE, 1.1 linux-2.6-xen-0063-Xen-64-bit-ready-MMU-operations.patch, NONE, 1.1 linux-2.6-xen-0064-Some-xen-mmu-pv-ops-implemented.patch, NONE, 1.1 linux-2.6-xen-0065-Trying-to-make-the-pagetable-initialization-code-wor.patch, NONE, 1.1 linux-2.6-xen-0066-Xen-specific-find_early_table_space-FIXME.patch, NONE, 1.1 linux-2.6-xen-0067-Xen-call-e820_print_map-when-setting-up-memory.patch, NONE, 1.1 linux-2.6-xen-0068-Comment-debugging-msgs.patch, NONE, 1.1 linux-2.6-xen-0069-Try-to-make-pagetables-read-only.patch, NONE, 1.1 linux-2.6-xen-0070-Debug-dump-pgtables-on-make_page_readonly.patch, NONE, 1.1 linux-2.6-xen-0071-Disable-apic-at-compile-time-FIXME.patch, NONE, 1.1 linux-2.6-xen-0072-Parse-early-params-after-init_memory_mapping.patch, NONE, 1.1 linux-2.6-xen-0073-xen-Move-addr_to_page-to-init.h.patch, NONE, 1.1 linux-2.6-xen-0074-Make-xen_pxx_val-and-xen_make_pxx-handle-attr-bi.patch, NONE, 1.1 linux-2.6-xen-0075-Pull-xen_finish_init_mappin-from-XS-upstream.patch, NONE, 1.1 linux-2.6-xen-0076-Pull-spp_getpage-changes-from-XS-upstream-REVIEWM.patch, NONE, 1.1 linux-2.6-xen-0077-Pull-xen_extend_init_mapping-from-XS-upstream-FIX.patch, NONE, 1.1 linux-2.6-xen-0078-New-enum-fixed_addresses-values-REVIEWME.patch, NONE, 1.1 linux-2.6-xen-0079-Reserve-bootmem-areas-used-by-Xen-FIXME.patch, NONE, 1.1 linux-2.6-xen-0080-xen_convert_trap_info-use-sizeof-struct-gate_desc.patch, NONE, 1.1 linux-2.6-xen-0081-Call-paravirt_pagetable_setup_-start-done-REVIEW.patch, NONE, 1.1 linux-2.6-xen-0082-ifdef-CONFIG_X86_32-on-xen-enlighten.c-REVIEWME.patch, NONE, 1.1 linux-2.6-xen-0083-Handle-Xen-exception-stack-it-is-different-from-bar.patch, NONE, 1.1 linux-2.6-xen-0084-Make-hvc_xen-console-use-xprintk-TEMPORARY.patch, NONE, 1.1 linux-2.6-xen-0085-Implement-64-bit-version-of-HYPERVISOR_set_callbacks.patch, NONE, 1.1 linux-2.6-xen-0086-Make-arch_vcpu_info-be-of-the-right-size-on-both-32.patch, NONE, 1.1 linux-2.6-xen-0087-Implement-asm-xen_iret.patch, NONE, 1.1 linux-2.6-xen-0088-xen-64-xen_iret-use-iretq-directly-if-returning-t.patch, NONE, 1.1 linux-2.6-xen-0089-Implement-xen_irqenable_syscall_ret.patch, NONE, 1.1 linux-2.6-xen-0090-DEBUG-xen_iret-always-return-through-the-hyperviso.patch, NONE, 1.1 linux-2.6-xen-0091-Implement-some-xen-callbacks-on-xen-entry_64.S.patch, NONE, 1.1 linux-2.6-xen-0092-Xen-specific-ifdef-hacks-on-kernel-entry_64.S-FIXM.patch, NONE, 1.1 linux-2.6-xen-0093-Disable-syscall32-code-temporarily-FIXME.patch, NONE, 1.1 linux-2.6-xen-0094-Use-__KERNEL_DS-as-SS-when-returning-to-a-kernel-thr.patch, NONE, 1.1 linux-2.6-xen-0095-Use-apic_xen-on-genapic-by-default-FIXME.patch, NONE, 1.1 linux-2.6-xen-0096-irq-vector-ifdef-chainsaw-FIXME.patch, NONE, 1.1 linux-2.6-xen-0097-ifdef-chainsaw-on-syscall_init-FIXME.patch, NONE, 1.1 linux-2.6-xen-0098-Pull-xen-genapic-implementation-from-upstream-Xen.patch, NONE, 1.1 linux-2.6-xen-0099-Debugging-printk-s.patch, NONE, 1.1 linux-2.6-xen-0100-Leave-lazy_cpu_mode-on-__switch_to.patch, NONE, 1.1 linux-2.6-xen-0101-xen-64-Handle-fs-and-gs-on-xen_load_tls-properl.patch, NONE, 1.1 linux-2.6-xen-0102-Disable-vcpu_info_placement-temporarily-FIXME.patch, NONE, 1.1 linux-2.6-xen-0103-Fix-typo-on-ifdef-again.patch, NONE, 1.1 linux-2.6-xen-0104-DEBUG-Don-t-try-to-actually-read-the-page-on-show_.patch, NONE, 1.1 linux-2.6-xen-0105-Make-load_gs_index-a-paravirt-operation.patch, NONE, 1.1 linux-2.6-xen-0106-xen-pgd_walk-use-limit-argument-instead-of-FIXADD.patch, NONE, 1.1 linux-2.6-xen-0107-xen-pgd_walk-Eliminate-BUG_ON-limit-FIXADDR_TOP.patch, NONE, 1.1 linux-2.6-xen-0108-xen-pgd_walk-accept-start-parameter.patch, NONE, 1.1 linux-2.6-xen-0109-xen-64-reserve_bootmem-xen_start_info-area.patch, NONE, 1.1 linux-2.6-xen-0110-pvops-64-call-paravirt_post_allocator_init-on-set.patch, NONE, 1.1 linux-2.6-xen-0111-use-write_gdt_entry-on-vsyscall_set_cpu-CLEANME.patch, NONE, 1.1 linux-2.6-xen-0112-xen-64-implement-xen_load_gs_index.patch, NONE, 1.1 linux-2.6-xen-0113-include-asm-x86-pgalloc_64.h-pvops-hacks-SPLITME.patch, NONE, 1.1 linux-2.6-xen-0114-Multi-pagetable-write_cr3-implementation-FIXME.patch, NONE, 1.1 linux-2.6-xen-0115-Make-kcons_write_dom0-non-static-TEMPORARY.patch, NONE, 1.1 linux-2.6-xen-0116-Disable-the-weird-count-loop-on-kcons_write_dom0.patch, NONE, 1.1 linux-2.6-xen-0117-Make-xen_start_info-read-only.patch, NONE, 1.1 linux-2.6-xen-0118-Hack-to-implement-return-to-userspace-without-SWAPGS.patch, NONE, 1.1 linux-2.6-xen-0119-Xen-SEGBASE_-defines.patch, NONE, 1.1 linux-2.6-xen-0120-Xen-HYPERVISOR_set_segment_base-implementation.patch, NONE, 1.1 linux-2.6-xen-0121-Change-signature-of-paravirt_alloc_-pt-pd-REVIEWME.patch, NONE, 1.1 linux-2.6-xen-0122-Comment-e820_print_map-call-TEMPORARY.patch, NONE, 1.1 linux-2.6-xen-0123-Xen-missing-includes.patch, NONE, 1.1 linux-2.6-xen-0124-asm-x86-pgtable_64.h-include-linux-spinlock.h.patch, NONE, 1.1 linux-2.6-xen-0125-asm-x86-pgtable.h-include-asm-page.h.patch, NONE, 1.1 linux-2.6-xen-0126-fix-pxxval_t-usage-on-mm-init_64.c.patch, NONE, 1.1 linux-2.6-xen-0127-Missing-Xen-include.patch, NONE, 1.1 linux-2.6-xen-0128-un-static-ipi_to_irq.patch, NONE, 1.1 linux-2.6-xen-0129-Don-t-use-_PAGE_GLOBAL-bit-under-Xen-FIXME.patch, NONE, 1.1 linux-2.6-xen-0130-Trying-to-organize-the-xen-bootmem-allocation-mess.patch, NONE, 1.1 linux-2.6-xen-0131-Don-t-call-xprintk-when-writing-to-hvc-console.patch, NONE, 1.1 linux-2.6-xen-0132-Xen-reserve_bootmem-xenstore-and-console-interfac.patch, NONE, 1.1 linux-2.6-xen-0133-pvops-64-call-paravirt_activate_mm-on-activate_mm.patch, NONE, 1.1 linux-2.6-xen-0134-Xen-64-bit-support-on-xen_pgd_pin.patch, NONE, 1.1 linux-2.6-xen-0135-Xen-64-pin-user-PGD-on-activate_mm-and-dup_mmap.patch, NONE, 1.1 linux-2.6-xen-0136-pgd_walk-changes-to-make-pgd-pinning-work-FIXME.patch, NONE, 1.1 linux-2.6-xen-0137-Xen-Add-a-order-parameter-to-pgd_walk.patch, NONE, 1.1 linux-2.6-xen-0138-Xen-64-Unpin-user-pagetable-on-xen_pgd_unpin.patch, NONE, 1.1 linux-2.6-xen-0139-Use-un-pin_page-when-un-pinning-pgd.patch, NONE, 1.1 linux-2.6-xen-0140-Allow-enabling-Xen-on-x86_64.patch, NONE, 1.1 linux-2.6-xen-0141-Add-include-linux-spinlock_types.h-to-asm-x86-pgt.patch, NONE, 1.1 linux-2.6-xen-0142-Restore-some-sanity-on-the-initial-pagetable-bootmem.patch, NONE, 1.1 linux-2.6-xen-0143-Xen-Use-system_call_after_swapgs-as-the-syscall-c.patch, NONE, 1.1 linux-2.6-xen-0144-DEBUG-write-to-HV-console-on-printk.patch, NONE, 1.1 linux-2.6-xen-0145-Add-a-system_call_after_saveargs-label-to-entry_64.S.patch, NONE, 1.1 linux-2.6-xen-0146-Create-xen-specific-syscall-entry.patch, NONE, 1.1 linux-2.6-xen-0147-syscall-related-Xen-ifdefs-FIXME.patch, NONE, 1.1 linux-2.6-xen-0148-Point-set_pte-to-xen_set_pte-since-the-beginning.patch, NONE, 1.1 linux-2.6-xen-0149-DEBUG-slab-debugging.patch, NONE, 1.1 linux-2.6-xen-0150-pvops-64-Include-rsi-on-the-register-clobber-list.patch, NONE, 1.1 linux-2.6-xen-0151-Xen-64-quick-ugly-hack-to-fix-pgd_clear-pagetabl.patch, NONE, 1.1 linux-2.6-xen-0152-Add-missing-acpi-include-to-xen-setup.c.patch, NONE, 1.1 linux-2.6-xen-0153-Don-t-use-FIX_VDSO-on-64-bit.patch, NONE, 1.1 linux-2.6-xen-0154-Mark-init-pages-read-write-again-on-free_init_pages.patch, NONE, 1.1 linux-2.6-xen-0155-reserve_early-kernel-text-and-data-segments.patch, NONE, 1.1 patch-2.6.25-rc9.bz2.sign, NONE, 1.1 .cvsignore, 1.14, 1.15 .gitignore, 1.4, 1.5 Makefile, 1.14, 1.15 Makefile.config, 1.14, 1.15 config-generic, 1.5, 1.6 config-nodebug, 1.4, 1.5 kernel.spec, 1.34, 1.35 linux-2.6-compile-fixes.patch, 1.4, 1.5 linux-2.6-drm-i915-modeset.patch, 1.1, 1.2 linux-2.6-firewire-git-pending.patch, 1.3, 1.4 linux-2.6-firewire-git-update.patch, 1.3, 1.4 linux-2.6-merge-efifb-imacfb.patch, 1.1, 1.2 linux-2.6-silence-noise.patch, 1.4, 1.5 linux-2.6-uvcvideo.patch, 1.2, 1.3 linux-2.6-wireless-pending.patch, 1.4, 1.5 linux-2.6-wireless.patch, 1.5, 1.6 linux-2.6-xen-0001-squashfs-Fix-build-without-CONFIG_SMP.patch, 1.4, 1.5 linux-2.6-xen-0002-xen-execshield-Add-xen-specific-load_user_cs_desc.patch, 1.4, 1.5 linux-2.6-xen-0003-xen-execshield-fix-endless-GPF-fault-loop.patch, 1.4, 1.5 nouveau-drm.patch, 1.4, 1.5 sources, 1.14, 1.15 upstream, 1.4, 1.5 linux-2.6-input-macbook-appletouch.patch, 1.1, NONE linux-2.6-libata-ali-atapi-dma.patch, 1.2, NONE linux-2.6-xen-0004-xen-Do-not-pin-unpin-PMD-pages.patch, 1.3, NONE linux-2.6-xen-0005-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch, 1.5, NONE linux-2.6-xen-0006-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch, 1.6, NONE linux-2.6-xen-0007-xen-Enable-Xen-console-by-default-in-domU.patch, 1.1, NONE linux-2.6-xen-0008-xen-Module-autoprobing-support-for-frontend-drivers.patch, 1.4, NONE linux-2.6-xen-0009-xen-Add-compatibility-aliases-for-frontend-drivers.patch, 1.4, NONE linux-2.6-xen-0010-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch, 1.3, NONE linux-2.6-xen-0011-xen-Add-a-vmlinuz-target.patch, 1.3, NONE linux-2.6-xen-0012-xen-Add-empty-xenctrl-module.patch, 1.3, NONE linux-2.6-xen-0013-xen-Add-proc-xen-capabilities.patch, 1.3, NONE linux-2.6-xen-0014-xen-Add-proc-xen-privcmd.patch, 1.4, NONE linux-2.6-xen-0015-xen-Add-proc-xen-xenbus.patch, 1.4, NONE linux-2.6-xen-0016-xen-Add-Xen-s-sys-hypervisor-interface.patch, 1.4, NONE linux-2.6-xen-0017-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch, 1.4, NONE linux-2.6-xen-0018-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch, 1.1, NONE linux-2.6-xen-0019-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch, 1.1, NONE linux-2.6-xen-0020-xen-x86_64-Initial-x86_64-support-for-Xen-paravirt_.patch, 1.3, NONE patch-2.6.25-rc8.bz2.sign, 1.1, NONE

Mark McLoughlin (markmc) fedora-extras-commits at redhat.com
Mon Apr 14 16:07:23 UTC 2008


Author: markmc

Update of /cvs/pkgs/rpms/kernel-xen-2.6/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31576

Modified Files:
	.cvsignore .gitignore Makefile Makefile.config config-generic 
	config-nodebug kernel.spec linux-2.6-compile-fixes.patch 
	linux-2.6-drm-i915-modeset.patch 
	linux-2.6-firewire-git-pending.patch 
	linux-2.6-firewire-git-update.patch 
	linux-2.6-merge-efifb-imacfb.patch 
	linux-2.6-silence-noise.patch linux-2.6-uvcvideo.patch 
	linux-2.6-wireless-pending.patch linux-2.6-wireless.patch 
	linux-2.6-xen-0001-squashfs-Fix-build-without-CONFIG_SMP.patch 
	linux-2.6-xen-0002-xen-execshield-Add-xen-specific-load_user_cs_desc.patch 
	linux-2.6-xen-0003-xen-execshield-fix-endless-GPF-fault-loop.patch 
	nouveau-drm.patch sources upstream 
Added Files:
	linux-2.6-efika-not-chrp.patch 
	linux-2.6-nfs-client-mounts-hang.patch 
	linux-2.6-smp-boot-delay.patch 
	linux-2.6-xen-0004-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch 
	linux-2.6-xen-0005-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch 
	linux-2.6-xen-0006-xen-Enable-Xen-console-by-default-in-domU.patch 
	linux-2.6-xen-0007-xen-Module-autoprobing-support-for-frontend-drivers.patch 
	linux-2.6-xen-0008-xen-Add-compatibility-aliases-for-frontend-drivers.patch 
	linux-2.6-xen-0009-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch 
	linux-2.6-xen-0010-xen-Add-a-vmlinuz-target.patch 
	linux-2.6-xen-0011-xen-Add-empty-xenctrl-module.patch 
	linux-2.6-xen-0012-xen-Add-proc-xen-capabilities.patch 
	linux-2.6-xen-0013-xen-Add-proc-xen-privcmd.patch 
	linux-2.6-xen-0014-xen-Add-proc-xen-xenbus.patch 
	linux-2.6-xen-0015-xen-Add-Xen-s-sys-hypervisor-interface.patch 
	linux-2.6-xen-0016-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch 
	linux-2.6-xen-0017-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch 
	linux-2.6-xen-0018-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch 
	linux-2.6-xen-0019-xen-expose-set_pte_vaddr-and-make-xen-use-it.patch 
	linux-2.6-xen-0020-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch 
	linux-2.6-xen-0021-x86_64-Expose-set_pte_vaddr.patch 
	linux-2.6-xen-0022-x86_64-Split-set_pte_vaddr.patch 
	linux-2.6-xen-0023-x86_64-Add-clear_fixmap.patch 
	linux-2.6-xen-0024-xen-x86_64-Make-set_fixmap-a-paravirt-op-on-64-bi.patch 
	linux-2.6-xen-0025-xen-x86_64-Hack-to-set-vsyscall-pages-on-user-space.patch 
	linux-2.6-xen-0026-Handle-VSYSCALL_FIRST_PAGE-on-xen_set_pte.patch 
	linux-2.6-xen-0027-DMI-Define-dmi_scan_machine-as-no-op-if-CONFIG_DM.patch 
	linux-2.6-xen-0028-ACPI-thermal-Compile-without-CONFIG_DMI.patch 
	linux-2.6-xen-0029-xen-x86_64-Remove-the-640K-1M-hole-and-disable-DMI.patch 
	linux-2.6-xen-0030-xen-x86_64-Add-update_va_mapping-64-bit-code.patch 
	linux-2.6-xen-0031-x86_64-Add-sync_cmpxchg.patch 
	linux-2.6-xen-0032-xen-x86_64-Implement-HYPERVISOR-MULTI-_update_desc.patch 
	linux-2.6-xen-0033-xen-x86_64-Add-hacky-64-bit-x86_-read-write-_percpu.patch 
	linux-2.6-xen-0034-xen-x86_64-Use-x86_read_percpu-only-to-refer-to-a.patch 
	linux-2.6-xen-0035-Better-implementation-of-pte-functions.patch 
	linux-2.6-xen-0036-Add-FIX_PARAVIRT_BOOTAP-to-fixmap_64.h-too.patch 
	linux-2.6-xen-0037-Add-gate_offset-and-gate_segment-macros.patch 
	linux-2.6-xen-0038-xen_write_idt_entry-and-cvt_gate_to_trap.patch 
	linux-2.6-xen-0039-typedefs-for-pte_val-and-friends.patch 
	linux-2.6-xen-0040-x86_64-implementation-of-some-page.h-macros.patch 
	linux-2.6-xen-0041-Chainsaw-style-ifdefs.patch 
	linux-2.6-xen-0042-xen-Make-xen_pte_val-generic.patch 
	linux-2.6-xen-0043-More-chainsaw-ifdefs.patch 
	linux-2.6-xen-0044-Chainsaw-ifdefs-on-assembly-percpu-handling.patch 
	linux-2.6-xen-0045-x86_64-percpu-assembly-macros.patch 
	linux-2.6-xen-0046-Some-xen-asm.S-x86_64-code.patch 
	linux-2.6-xen-0047-Chainsaw-party-SPLITME.patch 
	linux-2.6-xen-0048-xen-asm.S-x86_64-notes.patch 
	linux-2.6-xen-0049-xen-x86_64-Make-hypercall-assembly-code-work.patch 
	linux-2.6-xen-0050-xen-x86_64-pda-initialization.patch 
	linux-2.6-xen-0051-Disable-discover_ebda-under-paravirt.patch 
	linux-2.6-xen-0052-Disable-early_printk-by-default.patch 
	linux-2.6-xen-0053-xen-Set-__HYPERVISOR_VIRT_START-for-x86_64.patch 
	linux-2.6-xen-0054-Set-__PAGE_OFFSET-as-required-by-Xen.patch 
	linux-2.6-xen-0055-DEBUG-Add-xprintk-to-log-directly-via-hypercall-fo.patch 
	linux-2.6-xen-0056-Use-__pgd-on-mk_kernel_pgd.patch 
	linux-2.6-xen-0057-Include-user-page-tables-on-head_64.S.patch 
	linux-2.6-xen-0058-Avoid-using-mk_unsigned_long.patch 
	linux-2.6-xen-0059-Lots-of-unrelated-changes.patch 
	linux-2.6-xen-0060-Hack-disable-vsmp.patch 
	linux-2.6-xen-0061-Export-early_make_page_readonly.patch 
	linux-2.6-xen-0062-Disable-multicalls.c-too-verbose-debugging.patch 
	linux-2.6-xen-0063-Xen-64-bit-ready-MMU-operations.patch 
	linux-2.6-xen-0064-Some-xen-mmu-pv-ops-implemented.patch 
	linux-2.6-xen-0065-Trying-to-make-the-pagetable-initialization-code-wor.patch 
	linux-2.6-xen-0066-Xen-specific-find_early_table_space-FIXME.patch 
	linux-2.6-xen-0067-Xen-call-e820_print_map-when-setting-up-memory.patch 
	linux-2.6-xen-0068-Comment-debugging-msgs.patch 
	linux-2.6-xen-0069-Try-to-make-pagetables-read-only.patch 
	linux-2.6-xen-0070-Debug-dump-pgtables-on-make_page_readonly.patch 
	linux-2.6-xen-0071-Disable-apic-at-compile-time-FIXME.patch 
	linux-2.6-xen-0072-Parse-early-params-after-init_memory_mapping.patch 
	linux-2.6-xen-0073-xen-Move-addr_to_page-to-init.h.patch 
	linux-2.6-xen-0074-Make-xen_pxx_val-and-xen_make_pxx-handle-attr-bi.patch 
	linux-2.6-xen-0075-Pull-xen_finish_init_mappin-from-XS-upstream.patch 
	linux-2.6-xen-0076-Pull-spp_getpage-changes-from-XS-upstream-REVIEWM.patch 
	linux-2.6-xen-0077-Pull-xen_extend_init_mapping-from-XS-upstream-FIX.patch 
	linux-2.6-xen-0078-New-enum-fixed_addresses-values-REVIEWME.patch 
	linux-2.6-xen-0079-Reserve-bootmem-areas-used-by-Xen-FIXME.patch 
	linux-2.6-xen-0080-xen_convert_trap_info-use-sizeof-struct-gate_desc.patch 
	linux-2.6-xen-0081-Call-paravirt_pagetable_setup_-start-done-REVIEW.patch 
	linux-2.6-xen-0082-ifdef-CONFIG_X86_32-on-xen-enlighten.c-REVIEWME.patch 
	linux-2.6-xen-0083-Handle-Xen-exception-stack-it-is-different-from-bar.patch 
	linux-2.6-xen-0084-Make-hvc_xen-console-use-xprintk-TEMPORARY.patch 
	linux-2.6-xen-0085-Implement-64-bit-version-of-HYPERVISOR_set_callbacks.patch 
	linux-2.6-xen-0086-Make-arch_vcpu_info-be-of-the-right-size-on-both-32.patch 
	linux-2.6-xen-0087-Implement-asm-xen_iret.patch 
	linux-2.6-xen-0088-xen-64-xen_iret-use-iretq-directly-if-returning-t.patch 
	linux-2.6-xen-0089-Implement-xen_irqenable_syscall_ret.patch 
	linux-2.6-xen-0090-DEBUG-xen_iret-always-return-through-the-hyperviso.patch 
	linux-2.6-xen-0091-Implement-some-xen-callbacks-on-xen-entry_64.S.patch 
	linux-2.6-xen-0092-Xen-specific-ifdef-hacks-on-kernel-entry_64.S-FIXM.patch 
	linux-2.6-xen-0093-Disable-syscall32-code-temporarily-FIXME.patch 
	linux-2.6-xen-0094-Use-__KERNEL_DS-as-SS-when-returning-to-a-kernel-thr.patch 
	linux-2.6-xen-0095-Use-apic_xen-on-genapic-by-default-FIXME.patch 
	linux-2.6-xen-0096-irq-vector-ifdef-chainsaw-FIXME.patch 
	linux-2.6-xen-0097-ifdef-chainsaw-on-syscall_init-FIXME.patch 
	linux-2.6-xen-0098-Pull-xen-genapic-implementation-from-upstream-Xen.patch 
	linux-2.6-xen-0099-Debugging-printk-s.patch 
	linux-2.6-xen-0100-Leave-lazy_cpu_mode-on-__switch_to.patch 
	linux-2.6-xen-0101-xen-64-Handle-fs-and-gs-on-xen_load_tls-properl.patch 
	linux-2.6-xen-0102-Disable-vcpu_info_placement-temporarily-FIXME.patch 
	linux-2.6-xen-0103-Fix-typo-on-ifdef-again.patch 
	linux-2.6-xen-0104-DEBUG-Don-t-try-to-actually-read-the-page-on-show_.patch 
	linux-2.6-xen-0105-Make-load_gs_index-a-paravirt-operation.patch 
	linux-2.6-xen-0106-xen-pgd_walk-use-limit-argument-instead-of-FIXADD.patch 
	linux-2.6-xen-0107-xen-pgd_walk-Eliminate-BUG_ON-limit-FIXADDR_TOP.patch 
	linux-2.6-xen-0108-xen-pgd_walk-accept-start-parameter.patch 
	linux-2.6-xen-0109-xen-64-reserve_bootmem-xen_start_info-area.patch 
	linux-2.6-xen-0110-pvops-64-call-paravirt_post_allocator_init-on-set.patch 
	linux-2.6-xen-0111-use-write_gdt_entry-on-vsyscall_set_cpu-CLEANME.patch 
	linux-2.6-xen-0112-xen-64-implement-xen_load_gs_index.patch 
	linux-2.6-xen-0113-include-asm-x86-pgalloc_64.h-pvops-hacks-SPLITME.patch 
	linux-2.6-xen-0114-Multi-pagetable-write_cr3-implementation-FIXME.patch 
	linux-2.6-xen-0115-Make-kcons_write_dom0-non-static-TEMPORARY.patch 
	linux-2.6-xen-0116-Disable-the-weird-count-loop-on-kcons_write_dom0.patch 
	linux-2.6-xen-0117-Make-xen_start_info-read-only.patch 
	linux-2.6-xen-0118-Hack-to-implement-return-to-userspace-without-SWAPGS.patch 
	linux-2.6-xen-0119-Xen-SEGBASE_-defines.patch 
	linux-2.6-xen-0120-Xen-HYPERVISOR_set_segment_base-implementation.patch 
	linux-2.6-xen-0121-Change-signature-of-paravirt_alloc_-pt-pd-REVIEWME.patch 
	linux-2.6-xen-0122-Comment-e820_print_map-call-TEMPORARY.patch 
	linux-2.6-xen-0123-Xen-missing-includes.patch 
	linux-2.6-xen-0124-asm-x86-pgtable_64.h-include-linux-spinlock.h.patch 
	linux-2.6-xen-0125-asm-x86-pgtable.h-include-asm-page.h.patch 
	linux-2.6-xen-0126-fix-pxxval_t-usage-on-mm-init_64.c.patch 
	linux-2.6-xen-0127-Missing-Xen-include.patch 
	linux-2.6-xen-0128-un-static-ipi_to_irq.patch 
	linux-2.6-xen-0129-Don-t-use-_PAGE_GLOBAL-bit-under-Xen-FIXME.patch 
	linux-2.6-xen-0130-Trying-to-organize-the-xen-bootmem-allocation-mess.patch 
	linux-2.6-xen-0131-Don-t-call-xprintk-when-writing-to-hvc-console.patch 
	linux-2.6-xen-0132-Xen-reserve_bootmem-xenstore-and-console-interfac.patch 
	linux-2.6-xen-0133-pvops-64-call-paravirt_activate_mm-on-activate_mm.patch 
	linux-2.6-xen-0134-Xen-64-bit-support-on-xen_pgd_pin.patch 
	linux-2.6-xen-0135-Xen-64-pin-user-PGD-on-activate_mm-and-dup_mmap.patch 
	linux-2.6-xen-0136-pgd_walk-changes-to-make-pgd-pinning-work-FIXME.patch 
	linux-2.6-xen-0137-Xen-Add-a-order-parameter-to-pgd_walk.patch 
	linux-2.6-xen-0138-Xen-64-Unpin-user-pagetable-on-xen_pgd_unpin.patch 
	linux-2.6-xen-0139-Use-un-pin_page-when-un-pinning-pgd.patch 
	linux-2.6-xen-0140-Allow-enabling-Xen-on-x86_64.patch 
	linux-2.6-xen-0141-Add-include-linux-spinlock_types.h-to-asm-x86-pgt.patch 
	linux-2.6-xen-0142-Restore-some-sanity-on-the-initial-pagetable-bootmem.patch 
	linux-2.6-xen-0143-Xen-Use-system_call_after_swapgs-as-the-syscall-c.patch 
	linux-2.6-xen-0144-DEBUG-write-to-HV-console-on-printk.patch 
	linux-2.6-xen-0145-Add-a-system_call_after_saveargs-label-to-entry_64.S.patch 
	linux-2.6-xen-0146-Create-xen-specific-syscall-entry.patch 
	linux-2.6-xen-0147-syscall-related-Xen-ifdefs-FIXME.patch 
	linux-2.6-xen-0148-Point-set_pte-to-xen_set_pte-since-the-beginning.patch 
	linux-2.6-xen-0149-DEBUG-slab-debugging.patch 
	linux-2.6-xen-0150-pvops-64-Include-rsi-on-the-register-clobber-list.patch 
	linux-2.6-xen-0151-Xen-64-quick-ugly-hack-to-fix-pgd_clear-pagetabl.patch 
	linux-2.6-xen-0152-Add-missing-acpi-include-to-xen-setup.c.patch 
	linux-2.6-xen-0153-Don-t-use-FIX_VDSO-on-64-bit.patch 
	linux-2.6-xen-0154-Mark-init-pages-read-write-again-on-free_init_pages.patch 
	linux-2.6-xen-0155-reserve_early-kernel-text-and-data-segments.patch 
	patch-2.6.25-rc9.bz2.sign 
Removed Files:
	linux-2.6-input-macbook-appletouch.patch 
	linux-2.6-libata-ali-atapi-dma.patch 
	linux-2.6-xen-0004-xen-Do-not-pin-unpin-PMD-pages.patch 
	linux-2.6-xen-0005-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch 
	linux-2.6-xen-0006-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch 
	linux-2.6-xen-0007-xen-Enable-Xen-console-by-default-in-domU.patch 
	linux-2.6-xen-0008-xen-Module-autoprobing-support-for-frontend-drivers.patch 
	linux-2.6-xen-0009-xen-Add-compatibility-aliases-for-frontend-drivers.patch 
	linux-2.6-xen-0010-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch 
	linux-2.6-xen-0011-xen-Add-a-vmlinuz-target.patch 
	linux-2.6-xen-0012-xen-Add-empty-xenctrl-module.patch 
	linux-2.6-xen-0013-xen-Add-proc-xen-capabilities.patch 
	linux-2.6-xen-0014-xen-Add-proc-xen-privcmd.patch 
	linux-2.6-xen-0015-xen-Add-proc-xen-xenbus.patch 
	linux-2.6-xen-0016-xen-Add-Xen-s-sys-hypervisor-interface.patch 
	linux-2.6-xen-0017-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch 
	linux-2.6-xen-0018-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch 
	linux-2.6-xen-0019-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch 
	linux-2.6-xen-0020-xen-x86_64-Initial-x86_64-support-for-Xen-paravirt_.patch 
	patch-2.6.25-rc8.bz2.sign 
Log Message:
* Mon Apr 14 2008 Mark McLoughlin <markmc at redhat.com>
- Rebase to kernel-2.6.25-0.228.rc9.fc9
- Include Markus's latest console handling patch


linux-2.6-efika-not-chrp.patch:

--- NEW FILE linux-2.6-efika-not-chrp.patch ---
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 5ab4c84..723422e 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -2240,6 +2240,14 @@ static void __init fixup_device_tree_efika(void)
 	if (rv != PROM_ERROR && (strcmp(prop, "chrp") == 0))
 		prom_setprop(node, "/", "device_type", "efika", sizeof("efika"));
 
+	/* CODEGEN,description is exposed in /proc/cpuinfo so
+	   change that too */
+	rv = prom_getprop(node, "CODEGEN,description", prop, sizeof(prop));
+	if (rv != PROM_ERROR && (strstr(prop, "CHRP")))
+		prom_setprop(node, "/", "CODEGEN,description",
+			     "Efika 5200B PowerPC System",
+			     sizeof("Efika 5200B PowerPC System"));
+
 	/* Fixup bestcomm interrupts property */
 	node = call_prom("finddevice", 1, 1, ADDR("/builtin/bestcomm"));
 	if (PHANDLE_VALID(node)) {

linux-2.6-nfs-client-mounts-hang.patch:

--- NEW FILE linux-2.6-nfs-client-mounts-hang.patch ---
>From davej  Fri Apr 11 20:06:57 2008
Return-Path: <fedora-kernel-list-bounces at redhat.com>
X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on
	quoit.install.boston.redhat.com
X-Spam-Level: 
X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,
	UNPARSEABLE_RELAY autolearn=ham version=3.2.4
Received: from pobox.devel.redhat.com [10.11.255.8]
	by quoit.install.boston.redhat.com with IMAP (fetchmail-6.3.8)
	for <davej at localhost> (single-drop); Fri, 11 Apr 2008 20:06:57 -0400 (EDT)
Received: from pobox.devel.redhat.com ([unix socket])
	 by pobox.devel.redhat.com (Cyrus v2.2.12-Invoca-RPM-2.2.12-8.1.RHEL4) with LMTPA;
	 Fri, 11 Apr 2008 20:03:31 -0400
X-Sieve: CMU Sieve 2.2
Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254])
	by pobox.devel.redhat.com (8.13.1/8.13.1) with ESMTP id m3C03VUw021673;
	Fri, 11 Apr 2008 20:03:31 -0400
Received: from mx1.util.phx.redhat.com (mx1.util.phx.redhat.com [10.8.4.92])
	by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m3C03TPo021615;
	Fri, 11 Apr 2008 20:03:30 -0400
Received: from hormel.redhat.com (hormel1.util.phx.redhat.com [10.8.4.116])
	by mx1.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id m3C03Oxg016566;
	Fri, 11 Apr 2008 20:03:24 -0400
Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110])
	by hormel.redhat.com (Postfix) with ESMTP id 6D8876188FB;
	Fri, 11 Apr 2008 20:03:24 -0400 (EDT)
Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com
	[172.16.52.254])
	by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id
	m3C03M0S023637 for <fedora-kernel-list at listman.util.phx.redhat.com>;
	Fri, 11 Apr 2008 20:03:22 -0400
Received: from file.rdu.redhat.com (file.rdu.redhat.com [10.11.255.147])
	by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m3C03Mad021593;
	Fri, 11 Apr 2008 20:03:22 -0400
Received: from [10.13.248.64] (vpn-248-64.boston.redhat.com [10.13.248.64])
	by file.rdu.redhat.com (8.13.1/8.13.1) with ESMTP id m3C03KPG005232;
	Fri, 11 Apr 2008 20:03:21 -0400
Message-ID: <47FFFC3A.2040708 at RedHat.com>
Date: Fri, 11 Apr 2008 20:03:06 -0400
From: Steve Dickson <SteveD at redhat.com>
User-Agent: Thunderbird 2.0.0.12 (X11/20080226)
MIME-Version: 1.0
To: Linux NFS Mailing list <linux-nfs at vger.kernel.org>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254
X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254
X-loop: fedora-kernel-list at redhat.com
Cc: Fedora Kernel Mailing list <fedora-kernel-list at redhat.com>
Subject: [PATCH] NFS Client mounts hang when exported directory do not exist
X-BeenThere: fedora-kernel-list at redhat.com
X-Mailman-Version: 2.1.5
Precedence: junk
List-Id: "Fedora kernel development." <fedora-kernel-list.redhat.com>
List-Unsubscribe: <https://www.redhat.com/mailman/listinfo/fedora-kernel-list>, 
	<mailto:fedora-kernel-list-request at redhat.com?subject=unsubscribe>
List-Archive: <https://www.redhat.com/archives/fedora-kernel-list>
List-Post: <mailto:fedora-kernel-list at redhat.com>
List-Help: <mailto:fedora-kernel-list-request at redhat.com?subject=help>
List-Subscribe: <https://www.redhat.com/mailman/listinfo/fedora-kernel-list>, 
	<mailto:fedora-kernel-list-request at redhat.com?subject=subscribe>
Sender: fedora-kernel-list-bounces at redhat.com
Errors-To: fedora-kernel-list-bounces at redhat.com
Status: RO
Content-Length: 1546
Lines: 43

This patch fixes a regression that was introduced by the string based mounts. 

nfs_mount() statically returns -EACCES for every error returned
by the remote mounted. This is incorrect because -EACCES is
an non-fatal error to the mount.nfs command. This error causes
mount.nfs to retry the mount even in the case when the exported
directory does not exist. 

This patch maps the errors returned by the remote mountd into
valid errno values, exactly how it was done pre-string based 
mounts. By returning the correct errno enables mount.nfs 
to do the right thing.  

Signed-off-by: Steve Dickson <steved at redhat.com>
---
Take 2- Why reinvent the wheel, as Trond pointed out using
nfs_stat_to_errno() makes more sense and is makes things much 
similar, something I'm always a fan of... 

diff -up linux/fs/nfs/mount_clnt.c.orig linux/fs/nfs/mount_clnt.c
--- linux/fs/nfs/mount_clnt.c.orig	2008-04-09 08:32:43.000000000 -0400
+++ linux/fs/nfs/mount_clnt.c	2008-04-11 19:42:16.000000000 -0400
@@ -14,6 +14,7 @@
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/sched.h>
 #include <linux/nfs_fs.h>
+#include "internal.h"
 
 #ifdef RPC_DEBUG
 # define NFSDBG_FACILITY	NFSDBG_MOUNT
@@ -98,7 +99,7 @@ out_call_err:
 
 out_mnt_err:
 	dprintk("NFS: MNT server returned result %d\n", result.status);
-	status = -EACCES;
+	status = -nfs_stat_to_errno(result.status);
 	goto out;
 }

_______________________________________________
Fedora-kernel-list mailing list
Fedora-kernel-list at redhat.com
https://www.redhat.com/mailman/listinfo/fedora-kernel-list


linux-2.6-smp-boot-delay.patch:

--- NEW FILE linux-2.6-smp-boot-delay.patch ---
Subject: smp: boot delay
From: Ingo Molnar <mingo at elte.hu>
Date: Fri Mar 28 08:53:27 CET 2008

Signed-off-by: Ingo Molnar <mingo at elte.hu>

[2.6.25 backport: cebbert at redhat.com]
---
 arch/x86/kernel/smpboot_32.c |   10 +++++-----
 arch/x86/kernel/smpboot_64.c |    8 ++++----
 2 files changed, 9 insertions(+), 9 deletions(-)

--- linux-2.6.24.noarch.orig/arch/x86/kernel/smpboot_32.c
+++ linux-2.6.24.noarch/arch/x86/kernel/smpboot_32.c
@@ -531,7 +531,7 @@ static inline void __inquire_remote_apic
 
 		timeout = 0;
 		do {
-			udelay(100);
+			udelay(1000);
 			status = apic_read(APIC_ICR) & APIC_ICR_RR_MASK;
 		} while (status == APIC_ICR_RR_INPROG && timeout++ < 1000);
 
@@ -571,7 +571,7 @@ wakeup_secondary_cpu(int logical_apicid,
 	/*
 	 * Give the other CPU some time to accept the IPI.
 	 */
-	udelay(200);
+	udelay(2000);
 	/*
 	 * Due to the Pentium erratum 3AP.
 	 */
@@ -686,7 +686,7 @@ wakeup_secondary_cpu(int phys_apicid, un
 		/*
 		 * Give the other CPU some time to accept the IPI.
 		 */
-		udelay(300);
+		udelay(3000);
 
 		Dprintk("Startup point 1.\n");
 
@@ -696,7 +696,7 @@ wakeup_secondary_cpu(int phys_apicid, un
 		/*
 		 * Give the other CPU some time to accept the IPI.
 		 */
-		udelay(200);
+		udelay(2000);
 		/*
 		 * Due to the Pentium erratum 3AP.
 		 */
@@ -833,7 +833,7 @@ static int __cpuinit do_boot_cpu(int api
 		for (timeout = 0; timeout < 50000; timeout++) {
 			if (cpu_isset(cpu, cpu_callin_map))
 				break;	/* It has booted */
-			udelay(100);
+			udelay(1000);
 		}
 
 		if (cpu_isset(cpu, cpu_callin_map)) {
--- linux-2.6.24.noarch.orig/arch/x86/kernel/smpboot_64.c
+++ linux-2.6.24.noarch/arch/x86/kernel/smpboot_64.c
@@ -413,7 +413,7 @@ static void inquire_remote_apic(int apic
 
 		timeout = 0;
 		do {
-			udelay(100);
+			udelay(1000);
 			status = apic_read(APIC_ICR) & APIC_ICR_RR_MASK;
 		} while (status == APIC_ICR_RR_INPROG && timeout++ < 1000);
 
@@ -498,7 +498,7 @@ static int __cpuinit wakeup_secondary_vi
 		/*
 		 * Give the other CPU some time to accept the IPI.
 		 */
-		udelay(300);
+		udelay(3000);
 
 		Dprintk("Startup point 1.\n");
 
@@ -508,7 +508,7 @@ static int __cpuinit wakeup_secondary_vi
 		/*
 		 * Give the other CPU some time to accept the IPI.
 		 */
-		udelay(200);
+		udelay(2000);
 		/*
 		 * Due to the Pentium erratum 3AP.
 		 */
@@ -679,7 +679,7 @@ do_rest:
 		for (timeout = 0; timeout < 50000; timeout++) {
 			if (cpu_isset(cpu, cpu_callin_map))
 				break;	/* It has booted */
-			udelay(100);
+			udelay(1000);
 		}
 
 		if (cpu_isset(cpu, cpu_callin_map)) {

linux-2.6-xen-0004-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch:

Index: linux-2.6-xen-0004-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch
===================================================================
RCS file: linux-2.6-xen-0004-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch
diff -N linux-2.6-xen-0004-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0004-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch	14 Apr 2008 16:06:53 -0000	1.4
@@ -0,0 +1,78 @@
+From 11fe604211af1580c86f6d8b8f91356ecfd5fb3e Mon Sep 17 00:00:00 2001
+From: Markus Armbruster <armbru at redhat.com>
+Date: Mon, 25 Feb 2008 14:02:24 +0100
+Subject: [PATCH] xen: Make xen-blkfront write its protocol ABI to xenstore
+
+Frontends are expected to write their protocol ABI to xenstore.  Since
+the protocol ABI defaults to the backend's native ABI, things work
+fine without that as long as the frontend's native ABI is identical to
+the backend's native ABI.  This is not the case for xen-blkfront
+running 32-on-64, because its ABI differs between 32 and 64 bit, and
+thus needs this fix.
+
+Based on http://xenbits.xensource.com/xen-unstable.hg?rev/c545932a18f3
+and http://xenbits.xensource.com/xen-unstable.hg?rev/ffe52263b430 by
+Gerd Hoffmann <kraxel at suse.de>
+
+Signed-off-by: Markus Armbruster <armbru at redhat.com>
+---
+ drivers/block/xen-blkfront.c         |    7 +++++++
+ include/xen/interface/io/protocols.h |   21 +++++++++++++++++++++
+ 2 files changed, 28 insertions(+), 0 deletions(-)
+ create mode 100644 include/xen/interface/io/protocols.h
+
+diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
+index 9c6f3f9..2e7c81e 100644
+--- a/drivers/block/xen-blkfront.c
++++ b/drivers/block/xen-blkfront.c
+@@ -47,6 +47,7 @@
+ 
+ #include <xen/interface/grant_table.h>
+ #include <xen/interface/io/blkif.h>
++#include <xen/interface/io/protocols.h>
+ 
+ #include <asm/xen/hypervisor.h>
+ 
+@@ -614,6 +615,12 @@ again:
+ 		message = "writing event-channel";
+ 		goto abort_transaction;
+ 	}
++	err = xenbus_printf(xbt, dev->nodename, "protocol", "%s",
++			    XEN_IO_PROTO_ABI_NATIVE);
++	if (err) {
++		message = "writing protocol";
++		goto abort_transaction;
++	}
+ 
+ 	err = xenbus_transaction_end(xbt, 0);
+ 	if (err) {
+diff --git a/include/xen/interface/io/protocols.h b/include/xen/interface/io/protocols.h
+new file mode 100644
+index 0000000..01fc8ae
+--- /dev/null
++++ b/include/xen/interface/io/protocols.h
+@@ -0,0 +1,21 @@
++#ifndef __XEN_PROTOCOLS_H__
++#define __XEN_PROTOCOLS_H__
++
++#define XEN_IO_PROTO_ABI_X86_32     "x86_32-abi"
++#define XEN_IO_PROTO_ABI_X86_64     "x86_64-abi"
++#define XEN_IO_PROTO_ABI_IA64       "ia64-abi"
++#define XEN_IO_PROTO_ABI_POWERPC64  "powerpc64-abi"
++
++#if defined(__i386__)
++# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32
++#elif defined(__x86_64__)
++# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64
++#elif defined(__ia64__)
++# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_IA64
++#elif defined(__powerpc64__)
++# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_POWERPC64
++#else
++# error arch fixup needed here
++#endif
++
++#endif
+-- 
+1.5.4.1
+

linux-2.6-xen-0005-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch:

--- NEW FILE linux-2.6-xen-0005-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch ---
>From 445bc6ff11002517101ab108897f501e3775beeb Mon Sep 17 00:00:00 2001
From: Markus Armbruster <armbru at redhat.com>
Date: Mon, 25 Feb 2008 14:06:46 +0100
Subject: [PATCH] xen pvfb: Para-virtual framebuffer, keyboard and pointer driver

This is a pair of Xen para-virtual frontend device drivers:
drivers/video/xen-fbfront.c provides a framebuffer, and
drivers/input/xen-kbdfront provides keyboard and mouse.

The backends run in dom0 user space.

The two drivers are not in two separate patches, because the
intermediate step (one driver, not the other) is somewhat problematic:
the backend in dom0 needs both drivers, and will refuse to complete
device initialization unless they're both present.

Signed-off-by: Markus Armbruster <armbru at redhat.com>
---
 drivers/input/Kconfig            |    9 +
 drivers/input/Makefile           |    2 +
 drivers/input/xen-kbdfront.c     |  340 +++++++++++++++++++++++
 drivers/video/Kconfig            |   14 +
 drivers/video/Makefile           |    1 +
 drivers/video/xen-fbfront.c      |  550 ++++++++++++++++++++++++++++++++++++++
 include/xen/interface/io/fbif.h  |  124 +++++++++
 include/xen/interface/io/kbdif.h |  114 ++++++++
 8 files changed, 1154 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/xen-kbdfront.c
 create mode 100644 drivers/video/xen-fbfront.c
 create mode 100644 include/xen/interface/io/fbif.h
 create mode 100644 include/xen/interface/io/kbdif.h

diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index d84ac4a..747633c 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -149,6 +149,15 @@ config INPUT_APMPOWER
 	  To compile this driver as a module, choose M here: the
 	  module will be called apm-power.
 
+config XEN_KBDDEV_FRONTEND
+	tristate "Xen virtual keyboard and mouse support"
+	depends on XEN_FBDEV_FRONTEND
+	default y
+	help
+	  This driver implements the front-end of the Xen virtual
+	  keyboard and mouse device driver.  It communicates with a back-end
+	  in another domain.
+
 comment "Input Device Drivers"
 
 source "drivers/input/keyboard/Kconfig"
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 24bdec1..606e1b9 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -24,3 +24,5 @@ obj-$(CONFIG_INPUT_MISC)	+= misc/
 obj-$(CONFIG_INPUT_LIRC)	+= lirc/
 
 obj-$(CONFIG_INPUT_APMPOWER)	+= apm-power.o
+
+obj-$(CONFIG_XEN_KBDDEV_FRONTEND)	+= xen-kbdfront.o
diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/xen-kbdfront.c
new file mode 100644
index 0000000..0f47f46
--- /dev/null
+++ b/drivers/input/xen-kbdfront.c
@@ -0,0 +1,340 @@
+/*
+ * Xen para-virtual input device
+ *
+ * Copyright (C) 2005 Anthony Liguori <aliguori at us.ibm.com>
+ * Copyright (C) 2006-2008 Red Hat, Inc., Markus Armbruster <armbru at redhat.com>
+ *
+ *  Based on linux/drivers/input/mouse/sermouse.c
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License. See the file COPYING in the main directory of this archive for
+ *  more details.
+ */
+
+/*
+ * TODO:
+ *
+ * Switch to grant tables together with xen-fbfront.c.
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <linux/input.h>
+#include <asm/xen/hypervisor.h>
+#include <xen/events.h>
+#include <xen/page.h>
+#include <xen/interface/io/fbif.h>
+#include <xen/interface/io/kbdif.h>
+#include <xen/xenbus.h>
+
+struct xenkbd_info {
+	struct input_dev *kbd;
+	struct input_dev *ptr;
+	struct xenkbd_page *page;
+	int irq;
+	struct xenbus_device *xbdev;
+	char phys[32];
+};
+
+static int xenkbd_remove(struct xenbus_device *);
+static int xenkbd_connect_backend(struct xenbus_device *, struct xenkbd_info *);
+static void xenkbd_disconnect_backend(struct xenkbd_info *);
+
+/*
+ * Note: if you need to send out events, see xenfb_do_update() for how
+ * to do that.
+ */
+
+static irqreturn_t input_handler(int rq, void *dev_id)
+{
+	struct xenkbd_info *info = dev_id;
+	struct xenkbd_page *page = info->page;
+	__u32 cons, prod;
+
+	prod = page->in_prod;
+	if (prod == page->in_cons)
+		return IRQ_HANDLED;
+	rmb();			/* ensure we see ring contents up to prod */
+	for (cons = page->in_cons; cons != prod; cons++) {
+		union xenkbd_in_event *event;
+		struct input_dev *dev;
+		event = &XENKBD_IN_RING_REF(page, cons);
+
+		dev = info->ptr;
+		switch (event->type) {
+		case XENKBD_TYPE_MOTION:
+			input_report_rel(dev, REL_X, event->motion.rel_x);
+			input_report_rel(dev, REL_Y, event->motion.rel_y);
+			break;
+		case XENKBD_TYPE_KEY:
+			dev = NULL;
+			if (test_bit(event->key.keycode, info->kbd->keybit))
+				dev = info->kbd;
+			if (test_bit(event->key.keycode, info->ptr->keybit))
+				dev = info->ptr;
+			if (dev)
+				input_report_key(dev, event->key.keycode,
+						 event->key.pressed);
+			else
+				printk(KERN_WARNING
+				       "xenkbd: unhandled keycode 0x%x\n",
+				       event->key.keycode);
+			break;
+		case XENKBD_TYPE_POS:
+			input_report_abs(dev, ABS_X, event->pos.abs_x);
+			input_report_abs(dev, ABS_Y, event->pos.abs_y);
+			break;
+		}
+		if (dev)
+			input_sync(dev);
+	}
+	mb();			/* ensure we got ring contents */
+	page->in_cons = cons;
+	notify_remote_via_irq(info->irq);
+
+	return IRQ_HANDLED;
+}
+
+static int __devinit xenkbd_probe(struct xenbus_device *dev,
+				  const struct xenbus_device_id *id)
+{
+	int ret, i;
+	struct xenkbd_info *info;
+	struct input_dev *kbd, *ptr;
+
+	info = kzalloc(sizeof(*info), GFP_KERNEL);
+	if (!info) {
+		xenbus_dev_fatal(dev, -ENOMEM, "allocating info structure");
+		return -ENOMEM;
+	}
+	dev->dev.driver_data = info;
+	info->xbdev = dev;
+	info->irq = -1;
+	snprintf(info->phys, sizeof(info->phys), "xenbus/%s", dev->nodename);
+
+	info->page = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+	if (!info->page)
+		goto error_nomem;
+
+	/* keyboard */
+	kbd = input_allocate_device();
+	if (!kbd)
+		goto error_nomem;
+	kbd->name = "Xen Virtual Keyboard";
+	kbd->phys = info->phys;
+	kbd->id.bustype = BUS_PCI;
+	kbd->id.vendor = 0x5853;
+	kbd->id.product = 0xffff;
+	kbd->evbit[0] = BIT(EV_KEY);
+	for (i = KEY_ESC; i < KEY_UNKNOWN; i++)
+		set_bit(i, kbd->keybit);
+	for (i = KEY_OK; i < KEY_MAX; i++)
+		set_bit(i, kbd->keybit);
+
+	ret = input_register_device(kbd);
+	if (ret) {
+		input_free_device(kbd);
+		xenbus_dev_fatal(dev, ret, "input_register_device(kbd)");
+		goto error;
+	}
+	info->kbd = kbd;
+
+	/* pointing device */
+	ptr = input_allocate_device();
+	if (!ptr)
+		goto error_nomem;
+	ptr->name = "Xen Virtual Pointer";
+	ptr->phys = info->phys;
+	ptr->id.bustype = BUS_PCI;
+	ptr->id.vendor = 0x5853;
+	ptr->id.product = 0xfffe;
+	ptr->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
+	for (i = BTN_LEFT; i <= BTN_TASK; i++)
+		set_bit(i, ptr->keybit);
+	ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y);
+	input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0);
+	input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0);
+
+	ret = input_register_device(ptr);
+	if (ret) {
+		input_free_device(ptr);
+		xenbus_dev_fatal(dev, ret, "input_register_device(ptr)");
+		goto error;
+	}
+	info->ptr = ptr;
+
+	ret = xenkbd_connect_backend(dev, info);
+	if (ret < 0)
+		goto error;
+
+	return 0;
+
+ error_nomem:
+	ret = -ENOMEM;
+	xenbus_dev_fatal(dev, ret, "allocating device memory");
+ error:
+	xenkbd_remove(dev);
+	return ret;
+}
+
+static int xenkbd_resume(struct xenbus_device *dev)
+{
+	struct xenkbd_info *info = dev->dev.driver_data;
+
+	xenkbd_disconnect_backend(info);
+	memset(info->page, 0, PAGE_SIZE);
+	return xenkbd_connect_backend(dev, info);
+}
+
+static int xenkbd_remove(struct xenbus_device *dev)
+{
+	struct xenkbd_info *info = dev->dev.driver_data;
+
+	xenkbd_disconnect_backend(info);
+	if (info->kbd)
+		input_unregister_device(info->kbd);
+	if (info->ptr)
+		input_unregister_device(info->ptr);
+	free_page((unsigned long)info->page);
+	kfree(info);
+	return 0;
+}
+
+static int xenkbd_connect_backend(struct xenbus_device *dev,
+				  struct xenkbd_info *info)
+{
+	int ret, evtchn;
+	struct xenbus_transaction xbt;
+
+	ret = xenbus_alloc_evtchn(dev, &evtchn);
+	if (ret)
+		return ret;
+	ret = bind_evtchn_to_irqhandler(evtchn, input_handler,
+					0, dev->devicetype, info);
+	if (ret < 0) {
+		xenbus_free_evtchn(dev, evtchn);
+		xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler");
+		return ret;
+	}
+	info->irq = ret;
+
+ again:
+	ret = xenbus_transaction_start(&xbt);
+	if (ret) {
+		xenbus_dev_fatal(dev, ret, "starting transaction");
+		return ret;
+	}
+	ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu",
+			    virt_to_mfn(info->page));
+	if (ret)
+		goto error_xenbus;
+	ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
+			    evtchn);
+	if (ret)
+		goto error_xenbus;
+	ret = xenbus_transaction_end(xbt, 0);
+	if (ret) {
+		if (ret == -EAGAIN)
+			goto again;
+		xenbus_dev_fatal(dev, ret, "completing transaction");
+		return ret;
+	}
+
+	xenbus_switch_state(dev, XenbusStateInitialised);
+	return 0;
+
+ error_xenbus:
+	xenbus_transaction_end(xbt, 1);
+	xenbus_dev_fatal(dev, ret, "writing xenstore");
+	return ret;
+}
+
+static void xenkbd_disconnect_backend(struct xenkbd_info *info)
+{
+	if (info->irq >= 0)
+		unbind_from_irqhandler(info->irq, info);
+	info->irq = -1;
+}
+
+static void xenkbd_backend_changed(struct xenbus_device *dev,
+				   enum xenbus_state backend_state)
+{
+	struct xenkbd_info *info = dev->dev.driver_data;
+	int ret, val;
+
+	switch (backend_state) {
+	case XenbusStateInitialising:
+	case XenbusStateInitialised:
+	case XenbusStateUnknown:
+	case XenbusStateClosed:
+		break;
+
+	case XenbusStateInitWait:
+InitWait:
+		ret = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
+				   "feature-abs-pointer", "%d", &val);
+		if (ret < 0)
+			val = 0;
+		if (val) {
+			ret = xenbus_printf(XBT_NIL, info->xbdev->nodename,
+					    "request-abs-pointer", "1");
+			if (ret)
+				printk(KERN_WARNING
+				       "xenkbd: can't request abs-pointer");
+		}
+		xenbus_switch_state(dev, XenbusStateConnected);
+		break;
+
+	case XenbusStateConnected:
+		/*
+		 * Work around xenbus race condition: If backend goes
+		 * through InitWait to Connected fast enough, we can
+		 * get Connected twice here.
+		 */
+		if (dev->state != XenbusStateConnected)
+			goto InitWait; /* no InitWait seen yet, fudge it */
+		break;
+
+	case XenbusStateClosing:
+		xenbus_frontend_closed(dev);
+		break;
+	}
+}
+
+static struct xenbus_device_id xenkbd_ids[] = {
+	{ "vkbd" },
+	{ "" }
+};
+
+static struct xenbus_driver xenkbd = {
+	.name = "vkbd",
+	.owner = THIS_MODULE,
+	.ids = xenkbd_ids,
+	.probe = xenkbd_probe,
+	.remove = xenkbd_remove,
+	.resume = xenkbd_resume,
+	.otherend_changed = xenkbd_backend_changed,
+};
+
+static int __init xenkbd_init(void)
+{
+	if (!is_running_on_xen())
+		return -ENODEV;
+
+	/* Nothing to do if running in dom0. */
+	if (is_initial_xendomain())
+		return -ENODEV;
+
+	return xenbus_register_frontend(&xenkbd);
+}
+
+static void __exit xenkbd_cleanup(void)
+{
+	xenbus_unregister_driver(&xenkbd);
+}
+
+module_init(xenkbd_init);
+module_exit(xenkbd_cleanup);
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 474c375..fa65342 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1921,6 +1921,20 @@ config FB_VIRTUAL
 
 	  If unsure, say N.
 
+config XEN_FBDEV_FRONTEND
+	tristate "Xen virtual frame buffer support"
+	depends on FB && XEN
+	select FB_SYS_FILLRECT
+	select FB_SYS_COPYAREA
+	select FB_SYS_IMAGEBLIT
+	select FB_SYS_FOPS
+	select FB_DEFERRED_IO
+	default y
+	help
+	  This driver implements the front-end of the Xen virtual
+	  frame buffer driver.  It communicates with a back-end
+	  in another domain.
+
 source "drivers/video/omap/Kconfig"
 
 source "drivers/video/backlight/Kconfig"
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index c789b01..48f7fd3 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -114,6 +114,7 @@ obj-$(CONFIG_FB_PS3)		  += ps3fb.o
 obj-$(CONFIG_FB_SM501)            += sm501fb.o
 obj-$(CONFIG_FB_XILINX)           += xilinxfb.o
 obj-$(CONFIG_FB_OMAP)             += omap/
+obj-$(CONFIG_XEN_FBDEV_FRONTEND)  += xen-fbfront.o
 
 # Platform or fallback drivers go here
 obj-$(CONFIG_FB_UVESA)            += uvesafb.o
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
new file mode 100644
index 0000000..619a6f8
--- /dev/null
+++ b/drivers/video/xen-fbfront.c
@@ -0,0 +1,550 @@
+/*
+ * Xen para-virtual frame buffer device
+ *
+ * Copyright (C) 2005-2006 Anthony Liguori <aliguori at us.ibm.com>
+ * Copyright (C) 2006-2008 Red Hat, Inc., Markus Armbruster <armbru at redhat.com>
+ *
+ *  Based on linux/drivers/video/q40fb.c
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License. See the file COPYING in the main directory of this archive for
+ *  more details.
+ */
+
+/*
+ * TODO:
+ *
+ * Switch to grant tables when they become capable of dealing with the
+ * frame buffer.
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/fb.h>
+#include <linux/module.h>
+#include <linux/vmalloc.h>
+#include <linux/mm.h>
+#include <asm/xen/hypervisor.h>
+#include <xen/events.h>
+#include <xen/page.h>
+#include <xen/interface/io/fbif.h>
+#include <xen/interface/io/protocols.h>
+#include <xen/xenbus.h>
+
+struct xenfb_info {
+	unsigned char		*fb;
+	struct fb_info		*fb_info;
+	int			x1, y1, x2, y2;	/* dirty rectangle,
+						   protected by dirty_lock */
+	spinlock_t		dirty_lock;
+	int			nr_pages;
+	int			irq;
+	struct xenfb_page	*page;
+	unsigned long 		*mfns;
+	int			update_wanted; /* XENFB_TYPE_UPDATE wanted */
+
+	struct xenbus_device	*xbdev;
+};
+
+static u32 xenfb_mem_len = XENFB_WIDTH * XENFB_HEIGHT * XENFB_DEPTH / 8;
+
+static int xenfb_remove(struct xenbus_device *);
+static void xenfb_init_shared_page(struct xenfb_info *);
+static int xenfb_connect_backend(struct xenbus_device *, struct xenfb_info *);
+static void xenfb_disconnect_backend(struct xenfb_info *);
+
+static void xenfb_do_update(struct xenfb_info *info,
+			    int x, int y, int w, int h)
+{
+	union xenfb_out_event event;
+	u32 prod;
+
+	event.type = XENFB_TYPE_UPDATE;
+	event.update.x = x;
+	event.update.y = y;
+	event.update.width = w;
+	event.update.height = h;
+
+	prod = info->page->out_prod;
+	/* caller ensures !xenfb_queue_full() */
+	mb();			/* ensure ring space available */
+	XENFB_OUT_RING_REF(info->page, prod) = event;
+	wmb();			/* ensure ring contents visible */
+	info->page->out_prod = prod + 1;
+
+	notify_remote_via_irq(info->irq);
+}
+
+static int xenfb_queue_full(struct xenfb_info *info)
+{
+	u32 cons, prod;
+
+	prod = info->page->out_prod;
+	cons = info->page->out_cons;
+	return prod - cons == XENFB_OUT_RING_LEN;
+}
+
+static void xenfb_refresh(struct xenfb_info *info,
+			  int x1, int y1, int w, int h)
+{
+	unsigned long flags;
+	int y2 = y1 + h - 1;
+	int x2 = x1 + w - 1;
+
+	if (!info->update_wanted)
+		return;
+
+	spin_lock_irqsave(&info->dirty_lock, flags);
+
+	/* Combine with dirty rectangle: */
+	if (info->y1 < y1)
+		y1 = info->y1;
+	if (info->y2 > y2)
+		y2 = info->y2;
+	if (info->x1 < x1)
+		x1 = info->x1;
+	if (info->x2 > x2)
+		x2 = info->x2;
+
+	if (xenfb_queue_full(info)) {
+		/* Can't send right now, stash it in the dirty rectangle */
+		info->x1 = x1;
+		info->x2 = x2;
+		info->y1 = y1;
+		info->y2 = y2;
+		spin_unlock_irqrestore(&info->dirty_lock, flags);
+		return;
+	}
+
+	/* Clear dirty rectangle: */
+	info->x1 = info->y1 = INT_MAX;
+	info->x2 = info->y2 = 0;
+
+	spin_unlock_irqrestore(&info->dirty_lock, flags);
+
+	if (x1 <= x2 && y1 <= y2)
+		xenfb_do_update(info, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
+}
+
+static void xenfb_deferred_io(struct fb_info *fb_info,
+			      struct list_head *pagelist)
+{
+	struct xenfb_info *info = fb_info->par;
+	struct page *page;
+	unsigned long beg, end;
+	int y1, y2, miny, maxy;
+
+	miny = INT_MAX;
+	maxy = 0;
+	list_for_each_entry(page, pagelist, lru) {
+		beg = page->index << PAGE_SHIFT;
+		end = beg + PAGE_SIZE - 1;
+		y1 = beg / fb_info->fix.line_length;
+		y2 = end / fb_info->fix.line_length;
+		if (y2 >= fb_info->var.yres)
+			y2 = fb_info->var.yres - 1;
+		if (miny > y1)
+			miny = y1;
+		if (maxy < y2)
+			maxy = y2;
+	}
+	xenfb_refresh(info, 0, miny, fb_info->var.xres, maxy - miny + 1);
+}
+
+static struct fb_deferred_io xenfb_defio = {
+	.delay		= HZ / 20,
+	.deferred_io	= xenfb_deferred_io,
+};
+
+static int xenfb_setcolreg(unsigned regno, unsigned red, unsigned green,
+			   unsigned blue, unsigned transp,
+			   struct fb_info *info)
+{
+	u32 v;
+
+	if (regno > info->cmap.len)
+		return 1;
+
+#define CNVT_TOHW(val, width) ((((val)<<(width))+0x7FFF-(val))>>16)
+	red = CNVT_TOHW(red, info->var.red.length);
+	green = CNVT_TOHW(green, info->var.green.length);
+	blue = CNVT_TOHW(blue, info->var.blue.length);
+	transp = CNVT_TOHW(transp, info->var.transp.length);
+#undef CNVT_TOHW
+
+	v = (red << info->var.red.offset) |
+	    (green << info->var.green.offset) |
+	    (blue << info->var.blue.offset);
+
+	switch (info->var.bits_per_pixel) {
+	case 16:
+	case 24:
+	case 32:
+		((u32 *)info->pseudo_palette)[regno] = v;
+		break;
+	}
+
+	return 0;
+}
+
+static void xenfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
+{
+	struct xenfb_info *info = p->par;
+
+	sys_fillrect(p, rect);
+	xenfb_refresh(info, rect->dx, rect->dy, rect->width, rect->height);
+}
+
+static void xenfb_imageblit(struct fb_info *p, const struct fb_image *image)
+{
+	struct xenfb_info *info = p->par;
+
+	sys_imageblit(p, image);
+	xenfb_refresh(info, image->dx, image->dy, image->width, image->height);
+}
+
+static void xenfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
+{
+	struct xenfb_info *info = p->par;
+
+	sys_copyarea(p, area);
+	xenfb_refresh(info, area->dx, area->dy, area->width, area->height);
+}
+
+static ssize_t xenfb_write(struct fb_info *p, const char __user *buf,
+			size_t count, loff_t *ppos)
+{
+	struct xenfb_info *info = p->par;
+	ssize_t res;
+
+	res = fb_sys_write(p, buf, count, ppos);
+	xenfb_refresh(info, 0, 0, info->page->width, info->page->height);
+	return res;
+}
+
+static struct fb_ops xenfb_fb_ops = {
+	.owner		= THIS_MODULE,
+	.fb_read	= fb_sys_read,
+	.fb_write	= xenfb_write,
+	.fb_setcolreg	= xenfb_setcolreg,
+	.fb_fillrect	= xenfb_fillrect,
+	.fb_copyarea	= xenfb_copyarea,
+	.fb_imageblit	= xenfb_imageblit,
+};
+
+static irqreturn_t xenfb_event_handler(int rq, void *dev_id)
+{
+	/*
+	 * No in events recognized, simply ignore them all.
+	 * If you need to recognize some, see xen-kbdfront's
+	 * input_handler() for how to do that.
+	 */
+	struct xenfb_info *info = dev_id;
+	struct xenfb_page *page = info->page;
+
+	if (page->in_cons != page->in_prod) {
+		info->page->in_cons = info->page->in_prod;
+		notify_remote_via_irq(info->irq);
+	}
+
+	/* Flush dirty rectangle: */
+	xenfb_refresh(info, INT_MAX, INT_MAX, -INT_MAX, -INT_MAX);
+
+	return IRQ_HANDLED;
+}
+
+static int __devinit xenfb_probe(struct xenbus_device *dev,
+				 const struct xenbus_device_id *id)
+{
+	struct xenfb_info *info;
+	struct fb_info *fb_info;
+	int ret;
+
+	info = kzalloc(sizeof(*info), GFP_KERNEL);
+	if (info == NULL) {
+		xenbus_dev_fatal(dev, -ENOMEM, "allocating info structure");
+		return -ENOMEM;
+	}
+	dev->dev.driver_data = info;
+	info->xbdev = dev;
+	info->irq = -1;
+	info->x1 = info->y1 = INT_MAX;
+	spin_lock_init(&info->dirty_lock);
+
+	info->fb = vmalloc(xenfb_mem_len);
+	if (info->fb == NULL)
+		goto error_nomem;
+	memset(info->fb, 0, xenfb_mem_len);
+
+	info->nr_pages = (xenfb_mem_len + PAGE_SIZE - 1) >> PAGE_SHIFT;
+
+	info->mfns = vmalloc(sizeof(unsigned long) * info->nr_pages);
+	if (!info->mfns)
+		goto error_nomem;
+
+	/* set up shared page */
+	info->page = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+	if (!info->page)
+		goto error_nomem;
+
+	xenfb_init_shared_page(info);
+
+	/* abusing framebuffer_alloc() to allocate pseudo_palette */
+	fb_info = framebuffer_alloc(sizeof(u32) * 256, NULL);
+	if (fb_info == NULL)
+		goto error_nomem;
+
+	/* complete the abuse: */
+	fb_info->pseudo_palette = fb_info->par;
+	fb_info->par = info;
+
+	fb_info->screen_base = info->fb;
+
+	fb_info->fbops = &xenfb_fb_ops;
+	fb_info->var.xres_virtual = fb_info->var.xres = info->page->width;
+	fb_info->var.yres_virtual = fb_info->var.yres = info->page->height;
+	fb_info->var.bits_per_pixel = info->page->depth;
+
+	fb_info->var.red = (struct fb_bitfield){16, 8, 0};
+	fb_info->var.green = (struct fb_bitfield){8, 8, 0};
+	fb_info->var.blue = (struct fb_bitfield){0, 8, 0};
+
+	fb_info->var.activate = FB_ACTIVATE_NOW;
+	fb_info->var.height = -1;
+	fb_info->var.width = -1;
+	fb_info->var.vmode = FB_VMODE_NONINTERLACED;
+
+	fb_info->fix.visual = FB_VISUAL_TRUECOLOR;
+	fb_info->fix.line_length = info->page->line_length;
+	fb_info->fix.smem_start = 0;
+	fb_info->fix.smem_len = xenfb_mem_len;
+	strcpy(fb_info->fix.id, "xen");
+	fb_info->fix.type = FB_TYPE_PACKED_PIXELS;
+	fb_info->fix.accel = FB_ACCEL_NONE;
+
+	fb_info->flags = FBINFO_FLAG_DEFAULT;
+
+	ret = fb_alloc_cmap(&fb_info->cmap, 256, 0);
+	if (ret < 0) {
+		framebuffer_release(fb_info);
+		xenbus_dev_fatal(dev, ret, "fb_alloc_cmap");
+		goto error;
+	}
+
+	fb_info->fbdefio = &xenfb_defio;
+	fb_deferred_io_init(fb_info);
+
+	ret = register_framebuffer(fb_info);
+	if (ret) {
+		fb_deferred_io_cleanup(fb_info);
+		fb_dealloc_cmap(&fb_info->cmap);
+		framebuffer_release(fb_info);
+		xenbus_dev_fatal(dev, ret, "register_framebuffer");
+		goto error;
+	}
+	info->fb_info = fb_info;
+
+	ret = xenfb_connect_backend(dev, info);
+	if (ret < 0)
+		goto error;
+
+	return 0;
+
+ error_nomem:
+	ret = -ENOMEM;
+	xenbus_dev_fatal(dev, ret, "allocating device memory");
+ error:
+	xenfb_remove(dev);
+	return ret;
+}
+
+static int xenfb_resume(struct xenbus_device *dev)
+{
+	struct xenfb_info *info = dev->dev.driver_data;
+
+	xenfb_disconnect_backend(info);
+	xenfb_init_shared_page(info);
+	return xenfb_connect_backend(dev, info);
+}
+
+static int xenfb_remove(struct xenbus_device *dev)
+{
+	struct xenfb_info *info = dev->dev.driver_data;
+
+	xenfb_disconnect_backend(info);
+	if (info->fb_info) {
+		fb_deferred_io_cleanup(info->fb_info);
+		unregister_framebuffer(info->fb_info);
+		fb_dealloc_cmap(&info->fb_info->cmap);
+		framebuffer_release(info->fb_info);
+	}
+	free_page((unsigned long)info->page);
+	vfree(info->mfns);
+	vfree(info->fb);
+	kfree(info);
+
+	return 0;
+}
+
+static unsigned long vmalloc_to_mfn(void *address)
+{
+	return pfn_to_mfn(vmalloc_to_pfn(address));
+}
+
+static void xenfb_init_shared_page(struct xenfb_info *info)
+{
+	int i;
+
+	for (i = 0; i < info->nr_pages; i++)
+		info->mfns[i] = vmalloc_to_mfn(info->fb + i * PAGE_SIZE);
+
+	info->page->pd[0] = vmalloc_to_mfn(info->mfns);
+	info->page->pd[1] = 0;
+	info->page->width = XENFB_WIDTH;
+	info->page->height = XENFB_HEIGHT;
+	info->page->depth = XENFB_DEPTH;
+	info->page->line_length = (info->page->depth / 8) * info->page->width;
+	info->page->mem_length = xenfb_mem_len;
+	info->page->in_cons = info->page->in_prod = 0;
+	info->page->out_cons = info->page->out_prod = 0;
+}
+
+static int xenfb_connect_backend(struct xenbus_device *dev,
+				 struct xenfb_info *info)
+{
+	int ret, evtchn;
+	struct xenbus_transaction xbt;
+
+	ret = xenbus_alloc_evtchn(dev, &evtchn);
+	if (ret)
+		return ret;
+	ret = bind_evtchn_to_irqhandler(evtchn, xenfb_event_handler,
+					0, dev->devicetype, info);
+	if (ret < 0) {
+		xenbus_free_evtchn(dev, evtchn);
+		xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler");
+		return ret;
+	}
+	info->irq = ret;
+
+ again:
+	ret = xenbus_transaction_start(&xbt);
+	if (ret) {
+		xenbus_dev_fatal(dev, ret, "starting transaction");
+		return ret;
+	}
+	ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu",
+			    virt_to_mfn(info->page));
+	if (ret)
+		goto error_xenbus;
+	ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
+			    evtchn);
+	if (ret)
+		goto error_xenbus;
+	ret = xenbus_printf(xbt, dev->nodename, "protocol", "%s",
+			    XEN_IO_PROTO_ABI_NATIVE);
+	if (ret)
+		goto error_xenbus;
+	ret = xenbus_printf(xbt, dev->nodename, "feature-update", "1");
+	if (ret)
+		goto error_xenbus;
+	ret = xenbus_transaction_end(xbt, 0);
+	if (ret) {
+		if (ret == -EAGAIN)
+			goto again;
+		xenbus_dev_fatal(dev, ret, "completing transaction");
+		return ret;
+	}
+
+	xenbus_switch_state(dev, XenbusStateInitialised);
+	return 0;
+
+ error_xenbus:
+	xenbus_transaction_end(xbt, 1);
+	xenbus_dev_fatal(dev, ret, "writing xenstore");
+	return ret;
+}
+
+static void xenfb_disconnect_backend(struct xenfb_info *info)
+{
+	if (info->irq >= 0)
+		unbind_from_irqhandler(info->irq, info);
+	info->irq = -1;
+}
+
+static void xenfb_backend_changed(struct xenbus_device *dev,
+				  enum xenbus_state backend_state)
+{
+	struct xenfb_info *info = dev->dev.driver_data;
+	int val;
+
+	switch (backend_state) {
+	case XenbusStateInitialising:
+	case XenbusStateInitialised:
+	case XenbusStateUnknown:
+	case XenbusStateClosed:
+		break;
+
+	case XenbusStateInitWait:
+InitWait:
+		xenbus_switch_state(dev, XenbusStateConnected);
+		break;
+
+	case XenbusStateConnected:
+		/*
+		 * Work around xenbus race condition: If backend goes
+		 * through InitWait to Connected fast enough, we can
+		 * get Connected twice here.
+		 */
+		if (dev->state != XenbusStateConnected)
+			goto InitWait; /* no InitWait seen yet, fudge it */
+
+		if (xenbus_scanf(XBT_NIL, info->xbdev->otherend,
+				 "request-update", "%d", &val) < 0)
+			val = 0;
+		if (val)
+			info->update_wanted = 1;
+		break;
+
+	case XenbusStateClosing:
+		xenbus_frontend_closed(dev);
+		break;
+	}
+}
+
+static struct xenbus_device_id xenfb_ids[] = {
+	{ "vfb" },
+	{ "" }
+};
+
+static struct xenbus_driver xenfb = {
+	.name = "vfb",
+	.owner = THIS_MODULE,
+	.ids = xenfb_ids,
+	.probe = xenfb_probe,
+	.remove = xenfb_remove,
+	.resume = xenfb_resume,
+	.otherend_changed = xenfb_backend_changed,
+};
+
+static int __init xenfb_init(void)
+{
+	if (!is_running_on_xen())
+		return -ENODEV;
+
+	/* Nothing to do if running in dom0. */
+	if (is_initial_xendomain())
+		return -ENODEV;
+
+	return xenbus_register_frontend(&xenfb);
+}
+
+static void __exit xenfb_cleanup(void)
+{
+	xenbus_unregister_driver(&xenfb);
+}
+
+module_init(xenfb_init);
+module_exit(xenfb_cleanup);
+
+MODULE_LICENSE("GPL");
diff --git a/include/xen/interface/io/fbif.h b/include/xen/interface/io/fbif.h
new file mode 100644
index 0000000..5a934dd
--- /dev/null
+++ b/include/xen/interface/io/fbif.h
@@ -0,0 +1,124 @@
+/*
+ * fbif.h -- Xen virtual frame buffer device
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright (C) 2005 Anthony Liguori <aliguori at us.ibm.com>
+ * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru at redhat.com>
+ */
+
+#ifndef __XEN_PUBLIC_IO_FBIF_H__
+#define __XEN_PUBLIC_IO_FBIF_H__
+
+/* Out events (frontend -> backend) */
+
+/*
+ * Out events may be sent only when requested by backend, and receipt
+ * of an unknown out event is an error.
+ */
+
+/* Event type 1 currently not used */
+/*
+ * Framebuffer update notification event
+ * Capable frontend sets feature-update in xenstore.
+ * Backend requests it by setting request-update in xenstore.
+ */
+#define XENFB_TYPE_UPDATE 2
+
+struct xenfb_update {
+	uint8_t type;		/* XENFB_TYPE_UPDATE */
+	int32_t x;		/* source x */
+	int32_t y;		/* source y */
+	int32_t width;		/* rect width */
+	int32_t height;		/* rect height */
+};
+
+#define XENFB_OUT_EVENT_SIZE 40
+
+union xenfb_out_event {
+	uint8_t type;
+	struct xenfb_update update;
+	char pad[XENFB_OUT_EVENT_SIZE];
+};
+
+/* In events (backend -> frontend) */
+
+/*
+ * Frontends should ignore unknown in events.
+ * No in events currently defined.
+ */
+
+#define XENFB_IN_EVENT_SIZE 40
+
+union xenfb_in_event {
+	uint8_t type;
+	char pad[XENFB_IN_EVENT_SIZE];
+};
+
+/* shared page */
+
+#define XENFB_IN_RING_SIZE 1024
+#define XENFB_IN_RING_LEN (XENFB_IN_RING_SIZE / XENFB_IN_EVENT_SIZE)
+#define XENFB_IN_RING_OFFS 1024
+#define XENFB_IN_RING(page) \
+	((union xenfb_in_event *)((char *)(page) + XENFB_IN_RING_OFFS))
+#define XENFB_IN_RING_REF(page, idx) \
+	(XENFB_IN_RING((page))[(idx) % XENFB_IN_RING_LEN])
+
+#define XENFB_OUT_RING_SIZE 2048
+#define XENFB_OUT_RING_LEN (XENFB_OUT_RING_SIZE / XENFB_OUT_EVENT_SIZE)
+#define XENFB_OUT_RING_OFFS (XENFB_IN_RING_OFFS + XENFB_IN_RING_SIZE)
+#define XENFB_OUT_RING(page) \
+	((union xenfb_out_event *)((char *)(page) + XENFB_OUT_RING_OFFS))
+#define XENFB_OUT_RING_REF(page, idx) \
+	(XENFB_OUT_RING((page))[(idx) % XENFB_OUT_RING_LEN])
+
+struct xenfb_page {
+	uint32_t in_cons, in_prod;
+	uint32_t out_cons, out_prod;
+
+	int32_t width;          /* width of the framebuffer (in pixels) */
+	int32_t height;         /* height of the framebuffer (in pixels) */
+	uint32_t line_length;   /* length of a row of pixels (in bytes) */
+	uint32_t mem_length;    /* length of the framebuffer (in bytes) */
+	uint8_t depth;          /* depth of a pixel (in bits) */
+
+	/*
+	 * Framebuffer page directory
+	 *
+	 * Each directory page holds PAGE_SIZE / sizeof(*pd)
+	 * framebuffer pages, and can thus map up to PAGE_SIZE *
+	 * PAGE_SIZE / sizeof(*pd) bytes.  With PAGE_SIZE == 4096 and
+	 * sizeof(unsigned long) == 4, that's 4 Megs.  Two directory
+	 * pages should be enough for a while.
+	 */
+	unsigned long pd[2];
+};
+
+/*
+ * Wart: xenkbd needs to know resolution.  Put it here until a better
+ * solution is found, but don't leak it to the backend.
+ */
+#ifdef __KERNEL__
+#define XENFB_WIDTH 800
+#define XENFB_HEIGHT 600
+#define XENFB_DEPTH 32
+#endif
+
+#endif
diff --git a/include/xen/interface/io/kbdif.h b/include/xen/interface/io/kbdif.h
new file mode 100644
index 0000000..fb97f42
--- /dev/null
+++ b/include/xen/interface/io/kbdif.h
@@ -0,0 +1,114 @@
+/*
+ * kbdif.h -- Xen virtual keyboard/mouse
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright (C) 2005 Anthony Liguori <aliguori at us.ibm.com>
+ * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru at redhat.com>
+ */
+
+#ifndef __XEN_PUBLIC_IO_KBDIF_H__
+#define __XEN_PUBLIC_IO_KBDIF_H__
+
+/* In events (backend -> frontend) */
+
+/*
+ * Frontends should ignore unknown in events.
+ */
+
+/* Pointer movement event */
+#define XENKBD_TYPE_MOTION  1
+/* Event type 2 currently not used */
+/* Key event (includes pointer buttons) */
+#define XENKBD_TYPE_KEY     3
+/*
+ * Pointer position event
+ * Capable backend sets feature-abs-pointer in xenstore.
+ * Frontend requests ot instead of XENKBD_TYPE_MOTION by setting
+ * request-abs-update in xenstore.
+ */
+#define XENKBD_TYPE_POS     4
+
+struct xenkbd_motion {
+	uint8_t type;		/* XENKBD_TYPE_MOTION */
+	int32_t rel_x;		/* relative X motion */
+	int32_t rel_y;		/* relative Y motion */
+};
+
+struct xenkbd_key {
+	uint8_t type;		/* XENKBD_TYPE_KEY */
+	uint8_t pressed;	/* 1 if pressed; 0 otherwise */
+	uint32_t keycode;	/* KEY_* from linux/input.h */
+};
+
+struct xenkbd_position {
+	uint8_t type;		/* XENKBD_TYPE_POS */
+	int32_t abs_x;		/* absolute X position (in FB pixels) */
+	int32_t abs_y;		/* absolute Y position (in FB pixels) */
+};
+
+#define XENKBD_IN_EVENT_SIZE 40
+
+union xenkbd_in_event {
+	uint8_t type;
+	struct xenkbd_motion motion;
+	struct xenkbd_key key;
+	struct xenkbd_position pos;
+	char pad[XENKBD_IN_EVENT_SIZE];
+};
+
+/* Out events (frontend -> backend) */
+
+/*
+ * Out events may be sent only when requested by backend, and receipt
+ * of an unknown out event is an error.
+ * No out events currently defined.
+ */
+
+#define XENKBD_OUT_EVENT_SIZE 40
+
+union xenkbd_out_event {
+	uint8_t type;
+	char pad[XENKBD_OUT_EVENT_SIZE];
+};
+
+/* shared page */
+
+#define XENKBD_IN_RING_SIZE 2048
+#define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE)
+#define XENKBD_IN_RING_OFFS 1024
+#define XENKBD_IN_RING(page) \
+	((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS))
+#define XENKBD_IN_RING_REF(page, idx) \
+	(XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN])
+
+#define XENKBD_OUT_RING_SIZE 1024
+#define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE)
+#define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE)
+#define XENKBD_OUT_RING(page) \
+	((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS))
+#define XENKBD_OUT_RING_REF(page, idx) \
+	(XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN])
+
+struct xenkbd_page {
+	uint32_t in_cons, in_prod;
+	uint32_t out_cons, out_prod;
+};
+
+#endif
-- 
1.5.4.1


linux-2.6-xen-0006-xen-Enable-Xen-console-by-default-in-domU.patch:

--- NEW FILE linux-2.6-xen-0006-xen-Enable-Xen-console-by-default-in-domU.patch ---
>From 1244e80db318e37f73b5bd27c1b3b9d02cc6e1ef Mon Sep 17 00:00:00 2001
From: Markus Armbruster <armbru at redhat.com>
Date: Thu, 10 Apr 2008 17:46:39 +0200
Subject: [PATCH] xen: Enable Xen console by default in domU

Without console= arguments on the kernel command line, the first
console to register becomes enabled and the preferred console (the one
behind /dev/console).  This is tty (assuming CONFIG_VT_CONSOLE is
enabled, which it commonly is).

This is okay as long tty is a useful console.  But unless we have the
PV framebuffer, and it is enabled for this domain, tty0 in domU is
merely a dummy.  In that case, we want the preferred console to be the
Xen console hvc0, and we want it without having to fiddle with the
kernel command line.

Even with PV framebuffer enabled, we still want to enable the Xen
console as well.

Problem: when tty registers, we can't yet know whether the PVFB is
enabled.  By the time we can know (xenstore is up), the console setup
game is over.

Enable the Xen console hvc by default, and make it the preferred
console.  Change the preferred console to tty when PVFB probes
successfully, unless we've been given console kernel parameters.

Signed-off-by: Markus Armbruster <armbru at redhat.com>
---
 arch/x86/xen/enlighten.c    |    6 ++++++
 drivers/video/xen-fbfront.c |   25 +++++++++++++++++++++++++
 include/linux/console.h     |    2 ++
 kernel/printk.c             |    2 ++
 4 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 66ffdb2..a5b111d 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -25,6 +25,7 @@
 #include <linux/mm.h>
 #include <linux/page-flags.h>
 #include <linux/highmem.h>
+#include <linux/console.h>
 
 #include <xen/interface/xen.h>
 #include <xen/interface/physdev.h>
@@ -1245,6 +1246,11 @@ asmlinkage void __init xen_start_kernel(void)
 		? __pa(xen_start_info->mod_start) : 0;
 	boot_params.hdr.ramdisk_size = xen_start_info->mod_len;
 
+	if (!is_initial_xendomain()) {
+		add_preferred_console("tty", 0, NULL);
+		add_preferred_console("hvc", 0, NULL);
+	}
+
 	/* Start the world */
 	start_kernel();
 }
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index 619a6f8..4e10876 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -18,6 +18,7 @@
  * frame buffer.
  */
 
+#include <linux/console.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/fb.h>
@@ -48,6 +49,7 @@ struct xenfb_info {
 
 static u32 xenfb_mem_len = XENFB_WIDTH * XENFB_HEIGHT * XENFB_DEPTH / 8;
 
+static void xenfb_make_preferred_console(void);
 static int xenfb_remove(struct xenbus_device *);
 static void xenfb_init_shared_page(struct xenfb_info *);
 static int xenfb_connect_backend(struct xenbus_device *, struct xenfb_info *);
@@ -348,6 +350,7 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
 	if (ret < 0)
 		goto error;
 
+	xenfb_make_preferred_console();
 	return 0;
 
  error_nomem:
@@ -358,6 +361,28 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
 	return ret;
 }
 
+static __devinit void
+xenfb_make_preferred_console(void)
+{
+	struct console *c;
+
+	if (console_set_on_cmdline)
+		return;
+
+	acquire_console_sem();
+	for (c = console_drivers; c; c = c->next) {
+		if (!strcmp(c->name, "tty") && c->index == 0)
+			break;
+	}
+	release_console_sem();
+	if (c) {
+		unregister_console(c);
+		c->flags |= CON_CONSDEV;
+		c->flags &= ~CON_PRINTBUFFER; /* don't print again */
+		register_console(c);
+	}
+}
+
 static int xenfb_resume(struct xenbus_device *dev)
 {
 	struct xenfb_info *info = dev->dev.driver_data;
diff --git a/include/linux/console.h b/include/linux/console.h
index a5f88a6..7f51fa8 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -107,6 +107,8 @@ struct console {
 	struct	 console *next;
 };
 
+extern int console_set_on_cmdline;
+
 extern int add_preferred_console(char *name, int idx, char *options);
 extern int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, char *options);
 extern void register_console(struct console *);
diff --git a/kernel/printk.c b/kernel/printk.c
index c46a20a..c07bfc1 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -118,6 +118,7 @@ struct console_cmdline
 static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
 static int selected_console = -1;
 static int preferred_console = -1;
+int console_set_on_cmdline;
 
 /* Flag: console code may call schedule() */
 static int console_may_schedule;
@@ -829,6 +830,7 @@ static int __init console_setup(char *str)
 	*s = 0;
 
 	add_preferred_console(buf, idx, options);
+	console_set_on_cmdline = 1;
 	return 1;
 }
 __setup("console=", console_setup);
-- 
1.5.4.1


linux-2.6-xen-0007-xen-Module-autoprobing-support-for-frontend-drivers.patch:

Index: linux-2.6-xen-0007-xen-Module-autoprobing-support-for-frontend-drivers.patch
===================================================================
RCS file: linux-2.6-xen-0007-xen-Module-autoprobing-support-for-frontend-drivers.patch
diff -N linux-2.6-xen-0007-xen-Module-autoprobing-support-for-frontend-drivers.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0007-xen-Module-autoprobing-support-for-frontend-drivers.patch	14 Apr 2008 16:06:53 -0000	1.8
@@ -0,0 +1,97 @@
+From 4b9697a08b8c1d7c8a505d7189fc9f72396f7d64 Mon Sep 17 00:00:00 2001
+From: Mark McLoughlin <markmc at redhat.com>
+Date: Fri, 22 Feb 2008 12:42:52 +0000
+Subject: [PATCH] xen: Module autoprobing support for frontend drivers
+
+Add module aliases to support autoprobing modules
+for xen frontend devices.
+
+Signed-off-by: Mark McLoughlin <markmc at redhat.com>
+---
+ drivers/block/xen-blkfront.c      |    1 +
+ drivers/net/xen-netfront.c        |    1 +
+ drivers/xen/xenbus/xenbus_probe.c |   27 +++++++++++++++++++++++++--
+ 3 files changed, 27 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
+index 2e7c81e..0c47c02 100644
+--- a/drivers/block/xen-blkfront.c
++++ b/drivers/block/xen-blkfront.c
+@@ -1005,3 +1005,4 @@ module_exit(xlblk_exit);
+ MODULE_DESCRIPTION("Xen virtual block device frontend");
+ MODULE_LICENSE("GPL");
+ MODULE_ALIAS_BLOCKDEV_MAJOR(XENVBD_MAJOR);
++MODULE_ALIAS("xen:vbd");
+diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
+index 7483d45..b3fa27e 100644
+--- a/drivers/net/xen-netfront.c
++++ b/drivers/net/xen-netfront.c
+@@ -1809,3 +1809,4 @@ module_exit(netif_exit);
+ 
+ MODULE_DESCRIPTION("Xen virtual network device frontend");
+ MODULE_LICENSE("GPL");
++MODULE_ALIAS("xen:vif");
+diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
+index 4750de3..336363c 100644
+--- a/drivers/xen/xenbus/xenbus_probe.c
++++ b/drivers/xen/xenbus/xenbus_probe.c
+@@ -88,6 +88,16 @@ int xenbus_match(struct device *_dev, struct device_driver *_drv)
+ 	return match_device(drv->ids, to_xenbus_device(_dev)) != NULL;
+ }
+ 
++static int xenbus_uevent(struct device *_dev, struct kobj_uevent_env *env)
++{
++	struct xenbus_device *dev = to_xenbus_device(_dev);
++
++	if (add_uevent_var(env, "MODALIAS=xen:%s", dev->devicetype))
++		return -ENOMEM;
++
++	return 0;
++}
++
+ /* device/<type>/<id> => <type>-<id> */
+ static int frontend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
+ {
+@@ -166,6 +176,7 @@ static struct xen_bus_type xenbus_frontend = {
+ 	.bus = {
+ 		.name     = "xen",
+ 		.match    = xenbus_match,
++		.uevent   = xenbus_uevent,
+ 		.probe    = xenbus_dev_probe,
+ 		.remove   = xenbus_dev_remove,
+ 		.shutdown = xenbus_dev_shutdown,
+@@ -438,6 +449,12 @@ static ssize_t xendev_show_devtype(struct device *dev,
+ }
+ DEVICE_ATTR(devtype, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_devtype, NULL);
+ 
++static ssize_t xendev_show_modalias(struct device *dev,
++				    struct device_attribute *attr, char *buf)
++{
++	return sprintf(buf, "xen:%s\n", to_xenbus_device(dev)->devicetype);
++}
++DEVICE_ATTR(modalias, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_modalias, NULL);
+ 
+ int xenbus_probe_node(struct xen_bus_type *bus,
+ 		      const char *type,
+@@ -492,10 +509,16 @@ int xenbus_probe_node(struct xen_bus_type *bus,
+ 
+ 	err = device_create_file(&xendev->dev, &dev_attr_devtype);
+ 	if (err)
+-		goto fail_remove_file;
++		goto fail_remove_nodename;
++
++	err = device_create_file(&xendev->dev, &dev_attr_modalias);
++	if (err)
++		goto fail_remove_devtype;
+ 
+ 	return 0;
+-fail_remove_file:
++fail_remove_devtype:
++	device_remove_file(&xendev->dev, &dev_attr_devtype);
++fail_remove_nodename:
+ 	device_remove_file(&xendev->dev, &dev_attr_nodename);
+ fail_unregister:
+ 	device_unregister(&xendev->dev);
+-- 
+1.5.4.1
+

linux-2.6-xen-0008-xen-Add-compatibility-aliases-for-frontend-drivers.patch:

Index: linux-2.6-xen-0008-xen-Add-compatibility-aliases-for-frontend-drivers.patch
===================================================================
RCS file: linux-2.6-xen-0008-xen-Add-compatibility-aliases-for-frontend-drivers.patch
diff -N linux-2.6-xen-0008-xen-Add-compatibility-aliases-for-frontend-drivers.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0008-xen-Add-compatibility-aliases-for-frontend-drivers.patch	14 Apr 2008 16:06:53 -0000	1.8
@@ -0,0 +1,37 @@
+From 3b3af2bbea515992850cdbeaedcf4ad00bafc2fa Mon Sep 17 00:00:00 2001
+From: Mark McLoughlin <markmc at redhat.com>
+Date: Thu, 21 Feb 2008 11:13:12 +0000
+Subject: [PATCH] xen: Add compatibility aliases for frontend drivers
+
+Before getting merged, xen-blkfront was xenblk and
+xen-netfront was xennet.
+
+Add compatibility module aliases to ease upgrades.
+
+Signed-off-by: Mark McLoughlin <markmc at redhat.com>
+---
+ drivers/block/xen-blkfront.c |    1 +
+ drivers/net/xen-netfront.c   |    1 +
+ 2 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
+index 0c47c02..8ce168d 100644
+--- a/drivers/block/xen-blkfront.c
++++ b/drivers/block/xen-blkfront.c
+@@ -1006,3 +1006,4 @@ MODULE_DESCRIPTION("Xen virtual block device frontend");
+ MODULE_LICENSE("GPL");
+ MODULE_ALIAS_BLOCKDEV_MAJOR(XENVBD_MAJOR);
+ MODULE_ALIAS("xen:vbd");
++MODULE_ALIAS("xenblk");
+diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
+index b3fa27e..e62018a 100644
+--- a/drivers/net/xen-netfront.c
++++ b/drivers/net/xen-netfront.c
+@@ -1810,3 +1810,4 @@ module_exit(netif_exit);
+ MODULE_DESCRIPTION("Xen virtual network device frontend");
+ MODULE_LICENSE("GPL");
+ MODULE_ALIAS("xen:vif");
++MODULE_ALIAS("xennet");
+-- 
+1.5.4.1
+

linux-2.6-xen-0009-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch:

Index: linux-2.6-xen-0009-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch
===================================================================
RCS file: linux-2.6-xen-0009-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch
diff -N linux-2.6-xen-0009-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0009-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch	14 Apr 2008 16:06:53 -0000	1.7
@@ -0,0 +1,107 @@
+From c2d477ec5a0090ce9f9355bef9f4cc44143fd0a6 Mon Sep 17 00:00:00 2001
+From: Christian Limpach <Christian.Limpach at xensource.com>
+Date: Wed, 19 Mar 2008 15:54:48 +0000
+Subject: [PATCH] xen blkfront: Delay wait for block devices until after the disk is added.
+
+When the xen block frontend driver is built as a module the module load
+is only synchronous up to the point where the frontend and the backend
+become connected rather than when the disk is added.
+
+This means that there can be a race on boot between loading the module and
+loading the dm-* modules and doing the scan for LVM physical volumes (all
+in the initrd). In the failure case the disk is not present until after the
+scan for physical volumes is complete.
+
+Taken from:
+
+  http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/11483a00c017
+
+Signed-off-by: Christian Limpach <Christian.Limpach at xensource.com>
+Signed-off-by: Mark McLoughlin <markmc at redhat.com>
+---
+ drivers/block/xen-blkfront.c      |   11 +++++++++++
+ drivers/xen/xenbus/xenbus_probe.c |    5 ++++-
+ include/xen/xenbus.h              |    1 +
+ 3 files changed, 16 insertions(+), 1 deletions(-)
+
+diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
+index 8ce168d..74f943a 100644
+--- a/drivers/block/xen-blkfront.c
++++ b/drivers/block/xen-blkfront.c
+@@ -89,6 +89,7 @@ struct blkfront_info
+ 	struct blk_shadow shadow[BLK_RING_SIZE];
+ 	unsigned long shadow_free;
+ 	int feature_barrier;
++	int is_ready;
+ 
+ 	/**
+ 	 * The number of people holding this device open.  We won't allow a
+@@ -840,6 +841,8 @@ static void blkfront_connect(struct blkfront_info *info)
+ 	spin_unlock_irq(&blkif_io_lock);
+ 
+ 	add_disk(info->gd);
++
++	info->is_ready = 1;
+ }
+ 
+ /**
+@@ -932,6 +935,13 @@ static int blkfront_remove(struct xenbus_device *dev)
+ 	return 0;
+ }
+ 
++static int blkfront_is_ready(struct xenbus_device *dev)
++{
++	struct blkfront_info *info = dev->dev.driver_data;
++
++	return info->is_ready;
++}
++
+ static int blkif_open(struct inode *inode, struct file *filep)
+ {
+ 	struct blkfront_info *info = inode->i_bdev->bd_disk->private_data;
+@@ -978,6 +988,7 @@ static struct xenbus_driver blkfront = {
+ 	.remove = blkfront_remove,
+ 	.resume = blkfront_resume,
+ 	.otherend_changed = backend_changed,
++	.is_ready = blkfront_is_ready,
+ };
+ 
+ static int __init xlblk_init(void)
+diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
+index 336363c..57ceb53 100644
+--- a/drivers/xen/xenbus/xenbus_probe.c
++++ b/drivers/xen/xenbus/xenbus_probe.c
+@@ -869,6 +869,7 @@ static int is_disconnected_device(struct device *dev, void *data)
+ {
+ 	struct xenbus_device *xendev = to_xenbus_device(dev);
+ 	struct device_driver *drv = data;
++	struct xenbus_driver *xendrv;
+ 
+ 	/*
+ 	 * A device with no driver will never connect. We care only about
+@@ -881,7 +882,9 @@ static int is_disconnected_device(struct device *dev, void *data)
+ 	if (drv && (dev->driver != drv))
+ 		return 0;
+ 
+-	return (xendev->state != XenbusStateConnected);
++	xendrv = to_xenbus_driver(dev->driver);
++	return (xendev->state != XenbusStateConnected ||
++		(xendrv->is_ready && !xendrv->is_ready(xendev)));
+ }
+ 
+ static int exists_disconnected_device(struct device_driver *drv)
+diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h
+index 6f7c290..6369d89 100644
+--- a/include/xen/xenbus.h
++++ b/include/xen/xenbus.h
+@@ -97,6 +97,7 @@ struct xenbus_driver {
+ 	int (*uevent)(struct xenbus_device *, char **, int, char *, int);
+ 	struct device_driver driver;
+ 	int (*read_otherend_details)(struct xenbus_device *dev);
++	int (*is_ready)(struct xenbus_device *dev);
+ };
+ 
+ static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv)
+-- 
+1.5.4.1
+

linux-2.6-xen-0010-xen-Add-a-vmlinuz-target.patch:

Index: linux-2.6-xen-0010-xen-Add-a-vmlinuz-target.patch
===================================================================
RCS file: linux-2.6-xen-0010-xen-Add-a-vmlinuz-target.patch
diff -N linux-2.6-xen-0010-xen-Add-a-vmlinuz-target.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0010-xen-Add-a-vmlinuz-target.patch	14 Apr 2008 16:06:53 -0000	1.7
@@ -0,0 +1,78 @@
+From cf4fdac1d13c2a2c718c75f3487882c0e9b6bd2e Mon Sep 17 00:00:00 2001
+From: Mark McLoughlin <markmc at redhat.com>
+Date: Tue, 19 Feb 2008 15:34:32 +0000
+Subject: [PATCH] xen: Add a vmlinuz target
+
+Although patches are in progress to allow Xen boot
+a DomU using a bzImage, support for booting a Dom0
+using a bzImage is still a ways off.
+
+For now, just add a target to build a gzip-ed ELF
+file which Xen can use to boot both Dom0 and DomU.
+
+Signed-off-by: Mark McLoughlin <markmc at redhat.com>
+---
+ arch/x86/Makefile        |    9 +++++++++
+ arch/x86/boot/.gitignore |    1 +
+ arch/x86/boot/Makefile   |    9 +++++++++
+ 3 files changed, 19 insertions(+), 0 deletions(-)
+
+diff --git a/arch/x86/Makefile b/arch/x86/Makefile
+index f1e739a..14a752e 100644
+--- a/arch/x86/Makefile
++++ b/arch/x86/Makefile
+@@ -206,6 +206,15 @@ boot := arch/x86/boot
+ PHONY += zImage bzImage compressed zlilo bzlilo \
+          zdisk bzdisk fdimage fdimage144 fdimage288 isoimage install
+ 
++ifdef CONFIG_XEN
++PHONY += vmlinuz
++all: vmlinuz
++
++vmlinuz: KBUILD_IMAGE := $(boot)/vmlinuz
++vmlinuz: vmlinux
++	$(Q)$(MAKE) $(build)=$(boot) $(KBUILD_IMAGE)
++endif
++
+ # Default kernel to build
+ all: bzImage
+ 
+diff --git a/arch/x86/boot/.gitignore b/arch/x86/boot/.gitignore
+index b1bdc4c..35e7956 100644
+--- a/arch/x86/boot/.gitignore
++++ b/arch/x86/boot/.gitignore
+@@ -5,3 +5,4 @@ setup.bin
+ setup.elf
+ cpustr.h
+ mkcpustr
++vmlinuz
+diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
+index f88458e..61bba92 100644
+--- a/arch/x86/boot/Makefile
++++ b/arch/x86/boot/Makefile
+@@ -26,6 +26,7 @@ SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
+ #RAMDISK := -DRAMDISK=512
+ 
+ targets		:= vmlinux.bin setup.bin setup.elf zImage bzImage
++targets		+= vmlinuz vmlinux-stripped
+ subdir-		:= compressed
+ 
+ setup-y		+= a20.o cmdline.o copy.o cpu.o cpucheck.o edd.o
+@@ -105,6 +106,14 @@ $(obj)/setup.bin: $(obj)/setup.elf FORCE
+ $(obj)/compressed/vmlinux: FORCE
+ 	$(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
+ 
++$(obj)/vmlinuz: $(obj)/vmlinux-stripped FORCE
++	$(call if_changed,gzip)
++	@echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
++
++$(obj)/vmlinux-stripped: OBJCOPYFLAGS := -g --strip-unneeded
++$(obj)/vmlinux-stripped: vmlinux FORCE
++	$(call if_changed,objcopy)
++
+ # Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
+ FDARGS =
+ # Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
+-- 
+1.5.4.1
+

linux-2.6-xen-0011-xen-Add-empty-xenctrl-module.patch:

Index: linux-2.6-xen-0011-xen-Add-empty-xenctrl-module.patch
===================================================================
RCS file: linux-2.6-xen-0011-xen-Add-empty-xenctrl-module.patch
diff -N linux-2.6-xen-0011-xen-Add-empty-xenctrl-module.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0011-xen-Add-empty-xenctrl-module.patch	14 Apr 2008 16:06:53 -0000	1.7
@@ -0,0 +1,124 @@
+From 88a679ac465e3d4852cd9ca570872926e96b39c3 Mon Sep 17 00:00:00 2001
+From: Mark McLoughlin <markmc at redhat.com>
+Date: Mon, 4 Feb 2008 08:30:37 +0000
+Subject: [PATCH] xen: Add empty xenctrl module
+
+Add the basic infrastructure for a xenctrl module
+which will contain the various kernel interfaces
+used by (mainly Dom0) Xen userspace.
+
+Signed-off-by: Mark McLoughlin <markmc at redhat.com>
+---
+ arch/x86/xen/Kconfig         |    7 +++++
+ drivers/xen/Makefile         |    2 +
+ drivers/xen/xenctrl/Makefile |    4 +++
+ drivers/xen/xenctrl/main.c   |   62 ++++++++++++++++++++++++++++++++++++++++++
+ 4 files changed, 75 insertions(+), 0 deletions(-)
+ create mode 100644 drivers/xen/xenctrl/Makefile
+ create mode 100644 drivers/xen/xenctrl/main.c
+
+diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
+index 4d5f264..4723bc1 100644
+--- a/arch/x86/xen/Kconfig
++++ b/arch/x86/xen/Kconfig
+@@ -11,3 +11,10 @@ config XEN
+ 	  This is the Linux Xen port.  Enabling this will allow the
+ 	  kernel to boot in a paravirtualized environment under the
+ 	  Xen hypervisor.
++
++config XENCTRL
++	tristate "Xen's user space control interfaces"
++	depends on XEN && PROC_FS
++	default y if XEN
++	help
++	  This is the /proc/xen interface used by Xen's libxc.
+diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
+index 56592f0..6737463 100644
+--- a/drivers/xen/Makefile
++++ b/drivers/xen/Makefile
+@@ -1,2 +1,4 @@
+ obj-y	+= grant-table.o
+ obj-y	+= xenbus/
++
++obj-$(CONFIG_XENCTRL) += xenctrl/
+diff --git a/drivers/xen/xenctrl/Makefile b/drivers/xen/xenctrl/Makefile
+new file mode 100644
+index 0000000..1f43a43
+--- /dev/null
++++ b/drivers/xen/xenctrl/Makefile
+@@ -0,0 +1,4 @@
++obj-$(CONFIG_XENCTRL) += xenctrl.o
++
++xenctrl-objs  =
++xenctrl-objs += main.o
+diff --git a/drivers/xen/xenctrl/main.c b/drivers/xen/xenctrl/main.c
+new file mode 100644
+index 0000000..2965ceb
+--- /dev/null
++++ b/drivers/xen/xenctrl/main.c
+@@ -0,0 +1,62 @@
++/******************************************************************************
++ *
++ * main.c
++ *
++ * Xen userspace control interfaces
++ *
++ * Copyright (c) 2002-2004, K A Fraser, B Dragovic
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License version 2
++ * as published by the Free Software Foundation; or, when distributed
++ * separately from the Linux kernel or incorporated into other
++ * software packages, subject to the following license:
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this source file (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use, copy, modify,
++ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
++ * and to permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
++ * IN THE SOFTWARE.
++ */
++
++#include <linux/proc_fs.h>
++#include <linux/module.h>
++#include <asm/xen/hypervisor.h>
++
++static int __init xenctrl_init(void)
++{
++	struct proc_dir_entry *dir;
++
++	if (!is_running_on_xen())
++		return -ENODEV;
++
++	dir = proc_mkdir("xen", NULL);
++	if (!dir)
++		return -ENOMEM;
++
++	dir->owner = THIS_MODULE;
++
++	return 0;
++}
++
++static void __exit xenctrl_exit(void)
++{
++	remove_proc_entry("xen", NULL);
++}
++
++module_init(xenctrl_init);
++module_exit(xenctrl_exit);
++
++MODULE_LICENSE("Dual BSD/GPL");
+-- 
+1.5.4.1
+

linux-2.6-xen-0012-xen-Add-proc-xen-capabilities.patch:

Index: linux-2.6-xen-0012-xen-Add-proc-xen-capabilities.patch
===================================================================
RCS file: linux-2.6-xen-0012-xen-Add-proc-xen-capabilities.patch
diff -N linux-2.6-xen-0012-xen-Add-proc-xen-capabilities.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0012-xen-Add-proc-xen-capabilities.patch	14 Apr 2008 16:06:53 -0000	1.7
@@ -0,0 +1,190 @@
+From bfba19ed52ba828cc2faaf426377483bb6df473f Mon Sep 17 00:00:00 2001
+From: Mark McLoughlin <markmc at redhat.com>
+Date: Mon, 4 Feb 2008 09:16:51 +0000
+Subject: [PATCH] xen: Add /proc/xen/capabilities
+
+/proc/xen/capabilities is used by the xend init script
+to check whether it is running on Dom0.
+
+Signed-off-by: Mark McLoughlin <markmc at redhat.com>
+---
+ drivers/xen/xenctrl/Makefile       |    1 +
+ drivers/xen/xenctrl/capabilities.c |   68 ++++++++++++++++++++++++++++++++++++
+ drivers/xen/xenctrl/main.c         |   11 ++++++
+ drivers/xen/xenctrl/xenctrl.h      |   39 ++++++++++++++++++++
+ 4 files changed, 119 insertions(+), 0 deletions(-)
+ create mode 100644 drivers/xen/xenctrl/capabilities.c
+ create mode 100644 drivers/xen/xenctrl/xenctrl.h
+
+diff --git a/drivers/xen/xenctrl/Makefile b/drivers/xen/xenctrl/Makefile
+index 1f43a43..631f535 100644
+--- a/drivers/xen/xenctrl/Makefile
++++ b/drivers/xen/xenctrl/Makefile
+@@ -2,3 +2,4 @@ obj-$(CONFIG_XENCTRL) += xenctrl.o
+ 
+ xenctrl-objs  =
+ xenctrl-objs += main.o
++xenctrl-objs += capabilities.o
+diff --git a/drivers/xen/xenctrl/capabilities.c b/drivers/xen/xenctrl/capabilities.c
+new file mode 100644
+index 0000000..1ff078a
+--- /dev/null
++++ b/drivers/xen/xenctrl/capabilities.c
+@@ -0,0 +1,68 @@
++/******************************************************************************
++ *
++ * capabilities.c
++ *
++ * /proc/xen/capabilities
++ *
++ * Copyright (c) 2002-2004, K A Fraser, B Dragovic
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License version 2
++ * as published by the Free Software Foundation; or, when distributed
++ * separately from the Linux kernel or incorporated into other
++ * software packages, subject to the following license:
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this source file (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use, copy, modify,
++ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
++ * and to permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
++ * IN THE SOFTWARE.
++ */
++
++#include <linux/proc_fs.h>
++#include <linux/module.h>
++#include <asm/xen/hypervisor.h>
++
++static int capabilities_read(char *page, char **start, off_t off,
++			     int count, int *eof, void *data)
++{
++	int len = 0;
++	*page = 0;
++
++	if (is_initial_xendomain())
++		len = sprintf(page, "control_d\n");
++
++	*eof = 1;
++	return len;
++}
++
++int __init capabilities_create_proc_entry(void)
++{
++	struct proc_dir_entry *entry;
++
++	entry = create_proc_entry("xen/capabilities", 0400, NULL);
++	if (!entry)
++		return -ENOMEM;
++
++	entry->owner = THIS_MODULE;
++	entry->read_proc = capabilities_read;
++
++	return 0;
++}
++
++void __exit capabilities_remove_proc_entry(void)
++{
++	remove_proc_entry("xen/capabilities", NULL);
++}
+diff --git a/drivers/xen/xenctrl/main.c b/drivers/xen/xenctrl/main.c
+index 2965ceb..0e42f7e 100644
+--- a/drivers/xen/xenctrl/main.c
++++ b/drivers/xen/xenctrl/main.c
+@@ -31,6 +31,8 @@
+  * IN THE SOFTWARE.
+  */
+ 
++#include "xenctrl.h"
++
+ #include <linux/proc_fs.h>
+ #include <linux/module.h>
+ #include <asm/xen/hypervisor.h>
+@@ -38,6 +40,7 @@
+ static int __init xenctrl_init(void)
+ {
+ 	struct proc_dir_entry *dir;
++	int ret;
+ 
+ 	if (!is_running_on_xen())
+ 		return -ENODEV;
+@@ -48,11 +51,19 @@ static int __init xenctrl_init(void)
+ 
+ 	dir->owner = THIS_MODULE;
+ 
++	ret = capabilities_create_proc_entry();
++	if (ret)
++		goto fail1;
++
+ 	return 0;
++
++ fail1:	remove_proc_entry("xen", NULL);
++	return ret;
+ }
+ 
+ static void __exit xenctrl_exit(void)
+ {
++	capabilities_remove_proc_entry();
+ 	remove_proc_entry("xen", NULL);
+ }
+ 
+diff --git a/drivers/xen/xenctrl/xenctrl.h b/drivers/xen/xenctrl/xenctrl.h
+new file mode 100644
+index 0000000..7378dde
+--- /dev/null
++++ b/drivers/xen/xenctrl/xenctrl.h
+@@ -0,0 +1,39 @@
++/******************************************************************************
++ * xenctl.h
++ * 
++ * Xen userspace control interfaces
++ * 
++ * Copyright (c) 2002-2004, K A Fraser, B Dragovic
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License version 2
++ * as published by the Free Software Foundation; or, when distributed
++ * separately from the Linux kernel or incorporated into other
++ * software packages, subject to the following license:
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this source file (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use, copy, modify,
++ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
++ * and to permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
++ * IN THE SOFTWARE.
++ */
++
++#include <linux/init.h>
++
++/*
++ * capabilities.c
++ */
++int capabilities_create_proc_entry(void) __init;
++void capabilities_remove_proc_entry(void) __exit;
+-- 
+1.5.4.1
+

linux-2.6-xen-0013-xen-Add-proc-xen-privcmd.patch:

Index: linux-2.6-xen-0013-xen-Add-proc-xen-privcmd.patch
===================================================================
RCS file: linux-2.6-xen-0013-xen-Add-proc-xen-privcmd.patch
diff -N linux-2.6-xen-0013-xen-Add-proc-xen-privcmd.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0013-xen-Add-proc-xen-privcmd.patch	14 Apr 2008 16:06:53 -0000	1.7
@@ -0,0 +1,285 @@
+From f96c654b1d96dd63858ffa79b5317dbcdc91aa7a Mon Sep 17 00:00:00 2001
+From: Mark McLoughlin <markmc at redhat.com>
+Date: Mon, 4 Feb 2008 08:24:57 +0000
+Subject: [PATCH] xen: Add /proc/xen/privcmd
+
+/proc/xen/privcmd is an ioctl() interface which allows
+userspace apps to invoke hypercalls.
+
+There should also be an ioctl (IOCTL_PRIVCMD_MMAP)
+which is used to map foreign pages into a processes
+address space, but we leave this unimplemented for
+now pending further work on foreign page support.
+
+Signed-off-by: Mark McLoughlin <markmc at redhat.com>
+---
+ drivers/xen/xenctrl/Makefile    |    1 +
+ drivers/xen/xenctrl/main.c      |    6 +++
+ drivers/xen/xenctrl/privcmd.c   |   81 +++++++++++++++++++++++++++++++++++++++
+ drivers/xen/xenctrl/xenctrl.h   |    6 +++
+ include/asm-x86/xen/hypercall.h |   28 +++++++++++++
+ include/xen/sys/privcmd.h       |   79 ++++++++++++++++++++++++++++++++++++++
+ 6 files changed, 201 insertions(+), 0 deletions(-)
+ create mode 100644 drivers/xen/xenctrl/privcmd.c
+ create mode 100644 include/xen/sys/privcmd.h
+
+diff --git a/drivers/xen/xenctrl/Makefile b/drivers/xen/xenctrl/Makefile
+index 631f535..8a706cb 100644
+--- a/drivers/xen/xenctrl/Makefile
++++ b/drivers/xen/xenctrl/Makefile
+@@ -3,3 +3,4 @@ obj-$(CONFIG_XENCTRL) += xenctrl.o
+ xenctrl-objs  =
+ xenctrl-objs += main.o
+ xenctrl-objs += capabilities.o
++xenctrl-objs += privcmd.o
+diff --git a/drivers/xen/xenctrl/main.c b/drivers/xen/xenctrl/main.c
+index 0e42f7e..d1fe6ef 100644
+--- a/drivers/xen/xenctrl/main.c
++++ b/drivers/xen/xenctrl/main.c
+@@ -55,14 +55,20 @@ static int __init xenctrl_init(void)
+ 	if (ret)
+ 		goto fail1;
+ 
++	ret = privcmd_create_proc_entry();
++	if (ret)
++		goto fail2;
++
+ 	return 0;
+ 
++ fail2: capabilities_remove_proc_entry();
+  fail1:	remove_proc_entry("xen", NULL);
+ 	return ret;
+ }
+ 
+ static void __exit xenctrl_exit(void)
+ {
++	privcmd_remove_proc_entry();
+ 	capabilities_remove_proc_entry();
+ 	remove_proc_entry("xen", NULL);
+ }
+diff --git a/drivers/xen/xenctrl/privcmd.c b/drivers/xen/xenctrl/privcmd.c
+new file mode 100644
+index 0000000..58c4b83
+--- /dev/null
++++ b/drivers/xen/xenctrl/privcmd.c
+@@ -0,0 +1,81 @@
++/******************************************************************************
++ * privcmd.c
++ * 
++ * Interface to privileged domain-0 commands.
++ * 
++ * Copyright (c) 2002-2004, K A Fraser, B Dragovic
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License version 2
++ * as published by the Free Software Foundation; or, when distributed
++ * separately from the Linux kernel or incorporated into other
++ * software packages, subject to the following license:
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this source file (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use, copy, modify,
++ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
++ * and to permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
++ * IN THE SOFTWARE.
++ */
++
++#include <linux/proc_fs.h>
++#include <linux/module.h>
++#include <linux/uaccess.h>
++#include <asm/xen/hypervisor.h>
++#include <xen/sys/privcmd.h>
++
++static long privcmd_ioctl(struct file *file, unsigned int cmd,
++			  unsigned long arg)
++{
++	switch (cmd) {
++	case IOCTL_PRIVCMD_HYPERCALL: {
++		privcmd_hypercall_t cmd;
++  
++		if (copy_from_user(&cmd, (void __user *)arg, sizeof(cmd)))
++			return -EFAULT;
++
++		return privcmd_hypercall(&cmd);
++	}
++
++	case IOCTL_PRIVCMD_MMAP:
++	case IOCTL_PRIVCMD_MMAPBATCH:
++		printk(KERN_WARNING "IOCTL_PRIVCMD_MMAP ioctl not yet implemented\n");
++	default:
++		return -EINVAL;
++	}
++}
++
++static const struct file_operations privcmd_file_ops = {
++	.unlocked_ioctl = privcmd_ioctl,
++};
++
++int __init privcmd_create_proc_entry(void)
++{
++	static struct proc_dir_entry *entry;
++
++	entry = create_proc_entry("xen/privcmd", 0400, NULL);
++	if (!entry)
++		return -ENOMEM;
++
++	entry->owner = THIS_MODULE;
++	entry->proc_fops = &privcmd_file_ops;
++
++	return 0;
++}
++
++void __exit privcmd_remove_proc_entry(void)
++{
++	remove_proc_entry("xen/privcmd", NULL);
++}
+diff --git a/drivers/xen/xenctrl/xenctrl.h b/drivers/xen/xenctrl/xenctrl.h
+index 7378dde..a35209a 100644
+--- a/drivers/xen/xenctrl/xenctrl.h
++++ b/drivers/xen/xenctrl/xenctrl.h
+@@ -37,3 +37,9 @@
+  */
+ int capabilities_create_proc_entry(void) __init;
+ void capabilities_remove_proc_entry(void) __exit;
++
++/*
++ * privcmd.c
++ */
++int privcmd_create_proc_entry(void) __init;
++void privcmd_remove_proc_entry(void) __exit;
+diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
+index bc0ee7d..cd554ca 100644
+--- a/include/asm-x86/xen/hypercall.h
++++ b/include/asm-x86/xen/hypercall.h
+@@ -410,4 +410,32 @@ MULTI_stack_switch(struct multicall_entry *mcl,
+ 	mcl->args[1] = esp;
+ }
+ 
++#include <xen/sys/privcmd.h>
++
++static inline int privcmd_hypercall(privcmd_hypercall_t *hypercall)
++{
++	int ret;
++
++	if (hypercall->op >= (PAGE_SIZE >> 5))
++		return -EINVAL;
++
++	__asm__ __volatile__ (
++		"pushl %%ebx; pushl %%ecx; pushl %%edx; "
++		"pushl %%esi; pushl %%edi; "
++		"movl  8(%%eax),%%ebx ;"
++		"movl 16(%%eax),%%ecx ;"
++		"movl 24(%%eax),%%edx ;"
++		"movl 32(%%eax),%%esi ;"
++		"movl 40(%%eax),%%edi ;"
++		"movl   (%%eax),%%eax ;"
++		"shll $5,%%eax ;"
++		"addl $hypercall_page,%%eax ;"
++		"call *%%eax ;"
++		"popl %%edi; popl %%esi; popl %%edx; "
++		"popl %%ecx; popl %%ebx"
++		: "=a" (ret) : "0" (hypercall) : "memory" );
++
++	return ret;
++}
++
+ #endif /* __HYPERCALL_H__ */
+diff --git a/include/xen/sys/privcmd.h b/include/xen/sys/privcmd.h
+new file mode 100644
+index 0000000..9cfa9d7
+--- /dev/null
++++ b/include/xen/sys/privcmd.h
+@@ -0,0 +1,79 @@
++/******************************************************************************
++ * privcmd.h
++ * 
++ * Interface to /proc/xen/privcmd.
++ * 
++ * Copyright (c) 2003-2005, K A Fraser
++ * 
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License version 2
++ * as published by the Free Software Foundation; or, when distributed
++ * separately from the Linux kernel or incorporated into other
++ * software packages, subject to the following license:
++ * 
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this source file (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use, copy, modify,
++ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
++ * and to permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ * 
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ * 
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
++ * IN THE SOFTWARE.
++ */
++
++#ifndef __LINUX_PUBLIC_PRIVCMD_H__
++#define __LINUX_PUBLIC_PRIVCMD_H__
++
++#include <linux/types.h>
++
++#ifndef __user
++#define __user
++#endif
++
++typedef struct privcmd_hypercall
++{
++	__u64 op;
++	__u64 arg[5];
++} privcmd_hypercall_t;
++
++typedef struct privcmd_mmap_entry {
++	__u64 va;
++	__u64 mfn;
++	__u64 npages;
++} privcmd_mmap_entry_t; 
++
++typedef struct privcmd_mmap {
++	int num;
++	domid_t dom; /* target domain */
++	privcmd_mmap_entry_t __user *entry;
++} privcmd_mmap_t; 
++
++typedef struct privcmd_mmapbatch {
++	int num;     /* number of pages to populate */
++	domid_t dom; /* target domain */
++	__u64 addr;  /* virtual address */
++	ulong __user *arr; /* array of mfns - top nibble set on err */
++} privcmd_mmapbatch_t; 
++
++/*
++ * @cmd: IOCTL_PRIVCMD_HYPERCALL
++ * @arg: &privcmd_hypercall_t
++ * Return: Value returned from execution of the specified hypercall.
++ */
++#define IOCTL_PRIVCMD_HYPERCALL					\
++	_IOC(_IOC_NONE, 'P', 0, sizeof(privcmd_hypercall_t))
++#define IOCTL_PRIVCMD_MMAP					\
++	_IOC(_IOC_NONE, 'P', 2, sizeof(privcmd_mmap_t))
++#define IOCTL_PRIVCMD_MMAPBATCH					\
++	_IOC(_IOC_NONE, 'P', 3, sizeof(privcmd_mmapbatch_t))
++
++#endif /* __LINUX_PUBLIC_PRIVCMD_H__ */
+-- 
+1.5.4.1
+

linux-2.6-xen-0014-xen-Add-proc-xen-xenbus.patch:

Index: linux-2.6-xen-0014-xen-Add-proc-xen-xenbus.patch
===================================================================
RCS file: linux-2.6-xen-0014-xen-Add-proc-xen-xenbus.patch
diff -N linux-2.6-xen-0014-xen-Add-proc-xen-xenbus.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0014-xen-Add-proc-xen-xenbus.patch	14 Apr 2008 16:06:53 -0000	1.7
@@ -0,0 +1,529 @@
+From 1026aab43b06b301f4e1de76476fb35ead03d2c7 Mon Sep 17 00:00:00 2001
+From: Mark McLoughlin <markmc at redhat.com>
+Date: Mon, 4 Feb 2008 22:04:36 +0000
+Subject: [PATCH] xen: Add /proc/xen/xenbus
+
+This interface is used by userspace programs to talk to
+xenstored.
+
+Since xenstored makes itself available to Dom0 userspace
+via a socket this should only really be useful in Domu,
+but it turns out that Dom0 apps historically default
+to using /proc/xen/xenbus rather than the socket.
+
+Signed-off-by: Mark McLoughlin <markmc at redhat.com>
+---
+ drivers/xen/xenbus/xenbus_comms.h |    1 -
+ drivers/xen/xenbus/xenbus_probe.c |    2 +
+ drivers/xen/xenbus/xenbus_xs.c    |    1 +
+ drivers/xen/xenctrl/Makefile      |    1 +
+ drivers/xen/xenctrl/main.c        |    6 +
+ drivers/xen/xenctrl/xenbus.c      |  398 +++++++++++++++++++++++++++++++++++++
+ drivers/xen/xenctrl/xenctrl.h     |    6 +
+ include/xen/xenbus.h              |    2 +
+ 8 files changed, 416 insertions(+), 1 deletions(-)
+ create mode 100644 drivers/xen/xenctrl/xenbus.c
+
+diff --git a/drivers/xen/xenbus/xenbus_comms.h b/drivers/xen/xenbus/xenbus_comms.h
+index c21db75..fcc9b29 100644
+--- a/drivers/xen/xenbus/xenbus_comms.h
++++ b/drivers/xen/xenbus/xenbus_comms.h
+@@ -41,6 +41,5 @@ int xb_data_to_read(void);
+ int xb_wait_for_data_to_read(void);
+ int xs_input_avail(void);
+ extern struct xenstore_domain_interface *xen_store_interface;
+-extern int xen_store_evtchn;
+ 
+ #endif /* _XENBUS_COMMS_H */
+diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
+index 57ceb53..c811581 100644
+--- a/drivers/xen/xenbus/xenbus_probe.c
++++ b/drivers/xen/xenbus/xenbus_probe.c
+@@ -56,6 +56,8 @@
+ #include "xenbus_probe.h"
+ 
+ int xen_store_evtchn;
++EXPORT_SYMBOL_GPL(xen_store_evtchn);
++
+ struct xenstore_domain_interface *xen_store_interface;
+ static unsigned long xen_store_mfn;
+ 
+diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
+index 227d53b..810e24a 100644
+--- a/drivers/xen/xenbus/xenbus_xs.c
++++ b/drivers/xen/xenbus/xenbus_xs.c
+@@ -184,6 +184,7 @@ void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg)
+ 
+ 	return ret;
+ }
++EXPORT_SYMBOL(xenbus_dev_request_and_reply);
+ 
+ /* Send message to xs, get kmalloc'ed reply.  ERR_PTR() on error. */
+ static void *xs_talkv(struct xenbus_transaction t,
+diff --git a/drivers/xen/xenctrl/Makefile b/drivers/xen/xenctrl/Makefile
+index 8a706cb..23dafa3 100644
+--- a/drivers/xen/xenctrl/Makefile
++++ b/drivers/xen/xenctrl/Makefile
+@@ -4,3 +4,4 @@ xenctrl-objs  =
+ xenctrl-objs += main.o
+ xenctrl-objs += capabilities.o
+ xenctrl-objs += privcmd.o
++xenctrl-objs += xenbus.o
+diff --git a/drivers/xen/xenctrl/main.c b/drivers/xen/xenctrl/main.c
+index d1fe6ef..b0cf61b 100644
+--- a/drivers/xen/xenctrl/main.c
++++ b/drivers/xen/xenctrl/main.c
+@@ -59,8 +59,13 @@ static int __init xenctrl_init(void)
+ 	if (ret)
+ 		goto fail2;
+ 
++	ret = xenbus_create_proc_entry();
++	if (ret)
++		goto fail3;
++
+ 	return 0;
+ 
++ fail3: privcmd_remove_proc_entry();
+  fail2: capabilities_remove_proc_entry();
+  fail1:	remove_proc_entry("xen", NULL);
+ 	return ret;
+@@ -68,6 +73,7 @@ static int __init xenctrl_init(void)
+ 
+ static void __exit xenctrl_exit(void)
+ {
++	xenbus_remove_proc_entry();
+ 	privcmd_remove_proc_entry();
+ 	capabilities_remove_proc_entry();
+ 	remove_proc_entry("xen", NULL);
+diff --git a/drivers/xen/xenctrl/xenbus.c b/drivers/xen/xenctrl/xenbus.c
+new file mode 100644
+index 0000000..57d5501
+--- /dev/null
++++ b/drivers/xen/xenctrl/xenbus.c
+@@ -0,0 +1,398 @@
++/*
++ * xenbus.c
++ * 
++ * /proc/xen/xenbus gives user-space access to the kernel's xenbus
++ * connection to xenstore.
++ * 
++ * Copyright (c) 2005, Christian Limpach
++ * Copyright (c) 2005, Rusty Russell, IBM Corporation
++ * 
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License version 2
++ * as published by the Free Software Foundation; or, when distributed
++ * separately from the Linux kernel or incorporated into other
++ * software packages, subject to the following license:
++ * 
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this source file (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use, copy, modify,
++ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
++ * and to permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ * 
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ * 
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
++ * IN THE SOFTWARE.
++ */
++
++#include <linux/proc_fs.h>
++#include <linux/module.h>
++#include <linux/uaccess.h>
++#include <linux/poll.h>
++
++#include <xen/xenbus.h>
++
++struct xenbus_dev_transaction {
++	struct list_head list;
++	struct xenbus_transaction handle;
++};
++
++struct read_buffer {
++	struct list_head list;
++	unsigned int cons;
++	unsigned int len;
++	char msg[];
++};
++
++struct xenbus_dev_data {
++	/* In-progress transaction. */
++	struct list_head transactions;
++
++	/* Active watches. */
++	struct list_head watches;
++
++	/* Partial request. */
++	unsigned int len;
++	union {
++		struct xsd_sockmsg msg;
++		char buffer[PAGE_SIZE];
++	} u;
++
++	/* Response queue. */
++	struct list_head read_buffers;
++	wait_queue_head_t read_waitq;
++
++	struct mutex reply_mutex;
++};
++
++static ssize_t xenbus_dev_read(struct file *filp,
++			       char __user *ubuf,
++			       size_t len, loff_t *ppos)
++{
++	struct xenbus_dev_data *u = filp->private_data;
++	struct read_buffer *rb;
++	int i, ret;
++
++	mutex_lock(&u->reply_mutex);
++	while (list_empty(&u->read_buffers)) {
++		mutex_unlock(&u->reply_mutex);
++		ret = wait_event_interruptible(u->read_waitq,
++					       !list_empty(&u->read_buffers));
++		if (ret)
++			return ret;
++		mutex_lock(&u->reply_mutex);
++	}
++
++	rb = list_entry(u->read_buffers.next, struct read_buffer, list);
++	for (i = 0; i < len;) {
++		put_user(rb->msg[rb->cons], ubuf + i);
++		i++;
++		rb->cons++;
++		if (rb->cons == rb->len) {
++			list_del(&rb->list);
++			kfree(rb);
++			if (list_empty(&u->read_buffers))
++				break;
++			rb = list_entry(u->read_buffers.next,
++					struct read_buffer, list);
++		}
++	}
++	mutex_unlock(&u->reply_mutex);
++
++	return i;
++}
++
++static void queue_reply(struct xenbus_dev_data *u,
++			char *data, unsigned int len)
++{
++	struct read_buffer *rb;
++
++	if (len == 0)
++		return;
++
++	rb = kmalloc(sizeof(*rb) + len, GFP_KERNEL);
++	BUG_ON(rb == NULL);
++
++	rb->cons = 0;
++	rb->len = len;
++
++	memcpy(rb->msg, data, len);
++
++	list_add_tail(&rb->list, &u->read_buffers);
++
++	wake_up(&u->read_waitq);
++}
++
++struct watch_adapter
++{
++	struct list_head list;
++	struct xenbus_watch watch;
++	struct xenbus_dev_data *dev_data;
++	char *token;
++};
++
++static void free_watch_adapter(struct watch_adapter *watch)
++{
++	kfree(watch->watch.node);
++	kfree(watch->token);
++	kfree(watch);
++}
++
++static void watch_fired(struct xenbus_watch *watch,
++			const char **vec,
++			unsigned int len)
++{
++	struct watch_adapter *adap =
++            container_of(watch, struct watch_adapter, watch);
++	struct xsd_sockmsg hdr;
++	const char *path, *token;
++	int path_len, tok_len, body_len;
++
++	path = vec[XS_WATCH_PATH];
++	token = adap->token;
++
++	path_len = strlen(path) + 1;
++	tok_len = strlen(token) + 1;
++	body_len = path_len + tok_len;
++
++	hdr.type = XS_WATCH_EVENT;
++	hdr.len = body_len;
++
++	mutex_lock(&adap->dev_data->reply_mutex);
++	queue_reply(adap->dev_data, (char *)&hdr, sizeof(hdr));
++	queue_reply(adap->dev_data, (char *)path, path_len);
++	queue_reply(adap->dev_data, (char *)token, tok_len);
++	mutex_unlock(&adap->dev_data->reply_mutex);
++}
++
++static LIST_HEAD(watch_list);
++
++static ssize_t xenbus_dev_write(struct file *filp,
++				const char __user *ubuf,
++				size_t len, loff_t *ppos)
++{
++	struct xenbus_dev_data *u = filp->private_data;
++	struct xenbus_dev_transaction *trans = NULL;
++	uint32_t msg_type;
++	void *reply;
++	char *path, *token;
++	struct watch_adapter *watch, *tmp_watch;
++	int err, rc = len;
++
++	if ((len + u->len) > sizeof(u->u.buffer)) {
++		rc = -EINVAL;
++		goto out;
++	}
++
++	if (copy_from_user(u->u.buffer + u->len, ubuf, len) != 0) {
++		rc = -EFAULT;
++		goto out;
++	}
++
++	u->len += len;
++	if ((u->len < sizeof(u->u.msg)) ||
++	    (u->len < (sizeof(u->u.msg) + u->u.msg.len)))
++		return rc;
++
++	msg_type = u->u.msg.type;
++
++	switch (msg_type) {
++	case XS_TRANSACTION_START:
++	case XS_TRANSACTION_END:
++	case XS_DIRECTORY:
++	case XS_READ:
++	case XS_GET_PERMS:
++	case XS_RELEASE:
++	case XS_GET_DOMAIN_PATH:
++	case XS_WRITE:
++	case XS_MKDIR:
++	case XS_RM:
++	case XS_SET_PERMS:
++		if (msg_type == XS_TRANSACTION_START) {
++			trans = kmalloc(sizeof(*trans), GFP_KERNEL);
++			if (!trans) {
++				rc = -ENOMEM;
++				goto out;
++			}
++		}
++
++		reply = xenbus_dev_request_and_reply(&u->u.msg);
++		if (IS_ERR(reply)) {
++			kfree(trans);
++			rc = PTR_ERR(reply);
++			goto out;
++		}
++
++		if (msg_type == XS_TRANSACTION_START) {
++			trans->handle.id = simple_strtoul(reply, NULL, 0);
++			list_add(&trans->list, &u->transactions);
++		} else if (msg_type == XS_TRANSACTION_END) {
++			list_for_each_entry(trans, &u->transactions, list)
++				if (trans->handle.id == u->u.msg.tx_id)
++					break;
++			BUG_ON(&trans->list == &u->transactions);
++			list_del(&trans->list);
++			kfree(trans);
++		}
++		mutex_lock(&u->reply_mutex);
++		queue_reply(u, (char *)&u->u.msg, sizeof(u->u.msg));
++		queue_reply(u, (char *)reply, u->u.msg.len);
++		mutex_unlock(&u->reply_mutex);
++		kfree(reply);
++		break;
++
++	case XS_WATCH:
++	case XS_UNWATCH: {
++		static const char *XS_RESP = "OK";
++		struct xsd_sockmsg hdr;
++
++		path = u->u.buffer + sizeof(u->u.msg);
++		token = memchr(path, 0, u->u.msg.len);
++		if (token == NULL) {
++			rc = -EILSEQ;
++			goto out;
++		}
++		token++;
++
++		if (msg_type == XS_WATCH) {
++			watch = kmalloc(sizeof(*watch), GFP_KERNEL);
++			watch->watch.node = kmalloc(strlen(path)+1,
++                                                    GFP_KERNEL);
++			strcpy((char *)watch->watch.node, path);
++			watch->watch.callback = watch_fired;
++			watch->token = kmalloc(strlen(token)+1, GFP_KERNEL);
++			strcpy(watch->token, token);
++			watch->dev_data = u;
++
++			err = register_xenbus_watch(&watch->watch);
++			if (err) {
++				free_watch_adapter(watch);
++				rc = err;
++				goto out;
++			}
++			
++			list_add(&watch->list, &u->watches);
++		} else {
++			list_for_each_entry_safe(watch, tmp_watch,
++                                                 &u->watches, list) {
++				if (!strcmp(watch->token, token) &&
++				    !strcmp(watch->watch.node, path))
++				{
++					unregister_xenbus_watch(&watch->watch);
++					list_del(&watch->list);
++					free_watch_adapter(watch);
++					break;
++				}
++			}
++		}
++
++		hdr.type = msg_type;
++		hdr.len = strlen(XS_RESP) + 1;
++		mutex_lock(&u->reply_mutex);
++		queue_reply(u, (char *)&hdr, sizeof(hdr));
++		queue_reply(u, (char *)XS_RESP, hdr.len);
++		mutex_unlock(&u->reply_mutex);
++		break;
++	}
++
++	default:
++		rc = -EINVAL;
++		break;
++	}
++
++ out:
++	u->len = 0;
++	return rc;
++}
++
++static int xenbus_dev_open(struct inode *inode, struct file *filp)
++{
++	struct xenbus_dev_data *u;
++
++	if (xen_store_evtchn == 0)
++		return -ENOENT;
++
++	nonseekable_open(inode, filp);
++
++	u = kzalloc(sizeof(*u), GFP_KERNEL);
++	if (u == NULL)
++		return -ENOMEM;
++
++	INIT_LIST_HEAD(&u->transactions);
++	INIT_LIST_HEAD(&u->watches);
++	INIT_LIST_HEAD(&u->read_buffers);
++	init_waitqueue_head(&u->read_waitq);
++
++	mutex_init(&u->reply_mutex);
++
++	filp->private_data = u;
++
++	return 0;
++}
++
++static int xenbus_dev_release(struct inode *inode, struct file *filp)
++{
++	struct xenbus_dev_data *u = filp->private_data;
++	struct xenbus_dev_transaction *trans, *tmp;
++	struct watch_adapter *watch, *tmp_watch;
++
++	list_for_each_entry_safe(trans, tmp, &u->transactions, list) {
++		xenbus_transaction_end(trans->handle, 1);
++		list_del(&trans->list);
++		kfree(trans);
++	}
++
++	list_for_each_entry_safe(watch, tmp_watch, &u->watches, list) {
++		unregister_xenbus_watch(&watch->watch);
++		list_del(&watch->list);
++		free_watch_adapter(watch);
++	}
++
++	kfree(u);
++
++	return 0;
++}
++
++static unsigned int xenbus_dev_poll(struct file *file, poll_table *wait)
++{
++	struct xenbus_dev_data *u = file->private_data;
++
++	poll_wait(file, &u->read_waitq, wait);
++	if (!list_empty(&u->read_buffers))
++		return POLLIN | POLLRDNORM;
++	return 0;
++}
++
++static const struct file_operations xenbus_dev_file_ops = {
++	.read = xenbus_dev_read,
++	.write = xenbus_dev_write,
++	.open = xenbus_dev_open,
++	.release = xenbus_dev_release,
++	.poll = xenbus_dev_poll,
++};
++
++int __init xenbus_create_proc_entry(void)
++{
++	struct proc_dir_entry *entry;
++
++	entry = create_proc_entry("xen/xenbus", 0400, NULL);
++	if (!entry)
++		return -ENOMEM;
++
++	entry->owner = THIS_MODULE;
++	entry->proc_fops = &xenbus_dev_file_ops;
++
++	return 0;
++}
++
++void __exit xenbus_remove_proc_entry(void)
++{
++	remove_proc_entry("xen/xenbus", NULL);
++}
+diff --git a/drivers/xen/xenctrl/xenctrl.h b/drivers/xen/xenctrl/xenctrl.h
+index a35209a..e585c4b 100644
+--- a/drivers/xen/xenctrl/xenctrl.h
++++ b/drivers/xen/xenctrl/xenctrl.h
+@@ -43,3 +43,9 @@ void capabilities_remove_proc_entry(void) __exit;
+  */
+ int privcmd_create_proc_entry(void) __init;
+ void privcmd_remove_proc_entry(void) __exit;
++
++/*
++ * xenbus.c
++ */
++int xenbus_create_proc_entry(void) __init;
++void xenbus_remove_proc_entry(void) __exit;
+diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h
+index 6369d89..a3fef9d 100644
+--- a/include/xen/xenbus.h
++++ b/include/xen/xenbus.h
+@@ -232,4 +232,6 @@ const char *xenbus_strstate(enum xenbus_state state);
+ int xenbus_dev_is_online(struct xenbus_device *dev);
+ int xenbus_frontend_closed(struct xenbus_device *dev);
+ 
++extern int xen_store_evtchn;
++
+ #endif /* _XEN_XENBUS_H */
+-- 
+1.5.4.1
+

linux-2.6-xen-0015-xen-Add-Xen-s-sys-hypervisor-interface.patch:

Index: linux-2.6-xen-0015-xen-Add-Xen-s-sys-hypervisor-interface.patch
===================================================================
RCS file: linux-2.6-xen-0015-xen-Add-Xen-s-sys-hypervisor-interface.patch
diff -N linux-2.6-xen-0015-xen-Add-Xen-s-sys-hypervisor-interface.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0015-xen-Add-Xen-s-sys-hypervisor-interface.patch	14 Apr 2008 16:06:53 -0000	1.7
@@ -0,0 +1,479 @@
+From f31300dd7c0a3c18584056977526ce702713477c Mon Sep 17 00:00:00 2001
+From: Mark McLoughlin <markmc at redhat.com>
+Date: Thu, 7 Feb 2008 15:32:28 +0000
+Subject: [PATCH] xen: Add Xen's /sys/hypervisor interface
+
+Hook up Xen's /sys/hypervisor interface:
+
+  /sys/hypervisor/
+    -> type
+    -> uuid
+    -> compilation
+         -> compile_date
+         -> compiled_by
+         -> compiler
+    -> properties
+         -> capabilities
+         -> changeset
+         -> pagesize
+         -> virtual_start
+         -> writable_pt
+    -> version
+         -> extra
+         -> major
+         -> minor
+
+Note: the hypervisor subsys hook requires that
+SYS_HYPERVISOR is selected to enabled it, which in
+turns means that the subsys will be registered by
+a pv-ops kernel with Xen support, even on bare
+metal. This hook needs to be changed to be runtime
+enabled.
+
+Signed-off-by: Mark McLoughlin <markmc at redhat.com>
+---
+ arch/x86/xen/Kconfig            |    3 +-
+ drivers/xen/xenctrl/Makefile    |    1 +
+ drivers/xen/xenctrl/main.c      |    6 +
+ drivers/xen/xenctrl/sysfs.c     |  349 +++++++++++++++++++++++++++++++++++++++
+ drivers/xen/xenctrl/xenctrl.h   |    6 +
+ include/xen/interface/version.h |    6 +
+ 6 files changed, 370 insertions(+), 1 deletions(-)
+ create mode 100644 drivers/xen/xenctrl/sysfs.c
+
+diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
+index 4723bc1..ff6a56a 100644
+--- a/arch/x86/xen/Kconfig
++++ b/arch/x86/xen/Kconfig
+@@ -14,7 +14,8 @@ config XEN
+ 
+ config XENCTRL
+ 	tristate "Xen's user space control interfaces"
+-	depends on XEN && PROC_FS
++	depends on XEN && PROC_FS && SYSFS
+ 	default y if XEN
++	select SYS_HYPERVISOR
+ 	help
+ 	  This is the /proc/xen interface used by Xen's libxc.
+diff --git a/drivers/xen/xenctrl/Makefile b/drivers/xen/xenctrl/Makefile
+index 23dafa3..e126e76 100644
+--- a/drivers/xen/xenctrl/Makefile
++++ b/drivers/xen/xenctrl/Makefile
+@@ -5,3 +5,4 @@ xenctrl-objs += main.o
+ xenctrl-objs += capabilities.o
+ xenctrl-objs += privcmd.o
+ xenctrl-objs += xenbus.o
++xenctrl-objs += sysfs.o
+diff --git a/drivers/xen/xenctrl/main.c b/drivers/xen/xenctrl/main.c
+index b0cf61b..87d0dba 100644
+--- a/drivers/xen/xenctrl/main.c
++++ b/drivers/xen/xenctrl/main.c
+@@ -63,8 +63,13 @@ static int __init xenctrl_init(void)
+ 	if (ret)
+ 		goto fail3;
+ 
++	ret = sys_hypervisor_init();
++	if (ret)
++		goto fail4;
++
+ 	return 0;
+ 
++ fail4: xenbus_remove_proc_entry();
+  fail3: privcmd_remove_proc_entry();
+  fail2: capabilities_remove_proc_entry();
+  fail1:	remove_proc_entry("xen", NULL);
+@@ -73,6 +78,7 @@ static int __init xenctrl_init(void)
+ 
+ static void __exit xenctrl_exit(void)
+ {
++	sys_hypervisor_exit();
+ 	xenbus_remove_proc_entry();
+ 	privcmd_remove_proc_entry();
+ 	capabilities_remove_proc_entry();
+diff --git a/drivers/xen/xenctrl/sysfs.c b/drivers/xen/xenctrl/sysfs.c
+new file mode 100644
+index 0000000..8cbf4d6
+--- /dev/null
++++ b/drivers/xen/xenctrl/sysfs.c
+@@ -0,0 +1,349 @@
++/*
++ *  copyright (c) 2006 IBM Corporation
++ *  Authored by: Mike D. Day <ncmike at us.ibm.com>
++ *
++ *  This program is free software; you can redistribute it and/or modify
++ *  it under the terms of the GNU General Public License version 2 as
++ *  published by the Free Software Foundation.
++ */
++
++#include <linux/kobject.h>
++#include <linux/sysfs.h>
++#include <linux/err.h>
++#include <asm/xen/hypervisor.h>
++#include <xen/xenbus.h>
++#include "xenctrl.h"
++
++#define HYPERVISOR_ATTR_RO(_name) \
++static struct kobj_attribute _name##_attr = __ATTR_RO(_name)
++
++#define HYPERVISOR_ATTR_RW(_name) \
++static struct kobj_attribute _name##_attr = \
++	__ATTR(_name, 0644, _name##_show, _name##_store)
++
++static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	return sprintf(buffer, "xen\n");
++}
++
++HYPERVISOR_ATTR_RO(type);
++
++static int __init xen_sysfs_type_init(void)
++{
++	return sysfs_create_file(hypervisor_kobj, &type_attr.attr);
++}
++
++static void xen_sysfs_type_destroy(void)
++{
++	sysfs_remove_file(hypervisor_kobj, &type_attr.attr);
++}
++
++static ssize_t major_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	int version;
++
++	version = HYPERVISOR_xen_version(XENVER_version, NULL);
++	if (!version)
++		return -ENODEV;
++
++	return sprintf(buffer, "%d\n", version >> 16);
++}
++
++HYPERVISOR_ATTR_RO(major);
++
++static ssize_t minor_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	int version;
++
++	version = HYPERVISOR_xen_version(XENVER_version, NULL);
++	if (!version)
++		return -ENODEV;
++
++	return sprintf(buffer, "%d\n", version & 0xff);
++}
++
++HYPERVISOR_ATTR_RO(minor);
++
++static ssize_t extra_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	int ret;
++	struct xen_extraversion extra;
++
++	ret = HYPERVISOR_xen_version(XENVER_extraversion, &extra);
++	if (ret)
++		return ret;
++
++	return sprintf(buffer, "%s\n", extra.extraversion);
++}
++
++HYPERVISOR_ATTR_RO(extra);
++
++static struct attribute *version_attrs[] = {
++	&major_attr.attr,
++	&minor_attr.attr,
++	&extra_attr.attr,
++	NULL
++};
++
++static struct attribute_group version_group = {
++	.name = "version",
++	.attrs = version_attrs,
++};
++
++static int __init xen_sysfs_version_init(void)
++{
++	return sysfs_create_group(hypervisor_kobj, &version_group);
++}
++
++static void xen_sysfs_version_destroy(void)
++{
++	sysfs_remove_group(hypervisor_kobj, &version_group);
++}
++
++static ssize_t uuid_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	char *vm, *val;
++	int ret;
++
++	vm = xenbus_read(XBT_NIL, "vm", "", NULL);
++	if (IS_ERR(vm))
++		return PTR_ERR(vm);
++
++	val = xenbus_read(XBT_NIL, vm, "uuid", NULL);
++	if (IS_ERR(val)) {
++		ret = PTR_ERR(val);
++		goto out;
++	}
++
++	ret = sprintf(buffer, "%s\n", val);
++
++	kfree(val);
++out:	kfree(vm);
++
++	return ret;
++}
++
++HYPERVISOR_ATTR_RO(uuid);
++
++static int __init xen_sysfs_uuid_init(void)
++{
++	return sysfs_create_file(hypervisor_kobj, &uuid_attr.attr);
++}
++
++static void xen_sysfs_uuid_destroy(void)
++{
++	sysfs_remove_file(hypervisor_kobj, &uuid_attr.attr);
++}
++
++static ssize_t compiler_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	struct xen_compile_info info;
++	int ret;
++
++	ret = HYPERVISOR_xen_version(XENVER_compile_info, &info);
++	if (ret)
++		return ret;
++
++	return sprintf(buffer, "%s\n", info.compiler);
++}
++
++HYPERVISOR_ATTR_RO(compiler);
++
++static ssize_t compiled_by_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	struct xen_compile_info info;
++	int ret;
++
++	ret = HYPERVISOR_xen_version(XENVER_compile_info, &info);
++	if (ret)
++		return ret;
++
++	return sprintf(buffer, "%s\n", info.compile_by);
++}
++
++HYPERVISOR_ATTR_RO(compiled_by);
++
++static ssize_t compile_date_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	struct xen_compile_info info;
++	int ret;
++
++	ret = HYPERVISOR_xen_version(XENVER_compile_info, &info);
++	if (ret)
++		return ret;
++
++	return sprintf(buffer, "%s\n", info.compile_date);
++}
++
++HYPERVISOR_ATTR_RO(compile_date);
++
++static struct attribute *xen_compile_attrs[] = {
++	&compiler_attr.attr,
++	&compiled_by_attr.attr,
++	&compile_date_attr.attr,
++	NULL
++};
++
++static struct attribute_group xen_compilation_group = {
++	.name = "compilation",
++	.attrs = xen_compile_attrs,
++};
++
++static int __init xen_compilation_init(void)
++{
++	return sysfs_create_group(hypervisor_kobj,
++				  &xen_compilation_group);
++}
++
++static void xen_compilation_destroy(void)
++{
++	sysfs_remove_group(hypervisor_kobj,
++			   &xen_compilation_group);
++}
++
++static ssize_t capabilities_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	struct xen_capabilities_info *caps;
++	int ret;
++
++	caps = kmalloc(sizeof(struct xen_capabilities_info), GFP_KERNEL);
++	if (!caps)
++		return -ENOMEM;
++
++	ret = HYPERVISOR_xen_version(XENVER_capabilities, caps);
++	if (ret)
++		goto out;
++
++	ret = sprintf(buffer, "%s\n", caps->info);
++
++out:	kfree(caps);
++
++	return ret;
++}
++
++HYPERVISOR_ATTR_RO(capabilities);
++
++static ssize_t changeset_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	struct xen_changeset_info cset;
++	int ret;
++
++	ret = HYPERVISOR_xen_version(XENVER_changeset, &cset);
++	if (ret)
++		return ret;
++
++	return sprintf(buffer, "%s\n", cset.info);
++}
++
++HYPERVISOR_ATTR_RO(changeset);
++
++static ssize_t virtual_start_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	struct xen_platform_parameters parms;
++	int ret;
++
++	ret = HYPERVISOR_xen_version(XENVER_platform_parameters, &parms);
++	if (ret)
++		return ret;
++
++	return sprintf(buffer, "%lx\n", parms.virt_start);
++}
++
++HYPERVISOR_ATTR_RO(virtual_start);
++
++static ssize_t pagesize_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	int ret;
++
++	ret = HYPERVISOR_xen_version(XENVER_pagesize, NULL);
++	if (ret < 0)
++		return ret;
++
++	return sprintf(buffer, "%x\n", ret);
++}
++
++HYPERVISOR_ATTR_RO(pagesize);
++
++static ssize_t writable_pt_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
++{
++	struct xen_feature_info info;
++	int ret;
++
++	info.submap_idx = XENFEAT_writable_page_tables;
++
++	ret = HYPERVISOR_xen_version(XENVER_get_features, &info);
++	if (ret)
++		return ret;
++
++	return sprintf(buffer, "%d\n", info.submap);
++}
++
++HYPERVISOR_ATTR_RO(writable_pt);
++
++static struct attribute *xen_properties_attrs[] = {
++	&capabilities_attr.attr,
++	&changeset_attr.attr,
++	&virtual_start_attr.attr,
++	&pagesize_attr.attr,
++	&writable_pt_attr.attr,
++	NULL
++};
++
++static struct attribute_group xen_properties_group = {
++	.name = "properties",
++	.attrs = xen_properties_attrs,
++};
++
++static int __init xen_properties_init(void)
++{
++	return sysfs_create_group(hypervisor_kobj,
++				  &xen_properties_group);
++}
++
++static void xen_properties_destroy(void)
++{
++	sysfs_remove_group(hypervisor_kobj, &xen_properties_group);
++}
++
++int __init sys_hypervisor_init(void)
++{
++	int ret;
++
++	if (!is_running_on_xen())
++		return -ENODEV;
++
++	ret = xen_sysfs_type_init();
++	if (ret)
++		goto out;
++	ret = xen_sysfs_version_init();
++	if (ret)
++		goto version_out;
++	ret = xen_compilation_init();
++	if (ret)
++		goto comp_out;
++	ret = xen_sysfs_uuid_init();
++	if (ret)
++		goto uuid_out;
++	ret = xen_properties_init();
++	if (!ret)
++		goto out;
++
++	xen_sysfs_uuid_destroy();
++uuid_out:
++	xen_compilation_destroy();
++comp_out:
++	xen_sysfs_version_destroy();
++version_out:
++	xen_sysfs_type_destroy();
++out:
++	return ret;
++}
++
++void __exit sys_hypervisor_exit(void)
++{
++	xen_properties_destroy();
++	xen_compilation_destroy();
++	xen_sysfs_uuid_destroy();
++	xen_sysfs_version_destroy();
++	xen_sysfs_type_destroy();
++}
+diff --git a/drivers/xen/xenctrl/xenctrl.h b/drivers/xen/xenctrl/xenctrl.h
+index e585c4b..1afbdfb 100644
+--- a/drivers/xen/xenctrl/xenctrl.h
++++ b/drivers/xen/xenctrl/xenctrl.h
+@@ -49,3 +49,9 @@ void privcmd_remove_proc_entry(void) __exit;
+  */
+ int xenbus_create_proc_entry(void) __init;
+ void xenbus_remove_proc_entry(void) __exit;
++
++/*
++ * sysfs.c
++ */
++int sys_hypervisor_init(void) __init;
++void sys_hypervisor_exit(void) __exit;
+diff --git a/include/xen/interface/version.h b/include/xen/interface/version.h
+index 453235e..dd58cf5 100644
+--- a/include/xen/interface/version.h
++++ b/include/xen/interface/version.h
+@@ -57,4 +57,10 @@ struct xen_feature_info {
+ /* Declares the features reported by XENVER_get_features. */
+ #include "features.h"
+ 
++/* arg == NULL; returns host memory page size. */
++#define XENVER_pagesize 7
++
++/* arg == xen_domain_handle_t. */
++#define XENVER_guest_handle 8
++
+ #endif /* __XEN_PUBLIC_VERSION_H__ */
+-- 
+1.5.4.1
+

linux-2.6-xen-0016-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch:

Index: linux-2.6-xen-0016-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch
===================================================================
RCS file: linux-2.6-xen-0016-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch
diff -N linux-2.6-xen-0016-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0016-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch	14 Apr 2008 16:06:53 -0000	1.7
@@ -0,0 +1,79 @@
+From c314f2f1f8f1c4f8820b10e52ec3248b68735dcd Mon Sep 17 00:00:00 2001
+From: Stephen Tweedie <sct at redhat.com>
+Date: Wed, 21 Nov 2007 18:40:31 +0000
+Subject: [PATCH] xen debug: Add xprintk to log directly via hypercall
+
+For early debugging, it is useful to have a way of doing debugging output
+direct to the hypervisor without having to rely on console being fully
+initialised.
+
+Signed-off-by: Stephen Tweedie <sct at redhat.com>
+---
+ arch/x86/xen/enlighten.c  |   32 ++++++++++++++++++++++++++++++++
+ include/xen/hvc-console.h |    1 +
+ 2 files changed, 33 insertions(+), 0 deletions(-)
+
+diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
+index a5b111d..97a504d 100644
+--- a/arch/x86/xen/enlighten.c
++++ b/arch/x86/xen/enlighten.c
+@@ -33,6 +33,7 @@
+ #include <xen/interface/sched.h>
+ #include <xen/features.h>
+ #include <xen/page.h>
++#include <xen/hvc-console.h>
+ 
+ #include <asm/paravirt.h>
+ #include <asm/page.h>
+@@ -143,6 +144,37 @@ static void __init xen_banner(void)
+ 	printk(KERN_INFO "Hypervisor signature: %s\n", xen_start_info->magic);
+ }
+ 
++static void kcons_write_dom0(const char *s, unsigned int count)
++{
++       int rc;
++
++       while ((count > 0) &&
++              ((rc = HYPERVISOR_console_io(
++                       CONSOLEIO_write, count, (char *)s)) > 0)) {
++               count -= rc;
++               s += rc;
++       }
++}
++
++
++/*** Useful function for console debugging -- goes straight to Xen. ***/
++asmlinkage int xprintk(const char *fmt, ...)
++{
++       va_list args;
++       int printk_len;
++       static char printk_buf[1024];
++
++       /* Emit the output into the temporary buffer */
++       va_start(args, fmt);
++       printk_len = vsnprintf(printk_buf, sizeof(printk_buf), fmt, args);
++       va_end(args);
++
++       /* Send the processed output directly to Xen. */
++       kcons_write_dom0(printk_buf, printk_len);
++
++       return 0;
++}
++
+ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
+ 		      unsigned int *cx, unsigned int *dx)
+ {
+diff --git a/include/xen/hvc-console.h b/include/xen/hvc-console.h
+index 21c0ecf..cb7a3c9 100644
+--- a/include/xen/hvc-console.h
++++ b/include/xen/hvc-console.h
+@@ -2,5 +2,6 @@
+ #define XEN_HVC_CONSOLE_H
+ 
+ extern struct console xenboot_console;
++extern asmlinkage int xprintk(const char *fmt, ...);
+ 
+ #endif	/* XEN_HVC_CONSOLE_H */
+-- 
+1.5.4.1
+

linux-2.6-xen-0017-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch:

Index: linux-2.6-xen-0017-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch
===================================================================
RCS file: linux-2.6-xen-0017-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch
diff -N linux-2.6-xen-0017-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0017-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch	14 Apr 2008 16:06:53 -0000	1.8
@@ -0,0 +1,58 @@
+From f53ba1784684eaab473f0807d618bbc5500f73f0 Mon Sep 17 00:00:00 2001
+From: Mark McLoughlin <markmc at redhat.com>
+Date: Thu, 6 Mar 2008 11:10:59 +0000
+Subject: [PATCH] xen x86_64: Add 64 bit version of privcmd_hypercall()
+
+Signed-off-by: Mark McLoughlin <markmc at redhat.com>
+---
+ include/asm-x86/xen/hypercall.h |   28 ++++++++++++++++++++++++++++
+ 1 files changed, 28 insertions(+), 0 deletions(-)
+
+diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
+index cd554ca..b0c518c 100644
+--- a/include/asm-x86/xen/hypercall.h
++++ b/include/asm-x86/xen/hypercall.h
+@@ -412,6 +412,7 @@ MULTI_stack_switch(struct multicall_entry *mcl,
+ 
+ #include <xen/sys/privcmd.h>
+ 
++#ifdef CONFIG_X86_32
+ static inline int privcmd_hypercall(privcmd_hypercall_t *hypercall)
+ {
+ 	int ret;
+@@ -437,5 +438,32 @@ static inline int privcmd_hypercall(privcmd_hypercall_t *hypercall)
+ 
+ 	return ret;
+ }
++#else /* CONFIG_X86_32 */
++static inline int privcmd_hypercall(privcmd_hypercall_t *hypercall)
++{
++	int ret;
++        long ign1, ign2, ign3;
++
++	if (hypercall->op >= (PAGE_SIZE >> 5))
++		return -EINVAL;
++
++        __asm__ __volatile__ (
++		"movq %8,%%r10; movq %9,%%r8;"
++                "shll $5,%%eax ;"
++                "addq $hypercall_page,%%rax ;"
++                "call *%%rax"
++                : "=a" (ret), "=D" (ign1),
++                  "=S" (ign2), "=d" (ign3)
++                : "0" ((unsigned int)hypercall->op),
++                  "1" (hypercall->arg[0]),
++                  "2" (hypercall->arg[1]),
++                  "3" (hypercall->arg[2]),
++                  "g" (hypercall->arg[3]),
++                  "g" (hypercall->arg[4])
++                : "r8", "r10", "memory" );
++
++	return ret;
++}
++#endif /* CONFIG_X86_32 */
+ 
+ #endif /* __HYPERCALL_H__ */
+-- 
+1.5.4.1
+

linux-2.6-xen-0018-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch:

Index: linux-2.6-xen-0018-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch
===================================================================
RCS file: linux-2.6-xen-0018-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch
diff -N linux-2.6-xen-0018-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.6-xen-0018-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch	14 Apr 2008 16:06:53 -0000	1.5
@@ -0,0 +1,122 @@
+From c8a37db07e48c209193dbd07c8aa5e1a86f4a2ad Mon Sep 17 00:00:00 2001
+From: Mark McLoughlin <markmc at redhat.com>
+Date: Tue, 25 Mar 2008 11:56:43 +0000
+Subject: [PATCH] xen x86_64: Only define load_user_cs_desc() on 32 bit
+
+load_user_cs_desc() is only used on 32 bit, so only
+define it in that case.
+
+Fixes compile failure in native_load_user_cs_desc()
+since mm_context_t->user_cs is only available on
+32 bit.
+
+Signed-off-by: Mark McLoughlin <markmc at redhat.com>
+---
+ arch/x86/kernel/paravirt.c |    2 ++
+ arch/x86/xen/enlighten.c   |    4 ++++
+ include/asm-x86/desc.h     |    4 ++++
+ include/asm-x86/paravirt.h |    4 ++++
+ 4 files changed, 14 insertions(+), 0 deletions(-)
+
+diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
+index d59db07..c845947 100644
+--- a/arch/x86/kernel/paravirt.c
++++ b/arch/x86/kernel/paravirt.c
+@@ -331,7 +331,9 @@ struct pv_cpu_ops pv_cpu_ops = {
+ 	.read_tscp = native_read_tscp,
+ 	.load_tr_desc = native_load_tr_desc,
+ 	.set_ldt = native_set_ldt,
++#ifdef CONFIG_X86_32
+ 	.load_user_cs_desc = native_load_user_cs_desc,
++#endif
+ 	.load_gdt = native_load_gdt,
+ 	.load_idt = native_load_idt,
+ 	.store_gdt = native_store_gdt,
+diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
+index 97a504d..d815811 100644
+--- a/arch/x86/xen/enlighten.c
++++ b/arch/x86/xen/enlighten.c
+@@ -323,6 +323,7 @@ static void xen_set_ldt(const void *addr, unsigned entries)
+ 	xen_mc_issue(PARAVIRT_LAZY_CPU);
+ }
+ 
++#ifdef CONFIG_X86_32
+ static inline void xen_load_user_cs_desc(int cpu, struct mm_struct *mm)
+ {
+ 	void *gdt;
+@@ -338,6 +339,7 @@ static inline void xen_load_user_cs_desc(int cpu, struct mm_struct *mm)
+ 
+ 	HYPERVISOR_update_descriptor(mgdt.maddr, descriptor);
+ }
++#endif
+ 
+ static void xen_load_gdt(const struct desc_ptr *dtr)
+ {
+@@ -1047,7 +1049,9 @@ static const struct pv_cpu_ops xen_cpu_ops __initdata = {
+ 
+ 	.load_tr_desc = paravirt_nop,
+ 	.set_ldt = xen_set_ldt,
++#ifdef CONFIG_X86_32
+ 	.load_user_cs_desc = xen_load_user_cs_desc,
++#endif
+ 	.load_gdt = xen_load_gdt,
+ 	.load_idt = xen_load_idt,
+ 	.load_tls = xen_load_tls,
+diff --git a/include/asm-x86/desc.h b/include/asm-x86/desc.h
+index ec3a84a..9b280be 100644
+--- a/include/asm-x86/desc.h
++++ b/include/asm-x86/desc.h
+@@ -95,7 +95,9 @@ static inline int desc_empty(const void *ptr)
+ 
+ #define load_TLS(t, cpu) native_load_tls(t, cpu)
+ #define set_ldt native_set_ldt
++#ifdef CONFIG_X86_32
+ #define load_user_cs_desc native_load_user_cs_desc
++#endif
+ 
+ #define write_ldt_entry(dt, entry, desc) \
+ 				native_write_ldt_entry(dt, entry, desc)
+@@ -362,10 +364,12 @@ static inline void set_user_cs(struct desc_struct *desc, unsigned long limit)
+ 	desc->b = (limit & 0xf0000) | 0x00c0fb00;
+ }
+ 
++#ifdef CONFIG_X86_32
+ static inline void native_load_user_cs_desc(int cpu, struct mm_struct *mm)
+ {
+ 	get_cpu_gdt_table(cpu)[GDT_ENTRY_DEFAULT_USER_CS] = mm->context.user_cs;
+ }
++#endif
+ 
+ #ifdef CONFIG_X86_32
+ extern void arch_add_exec_range(struct mm_struct *mm, unsigned long limit);
+diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
+index ff8d218..7d7070a 100644
+--- a/include/asm-x86/paravirt.h
++++ b/include/asm-x86/paravirt.h
+@@ -113,7 +113,9 @@ struct pv_cpu_ops {
+ 	void (*store_gdt)(struct desc_ptr *);
+ 	void (*store_idt)(struct desc_ptr *);
+ 	void (*set_ldt)(const void *desc, unsigned entries);
++#ifdef CONFIG_X86_32
+ 	void (*load_user_cs_desc)(int cpu, struct mm_struct *mm);
++#endif
+ 	unsigned long (*store_tr)(void);
+ 	void (*load_tls)(struct thread_struct *t, unsigned int cpu);
+ 	void (*write_ldt_entry)(struct desc_struct *ldt, int entrynum,
+@@ -755,11 +757,13 @@ static inline void set_ldt(const void *addr, unsigned entries)
+ {
+ 	PVOP_VCALL2(pv_cpu_ops.set_ldt, addr, entries);
+ }
++#ifdef CONFIG_X86_32
+ static inline void load_user_cs_desc(unsigned int cpu, 
+ 				     struct mm_struct *mm)
+ {
+ 	PVOP_VCALL2(pv_cpu_ops.load_user_cs_desc, cpu, mm);
+ }
++#endif
+ static inline void store_gdt(struct desc_ptr *dtr)
+ {
+ 	PVOP_VCALL1(pv_cpu_ops.store_gdt, dtr);
+-- 
+1.5.4.1
+

linux-2.6-xen-0019-xen-expose-set_pte_vaddr-and-make-xen-use-it.patch:

--- NEW FILE linux-2.6-xen-0019-xen-expose-set_pte_vaddr-and-make-xen-use-it.patch ---
>From ad5aaff26dd68ab8b2b1a9020996eaff6fd22036 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Mon, 28 Jan 2008 15:38:03 +0000
Subject: [PATCH] xen: expose set_pte_vaddr() and make xen use it

Re-name set_pte_pfn() to set_pte_vaddr(), taking a pte_t
rather than pfn/flags, and expose it.

Make xen's set_pte_mfn() use this rather than copying it.

Signed-off-by: Jeremy Fitzhardinge <jeremy at xensource.com>
Signed-off-by: Juan Quintela <quintela at redhat.com>
Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/mm/pgtable_32.c     |    8 ++++----
 arch/x86/xen/mmu.c           |   30 +-----------------------------
 include/asm-x86/pgtable_32.h |    3 +++
 3 files changed, 8 insertions(+), 33 deletions(-)

diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
index 2f9e9af..fca936b 100644
--- a/arch/x86/mm/pgtable_32.c
+++ b/arch/x86/mm/pgtable_32.c
@@ -76,7 +76,7 @@ void show_mem(void)
  * Associate a virtual page frame with a given physical page frame 
  * and protection flags for that frame.
  */ 
-static void set_pte_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
+void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
 {
 	pgd_t *pgd;
 	pud_t *pud;
@@ -99,8 +99,8 @@ static void set_pte_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
 		return;
 	}
 	pte = pte_offset_kernel(pmd, vaddr);
-	if (pgprot_val(flags))
-		set_pte_present(&init_mm, vaddr, pte, pfn_pte(pfn, flags));
+	if (pte_val(pteval))
+		set_pte_present(&init_mm, vaddr, pte, pteval);
 	else
 		pte_clear(&init_mm, vaddr, pte);
 
@@ -158,7 +158,7 @@ void __set_fixmap (enum fixed_addresses idx, unsigned long phys, pgprot_t flags)
 		BUG();
 		return;
 	}
-	set_pte_pfn(address, phys >> PAGE_SHIFT, flags);
+	set_pte_vaddr(address, pfn_pte(phys >> PAGE_SHIFT, flags));
 	fixmaps++;
 }
 
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 2a054ef..8660786 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -122,35 +122,7 @@ void xen_set_pmd(pmd_t *ptr, pmd_t val)
  */
 void set_pte_mfn(unsigned long vaddr, unsigned long mfn, pgprot_t flags)
 {
-	pgd_t *pgd;
-	pud_t *pud;
-	pmd_t *pmd;
-	pte_t *pte;
-
-	pgd = swapper_pg_dir + pgd_index(vaddr);
-	if (pgd_none(*pgd)) {
-		BUG();
-		return;
-	}
-	pud = pud_offset(pgd, vaddr);
-	if (pud_none(*pud)) {
-		BUG();
-		return;
-	}
-	pmd = pmd_offset(pud, vaddr);
-	if (pmd_none(*pmd)) {
-		BUG();
-		return;
-	}
-	pte = pte_offset_kernel(pmd, vaddr);
-	/* <mfn,flags> stored as-is, to permit clearing entries */
-	xen_set_pte(pte, mfn_pte(mfn, flags));
-
-	/*
-	 * It's enough to flush this one mapping.
-	 * (PGE mappings get flushed as well)
-	 */
-	__flush_tlb_one(vaddr);
+	set_pte_vaddr(vaddr, mfn_pte(mfn, flags));
 }
 
 void xen_set_pte_at(struct mm_struct *mm, unsigned long addr,
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h
index 4e6a0fc..0c9fddb 100644
--- a/include/asm-x86/pgtable_32.h
+++ b/include/asm-x86/pgtable_32.h
@@ -209,6 +209,9 @@ do {									\
 void native_pagetable_setup_start(pgd_t *base);
 void native_pagetable_setup_done(pgd_t *base);
 
+/* Install a pte for a particular vaddr in kernel space. */
+void set_pte_vaddr(unsigned long vaddr, pte_t pte);
+
 #ifndef CONFIG_PARAVIRT
 static inline void paravirt_pagetable_setup_start(pgd_t *base)
 {
-- 
1.5.4.1


linux-2.6-xen-0020-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch:

--- NEW FILE linux-2.6-xen-0020-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch ---
>From ac064d6ac76b040bdf5ae7d1c2f04b8b9b1a58f6 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Mon, 28 Jan 2008 15:42:08 +0000
Subject: [PATCH] xen dom0: Add set_fixmap pv_mmu_ops.

Adds the logic necessary to map by mfn rather than pfn when we set up
fixmaps to point to IO space.

Signed-off-by: Jeremy Fitzhardinge <jeremy at xensource.com>
Signed-off-by: Juan Quintela <quintela at redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/kernel/paravirt.c  |    2 ++
 arch/x86/mm/pgtable_32.c    |    9 +++++++--
 arch/x86/xen/enlighten.c    |   28 ++++++++++++++++++++++++++++
 include/asm-x86/fixmap_32.h |   13 +++++++++++--
 include/asm-x86/paravirt.h  |   13 +++++++++++++
 5 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index c845947..47f42bf 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -433,6 +433,8 @@ struct pv_mmu_ops pv_mmu_ops = {
 		.enter = paravirt_nop,
 		.leave = paravirt_nop,
 	},
+
+	.set_fixmap = native_set_fixmap,
 };
 
 EXPORT_SYMBOL_GPL(pv_time_ops);
diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
index fca936b..c1c7c36 100644
--- a/arch/x86/mm/pgtable_32.c
+++ b/arch/x86/mm/pgtable_32.c
@@ -150,7 +150,7 @@ static int fixmaps;
 unsigned long __FIXADDR_TOP = 0xfffff000;
 EXPORT_SYMBOL(__FIXADDR_TOP);
 
-void __set_fixmap (enum fixed_addresses idx, unsigned long phys, pgprot_t flags)
+void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
 {
 	unsigned long address = __fix_to_virt(idx);
 
@@ -158,10 +158,15 @@ void __set_fixmap (enum fixed_addresses idx, unsigned long phys, pgprot_t flags)
 		BUG();
 		return;
 	}
-	set_pte_vaddr(address, pfn_pte(phys >> PAGE_SHIFT, flags));
+	set_pte_vaddr(address, pte);
 	fixmaps++;
 }
 
+void native_set_fixmap(enum fixed_addresses idx, unsigned long phys, pgprot_t flags)
+{
+	__native_set_fixmap(idx, pfn_pte(phys >> PAGE_SHIFT, flags));
+}
+
 /**
  * reserve_top_address - reserves a hole in the top of kernel address space
  * @reserve - size of hole to reserve
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index d815811..4c5453d 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -997,6 +997,32 @@ static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf,
 	return ret;
 }
 
+static void xen_set_fixmap(unsigned idx, unsigned long phys, pgprot_t prot)
+{
+	pte_t pte;
+
+	phys >>= PAGE_SHIFT;
+
+	switch (idx) {
+#ifdef CONFIG_X86_F00F_BUG
+	case FIX_F00F_IDT:
+#endif
+	case FIX_WP_TEST:
+	case FIX_VDSO:
+#ifdef CONFIG_X86_LOCAL_APIC
+	case FIX_APIC_BASE:	/* maps dummy local APIC */
+#endif
+		pte = pfn_pte(phys, prot);
+		break;
+
+	default:
+		pte = mfn_pte(phys, prot);
+		break;
+	}
+
+	__native_set_fixmap(idx, pte);
+}
+
 static const struct pv_info xen_info __initdata = {
 	.paravirt_enabled = 1,
 	.shared_kernel_pmd = 0,
@@ -1152,6 +1178,8 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = {
 		.enter = paravirt_enter_lazy_mmu,
 		.leave = xen_leave_lazy,
 	},
+
+	.set_fixmap = xen_set_fixmap,
 };
 
 #ifdef CONFIG_SMP
diff --git a/include/asm-x86/fixmap_32.h b/include/asm-x86/fixmap_32.h
index a7404d5..c2e450a 100644
--- a/include/asm-x86/fixmap_32.h
+++ b/include/asm-x86/fixmap_32.h
@@ -110,8 +110,17 @@ enum fixed_addresses {
 	__end_of_fixed_addresses
 };
 
-extern void __set_fixmap (enum fixed_addresses idx,
-					unsigned long phys, pgprot_t flags);
+void __native_set_fixmap(enum fixed_addresses idx, pte_t pte);
+void native_set_fixmap(enum fixed_addresses idx,
+		       unsigned long phys, pgprot_t flags);
+
+#ifndef CONFIG_PARAVIRT
+static inline void __set_fixmap(enum fixed_addresses idx,
+				unsigned long phys, pgprot_t flags)
+{
+	native_set_fixmap(idx, phys, flags);
+}
+#endif
 extern void reserve_top_address(unsigned long reserve);
 
 #define set_fixmap(idx, phys) \
diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
index 7d7070a..c7c4e34 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -272,6 +272,13 @@ struct pv_mmu_ops {
 #endif
 
 	struct pv_lazy_ops lazy_mode;
+
+	/* dom0 ops */
+
+	/* Sometimes the physical address is a pfn, and sometimes its
+	   an mfn.  We can tell which is which from the index. */
+	void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
+			   unsigned long phys, pgprot_t flags);
 };
 
 /* This contains all the paravirt structures: we get a convenient
@@ -1235,6 +1242,12 @@ static inline void arch_flush_lazy_mmu_mode(void)
 	}
 }
 
+static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
+				unsigned long phys, pgprot_t flags)
+{
+	pv_mmu_ops.set_fixmap(idx, phys, flags);
+}
+
 void _paravirt_nop(void);
 #define paravirt_nop	((void *)_paravirt_nop)
 
-- 
1.5.4.1


linux-2.6-xen-0021-x86_64-Expose-set_pte_vaddr.patch:

--- NEW FILE linux-2.6-xen-0021-x86_64-Expose-set_pte_vaddr.patch ---
>From 58aaa774e4684ba2fe9f607ef9cf7a169afc0e74 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 3 Mar 2008 15:03:42 -0300
Subject: [PATCH] x86_64: Expose set_pte_vaddr()

Re-name set_pte_pfn() to set_pte_vaddr(), taking a pte_t
rather than pfn/flags, and expose it.

This brings 32-bit closer to 64-bit.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/mm/init_64.c        |   13 ++++++-------
 include/asm-x86/pgtable_64.h |    4 ++++
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 954a6d6..00628b5 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -121,15 +121,15 @@ static __init void *spp_getpage(void)
 	return ptr;
 }
 
-static __init void
-set_pte_phys(unsigned long vaddr, unsigned long phys, pgprot_t prot)
+void
+set_pte_vaddr(unsigned long vaddr, pte_t pteval)
 {
 	pgd_t *pgd;
 	pud_t *pud;
 	pmd_t *pmd;
-	pte_t *pte, new_pte;
+	pte_t *pte;
 
-	pr_debug("set_pte_phys %lx to %lx\n", vaddr, phys);
+	pr_debug("set_pte_phys %lx to %lx\n", vaddr, native_pte_val(pteval));
 
 	pgd = pgd_offset_k(vaddr);
 	if (pgd_none(*pgd)) {
@@ -156,13 +156,12 @@ set_pte_phys(unsigned long vaddr, unsigned long phys, pgprot_t prot)
 			return;
 		}
 	}
-	new_pte = pfn_pte(phys >> PAGE_SHIFT, prot);
 
 	pte = pte_offset_kernel(pmd, vaddr);
 	if (!pte_none(*pte) &&
-	    pte_val(*pte) != (pte_val(new_pte) & __supported_pte_mask))
+	    pte_val(*pte) != (pte_val(pteval) & __supported_pte_mask))
 		pte_ERROR(*pte);
-	set_pte(pte, new_pte);
+	set_pte(pte, pteval);
 
 	/*
 	 * It's enough to flush this one mapping.
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
index 0a0b77b..c9352fe 100644
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -267,6 +267,10 @@ extern void cleanup_highmap(void);
    (((o) & (1UL << (__VIRTUAL_MASK_SHIFT-1))) ? ((o) | (~__VIRTUAL_MASK)) : (o))
 
 #define __HAVE_ARCH_PTE_SAME
+
+/* Install a pte for a particular vaddr in kernel space. */
+void set_pte_vaddr(unsigned long vaddr, pte_t pte);
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* _X86_64_PGTABLE_H */
-- 
1.5.4.1


linux-2.6-xen-0022-x86_64-Split-set_pte_vaddr.patch:

--- NEW FILE linux-2.6-xen-0022-x86_64-Split-set_pte_vaddr.patch ---
>From e04f2cf21632db6012297e15b557ae9c421d04c4 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 8 Feb 2008 12:41:04 -0200
Subject: [PATCH] x86_64: Split set_pte_vaddr()

We will need to set a pte on l3_user_pgt. Extract set_pte_vaddr_pud()
from set_pte_vaddr(), that will accept the l3 page table as
parameter.

This change should be a no-op for existing code.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/mm/init_64.c |   33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 00628b5..65d2a75 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -121,23 +121,14 @@ static __init void *spp_getpage(void)
 	return ptr;
 }
 
-void
-set_pte_vaddr(unsigned long vaddr, pte_t pteval)
+static void
+set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t pteval)
 {
-	pgd_t *pgd;
 	pud_t *pud;
 	pmd_t *pmd;
 	pte_t *pte;
 
-	pr_debug("set_pte_phys %lx to %lx\n", vaddr, native_pte_val(pteval));
-
-	pgd = pgd_offset_k(vaddr);
-	if (pgd_none(*pgd)) {
-		printk(KERN_ERR
-			"PGD FIXMAP MISSING, it should be setup in head.S!\n");
-		return;
-	}
-	pud = pud_offset(pgd, vaddr);
+	pud = pud_page + pud_index(vaddr);
 	if (pud_none(*pud)) {
 		pmd = (pmd_t *) spp_getpage();
 		set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE | _PAGE_USER));
@@ -170,6 +161,24 @@ set_pte_vaddr(unsigned long vaddr, pte_t pteval)
 	__flush_tlb_one(vaddr);
 }
 
+void
+set_pte_vaddr(unsigned long vaddr, pte_t pteval)
+{
+	pgd_t *pgd;
+	pud_t *pud_page;
+
+	pr_debug("set_pte_vaddr %lx to %lx\n", vaddr, native_pte_val(pteval));
+
+	pgd = pgd_offset_k(vaddr);
+	if (pgd_none(*pgd)) {
+		printk(KERN_ERR
+			"PGD FIXMAP MISSING, it should be setup in head.S!\n");
+		return;
+	}
+	pud_page = (pud_t*)pgd_page_vaddr(*pgd);
+	set_pte_vaddr_pud(pud_page, vaddr, pteval);
+}
+
 /*
  * The head.S code sets up the kernel high mapping:
  *
-- 
1.5.4.1


linux-2.6-xen-0023-x86_64-Add-clear_fixmap.patch:

--- NEW FILE linux-2.6-xen-0023-x86_64-Add-clear_fixmap.patch ---
>From 723cc272c2333dd52c964bdb749b81981361f5cf Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 3 Mar 2008 16:31:57 -0300
Subject: [PATCH] x86_64: Add clear_fixmap()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 include/asm-x86/fixmap_64.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/fixmap_64.h b/include/asm-x86/fixmap_64.h
index 70ddb21..e205dc0 100644
--- a/include/asm-x86/fixmap_64.h
+++ b/include/asm-x86/fixmap_64.h
@@ -61,6 +61,9 @@ extern void __set_fixmap (enum fixed_addresses idx,
 #define set_fixmap_nocache(idx, phys) \
 		__set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
 
+#define clear_fixmap(idx) \
+		__set_fixmap(idx, 0, __pgprot(0))
+
 #define FIXADDR_TOP	(VSYSCALL_END-PAGE_SIZE)
 #define FIXADDR_SIZE	(__end_of_fixed_addresses << PAGE_SHIFT)
 #define FIXADDR_START	(FIXADDR_TOP - FIXADDR_SIZE)
-- 
1.5.4.1


linux-2.6-xen-0024-xen-x86_64-Make-set_fixmap-a-paravirt-op-on-64-bi.patch:

--- NEW FILE linux-2.6-xen-0024-xen-x86_64-Make-set_fixmap-a-paravirt-op-on-64-bi.patch ---
>From c084cbd1425bdf4579c49bf8d12cf61a0f5cc1ad Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 3 Mar 2008 14:36:59 -0300
Subject: [PATCH] xen x86_64: Make set_fixmap() a paravirt op on 64-bit

Make set_fixmap() a paravirt op on 64-bit.

This should be unified with 32-bit later.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c       |   10 ++++++++--
 include/asm-x86/fixmap_64.h |   13 +++++++++++--
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 65d2a75..0a0307a 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -209,7 +209,7 @@ void __init cleanup_highmap(void)
 
 /* NOTE: this is meant to be run only at boot */
 void __init
-__set_fixmap(enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
+__native_set_fixmap(enum fixed_addresses idx, pte_t pte)
 {
 	unsigned long address = __fix_to_virt(idx);
 
@@ -217,7 +217,13 @@ __set_fixmap(enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
 		printk(KERN_ERR "Invalid __set_fixmap\n");
 		return;
 	}
-	set_pte_phys(address, phys, prot);
+	set_pte_vaddr(address, pte);
+}
+
+void __init
+native_set_fixmap(enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
+{
+	__native_set_fixmap(idx, pfn_pte(phys >> PAGE_SHIFT, prot));
 }
 
 static unsigned long __initdata table_start;
diff --git a/include/asm-x86/fixmap_64.h b/include/asm-x86/fixmap_64.h
index e205dc0..45beeb1 100644
--- a/include/asm-x86/fixmap_64.h
+++ b/include/asm-x86/fixmap_64.h
@@ -50,8 +50,17 @@ enum fixed_addresses {
 	__end_of_fixed_addresses
 };
 
-extern void __set_fixmap (enum fixed_addresses idx,
-					unsigned long phys, pgprot_t flags);
+void __native_set_fixmap(enum fixed_addresses idx, pte_t pte);
+void native_set_fixmap(enum fixed_addresses idx,
+		       unsigned long phys, pgprot_t flags);
+
+#ifndef CONFIG_PARAVIRT
+static inline void __set_fixmap(enum fixed_addresses idx,
+				unsigned long phys, pgprot_t flags)
+{
+	native_set_fixmap(idx, phys, flags);
+}
+#endif
 
 #define set_fixmap(idx, phys) \
 		__set_fixmap(idx, phys, PAGE_KERNEL)
-- 
1.5.4.1


linux-2.6-xen-0025-xen-x86_64-Hack-to-set-vsyscall-pages-on-user-space.patch:

--- NEW FILE linux-2.6-xen-0025-xen-x86_64-Hack-to-set-vsyscall-pages-on-user-space.patch ---
>From b2ba32ad1b7e2e4d5c3590d16dc5300df2687996 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 8 Feb 2008 12:48:51 -0200
Subject: [PATCH] xen x86_64: Hack to set vsyscall pages on user-space pagetables also (FIXME)

This should be done using pvops.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 0a0307a..b5f1f6e 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -218,6 +218,12 @@ __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
 		return;
 	}
 	set_pte_vaddr(address, pte);
+
+#ifdef CONFIG_XEN
+	/*FIXME: move this to xen_set_pte() */
+	if (idx == VSYSCALL_FIRST_PAGE)
+		set_pte_vaddr_pud(level3_user_pgt, address, pte);
+#endif
 }
 
 void __init
-- 
1.5.4.1


linux-2.6-xen-0026-Handle-VSYSCALL_FIRST_PAGE-on-xen_set_pte.patch:

--- NEW FILE linux-2.6-xen-0026-Handle-VSYSCALL_FIRST_PAGE-on-xen_set_pte.patch ---
>From 0d543cf092be05521e8a9153e9b73131606f483c Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 7 Mar 2008 18:53:28 -0300
Subject: [PATCH] Handle VSYSCALL_FIRST_PAGE on xen_set_pte()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 4c5453d..504bd13 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1012,6 +1012,9 @@ static void xen_set_fixmap(unsigned idx, unsigned long phys, pgprot_t prot)
 #ifdef CONFIG_X86_LOCAL_APIC
 	case FIX_APIC_BASE:	/* maps dummy local APIC */
 #endif
+#ifdef CONFIG_X86_64
+	case VSYSCALL_FIRST_PAGE:
+#endif
 		pte = pfn_pte(phys, prot);
 		break;
 
-- 
1.5.4.1


linux-2.6-xen-0027-DMI-Define-dmi_scan_machine-as-no-op-if-CONFIG_DM.patch:

--- NEW FILE linux-2.6-xen-0027-DMI-Define-dmi_scan_machine-as-no-op-if-CONFIG_DM.patch ---
>From 853696b8feb7ff1ae90961647ab1b985547e455e Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at monstro.(none)>
Date: Thu, 28 Feb 2008 12:16:04 -0300
Subject: [PATCH] DMI: Define dmi_scan_machine() as no-op if CONFIG_DMI is not set

This allows arch/x86 to build if CONFIG_DMI can be disabled in the
future.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 include/linux/dmi.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index 325acdf..96a9f0f 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -86,6 +86,7 @@ extern int dmi_walk(void (*decode)(const struct dmi_header *));
 
 #else
 
+static inline void dmi_scan_machine(void) { }
 static inline int dmi_check_system(const struct dmi_system_id *list) { return 0; }
 static inline const char * dmi_get_system_info(int field) { return NULL; }
 static inline const struct dmi_device * dmi_find_device(int type, const char *name,
-- 
1.5.4.1


linux-2.6-xen-0028-ACPI-thermal-Compile-without-CONFIG_DMI.patch:

--- NEW FILE linux-2.6-xen-0028-ACPI-thermal-Compile-without-CONFIG_DMI.patch ---
>From 4338604f501df3106684428706851de3ca7bbe7e Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 4 Mar 2008 16:59:48 -0300
Subject: [PATCH] ACPI: thermal: Compile without CONFIG_DMI

Add a macro for thermal_dmi_table to allow the driver to build if
CONFIG_DMI is not set.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 drivers/acpi/thermal.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 1bcecc7..f044a66 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -1785,6 +1785,11 @@ static struct dmi_system_id thermal_dmi_table[] __initdata = {
 	},
 	{}
 };
+#else
+
+/* Just that the dmi_check_system() call below compiles */
+#define thermal_dmi_table NULL
+
 #endif /* CONFIG_DMI */
 
 static int __init acpi_thermal_init(void)
-- 
1.5.4.1


linux-2.6-xen-0029-xen-x86_64-Remove-the-640K-1M-hole-and-disable-DMI.patch:

--- NEW FILE linux-2.6-xen-0029-xen-x86_64-Remove-the-640K-1M-hole-and-disable-DMI.patch ---
>From f5623fec9c2d0e0bf7963d8826ed0d4e8d5aa6c4 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 5 Mar 2008 11:48:34 -0300
Subject: [PATCH] xen x86_64: Remove the 640K-1M hole and disable DMI (TEMPORARY)

On 64-bit, we don't have the LOWMEM and HIGHMEM macros. As I think
using the LOWMEM and HIGHMEM macros on 64-bit would be ugly, I am
disabling the hole temporarily, until I understand the DMI problem
properly.

Instead, for now, just disable CONFIG_DMI under CONFIG_XEN.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/Kconfig     |    2 +-
 arch/x86/xen/setup.c |    4 ++++
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 6c70fed..3daae55 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -89,7 +89,7 @@ config ARCH_MAY_HAVE_PC_FDC
 	def_bool y
 
 config DMI
-	def_bool y
+	def_bool !XEN
 
 config RWSEM_GENERIC_SPINLOCK
 	def_bool !X86_XADD
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 2341492..d42586d 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -38,8 +38,12 @@ char * __init xen_memory_setup(void)
 	unsigned long max_pfn = xen_start_info->nr_pages;
 
 	e820.nr_map = 0;
+#ifdef CONFIG_X86_32
 	add_memory_region(0, LOWMEMSIZE(), E820_RAM);
 	add_memory_region(HIGH_MEMORY, PFN_PHYS(max_pfn)-HIGH_MEMORY, E820_RAM);
+#else
+	add_memory_region(0, PFN_PHYS(max_pfn), E820_RAM);
+#endif
 
 	return "Xen";
 }
-- 
1.5.4.1


linux-2.6-xen-0030-xen-x86_64-Add-update_va_mapping-64-bit-code.patch:

--- NEW FILE linux-2.6-xen-0030-xen-x86_64-Add-update_va_mapping-64-bit-code.patch ---
>From eec55b0b4eb1565dac4f59ce79b91f74ba92fec9 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
Date: Tue, 27 Nov 2007 14:50:24 -0200
Subject: [PATCH] xen x86_64: Add update_va_mapping 64-bit code

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/xen/hypercall.h  |   44 ++++++++++++++++++++++++++++++-------
 include/asm-x86/xen/hypervisor.h |    3 --
 2 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
index b0c518c..1242e5b 100644
--- a/include/asm-x86/xen/hypercall.h
+++ b/include/asm-x86/xen/hypercall.h
@@ -120,6 +120,15 @@ extern struct { char _entry[32]; } hypercall_page[];
 	(type)__res;							\
 })
 
+#if defined(CONFIG_X86_64)
+#define MULTI_UVMFLAGS_INDEX 2
+#define MULTI_UVMDOMID_INDEX 3
+#else
+#define MULTI_UVMFLAGS_INDEX 3
+#define MULTI_UVMDOMID_INDEX 4
+#endif
+
+
 static inline int
 HYPERVISOR_set_trap_table(struct trap_info *table)
 {
@@ -217,12 +226,17 @@ static inline int
 HYPERVISOR_update_va_mapping(unsigned long va, pte_t new_val,
 			     unsigned long flags)
 {
+#ifdef CONFIG_X86_64
+	return _hypercall3(int, update_va_mapping, va,
+			   new_val.pte, flags);
+#else
 	unsigned long pte_hi = 0;
 #ifdef CONFIG_X86_PAE
 	pte_hi = new_val.pte_high;
 #endif
 	return _hypercall4(int, update_va_mapping, va,
 			   new_val.pte_low, pte_hi, flags);
+#endif
 }
 
 static inline int
@@ -275,12 +289,17 @@ static inline int
 HYPERVISOR_update_va_mapping_otherdomain(unsigned long va, pte_t new_val,
 					 unsigned long flags, domid_t domid)
 {
+#ifdef CONFIG_X86_64
+	return _hypercall4(int, update_va_mapping_otherdomain, va,
+			   new_val.pte, flags, domid);
+#else
 	unsigned long pte_hi = 0;
 #ifdef CONFIG_X86_PAE
 	pte_hi = new_val.pte_high;
 #endif
 	return _hypercall5(int, update_va_mapping_otherdomain, va,
 			   new_val.pte_low, pte_hi, flags, domid);
+#endif
 }
 
 static inline int
@@ -314,14 +333,18 @@ MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va,
 {
 	mcl->op = __HYPERVISOR_update_va_mapping;
 	mcl->args[0] = va;
-#ifdef CONFIG_X86_PAE
-	mcl->args[1] = new_val.pte_low;
-	mcl->args[2] = new_val.pte_high;
+
+#ifdef CONFIG_X86_64
+	mcl->args[1] = new_val.pte;
 #else
 	mcl->args[1] = new_val.pte_low;
+#  ifdef CONFIG_X86_PAE
+	mcl->args[2] = new_val.pte_high;
+#  else
 	mcl->args[2] = 0;
+#  endif
 #endif
-	mcl->args[3] = flags;
+	mcl->args[MULTI_UVMFLAGS_INDEX] = flags;
 }
 
 static inline void
@@ -341,15 +364,18 @@ MULTI_update_va_mapping_otherdomain(struct multicall_entry *mcl, unsigned long v
 {
 	mcl->op = __HYPERVISOR_update_va_mapping_otherdomain;
 	mcl->args[0] = va;
-#ifdef CONFIG_X86_PAE
-	mcl->args[1] = new_val.pte_low;
-	mcl->args[2] = new_val.pte_high;
+#ifdef CONFIG_X86_64
+	mcl->args[1] = new_val.pte;
 #else
 	mcl->args[1] = new_val.pte_low;
+#  ifdef CONFIG_X86_PAE
+	mcl->args[2] = new_val.pte_high;
+#  else
 	mcl->args[2] = 0;
+#  endif
 #endif
-	mcl->args[3] = flags;
-	mcl->args[4] = domid;
+	mcl->args[MULTI_UVMFLAGS_INDEX] = flags;
+	mcl->args[MULTI_UVMDOMID_INDEX] = domid;
 }
 
 static inline void
diff --git a/include/asm-x86/xen/hypervisor.h b/include/asm-x86/xen/hypervisor.h
index 8e15dd2..49a5e24 100644
--- a/include/asm-x86/xen/hypervisor.h
+++ b/include/asm-x86/xen/hypervisor.h
@@ -65,9 +65,6 @@ extern void force_evtchn_callback(void);
 u64 jiffies_to_st(unsigned long jiffies);
 
 
-#define MULTI_UVMFLAGS_INDEX 3
-#define MULTI_UVMDOMID_INDEX 4
-
 #define is_running_on_xen()	(xen_start_info ? 1 : 0)
 
 #endif /* __HYPERVISOR_H__ */
-- 
1.5.4.1


linux-2.6-xen-0031-x86_64-Add-sync_cmpxchg.patch:

--- NEW FILE linux-2.6-xen-0031-x86_64-Add-sync_cmpxchg.patch ---
>From 828a4a3259e30f1f9b7d26ae0b9ebae4587e1d94 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
Date: Tue, 27 Nov 2007 18:08:41 -0200
Subject: [PATCH] x86_64: Add sync_cmpxchg()

Add a sync_cmpxchg() for x86_64, including a sync_cmpxchg64()
implementation.

Needed for Xen's grant table implementation.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 include/asm-x86/cmpxchg_64.h |   47 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/cmpxchg_64.h b/include/asm-x86/cmpxchg_64.h
index 56f5b41..1556f64 100644
--- a/include/asm-x86/cmpxchg_64.h
+++ b/include/asm-x86/cmpxchg_64.h
@@ -91,6 +91,45 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
 	return old;
 }
 
+/*
+ * Always use locked operations when touching memory shared with a
+ * hypervisor, since the system may be SMP even if the guest kernel
+ * isn't.
+ */
+static inline unsigned long __sync_cmpxchg(volatile void *ptr,
+					    unsigned long old,
+					    unsigned long new, int size)
+{
+	unsigned long prev;
+	switch (size) {
+	case 1:
+		__asm__ __volatile__("lock; cmpxchgb %b1,%2"
+				     : "=a"(prev)
+				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
+				     : "memory");
+		return prev;
+	case 2:
+		__asm__ __volatile__("lock; cmpxchgw %w1,%2"
+				     : "=a"(prev)
+				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
+				     : "memory");
+		return prev;
+	case 4:
+		__asm__ __volatile__("lock; cmpxchgl %k1,%2"
+				     : "=a"(prev)
+				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
+				     : "memory");
+		return prev;
+	case 8:
+		__asm__ __volatile__("lock; cmpxchgq %1,%2"
+				     : "=a"(prev)
+				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
+				     : "memory");
+		return prev;
+	}
+	return old;
+}
+
 static inline unsigned long __cmpxchg_local(volatile void *ptr,
 			unsigned long old, unsigned long new, int size)
 {
@@ -132,6 +171,14 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
 	BUILD_BUG_ON(sizeof(*(ptr)) != 8);				\
 	cmpxchg((ptr), (o), (n));					\
   })
+#define sync_cmpxchg(ptr, o, n)						\
+	((__typeof__(*(ptr)))__sync_cmpxchg((ptr), (unsigned long)(o),	\
+					(unsigned long)(n), sizeof(*(ptr))))
+#define sync_cmpxchg64(ptr, o, n)					\
+  ({									\
+	BUILD_BUG_ON(sizeof(*(ptr)) != 8);				\
+	sync_cmpxchg((ptr), (o), (n));					\
+  })
 #define cmpxchg_local(ptr, o, n)					\
 	((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o),	\
 					(unsigned long)(n), sizeof(*(ptr))))
-- 
1.5.4.1


linux-2.6-xen-0032-xen-x86_64-Implement-HYPERVISOR-MULTI-_update_desc.patch:

--- NEW FILE linux-2.6-xen-0032-xen-x86_64-Implement-HYPERVISOR-MULTI-_update_desc.patch ---
>From c07dfe4328d1b9de44ecfc37151c3c6ecf15606d Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
Date: Tue, 27 Nov 2007 18:09:08 -0200
Subject: [PATCH] xen x86_64: Implement {HYPERVISOR,MULTI}_update_descriptor()

Add 64-bit versions of HYPERVISOR_update_descriptor() and
MULTI_update_descriptor().

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 include/asm-x86/xen/hypercall.h |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
index 1242e5b..cbf3d52 100644
--- a/include/asm-x86/xen/hypercall.h
+++ b/include/asm-x86/xen/hypercall.h
@@ -204,11 +204,20 @@ HYPERVISOR_get_debugreg(int reg)
 	return _hypercall1(unsigned long, get_debugreg, reg);
 }
 
+#ifdef CONFIG_X86_64
+static inline int
+HYPERVISOR_update_descriptor(
+	unsigned long ma, unsigned long word)
+{
+	return _hypercall2(int, update_descriptor, ma, word);
+}
+#else
 static inline int
 HYPERVISOR_update_descriptor(u64 ma, u64 desc)
 {
 	return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
 }
+#endif
 
 static inline int
 HYPERVISOR_memory_op(unsigned int cmd, void *arg)
@@ -383,10 +392,16 @@ MULTI_update_descriptor(struct multicall_entry *mcl, u64 maddr,
 			struct desc_struct desc)
 {
 	mcl->op = __HYPERVISOR_update_descriptor;
+#ifdef CONFIG_X86_64
+	BUG_ON(sizeof(desc) != sizeof(mcl->args[2]));
+	mcl->args[0] = maddr;
+	mcl->args[1] = *((unsigned long *)&desc);
+#else
 	mcl->args[0] = maddr;
 	mcl->args[1] = maddr >> 32;
 	mcl->args[2] = desc.a;
 	mcl->args[3] = desc.b;
+#endif
 }
 
 static inline void
-- 
1.5.4.1


linux-2.6-xen-0033-xen-x86_64-Add-hacky-64-bit-x86_-read-write-_percpu.patch:

--- NEW FILE linux-2.6-xen-0033-xen-x86_64-Add-hacky-64-bit-x86_-read-write-_percpu.patch ---
>From 98a49c721b085ef7107a105d52caca907898ebb6 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
Date: Tue, 27 Nov 2007 18:21:29 -0200
Subject: [PATCH] xen x86_64: Add hacky 64-bit x86_{read,write}_percpu()

It isn't implemented on x86_64 yet, so I am simply using __get_cpu_var().

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/percpu.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/percpu.h b/include/asm-x86/percpu.h
index 0dec00f..b80af66 100644
--- a/include/asm-x86/percpu.h
+++ b/include/asm-x86/percpu.h
@@ -22,6 +22,10 @@
 
 DECLARE_PER_CPU(struct x8664_pda, pda);
 
+/* x86_read_percpu & friends */
+#define x86_read_percpu(var) __get_cpu_var(var)
+#define x86_write_percpu(var,val) (__get_cpu_var(var) = (val))
+
 #else /* CONFIG_X86_64 */
 
 #ifdef __ASSEMBLY__
-- 
1.5.4.1


linux-2.6-xen-0034-xen-x86_64-Use-x86_read_percpu-only-to-refer-to-a.patch:

--- NEW FILE linux-2.6-xen-0034-xen-x86_64-Use-x86_read_percpu-only-to-refer-to-a.patch ---
>From b73288eba739fffd288b7d2c4301bf8a3624ec00 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
Date: Tue, 27 Nov 2007 19:25:50 -0200
Subject: [PATCH] xen x86_64: Use x86_read_percpu() only to refer to a variable name

Our x86_read_percpu() implementation doesn't handle struct
dereferences.

Signed-off-by: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
---
 arch/x86/xen/enlighten.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 504bd13..3477bec 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -657,7 +657,11 @@ static unsigned long xen_read_cr2(void)
 
 static unsigned long xen_read_cr2_direct(void)
 {
+#ifdef CONFIG_X86_32
 	return x86_read_percpu(xen_vcpu_info.arch.cr2);
+#else
+	return x86_read_percpu(xen_vcpu_info).arch.cr2;
+#endif
 }
 
 static void xen_write_cr4(unsigned long cr4)
-- 
1.5.4.1


linux-2.6-xen-0035-Better-implementation-of-pte-functions.patch:

--- NEW FILE linux-2.6-xen-0035-Better-implementation-of-pte-functions.patch ---
>From 49b29000d2fa578c0848a8e00cb97898ee92293a Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
Date: Tue, 27 Nov 2007 19:26:30 -0200
Subject: [PATCH] Better implementation of pte functions

Signed-off-by: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
---
 include/xen/page.h |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/include/xen/page.h b/include/xen/page.h
index 031ef22..4456566 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -143,27 +143,23 @@ static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
 
 static inline pte_t mfn_pte(unsigned long page_nr, pgprot_t pgprot)
 {
-	pte_t pte;
-
-	pte.pte_high = (page_nr >> (32 - PAGE_SHIFT)) |
-		(pgprot_val(pgprot) >> 32);
-	pte.pte_high &= (__supported_pte_mask >> 32);
-	pte.pte_low = ((page_nr << PAGE_SHIFT) | pgprot_val(pgprot));
-	pte.pte_low &= __supported_pte_mask;
-
-	return pte;
+	pteval_t val;
+	
+	val = (page_nr << PAGE_SHIFT) | pgprot_val(pgprot);
+	val &= __supported_pte_mask;
+	return native_make_pte(val);
 }
 
-static inline unsigned long long pte_val_ma(pte_t x)
+static inline pteval_t pte_val_ma(pte_t x)
 {
-	return x.pte;
+	return native_pte_val(x);
 }
 #define pmd_val_ma(v) ((v).pmd)
 #define pud_val_ma(v) ((v).pgd.pgd)
-#define __pte_ma(x)	((pte_t) { .pte = (x) })
+#define __pte_ma(x)	(native_make_pte(x))
 #define __pmd_ma(x)	((pmd_t) { (x) } )
 #else  /* !X86_PAE */
-#define pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT)
+#define pte_mfn(_pte) ((native_pte_val(_pte) & __PHYSICAL_MASK) >> PAGE_SHIFT)
 #define mfn_pte(pfn, prot)	__pte_ma(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
 #define pte_val_ma(x)	((x).pte)
 #define pmd_val_ma(v)	((v).pud.pgd.pgd)
-- 
1.5.4.1


linux-2.6-xen-0036-Add-FIX_PARAVIRT_BOOTAP-to-fixmap_64.h-too.patch:

--- NEW FILE linux-2.6-xen-0036-Add-FIX_PARAVIRT_BOOTAP-to-fixmap_64.h-too.patch ---
>From d0aa5508cab05272b5a35c3c70306b39a3623c94 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
Date: Tue, 27 Nov 2007 19:42:21 -0200
Subject: [PATCH] Add FIX_PARAVIRT_BOOTAP to fixmap_64.h too

Signed-off-by: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
---
 include/asm-x86/fixmap_64.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/fixmap_64.h b/include/asm-x86/fixmap_64.h
index 45beeb1..0ffb60c 100644
--- a/include/asm-x86/fixmap_64.h
+++ b/include/asm-x86/fixmap_64.h
@@ -44,6 +44,9 @@ enum fixed_addresses {
 	FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,
 	FIX_EFI_IO_MAP_LAST_PAGE,
 	FIX_EFI_IO_MAP_FIRST_PAGE = FIX_EFI_IO_MAP_LAST_PAGE+MAX_EFI_IO_PAGES-1,
+#ifdef CONFIG_PARAVIRT
+	FIX_PARAVIRT_BOOTMAP,
+#endif
 #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
 	FIX_OHCI1394_BASE,
 #endif
-- 
1.5.4.1


linux-2.6-xen-0037-Add-gate_offset-and-gate_segment-macros.patch:

--- NEW FILE linux-2.6-xen-0037-Add-gate_offset-and-gate_segment-macros.patch ---
>From f390eb31d682cd6a4060d8b5d70d7b6d2e56e7db Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
Date: Tue, 27 Nov 2007 19:42:54 -0200
Subject: [PATCH] Add gate_offset() and gate_segment() macros

For calculating the offset from struct gate_struct fields.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/desc_defs.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/desc_defs.h b/include/asm-x86/desc_defs.h
index e33f078..dbf5e19 100644
--- a/include/asm-x86/desc_defs.h
+++ b/include/asm-x86/desc_defs.h
@@ -73,10 +73,14 @@ struct ldttss_desc64 {
 typedef struct gate_struct64 gate_desc;
 typedef struct ldttss_desc64 ldt_desc;
 typedef struct ldttss_desc64 tss_desc;
+#define gate_offset(g) ((g).offset_low | ((unsigned long)(g).offset_middle << 16) | ((unsigned long)(g).offset_high << 32))
+#define gate_segment(g) ((g).segment)
 #else
 typedef struct desc_struct gate_desc;
 typedef struct desc_struct ldt_desc;
 typedef struct desc_struct tss_desc;
+#define gate_offset(g) get_desc_limit(&(g))
+#define gate_segment(g) get_desc_base(&(g))
 #endif
 
 struct desc_ptr {
-- 
1.5.4.1


linux-2.6-xen-0038-xen_write_idt_entry-and-cvt_gate_to_trap.patch:

--- NEW FILE linux-2.6-xen-0038-xen_write_idt_entry-and-cvt_gate_to_trap.patch ---
>From b60d87761b341d8b60a398534e4daaa1c7dd3943 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
Date: Tue, 27 Nov 2007 19:43:41 -0200
Subject: [PATCH] xen_write_idt_entry() and cvt_gate_to_trap()

Changed to use the (to-be-)unified descriptor structs.

Signed-off-by: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
---
 arch/x86/xen/enlighten.c |   24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 3477bec..2c0f4ae 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -418,23 +418,18 @@ static void xen_write_ldt_entry(struct desc_struct *dt, int entrynum,
 	preempt_enable();
 }
 
-static int cvt_gate_to_trap(int vector, u32 low, u32 high,
+static int cvt_gate_to_trap(int vector, const gate_desc *val,
 			    struct trap_info *info)
 {
-	u8 type, dpl;
-
-	type = (high >> 8) & 0x1f;
-	dpl = (high >> 13) & 3;
-
-	if (type != 0xf && type != 0xe)
+	if (val->type != 0xf && val->type != 0xe)
 		return 0;
 
 	info->vector = vector;
-	info->address = (high & 0xffff0000) | (low & 0x0000ffff);
-	info->cs = low >> 16;
-	info->flags = dpl;
+	info->address = gate_offset(*val);
+	info->cs = gate_segment(*val);
+	info->flags = val->dpl;
 	/* interrupt gates clear IF */
-	if (type == 0xe)
+	if (val->type == 0xe)
 		info->flags |= 4;
 
 	return 1;
@@ -461,11 +456,10 @@ static void xen_write_idt_entry(gate_desc *dt, int entrynum, const gate_desc *g)
 
 	if (p >= start && (p + 8) <= end) {
 		struct trap_info info[2];
-		u32 *desc = (u32 *)g;
 
 		info[1].address = 0;
 
-		if (cvt_gate_to_trap(entrynum, desc[0], desc[1], &info[0]))
+		if (cvt_gate_to_trap(entrynum, g, &info[0]))
 			if (HYPERVISOR_set_trap_table(info))
 				BUG();
 	}
@@ -482,9 +476,9 @@ static void xen_convert_trap_info(const struct desc_ptr *desc,
 	BUG_ON(count > 256);
 
 	for (in = out = 0; in < count; in++) {
-		const u32 *entry = (u32 *)(desc->address + in * 8);
+		gate_desc *entry = (gate_desc*)(desc->address) + in;
 
-		if (cvt_gate_to_trap(in, entry[0], entry[1], &traps[out]))
+		if (cvt_gate_to_trap(in, entry, &traps[out]))
 			out++;
 	}
 	traps[out].address = 0;
-- 
1.5.4.1


linux-2.6-xen-0039-typedefs-for-pte_val-and-friends.patch:

--- NEW FILE linux-2.6-xen-0039-typedefs-for-pte_val-and-friends.patch ---
>From ff8da38cf7da220b489cf3ee82b12db5bb5a8191 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at Rawhide-64.localdomain>
Date: Tue, 27 Nov 2007 20:09:43 -0200
Subject: [PATCH] typedefs for pte_val() and friends

Trying to reduce the #ifdef mess a bit.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/mmu.c |   20 ++++++++++----------
 arch/x86/xen/mmu.h |   23 +++++++----------------
 2 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 8660786..b974434 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -186,7 +186,7 @@ void xen_pmd_clear(pmd_t *pmdp)
 	xen_set_pmd(pmdp, __pmd(0));
 }
 
-unsigned long long xen_pte_val(pte_t pte)
+pteval_t xen_pte_val(pte_t pte)
 {
 	unsigned long long ret = 0;
 
@@ -198,7 +198,7 @@ unsigned long long xen_pte_val(pte_t pte)
 	return ret;
 }
 
-unsigned long long xen_pmd_val(pmd_t pmd)
+pmdval_t xen_pmd_val(pmd_t pmd)
 {
 	unsigned long long ret = pmd.pmd;
 	if (ret)
@@ -206,7 +206,7 @@ unsigned long long xen_pmd_val(pmd_t pmd)
 	return ret;
 }
 
-unsigned long long xen_pgd_val(pgd_t pgd)
+pgdval_t xen_pgd_val(pgd_t pgd)
 {
 	unsigned long long ret = pgd.pgd;
 	if (ret)
@@ -214,7 +214,7 @@ unsigned long long xen_pgd_val(pgd_t pgd)
 	return ret;
 }
 
-pte_t xen_make_pte(unsigned long long pte)
+pte_t xen_make_pte(pteval_t pte)
 {
 	if (pte & _PAGE_PRESENT) {
 		pte = phys_to_machine(XPADDR(pte)).maddr;
@@ -224,7 +224,7 @@ pte_t xen_make_pte(unsigned long long pte)
 	return (pte_t){ .pte = pte };
 }
 
-pmd_t xen_make_pmd(unsigned long long pmd)
+pmd_t xen_make_pmd(pmdval_t pmd)
 {
 	if (pmd & 1)
 		pmd = phys_to_machine(XPADDR(pmd)).maddr;
@@ -232,7 +232,7 @@ pmd_t xen_make_pmd(unsigned long long pmd)
 	return (pmd_t){ pmd };
 }
 
-pgd_t xen_make_pgd(unsigned long long pgd)
+pgd_t xen_make_pgd(pgdval_t pgd)
 {
 	if (pgd & _PAGE_PRESENT)
 		pgd = phys_to_machine(XPADDR(pgd)).maddr;
@@ -245,7 +245,7 @@ void xen_set_pte(pte_t *ptep, pte_t pte)
 	*ptep = pte;
 }
 
-unsigned long xen_pte_val(pte_t pte)
+pteval_t xen_pte_val(pte_t pte)
 {
 	unsigned long ret = pte.pte_low;
 
@@ -255,7 +255,7 @@ unsigned long xen_pte_val(pte_t pte)
 	return ret;
 }
 
-unsigned long xen_pgd_val(pgd_t pgd)
+pgdval_t xen_pgd_val(pgd_t pgd)
 {
 	unsigned long ret = pgd.pgd;
 	if (ret)
@@ -263,7 +263,7 @@ unsigned long xen_pgd_val(pgd_t pgd)
 	return ret;
 }
 
-pte_t xen_make_pte(unsigned long pte)
+pte_t xen_make_pte(pteval_t pte)
 {
 	if (pte & _PAGE_PRESENT) {
 		pte = phys_to_machine(XPADDR(pte)).maddr;
@@ -273,7 +273,7 @@ pte_t xen_make_pte(unsigned long pte)
 	return (pte_t){ pte };
 }
 
-pgd_t xen_make_pgd(unsigned long pgd)
+pgd_t xen_make_pgd(pgdval_t pgd)
 {
 	if (pgd & _PAGE_PRESENT)
 		pgd = phys_to_machine(XPADDR(pgd)).maddr;
diff --git a/arch/x86/xen/mmu.h b/arch/x86/xen/mmu.h
index b5e189b..ce425a4 100644
--- a/arch/x86/xen/mmu.h
+++ b/arch/x86/xen/mmu.h
@@ -37,15 +37,15 @@ void xen_exit_mmap(struct mm_struct *mm);
 void xen_pgd_pin(pgd_t *pgd);
 //void xen_pgd_unpin(pgd_t *pgd);
 
-#ifdef CONFIG_X86_PAE
-unsigned long long xen_pte_val(pte_t);
-unsigned long long xen_pmd_val(pmd_t);
-unsigned long long xen_pgd_val(pgd_t);
+pteval_t xen_pte_val(pte_t);
+pmdval_t xen_pmd_val(pmd_t);
+pgdval_t xen_pgd_val(pgd_t);
 
-pte_t xen_make_pte(unsigned long long);
-pmd_t xen_make_pmd(unsigned long long);
-pgd_t xen_make_pgd(unsigned long long);
+pte_t xen_make_pte(pteval_t);
+pmd_t xen_make_pmd(pmdval_t);
+pgd_t xen_make_pgd(pgdval_t);
 
+#ifdef CONFIG_X86_PAE
 void xen_set_pte_at(struct mm_struct *mm, unsigned long addr,
 		    pte_t *ptep, pte_t pteval);
 void xen_set_pte_atomic(pte_t *ptep, pte_t pte);
@@ -53,15 +53,6 @@ void xen_set_pud(pud_t *ptr, pud_t val);
 void xen_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
 void xen_pmd_clear(pmd_t *pmdp);
 
-
-#else
-unsigned long xen_pte_val(pte_t);
-unsigned long xen_pmd_val(pmd_t);
-unsigned long xen_pgd_val(pgd_t);
-
-pte_t xen_make_pte(unsigned long);
-pmd_t xen_make_pmd(unsigned long);
-pgd_t xen_make_pgd(unsigned long);
 #endif
 
 #endif	/* _XEN_MMU_H */
-- 
1.5.4.1


linux-2.6-xen-0040-x86_64-implementation-of-some-page.h-macros.patch:

--- NEW FILE linux-2.6-xen-0040-x86_64-implementation-of-some-page.h-macros.patch ---
>From 3d77b75880104bf13fc9a29d198d2034f3e3cca6 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 28 Nov 2007 12:20:59 -0200
Subject: [PATCH] x86_64 implementation of some page.h macros

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/xen/page.h |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/include/xen/page.h b/include/xen/page.h
index 4456566..7bf5b56 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -154,7 +154,6 @@ static inline pteval_t pte_val_ma(pte_t x)
 {
 	return native_pte_val(x);
 }
-#define pmd_val_ma(v) ((v).pmd)
 #define pud_val_ma(v) ((v).pgd.pgd)
 #define __pte_ma(x)	(native_make_pte(x))
 #define __pmd_ma(x)	((pmd_t) { (x) } )
@@ -162,11 +161,11 @@ static inline pteval_t pte_val_ma(pte_t x)
 #define pte_mfn(_pte) ((native_pte_val(_pte) & __PHYSICAL_MASK) >> PAGE_SHIFT)
 #define mfn_pte(pfn, prot)	__pte_ma(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
 #define pte_val_ma(x)	((x).pte)
-#define pmd_val_ma(v)	((v).pud.pgd.pgd)
 #define __pte_ma(x)	((pte_t) { (x) } )
 #endif	/* CONFIG_X86_PAE */
 
 #define pgd_val_ma(x)	((x).pgd)
+#define pmd_val_ma(x)	(native_pmd_val((x)))
 
 
 xmaddr_t arbitrary_virt_to_machine(unsigned long address);
-- 
1.5.4.1


linux-2.6-xen-0041-Chainsaw-style-ifdefs.patch:

--- NEW FILE linux-2.6-xen-0041-Chainsaw-style-ifdefs.patch ---
>From a4410c885221d94acb8a33f5f03328f15ea1aba0 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 28 Nov 2007 12:21:33 -0200
Subject: [PATCH] Chainsaw-style #ifdefs

Whee!

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |    8 ++++++++
 arch/x86/xen/setup.c     |    5 +++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 2c0f4ae..fb28f68 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1236,6 +1236,7 @@ static const struct machine_ops __initdata xen_machine_ops = {
 };
 
 
+#ifdef CONFIG_X86_32
 static void __init xen_reserve_top(void)
 {
 	unsigned long top = HYPERVISOR_VIRT_START;
@@ -1246,6 +1247,9 @@ static void __init xen_reserve_top(void)
 
 	reserve_top_address(-top + 2 * PAGE_SIZE);
 }
+#else
+#define xen_reserve_top() do { } while (0)
+#endif
 
 /* First C function to be called on Xen boot */
 asmlinkage void __init xen_start_kernel(void)
@@ -1280,7 +1284,9 @@ asmlinkage void __init xen_start_kernel(void)
 
 	pgd = (pgd_t *)xen_start_info->pt_base;
 
+#ifdef CONFIG_X86_32
 	init_pg_tables_end = __pa(pgd) + xen_start_info->nr_pt_frames*PAGE_SIZE;
+#endif
 
 	init_mm.pgd = pgd; /* use the Xen pagetables to start */
 
@@ -1300,10 +1306,12 @@ asmlinkage void __init xen_start_kernel(void)
 	/* set the limit of our address space */
 	xen_reserve_top();
 
+#ifdef CONFIG_X86_32
 	/* set up basic CPUID stuff */
 	cpu_detect(&new_cpu_data);
 	new_cpu_data.hard_math = 1;
 	new_cpu_data.x86_capability[0] = cpuid_edx(1);
+#endif
 
 	/* Poke various useful things into boot_params */
 	boot_params.hdr.type_of_loader = (9 << 4) | 0;
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index d42586d..7b66f26 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -8,6 +8,7 @@
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/pm.h>
+#include <linux/pfn.h>
 
 #include <asm/elf.h>
 #include <asm/vdso.h>
@@ -62,6 +63,7 @@ static void xen_idle(void)
 	}
 }
 
+#ifdef CONFIG_X86_32
 /*
  * Set the bit indicating "nosegneg" library variants should be used.
  */
@@ -71,6 +73,9 @@ static void __init fiddle_vdso(void)
 	u32 *mask = VDSO32_SYMBOL(&vdso32_default_start, NOTE_MASK);
 	*mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
 }
+#else
+#define fiddle_vdso() do { } while (0)
+#endif
 
 void __init xen_arch_setup(void)
 {
-- 
1.5.4.1


linux-2.6-xen-0042-xen-Make-xen_pte_val-generic.patch:

--- NEW FILE linux-2.6-xen-0042-xen-Make-xen_pte_val-generic.patch ---
>From 84ddfd0bfea48b4986d14cb6f1d11af6ab97aa63 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 28 Nov 2007 17:53:17 -0200
Subject: [PATCH] xen: Make xen_pte_val() generic

Care is taken to make sure that all attribute bits
are left untouched by the address translation,
especially NX since it is a higher bit than all the
others.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/mmu.c |   36 ++++++++++++++----------------------
 1 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index b974434..4ec41ce 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -143,6 +143,20 @@ void xen_set_pte_at(struct mm_struct *mm, unsigned long addr,
 	xen_set_pte(ptep, pteval);
 }
 
+pteval_t xen_pte_val(pte_t pte)
+{
+	pteval_t ret = pte_val_ma(pte);
+
+	if (ret & _PAGE_PRESENT) {
+		/* preserve all other pte bits */
+		unsigned long m = machine_to_phys(XMADDR(ret & PHYSICAL_PAGE_MASK)).paddr;
+		ret &= ~PHYSICAL_PAGE_MASK;
+		ret |= m;
+	}
+
+	return ret;
+}
+
 #ifdef CONFIG_X86_PAE
 void xen_set_pud(pud_t *ptr, pud_t val)
 {
@@ -186,18 +200,6 @@ void xen_pmd_clear(pmd_t *pmdp)
 	xen_set_pmd(pmdp, __pmd(0));
 }
 
-pteval_t xen_pte_val(pte_t pte)
-{
-	unsigned long long ret = 0;
-
-	if (pte.pte_low) {
-		ret = ((unsigned long long)pte.pte_high << 32) | pte.pte_low;
-		ret = machine_to_phys(XMADDR(ret)).paddr | 1;
-	}
-
-	return ret;
-}
-
 pmdval_t xen_pmd_val(pmd_t pmd)
 {
 	unsigned long long ret = pmd.pmd;
@@ -245,16 +247,6 @@ void xen_set_pte(pte_t *ptep, pte_t pte)
 	*ptep = pte;
 }
 
-pteval_t xen_pte_val(pte_t pte)
-{
-	unsigned long ret = pte.pte_low;
-
-	if (ret & _PAGE_PRESENT)
-		ret = machine_to_phys(XMADDR(ret)).paddr;
-
-	return ret;
-}
-
 pgdval_t xen_pgd_val(pgd_t pgd)
 {
 	unsigned long ret = pgd.pgd;
-- 
1.5.4.1


linux-2.6-xen-0043-More-chainsaw-ifdefs.patch:

--- NEW FILE linux-2.6-xen-0043-More-chainsaw-ifdefs.patch ---
>From 6fae3b6643ce75827cf203ba579c1cd5881aa08f Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 28 Nov 2007 17:54:25 -0200
Subject: [PATCH] More chainsaw-ifdefs

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/events.c |   11 ++++++++++-
 arch/x86/xen/mmu.c    |    5 +++++
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/events.c b/arch/x86/xen/events.c
index dcf613e..fa67e61 100644
--- a/arch/x86/xen/events.c
+++ b/arch/x86/xen/events.c
@@ -456,6 +456,12 @@ void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector)
 }
 
 
+/*FIXME: ugly */
+#ifdef CONFIG_X86_64
+extern asmlinkage unsigned int do_IRQ(struct pt_regs *regs);
+#endif
+
+
 /*
  * Search the CPUs pending events bitmasks.  For each one found, map
  * the event number to an irq, and feed it into do_IRQ() for
@@ -587,5 +593,8 @@ void __init xen_init_IRQ(void)
 	for (i = 0; i < NR_IRQS; i++)
 		irq_bindcount[i] = 0;
 
-	irq_ctx_init(smp_processor_id());
+#ifdef CONFIG_X86_32
+	/*FIXME: investigate this better */
+ 	irq_ctx_init(smp_processor_id());
+#endif
 }
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 4ec41ce..d4742df 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -526,7 +526,12 @@ static void drop_other_mm_ref(void *info)
 {
 	struct mm_struct *mm = info;
 
+#ifdef CONFIG_X86_32
+	/*FIXME: better way to do this, avoiding #ifdefs */
 	if (__get_cpu_var(cpu_tlbstate).active_mm == mm)
+#else
+	if (read_pda(active_mm) == mm)
+#endif
 		leave_mm(smp_processor_id());
 
 	/* If this cpu still has a stale cr3 reference, then make sure
-- 
1.5.4.1


linux-2.6-xen-0044-Chainsaw-ifdefs-on-assembly-percpu-handling.patch:

--- NEW FILE linux-2.6-xen-0044-Chainsaw-ifdefs-on-assembly-percpu-handling.patch ---
>From 85d04142dd919d89e94d145ff0227a5fe4362c71 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 28 Nov 2007 17:55:00 -0200
Subject: [PATCH] Chainsaw-ifdefs on assembly percpu handling

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>

Undo stupid code added when trying to make percpu work

Using 32-bit registers would never work.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/percpu.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/percpu.h b/include/asm-x86/percpu.h
index b80af66..5dcb3bd 100644
--- a/include/asm-x86/percpu.h
+++ b/include/asm-x86/percpu.h
@@ -9,6 +9,8 @@
    should be just put into a single section and referenced directly
    from %gs */
 
+#ifndef __ASSEMBLY__
+
 #ifdef CONFIG_SMP
 #include <asm/pda.h>
 
@@ -26,6 +28,8 @@ DECLARE_PER_CPU(struct x8664_pda, pda);
 #define x86_read_percpu(var) __get_cpu_var(var)
 #define x86_write_percpu(var,val) (__get_cpu_var(var) = (val))
 
+#endif
+
 #else /* CONFIG_X86_64 */
 
 #ifdef __ASSEMBLY__
-- 
1.5.4.1


linux-2.6-xen-0045-x86_64-percpu-assembly-macros.patch:

--- NEW FILE linux-2.6-xen-0045-x86_64-percpu-assembly-macros.patch ---
>From f77443cf32c4cf65a9e5e2a080a06eb763992fa1 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Thu, 29 Nov 2007 16:05:08 -0200
Subject: [PATCH] x86_64 percpu assembly macros

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/percpu.h |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/include/asm-x86/percpu.h b/include/asm-x86/percpu.h
index 5dcb3bd..3f4522b 100644
--- a/include/asm-x86/percpu.h
+++ b/include/asm-x86/percpu.h
@@ -9,7 +9,31 @@
    should be just put into a single section and referenced directly
    from %gs */
 
-#ifndef __ASSEMBLY__
+#ifdef __ASSEMBLY__
+
+/*
+ * PER_CPU finds an address of a per-cpu variable.
+ *
+ * Args:
+ *    var - variable name
+ *    reg - 32bit register
+ *
+ * The resulting address is stored in the "reg" argument.
+ *
+ * Example:
+ *    PER_CPU(cpu_gdt_descr, %ebx)
+ */
+#ifdef CONFIG_SMP
+#define PER_CPU(var, reg)			\
+	movq %gs:pda_data_offset, reg;		\
+	lea per_cpu__##var(reg), reg
+#else /* ! SMP */
+#define PER_CPU(var, reg)			\
+	movl $per_cpu__##var, reg
+#define PER_CPU_VAR(var)	per_cpu__##var
+#endif	/* SMP */
+
+#else /* ...!ASSEMBLY */
 
 #ifdef CONFIG_SMP
 #include <asm/pda.h>
-- 
1.5.4.1


linux-2.6-xen-0046-Some-xen-asm.S-x86_64-code.patch:

--- NEW FILE linux-2.6-xen-0046-Some-xen-asm.S-x86_64-code.patch ---
>From b8fc7bbbdde24b52a957c70c0c07dbd1642e6c82 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Thu, 29 Nov 2007 16:06:30 -0200
Subject: [PATCH] Some xen-asm.S x86_64 code

Funny preprocessor tricks to make the same code work on both arches
included.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/xen-asm.S |   55 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 54 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/xen-asm.S b/arch/x86/xen/xen-asm.S
index 6b71904..af6abfa 100644
--- a/arch/x86/xen/xen-asm.S
+++ b/arch/x86/xen/xen-asm.S
@@ -24,6 +24,28 @@
 #define RELOC(x, v)	.globl x##_reloc; x##_reloc=v
 #define ENDPATCH(x)	.globl x##_end; x##_end=.
 
+#ifdef CONFIG_X86_64
+#  define SUFFIX  q
+#  define REGPREF r
+#else
+#  define SUFFIX  l
+#  define REGPREF e
+#endif
+
+#define  __REG(pref, reg) %pref##reg
+#define  _REG(pref, reg) __REG(pref, reg)
+#define  REG(reg) _REG(REGPREF, reg)
+
+#define  __INSN(in, suff) in##suff
+#define  _INSN(in, suff) __INSN(in, suff)
+#define  INSN(in) _INSN(in, SUFFIX)
+
+#define  rAX REG(ax)
+#define  rSP REG(sp)
+#define  MOV INSN(mov)
+#define  AND INSN(and)
+
+
 /* Pseudo-flag used for virtual NMI, which we don't implement yet */
 #define XEN_EFLAGS_NMI	0x80000000
 
@@ -34,14 +56,24 @@
  */
 ENTRY(xen_irq_enable_direct)
 	/* Unmask events */
+#ifdef PER_CPU_VAR
 	movb $0, PER_CPU_VAR(xen_vcpu_info)+XEN_vcpu_info_mask
+#else
+	PER_CPU(xen_vcpu_info, rAX)
+	movb $0, XEN_vcpu_info_mask(rAX)
+#endif
 
 	/* Preempt here doesn't matter because that will deal with
 	   any pending interrupts.  The pending check may end up being
 	   run on the wrong CPU, but that doesn't hurt. */
 
 	/* Test for pending */
+#ifdef PER_CPU_VAR
 	testb $0xff, PER_CPU_VAR(xen_vcpu_info)+XEN_vcpu_info_pending
+#else
+	/* rAX already points to xen_vcpu_info */
+	testb $0xff, XEN_vcpu_info_pending(rAX)
+#endif
 	jz 1f
 
 2:	call check_events
@@ -57,7 +89,12 @@ ENDPATCH(xen_irq_enable_direct)
 	non-zero.
  */
 ENTRY(xen_irq_disable_direct)
+#ifdef PER_CPU_VAR
 	movb $1, PER_CPU_VAR(xen_vcpu_info)+XEN_vcpu_info_mask
+#else
+	PER_CPU(xen_vcpu_info, rAX)
+	movb $1, XEN_vcpu_info_mask(rAX)
+#endif
 ENDPATCH(xen_irq_disable_direct)
 	ret
 	ENDPROC(xen_irq_disable_direct)
@@ -73,7 +110,12 @@ ENDPATCH(xen_irq_disable_direct)
 	Xen and x86 use opposite senses (mask vs enable).
  */
 ENTRY(xen_save_fl_direct)
+#ifdef PER_CPU_VAR
 	testb $0xff, PER_CPU_VAR(xen_vcpu_info)+XEN_vcpu_info_mask
+#else
+	PER_CPU(xen_vcpu_info, rAX)
+	testb $0xff, XEN_vcpu_info_mask(rAX)
+#endif
 	setz %ah
 	addb %ah,%ah
 ENDPATCH(xen_save_fl_direct)
@@ -92,13 +134,23 @@ ENDPATCH(xen_save_fl_direct)
  */
 ENTRY(xen_restore_fl_direct)
 	testb $X86_EFLAGS_IF>>8, %ah
+#ifdef PER_CPU_VAR
 	setz PER_CPU_VAR(xen_vcpu_info)+XEN_vcpu_info_mask
+#else
+	PER_CPU(xen_vcpu_info, rAX)
+	setz XEN_vcpu_info_mask(rAX)
+#endif
 	/* Preempt here doesn't matter because that will deal with
 	   any pending interrupts.  The pending check may end up being
 	   run on the wrong CPU, but that doesn't hurt. */
 
 	/* check for unmasked and pending */
+#ifdef PER_CPU_VAR
 	cmpw $0x0001, PER_CPU_VAR(xen_vcpu_info)+XEN_vcpu_info_pending
+#else
+	/* rAX already points to xen_vcpu_info */
+	cmpw $0x0001, XEN_vcpu_info_pending(rAX)
+#endif
 	jz 1f
 2:	call check_events
 1:
@@ -143,7 +195,8 @@ ENDPATCH(xen_restore_fl_direct)
  */
 ENTRY(xen_iret_direct)
 	/* test eflags for special cases */
-	testl $(X86_EFLAGS_VM | XEN_EFLAGS_NMI), 8(%esp)
+	/*FIXME: use right offset for rFLAGS */
+	testl $(X86_EFLAGS_VM | XEN_EFLAGS_NMI), 8(rSP)
 	jnz hyper_iret
 
 	push %eax
-- 
1.5.4.1


linux-2.6-xen-0047-Chainsaw-party-SPLITME.patch:

--- NEW FILE linux-2.6-xen-0047-Chainsaw-party-SPLITME.patch ---
>From fd6cb5b6815deb2b122ab0ea1ab8c866b0c3c6b6 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 3 Dec 2007 17:28:38 -0200
Subject: [PATCH] Chainsaw party (SPLITME)

:D

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/asm-offsets_64.c |   15 +++
 arch/x86/kernel/entry_32.S       |   83 +---------------
 arch/x86/kernel/entry_64.S       |    4 +
 arch/x86/kernel/head_64.S        |    3 +
 arch/x86/kernel/smpboot_64.c     |    4 +-
 arch/x86/xen/enlighten.c         |    3 +
 arch/x86/xen/entry.S             |    5 +
 arch/x86/xen/entry_32.S          |   81 +++++++++++++++
 arch/x86/xen/entry_64.S          |    1 +
 arch/x86/xen/smp.c               |   16 +++
 arch/x86/xen/xen-asm.S           |  210 +-------------------------------------
 arch/x86/xen/xen-asm_32.S        |  184 +++++++++++++++++++++++++++++++++
 arch/x86/xen/xen-asm_64.S        |    8 ++
 arch/x86/xen/xen-head.S          |   20 +++-
 include/asm-x86/asm-hack.h       |   27 +++++
 include/asm-x86/smp_64.h         |    3 +
 include/linux/elfnote.h          |    2 +-
 include/xen/interface/elfnote.h  |   16 +++
 18 files changed, 390 insertions(+), 295 deletions(-)
 create mode 100644 arch/x86/xen/entry.S
 create mode 100644 arch/x86/xen/entry_32.S
 create mode 100644 arch/x86/xen/entry_64.S
 create mode 100644 arch/x86/xen/xen-asm_32.S
 create mode 100644 arch/x86/xen/xen-asm_64.S
 create mode 100644 include/asm-x86/asm-hack.h

diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
index 494e1e0..d0fabfd 100644
--- a/arch/x86/kernel/asm-offsets_64.c
+++ b/arch/x86/kernel/asm-offsets_64.c
@@ -25,6 +25,8 @@
 #define OFFSET(sym, str, mem) \
 	DEFINE(sym, offsetof(struct str, mem))
 
+#include <xen/interface/xen.h>
+
 #define __NO_STUBS 1
 #undef __SYSCALL
 #undef _ASM_X86_64_UNISTD_H_
@@ -92,6 +94,13 @@ int main(void)
 	       offsetof (struct rt_sigframe32, uc.uc_mcontext));
 	BLANK();
 #endif
+
+#ifdef CONFIG_XEN
+	BLANK();
+	OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
+	OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
+#endif
+
 	DEFINE(pbe_address, offsetof(struct pbe, address));
 	DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
 	DEFINE(pbe_next, offsetof(struct pbe, next));
@@ -130,6 +139,12 @@ int main(void)
 	BLANK();
 	DEFINE(__NR_syscall_max, sizeof(syscalls) - 1);
 
+	DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
+	DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
+	DEFINE(PTRS_PER_PTE, PTRS_PER_PTE);
+	DEFINE(PTRS_PER_PMD, PTRS_PER_PMD);
+	DEFINE(PTRS_PER_PGD, PTRS_PER_PGD);
+
 	BLANK();
 	OFFSET(BP_scratch, boot_params, scratch);
 	OFFSET(BP_loadflags, boot_params, hdr.loadflags);
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 4b87c32..4ef3881 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1023,88 +1023,7 @@ ENTRY(kernel_thread_helper)
 ENDPROC(kernel_thread_helper)
 
 #ifdef CONFIG_XEN
-ENTRY(xen_hypervisor_callback)
-	CFI_STARTPROC
-	pushl $0
-	CFI_ADJUST_CFA_OFFSET 4
-	SAVE_ALL
-	TRACE_IRQS_OFF
-
-	/* Check to see if we got the event in the critical
-	   region in xen_iret_direct, after we've reenabled
-	   events and checked for pending events.  This simulates
-	   iret instruction's behaviour where it delivers a
-	   pending interrupt when enabling interrupts. */
-	movl PT_EIP(%esp),%eax
-	cmpl $xen_iret_start_crit,%eax
-	jb   1f
-	cmpl $xen_iret_end_crit,%eax
-	jae  1f
-
-	call xen_iret_crit_fixup
-
-1:	mov %esp, %eax
-	call xen_evtchn_do_upcall
-	jmp  ret_from_intr
-	CFI_ENDPROC
-ENDPROC(xen_hypervisor_callback)
-
-# Hypervisor uses this for application faults while it executes.
-# We get here for two reasons:
-#  1. Fault while reloading DS, ES, FS or GS
-#  2. Fault while executing IRET
-# Category 1 we fix up by reattempting the load, and zeroing the segment
-# register if the load fails.
-# Category 2 we fix up by jumping to do_iret_error. We cannot use the
-# normal Linux return path in this case because if we use the IRET hypercall
-# to pop the stack frame we end up in an infinite loop of failsafe callbacks.
-# We distinguish between categories by maintaining a status value in EAX.
-ENTRY(xen_failsafe_callback)
-	CFI_STARTPROC
-	pushl %eax
-	CFI_ADJUST_CFA_OFFSET 4
-	movl $1,%eax
-1:	mov 4(%esp),%ds
-2:	mov 8(%esp),%es
-3:	mov 12(%esp),%fs
-4:	mov 16(%esp),%gs
-	testl %eax,%eax
-	popl %eax
-	CFI_ADJUST_CFA_OFFSET -4
-	lea 16(%esp),%esp
-	CFI_ADJUST_CFA_OFFSET -16
-	jz 5f
-	addl $16,%esp
-	jmp iret_exc		# EAX != 0 => Category 2 (Bad IRET)
-5:	pushl $0		# EAX == 0 => Category 1 (Bad segment)
-	CFI_ADJUST_CFA_OFFSET 4
-	SAVE_ALL
-	jmp ret_from_exception
-	CFI_ENDPROC
-
-.section .fixup,"ax"
-6:	xorl %eax,%eax
-	movl %eax,4(%esp)
-	jmp 1b
-7:	xorl %eax,%eax
-	movl %eax,8(%esp)
-	jmp 2b
-8:	xorl %eax,%eax
-	movl %eax,12(%esp)
-	jmp 3b
-9:	xorl %eax,%eax
-	movl %eax,16(%esp)
-	jmp 4b
-.previous
-.section __ex_table,"a"
-	.align 4
-	.long 1b,6b
-	.long 2b,7b
-	.long 3b,8b
-	.long 4b,9b
-.previous
-ENDPROC(xen_failsafe_callback)
-
+#include "../xen/entry_32.S"
 #endif	/* CONFIG_XEN */
 
 .section .rodata,"a"
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 556a8df..3fedbd6 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1202,3 +1202,7 @@ KPROBE_ENTRY(ignore_sysret)
 	sysret
 	CFI_ENDPROC
 ENDPROC(ignore_sysret)
+
+#ifdef CONFIG_XEN
+#include "../xen/entry_64.S"
+#endif	/* CONFIG_XEN */
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index a007454..923ad56 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -419,6 +419,9 @@ ENTRY(phys_base)
 	/* This must match the first entry in level2_kernel_pgt */
 	.quad   0x0000000000000000
 
+#include "../../x86/xen/xen-head.S"
+
+
 /* We need valid kernel segments for data and code in long mode too
  * IRET will check the segment types  kkeil 2000/10/28
  * Also sysret mandates a special GDT layout 
diff --git a/arch/x86/kernel/smpboot_64.c b/arch/x86/kernel/smpboot_64.c
index a47f973..08bbcad 100644
--- a/arch/x86/kernel/smpboot_64.c
+++ b/arch/x86/kernel/smpboot_64.c
@@ -144,7 +144,7 @@ static unsigned long __cpuinit setup_trampoline(void)
  * a given CPU
  */
 
-static void __cpuinit smp_store_cpu_info(int id)
+void __cpuinit smp_store_cpu_info(int id)
 {
 	struct cpuinfo_x86 *c = &cpu_data(id);
 
@@ -261,7 +261,7 @@ cpumask_t cpu_coregroup_map(int cpu)
 /* representing cpus for which sibling maps can be computed */
 static cpumask_t cpu_sibling_setup_map;
 
-static inline void set_cpu_sibling_map(int cpu)
+inline void set_cpu_sibling_map(int cpu)
 {
 	int i;
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index fb28f68..9518194 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1270,7 +1270,10 @@ asmlinkage void __init xen_start_kernel(void)
 	pv_apic_ops = xen_apic_ops;
 	pv_mmu_ops = xen_mmu_ops;
 
+#ifdef CONFIG_X86_32
+	/*FIXME: implement me! */
 	machine_ops = xen_machine_ops;
+#endif
 
 #ifdef CONFIG_SMP
 	smp_ops = xen_smp_ops;
diff --git a/arch/x86/xen/entry.S b/arch/x86/xen/entry.S
new file mode 100644
index 0000000..1e7551e
--- /dev/null
+++ b/arch/x86/xen/entry.S
@@ -0,0 +1,5 @@
+#ifdef CONFIG_X86_64
+#  include "entry_64.S"
+#else
+#  include "entry_32.S"
+#endif
diff --git a/arch/x86/xen/entry_32.S b/arch/x86/xen/entry_32.S
new file mode 100644
index 0000000..89109a8
--- /dev/null
+++ b/arch/x86/xen/entry_32.S
@@ -0,0 +1,81 @@
+ENTRY(xen_hypervisor_callback)
+	CFI_STARTPROC
+	pushl $0
+	CFI_ADJUST_CFA_OFFSET 4
+	SAVE_ALL
+	TRACE_IRQS_OFF
+
+	/* Check to see if we got the event in the critical
+	   region in xen_iret_direct, after we've reenabled
+	   events and checked for pending events.  This simulates
+	   iret instruction's behaviour where it delivers a
+	   pending interrupt when enabling interrupts. */
+	movl PT_EIP(%esp),%eax
+	cmpl $xen_iret_start_crit,%eax
+	jb   1f
+	cmpl $xen_iret_end_crit,%eax
+	jae  1f
+
+	call xen_iret_crit_fixup
+
+1:	mov %esp, %eax
+	call xen_evtchn_do_upcall
+	jmp  ret_from_intr
+	CFI_ENDPROC
+ENDPROC(xen_hypervisor_callback)
+
+# Hypervisor uses this for application faults while it executes.
+# We get here for two reasons:
+#  1. Fault while reloading DS, ES, FS or GS
+#  2. Fault while executing IRET
+# Category 1 we fix up by reattempting the load, and zeroing the segment
+# register if the load fails.
+# Category 2 we fix up by jumping to do_iret_error. We cannot use the
+# normal Linux return path in this case because if we use the IRET hypercall
+# to pop the stack frame we end up in an infinite loop of failsafe callbacks.
+# We distinguish between categories by maintaining a status value in EAX.
+ENTRY(xen_failsafe_callback)
+	CFI_STARTPROC
+	pushl %eax
+	CFI_ADJUST_CFA_OFFSET 4
+	movl $1,%eax
+1:	mov 4(%esp),%ds
+2:	mov 8(%esp),%es
+3:	mov 12(%esp),%fs
+4:	mov 16(%esp),%gs
+	testl %eax,%eax
+	popl %eax
+	CFI_ADJUST_CFA_OFFSET -4
+	lea 16(%esp),%esp
+	CFI_ADJUST_CFA_OFFSET -16
+	jz 5f
+	addl $16,%esp
+	jmp iret_exc		# EAX != 0 => Category 2 (Bad IRET)
+5:	pushl $0		# EAX == 0 => Category 1 (Bad segment)
+	CFI_ADJUST_CFA_OFFSET 4
+	SAVE_ALL
+	jmp ret_from_exception
+	CFI_ENDPROC
+
+.section .fixup,"ax"
+6:	xorl %eax,%eax
+	movl %eax,4(%esp)
+	jmp 1b
+7:	xorl %eax,%eax
+	movl %eax,8(%esp)
+	jmp 2b
+8:	xorl %eax,%eax
+	movl %eax,12(%esp)
+	jmp 3b
+9:	xorl %eax,%eax
+	movl %eax,16(%esp)
+	jmp 4b
+.previous
+.section __ex_table,"a"
+	.align 4
+	.long 1b,6b
+	.long 2b,7b
+	.long 3b,8b
+	.long 4b,9b
+.previous
+ENDPROC(xen_failsafe_callback)
diff --git a/arch/x86/xen/entry_64.S b/arch/x86/xen/entry_64.S
new file mode 100644
index 0000000..c8c1473
--- /dev/null
+++ b/arch/x86/xen/entry_64.S
@@ -0,0 +1 @@
+#error foo
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index aafc544..03580bf 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -144,7 +144,10 @@ void __init xen_smp_prepare_boot_cpu(void)
 
 	/* We've switched to the "real" per-cpu gdt, so make sure the
 	   old memory can be recycled */
+#ifdef CONFIG_X86_32
+	//FIXME: implement this on 64-bit
 	make_lowmem_page_readwrite(&per_cpu__gdt_page);
+#endif
 
 	for_each_possible_cpu(cpu) {
 		cpus_clear(per_cpu(cpu_sibling_map, cpu));
@@ -207,6 +210,8 @@ void __init xen_smp_prepare_cpus(unsigned int max_cpus)
 static __cpuinit int
 cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
 {
+/*FIXME: implement me */
+#ifdef CONFIG_X86_32
 	struct vcpu_guest_context *ctxt;
 	struct gdt_page *gdt = &per_cpu(gdt_page, cpu);
 
@@ -256,11 +261,14 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
 		BUG();
 
 	kfree(ctxt);
+#endif
 	return 0;
 }
 
 int __cpuinit xen_cpu_up(unsigned int cpu)
 {
+//FIXME: implement me!
+#ifdef CONFIG_X86_32
 	struct task_struct *idle = idle_task(cpu);
 	int rc;
 
@@ -299,6 +307,7 @@ int __cpuinit xen_cpu_up(unsigned int cpu)
 	rc = HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL);
 	BUG_ON(rc);
 
+#endif
 	return 0;
 }
 
@@ -308,6 +317,8 @@ void xen_smp_cpus_done(unsigned int max_cpus)
 
 static void stop_self(void *v)
 {
+//FIXME: implement me!
+#ifdef CONFIG_X86_32
 	int cpu = smp_processor_id();
 
 	/* make sure we're not pinning something down */
@@ -316,6 +327,7 @@ static void stop_self(void *v)
 
 	HYPERVISOR_vcpu_op(VCPUOP_down, cpu, NULL);
 	BUG();
+#endif
 }
 
 void xen_smp_send_stop(void)
@@ -356,7 +368,11 @@ static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id)
 	 */
 	irq_enter();
 	(*func)(info);
+#ifdef CONFIG_X86_32
 	__get_cpu_var(irq_stat).irq_call_count++;
+#else
+	add_pda(irq_call_count, 1);
+#endif
 	irq_exit();
 
 	if (wait) {
diff --git a/arch/x86/xen/xen-asm.S b/arch/x86/xen/xen-asm.S
index af6abfa..1c3c0ac 100644
--- a/arch/x86/xen/xen-asm.S
+++ b/arch/x86/xen/xen-asm.S
@@ -18,33 +18,13 @@
 #include <asm/percpu.h>
 #include <asm/processor-flags.h>
 #include <asm/segment.h>
+#include <asm/asm-hack.h>
 
 #include <xen/interface/xen.h>
 
 #define RELOC(x, v)	.globl x##_reloc; x##_reloc=v
 #define ENDPATCH(x)	.globl x##_end; x##_end=.
 
-#ifdef CONFIG_X86_64
-#  define SUFFIX  q
-#  define REGPREF r
-#else
-#  define SUFFIX  l
-#  define REGPREF e
-#endif
-
-#define  __REG(pref, reg) %pref##reg
-#define  _REG(pref, reg) __REG(pref, reg)
-#define  REG(reg) _REG(REGPREF, reg)
-
-#define  __INSN(in, suff) in##suff
-#define  _INSN(in, suff) __INSN(in, suff)
-#define  INSN(in) _INSN(in, SUFFIX)
-
-#define  rAX REG(ax)
-#define  rSP REG(sp)
-#define  MOV INSN(mov)
-#define  AND INSN(and)
-
 
 /* Pseudo-flag used for virtual NMI, which we don't implement yet */
 #define XEN_EFLAGS_NMI	0x80000000
@@ -159,191 +139,9 @@ ENDPATCH(xen_restore_fl_direct)
 	ENDPROC(xen_restore_fl_direct)
 	RELOC(xen_restore_fl_direct, 2b+1)
 
-/*
-	This is run where a normal iret would be run, with the same stack setup:
-	      8: eflags
-	      4: cs
-	esp-> 0: eip
-
-	This attempts to make sure that any pending events are dealt
-	with on return to usermode, but there is a small window in
-	which an event can happen just before entering usermode.  If
-	the nested interrupt ends up setting one of the TIF_WORK_MASK
-	pending work flags, they will not be tested again before
-	returning to usermode. This means that a process can end up
-	with pending work, which will be unprocessed until the process
-	enters and leaves the kernel again, which could be an
-	unbounded amount of time.  This means that a pending signal or
-	reschedule event could be indefinitely delayed.
-
-	The fix is to notice a nested interrupt in the critical
-	window, and if one occurs, then fold the nested interrupt into
-	the current interrupt stack frame, and re-process it
-	iteratively rather than recursively.  This means that it will
-	exit via the normal path, and all pending work will be dealt
-	with appropriately.
-
-	Because the nested interrupt handler needs to deal with the
-	current stack state in whatever form its in, we keep things
-	simple by only using a single register which is pushed/popped
-	on the stack.
 
-	Non-direct iret could be done in the same way, but it would
-	require an annoying amount of code duplication.  We'll assume
-	that direct mode will be the common case once the hypervisor
-	support becomes commonplace.
- */
-ENTRY(xen_iret_direct)
-	/* test eflags for special cases */
-	/*FIXME: use right offset for rFLAGS */
-	testl $(X86_EFLAGS_VM | XEN_EFLAGS_NMI), 8(rSP)
-	jnz hyper_iret
-
-	push %eax
-	ESP_OFFSET=4	# bytes pushed onto stack
-
-	/* Store vcpu_info pointer for easy access.  Do it this
-	   way to avoid having to reload %fs */
-#ifdef CONFIG_SMP
-	GET_THREAD_INFO(%eax)
-	movl TI_cpu(%eax),%eax
-	movl __per_cpu_offset(,%eax,4),%eax
-	lea per_cpu__xen_vcpu_info(%eax),%eax
+#ifdef CONFIG_X86_64
+#include "xen-asm_64.S"
 #else
-	movl $per_cpu__xen_vcpu_info, %eax
+#include "xen-asm_32.S"
 #endif
-
-	/* check IF state we're restoring */
-	testb $X86_EFLAGS_IF>>8, 8+1+ESP_OFFSET(%esp)
-
-	/* Maybe enable events.  Once this happens we could get a
-	   recursive event, so the critical region starts immediately
-	   afterwards.  However, if that happens we don't end up
-	   resuming the code, so we don't have to be worried about
-	   being preempted to another CPU. */
-	setz XEN_vcpu_info_mask(%eax)
-xen_iret_start_crit:
-
-	/* check for unmasked and pending */
-	cmpw $0x0001, XEN_vcpu_info_pending(%eax)
-
-	/* If there's something pending, mask events again so we
-	   can jump back into xen_hypervisor_callback */
-	sete XEN_vcpu_info_mask(%eax)
-
-	popl %eax
-
-	/* From this point on the registers are restored and the stack
-	   updated, so we don't need to worry about it if we're preempted */
-iret_restore_end:
-
-	/* Jump to hypervisor_callback after fixing up the stack.
-	   Events are masked, so jumping out of the critical
-	   region is OK. */
-	je xen_hypervisor_callback
-
-	iret
-xen_iret_end_crit:
-
-hyper_iret:
-	/* put this out of line since its very rarely used */
-	jmp hypercall_page + __HYPERVISOR_iret * 32
-
-	.globl xen_iret_start_crit, xen_iret_end_crit
-
-/*
-   This is called by xen_hypervisor_callback in entry.S when it sees
-   that the EIP at the time of interrupt was between xen_iret_start_crit
-   and xen_iret_end_crit.  We're passed the EIP in %eax so we can do
-   a more refined determination of what to do.
-
-   The stack format at this point is:
-	----------------
-	 ss		: (ss/esp may be present if we came from usermode)
-	 esp		:
-	 eflags		}  outer exception info
-	 cs		}
-	 eip		}
-	---------------- <- edi (copy dest)
-	 eax		:  outer eax if it hasn't been restored
-	----------------
-	 eflags		}  nested exception info
-	 cs		}   (no ss/esp because we're nested
-	 eip		}    from the same ring)
-	 orig_eax	}<- esi (copy src)
-	 - - - - - - - -
-	 fs		}
-	 es		}
-	 ds		}  SAVE_ALL state
-	 eax		}
-	  :		:
-	 ebx		}
-	----------------
-	 return addr	 <- esp
-	----------------
-
-   In order to deliver the nested exception properly, we need to shift
-   everything from the return addr up to the error code so it
-   sits just under the outer exception info.  This means that when we
-   handle the exception, we do it in the context of the outer exception
-   rather than starting a new one.
-
-   The only caveat is that if the outer eax hasn't been
-   restored yet (ie, it's still on stack), we need to insert
-   its value into the SAVE_ALL state before going on, since
-   it's usermode state which we eventually need to restore.
- */
-ENTRY(xen_iret_crit_fixup)
-	/* offsets +4 for return address */
-
-	/*
-	   Paranoia: Make sure we're really coming from userspace.
-	   One could imagine a case where userspace jumps into the
-	   critical range address, but just before the CPU delivers a GP,
-	   it decides to deliver an interrupt instead.  Unlikely?
-	   Definitely.  Easy to avoid?  Yes.  The Intel documents
-	   explicitly say that the reported EIP for a bad jump is the
-	   jump instruction itself, not the destination, but some virtual
-	   environments get this wrong.
-	 */
-	movl PT_CS+4(%esp), %ecx
-	andl $SEGMENT_RPL_MASK, %ecx
-	cmpl $USER_RPL, %ecx
-	je 2f
-
-	lea PT_ORIG_EAX+4(%esp), %esi
-	lea PT_EFLAGS+4(%esp), %edi
-
-	/* If eip is before iret_restore_end then stack
-	   hasn't been restored yet. */
-	cmp $iret_restore_end, %eax
-	jae 1f
-
-	movl 0+4(%edi),%eax		/* copy EAX */
-	movl %eax, PT_EAX+4(%esp)
-
-	lea ESP_OFFSET(%edi),%edi	/* move dest up over saved regs */
-
-	/* set up the copy */
-1:	std
-	mov $(PT_EIP+4) / 4, %ecx	/* copy ret+saved regs up to orig_eax */
-	rep movsl
-	cld
-
-	lea 4(%edi),%esp		/* point esp to new frame */
-2:	ret
-
-
-/*
-	Force an event check by making a hypercall,
-	but preserve regs before making the call.
- */
-check_events:
-	push %eax
-	push %ecx
-	push %edx
-	call force_evtchn_callback
-	pop %edx
-	pop %ecx
-	pop %eax
-	ret
diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
new file mode 100644
index 0000000..1340296
--- /dev/null
+++ b/arch/x86/xen/xen-asm_32.S
@@ -0,0 +1,184 @@
+/*
+	This is run where a normal iret would be run, with the same stack setup:
+	      8: eflags
+	      4: cs
+	esp-> 0: eip
+
+	This attempts to make sure that any pending events are dealt
+	with on return to usermode, but there is a small window in
+	which an event can happen just before entering usermode.  If
+	the nested interrupt ends up setting one of the TIF_WORK_MASK
+	pending work flags, they will not be tested again before
+	returning to usermode. This means that a process can end up
+	with pending work, which will be unprocessed until the process
+	enters and leaves the kernel again, which could be an
+	unbounded amount of time.  This means that a pending signal or
+	reschedule event could be indefinitely delayed.
+
+	The fix is to notice a nested interrupt in the critical
+	window, and if one occurs, then fold the nested interrupt into
+	the current interrupt stack frame, and re-process it
+	iteratively rather than recursively.  This means that it will
+	exit via the normal path, and all pending work will be dealt
+	with appropriately.
+
+	Because the nested interrupt handler needs to deal with the
+	current stack state in whatever form its in, we keep things
+	simple by only using a single register which is pushed/popped
+	on the stack.
+
+	Non-direct iret could be done in the same way, but it would
+	require an annoying amount of code duplication.  We'll assume
+	that direct mode will be the common case once the hypervisor
+	support becomes commonplace.
+ */
+ENTRY(xen_iret_direct)
+	/* test eflags for special cases */
+	/*FIXME: use right offset for rFLAGS */
+	testl $(X86_EFLAGS_VM | XEN_EFLAGS_NMI), 8(rSP)
+	jnz hyper_iret
+
+	push rAX
+	ESP_OFFSET=4	# bytes pushed onto stack
+
+	/* Store vcpu_info pointer for easy access.  Do it this
+	   way to avoid having to reload %fs */
+	PER_CPU(xen_vcpu_info, rAX)
+
+	/* check IF state we're restoring */
+	/*FIXME: fix ESP offset */
+	/*FIXME: check WTF the magic numbers below mean */
+	testb $X86_EFLAGS_IF>>8, 8+1+ESP_OFFSET(rSP)
+
+	/* Maybe enable events.  Once this happens we could get a
+	   recursive event, so the critical region starts immediately
+	   afterwards.  However, if that happens we don't end up
+	   resuming the code, so we don't have to be worried about
+	   being preempted to another CPU. */
+	setz XEN_vcpu_info_mask(rAX)
+xen_iret_start_crit:
+
+	/* check for unmasked and pending */
+	cmpw $0x0001, XEN_vcpu_info_pending(%eax)
+
+	/* If there's something pending, mask events again so we
+	   can jump back into xen_hypervisor_callback */
+	sete XEN_vcpu_info_mask(%eax)
+
+	popl %eax
+
+	/* From this point on the registers are restored and the stack
+	   updated, so we don't need to worry about it if we're preempted */
+iret_restore_end:
+
+	/* Jump to hypervisor_callback after fixing up the stack.
+	   Events are masked, so jumping out of the critical
+	   region is OK. */
+	je xen_hypervisor_callback
+
+	iret
+xen_iret_end_crit:
+
+hyper_iret:
+	/* put this out of line since its very rarely used */
+	jmp hypercall_page + __HYPERVISOR_iret * 32
+
+	.globl xen_iret_start_crit, xen_iret_end_crit
+
+/*
+   This is called by xen_hypervisor_callback in entry.S when it sees
+   that the EIP at the time of interrupt was between xen_iret_start_crit
+   and xen_iret_end_crit.  We're passed the EIP in %eax so we can do
+   a more refined determination of what to do.
+
+   The stack format at this point is:
+	----------------
+	 ss		: (ss/esp may be present if we came from usermode)
+	 esp		:
+	 eflags		}  outer exception info
+	 cs		}
+	 eip		}
+	---------------- <- edi (copy dest)
+	 eax		:  outer eax if it hasn't been restored
+	----------------
+	 eflags		}  nested exception info
+	 cs		}   (no ss/esp because we're nested
+	 eip		}    from the same ring)
+	 orig_eax	}<- esi (copy src)
+	 - - - - - - - -
+	 fs		}
+	 es		}
+	 ds		}  SAVE_ALL state
+	 eax		}
+	  :		:
+	 ebx		}
+	----------------
+	 return addr	 <- esp
+	----------------
+
+   In order to deliver the nested exception properly, we need to shift
+   everything from the return addr up to the error code so it
+   sits just under the outer exception info.  This means that when we
+   handle the exception, we do it in the context of the outer exception
+   rather than starting a new one.
+
+   The only caveat is that if the outer eax hasn't been
+   restored yet (ie, it's still on stack), we need to insert
+   its value into the SAVE_ALL state before going on, since
+   it's usermode state which we eventually need to restore.
+ */
+ENTRY(xen_iret_crit_fixup)
+	/* offsets +4 for return address */
+
+	/*
+	   Paranoia: Make sure we're really coming from userspace.
+	   One could imagine a case where userspace jumps into the
+	   critical range address, but just before the CPU delivers a GP,
+	   it decides to deliver an interrupt instead.  Unlikely?
+	   Definitely.  Easy to avoid?  Yes.  The Intel documents
+	   explicitly say that the reported EIP for a bad jump is the
+	   jump instruction itself, not the destination, but some virtual
+	   environments get this wrong.
+	 */
+	movl PT_CS+4(%esp), %ecx
+	andl $SEGMENT_RPL_MASK, %ecx
+	cmpl $USER_RPL, %ecx
+	je 2f
+
+	lea PT_ORIG_EAX+4(%esp), %esi
+	lea PT_EFLAGS+4(%esp), %edi
+
+	/* If eip is before iret_restore_end then stack
+	   hasn't been restored yet. */
+	cmp $iret_restore_end, %eax
+	jae 1f
+
+	movl 0+4(%edi),%eax		/* copy EAX */
+	movl %eax, PT_EAX+4(%esp)
+
+	lea ESP_OFFSET(%edi),%edi	/* move dest up over saved regs */
+
+	/* set up the copy */
+1:	std
+	mov $(PT_EIP+4) / 4, %ecx	/* copy ret+saved regs up to orig_eax */
+	rep movsl
+	cld
+
+	lea 4(%edi),%esp		/* point esp to new frame */
+2:	ret
+
+
+/*
+	Force an event check by making a hypercall,
+	but preserve regs before making the call.
+ */
+check_events:
+	push %eax
+	push %ecx
+	push %edx
+	call force_evtchn_callback
+	pop %edx
+	pop %ecx
+	pop %eax
+	ret
+
diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
new file mode 100644
index 0000000..38443b8
--- /dev/null
+++ b/arch/x86/xen/xen-asm_64.S
@@ -0,0 +1,8 @@
+check_events:
+	/*FIXME: implement me! */
+	ud2a
+
+
+ENTRY(xen_iret_direct)
+	/*FIXME: implement me! */
+	ud2a
diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
index 288d587..ec5d622 100644
--- a/arch/x86/xen/xen-head.S
+++ b/arch/x86/xen/xen-head.S
@@ -7,12 +7,14 @@
 #include <linux/init.h>
 #include <asm/boot.h>
 #include <xen/interface/elfnote.h>
+#include <asm/asm-hack.h>
+
 
 	__INIT
 ENTRY(startup_xen)
-	movl %esi,xen_start_info
+ 	MOV rSI,xen_start_info
 	cld
-	movl $(init_thread_union+THREAD_SIZE),%esp
+ 	MOV $(init_thread_union+THREAD_SIZE),rSP
 	jmp xen_start_kernel
 
 	__FINIT
@@ -26,14 +28,24 @@ ENTRY(hypercall_page)
 	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz "linux")
 	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,  .asciz "2.6")
 	ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,    .asciz "xen-3.0")
+#ifdef CONFIG_X86_32
 	ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      .long  __PAGE_OFFSET)
 	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          .long  startup_xen)
 	ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .long  hypercall_page)
+#else
+	ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      .quad  __START_KERNEL_map)
+	ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   .quad  0)
+	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          .quad  startup_64)
+	ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,   .quad  _PAGE_PRESENT,_PAGE_PRESENT)
+#endif
+
 	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz "!writable_page_tables|pae_pgdir_above_4gb")
-#ifdef CONFIG_X86_PAE
+#ifdef CONFIG_X86_32
+#  ifdef CONFIG_X86_PAE
 	ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz "yes")
-#else
+#  else
 	ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz "no")
+#  endif
 #endif
 	ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz "generic")
 
diff --git a/include/asm-x86/asm-hack.h b/include/asm-x86/asm-hack.h
new file mode 100644
index 0000000..b7c2a66
--- /dev/null
+++ b/include/asm-x86/asm-hack.h
@@ -0,0 +1,27 @@
+#ifndef __ASM_ASM_HACK_H
+
+#ifdef CONFIG_X86_64
+#  define SUFFIX  q
+#  define REGPREF r
+#else
+#  define SUFFIX  l
+#  define REGPREF e
+#endif
+
+#define  __REG(pref, reg) %pref##reg
+#define  _REG(pref, reg) __REG(pref, reg)
+#define  REG(reg) _REG(REGPREF, reg)
+
+#define  __INSN(in, suff) in##suff
+#define  _INSN(in, suff) __INSN(in, suff)
+#define  INSN(in) _INSN(in, SUFFIX)
+
+#define  rAX REG(ax)
+#define  rSP REG(sp)
+#define  rSI REG(si)
+#define  rDI REG(di)
+
+#define  MOV INSN(mov)
+#define  AND INSN(and)
+
+#endif /* __ASM_ASM_HACK_H */
diff --git a/include/asm-x86/smp_64.h b/include/asm-x86/smp_64.h
index e0a7551..48630c1 100644
--- a/include/asm-x86/smp_64.h
+++ b/include/asm-x86/smp_64.h
@@ -97,5 +97,8 @@ static inline int hard_smp_processor_id(void)
 	return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
 }
 
+extern void smp_store_cpu_info(int id);
+extern void set_cpu_sibling_map(int cpu);
+
 #endif
 
diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h
index 278e3ef..9f9816a 100644
--- a/include/linux/elfnote.h
+++ b/include/linux/elfnote.h
@@ -52,7 +52,7 @@
 4484:.balign 4				;	\
 .popsection				;
 
-#define ELFNOTE(name, type, desc)		\
+#define ELFNOTE(name, type, desc...)		\
 	ELFNOTE_START(name, type, "")		\
 		desc			;	\
 	ELFNOTE_END
diff --git a/include/xen/interface/elfnote.h b/include/xen/interface/elfnote.h
index a64d3df..ee5501d 100644
--- a/include/xen/interface/elfnote.h
+++ b/include/xen/interface/elfnote.h
@@ -120,6 +120,22 @@
  */
 #define XEN_ELFNOTE_BSD_SYMTAB    11
 
+/*
+ * The lowest address the hypervisor hole can begin at (numeric).
+ *
+ * This must not be set higher than HYPERVISOR_VIRT_START. Its presence
+ * also indicates to the hypervisor that the kernel can deal with the
+ * hole starting at a higher address.
+ */
+#define XEN_ELFNOTE_HV_START_LOW  12
+
+/*
+ * List of maddr_t-sized mask/value pairs describing how to recognize
+ * (non-present) L1 page table entries carrying valid MFNs (numeric).
+ */
+#define XEN_ELFNOTE_L1_MFN_VALID  13
+
+
 #endif /* __XEN_PUBLIC_ELFNOTE_H__ */
 
 /*
-- 
1.5.4.1


linux-2.6-xen-0048-xen-asm.S-x86_64-notes.patch:

--- NEW FILE linux-2.6-xen-0048-xen-asm.S-x86_64-notes.patch ---
>From e1b7c1aaa82d799d83ea5396a4419b63e654312a Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 4 Dec 2007 14:43:21 -0200
Subject: [PATCH] xen-asm.S: x86_64 notes

- Point to right entrypoint (startup_xen)
- Point to hypercall_page

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/xen-head.S |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
index ec5d622..429e8f3 100644
--- a/arch/x86/xen/xen-head.S
+++ b/arch/x86/xen/xen-head.S
@@ -33,9 +33,10 @@ ENTRY(hypercall_page)
 	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          .long  startup_xen)
 	ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .long  hypercall_page)
 #else
+	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          .quad  startup_xen)
+	ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad  hypercall_page)
 	ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      .quad  __START_KERNEL_map)
 	ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   .quad  0)
-	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          .quad  startup_64)
 	ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,   .quad  _PAGE_PRESENT,_PAGE_PRESENT)
 #endif
 
-- 
1.5.4.1


linux-2.6-xen-0049-xen-x86_64-Make-hypercall-assembly-code-work.patch:

--- NEW FILE linux-2.6-xen-0049-xen-x86_64-Make-hypercall-assembly-code-work.patch ---
>From 0e1e00716f7f419ae3d5191538e5b16949ee1034 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 4 Dec 2007 16:25:41 -0200
Subject: [PATCH] xen x86_64: Make hypercall assembly code work

Se comment for explanation.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/xen/hypercall.h |  113 ++++++++++++++++++++++++++++++--------
 1 files changed, 89 insertions(+), 24 deletions(-)

diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
index cbf3d52..605775e 100644
--- a/include/asm-x86/xen/hypercall.h
+++ b/include/asm-x86/xen/hypercall.h
@@ -42,13 +42,42 @@
 
 extern struct { char _entry[32]; } hypercall_page[];
 
+#define __STR(x) #x
+#define STR(x) __STR(x)
+
+/* We could let gcc handle the asm operand generation for us, and
+ * use hypercall_page[__HYPERVISOR_##name] as a asm "m" or "i" operand.
+ *
+ * On i386, a "m" operand works for a direct call, but on x86_64,
+ * gcc generates a %rip-relative operand and the assembler generates
+ * an indirect call (and emits a warning).
+ *
+ *
+ * A "i" operand could work, but at least on x86_64, gcc generates
+ * the following:
+ *
+ * 	call $hypercall_page+555
+ *
+ * That is rejected by the assembler with the error "suffix or operands
+ * invalid for `call'"
+ */
+#define HYPERCALL_STR(name)						\
+	"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
+
+#ifdef CONFIG_X86_64
+#define IGN1 "=D"
+#define IGN2 "=S"
+#else
+#define IGN1 "=b"
+#define IGN2 "=c"
+#endif
+
 #define _hypercall0(type, name)						\
 ({									\
 	long __res;							\
 	asm volatile (							\
-		"call %[call]"						\
+		HYPERCALL_STR(name)					\
 		: "=a" (__res)						\
-		: [call] "m" (hypercall_page[__HYPERVISOR_##name])	\
 		: "memory" );						\
 	(type)__res;							\
 })
@@ -57,10 +86,9 @@ extern struct { char _entry[32]; } hypercall_page[];
 ({									\
 	long __res, __ign1;						\
 	asm volatile (							\
-		"call %[call]"						\
-		: "=a" (__res), "=b" (__ign1)				\
-		: "1" ((long)(a1)),					\
-		  [call] "m" (hypercall_page[__HYPERVISOR_##name])	\
+		HYPERCALL_STR(name)					\
+		: "=a" (__res), IGN1(__ign1)				\
+		: "1" ((long)(a1))					\
 		: "memory" );						\
 	(type)__res;							\
 })
@@ -69,10 +97,9 @@ extern struct { char _entry[32]; } hypercall_page[];
 ({									\
 	long __res, __ign1, __ign2;					\
 	asm volatile (							\
-		"call %[call]"						\
-		: "=a" (__res), "=b" (__ign1), "=c" (__ign2)		\
-		: "1" ((long)(a1)), "2" ((long)(a2)),			\
-		  [call] "m" (hypercall_page[__HYPERVISOR_##name])	\
+		HYPERCALL_STR(name)					\
+		: "=a" (__res), IGN1(__ign1), IGN2(__ign2)		\
+		: "1" ((long)(a1)), "2" ((long)(a2))			\
 		: "memory" );						\
 	(type)__res;							\
 })
@@ -81,27 +108,64 @@ extern struct { char _entry[32]; } hypercall_page[];
 ({									\
 	long __res, __ign1, __ign2, __ign3;				\
 	asm volatile (							\
-		"call %[call]"						\
-		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),		\
+		HYPERCALL_STR(name)					\
+		: "=a" (__res), IGN1(__ign1), IGN2(__ign2),		\
 		"=d" (__ign3)						\
 		: "1" ((long)(a1)), "2" ((long)(a2)),			\
-		  "3" ((long)(a3)),					\
-		  [call] "m" (hypercall_page[__HYPERVISOR_##name])	\
+		  "3" ((long)(a3))					\
 		: "memory" );						\
 	(type)__res;							\
 })
 
+/* The hypercalls below are handled differently on x86_64 because
+ * of the way the 4th and following parameters are passed to the asm
+ * block.
+ */
+
+#ifdef CONFIG_X86_64
+
+#define _hypercall4(type, name, a1, a2, a3, a4)			\
+({								\
+	long __res, __ign1, __ign2, __ign3;			\
+	asm volatile (						\
+		"movq %7,%%r10; "				\
+		HYPERCALL_STR(name)				\
+		: "=a" (__res), IGN1(__ign1), IGN2(__ign2),	\
+		"=d" (__ign3)					\
+		: "1" ((long)(a1)), "2" ((long)(a2)),		\
+		"3" ((long)(a3)), "g" ((long)(a4))		\
+		: "memory", "r10");				\
+	(type)__res;						\
+})
+
+#define _hypercall5(type, name, a1, a2, a3, a4, a5)		\
+({								\
+	long __res, __ign1, __ign2, __ign3;			\
+	asm volatile (						\
+		"movq %7,%%r10; movq %8,%%r8; "			\
+		HYPERCALL_STR(name)				\
+		: "=a" (__res), IGN1(__ign1), IGN2(__ign2),	\
+		"=d" (__ign3)					\
+		: "1" ((long)(a1)), "2" ((long)(a2)),		\
+		"3" ((long)(a3)), "g" ((long)(a4)),		\
+		"g" ((long)(a5))				\
+		: "memory", "r10", "r8");			\
+	(type)__res;						\
+})
+
+
+#else
+
 #define _hypercall4(type, name, a1, a2, a3, a4)				\
 ({									\
 	long __res, __ign1, __ign2, __ign3, __ign4;			\
 	asm volatile (							\
-		"call %[call]"						\
-		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),		\
+		HYPERCALL_STR(name)					\
+		: "=a" (__res), IGN1(__ign1), IGN2(__ign2),		\
 		"=d" (__ign3), "=S" (__ign4)				\
 		: "1" ((long)(a1)), "2" ((long)(a2)),			\
-		  "3" ((long)(a3)), "4" ((long)(a4)),			\
-		  [call] "m" (hypercall_page[__HYPERVISOR_##name])	\
-		: "memory" );						\
+		  "3" ((long)(a3)), "4" ((long)(a4))			\
+		: "memory");						\
 	(type)__res;							\
 })
 
@@ -109,17 +173,18 @@ extern struct { char _entry[32]; } hypercall_page[];
 ({									\
 	long __res, __ign1, __ign2, __ign3, __ign4, __ign5;		\
 	asm volatile (							\
-		"call %[call]"						\
-		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),		\
+		HYPERCALL_STR(name)					\
+		: "=a" (__res), IGN1(__ign1), IGN2(__ign2),		\
 		"=d" (__ign3), "=S" (__ign4), "=D" (__ign5)		\
 		: "1" ((long)(a1)), "2" ((long)(a2)),			\
 		  "3" ((long)(a3)), "4" ((long)(a4)),			\
-		  "5" ((long)(a5)),					\
-		  [call] "m" (hypercall_page[__HYPERVISOR_##name])	\
-		: "memory" );						\
+		  "5" ((long)(a5))					\
+		: "memory");						\
 	(type)__res;							\
 })
 
+#endif
+
 #if defined(CONFIG_X86_64)
 #define MULTI_UVMFLAGS_INDEX 2
 #define MULTI_UVMDOMID_INDEX 3
-- 
1.5.4.1


linux-2.6-xen-0050-xen-x86_64-pda-initialization.patch:

--- NEW FILE linux-2.6-xen-0050-xen-x86_64-pda-initialization.patch ---
>From 2575ed9771f6e3d8437208300c172379ad17e0d0 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 4 Dec 2007 17:01:56 -0200
Subject: [PATCH] xen x86_64 pda initialization

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 9518194..b7f2540 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -46,6 +46,7 @@
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/reboot.h>
+#include <asm/proto.h>
 
 #include "xen-ops.h"
 #include "mmu.h"
@@ -1261,6 +1262,19 @@ asmlinkage void __init xen_start_kernel(void)
 
 	BUG_ON(memcmp(xen_start_info->magic, "xen-3", 5) != 0);
 
+#ifdef CONFIG_X86_64
+	{
+		/*FIXME: move this to common code
+		 * (it is duplicated on x86_64_start_kernel()
+		 */
+		int i;
+		for (i = 0; i < NR_CPUS; i++)
+			cpu_pda(i) = &boot_cpu_pda[i];
+
+		pda_init(0);
+	}
+#endif
+
 	/* Install Xen paravirt ops */
 	pv_info = xen_info;
 	pv_init_ops = xen_init_ops;
-- 
1.5.4.1


linux-2.6-xen-0051-Disable-discover_ebda-under-paravirt.patch:

--- NEW FILE linux-2.6-xen-0051-Disable-discover_ebda-under-paravirt.patch ---
>From d2eb60e06b358038eac45bb95c9bbf0095bd37bd Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 5 Dec 2007 16:58:09 -0200
Subject: [PATCH] Disable discover_ebda() under paravirt

Temporary solution. Should be discussed.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/head64.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index ad24408..df8e1fc 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -55,6 +55,10 @@ static __init void reserve_ebda(void)
 {
 	unsigned ebda_addr, ebda_size;
 
+	if (paravirt_enabled())
+		/* We don't have access to this physical address under Xen */
+		return;
+
 	/*
 	 * there is a real-mode segmented pointer pointing to the
 	 * 4K EBDA area at 0x40E
-- 
1.5.4.1


linux-2.6-xen-0052-Disable-early_printk-by-default.patch:

--- NEW FILE linux-2.6-xen-0052-Disable-early_printk-by-default.patch ---
>From b837377c211da0e755551150d797a2e7c8ae770b Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 5 Dec 2007 17:21:53 -0200
Subject: [PATCH] Disable early_printk() by default

Temporary until a better solution for automatically skipping the VGA
console is found.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/early_printk.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index cff84cd..4c70cc4 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -193,7 +193,7 @@ static struct console simnow_console = {
 };
 
 /* Direct interface for emergencies */
-static struct console *early_console = &early_vga_console;
+static struct console *early_console;
 static int early_console_initialized = 0;
 
 void early_printk(const char *fmt, ...)
@@ -204,7 +204,8 @@ void early_printk(const char *fmt, ...)
 
 	va_start(ap,fmt);
 	n = vscnprintf(buf,512,fmt,ap);
-	early_console->write(early_console,buf,n);
+	if (likely(early_console))
+		early_console->write(early_console,buf,n);
 	va_end(ap);
 }
 
-- 
1.5.4.1


linux-2.6-xen-0053-xen-Set-__HYPERVISOR_VIRT_START-for-x86_64.patch:

--- NEW FILE linux-2.6-xen-0053-xen-Set-__HYPERVISOR_VIRT_START-for-x86_64.patch ---
>From 7a10c27f2dcfb4ebe4ef11cb4b4ef0f9b854356c Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 5 Dec 2007 17:43:29 -0200
Subject: [PATCH] xen: Set __HYPERVISOR_VIRT_START for x86_64

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/xen/interface.h |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/asm-x86/xen/interface.h b/include/asm-x86/xen/interface.h
index 165c396..563074c 100644
--- a/include/asm-x86/xen/interface.h
+++ b/include/asm-x86/xen/interface.h
@@ -72,10 +72,14 @@ DEFINE_GUEST_HANDLE(void);
  * Virtual addresses beyond this are not modifiable by guest OSes. The
  * machine->physical mapping table starts at this address, read-only.
  */
-#ifdef CONFIG_X86_PAE
-#define __HYPERVISOR_VIRT_START 0xF5800000
+#ifdef CONFIG_X86_64
+#define __HYPERVISOR_VIRT_START 0xFFFF800000000000
 #else
-#define __HYPERVISOR_VIRT_START 0xFC000000
+#  ifdef CONFIG_X86_PAE
+#    define __HYPERVISOR_VIRT_START 0xF5800000
+#  else
+#    define __HYPERVISOR_VIRT_START 0xFC000000
+#  endif
 #endif
 
 #ifndef HYPERVISOR_VIRT_START
-- 
1.5.4.1


linux-2.6-xen-0054-Set-__PAGE_OFFSET-as-required-by-Xen.patch:

--- NEW FILE linux-2.6-xen-0054-Set-__PAGE_OFFSET-as-required-by-Xen.patch ---
>From 15cb59370b9c8788a05ee39316911682059b43a7 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 5 Dec 2007 17:45:55 -0200
Subject: [PATCH] Set __PAGE_OFFSET as required by Xen

This will need some discussion. __va() is used everywhere and calculated
on compile-time. What if some hypervisor somewhere needs a different
__PAGE_OFFSET too?

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/page_64.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
index 1435460..c79aa87 100644
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -26,7 +26,7 @@
 #define PUD_PAGE_SIZE		(_AC(1, UL) << PUD_SHIFT)
 #define PUD_PAGE_MASK		(~(PUD_PAGE_SIZE-1))
 
-#define __PAGE_OFFSET           _AC(0xffff810000000000, UL)
+#define __PAGE_OFFSET           _AC(0xffff880000000000, UL)
 
 #define __PHYSICAL_START	CONFIG_PHYSICAL_START
 #define __KERNEL_ALIGN		0x200000
-- 
1.5.4.1


linux-2.6-xen-0055-DEBUG-Add-xprintk-to-log-directly-via-hypercall-fo.patch:

--- NEW FILE linux-2.6-xen-0055-DEBUG-Add-xprintk-to-log-directly-via-hypercall-fo.patch ---
>From 712ba371e3fe388f0a809180ff1de28e0efd2e5b Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Wed, 21 Nov 2007 18:40:31 +0000
Subject: [PATCH] DEBUG: Add xprintk to log directly via hypercall, for early debugging

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/xen/enlighten.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index b7f2540..0ea43a0 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -138,6 +138,37 @@ static void __init xen_vcpu_setup(int cpu)
 	}
 }
 
+static void kcons_write_dom0(const char *s, unsigned int count)
+{
+       int rc;
+
+       while ((count > 0) &&
+              ((rc = HYPERVISOR_console_io(
+                       CONSOLEIO_write, count, (char *)s)) > 0)) {
+               count -= rc;
+               s += rc;
+       }
+}
+
+
+/*** Useful function for console debugging -- goes straight to Xen. ***/
+asmlinkage int xprintk(const char *fmt, ...)
+{
+       va_list args;
+       int printk_len;
+       static char printk_buf[1024];
+
+       /* Emit the output into the temporary buffer */
+       va_start(args, fmt);
+       printk_len = vsnprintf(printk_buf, sizeof(printk_buf), fmt, args);
+       va_end(args);
+
+       /* Send the processed output directly to Xen. */
+       kcons_write_dom0(printk_buf, printk_len);
+
+       return 0;
+}
+
 static void __init xen_banner(void)
 {
 	printk(KERN_INFO "Booting paravirtualized kernel on %s\n",
-- 
1.5.4.1


linux-2.6-xen-0056-Use-__pgd-on-mk_kernel_pgd.patch:

--- NEW FILE linux-2.6-xen-0056-Use-__pgd-on-mk_kernel_pgd.patch ---
>From d54cf35c99c9c28d2ba74454d971706aaf4b3b0b Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 11 Dec 2007 12:00:09 -0200
Subject: [PATCH] Use __pgd() on mk_kernel_pgd()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/pgtable_64.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
index c9352fe..d96a272 100644
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -189,7 +189,7 @@ static inline unsigned long pmd_bad(pmd_t pmd)
 #define pgd_offset_k(address) (init_level4_pgt + pgd_index(address))
 #define pgd_present(pgd) (pgd_val(pgd) & _PAGE_PRESENT)
 static inline int pgd_large(pgd_t pgd) { return 0; }
-#define mk_kernel_pgd(address) ((pgd_t){ (address) | _KERNPG_TABLE })
+#define mk_kernel_pgd(address) (__pgd((address) | _KERNPG_TABLE))
 
 /* PUD - Level3 access */
 /* to find an entry in a page-table-directory. */
-- 
1.5.4.1


linux-2.6-xen-0057-Include-user-page-tables-on-head_64.S.patch:

--- NEW FILE linux-2.6-xen-0057-Include-user-page-tables-on-head_64.S.patch ---
>From 60e4499fae7bc3d9f727fca70badb506f94f1c37 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 11 Dec 2007 12:02:11 -0200
Subject: [PATCH] Include user page tables on head_64.S

This will need to be conditional on Xen being enabled.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/head_64.S |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 923ad56..b104024 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -356,6 +356,18 @@ NEXT_PAGE(init_level4_pgt)
 	/* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
 	.quad	level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
 
+
+	/*
+	 * We update two pgd entries to make kernel and user pgd consistent
+	 * at pgd_populate(). It can be used for kernel modules. So we place 
+	 * this page here for those cases to avoid memory corruption.
+	 * We also use this page to establish the initiali mapping for
+	 * vsyscall area.
+	 */
+NEXT_PAGE(init_level4_user_pgt)
+	.fill	512,8,0
+
+
 NEXT_PAGE(level3_ident_pgt)
 	.quad	level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
 	.fill	511,8,0
@@ -366,6 +378,14 @@ NEXT_PAGE(level3_kernel_pgt)
 	.quad	level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
 	.quad	level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
 
+	/*
+	 * This is used for vsyscall area mapping as we have a different
+	 * level4 page table for user.
+	 */
+NEXT_PAGE(level3_user_pgt)
+	.fill	512,8,0
+
+
 NEXT_PAGE(level2_fixmap_pgt)
 	.fill	506,8,0
 	.quad	level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
-- 
1.5.4.1


linux-2.6-xen-0058-Avoid-using-mk_unsigned_long.patch:

--- NEW FILE linux-2.6-xen-0058-Avoid-using-mk_unsigned_long.patch ---
>From c216f8a48d1a4393b2cf59478a13b69a0e9db76e Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 11 Dec 2007 16:06:14 -0200
Subject: [PATCH] Avoid using mk_unsigned_long()

This is just to avoid diving into the header file mess to make
the macro available.

The constants aren't used on assembly code, anyway, so just append
UL to them.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/xen/interface.h |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/asm-x86/xen/interface.h b/include/asm-x86/xen/interface.h
index 563074c..881d1b3 100644
--- a/include/asm-x86/xen/interface.h
+++ b/include/asm-x86/xen/interface.h
@@ -73,17 +73,17 @@ DEFINE_GUEST_HANDLE(void);
  * machine->physical mapping table starts at this address, read-only.
  */
 #ifdef CONFIG_X86_64
-#define __HYPERVISOR_VIRT_START 0xFFFF800000000000
+#define __HYPERVISOR_VIRT_START 0xFFFF800000000000UL
 #else
 #  ifdef CONFIG_X86_PAE
-#    define __HYPERVISOR_VIRT_START 0xF5800000
+#    define __HYPERVISOR_VIRT_START 0xF5800000UL
 #  else
-#    define __HYPERVISOR_VIRT_START 0xFC000000
+#    define __HYPERVISOR_VIRT_START 0xFC000000UL
 #  endif
 #endif
 
 #ifndef HYPERVISOR_VIRT_START
-#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
+#define HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START
 #endif
 
 #ifndef machine_to_phys_mapping
-- 
1.5.4.1


linux-2.6-xen-0059-Lots-of-unrelated-changes.patch:

--- NEW FILE linux-2.6-xen-0059-Lots-of-unrelated-changes.patch ---
>From b2f0e779b2817003dd7618cfb79e2b897d75cf0f Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 11 Dec 2007 16:14:09 -0200
Subject: [PATCH] Lots of unrelated changes

Debugging + changes to make pagetable initialization code work.

This must be splitted in smaller changesets and changed to avoid adding
a new .c file just for the xen_init_pt() function.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/Makefile     |    6 ++
 arch/x86/xen/enlighten.c  |   41 +++++++++-
 arch/x86/xen/init.h       |   10 +++
 arch/x86/xen/init_32.c    |    3 +
 arch/x86/xen/init_64.c    |  188 +++++++++++++++++++++++++++++++++++++++++++++
 arch/x86/xen/mmu.c        |   86 +++++++++++++++-----
 arch/x86/xen/mmu.h        |    8 ++
 arch/x86/xen/multicalls.c |   13 ++-
 arch/x86/xen/xen-ops.h    |    7 ++
 include/xen/page.h        |    9 ++-
 10 files changed, 342 insertions(+), 29 deletions(-)
 create mode 100644 arch/x86/xen/init.h
 create mode 100644 arch/x86/xen/init_32.c
 create mode 100644 arch/x86/xen/init_64.c

diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
index 343df24..e2dc9c1 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -1,4 +1,10 @@
 obj-y		:= enlighten.o setup.o features.o multicalls.o mmu.o \
 			events.o time.o manage.o xen-asm.o
 
+ifeq ($(CONFIG_X86_32),y)
+obj-y 	+= init_32.o
+else
+obj-y	+= init_64.o
+endif
+
 obj-$(CONFIG_SMP)	+= smp.o
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 0ea43a0..89dd8d7 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -51,6 +51,7 @@
 #include "xen-ops.h"
 #include "mmu.h"
 #include "multicalls.h"
+#include "init.h"
 
 EXPORT_SYMBOL_GPL(hypercall_page);
 
@@ -733,6 +734,25 @@ static void xen_write_cr3(unsigned long cr3)
 	xen_mc_issue(PARAVIRT_LAZY_CPU);  /* interrupts restored */
 }
 
+static void xen_new_user_baseptr(unsigned long pfn)
+{
+	struct mmuext_op *op;
+	struct multicall_space mcs;
+	unsigned long mfn = pfn_to_mfn(PFN_DOWN(pfn));
+
+	xprintk("%s: %lx\n", __func__, pfn);
+
+	mcs = xen_mc_entry(sizeof(*op));  /* disables interrupts */
+
+	op = mcs.args;
+	op->cmd = MMUEXT_NEW_USER_BASEPTR;
+	op->arg1.mfn = mfn;
+
+	MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF);
+
+	xen_mc_issue(PARAVIRT_LAZY_CPU);  /* interrupts restored */
+}
+
 /* Early in boot, while setting up the initial pagetable, assume
    everything is pinned. */
 static __init void xen_alloc_pt_init(struct mm_struct *mm, u32 pfn)
@@ -992,10 +1012,12 @@ static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf,
 	goto patch_site
 
 	switch (type) {
+#ifdef CONFIG_X86_32
 		SITE(pv_irq_ops, irq_enable);
 		SITE(pv_irq_ops, irq_disable);
 		SITE(pv_irq_ops, save_fl);
 		SITE(pv_irq_ops, restore_fl);
+#endif
 #undef SITE
 
 	patch_site:
@@ -1192,7 +1214,8 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = {
 	.make_pte = xen_make_pte,
 	.make_pgd = xen_make_pgd,
 
-#ifdef CONFIG_X86_PAE
+#ifdef CONFIG_X86_32
+#  ifdef CONFIG_X86_PAE
 	.set_pte_atomic = xen_set_pte_atomic,
 	.set_pte_present = xen_set_pte_at,
 	.set_pud = xen_set_pud,
@@ -1201,7 +1224,14 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = {
 
 	.make_pmd = xen_make_pmd,
 	.pmd_val = xen_pmd_val,
-#endif	/* PAE */
+#  endif	/* PAE */
+#else
+	.set_pgd = xen_set_pgd,
+	.make_pud = xen_make_pud,
+
+	.make_pmd = xen_make_pmd,
+	.pmd_val = xen_pmd_val,
+#endif
 
 	.activate_mm = xen_activate_mm,
 	.dup_mmap = xen_dup_mmap,
@@ -1293,6 +1323,8 @@ asmlinkage void __init xen_start_kernel(void)
 
 	BUG_ON(memcmp(xen_start_info->magic, "xen-3", 5) != 0);
 
+	xprintk("hello, world!\n");
+
 #ifdef CONFIG_X86_64
 	{
 		/*FIXME: move this to common code
@@ -1333,6 +1365,7 @@ asmlinkage void __init xen_start_kernel(void)
 	pgd = (pgd_t *)xen_start_info->pt_base;
 
 #ifdef CONFIG_X86_32
+	/*FIXME: x86_64 equivalent */
 	init_pg_tables_end = __pa(pgd) + xen_start_info->nr_pt_frames*PAGE_SIZE;
 #endif
 
@@ -1347,6 +1380,10 @@ asmlinkage void __init xen_start_kernel(void)
 	   possible map and a non-dummy shared_info. */
 	per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0];
 
+	xprintk("xen_init_pt:\n");
+	xen_init_pt();
+	xprintk("xen_init_pt returned.\n");
+
 	pv_info.kernel_rpl = 1;
 	if (xen_feature(XENFEAT_supervisor_mode_kernel))
 		pv_info.kernel_rpl = 0;
diff --git a/arch/x86/xen/init.h b/arch/x86/xen/init.h
new file mode 100644
index 0000000..9cd3954
--- /dev/null
+++ b/arch/x86/xen/init.h
@@ -0,0 +1,10 @@
+#ifndef __X86_XEN_INIT_H
+#define __X86_XEN_INIT_H
+
+void xen_init_pt(void);
+
+extern pud_t level3_user_pgt[512];
+extern pgd_t init_level4_user_pgt[];
+
+
+#endif /* __X86_XEN_INIT_H */
diff --git a/arch/x86/xen/init_32.c b/arch/x86/xen/init_32.c
new file mode 100644
index 0000000..6b49e40
--- /dev/null
+++ b/arch/x86/xen/init_32.c
@@ -0,0 +1,3 @@
+void xen_init_pt(void)
+{
+}
diff --git a/arch/x86/xen/init_64.c b/arch/x86/xen/init_64.c
new file mode 100644
index 0000000..f025c21
--- /dev/null
+++ b/arch/x86/xen/init_64.c
@@ -0,0 +1,188 @@
+#include <linux/kernel.h>
+#include <linux/init.h>
+
+#include <asm/pgtable.h>
+
+#include <asm/xen/hypercall.h>
+#include <xen/page.h>
+#include <xen/hvc-console.h>
+
+#include "xen-ops.h"
+#include "init.h"
+#include "mmu.h"
+
+#define addr_to_page(addr, page)				\
+	(addr) &= PHYSICAL_PAGE_MASK;				\
+	(page) = ((unsigned long *) ((unsigned long)		\
+	(((mfn_to_pfn((addr) >> PAGE_SHIFT)) << PAGE_SHIFT) +	\
+	__START_KERNEL_map)))
+
+
+static void __meminit early_make_page_readonly(void *va, unsigned int feature)
+{
+	unsigned long addr, _va = (unsigned long)va;
+	int r;
+	unsigned long idx;
+	pte_t pte, *ptep;
+	unsigned long *page = (unsigned long *) init_level4_pgt;
+
+	if (xen_feature(feature))
+		return;
+
+	idx = pgd_index(_va);
+
+	addr = (unsigned long) page[idx];
+	addr_to_page(addr, page);
+
+	idx = pud_index(_va);
+	addr = page[idx];
+
+	addr_to_page(addr, page);
+
+	idx = pmd_index(_va);
+	addr = page[idx];
+	addr_to_page(addr, page);
+
+	idx =pte_index(_va);
+	ptep = (pte_t *) &page[idx];
+
+	pte.pte = ptep->pte & ~_PAGE_RW;
+
+	if ( (r = HYPERVISOR_update_va_mapping(_va, pte, 0)) ) {
+		xprintk("%s: failure: %d :(\n", __func__, r);
+		BUG();
+	}
+}
+
+
+
+void __init xen_init_pt(void)
+{
+	unsigned long addr, *page;
+
+	xprintk("%s starting\n", __func__);
+
+	xprintk("xen_cr3: %lx. xen_cur_cr3: %lx\n", x86_read_percpu(xen_cr3), x86_read_percpu(xen_current_cr3));
+
+	/* Find the initial pte page that was built for us. */
+	page = (unsigned long *)xen_start_info->pt_base;
+	xprintk("page1: %p\n", page);
+	addr = page[pgd_index(__START_KERNEL_map)];
+	xprintk("addr1: %lx\n", addr);
+	addr_to_page(addr, page);
+	xprintk("addr1, page2: %lx, %p\n", addr, page);
+
+	addr = page[pud_index(__START_KERNEL_map)];
+	xprintk("addr2: %lx\n", addr);
+
+	addr_to_page(addr, page);
+	xprintk("addr2,page2: %lx, %p\n", addr, page);
+
+
+#if 0  /* CONFIG_XEN_COMPAT <= 0x030002 */
+	/* On Xen 3.0.2 and older we may need to explicitly specify _PAGE_USER
+	   in kernel PTEs. We check that here. */
+	if (HYPERVISOR_xen_version(XENVER_version, NULL) <= 0x30000) {
+		unsigned long *pg;
+		pte_t pte;
+
+		/* Mess with the initial mapping of page 0. It's not needed. */
+		BUILD_BUG_ON(__START_KERNEL <= __START_KERNEL_map);
+		addr = page[pmd_index(__START_KERNEL_map)];
+		addr_to_page(addr, pg);
+		pte.pte = pg[pte_index(__START_KERNEL_map)];
+		BUG_ON(!(pte.pte & _PAGE_PRESENT));
+
+		/* If _PAGE_USER isn't set, we obviously do not need it. */
+		if (pte.pte & _PAGE_USER) {
+			/* _PAGE_USER is needed, but is it set implicitly? */
+			pte.pte &= ~_PAGE_USER;
+			if ((HYPERVISOR_update_va_mapping(__START_KERNEL_map,
+							  pte, 0) != 0) ||
+			    !(pg[pte_index(__START_KERNEL_map)] & _PAGE_USER))
+				/* We need to explicitly specify _PAGE_USER. */
+				__kernel_page_user = _PAGE_USER;
+		}
+	}
+#endif
+
+	xprintk("l4pgt: %p\n", init_level4_pgt);
+
+	/* The page tables are pre-initialized with values that are not
+	 * usable by Xen. Zero them out.
+	 */
+	memset(init_level4_pgt, 0, PAGE_SIZE);
+	memset(level3_kernel_pgt, 0, PAGE_SIZE);
+	memset(level2_kernel_pgt, 0, PAGE_SIZE);
+
+	xprintk("%s going change init_level4_pgt\n", __func__);
+
+	/* Construct mapping of initial pte page in our own directories. */
+	init_level4_pgt[pgd_index(__START_KERNEL_map)] = 
+		mk_kernel_pgd(__pa_symbol(level3_kernel_pgt));
+
+	xprintk("pointed l4 to l3kpgt\n");
+
+	xprintk("l3pgt: %p\n", level3_kernel_pgt);
+
+
+	{
+	unsigned long pi = pud_index(__START_KERNEL_map);
+	pud_t newp;
+	/*int i;
+	for (i = 0; i < PTRS_PER_PUD; i++)
+		xprintk("l3[%d] (%p)= %lx\n", i, &level3_kernel_pgt[i], (unsigned long)level3_kernel_pgt[i].pud);*/
+
+	xprintk("pud index: %lx\n", pi);
+	xprintk("writing to %p\n", &level3_kernel_pgt[pi]);
+	newp = __pud(__pa_symbol(level2_kernel_pgt) |
+		      _KERNPG_TABLE);
+	xprintk("new pud: %lx\n", (unsigned long)newp.pud);
+	level3_kernel_pgt[pi] = newp;
+
+	}
+	xprintk("pointed l3 to l2kpgt\n");
+
+	xprintk("l2pgt: %p\n", level2_kernel_pgt);
+	memcpy((void *)level2_kernel_pgt, page, PAGE_SIZE);
+	xprintk("copied l2kpgt from page\n");
+
+
+	xprintk("%s: going to pin\n", __func__);
+
+	early_make_page_readonly(init_level4_user_pgt,
+				 XENFEAT_writable_page_tables);
+	early_make_page_readonly(level3_user_pgt,
+				 XENFEAT_writable_page_tables);
+
+	xprintk("%s going to make pages readonly\n", __func__);
+	early_make_page_readonly(init_level4_pgt,
+				 XENFEAT_writable_page_tables);
+	early_make_page_readonly(level3_kernel_pgt,
+				 XENFEAT_writable_page_tables);
+	early_make_page_readonly(level2_kernel_pgt,
+				 XENFEAT_writable_page_tables);
+
+	xprintk("%s going to pin pgds\n", __func__);
+	if (!xen_feature(XENFEAT_writable_page_tables)) {
+		xprintk("kernel:\n");
+		xen_do_pin(MMUEXT_PIN_L4_TABLE, PFN_DOWN(__pa_symbol(init_level4_pgt)));
+		xprintk("user:\n");
+		xen_do_pin(MMUEXT_PIN_L4_TABLE, PFN_DOWN(__pa_symbol(init_level4_user_pgt)));
+	}
+
+
+	/*FIXME: check why this isn't set before xen_pgd_pin() on
+	 * x86_64 XenSource code
+	 */
+	xprintk("%s: set_pgd:\n", __func__);
+	set_pgd((pgd_t *)(init_level4_user_pgt + 511), 
+		mk_kernel_pgd(__pa_symbol(level3_user_pgt)));
+	xprintk("%s: returning.\n", __func__);
+
+	xprintk("going to load new pagetable:\n");
+	write_cr3(__pa(init_level4_pgt));
+	xprintk("loaded new pagetable\n");
+}
+
+
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index d4742df..89aaa58 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -53,6 +53,8 @@
 #include <xen/page.h>
 #include <xen/interface/xen.h>
 
+#include <xen/hvc-console.h>
+
 #include "multicalls.h"
 #include "mmu.h"
 
@@ -157,7 +159,21 @@ pteval_t xen_pte_val(pte_t pte)
 	return ret;
 }
 
-#ifdef CONFIG_X86_PAE
+pte_t xen_make_pte(pteval_t pte)
+{
+	if (pte & _PAGE_PRESENT) {
+		pte = phys_to_machine(XPADDR(pte)).maddr;
+		pte &= ~(_PAGE_PCD | _PAGE_PWT);
+	}
+
+	return (pte_t){ .pte = pte };
+}
+
+#if defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
+
+/*FIXME: merge functions where possible */
+
+
 void xen_set_pud(pud_t *ptr, pud_t val)
 {
 	struct multicall_space mcs;
@@ -176,6 +192,46 @@ void xen_set_pud(pud_t *ptr, pud_t val)
 	preempt_enable();
 }
 
+
+#ifdef CONFIG_X86_64
+
+void xen_set_pte(pte_t *ptep, pte_t pte)
+{
+	ptep->pte = pte.pte;
+	//smp_wmb();
+}
+
+void xen_set_pte_atomic(pte_t *ptep, pte_t pte)
+{
+	set_64bit((unsigned long *)ptep, pte_val_ma(pte));
+}
+
+void xen_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+	ptep->pte = 0;
+}
+
+void xen_set_pgd(pgd_t *ptr, pgd_t val)
+{
+	struct multicall_space mcs;
+	struct mmu_update *u;
+
+	preempt_disable();
+
+	mcs = xen_mc_entry(sizeof(*u));
+	u = mcs.args;
+
+	u->ptr = virt_to_machine(ptr).maddr;
+	u->val = pgd_val_ma(val);
+
+	MULTI_mmu_update(mcs.mc, u, 1, NULL, DOMID_SELF);
+
+	xen_mc_issue(PARAVIRT_LAZY_MMU);
+
+	preempt_enable();
+}
+#else
+
 void xen_set_pte(pte_t *ptep, pte_t pte)
 {
 	ptep->pte_high = pte.pte_high;
@@ -195,6 +251,8 @@ void xen_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 	ptep->pte_high = 0;
 }
 
+#endif
+
 void xen_pmd_clear(pmd_t *pmdp)
 {
 	xen_set_pmd(pmdp, __pmd(0));
@@ -203,6 +261,7 @@ void xen_pmd_clear(pmd_t *pmdp)
 pmdval_t xen_pmd_val(pmd_t pmd)
 {
 	unsigned long long ret = pmd.pmd;
+
 	if (ret)
 		ret = machine_to_phys(XMADDR(ret)).paddr | 1;
 	return ret;
@@ -216,16 +275,6 @@ pgdval_t xen_pgd_val(pgd_t pgd)
 	return ret;
 }
 
-pte_t xen_make_pte(pteval_t pte)
-{
-	if (pte & _PAGE_PRESENT) {
-		pte = phys_to_machine(XPADDR(pte)).maddr;
-		pte &= ~(_PAGE_PCD | _PAGE_PWT);
-	}
-
-	return (pte_t){ .pte = pte };
-}
-
 pmd_t xen_make_pmd(pmdval_t pmd)
 {
 	if (pmd & 1)
@@ -241,7 +290,9 @@ pgd_t xen_make_pgd(pgdval_t pgd)
 
 	return (pgd_t){ pgd };
 }
+
 #else  /* !PAE */
+
 void xen_set_pte(pte_t *ptep, pte_t pte)
 {
 	*ptep = pte;
@@ -255,16 +306,6 @@ pgdval_t xen_pgd_val(pgd_t pgd)
 	return ret;
 }
 
-pte_t xen_make_pte(pteval_t pte)
-{
-	if (pte & _PAGE_PRESENT) {
-		pte = phys_to_machine(XPADDR(pte)).maddr;
-		pte &= ~(_PAGE_PCD | _PAGE_PWT);
-	}
-
-	return (pte_t){ pte };
-}
-
 pgd_t xen_make_pgd(pgdval_t pgd)
 {
 	if (pgd & _PAGE_PRESENT)
@@ -272,6 +313,7 @@ pgd_t xen_make_pgd(pgdval_t pgd)
 
 	return (pgd_t){ pgd };
 }
+
 #endif	/* CONFIG_X86_PAE */
 
 /*
@@ -368,7 +410,7 @@ static void do_unlock(void *v)
 	spin_unlock(ptl);
 }
 
-static void xen_do_pin(unsigned level, unsigned long pfn)
+void xen_do_pin(unsigned level, unsigned long pfn)
 {
 	struct mmuext_op *op;
 	struct multicall_space mcs;
diff --git a/arch/x86/xen/mmu.h b/arch/x86/xen/mmu.h
index ce425a4..62a325c 100644
--- a/arch/x86/xen/mmu.h
+++ b/arch/x86/xen/mmu.h
@@ -36,13 +36,17 @@ void xen_exit_mmap(struct mm_struct *mm);
 
 void xen_pgd_pin(pgd_t *pgd);
 //void xen_pgd_unpin(pgd_t *pgd);
+//
+void xen_do_pin(unsigned level, unsigned long pfn);
 
 pteval_t xen_pte_val(pte_t);
 pmdval_t xen_pmd_val(pmd_t);
+pudval_t xen_pud_val(pud_t);
 pgdval_t xen_pgd_val(pgd_t);
 
 pte_t xen_make_pte(pteval_t);
 pmd_t xen_make_pmd(pmdval_t);
+pud_t xen_make_pud(pudval_t);
 pgd_t xen_make_pgd(pgdval_t);
 
 #ifdef CONFIG_X86_PAE
@@ -55,4 +59,8 @@ void xen_pmd_clear(pmd_t *pmdp);
 
 #endif
 
+#ifdef CONFIG_X86_64
+void xen_set_pgd(pgd_t *pgdp, pgd_t pgdval);
+#endif
+
 #endif	/* _XEN_MMU_H */
diff --git a/arch/x86/xen/multicalls.c b/arch/x86/xen/multicalls.c
index 5e6f36f..c96a8b0 100644
--- a/arch/x86/xen/multicalls.c
+++ b/arch/x86/xen/multicalls.c
@@ -24,6 +24,8 @@
 
 #include <asm/xen/hypercall.h>
 
+#include <xen/hvc-console.h>
+
 #include "multicalls.h"
 
 #define MC_DEBUG	1
@@ -60,6 +62,8 @@ void xen_mc_flush(void)
 	   something in the middle */
 	local_irq_save(flags);
 
+	xprintk("xen_mc_flush called. mcidx: %u\n", b->mcidx);
+
 	if (b->mcidx) {
 #if MC_DEBUG
 		memcpy(b->debug, b->entries,
@@ -72,19 +76,20 @@ void xen_mc_flush(void)
 			if (b->entries[i].result < 0)
 				ret++;
 
-#if MC_DEBUG
+		xprintk("multicall ret: %d\n", ret);
+//#if MC_DEBUG
 		if (ret) {
-			printk(KERN_ERR "%d multicall(s) failed: cpu %d\n",
+			xprintk("%d multicall(s) failed: cpu %d\n",
 			       ret, smp_processor_id());
 			for(i = 0; i < b->mcidx; i++) {
-				printk("  call %2d/%d: op=%lu arg=[%lx] result=%ld\n",
+				xprintk("  call %2d/%d: op=%lu arg=[%lx] result=%ld\n",
 				       i+1, b->mcidx,
 				       b->debug[i].op,
 				       b->debug[i].args[0],
 				       b->entries[i].result);
 			}
 		}
-#endif
+//#endif
 
 		b->mcidx = 0;
 		b->argidx = 0;
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index b02a909..f062eab 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -2,6 +2,13 @@
 #define XEN_OPS_H
 
 #include <linux/init.h>
+#include <linux/types.h>
+
+#include <xen/interface/xen.h>
+
+#include <asm/xen/interface.h>
+
+#include <asm/percpu.h>
 
 /* These are code, but not functions.  Defined in entry.S */
 extern const char xen_hypervisor_callback[];
diff --git a/include/xen/page.h b/include/xen/page.h
index 7bf5b56..8008734 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -8,6 +8,10 @@
 
 #include <xen/features.h>
 
+#include <asm/xen/interface.h>
+
+#include <xen/hvc-console.h>
+
 #ifdef CONFIG_X86_PAE
 /* Xen machine address */
 typedef struct xmaddr {
@@ -70,6 +74,8 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
 #endif
 
 	pfn = 0;
+	xprintk("mfn_to_pfn(%lx):\n", mfn);
+
 	/*
 	 * The array access can fail (e.g., device space beyond end of RAM).
 	 * In such cases it doesn't matter what we return (we return garbage),
@@ -77,6 +83,7 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
 	 */
 	__get_user(pfn, &machine_to_phys_mapping[mfn]);
 
+	xprintk("mfn_to_pfn(%lx) = %lx\n", mfn, pfn);
 	return pfn;
 }
 
@@ -154,7 +161,6 @@ static inline pteval_t pte_val_ma(pte_t x)
 {
 	return native_pte_val(x);
 }
-#define pud_val_ma(v) ((v).pgd.pgd)
 #define __pte_ma(x)	(native_make_pte(x))
 #define __pmd_ma(x)	((pmd_t) { (x) } )
 #else  /* !X86_PAE */
@@ -166,6 +172,7 @@ static inline pteval_t pte_val_ma(pte_t x)
 
 #define pgd_val_ma(x)	((x).pgd)
 #define pmd_val_ma(x)	(native_pmd_val((x)))
+#define pud_val_ma(x)	(native_pud_val((x)))
 
 
 xmaddr_t arbitrary_virt_to_machine(unsigned long address);
-- 
1.5.4.1


linux-2.6-xen-0060-Hack-disable-vsmp.patch:

--- NEW FILE linux-2.6-xen-0060-Hack-disable-vsmp.patch ---
>From bebca8add50a5a7d8c4e4f0d6208a9a31f121ea6 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 12 Dec 2007 16:19:02 -0200
Subject: [PATCH] Hack: disable vsmp

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 3daae55..f18418d 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -327,6 +327,7 @@ config X86_RDC321X
 
 config X86_VSMP
 	bool "Support for ScaleMP vSMP"
+	depends on !XEN
 	depends on X86_64 && PCI
 	 help
 	  Support for ScaleMP vSMP systems.  Say 'Y' here if this kernel is
-- 
1.5.4.1


linux-2.6-xen-0061-Export-early_make_page_readonly.patch:

--- NEW FILE linux-2.6-xen-0061-Export-early_make_page_readonly.patch ---
>From d01f6ebf8fb4665f9d1aae933585430fa8a70e57 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 12 Dec 2007 16:23:34 -0200
Subject: [PATCH] Export early_make_page_readonly()

Used by mm/init_64.c

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/init.h    |    3 +++
 arch/x86/xen/init_64.c |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/init.h b/arch/x86/xen/init.h
index 9cd3954..ee22051 100644
--- a/arch/x86/xen/init.h
+++ b/arch/x86/xen/init.h
@@ -6,5 +6,8 @@ void xen_init_pt(void);
 extern pud_t level3_user_pgt[512];
 extern pgd_t init_level4_user_pgt[];
 
+extern unsigned long start_pfn;
+
+void early_make_page_readonly(void *va, unsigned int feature);
 
 #endif /* __X86_XEN_INIT_H */
diff --git a/arch/x86/xen/init_64.c b/arch/x86/xen/init_64.c
index f025c21..872c152 100644
--- a/arch/x86/xen/init_64.c
+++ b/arch/x86/xen/init_64.c
@@ -18,7 +18,7 @@
 	__START_KERNEL_map)))
 
 
-static void __meminit early_make_page_readonly(void *va, unsigned int feature)
+void __meminit early_make_page_readonly(void *va, unsigned int feature)
 {
 	unsigned long addr, _va = (unsigned long)va;
 	int r;
-- 
1.5.4.1


linux-2.6-xen-0062-Disable-multicalls.c-too-verbose-debugging.patch:

--- NEW FILE linux-2.6-xen-0062-Disable-multicalls.c-too-verbose-debugging.patch ---
>From 61a44cf3cea3298070550a5a639e6e385258d93a Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 12 Dec 2007 16:24:08 -0200
Subject: [PATCH] Disable multicalls.c too-verbose debugging

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/multicalls.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/xen/multicalls.c b/arch/x86/xen/multicalls.c
index c96a8b0..7506e59 100644
--- a/arch/x86/xen/multicalls.c
+++ b/arch/x86/xen/multicalls.c
@@ -62,7 +62,7 @@ void xen_mc_flush(void)
 	   something in the middle */
 	local_irq_save(flags);
 
-	xprintk("xen_mc_flush called. mcidx: %u\n", b->mcidx);
+	//xprintk("xen_mc_flush called. mcidx: %u\n", b->mcidx);
 
 	if (b->mcidx) {
 #if MC_DEBUG
@@ -76,8 +76,8 @@ void xen_mc_flush(void)
 			if (b->entries[i].result < 0)
 				ret++;
 
-		xprintk("multicall ret: %d\n", ret);
-//#if MC_DEBUG
+		//xprintk("multicall ret: %d\n", ret);
+#if MC_DEBUG
 		if (ret) {
 			xprintk("%d multicall(s) failed: cpu %d\n",
 			       ret, smp_processor_id());
@@ -89,7 +89,7 @@ void xen_mc_flush(void)
 				       b->entries[i].result);
 			}
 		}
-//#endif
+#endif
 
 		b->mcidx = 0;
 		b->argidx = 0;
-- 
1.5.4.1


linux-2.6-xen-0063-Xen-64-bit-ready-MMU-operations.patch:

--- NEW FILE linux-2.6-xen-0063-Xen-64-bit-ready-MMU-operations.patch ---
>From 4dc0725dc209e925d1995083fb1f83accfe20f60 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 12:00:39 -0200
Subject: [PATCH] Xen 64-bit-ready MMU operations

Lots of unification of functions.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |   18 +++---
 arch/x86/xen/mmu.c       |  136 +++++++++++++++++++++++-----------------------
 arch/x86/xen/mmu.h       |   26 +++++-----
 3 files changed, 90 insertions(+), 90 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 89dd8d7..8421216 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1214,23 +1214,23 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = {
 	.make_pte = xen_make_pte,
 	.make_pgd = xen_make_pgd,
 
-#ifdef CONFIG_X86_32
-#  ifdef CONFIG_X86_PAE
+#ifdef CONFIG_X86_PAE
 	.set_pte_atomic = xen_set_pte_atomic,
 	.set_pte_present = xen_set_pte_at,
-	.set_pud = xen_set_pud,
 	.pte_clear = xen_pte_clear,
 	.pmd_clear = xen_pmd_clear,
 
-	.make_pmd = xen_make_pmd,
-	.pmd_val = xen_pmd_val,
-#  endif	/* PAE */
-#else
-	.set_pgd = xen_set_pgd,
-	.make_pud = xen_make_pud,
+#endif	/* PAE */
 
+#if PAGETABLE_LEVELS >= 3
 	.make_pmd = xen_make_pmd,
 	.pmd_val = xen_pmd_val,
+	.set_pud = xen_set_pud,
+#endif
+#if PAGETABLE_LEVELS >= 4
+	.make_pud = xen_make_pud,
+	.pud_val = xen_pud_val,
+	.set_pgd = xen_set_pgd,
 #endif
 
 	.activate_mm = xen_activate_mm,
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 89aaa58..1880f9f 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -169,9 +169,29 @@ pte_t xen_make_pte(pteval_t pte)
 	return (pte_t){ .pte = pte };
 }
 
-#if defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
+/*FIXME: re-check all pgtable functions and the patches that touch them */
+
+#if PAGETABLE_LEVELS >= 3
+
+pmdval_t xen_pmd_val(pmd_t pmd)
+{
+	pmdval_t ret = pmd_val_ma(pmd);
+
+	/*FIXME: handle attr bits properly (especially NX) */
+	if (ret & _PAGE_PRESENT)
+		ret = machine_to_phys(XMADDR(ret)).paddr | 1;
+	return ret;
+}
+
+pmd_t xen_make_pmd(pmdval_t pmd)
+{
+	/*FIXME: handle attr bits properly (especially NX) */
+	if (pmd & _PAGE_PRESENT)
+		pmd = phys_to_machine(XPADDR(pmd)).maddr;
+
+	return (pmd_t){ pmd };
+}
 
-/*FIXME: merge functions where possible */
 
 
 void xen_set_pud(pud_t *ptr, pud_t val)
@@ -192,23 +212,28 @@ void xen_set_pud(pud_t *ptr, pud_t val)
 	preempt_enable();
 }
 
+#endif
 
-#ifdef CONFIG_X86_64
 
-void xen_set_pte(pte_t *ptep, pte_t pte)
-{
-	ptep->pte = pte.pte;
-	//smp_wmb();
-}
+#if PAGETABLE_LEVELS >= 4
 
-void xen_set_pte_atomic(pte_t *ptep, pte_t pte)
+pudval_t xen_pud_val(pud_t pud)
 {
-	set_64bit((unsigned long *)ptep, pte_val_ma(pte));
+	pudval_t ret = pud_val_ma(pud);
+
+	/*FIXME: handle attr bits properly (especially NX) */
+	if (ret)
+		ret = machine_to_phys(XMADDR(ret)).paddr | 1;
+	return ret;
 }
 
-void xen_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+pud_t xen_make_pud(pudval_t pud)
 {
-	ptep->pte = 0;
+	/*FIXME: handle attr bits properly (especially NX) */
+	if (pud & _PAGE_PRESENT)
+		pud = phys_to_machine(XPADDR(pud)).maddr;
+
+	return native_make_pud(pud);
 }
 
 void xen_set_pgd(pgd_t *ptr, pgd_t val)
@@ -230,91 +255,66 @@ void xen_set_pgd(pgd_t *ptr, pgd_t val)
 
 	preempt_enable();
 }
-#else
 
-void xen_set_pte(pte_t *ptep, pte_t pte)
-{
-	ptep->pte_high = pte.pte_high;
-	smp_wmb();
-	ptep->pte_low = pte.pte_low;
-}
+#endif
 
-void xen_set_pte_atomic(pte_t *ptep, pte_t pte)
+pgdval_t xen_pgd_val(pgd_t pgd)
 {
-	set_64bit((u64 *)ptep, pte_val_ma(pte));
+	pgdval_t ret = pgd_val_ma(pgd);
+
+	/*FIXME: handle attr bits properly (especially NX) */
+	if (ret & _PAGE_PRESENT)
+		ret = machine_to_phys(XMADDR(ret)).paddr | 1;
+	return ret;
 }
 
-void xen_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+pgd_t xen_make_pgd(pgdval_t pgd)
 {
-	ptep->pte_low = 0;
-	smp_wmb();		/* make sure low gets written first */
-	ptep->pte_high = 0;
+	/*FIXME: handle attr bits properly (especially NX) */
+	if (pgd & _PAGE_PRESENT)
+		pgd = phys_to_machine(XPADDR(pgd)).maddr;
+
+	return native_make_pgd(pgd);
 }
 
-#endif
 
-void xen_pmd_clear(pmd_t *pmdp)
-{
-	xen_set_pmd(pmdp, __pmd(0));
-}
+#ifdef CONFIG_X86_PAE
 
-pmdval_t xen_pmd_val(pmd_t pmd)
-{
-	unsigned long long ret = pmd.pmd;
+/* Some operations need special handling on x86_32 under PAE */
 
-	if (ret)
-		ret = machine_to_phys(XMADDR(ret)).paddr | 1;
-	return ret;
+void xen_set_pte(pte_t *ptep, pte_t pte)
+{
+	ptep->pte_high = pte.pte_high;
+	smp_wmb();
+	ptep->pte_low = pte.pte_low;
 }
 
-pgdval_t xen_pgd_val(pgd_t pgd)
+void xen_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
-	unsigned long long ret = pgd.pgd;
-	if (ret)
-		ret = machine_to_phys(XMADDR(ret)).paddr | 1;
-	return ret;
+	ptep->pte_low = 0;
+	smp_wmb();		/* make sure low gets written first */
+	ptep->pte_high = 0;
 }
 
-pmd_t xen_make_pmd(pmdval_t pmd)
+void xen_set_pte_atomic(pte_t *ptep, pte_t pte)
 {
-	if (pmd & 1)
-		pmd = phys_to_machine(XPADDR(pmd)).maddr;
-
-	return (pmd_t){ pmd };
+	set_64bit((u64 *)ptep, pte_val_ma(pte));
 }
 
-pgd_t xen_make_pgd(pgdval_t pgd)
+void xen_pmd_clear(pmd_t *pmdp)
 {
-	if (pgd & _PAGE_PRESENT)
-		pgd = phys_to_machine(XPADDR(pgd)).maddr;
-
-	return (pgd_t){ pgd };
+	xen_set_pmd(pmdp, __pmd(0));
 }
 
-#else  /* !PAE */
+#else  /* non-PAE */
 
 void xen_set_pte(pte_t *ptep, pte_t pte)
 {
 	*ptep = pte;
 }
 
-pgdval_t xen_pgd_val(pgd_t pgd)
-{
-	unsigned long ret = pgd.pgd;
-	if (ret)
-		ret = machine_to_phys(XMADDR(ret)).paddr | 1;
-	return ret;
-}
-
-pgd_t xen_make_pgd(pgdval_t pgd)
-{
-	if (pgd & _PAGE_PRESENT)
-		pgd = phys_to_machine(XPADDR(pgd)).maddr;
-
-	return (pgd_t){ pgd };
-}
+#endif
 
-#endif	/* CONFIG_X86_PAE */
 
 /*
   (Yet another) pagetable walker.  This one is intended for pinning a
diff --git a/arch/x86/xen/mmu.h b/arch/x86/xen/mmu.h
index 62a325c..b25b8e4 100644
--- a/arch/x86/xen/mmu.h
+++ b/arch/x86/xen/mmu.h
@@ -28,7 +28,6 @@ void set_pte_mfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags);
 void xen_set_pte(pte_t *ptep, pte_t pteval);
 void xen_set_pte_at(struct mm_struct *mm, unsigned long addr,
 		    pte_t *ptep, pte_t pteval);
-void xen_set_pmd(pmd_t *pmdp, pmd_t pmdval);
 
 void xen_activate_mm(struct mm_struct *prev, struct mm_struct *next);
 void xen_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm);
@@ -40,27 +39,28 @@ void xen_pgd_pin(pgd_t *pgd);
 void xen_do_pin(unsigned level, unsigned long pfn);
 
 pteval_t xen_pte_val(pte_t);
-pmdval_t xen_pmd_val(pmd_t);
-pudval_t xen_pud_val(pud_t);
-pgdval_t xen_pgd_val(pgd_t);
-
 pte_t xen_make_pte(pteval_t);
+void xen_set_pmd(pmd_t *pmdp, pmd_t pmdval);
+
+#if PAGETABLE_LEVELS >= 3
+pmdval_t xen_pmd_val(pmd_t);
 pmd_t xen_make_pmd(pmdval_t);
+void xen_set_pud(pud_t *ptr, pud_t val);
+#endif
+
+#if PAGETABLE_LEVELS >= 4
+pudval_t xen_pud_val(pud_t);
 pud_t xen_make_pud(pudval_t);
+void xen_set_pgd(pgd_t *pgdp, pgd_t pgdval);
+#endif
+
+pgdval_t xen_pgd_val(pgd_t);
 pgd_t xen_make_pgd(pgdval_t);
 
 #ifdef CONFIG_X86_PAE
-void xen_set_pte_at(struct mm_struct *mm, unsigned long addr,
-		    pte_t *ptep, pte_t pteval);
 void xen_set_pte_atomic(pte_t *ptep, pte_t pte);
-void xen_set_pud(pud_t *ptr, pud_t val);
 void xen_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
 void xen_pmd_clear(pmd_t *pmdp);
-
-#endif
-
-#ifdef CONFIG_X86_64
-void xen_set_pgd(pgd_t *pgdp, pgd_t pgdval);
 #endif
 
 #endif	/* _XEN_MMU_H */
-- 
1.5.4.1


linux-2.6-xen-0064-Some-xen-mmu-pv-ops-implemented.patch:

--- NEW FILE linux-2.6-xen-0064-Some-xen-mmu-pv-ops-implemented.patch ---
>From 6a4ce474f2e1f08f3347753ee4ed4cbcdce877a0 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 12 Dec 2007 16:26:01 -0200
Subject: [PATCH] Some xen mmu pv-ops implemented

- Lots of debugging messages
- Lots of #ifdefs

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 8421216..5bd8265 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1369,12 +1369,19 @@ asmlinkage void __init xen_start_kernel(void)
 	init_pg_tables_end = __pa(pgd) + xen_start_info->nr_pt_frames*PAGE_SIZE;
 #endif
 
+#ifdef CONFIG_X86_64
+	/* used by alloc_low_page() */
+	start_pfn = PFN_UP(__pa_symbol(xen_start_info->pt_base)) + xen_start_info->nr_pt_frames;
+#endif
+
+#ifdef CONFIG_X86_32
 	init_mm.pgd = pgd; /* use the Xen pagetables to start */
 
 	/* keep using Xen gdt for now; no urgent need to change it */
 
 	x86_write_percpu(xen_cr3, __pa(pgd));
 	x86_write_percpu(xen_current_cr3, __pa(pgd));
+#endif
 
 	/* Don't do the full vcpu_info placement stuff until we have a
 	   possible map and a non-dummy shared_info. */
-- 
1.5.4.1


linux-2.6-xen-0065-Trying-to-make-the-pagetable-initialization-code-wor.patch:

--- NEW FILE linux-2.6-xen-0065-Trying-to-make-the-pagetable-initialization-code-wor.patch ---
>From 43a60e1c574bee942f1848ab6202d4e6e18fab94 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 12 Dec 2007 16:26:56 -0200
Subject: [PATCH] Trying to make the pagetable initialization code work under Xen

To be fixed:

- Lots of #ifdef CONFIG_XEN that will break bare metal
- Make it actually work

Wrt. pse_available() in pgtable_64.h:

- Probably we may use the CPU feature code to handle this
- We need it to be variable (not constant 0) if Xen is supported

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c        |  153 ++++++++++++++++++++++++++++++++++++++++--
 include/asm-x86/paravirt.h   |   10 +++
 include/asm-x86/pgalloc_64.h |    1 +
 include/asm-x86/pgtable.h    |    4 +
 4 files changed, 161 insertions(+), 7 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index b5f1f6e..69d1056 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -47,6 +47,22 @@
 #include <asm/numa.h>
 #include <asm/cacheflush.h>
 
+#ifdef CONFIG_XEN
+/*FIXME: ouch. */
+#include <xen/features.h>
+#include <xen/page.h>
+#include <xen/hvc-console.h>
+#include <asm/xen/hypercall.h>
+#include "../xen/init.h"
+#include "../xen/xen-ops.h"
+#endif
+
+#ifdef CONFIG_XEN
+/*FIXME: ouch again */
+#define PTE_SIZE  PAGE_SIZE
+#else
+#endif
+
 const struct dma_mapping_ops *dma_ops;
 EXPORT_SYMBOL(dma_ops);
 
@@ -102,6 +118,9 @@ void show_mem(void)
 
 int after_bootmem;
 
+static unsigned long __initdata table_start;
+static unsigned long __meminitdata table_end;
+
 static __init void *spp_getpage(void)
 {
 	void *ptr;
@@ -232,8 +251,75 @@ native_set_fixmap(enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
 	__native_set_fixmap(idx, pfn_pte(phys >> PAGE_SHIFT, prot));
 }
 
-static unsigned long __initdata table_start;
-static unsigned long __meminitdata table_end;
+
+#ifdef CONFIG_XEN
+
+/*FIXME: this code should be enabled at runtime, somehow */
+
+unsigned long start_pfn;
+
+static __meminit void *alloc_low_page(unsigned long *phys)
+{
+	unsigned long pfn;
+	void *adr;
+
+	if (after_bootmem) {
+		adr = (void *)get_zeroed_page(GFP_ATOMIC);
+		*phys = __pa(adr);
+		return adr;
+	}
+
+	pfn = start_pfn++;
+	*phys  = pfn << PAGE_SHIFT;
+
+	/* The address returned by __va() is not available yet.
+	 * This function is used by init_memory_mapping(). We will
+	 * use the mapping that was set by Xen for us.
+	 */
+	adr = (void*)((*phys) + __START_KERNEL_map);
+	memset(adr, 0, PAGE_SIZE);
+
+	return adr;
+}
+
+
+static inline void __set_pte(pte_t *dst, pte_t val)
+{
+	*dst = val;
+}
+
+
+int make_readonly(unsigned long paddr)
+{
+	extern char __vsyscall_0;
+	int readonly = 0;
+
+	/* Make new page tables read-only. */
+	if (!xen_feature(XENFEAT_writable_page_tables)
+	    && (paddr >= (table_start << PAGE_SHIFT))
+	    && (paddr < (table_end << PAGE_SHIFT)))
+		readonly = 1;
+	/* Make old page tables read-only. */
+	if (!xen_feature(XENFEAT_writable_page_tables)
+	    && (paddr >= (xen_start_info->pt_base - __START_KERNEL_map))
+	    && (paddr < (start_pfn << PAGE_SHIFT)))
+		readonly = 1;
+
+	/*
+	 * No need for writable mapping of kernel image. This also ensures that
+	 * page and descriptor tables embedded inside don't have writable
+	 * mappings. Exclude the vsyscall area here, allowing alternative
+	 * instruction patching to work.
+	 */
+	if ((paddr >= __pa_symbol(&_text)) && (paddr < __pa_symbol(&_end))
+	    && !(paddr >= __pa_symbol(&__vsyscall_0)
+	         && paddr < __pa_symbol(&__vsyscall_0) + PAGE_SIZE))
+		readonly = 1;
+
+	return readonly;
+}
+
+#else /* !XEN */
 
 static __meminit void *alloc_low_page(unsigned long *phys)
 {
@@ -256,12 +342,18 @@ static __meminit void *alloc_low_page(unsigned long *phys)
 	return adr;
 }
 
+#endif  /* !XEN */
+
+
 static __meminit void unmap_low_page(void *adr)
 {
 	if (after_bootmem)
 		return;
 
+#ifndef CONFIG_XEN
+	/*FIXME: this behaviour should be changed in runtime, also */
 	early_iounmap(adr, PAGE_SIZE);
+#endif
 }
 
 /* Must run before zap_low_mappings */
@@ -284,8 +376,9 @@ __meminit void *early_ioremap(unsigned long addr, unsigned long size)
 		vaddr += addr & ~PMD_MASK;
 		addr &= PMD_MASK;
 
-		for (i = 0; i < pmds; i++, addr += PMD_SIZE)
+		for (i = 0; i < pmds; i++, addr += PMD_SIZE) {
 			set_pmd(pmd+i, __pmd(addr | __PAGE_KERNEL_LARGE_EXEC));
+		} /* for pmds */
 		__flush_tlb_all();
 
 		return (void *)vaddr;
@@ -321,7 +414,7 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end)
 {
 	int i = pmd_index(address);
 
-	for (; i < PTRS_PER_PMD; i++, address += PMD_SIZE) {
+	for (; i < PTRS_PER_PMD; i++) {
 		pmd_t *pmd = pmd_page + pmd_index(address);
 
 		if (address >= end) {
@@ -335,8 +428,46 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end)
 		if (pmd_val(*pmd))
 			continue;
 
-		set_pte((pte_t *)pmd,
-			pfn_pte(address >> PAGE_SHIFT, PAGE_KERNEL_LARGE));
+		if (pse_available()) {
+			/* Lucky us :) */
+			set_pte((pte_t *)pmd,
+				pfn_pte(address >> PAGE_SHIFT,
+				PAGE_KERNEL_LARGE));
+			address += PMD_SIZE;
+		} else {
+			/* No PSE support. Must make lots of PTEs */
+			unsigned long pte_phys;
+			pte_t *pte, *pte_save;
+			int k;
+
+			pte = alloc_low_page(&pte_phys);
+			pte_save = pte;
+			for (k = 0; k < PTRS_PER_PTE; pte++, k++, address += PTE_SIZE) {
+				pteval_t attrs;
+				if ((address >= end)) {
+					__set_pte(pte, __pte(0));
+					continue;
+				}
+
+				/*FIXME: _PAGE_GLOBAL is skipped here,
+				 * but this is Xen-specific. Use pvops
+				 * to handle this
+				 */
+				attrs = __PAGE_KERNEL;
+
+				/*FIXME: somehow we need to make those
+				 * pages readonly on some other place
+				 */
+				if (make_readonly(address))
+					attrs &= ~_PAGE_RW;
+				__set_pte(pte, __pte(address | attrs));
+			}
+			pte = pte_save;
+
+			/*FIXME: this should be done somewhere else */
+			early_make_page_readonly(pte, XENFEAT_writable_page_tables);
+			set_pmd(pmd, pfn_pmd(pte_phys>>PAGE_SHIFT, PAGE_KERNEL));
+		} /* !pse_available() */
 	}
 }
 
@@ -363,11 +494,14 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end)
 		if (addr >= end)
 			break;
 
+#ifndef CONFIG_XEN
+		/*FIXME: how to make this enabled on runtime */
 		if (!after_bootmem &&
 				!e820_any_mapped(addr, addr+PUD_SIZE, 0)) {
 			set_pud(pud, __pud(0));
 			continue;
 		}
+#endif
 
 		if (pud_val(*pud)) {
 			phys_pmd_update(pud, addr, end);
@@ -375,6 +509,8 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end)
 		}
 
 		pmd = alloc_low_page(&pmd_phys);
+		/*FIXME: this (making page readonly) should be done somewhere else */
+		early_make_page_readonly(pmd, XENFEAT_writable_page_tables);
 
 		spin_lock(&init_mm.page_table_lock);
 		set_pud(pud, __pud(pmd_phys | _KERNPG_TABLE));
@@ -440,8 +576,11 @@ void __init_refok init_memory_mapping(unsigned long start, unsigned long end)
 
 		if (after_bootmem)
 			pud = pud_offset(pgd, start & PGDIR_MASK);
-		else
+		else {
 			pud = alloc_low_page(&pud_phys);
+			/*FIXME: this (making page readonly) should be done somewhere else */
+			early_make_page_readonly(pud, XENFEAT_writable_page_tables);
+		}
 
 		next = start + PGDIR_SIZE;
 		if (next > end)
diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
index c7c4e34..7edbeda 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -153,6 +153,16 @@ struct pv_cpu_ops {
 	struct pv_lazy_ops lazy_mode;
 };
 
+
+#ifdef CONFIG_XEN
+/*FIXME: return 0 only if we are really running under Xen */
+#define pse_available() (0)
+#else
+/* No Xen support, PSE is always available */
+#define pse_available() (1)
+#endif
+
+
 struct pv_irq_ops {
 	void (*init_IRQ)(void);
 
diff --git a/include/asm-x86/pgalloc_64.h b/include/asm-x86/pgalloc_64.h
index 982e1cb..b9835d6 100644
--- a/include/asm-x86/pgalloc_64.h
+++ b/include/asm-x86/pgalloc_64.h
@@ -2,6 +2,7 @@
 #define _X86_64_PGALLOC_H
 
 #include <asm/pda.h>
+#include <asm/vsyscall.h>
 #include <linux/threads.h>
 #include <linux/mm.h>
 
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 9cf472a..6b3979e 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -232,6 +232,10 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 
 #define pte_update(mm, addr, ptep)              do { } while (0)
 #define pte_update_defer(mm, addr, ptep)        do { } while (0)
+
+/*FIXME: this have a better place than here */
+#define pse_available() (1)
+
 #endif	/* CONFIG_PARAVIRT */
 
 #endif	/* __ASSEMBLY__ */
-- 
1.5.4.1


linux-2.6-xen-0066-Xen-specific-find_early_table_space-FIXME.patch:

--- NEW FILE linux-2.6-xen-0066-Xen-specific-find_early_table_space-FIXME.patch ---
>From 406d83cc45d7167497099b15c69fbfed5a0b5120 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 12:15:58 -0200
Subject: [PATCH] Xen-specific find_early_table_space() (FIXME)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 69d1056..a6f2051 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -522,6 +522,35 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end)
 	__flush_tlb_all();
 }
 
+#ifdef CONFIG_XEN
+/*FIXME: Yet Another Xen #ifdef that needs to be done at runtime */
+
+static void __init find_early_table_space(unsigned long end)
+{
+	unsigned long puds, pmds, ptes, tables;
+
+	puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
+	pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
+	ptes = (end + PTE_SIZE - 1) >> PAGE_SHIFT;
+
+	tables = round_up(puds * 8, PAGE_SIZE) + 
+		round_up(pmds * 8, PAGE_SIZE) + 
+		round_up(ptes * 8, PAGE_SIZE); 
+
+	/*FIXME: what does this do? */
+	//extend_init_mapping(tables);
+
+	table_start = start_pfn;
+	table_end = table_start + (tables>>PAGE_SHIFT);
+
+	early_printk("kernel direct mapping tables up to %lx @ %lx-%lx\n",
+		end, table_start << PAGE_SHIFT,
+		(table_start << PAGE_SHIFT) + tables);
+}
+
+
+#else /* XEN */
+
 static void __init find_early_table_space(unsigned long end)
 {
 	unsigned long puds, pmds, tables, start;
@@ -545,6 +574,8 @@ static void __init find_early_table_space(unsigned long end)
 	table_end = table_start;
 }
 
+#endif /* !XEN */
+
 /*
  * Setup the direct mapping of the physical memory at PAGE_OFFSET.
  * This runs before bootmem is initialized and gets pages directly from
-- 
1.5.4.1


linux-2.6-xen-0067-Xen-call-e820_print_map-when-setting-up-memory.patch:

--- NEW FILE linux-2.6-xen-0067-Xen-call-e820_print_map-when-setting-up-memory.patch ---
>From f9d2cd995ebcd5c0bc907b7cd87d6a1e35ea891a Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 17 Dec 2007 18:08:13 -0200
Subject: [PATCH] Xen: call e820_print_map() when setting up memory

The memory_setup() behaviour of x86_64 is different, right now.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/setup.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 7b66f26..2216e44 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -20,6 +20,8 @@
 #include <xen/interface/physdev.h>
 #include <xen/features.h>
 
+#include <asm/proto.h>
+
 #include "xen-ops.h"
 #include "vdso.h"
 
@@ -46,6 +48,10 @@ char * __init xen_memory_setup(void)
 	add_memory_region(0, PFN_PHYS(max_pfn), E820_RAM);
 #endif
 
+#ifdef CONFIG_X86_64
+	early_printk(KERN_INFO "Xen-provided physical RAM map:\n");
+	e820_print_map("Xen");
+#endif
 	return "Xen";
 }
 
-- 
1.5.4.1


linux-2.6-xen-0068-Comment-debugging-msgs.patch:

--- NEW FILE linux-2.6-xen-0068-Comment-debugging-msgs.patch ---
>From 76ca974f9867287440aa08235f781aedd05753e3 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 17 Dec 2007 18:08:43 -0200
Subject: [PATCH] Comment debugging msgs

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/xen/page.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/xen/page.h b/include/xen/page.h
index 8008734..158fb60 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -74,7 +74,7 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
 #endif
 
 	pfn = 0;
-	xprintk("mfn_to_pfn(%lx):\n", mfn);
+	//xprintk("mfn_to_pfn(%lx):\n", mfn);
 
 	/*
 	 * The array access can fail (e.g., device space beyond end of RAM).
@@ -83,7 +83,7 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
 	 */
 	__get_user(pfn, &machine_to_phys_mapping[mfn]);
 
-	xprintk("mfn_to_pfn(%lx) = %lx\n", mfn, pfn);
+	//xprintk("mfn_to_pfn(%lx) = %lx\n", mfn, pfn);
 	return pfn;
 }
 
-- 
1.5.4.1


linux-2.6-xen-0069-Try-to-make-pagetables-read-only.patch:

--- NEW FILE linux-2.6-xen-0069-Try-to-make-pagetables-read-only.patch ---
>From e0d1c1ba95d26f55d787982e65ed6d851f3f3cd3 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 18 Dec 2007 10:21:45 -0200
Subject: [PATCH] Try to make pagetables read-only

Not working yet.  :(

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index a6f2051..cf1453b 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -70,6 +70,85 @@ static unsigned long dma_reserve __initdata;
 
 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 
+#ifdef CONFIG_XEN
+
+static void __make_page_readonly(void *va)
+{
+	pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
+	unsigned long addr = (unsigned long) va;
+
+	xprintk("%s(%p)\n", __func__, va);
+
+	pgd = pgd_offset_k(addr);
+	pud = pud_offset(pgd, addr);
+	pmd = pmd_offset(pud, addr);
+	ptep = pte_offset_kernel(pmd, addr);
+
+	pte.pte = ptep->pte & ~_PAGE_RW;
+	xprintk("update_va_mapping: %lx, %lx\n", addr, pte);
+
+	if (HYPERVISOR_update_va_mapping(addr, pte, 0))
+		BUG(); //xen_l1_entry_update(ptep, pte); /* fallback */
+
+	if ((addr >= VMALLOC_START) && (addr < VMALLOC_END))
+		__make_page_readonly(__va(pte_pfn(pte) << PAGE_SHIFT));
+}
+
+static void __make_page_writable(void *va)
+{
+	pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
+	unsigned long addr = (unsigned long) va;
+
+	pgd = pgd_offset_k(addr);
+	pud = pud_offset(pgd, addr);
+	pmd = pmd_offset(pud, addr);
+	ptep = pte_offset_kernel(pmd, addr);
+
+	pte.pte = ptep->pte | _PAGE_RW;
+	if (HYPERVISOR_update_va_mapping(addr, pte, 0))
+		BUG();//xen_l1_entry_update(ptep, pte); /* fallback */
+
+	if ((addr >= VMALLOC_START) && (addr < VMALLOC_END))
+		__make_page_writable(__va(pte_pfn(pte) << PAGE_SHIFT));
+}
+
+void make_page_readonly(void *va, unsigned int feature)
+{
+	if (!xen_feature(feature))
+		__make_page_readonly(va);
+}
+
+void make_page_writable(void *va, unsigned int feature)
+{
+	if (!xen_feature(feature))
+		__make_page_writable(va);
+}
+
+void make_pages_readonly(void *va, unsigned nr, unsigned int feature)
+{
+	if (xen_feature(feature))
+		return;
+
+	while (nr-- != 0) {
+		__make_page_readonly(va);
+		va = (void*)((unsigned long)va + PAGE_SIZE);
+	}
+}
+
+void make_pages_writable(void *va, unsigned nr, unsigned int feature)
+{
+	if (xen_feature(feature))
+		return;
+
+	while (nr-- != 0) {
+		__make_page_writable(va);
+		va = (void*)((unsigned long)va + PAGE_SIZE);
+	}
+}
+
+
+#endif
+
 /*
  * NOTE: pagetable_init alloc all the fixmap pagetables contiguous on the
  * physical space so we can cache the place of the first one and move
@@ -150,6 +229,7 @@ set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t pteval)
 	pud = pud_page + pud_index(vaddr);
 	if (pud_none(*pud)) {
 		pmd = (pmd_t *) spp_getpage();
+		make_page_readonly(pmd, XENFEAT_writable_page_tables);
 		set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE | _PAGE_USER));
 		if (pmd != pmd_offset(pud, 0)) {
 			printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
@@ -160,6 +240,7 @@ set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t pteval)
 	pmd = pmd_offset(pud, vaddr);
 	if (pmd_none(*pmd)) {
 		pte = (pte_t *) spp_getpage();
+		make_page_readonly(pte, XENFEAT_writable_page_tables);
 		set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE | _PAGE_USER));
 		if (pte != pte_offset_kernel(pmd, 0)) {
 			printk(KERN_ERR "PAGETABLE BUG #02!\n");
-- 
1.5.4.1


linux-2.6-xen-0070-Debug-dump-pgtables-on-make_page_readonly.patch:

--- NEW FILE linux-2.6-xen-0070-Debug-dump-pgtables-on-make_page_readonly.patch ---
>From 205312a7d699cbc8ea0ea6e9adccfaff798857a0 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 18 Dec 2007 12:34:36 -0200
Subject: [PATCH] Debug: dump pgtables on make_page_readonly()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index cf1453b..fddf208 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -72,6 +72,71 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 
 #ifdef CONFIG_XEN
 
+//#define vvva(p) ((void*)((p) + __START_KERNEL_map))
+#define vvva(p) __va((p))
+
+void show_pgtable1(pte_t *tbl, unsigned long addr)
+{
+	pte_t *pte = tbl + pte_index(addr);
+	pte_val_t pv;
+	unsigned long *page;
+
+	xprintk("\npte: %p\n", pte);
+	xprintk("\npte val: %lx\n", pte->pte);
+
+	pv = pte_val(*pte);
+	if (!(pv & _PAGE_PRESENT))
+		return;
+
+	page = vvva(pv & PHYSICAL_PAGE_MASK);
+
+	xprintk("\npage: %p\n", page);
+	xprintk("\npage val: %lx\n", *page);
+}
+
+void show_pgtable2(pmd_t *tbl, unsigned long addr)
+{
+	pmd_t *pmd = tbl + pmd_index(addr);
+	pmd_val_t pv;
+
+	xprintk("\npmd: %p\n", pmd);
+	xprintk("\npmd val: %lx\n", pmd->pmd);
+
+	pv = pmd_val(*pmd);
+	if (!(pv & _PAGE_PRESENT))
+		return;
+
+	show_pgtable1((pte_t*)vvva(pv & PHYSICAL_PAGE_MASK), addr);
+}
+
+void show_pgtable3(pud_t *tbl, unsigned long addr)
+{
+	pud_t *pud = tbl + pud_index(addr);
+
+	xprintk("\npud: %p\n", pud);
+	xprintk("pud value: %lx\n", pud->pud);
+
+	show_pgtable2((pmd_t*)vvva(pud_val(*pud) & PHYSICAL_PAGE_MASK), addr);
+}
+
+void show_pgtable4(pgd_t *tbl, unsigned long addr)
+{
+	pgd_t *pgd = tbl + pgd_index(addr);
+
+	xprintk("\npgd: %p\n", pgd);
+	xprintk("pgd value: %lx\n", pgd->pgd);
+
+	show_pgtable3((pud_t*)vvva(pgd_val(*pgd) & PHYSICAL_PAGE_MASK), addr);
+}
+
+void show_pgtable(unsigned long addr)
+{
+	xprintk("\nshowing pgtable for %lx\n", addr);
+
+	show_pgtable4(init_level4_pgt, addr);
+}
+
+
 static void __make_page_readonly(void *va)
 {
 	pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
@@ -92,6 +157,9 @@ static void __make_page_readonly(void *va)
 
 	if ((addr >= VMALLOC_START) && (addr < VMALLOC_END))
 		__make_page_readonly(__va(pte_pfn(pte) << PAGE_SHIFT));
+
+	//show_pgtable(addr);
+	//show_pgtable(__START_KERNEL_map + __pa(va));
 }
 
 static void __make_page_writable(void *va)
-- 
1.5.4.1


linux-2.6-xen-0071-Disable-apic-at-compile-time-FIXME.patch:

--- NEW FILE linux-2.6-xen-0071-Disable-apic-at-compile-time-FIXME.patch ---
>From cc330d7a4cc7c5c2639df43a10a5e2c542a09d99 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 18 Dec 2007 16:54:43 -0200
Subject: [PATCH] Disable apic at compile time (FIXME)

More code that will need to be disabled at runtime.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/setup_64.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index f4f7ecf..e81261a 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -444,7 +444,10 @@ void __init setup_arch(char **cmdline_p)
 	 */
 	if (smp_found_config)
 		get_smp_config();
+#ifndef CONFIG_XEN
+	/*FIXME: pvops */
 	init_apic_mappings();
+#endif
 	ioapic_init_mappings();
 
 	/*
-- 
1.5.4.1


linux-2.6-xen-0072-Parse-early-params-after-init_memory_mapping.patch:

--- NEW FILE linux-2.6-xen-0072-Parse-early-params-after-init_memory_mapping.patch ---
>From 86ca6e68e737bbb467a57f72e43b6ca2815880a1 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 18 Dec 2007 17:38:40 -0200
Subject: [PATCH] Parse early params after init_memory_mapping()

The xen console needs __va() to be working.

The question is: is this the case for other early_printk() handlers?

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/setup_64.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index e81261a..5768ef5 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -313,8 +313,6 @@ void __init setup_arch(char **cmdline_p)
 	strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
 	*cmdline_p = command_line;
 
-	parse_early_param();
-
 #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
 	if (init_ohci1394_dma_early)
 		init_ohci1394_dma_on_all_controllers();
@@ -342,6 +340,8 @@ void __init setup_arch(char **cmdline_p)
 	check_efer();
 
 	init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
+	parse_early_param();
+
 	if (efi_enabled)
 		efi_init();
 
-- 
1.5.4.1


linux-2.6-xen-0073-xen-Move-addr_to_page-to-init.h.patch:

--- NEW FILE linux-2.6-xen-0073-xen-Move-addr_to_page-to-init.h.patch ---
>From 9e50047d7a5001fb3db0e7c86cb4227379036c7c Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 18 Dec 2007 17:40:35 -0200
Subject: [PATCH] xen: Move addr_to_page() to init.h

Needed on arch/x86/mm/init_64.c

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/init.h    |    7 +++++++
 arch/x86/xen/init_64.c |    7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/xen/init.h b/arch/x86/xen/init.h
index ee22051..fee0c05 100644
--- a/arch/x86/xen/init.h
+++ b/arch/x86/xen/init.h
@@ -10,4 +10,11 @@ extern unsigned long start_pfn;
 
 void early_make_page_readonly(void *va, unsigned int feature);
 
+
+#define addr_to_page(addr, page)				\
+	(addr) &= PHYSICAL_PAGE_MASK;				\
+	(page) = ((unsigned long *) ((unsigned long)		\
+	(((mfn_to_pfn((addr) >> PAGE_SHIFT)) << PAGE_SHIFT) +	\
+	__START_KERNEL_map)))
+
 #endif /* __X86_XEN_INIT_H */
diff --git a/arch/x86/xen/init_64.c b/arch/x86/xen/init_64.c
index 872c152..1e53c59 100644
--- a/arch/x86/xen/init_64.c
+++ b/arch/x86/xen/init_64.c
@@ -11,13 +11,6 @@
 #include "init.h"
 #include "mmu.h"
 
-#define addr_to_page(addr, page)				\
-	(addr) &= PHYSICAL_PAGE_MASK;				\
-	(page) = ((unsigned long *) ((unsigned long)		\
-	(((mfn_to_pfn((addr) >> PAGE_SHIFT)) << PAGE_SHIFT) +	\
-	__START_KERNEL_map)))
-
-
 void __meminit early_make_page_readonly(void *va, unsigned int feature)
 {
 	unsigned long addr, _va = (unsigned long)va;
-- 
1.5.4.1


linux-2.6-xen-0074-Make-xen_pxx_val-and-xen_make_pxx-handle-attr-bi.patch:

--- NEW FILE linux-2.6-xen-0074-Make-xen_pxx_val-and-xen_make_pxx-handle-attr-bi.patch ---
>From bdb0a261de5bdd4c30ff7199345e023bf459e45b Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 12:31:46 -0200
Subject: [PATCH] Make xen_pxx_val() and xen_make_pxx() handle attr bits safely

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/mmu.c |   60 +++++++++++++++++++++++++++++++++++----------------
 1 files changed, 41 insertions(+), 19 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 1880f9f..16020ec 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -162,7 +162,10 @@ pteval_t xen_pte_val(pte_t pte)
 pte_t xen_make_pte(pteval_t pte)
 {
 	if (pte & _PAGE_PRESENT) {
-		pte = phys_to_machine(XPADDR(pte)).maddr;
+		/* preserve all other pte bits */
+		pteval_t m = phys_to_machine(XPADDR(pte & PHYSICAL_PAGE_MASK)).maddr;
+		pte &= ~PHYSICAL_PAGE_MASK;
+		pte |= m;
 		pte &= ~(_PAGE_PCD | _PAGE_PWT);
 	}
 
@@ -177,17 +180,23 @@ pmdval_t xen_pmd_val(pmd_t pmd)
 {
 	pmdval_t ret = pmd_val_ma(pmd);
 
-	/*FIXME: handle attr bits properly (especially NX) */
-	if (ret & _PAGE_PRESENT)
-		ret = machine_to_phys(XMADDR(ret)).paddr | 1;
+	if (ret & _PAGE_PRESENT) {
+		/* preserve all other pmd bits */
+		pmdval_t m = machine_to_phys(XMADDR(ret & PHYSICAL_PAGE_MASK)).paddr;
+		ret &= ~PHYSICAL_PAGE_MASK;
+		ret |= m;
+	}
 	return ret;
 }
 
 pmd_t xen_make_pmd(pmdval_t pmd)
 {
-	/*FIXME: handle attr bits properly (especially NX) */
-	if (pmd & _PAGE_PRESENT)
-		pmd = phys_to_machine(XPADDR(pmd)).maddr;
+	if (pmd & _PAGE_PRESENT) {
+		/* preserve all other pmd bits */
+		pmdval_t m = phys_to_machine(XPADDR(pmd & PHYSICAL_PAGE_MASK)).maddr;
+		pmd &= ~PHYSICAL_PAGE_MASK;
+		pmd |= m;
+	}
 
 	return (pmd_t){ pmd };
 }
@@ -221,17 +230,23 @@ pudval_t xen_pud_val(pud_t pud)
 {
 	pudval_t ret = pud_val_ma(pud);
 
-	/*FIXME: handle attr bits properly (especially NX) */
-	if (ret)
-		ret = machine_to_phys(XMADDR(ret)).paddr | 1;
+	if (ret & _PAGE_PRESENT) {
+		/* preserve all other pud bits */
+		pudval_t m = machine_to_phys(XMADDR(ret & PHYSICAL_PAGE_MASK)).paddr;
+		ret &= ~PHYSICAL_PAGE_MASK;
+		ret |= m;
+	}
 	return ret;
 }
 
 pud_t xen_make_pud(pudval_t pud)
 {
-	/*FIXME: handle attr bits properly (especially NX) */
-	if (pud & _PAGE_PRESENT)
-		pud = phys_to_machine(XPADDR(pud)).maddr;
+	if (pud & _PAGE_PRESENT) {
+		/* preserve all other pud bits */
+		pudval_t m = phys_to_machine(XPADDR(pud & PHYSICAL_PAGE_MASK)).maddr;
+		pud &= ~PHYSICAL_PAGE_MASK;
+		pud |= m;
+	}
 
 	return native_make_pud(pud);
 }
@@ -262,17 +277,24 @@ pgdval_t xen_pgd_val(pgd_t pgd)
 {
 	pgdval_t ret = pgd_val_ma(pgd);
 
-	/*FIXME: handle attr bits properly (especially NX) */
-	if (ret & _PAGE_PRESENT)
-		ret = machine_to_phys(XMADDR(ret)).paddr | 1;
+	if (ret & _PAGE_PRESENT) {
+		/* preserve all other pgd bits */
+		pgdval_t m = machine_to_phys(XMADDR(ret & PHYSICAL_PAGE_MASK)).paddr;
+		ret &= ~PHYSICAL_PAGE_MASK;
+		ret |= m;
+	}
 	return ret;
 }
 
 pgd_t xen_make_pgd(pgdval_t pgd)
 {
-	/*FIXME: handle attr bits properly (especially NX) */
-	if (pgd & _PAGE_PRESENT)
-		pgd = phys_to_machine(XPADDR(pgd)).maddr;
+	if (pgd & _PAGE_PRESENT) {
+		/* preserve all other pgd bits */
+		pgdval_t m = phys_to_machine(XPADDR(pgd & PHYSICAL_PAGE_MASK)).maddr;
+		pgd &= ~PHYSICAL_PAGE_MASK;
+		pgd |= m;
+	}
+
 
 	return native_make_pgd(pgd);
 }
-- 
1.5.4.1


linux-2.6-xen-0075-Pull-xen_finish_init_mappin-from-XS-upstream.patch:

--- NEW FILE linux-2.6-xen-0075-Pull-xen_finish_init_mappin-from-XS-upstream.patch ---
>From 447d2eb7428f21ece75919ea7dcd3a338e98da0d Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 13:20:18 -0200
Subject: [PATCH] Pull xen_finish_init_mappin() from XS upstream

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c |   86 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 85 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index fddf208..58ae6ad 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -468,6 +468,85 @@ int make_readonly(unsigned long paddr)
 	return readonly;
 }
 
+static void xen_finish_init_mapping(void)
+{
+	/*FIXME: move this to pvops */
+	unsigned long i, start, end;
+
+	xprintk("messing with start_info:\n");
+
+	/* Re-vector virtual addresses pointing into the initial
+	   mapping to the just-established permanent ones. */
+	xen_start_info = __va(__pa(xen_start_info));
+	xen_start_info->pt_base = (unsigned long)
+		__va(__pa(xen_start_info->pt_base));
+	if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+		phys_to_machine_mapping =
+			__va(__pa(xen_start_info->mfn_list));
+		xen_start_info->mfn_list = (unsigned long)
+			phys_to_machine_mapping;
+	}
+	if (xen_start_info->mod_start)
+		xen_start_info->mod_start = (unsigned long)
+			__va(__pa(xen_start_info->mod_start));
+
+	xprintk("messed with start_info.\n");
+	xprintk("unmapping:\n");
+
+	/* Destroy the Xen-created mappings beyond the kernel image as
+	 * well as the temporary mappings created above. Prevents
+	 * overlap with modules area (if init mapping is very big).
+	 */
+	start = PAGE_ALIGN((unsigned long)_end);
+	end   = __START_KERNEL_map + (table_end << PAGE_SHIFT);
+
+	xprintk("from %lx to %lx\n", start, end);
+	for (; start < end; start += PAGE_SIZE)
+		WARN_ON(HYPERVISOR_update_va_mapping(
+			start, __pte_ma(0), 0));
+
+	/* Allocate pte's for initial fixmaps from 'start_pfn' allocator. */
+	table_end = ~0UL;
+
+
+	xprintk("set_fixmaps:\n");
+
+	/*
+	 * Prefetch pte's for the bt_ioremap() area. It gets used before the
+	 * boot-time allocator is online, so allocate-on-demand would fail.
+	 */
+	for (i = FIX_BTMAP_END; i <= FIX_BTMAP_BEGIN; i++)
+		clear_fixmap(i);
+
+	xprintk("btmap end.\n");
+
+	/* Switch to the real shared_info page, and clear the dummy page. */
+#if 0
+	set_fixmap_mfn(FIX_SHARED_INFO, xen_start_info->shared_info);
+	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
+#endif
+
+	memset(empty_zero_page, 0, sizeof(empty_zero_page));
+	xprintk("isamaps:\n");
+
+	/* Set up mapping of lowest 1MB of physical memory. */
+	for (i = 0; i < NR_FIX_ISAMAPS; i++)
+		if (is_initial_xendomain())
+			__native_set_fixmap(FIX_ISAMAP_BEGIN - i,
+					    mfn_pte(i * PAGE_SIZE, PAGE_KERNEL));
+		else
+			__native_set_fixmap(FIX_ISAMAP_BEGIN - i,
+					    pfn_pte(__pa(empty_zero_page)
+					        >> PAGE_SHIFT,
+					    PAGE_KERNEL_RO));
+
+	/* Disable the 'start_pfn' allocator. */
+	table_end = start_pfn;
+
+	xprintk("finished!\n");
+}
+
+
 #else /* !XEN */
 
 static __meminit void *alloc_low_page(unsigned long *phys)
@@ -771,8 +850,13 @@ void __init_refok init_memory_mapping(unsigned long start, unsigned long end)
 		unmap_low_page(pud);
 	}
 
-	if (!after_bootmem)
+	if (!after_bootmem) {
+#ifdef CONFIG_XEN
+		BUG_ON(start_pfn != table_end);
+		xen_finish_init_mapping();
+#endif
 		mmu_cr4_features = read_cr4();
+	}
 	__flush_tlb_all();
 
 	if (!after_bootmem)
-- 
1.5.4.1


linux-2.6-xen-0076-Pull-spp_getpage-changes-from-XS-upstream-REVIEWM.patch:

--- NEW FILE linux-2.6-xen-0076-Pull-spp_getpage-changes-from-XS-upstream-REVIEWM.patch ---
>From 8d7d253384759e7d8260265b4830a5fbbc572a3a Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 13:21:20 -0200
Subject: [PATCH] Pull spp_getpage() changes from XS upstream (REVIEWME)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 58ae6ad..2e6af9d 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -274,7 +274,11 @@ static __init void *spp_getpage(void)
 
 	if (after_bootmem)
 		ptr = (void *) get_zeroed_page(GFP_ATOMIC);
-	else
+	else if (start_pfn < table_end) {
+		ptr = __va(start_pfn << PAGE_SHIFT);
+		start_pfn++;
+		memset(ptr, 0, PAGE_SIZE);
+	} else
 		ptr = alloc_bootmem_pages(PAGE_SIZE);
 
 	if (!ptr || ((unsigned long)ptr & ~PAGE_MASK)) {
-- 
1.5.4.1


linux-2.6-xen-0077-Pull-xen_extend_init_mapping-from-XS-upstream-FIX.patch:

--- NEW FILE linux-2.6-xen-0077-Pull-xen_extend_init_mapping-from-XS-upstream-FIX.patch ---
>From 7173948b099cc28316bdb05b0dbd85c2b823be1a Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 13:22:29 -0200
Subject: [PATCH] Pull xen_extend_init_mapping() from XS upstream (FIXME)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 55 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 2e6af9d..9df9ee4 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -550,6 +550,60 @@ static void xen_finish_init_mapping(void)
 	xprintk("finished!\n");
 }
 
+static void __init xen_extend_init_mapping(unsigned long tables_space)
+{
+	unsigned long va = __START_KERNEL_map;
+	unsigned long phys, addr, *pte_page;
+	pmd_t *pmd;
+	pte_t *pte, new_pte;
+	unsigned long *page = (unsigned long *)init_level4_pgt;
+
+	addr = page[pgd_index(va)];
+	addr_to_page(addr, page);
+	addr = page[pud_index(va)];
+	addr_to_page(addr, page);
+
+	/* Kill mapping of low 1MB. */
+	while (va < (unsigned long)&_text) {
+		HYPERVISOR_update_va_mapping(va, __pte_ma(0), 0);
+		va += PAGE_SIZE;
+	}
+
+	/* Ensure init mappings cover kernel text/data and initial tables. */
+	while (va < (__START_KERNEL_map
+		     + (start_pfn << PAGE_SHIFT)
+		     + tables_space)) {
+		pmd = (pmd_t *)&page[pmd_index(va)];
+		if (pmd_none(*pmd)) {
+			pte_page = alloc_low_page(&phys);
+			early_make_page_readonly(
+				pte_page, XENFEAT_writable_page_tables);
+			set_pmd(pmd, __pmd(phys | _KERNPG_TABLE));
+		} else {
+			addr = page[pmd_index(va)];
+			addr_to_page(addr, pte_page);
+		}
+		pte = (pte_t *)&pte_page[pte_index(va)];
+		if (pte_none(*pte)) {
+			new_pte = pfn_pte(
+				(va - __START_KERNEL_map) >> PAGE_SHIFT, 
+				__pgprot(_KERNPG_TABLE));
+			set_pte_at(&init_mm, va, pte, new_pte);
+		}
+		va += PAGE_SIZE;
+	}
+
+	/* Finally, blow away any spurious initial mappings. */
+	while (1) {
+		pmd = (pmd_t *)&page[pmd_index(va)];
+		if (pmd_none(*pmd))
+			break;
+		HYPERVISOR_update_va_mapping(va, __pte_ma(0), 0);
+		va += PAGE_SIZE;
+	}
+}
+
+
 
 #else /* !XEN */
 
@@ -770,7 +824,7 @@ static void __init find_early_table_space(unsigned long end)
 		round_up(ptes * 8, PAGE_SIZE); 
 
 	/*FIXME: what does this do? */
-	//extend_init_mapping(tables);
+	xen_extend_init_mapping(tables);
 
 	table_start = start_pfn;
 	table_end = table_start + (tables>>PAGE_SHIFT);
-- 
1.5.4.1


linux-2.6-xen-0078-New-enum-fixed_addresses-values-REVIEWME.patch:

--- NEW FILE linux-2.6-xen-0078-New-enum-fixed_addresses-values-REVIEWME.patch ---
>From ad843228e5bcef747e694adc5dcaac900d42d5f5 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 13:28:40 -0200
Subject: [PATCH] New enum fixed_addresses values (REVIEWME)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/fixmap_32.h |    3 +++
 include/asm-x86/fixmap_64.h |    9 +++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/fixmap_32.h b/include/asm-x86/fixmap_32.h
index c2e450a..9388399 100644
--- a/include/asm-x86/fixmap_32.h
+++ b/include/asm-x86/fixmap_32.h
@@ -89,6 +89,9 @@ enum fixed_addresses {
 #ifdef CONFIG_PARAVIRT
 	FIX_PARAVIRT_BOOTMAP,
 #endif
+#define NR_FIX_ISAMAPS	256
+	FIX_ISAMAP_END,
+	FIX_ISAMAP_BEGIN = FIX_ISAMAP_END + NR_FIX_ISAMAPS - 1,
 	__end_of_permanent_fixed_addresses,
 	/*
 	 * 256 temporary boot-time mappings, used by early_ioremap(),
diff --git a/include/asm-x86/fixmap_64.h b/include/asm-x86/fixmap_64.h
index 0ffb60c..6f632e1 100644
--- a/include/asm-x86/fixmap_64.h
+++ b/include/asm-x86/fixmap_64.h
@@ -50,6 +50,15 @@ enum fixed_addresses {
 #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
 	FIX_OHCI1394_BASE,
 #endif
+#define NR_FIX_ISAMAPS	256
+	FIX_ISAMAP_END,
+	FIX_ISAMAP_BEGIN = FIX_ISAMAP_END + NR_FIX_ISAMAPS - 1,
+	__end_of_permanent_fixed_addresses,
+	/* temporary boot-time mappings, used before ioremap() is functional */
+#define NR_FIX_BTMAPS	16
+	FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
+	FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS - 1,
+	FIX_WP_TEST,
 	__end_of_fixed_addresses
 };
 
-- 
1.5.4.1


linux-2.6-xen-0079-Reserve-bootmem-areas-used-by-Xen-FIXME.patch:

--- NEW FILE linux-2.6-xen-0079-Reserve-bootmem-areas-used-by-Xen-FIXME.patch ---
>From bfc90c4a427f1afc49e04ac39e43296acb7c008e Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Thu, 20 Dec 2007 16:03:58 -0200
Subject: [PATCH] Reserve bootmem areas used by Xen (FIXME)

Should be moved to pvops code.

Debugging needs to be removed.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/setup_64.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index 5768ef5..5efffe8 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -73,6 +73,12 @@
 #define ARCH_SETUP
 #endif
 
+
+/*FIXME: remove xen-specific code here */
+#include <xen/page.h>
+#include <asm/xen/hypervisor.h>
+
+
 /*
  * Machine setup..
  */
@@ -399,6 +405,22 @@ void __init setup_arch(char **cmdline_p)
 	if (efi_enabled)
 		efi_reserve_bootmem();
 
+#ifdef CONFIG_XEN
+	/*FIXME: pvops */
+	/* Reserve phys_to_machine_mapping */
+	reserve_bootmem(__pa(phys_to_machine_mapping),
+			sizeof(unsigned long *)*xen_start_info->nr_pages,
+			BOOTMEM_DEFAULT);
+
+	/* Reserve initial pagetables*/
+	/*FIXME: probably they are not used anymore and may be made
+	 * writeable again after the kernel page tables are set up.
+	 */
+	reserve_bootmem(__pa(xen_start_info->pt_base),
+			xen_start_info->nr_pt_frames*PAGE_SIZE,
+			BOOTMEM_DEFAULT);
+#endif
+
        /*
 	* Find and reserve possible boot-time SMP configuration:
 	*/
-- 
1.5.4.1


linux-2.6-xen-0080-xen_convert_trap_info-use-sizeof-struct-gate_desc.patch:

--- NEW FILE linux-2.6-xen-0080-xen_convert_trap_info-use-sizeof-struct-gate_desc.patch ---
>From 876c274a46072215cd02d724602963757726a7d8 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Thu, 20 Dec 2007 16:45:51 -0200
Subject: [PATCH] xen_convert_trap_info(): use sizeof(struct gate_desc)

This will make it consider the corect size depending on the architecture.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 5bd8265..5e8e493 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -505,7 +505,7 @@ static void xen_convert_trap_info(const struct desc_ptr *desc,
 {
 	unsigned in, out, count;
 
-	count = (desc->size+1) / 8;
+	count = (desc->size+1) / sizeof(gate_desc);
 	BUG_ON(count > 256);
 
 	for (in = out = 0; in < count; in++) {
-- 
1.5.4.1


linux-2.6-xen-0081-Call-paravirt_pagetable_setup_-start-done-REVIEW.patch:

--- NEW FILE linux-2.6-xen-0081-Call-paravirt_pagetable_setup_-start-done-REVIEW.patch ---
>From c8aafb38657e26d398af65017bc365a36725bc9e Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 21 Dec 2007 11:57:55 -0200
Subject: [PATCH] Call paravirt_pagetable_setup_{start,done} (REVIEW)

These paravirt_ops functions were not being called
on x86_64.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/setup_64.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index 5efffe8..5c44c2e 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -447,7 +447,9 @@ void __init setup_arch(char **cmdline_p)
 	}
 #endif
 	reserve_crashkernel();
+	paravirt_pagetable_setup_start(swapper_pg_dir);
 	paging_init();
+	paravirt_pagetable_setup_done(swapper_pg_dir);
 	map_vsyscall();
 
 	early_quirks();
-- 
1.5.4.1


linux-2.6-xen-0082-ifdef-CONFIG_X86_32-on-xen-enlighten.c-REVIEWME.patch:

--- NEW FILE linux-2.6-xen-0082-ifdef-CONFIG_X86_32-on-xen-enlighten.c-REVIEWME.patch ---
>From 723ede95f0132cc25c9ced8111fb6cd531f2eec4 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 13:34:59 -0200
Subject: [PATCH] ifdef CONFIG_X86_32 on xen/enlighten.c (REVIEWME)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 5e8e493..4bbb65e 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -870,12 +870,18 @@ static __init void xen_set_pte_init(pte_t *ptep, pte_t pte)
 
 static __init void xen_pagetable_setup_start(pgd_t *base)
 {
+#ifdef CONFIG_X86_32
 	pgd_t *xen_pgd = (pgd_t *)xen_start_info->pt_base;
+#endif
 
 	/* special set_pte for pagetable initialization */
 	pv_mmu_ops.set_pte = xen_set_pte_init;
 
 	init_mm.pgd = base;
+
+#ifdef CONFIG_X86_32
+	/*FIXME: for x86_64, pull the mm/init_64.c code here */
+
 	/*
 	 * copy top-level of Xen-supplied pagetable into place.	 For
 	 * !PAE we can use this as-is, but for PAE it is a stand-in
@@ -914,6 +920,7 @@ static __init void xen_pagetable_setup_start(pgd_t *base)
 	 * added to the table can be prepared properly for Xen.
 	 */
 	xen_write_cr3(__pa(base));
+#endif
 
 	/* Unpin initial Xen pagetable */
 	pin_pagetable_pfn(MMUEXT_UNPIN_TABLE,
@@ -957,6 +964,9 @@ static __init void xen_pagetable_setup_done(pgd_t *base)
 
 	setup_shared_info();
 
+#ifdef CONFIG_X86_32
+	/*FIXME: for x86_64, code needs to be pulled from mm/init_64.c */
+
 	/* Actually pin the pagetable down, but we can't set PG_pinned
 	   yet because the page structures don't exist yet. */
 	{
@@ -970,6 +980,7 @@ static __init void xen_pagetable_setup_done(pgd_t *base)
 
 		pin_pagetable_pfn(level, PFN_DOWN(__pa(base)));
 	}
+#endif
 }
 
 /* This is called once we have the cpu_possible_map */
-- 
1.5.4.1


linux-2.6-xen-0083-Handle-Xen-exception-stack-it-is-different-from-bar.patch:

--- NEW FILE linux-2.6-xen-0083-Handle-Xen-exception-stack-it-is-different-from-bar.patch ---
>From d043ca96e0fd6e7e8a48e38295e9edac96a08df0 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 24 Dec 2007 17:22:58 -0200
Subject: [PATCH] Handle Xen exception stack (it is different from baremetal stack) (FIXME)

Now Oopses make sense!  :D

FIXME: This needs to be handled differently at runtime, not compile time.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/entry_64.S |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 3fedbd6..d026834 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -728,11 +728,28 @@ ENTRY(spurious_interrupt)
 	apicinterrupt SPURIOUS_APIC_VECTOR,smp_spurious_interrupt
 END(spurious_interrupt)
 				
+
+/* Xen register handling */
+#ifdef CONFIG_XEN
+	/*FIXME: select this at runtime */
+	.macro xen_fix_stack
+	movq (%rsp),%rcx
+	CFI_RESTORE rcx
+	movq 8(%rsp),%r11
+	CFI_RESTORE r11
+	addq $0x10,%rsp /* skip rcx and r11 */
+	CFI_ADJUST_CFA_OFFSET -0x10
+	.endm
+#else
+	.macro xen_fix_stack
+	.endm
+#endif
 /*
  * Exception entry points.
  */ 		
 	.macro zeroentry sym
 	INTR_FRAME
+	xen_fix_stack
 	pushq $0	/* push error code/oldrax */ 
 	CFI_ADJUST_CFA_OFFSET 8
 	pushq %rax	/* push real oldrax to the rdi slot */ 
@@ -745,6 +762,7 @@ END(spurious_interrupt)
 
 	.macro errorentry sym
 	XCPT_FRAME
+	xen_fix_stack
 	pushq %rax
 	CFI_ADJUST_CFA_OFFSET 8
 	CFI_REL_OFFSET rax,0
-- 
1.5.4.1


linux-2.6-xen-0084-Make-hvc_xen-console-use-xprintk-TEMPORARY.patch:

--- NEW FILE linux-2.6-xen-0084-Make-hvc_xen-console-use-xprintk-TEMPORARY.patch ---
>From 44f9ddbb0a626c8b5439097e39695dfa97c96a65 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Thu, 20 Dec 2007 16:05:25 -0200
Subject: [PATCH] Make hvc_xen console use xprintk() (TEMPORARY)

Temporarly, while the console is not working when booting fails quickly.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 drivers/char/hvc_xen.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c
index dd68f85..6e0ec3a 100644
--- a/drivers/char/hvc_xen.c
+++ b/drivers/char/hvc_xen.c
@@ -55,6 +55,9 @@ static int write_console(uint32_t vtermno, const char *data, int len)
 	struct xencons_interface *intf = xencons_interface();
 	XENCONS_RING_IDX cons, prod;
 	int sent = 0;
+	char fmt[16];
+	sprintf(fmt, "%%%ds", len);
+	xprintk(fmt, data);
 
 	cons = intf->out_cons;
 	prod = intf->out_prod;
-- 
1.5.4.1


linux-2.6-xen-0085-Implement-64-bit-version-of-HYPERVISOR_set_callbacks.patch:

--- NEW FILE linux-2.6-xen-0085-Implement-64-bit-version-of-HYPERVISOR_set_callbacks.patch ---
>From 92f0a6bb139a319bd29cb79d8519e539dd8c9d78 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 26 Dec 2007 15:51:34 -0200
Subject: [PATCH] Implement 64-bit version of HYPERVISOR_set_callbacks() (IFDEF?)

HYPERVISOR_set_callbacks() interface is different on x86_64.

(More #ifdef abuse).

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/setup.c            |    6 ++++++
 include/asm-x86/xen/hypercall.h |   12 ++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 2216e44..99b7463 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -94,8 +94,14 @@ void __init xen_arch_setup(void)
 	if (!xen_feature(XENFEAT_auto_translated_physmap))
 		HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3);
 
+#ifdef CONFIG_X86_32
 	HYPERVISOR_set_callbacks(__KERNEL_CS, (unsigned long)xen_hypervisor_callback,
 				 __KERNEL_CS, (unsigned long)xen_failsafe_callback);
+#else
+	HYPERVISOR_set_callbacks((unsigned long)xen_hypervisor_callback,
+				 (unsigned long)xen_failsafe_callback,
+				 (unsigned long)system_call);
+#endif
 
 	set_iopl.iopl = 1;
 	rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
index 605775e..0588d6d 100644
--- a/include/asm-x86/xen/hypercall.h
+++ b/include/asm-x86/xen/hypercall.h
@@ -226,6 +226,7 @@ HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp)
 	return _hypercall2(int, stack_switch, ss, esp);
 }
 
+#ifdef CONFIG_X86_32
 static inline int
 HYPERVISOR_set_callbacks(unsigned long event_selector,
 			 unsigned long event_address,
@@ -236,6 +237,17 @@ HYPERVISOR_set_callbacks(unsigned long event_selector,
 			   event_selector, event_address,
 			   failsafe_selector, failsafe_address);
 }
+#else  /* CONFIG_X86_64 */
+static inline int
+HYPERVISOR_set_callbacks(unsigned long event_address,
+			unsigned long failsafe_address,
+			unsigned long syscall_address)
+{
+	return _hypercall3(int, set_callbacks,
+			   event_address, failsafe_address,
+			   syscall_address);
+}
+#endif  /* CONFIG_X86_{32,64} */
 
 static inline int
 HYPERVISOR_fpu_taskswitch(int set)
-- 
1.5.4.1


linux-2.6-xen-0086-Make-arch_vcpu_info-be-of-the-right-size-on-both-32.patch:

--- NEW FILE linux-2.6-xen-0086-Make-arch_vcpu_info-be-of-the-right-size-on-both-32.patch ---
>From 343878380729274e11bdb405e4271f666194154d Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Thu, 27 Dec 2007 17:33:32 -0200
Subject: [PATCH] Make arch_vcpu_info be of the right size on both 32 and 64 bits

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/xen/interface.h |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/asm-x86/xen/interface.h b/include/asm-x86/xen/interface.h
index 881d1b3..ab69adb 100644
--- a/include/asm-x86/xen/interface.h
+++ b/include/asm-x86/xen/interface.h
@@ -171,8 +171,16 @@ struct arch_shared_info {
 };
 
 struct arch_vcpu_info {
-    unsigned long cr2;
-    unsigned long pad[5]; /* sizeof(struct vcpu_info) == 64 */
+    union {
+        struct {
+            /* The "real" struct */
+            unsigned long cr2;
+        };
+        struct {
+            /* force struct size to 16 bytes */
+            char fill[16];
+        };
+    };
 };
 
 #endif /* !__ASSEMBLY__ */
-- 
1.5.4.1


linux-2.6-xen-0087-Implement-asm-xen_iret.patch:

--- NEW FILE linux-2.6-xen-0087-Implement-asm-xen_iret.patch ---
>From b602b53bcfdcb660f0c138b70aaece95a409d232 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 11 Feb 2008 11:59:29 -0200
Subject: [PATCH] Implement asm xen_iret

Not optimized yet. Always return through the hypervisor.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c  |    4 ++++
 arch/x86/xen/xen-asm_64.S |    7 +++++++
 arch/x86/xen/xen-ops.h    |    1 +
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 4bbb65e..894252a 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1136,7 +1136,11 @@ static const struct pv_cpu_ops xen_cpu_ops __initdata = {
 	.read_tsc = native_read_tsc,
 	.read_pmc = native_read_pmc,
 
+#ifdef CONFIG_X86_32
 	.iret = (void *)&hypercall_page[__HYPERVISOR_iret],
+#else
+	.iret = xen_iret,
+#endif
 	.irq_enable_syscall_ret = NULL,  /* never called */
 
 	.load_tr_desc = paravirt_nop,
diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
index 38443b8..8f28a91 100644
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -6,3 +6,10 @@ check_events:
 ENTRY(xen_iret_direct)
 	/*FIXME: implement me! */
 	ud2a
+
+ENTRY(xen_iret)
+	/*FIXME: the VGCF_in_syscall flag need to be handled here */
+	pushq $0
+	jmp hypercall_page + (__HYPERVISOR_iret * 32)
+END(xen_iret)
+
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index f062eab..e52bb4c 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -71,4 +71,5 @@ DECL_ASM(unsigned long, xen_save_fl_direct, void);
 DECL_ASM(void, xen_restore_fl_direct, unsigned long);
 
 void xen_iret_direct(void);
+void xen_iret(void);
 #endif /* XEN_OPS_H */
-- 
1.5.4.1


linux-2.6-xen-0088-xen-64-xen_iret-use-iretq-directly-if-returning-t.patch:

--- NEW FILE linux-2.6-xen-0088-xen-64-xen_iret-use-iretq-directly-if-returning-t.patch ---
>From c539598eff8ae511a84e94657ca8f0fb34433439 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 4 Jan 2008 11:54:37 -0200
Subject: [PATCH] xen-64: xen_iret() use iretq directly if returning to kernel-space

Optimization pulled from upstream Xen.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/xen-asm.S    |    5 ++++
 arch/x86/xen/xen-asm_64.S |   49 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/xen-asm.S b/arch/x86/xen/xen-asm.S
index 1c3c0ac..c7356c0 100644
--- a/arch/x86/xen/xen-asm.S
+++ b/arch/x86/xen/xen-asm.S
@@ -21,6 +21,11 @@
 #include <asm/asm-hack.h>
 
 #include <xen/interface/xen.h>
+#include <xen/interface/features.h>
+
+#include <asm/calling.h>
+#include <asm/processor-flags.h>
+
 
 #define RELOC(x, v)	.globl x##_reloc; x##_reloc=v
 #define ENDPATCH(x)	.globl x##_end; x##_end=.
diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
index 8f28a91..85c235c 100644
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -7,7 +7,56 @@ ENTRY(xen_iret_direct)
 	/*FIXME: implement me! */
 	ud2a
 
+//FIXME: move to calling.h?
+#define IRETOFFSET RIP
+
 ENTRY(xen_iret)
+	/* Are we returning to kernel space? */
+	testb $3,CS-IRETOFFSET(%rsp)
+	jnz xen_iret_slow
+
+#if 0
+	/*FIXME: handle NMI callbacks */
+	testl $NMI_MASK,EFLAGS-IRETOFFSET(%rsp)
+	jnz xen_iret_slow
+#endif
+
+	/* If we are going to restore interrupts, we need to
+	 * return through the hypervisor, too.
+	 *
+	 * We may set evtchn_upcall_mask ourselves, but things get complicated
+	 * because we would need to avoid a stack overflow if we get
+	 * interrupts between upcall_mask being cleared and iret being
+	 * executed.
+	 */
+	testl $X86_EFLAGS_IF,EFLAGS-IRETOFFSET(%rsp)
+	jnz xen_iret_slow
+
+
+
+	/* Returning to kernel (RING0).
+	 * Use direct iret to kernel space after correcting CS and SS
+	 */
+
+	cmpb  $0,(xen_features+XENFEAT_supervisor_mode_kernel)(%rip)
+	/* supervisor_mode_kernel -> no need to correct CS and SS */
+	jne   xen_iretq
+
+	/* Direct iret to kernel space. Correct CS and SS. */
+	orl   $3,CS-IRETOFFSET(%rsp)
+	orl   $3,SS-IRETOFFSET(%rsp)
+xen_iretq:
+	iretq
+
+xen_iret_slow:
+	/* Slow iret via hypervisor */
+
+#if 0
+	/*FIXME: handle NMI callbacks */
+	andl  $~NMI_MASK, 2*8(%rsp)
+#endif
+
+	/* Xen has an additional value in the stack for iret */
 	/*FIXME: the VGCF_in_syscall flag need to be handled here */
 	pushq $0
 	jmp hypercall_page + (__HYPERVISOR_iret * 32)
-- 
1.5.4.1


linux-2.6-xen-0089-Implement-xen_irqenable_syscall_ret.patch:

--- NEW FILE linux-2.6-xen-0089-Implement-xen_irqenable_syscall_ret.patch ---
>From 0e8c0e76d9f40283984060c5481b2573d3b9f824 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 4 Feb 2008 18:06:53 -0200
Subject: [PATCH] Implement xen_irqenable_syscall_ret()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c  |    3 ++-
 arch/x86/xen/xen-asm_64.S |    8 ++++++++
 arch/x86/xen/xen-ops.h    |    2 ++
 3 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 894252a..97fa630 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1138,10 +1138,11 @@ static const struct pv_cpu_ops xen_cpu_ops __initdata = {
 
 #ifdef CONFIG_X86_32
 	.iret = (void *)&hypercall_page[__HYPERVISOR_iret],
+	.irq_enable_syscall_ret = NULL,  /* never called */
 #else
 	.iret = xen_iret,
+	.irq_enable_syscall_ret = xen_irqenable_syscall_ret,
 #endif
-	.irq_enable_syscall_ret = NULL,  /* never called */
 
 	.load_tr_desc = paravirt_nop,
 	.set_ldt = xen_set_ldt,
diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
index 85c235c..9ceaeab 100644
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -62,3 +62,11 @@ xen_iret_slow:
 	jmp hypercall_page + (__HYPERVISOR_iret * 32)
 END(xen_iret)
 
+#define VGCF_in_syscall (1<<8)
+
+ENTRY(xen_irqenable_syscall_ret)
+	orl $X86_EFLAGS_IF,EFLAGS-IRETOFFSET(%rsp)
+
+	pushq $VGCF_in_syscall
+	jmp hypercall_page + (__HYPERVISOR_iret * 32)
+END(xen_irqenable_syscall_ret)
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index e52bb4c..b523062 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -72,4 +72,6 @@ DECL_ASM(void, xen_restore_fl_direct, unsigned long);
 
 void xen_iret_direct(void);
 void xen_iret(void);
+void xen_irqenable_syscall_ret(void);
+
 #endif /* XEN_OPS_H */
-- 
1.5.4.1


linux-2.6-xen-0090-DEBUG-xen_iret-always-return-through-the-hyperviso.patch:

--- NEW FILE linux-2.6-xen-0090-DEBUG-xen_iret-always-return-through-the-hyperviso.patch ---
>From 7766fab2c028d144555817cf50701069d229c2f9 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 4 Feb 2008 18:11:05 -0200
Subject: [PATCH] DEBUG: xen_iret: always return through the hypervisor

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/xen-asm_64.S |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
index 9ceaeab..95b3554 100644
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -11,6 +11,9 @@ ENTRY(xen_iret_direct)
 #define IRETOFFSET RIP
 
 ENTRY(xen_iret)
+	/*FIXME: for debugging */
+	jmp xen_iret_slow
+
 	/* Are we returning to kernel space? */
 	testb $3,CS-IRETOFFSET(%rsp)
 	jnz xen_iret_slow
-- 
1.5.4.1


linux-2.6-xen-0091-Implement-some-xen-callbacks-on-xen-entry_64.S.patch:

--- NEW FILE linux-2.6-xen-0091-Implement-some-xen-callbacks-on-xen-entry_64.S.patch ---
>From ad309d51e85f84405df78ba7e859b9f2dc002fa2 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 11 Feb 2008 12:00:28 -0200
Subject: [PATCH] Implement some xen callbacks on xen/entry_64.S

hypervisor callback and failsafe callback. Not tested yet.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/entry_64.S |   44 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/entry_64.S b/arch/x86/xen/entry_64.S
index c8c1473..927108c 100644
--- a/arch/x86/xen/entry_64.S
+++ b/arch/x86/xen/entry_64.S
@@ -1 +1,43 @@
-#error foo
+ENTRY(xen_hypervisor_callback)
+	zeroentry do_hypervisor_callback
+ENDPROC(xen_hypervisor_callback)
+
+ENTRY(xen_failsafe_callback)
+	/*FIXME: implement me! */
+	ud2a
+ENDPROC(xen_failsafe_callback)
+
+
+/*
+ * Copied from arch/xen/i386/kernel/entry.S
+ */               
+# A note on the "critical region" in our callback handler.
+# We want to avoid stacking callback handlers due to events occurring
+# during handling of the last event. To do this, we keep events disabled
+# until we've done all processing. HOWEVER, we must enable events before
+# popping the stack frame (can't be done atomically) and so it would still
+# be possible to get enough handler activations to overflow the stack.
+# Although unlikely, bugs of that kind are hard to track down, so we'd
+# like to avoid the possibility.
+# So, on entry to the handler we detect whether we interrupted an
+# existing activation in its critical region -- if so, we pop the current
+# activation and restart the handler using the previous one.
+ENTRY(do_hypervisor_callback)   # do_hypervisor_callback(struct *pt_regs)
+	CFI_STARTPROC
+# Since we don't modify %rdi, evtchn_do_upall(struct *pt_regs) will
+# see the correct pointer to the pt_regs
+	movq %rdi, %rsp            # we don't return, adjust the stack frame
+	CFI_ENDPROC
+	CFI_DEFAULT_STACK
+11:	incl %gs:pda_irqcount
+	movq %rsp,%rbp
+	CFI_DEF_CFA_REGISTER rbp
+	cmovzq %gs:pda_irqstackptr,%rsp
+	pushq %rbp			# backlink for old unwinder
+	call xen_evtchn_do_upcall
+	popq %rsp
+	CFI_DEF_CFA_REGISTER rsp
+	decl %gs:pda_irqcount
+	jmp  error_exit
+	CFI_ENDPROC
+END(do_hypervisor_callback)
-- 
1.5.4.1


linux-2.6-xen-0092-Xen-specific-ifdef-hacks-on-kernel-entry_64.S-FIXM.patch:

--- NEW FILE linux-2.6-xen-0092-Xen-specific-ifdef-hacks-on-kernel-entry_64.S-FIXM.patch ---
>From b4fc4b6196bd70eba0655709bf31bedd45fae952 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 11 Feb 2008 12:02:07 -0200
Subject: [PATCH] Xen-specific #ifdef hacks on kernel/entry_64.S (FIXME)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/entry_64.S |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index d026834..db76caa 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -922,13 +922,22 @@ error_sti:
 	call *%rax
 	/* ebx:	no swapgs flag (1: don't need swapgs, 0: need it) */
 error_exit:
+#ifndef CONFIG_XEN
+	/*FIXME: select at runtime */
 	movl %ebx,%eax
+#endif
 	RESTORE_REST
 	DISABLE_INTERRUPTS(CLBR_NONE)
 	TRACE_IRQS_OFF
 	GET_THREAD_INFO(%rcx)	
+#ifndef CONFIG_XEN
+	/*FIXME: select at runtime */
 	testl %eax,%eax
 	jne  retint_kernel
+#else
+	testb $3,CS-ARGOFFSET(%rsp)
+	jz retint_kernel
+#endif
 	LOCKDEP_SYS_EXIT_IRQ
 	movl  threadinfo_flags(%rcx),%edx
 	movl  $_TIF_WORK_MASK,%edi
-- 
1.5.4.1


linux-2.6-xen-0093-Disable-syscall32-code-temporarily-FIXME.patch:

--- NEW FILE linux-2.6-xen-0093-Disable-syscall32-code-temporarily-FIXME.patch ---
>From 491978aa7ad21061323e60b8b3e323693c5ebad2 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 4 Jan 2008 11:30:17 -0200
Subject: [PATCH] Disable syscall32 code temporarily (FIXME)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/vdso/vdso32-setup.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
index 0bd5f44..4a0ae65 100644
--- a/arch/x86/vdso/vdso32-setup.c
+++ b/arch/x86/vdso/vdso32-setup.c
@@ -210,6 +210,9 @@ static int use_sysenter __read_mostly = -1;
 /* May not be __init: called during resume */
 void syscall32_cpu_init(void)
 {
+#ifndef CONFIG_XEN
+	/*FIXME: handle using pvops */
+
 	if (use_sysenter < 0)
 		use_sysenter = (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL);
 
@@ -220,6 +223,7 @@ void syscall32_cpu_init(void)
 	checking_wrmsrl(MSR_IA32_SYSENTER_EIP, (u64)ia32_sysenter_target);
 
 	wrmsrl(MSR_CSTAR, ia32_cstar_target);
+#endif
 }
 
 #define compat_uses_vma		1
-- 
1.5.4.1


linux-2.6-xen-0094-Use-__KERNEL_DS-as-SS-when-returning-to-a-kernel-thr.patch:

--- NEW FILE linux-2.6-xen-0094-Use-__KERNEL_DS-as-SS-when-returning-to-a-kernel-thr.patch ---
>From 15d0d1641d1e74bb833740f7356b533002b70985 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 4 Jan 2008 11:35:15 -0200
Subject: [PATCH] Use __KERNEL_DS as SS when returning to a kernel thread (VERIFY)

This is needed when the kernel is running on RING3, such as under Xen.
x86_64 has a weird feature that makes it #GP on iret when SS is a null
descriptor.

This need to be tested on bare metal to make sure it doesn't cause any
problems. AMD specs say SS is always ignored (except on iret?).

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/entry_64.S |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index db76caa..9f31c00 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -104,7 +104,8 @@ ENTRY(native_irq_enable_syscall_ret)
 	.macro FAKE_STACK_FRAME child_rip
 	/* push in order ss, rsp, eflags, cs, rip */
 	xorl %eax, %eax
-	pushq %rax /* ss */
+	/*FIXME: check if this causes problems on bare metal */
+	pushq $__KERNEL_DS /* ss */
 	CFI_ADJUST_CFA_OFFSET	8
 	/*CFI_REL_OFFSET	ss,0*/
 	pushq %rax /* rsp */
-- 
1.5.4.1


linux-2.6-xen-0095-Use-apic_xen-on-genapic-by-default-FIXME.patch:

--- NEW FILE linux-2.6-xen-0095-Use-apic_xen-on-genapic-by-default-FIXME.patch ---
>From f4bb90bffd9e24b88c6c17b623d1dd0c97bf1da3 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 13:37:35 -0200
Subject: [PATCH] Use apic_xen on genapic, by default (FIXME)

Needs to be handled at runtime.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/genapic_64.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/genapic_64.c b/arch/x86/kernel/genapic_64.c
index 4ae7b64..d983406 100644
--- a/arch/x86/kernel/genapic_64.c
+++ b/arch/x86/kernel/genapic_64.c
@@ -31,13 +31,24 @@ void *x86_cpu_to_apicid_early_ptr;
 DEFINE_PER_CPU(u16, x86_cpu_to_apicid) = BAD_APICID;
 EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
 
+
+#ifdef CONFIG_XEN
+/*FIXME: move to the proper header file */
+extern struct genapic apic_xen;
+struct genapic __read_mostly *genapic = &apic_xen;
+#else
 struct genapic __read_mostly *genapic = &apic_flat;
+#endif
 
 /*
  * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
  */
 void __init setup_apic_routing(void)
 {
+#ifdef CONFIG_XEN
+	/*FIXME: handle this at runtime */
+	genapic = &apic_xen;
+#else
 #ifdef CONFIG_ACPI
 	/*
 	 * Quirk: some x86_64 machines can only use physical APIC mode
@@ -55,6 +66,7 @@ void __init setup_apic_routing(void)
 	else
 		genapic = &apic_physflat;
 
+#endif  /* CONFIG_XEN else */
 	printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name);
 }
 
-- 
1.5.4.1


linux-2.6-xen-0096-irq-vector-ifdef-chainsaw-FIXME.patch:

--- NEW FILE linux-2.6-xen-0096-irq-vector-ifdef-chainsaw-FIXME.patch ---
>From 94b498aaac840510cf6c67f574eccc54e90208c5 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 4 Jan 2008 11:36:34 -0200
Subject: [PATCH] irq<->vector #ifdef chainsaw (FIXME)

Xen doesn't need the vector<->irq translation.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/irq_64.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
index 3aac154..f5e486c 100644
--- a/arch/x86/kernel/irq_64.c
+++ b/arch/x86/kernel/irq_64.c
@@ -167,7 +167,12 @@ asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
 
 	exit_idle();
 	irq_enter();
+#ifdef CONFIG_XEN
+	/*FIXME: make vector_irq[] make sense, at runtime */
+	irq = vector;
+#else
 	irq = __get_cpu_var(vector_irq)[vector];
+#endif
 
 #ifdef CONFIG_DEBUG_STACKOVERFLOW
 	stack_overflow_check(regs);
-- 
1.5.4.1


linux-2.6-xen-0097-ifdef-chainsaw-on-syscall_init-FIXME.patch:

--- NEW FILE linux-2.6-xen-0097-ifdef-chainsaw-on-syscall_init-FIXME.patch ---
>From 73476f105e7c6797f6f3bd15c31d10e3265fbd84 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 4 Jan 2008 11:39:15 -0200
Subject: [PATCH] ifdef chainsaw on syscall_init() (FIXME)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/setup64.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/setup64.c b/arch/x86/kernel/setup64.c
index 2cb06bf..7d06197 100644
--- a/arch/x86/kernel/setup64.c
+++ b/arch/x86/kernel/setup64.c
@@ -163,6 +163,8 @@ extern asmlinkage void ignore_sysret(void);
 /* May not be marked __init: used by software suspend */
 void syscall_init(void)
 {
+#ifndef CONFIG_XEN
+	/*FIXME: handle this using pvops */
 	/* 
 	 * LSTAR and STAR live in a bit strange symbiosis.
 	 * They both write to the same internal register. STAR allows to set CS/DS
@@ -171,14 +173,17 @@ void syscall_init(void)
 	wrmsrl(MSR_STAR,  ((u64)__USER32_CS)<<48  | ((u64)__KERNEL_CS)<<32); 
 	wrmsrl(MSR_LSTAR, system_call); 
 	wrmsrl(MSR_CSTAR, ignore_sysret);
+#endif
 
 #ifdef CONFIG_IA32_EMULATION   		
 	syscall32_cpu_init ();
 #endif
 
+#ifndef CONFIG_XEN
 	/* Flags to clear on syscall */
 	wrmsrl(MSR_SYSCALL_MASK,
 	       X86_EFLAGS_TF|X86_EFLAGS_DF|X86_EFLAGS_IF|X86_EFLAGS_IOPL);
+#endif
 }
 
 void __cpuinit check_efer(void)
-- 
1.5.4.1


linux-2.6-xen-0098-Pull-xen-genapic-implementation-from-upstream-Xen.patch:

--- NEW FILE linux-2.6-xen-0098-Pull-xen-genapic-implementation-from-upstream-Xen.patch ---
>From 8cee3ac4ea014f74b5615b7d932972537052e486 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 4 Jan 2008 11:40:38 -0200
Subject: [PATCH] Pull xen genapic implementation from upstream Xen

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/Makefile  |    2 +-
 arch/x86/xen/genapic.c |  190 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 191 insertions(+), 1 deletions(-)
 create mode 100644 arch/x86/xen/genapic.c

diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
index e2dc9c1..147dde2 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -4,7 +4,7 @@ obj-y		:= enlighten.o setup.o features.o multicalls.o mmu.o \
 ifeq ($(CONFIG_X86_32),y)
 obj-y 	+= init_32.o
 else
-obj-y	+= init_64.o
+obj-y	+= init_64.o genapic.o
 endif
 
 obj-$(CONFIG_SMP)	+= smp.o
diff --git a/arch/x86/xen/genapic.c b/arch/x86/xen/genapic.c
new file mode 100644
index 0000000..0b9e74e
--- /dev/null
+++ b/arch/x86/xen/genapic.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2004 James Cleverdon, IBM.
+ * Subject to the GNU Public License, v.2
+ *
+ * Xen APIC subarch code.  Maximum 8 CPUs, logical delivery.
+ *
+ * Hacked for x86-64 by James Cleverdon from i386 architecture code by
+ * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
+ * James Cleverdon.
+ *
+ * Hacked to pieces for Xen by Chris Wright.
+ */
+#include <linux/threads.h>
+#include <linux/cpumask.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/ctype.h>
+#include <linux/init.h>
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
+#include <asm/smp.h>
+#include <asm/ipi.h>
+#else
+#include <asm/apic.h>
+#include <asm/apicdef.h>
+#endif
+#include <asm/genapic.h>
+#include <xen/events.h>
+
+DECLARE_PER_CPU(int, ipi_to_irq[XEN_NR_IPIS]);
+
+static inline void __send_IPI_one(unsigned int cpu, int vector)
+{
+	int irq = per_cpu(ipi_to_irq, cpu)[vector];
+	BUG_ON(irq < 0);
+	notify_remote_via_irq(irq);
+}
+
+void xen_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest)
+{
+	int cpu;
+
+	switch (shortcut) {
+	case APIC_DEST_SELF:
+		__send_IPI_one(smp_processor_id(), vector);
+		break;
+	case APIC_DEST_ALLBUT:
+		for (cpu = 0; cpu < NR_CPUS; ++cpu) {
+			if (cpu == smp_processor_id())
+				continue;
+			if (cpu_isset(cpu, cpu_online_map)) {
+				__send_IPI_one(cpu, vector);
+			}
+		}
+		break;
+	case APIC_DEST_ALLINC:
+		for (cpu = 0; cpu < NR_CPUS; ++cpu) {
+			if (cpu_isset(cpu, cpu_online_map)) {
+				__send_IPI_one(cpu, vector);
+			}
+		}
+		break;
+	default:
+		printk("XXXXXX __send_IPI_shortcut %08x vector %d\n", shortcut,
+		       vector);
+		break;
+	}
+}
+
+static cpumask_t xen_target_cpus(void)
+{
+	return cpu_online_map;
+}
+
+static cpumask_t xen_vector_allocation_domain(int cpu)
+{
+	/* Careful. Some cpus do not strictly honor the set of cpus
+	 * specified in the interrupt destination when using lowest
+	 * priority interrupt delivery mode.
+	 *
+	 * In particular there was a hyperthreading cpu observed to
+	 * deliver interrupts to the wrong hyperthread when only one
+	 * hyperthread was specified in the interrupt desitination.
+	 */
+	cpumask_t domain = { { [0] = APIC_ALL_CPUS, } };
+	return domain;
+}
+
+/*
+ * Set up the logical destination ID.
+ * Do nothing, not called now.
+ */
+static void xen_init_apic_ldr(void)
+{
+	Dprintk("%s\n", __FUNCTION__);
+	return;
+}
+
+static void xen_send_IPI_mask(cpumask_t cpumask, int vector)
+{
+	unsigned long mask = cpus_addr(cpumask)[0];
+	unsigned int cpu;
+	unsigned long flags;
+
+	Dprintk("%s\n", __FUNCTION__);
+	local_irq_save(flags);
+	WARN_ON(mask & ~cpus_addr(cpu_online_map)[0]);
+
+	for (cpu = 0; cpu < NR_CPUS; ++cpu) {
+		if (cpu_isset(cpu, cpumask)) {
+			__send_IPI_one(cpu, vector);
+		}
+	}
+	local_irq_restore(flags);
+}
+
+static void xen_send_IPI_allbutself(int vector)
+{
+#ifdef	CONFIG_HOTPLUG_CPU
+	int hotplug = 1;
+#else
+	int hotplug = 0;
+#endif
+	/*
+	 * if there are no other CPUs in the system then
+	 * we get an APIC send error if we try to broadcast.
+	 * thus we have to avoid sending IPIs in this case.
+	 */
+	Dprintk("%s\n", __FUNCTION__);
+	if (hotplug || vector == NMI_VECTOR) {
+		cpumask_t allbutme = cpu_online_map;
+
+		cpu_clear(smp_processor_id(), allbutme);
+
+		if (!cpus_empty(allbutme))
+			xen_send_IPI_mask(allbutme, vector);
+	} else if (num_online_cpus() > 1) {
+		xen_send_IPI_shortcut(APIC_DEST_ALLBUT, vector, APIC_DEST_LOGICAL);
+	}
+}
+
+static void xen_send_IPI_all(int vector)
+{
+	Dprintk("%s\n", __FUNCTION__);
+	if (vector == NMI_VECTOR)
+		xen_send_IPI_mask(cpu_online_map, vector);
+	else
+		xen_send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
+}
+
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
+static int xen_apic_id_registered(void)
+{
+	/* better be set */
+	Dprintk("%s\n", __FUNCTION__);
+	return physid_isset(smp_processor_id(), phys_cpu_present_map);
+}
+#endif
+
+static unsigned int xen_cpu_mask_to_apicid(cpumask_t cpumask)
+{
+	Dprintk("%s\n", __FUNCTION__);
+	return cpus_addr(cpumask)[0] & APIC_ALL_CPUS;
+}
+
+static unsigned int phys_pkg_id(int index_msb)
+{
+	int ebx;
+	Dprintk("%s\n", __FUNCTION__);
+	ebx = cpuid_ebx(1);
+	return ((ebx >> 24) & 0xFF) >> index_msb;
+}
+
+struct genapic apic_xen =  {
+	.name = "xen",
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
+	.int_delivery_mode = dest_LowestPrio,
+#endif
+	.int_dest_mode = (APIC_DEST_LOGICAL != 0),
+	.target_cpus = xen_target_cpus,
+	.vector_allocation_domain = xen_vector_allocation_domain,
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
+	.apic_id_registered = xen_apic_id_registered,
+#endif
+	.init_apic_ldr = xen_init_apic_ldr,
+	.send_IPI_all = xen_send_IPI_all,
+	.send_IPI_allbutself = xen_send_IPI_allbutself,
+	.send_IPI_mask = xen_send_IPI_mask,
+	.cpu_mask_to_apicid = xen_cpu_mask_to_apicid,
+	.phys_pkg_id = phys_pkg_id,
+};
-- 
1.5.4.1


linux-2.6-xen-0099-Debugging-printk-s.patch:

--- NEW FILE linux-2.6-xen-0099-Debugging-printk-s.patch ---
>From ec592a2eb12f9748e599f67e3e1e15eefe825973 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 4 Jan 2008 11:41:38 -0200
Subject: [PATCH] Debugging printk()s

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 init/main.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/init/main.c b/init/main.c
index 4aad2d4..df6f3ed 100644
--- a/init/main.c
+++ b/init/main.c
@@ -580,17 +580,25 @@ asmlinkage void __init start_kernel(void)
 	rcu_init();
 	init_IRQ();
 	pidhash_init();
+	printk("init_timers:\n");
 	init_timers();
 	hrtimers_init();
 	softirq_init();
+	printk("timekeeping:\n");
 	timekeeping_init();
+	printk("time:\n");
 	time_init();
+	printk("profile:\n");
 	profile_init();
+	printk("irqs_disabled:\n");
 	if (!irqs_disabled())
 		printk("start_kernel(): bug: interrupts were enabled early\n");
+	printk("early_boot_irqs_on:\n");
 	early_boot_irqs_on();
+	printk("local_irq_enable:\n");
 	local_irq_enable();
 
+	printk("console_init:\n");
 	/*
 	 * HACK ALERT! This is early. We're enabling the console before
 	 * we've done PCI setups etc, and console_init() must be aware of
@@ -627,7 +635,9 @@ asmlinkage void __init start_kernel(void)
 	numa_policy_init();
 	if (late_time_init)
 		late_time_init();
+	printk("calibrate_delay:\n");
 	calibrate_delay();
+	printk("pidmap_init:\n");
 	pidmap_init();
 	pgtable_cache_init();
 	prio_tree_init();
-- 
1.5.4.1


linux-2.6-xen-0100-Leave-lazy_cpu_mode-on-__switch_to.patch:

--- NEW FILE linux-2.6-xen-0100-Leave-lazy_cpu_mode-on-__switch_to.patch ---
>From 411c2ec49b8401bfa7609c26234f7c5df1f52ca7 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 4 Jan 2008 11:43:40 -0200
Subject: [PATCH] Leave lazy_cpu_mode() on __switch_to()

Just like it is done on i386.

Note, We must leave lazy mode before switching the %fs and %gs
selectors.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/process_64.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 46c4c54..cf9ff51 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -628,6 +628,15 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
 
 	load_TLS(next, cpu);
 
+	/*
+	 * Leave lazy mode, flushing any hypercalls made here.
+	 * This must be done before restoring TLS segments so
+	 * the GDT and LDT are properly updated, and must be
+	 * done before math_state_restore, so the TS bit is up
+	 * to date.
+	 */
+	arch_leave_lazy_cpu_mode();
+
 	/* 
 	 * Switch FS and GS.
 	 */
-- 
1.5.4.1


linux-2.6-xen-0101-xen-64-Handle-fs-and-gs-on-xen_load_tls-properl.patch:

--- NEW FILE linux-2.6-xen-0101-xen-64-Handle-fs-and-gs-on-xen_load_tls-properl.patch ---
>From 3eb650d5317a06c6ca4fa0740e3f0a55f05bdffc Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 4 Jan 2008 11:45:33 -0200
Subject: [PATCH] xen-64: Handle %fs and %gs on xen_load_tls() properly

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 97fa630..5377f41 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -422,6 +422,7 @@ static void xen_load_tls(struct thread_struct *t, unsigned int cpu)
 
 	xen_mc_issue(PARAVIRT_LAZY_CPU);
 
+#ifdef CONFIG_X86_32
 	/*
 	 * XXX sleazy hack: If we're being called in a lazy-cpu zone,
 	 * it means we're in a context switch, and %gs has just been
@@ -430,9 +431,21 @@ static void xen_load_tls(struct thread_struct *t, unsigned int cpu)
 	 * Either way, it has been saved, and the new value will get
 	 * loaded properly.  This will go away as soon as Xen has been
 	 * modified to not save/restore %gs for normal hypercalls.
+	 *
+	 * This hack is not used on x86_64, because:
+	 * - For %gs: x86_64 gs points to KERNEL_GS_BASE (and uses it for PDA
+	 *   references), so we must not zero %gs on x86_64
+	 * - For %fs: x86_64 may have %fs pointing to TLS descriptors, but
+	 *   __switch_to() reads %fs after load_TLS(). We can't clear it
+	 *
+	 * FIXME: we need to be sure we don't _need_ the hack on x86_64.
+	 * Can we get a #GP when switch back from the hypervisor if
+	 * TLS descriptor is cleared but %fs still points to it?
 	 */
-	if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_CPU)
+	if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_CPU) {
 		loadsegment(gs, 0);
+	}
+#endif
 }
 
 static void xen_write_ldt_entry(struct desc_struct *dt, int entrynum,
-- 
1.5.4.1


linux-2.6-xen-0102-Disable-vcpu_info_placement-temporarily-FIXME.patch:

--- NEW FILE linux-2.6-xen-0102-Disable-vcpu_info_placement-temporarily-FIXME.patch ---
>From 4d4ae974dc48d579b9539cbc3a6fd8cc9fb51812 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 4 Jan 2008 11:46:49 -0200
Subject: [PATCH] Disable vcpu_info_placement temporarily (FIXME)

We are trying to make it work without it, first.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 5377f41..17687e6 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -121,6 +121,9 @@ static void __init xen_vcpu_setup(int cpu)
 	printk(KERN_DEBUG "trying to map vcpu_info %d at %p, mfn %llx, offset %d\n",
 	       cpu, vcpup, info.mfn, info.offset);
 
+#ifdef CONFIG_x86_32
+	/*FIXME: implement this support on x86_64 */
+
 	/* Check to see if the hypervisor will put the vcpu_info
 	   structure where we want it, which allows direct access via
 	   a percpu-variable. */
@@ -137,6 +140,10 @@ static void __init xen_vcpu_setup(int cpu)
 		printk(KERN_DEBUG "cpu %d using vcpu_info at %p\n",
 		       cpu, vcpup);
 	}
+#else
+	have_vcpu_info_placement = 0;
+#endif
+
 }
 
 static void kcons_write_dom0(const char *s, unsigned int count)
-- 
1.5.4.1


linux-2.6-xen-0103-Fix-typo-on-ifdef-again.patch:

--- NEW FILE linux-2.6-xen-0103-Fix-typo-on-ifdef-again.patch ---
>From d4ed01e1d56b13d4fe93ec324971e63a11e9e6d5 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 19:13:01 -0200
Subject: [PATCH] Fix typo on #ifdef (again)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 17687e6..2fceedd 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -121,7 +121,7 @@ static void __init xen_vcpu_setup(int cpu)
 	printk(KERN_DEBUG "trying to map vcpu_info %d at %p, mfn %llx, offset %d\n",
 	       cpu, vcpup, info.mfn, info.offset);
 
-#ifdef CONFIG_x86_32
+#ifdef CONFIG_X86_32
 	/*FIXME: implement this support on x86_64 */
 
 	/* Check to see if the hypervisor will put the vcpu_info
-- 
1.5.4.1


linux-2.6-xen-0104-DEBUG-Don-t-try-to-actually-read-the-page-on-show_.patch:

--- NEW FILE linux-2.6-xen-0104-DEBUG-Don-t-try-to-actually-read-the-page-on-show_.patch ---
>From 0b2c042076d44cb2a80ff2550713f21655a99d81 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 4 Jan 2008 12:23:34 -0200
Subject: [PATCH] (DEBUG) Don't try to actually read the page on show_pgtable1()

It is crashing.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 9df9ee4..48f9912 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -91,7 +91,7 @@ void show_pgtable1(pte_t *tbl, unsigned long addr)
 	page = vvva(pv & PHYSICAL_PAGE_MASK);
 
 	xprintk("\npage: %p\n", page);
-	xprintk("\npage val: %lx\n", *page);
+	//xprintk("\npage val: %lx\n", *page);
 }
 
 void show_pgtable2(pmd_t *tbl, unsigned long addr)
-- 
1.5.4.1


linux-2.6-xen-0105-Make-load_gs_index-a-paravirt-operation.patch:

--- NEW FILE linux-2.6-xen-0105-Make-load_gs_index-a-paravirt-operation.patch ---
>From d02a193e0f491a1a82e2eb0905af609d037f607e Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 4 Jan 2008 12:33:43 -0200
Subject: [PATCH] Make load_gs_index() a paravirt operation

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/entry_64.S |    4 ++--
 arch/x86/kernel/paravirt.c |    3 +++
 include/asm-x86/paravirt.h |   10 +++++++++-
 include/asm-x86/system.h   |    3 ++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 9f31c00..9952c3f 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -967,7 +967,7 @@ KPROBE_END(error_entry)
 	
        /* Reload gs selector with exception handling */
        /* edi:  new selector */ 
-ENTRY(load_gs_index)
+ENTRY(native_load_gs_index)
 	CFI_STARTPROC
 	pushf
 	CFI_ADJUST_CFA_OFFSET 8
@@ -981,7 +981,7 @@ gs_change:
 	CFI_ADJUST_CFA_OFFSET -8
         ret
 	CFI_ENDPROC
-ENDPROC(load_gs_index)
+ENDPROC(native_load_gs_index)
        
         .section __ex_table,"a"
         .align 8
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index 47f42bf..3f75e88 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -340,6 +340,9 @@ struct pv_cpu_ops pv_cpu_ops = {
 	.store_idt = native_store_idt,
 	.store_tr = native_store_tr,
 	.load_tls = native_load_tls,
+#ifdef CONFIG_X86_64
+	.load_gs_index = native_load_gs_index,
+#endif
 	.write_ldt_entry = native_write_ldt_entry,
 	.write_gdt_entry = native_write_gdt_entry,
 	.write_idt_entry = native_write_idt_entry,
diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
index 7edbeda..292db13 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -118,6 +118,9 @@ struct pv_cpu_ops {
 #endif
 	unsigned long (*store_tr)(void);
 	void (*load_tls)(struct thread_struct *t, unsigned int cpu);
+#ifdef CONFIG_X86_64
+	void (*load_gs_index)(unsigned int idx);
+#endif
 	void (*write_ldt_entry)(struct desc_struct *ldt, int entrynum,
 				const void *desc);
 	void (*write_gdt_entry)(struct desc_struct *,
@@ -798,7 +801,12 @@ static inline void load_TLS(struct thread_struct *t, unsigned cpu)
 {
 	PVOP_VCALL2(pv_cpu_ops.load_tls, t, cpu);
 }
-
+#ifdef CONFIG_X86_64
+static inline void load_gs_index(unsigned int idx)
+{
+	PVOP_VCALL1(pv_cpu_ops.load_gs_index, idx);
+}
+#endif
 static inline void write_ldt_entry(struct desc_struct *dt, int entry,
 				   const void *desc)
 {
diff --git a/include/asm-x86/system.h b/include/asm-x86/system.h
index 9cff02f..d6623cb 100644
--- a/include/asm-x86/system.h
+++ b/include/asm-x86/system.h
@@ -114,7 +114,7 @@ __asm__ __volatile__ ("movw %%dx,%1\n\t" \
 #define set_base(ldt, base) _set_base(((char *)&(ldt)) , (base))
 #define set_limit(ldt, limit) _set_limit(((char *)&(ldt)) , ((limit)-1))
 
-extern void load_gs_index(unsigned);
+extern void native_load_gs_index(unsigned); 
 
 /*
  * Load a segment. Fall back on loading the zero
@@ -260,6 +260,7 @@ static inline void native_wbinvd(void)
 #ifdef CONFIG_X86_64
 #define read_cr8()	(native_read_cr8())
 #define write_cr8(x)	(native_write_cr8(x))
+#define load_gs_index   native_load_gs_index
 #endif
 
 /* Clear the 'TS' bit */
-- 
1.5.4.1


linux-2.6-xen-0106-xen-pgd_walk-use-limit-argument-instead-of-FIXADD.patch:

--- NEW FILE linux-2.6-xen-0106-xen-pgd_walk-use-limit-argument-instead-of-FIXADD.patch ---
>From 682b00f0631467c7767e4b8d365de9aeeed1febb Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 7 Jan 2008 19:06:06 -0200
Subject: [PATCH] xen pgd_walk: use 'limit' argument instead of FIXADDR_TOP constant

Eliminating the usage of FIXADDR_TOP inside of pgd_walk(), so it
can become 64-bit-ready.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/mmu.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 16020ec..1fbc3ce 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -361,11 +361,11 @@ static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return 0;
 
-	for (; addr != FIXADDR_TOP; pgd++, addr = pgd_next) {
+	for (; addr != limit; pgd++, addr = pgd_next) {
 		pud_t *pud;
 		unsigned long pud_limit, pud_next;
 
-		pgd_next = pud_limit = pgd_addr_end(addr, FIXADDR_TOP);
+		pgd_next = pud_limit = pgd_addr_end(addr, limit);
 
 		if (!pgd_val(*pgd))
 			continue;
@@ -379,12 +379,7 @@ static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 			pmd_t *pmd;
 			unsigned long pmd_limit;
 
-			pud_next = pud_addr_end(addr, pud_limit);
-
-			if (pud_next < limit)
-				pmd_limit = pud_next;
-			else
-				pmd_limit = limit;
+			pud_next = pmd_limit = pud_addr_end(addr, pud_limit);
 
 			if (pud_none(*pud))
 				continue;
-- 
1.5.4.1


linux-2.6-xen-0107-xen-pgd_walk-Eliminate-BUG_ON-limit-FIXADDR_TOP.patch:

--- NEW FILE linux-2.6-xen-0107-xen-pgd_walk-Eliminate-BUG_ON-limit-FIXADDR_TOP.patch ---
>From 782c4acc0769a49ec0d91be1a11f01aaa1005cc1 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 7 Jan 2008 19:07:26 -0200
Subject: [PATCH] xen pgd_walk: Eliminate BUG_ON(limit > FIXADDR_TOP)

This BUG_ON() is 32-bit-specific.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/mmu.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 1fbc3ce..4f8ab26 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -356,8 +356,6 @@ static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 	unsigned long addr = 0;
 	unsigned long pgd_next;
 
-	BUG_ON(limit > FIXADDR_TOP);
-
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return 0;
 
-- 
1.5.4.1


linux-2.6-xen-0108-xen-pgd_walk-accept-start-parameter.patch:

--- NEW FILE linux-2.6-xen-0108-xen-pgd_walk-accept-start-parameter.patch ---
>From 48a1766cf0c45b62b807cf5877514a08cdd87085 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 7 Jan 2008 19:15:35 -0200
Subject: [PATCH] xen pgd_walk: accept 'start' parameter

Change usage of pgd_walk() to work under x86_64 also.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/mmu.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 4f8ab26..eaf9652 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -349,16 +349,17 @@ void xen_set_pte(pte_t *ptep, pte_t pte)
   there, because then we start getting into Xen's ptes.
 */
 static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
-		    unsigned long limit)
+		    unsigned long start, unsigned long limit)
 {
-	pgd_t *pgd = pgd_base;
+	pgd_t *pgd;
 	int flush = 0;
-	unsigned long addr = 0;
+	unsigned long addr = start;
 	unsigned long pgd_next;
 
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return 0;
 
+	pgd = pgd_base + pgd_index(addr);
 	for (; addr != limit; pgd++, addr = pgd_next) {
 		pud_t *pud;
 		unsigned long pud_limit, pud_next;
@@ -486,7 +487,7 @@ void xen_pgd_pin(pgd_t *pgd)
 
 	xen_mc_batch();
 
-	if (pgd_walk(pgd, pin_page, TASK_SIZE)) {
+	if (pgd_walk(pgd, pin_page, 0, TASK_SIZE)) {
 		/* re-enable interrupts for kmap_flush_unused */
 		xen_mc_issue(0);
 		kmap_flush_unused();
@@ -513,9 +514,19 @@ static __init int mark_pinned(struct page *page, enum pt_level level)
 	return 0;
 }
 
+/* Addresses that will be walked on xen_mark_init_mm_pinned()
+ */
+#ifdef CONFIG_X86_32
+#  define INIT_MM_WALK_BEGIN 0
+#  define INIT_MM_WALK_END   FIXADDR_TOP
+#else
+#  define INIT_MM_WALK_BEGIN __START_KERNEL_map
+#  define INIT_MM_WALK_END   (__START_KERNEL_map + PGDIR_SIZE)
+#endif
+
 void __init xen_mark_init_mm_pinned(void)
 {
-	pgd_walk(init_mm.pgd, mark_pinned, FIXADDR_TOP);
+	pgd_walk(init_mm.pgd, mark_pinned, INIT_MM_WALK_BEGIN, INIT_MM_WALK_END);
 }
 
 static int unpin_page(struct page *page, enum pt_level level)
@@ -556,7 +567,7 @@ static void xen_pgd_unpin(pgd_t *pgd)
 
 	xen_do_pin(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(pgd)));
 
-	pgd_walk(pgd, unpin_page, TASK_SIZE);
+	pgd_walk(pgd, unpin_page, 0, TASK_SIZE);
 
 	xen_mc_issue(0);
 }
-- 
1.5.4.1


linux-2.6-xen-0109-xen-64-reserve_bootmem-xen_start_info-area.patch:

--- NEW FILE linux-2.6-xen-0109-xen-64-reserve_bootmem-xen_start_info-area.patch ---
>From 72990d9cb491968f2832d86ad7c8c7289d544f72 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 14 Jan 2008 19:51:36 -0200
Subject: [PATCH] xen-64: reserve_bootmem() xen_start_info area

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/setup_64.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index 5c44c2e..03a22e5 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -419,6 +419,11 @@ void __init setup_arch(char **cmdline_p)
 	reserve_bootmem(__pa(xen_start_info->pt_base),
 			xen_start_info->nr_pt_frames*PAGE_SIZE,
 			BOOTMEM_DEFAULT);
+
+	/* Reserve xen_start_info area */
+	reserve_bootmem(__pa(xen_start_info),
+			sizeof(*xen_start_info),
+			BOOTMEM_DEFAULT);
 #endif
 
        /*
-- 
1.5.4.1


linux-2.6-xen-0110-pvops-64-call-paravirt_post_allocator_init-on-set.patch:

--- NEW FILE linux-2.6-xen-0110-pvops-64-call-paravirt_post_allocator_init-on-set.patch ---
>From 5a43dd767557854f6fb5baaffd4b1ea7eb5874d0 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 14 Jan 2008 19:52:23 -0200
Subject: [PATCH] pvops-64: call paravirt_post_allocator_init() on setup_arch()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/setup_64.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index 03a22e5..479c782 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -455,6 +455,8 @@ void __init setup_arch(char **cmdline_p)
 	paravirt_pagetable_setup_start(swapper_pg_dir);
 	paging_init();
 	paravirt_pagetable_setup_done(swapper_pg_dir);
+	paravirt_post_allocator_init();
+
 	map_vsyscall();
 
 	early_quirks();
-- 
1.5.4.1


linux-2.6-xen-0111-use-write_gdt_entry-on-vsyscall_set_cpu-CLEANME.patch:

--- NEW FILE linux-2.6-xen-0111-use-write_gdt_entry-on-vsyscall_set_cpu-CLEANME.patch ---
>From 032db17d0a2c3871adcb8e07424d1ed138d85ad2 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 14 Jan 2008 19:53:14 -0200
Subject: [PATCH] use write_gdt_entry() on vsyscall_set_cpu() (CLEANME)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/vsyscall_64.c |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index edff4c9..49273b9 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -249,7 +249,8 @@ static ctl_table kernel_root_table2[] = {
    doesn't violate that. We'll find out if it does. */
 static void __cpuinit vsyscall_set_cpu(int cpu)
 {
-	unsigned long *d;
+	unsigned long v;
+	struct desc_struct *d;
 	unsigned long node = 0;
 #ifdef CONFIG_NUMA
 	node = cpu_to_node(cpu);
@@ -260,11 +261,27 @@ static void __cpuinit vsyscall_set_cpu(int cpu)
 	/* Store cpu number in limit so that it can be loaded quickly
 	   in user space in vgetcpu.
 	   12 bits for the CPU and 8 bits for the node. */
-	d = (unsigned long *)(get_cpu_gdt_table(cpu) + GDT_ENTRY_PER_CPU);
-	*d = 0x0f40000000000ULL;
-	*d |= cpu;
-	*d |= (node & 0xf) << 12;
-	*d |= (node >> 4) << 48;
+#if 0
+	d = (struct desc_struct*)&v;
+	d.limit0 = 0;
+	d.base0 = 0;
+	d.base1 = 0;
+	d.type = 4; //FIXME: constant?
+	d.s = 1;
+	d.dpl = 3;
+	d.p = 1;
+	d.limit = 0;
+	d.avl = d.l = d.d = d.g = 0;
+#else
+	v = 0x0000f40000000000ULL;
+#endif
+	v |= cpu;
+	v |= (node & 0xf) << 12;
+	v |= (node >> 4) << 48;
+
+	//printk("limit0: %lx, base0: %lx, base1: %lx, type: %lx, s: %d, dpl: %d, p: %d, limit: %lx, avl: %d, l: %d, d: %d, g: %d, base2: %lx\n", d->limit0, d->base0, d->base1, d->type, d->s, d->dpl, d->p, d->limit, d->avl, d->l, d->d, d->g, d->base2);
+
+	write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_PER_CPU, &v, sizeof(v));
 }
 
 static void __cpuinit cpu_vsyscall_init(void *arg)
-- 
1.5.4.1


linux-2.6-xen-0112-xen-64-implement-xen_load_gs_index.patch:

--- NEW FILE linux-2.6-xen-0112-xen-64-implement-xen_load_gs_index.patch ---
>From 6a9fbb993d87720227e167ed20b478b57b8efa69 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 14 Jan 2008 19:56:21 -0200
Subject: [PATCH] xen-64: implement xen_load_gs_index()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 2fceedd..1404bb2 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -455,6 +455,13 @@ static void xen_load_tls(struct thread_struct *t, unsigned int cpu)
 #endif
 }
 
+#ifdef CONFIG_X86_64
+static void xen_load_gs_index(unsigned int idx)
+{
+	HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL, idx);
+}
+#endif
+
 static void xen_write_ldt_entry(struct desc_struct *dt, int entrynum,
 				const void *ptr)
 {
@@ -1172,6 +1179,9 @@ static const struct pv_cpu_ops xen_cpu_ops __initdata = {
 	.load_gdt = xen_load_gdt,
 	.load_idt = xen_load_idt,
 	.load_tls = xen_load_tls,
+#ifdef CONFIG_X86_64
+	.load_gs_index = xen_load_gs_index,
+#endif
 
 	.store_gdt = native_store_gdt,
 	.store_idt = native_store_idt,
-- 
1.5.4.1


linux-2.6-xen-0113-include-asm-x86-pgalloc_64.h-pvops-hacks-SPLITME.patch:

--- NEW FILE linux-2.6-xen-0113-include-asm-x86-pgalloc_64.h-pvops-hacks-SPLITME.patch ---
>From 738819041db19177517cf41aa90fa2b10e172595 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 14 Jan 2008 20:01:22 -0200
Subject: [PATCH] include/asm-x86/pgalloc_64.h pvops hacks (SPLITME)

- Xen-specific:
  - Create __user_pgd()
  - Change pgd allocation to allocate two pages

- Not xen-specific:
  - pagetable allocation hooks

- Maybe other stuff

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/pgalloc_64.h |   68 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/include/asm-x86/pgalloc_64.h b/include/asm-x86/pgalloc_64.h
index b9835d6..1188281 100644
--- a/include/asm-x86/pgalloc_64.h
+++ b/include/asm-x86/pgalloc_64.h
@@ -13,17 +13,37 @@
 #define arch_remove_exec_range(mm, limit) \
 		do { (void)(mm), (void)(limit); } while (0)
 
-#define pmd_populate_kernel(mm, pmd, pte) \
-		set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte)))
-#define pud_populate(mm, pud, pmd) \
-		set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)))
-#define pgd_populate(mm, pgd, pud) \
-		set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)))
+#ifdef CONFIG_XEN
+
+extern pud_t level3_user_pgt[512];
+
+/*FIXME: use pvops */
+static pgd_t *__user_pgd(pgd_t *pgd)
+{
+	return pgd + PTRS_PER_PGD;
+}
+
+#endif
+
+#define pmd_populate_kernel(mm, pmd, pte) do { \
+		paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT); \
+		set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte))); \
+		} while (0)
+#define pud_populate(mm, pud, pmd) do { \
+		paravirt_alloc_pd(mm, __pa(pmd) >> PAGE_SHIFT); \
+		set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd))); \
+		} while (0)
+#define pgd_populate(mm, pgd, pud) do {\
+		paravirt_alloc_pd(mm, __pa(pud) >> PAGE_SHIFT); \
+		set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud))); \
+		set_pgd(__user_pgd(pgd), __pgd(_PAGE_TABLE | __pa(pud))); \
+		} while (0)
 
 #define pmd_pgtable(pmd) pmd_page(pmd)
 
 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
 {
+	paravirt_alloc_pt(mm, page_to_pfn(pte)); \
 	set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT)));
 }
 
@@ -35,12 +55,16 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
 
 static inline pmd_t *pmd_alloc_one (struct mm_struct *mm, unsigned long addr)
 {
-	return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
+	pmd_t *pmd = (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
+	paravirt_alloc_pd(mm, __pa(pmd) >> PAGE_SHIFT);
+	return pmd;
 }
 
 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
 {
-	return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
+	pud_t *pud = (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
+	paravirt_alloc_pd(mm, __pa(pud) >> PAGE_SHIFT);
+	return pud;
 }
 
 static inline void pud_free(struct mm_struct *mm, pud_t *pud)
@@ -72,7 +96,7 @@ static inline void pgd_list_del(pgd_t *pgd)
 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
 	unsigned boundary;
-	pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	pgd_t *pgd = (pgd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT, 1);
 	if (!pgd)
 		return NULL;
 	pgd_list_add(pgd);
@@ -86,6 +110,14 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 	memcpy(pgd + boundary,
 	       init_level4_pgt + boundary,
 	       (PTRS_PER_PGD - boundary) * sizeof(pgd_t));
+
+	memset(__user_pgd(pgd), 0, PAGE_SIZE); /* clean up user pgd */
+	/*
+	 * Set level3_user_pgt for vsyscall area
+	 */
+	set_pgd(__user_pgd(pgd) + pgd_index(VSYSCALL_START), 
+		mk_kernel_pgd(__pa_symbol(level3_user_pgt)));
+
 	return pgd;
 }
 
@@ -93,7 +125,9 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
 {
 	BUG_ON((unsigned long)pgd & (PAGE_SIZE-1));
 	pgd_list_del(pgd);
-	free_page((unsigned long)pgd);
+
+	/*FIXME: unpin and mark as rw */
+	free_pages((unsigned long)pgd, 1);
 }
 
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
@@ -132,10 +166,20 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
 #define __pte_free_tlb(tlb,pte)				\
 do {							\
 	pgtable_page_dtor((pte));				\
+	paravirt_release_pt(page_to_pfn(pte));		\
 	tlb_remove_page((tlb), (pte));			\
 } while (0)
 
-#define __pmd_free_tlb(tlb,x)   tlb_remove_page((tlb),virt_to_page(x))
-#define __pud_free_tlb(tlb,x)   tlb_remove_page((tlb),virt_to_page(x))
+#define __pmd_free_tlb(tlb,x)				\
+do {							\
+	paravirt_release_pd(page_to_pfn(virt_to_page(x)));	\
+	tlb_remove_page((tlb),virt_to_page(x));			\
+} while (0)
+
+#define __pud_free_tlb(tlb,x)				\
+do {							\
+	paravirt_release_pd(page_to_pfn(virt_to_page(x)));	\
+	tlb_remove_page((tlb),virt_to_page(x));			\
+} while (0)
 
 #endif /* _X86_64_PGALLOC_H */
-- 
1.5.4.1


linux-2.6-xen-0114-Multi-pagetable-write_cr3-implementation-FIXME.patch:

--- NEW FILE linux-2.6-xen-0114-Multi-pagetable-write_cr3-implementation-FIXME.patch ---
>From 07081b977de05414171ee424fbdc5d34cc093cbc Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 14 Jan 2008 20:02:02 -0200
Subject: [PATCH] Multi-pagetable write_cr3() implementation (FIXME)

x86_64-specific. Needs #ifdefs.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 1404bb2..82c34c3 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -37,6 +37,7 @@
 
 #include <asm/paravirt.h>
 #include <asm/page.h>
+#include <asm/pgalloc.h>
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
 #include <asm/fixmap.h>
@@ -742,7 +743,10 @@ static void xen_write_cr3(unsigned long cr3)
 
 	BUG_ON(preemptible());
 
-	mcs = xen_mc_entry(sizeof(*op));  /* disables interrupts */
+	xen_mc_batch();  /* disables interrupts */
+
+
+	mcs = __xen_mc_entry(sizeof(*op));
 
 	/* Update while interrupts are disabled, so its atomic with
 	   respect to ipis */
@@ -758,9 +762,32 @@ static void xen_write_cr3(unsigned long cr3)
 	   been submitted. */
 	xen_mc_callback(set_current_cr3, (void *)cr3);
 
+#ifdef CONFIG_X86_64
+	{
+	pgd_t *pgd = __va(cr3);
+	unsigned long user_mfn = virt_to_mfn(__user_pgd(pgd));
+
+	mcs = __xen_mc_entry(sizeof(*op));
+
+	op = mcs.args;
+	op->cmd = MMUEXT_NEW_USER_BASEPTR;
+	/* pgd_alloc() allocates two pages for us. the second one is the
+	 * user page table
+	 */
+	op->arg1.mfn = user_mfn;
+
+	MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF);
+	}
+#endif
+
 	xen_mc_issue(PARAVIRT_LAZY_CPU);  /* interrupts restored */
 }
 
+#ifdef CONFIG_X86_64
+#if 0
+/*
+ * FIXME: unused
+ */
 static void xen_new_user_baseptr(unsigned long pfn)
 {
 	struct mmuext_op *op;
@@ -779,6 +806,8 @@ static void xen_new_user_baseptr(unsigned long pfn)
 
 	xen_mc_issue(PARAVIRT_LAZY_CPU);  /* interrupts restored */
 }
+#endif
+#endif
 
 /* Early in boot, while setting up the initial pagetable, assume
    everything is pinned. */
-- 
1.5.4.1


linux-2.6-xen-0115-Make-kcons_write_dom0-non-static-TEMPORARY.patch:

--- NEW FILE linux-2.6-xen-0115-Make-kcons_write_dom0-non-static-TEMPORARY.patch ---
>From edbdcdf5b153da991d01783c01d8664d8a6f8781 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 15:14:54 -0200
Subject: [PATCH] Make kcons_write_dom0() non-static (TEMPORARY)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 82c34c3..5c74aef 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -147,7 +147,7 @@ static void __init xen_vcpu_setup(int cpu)
 
 }
 
-static void kcons_write_dom0(const char *s, unsigned int count)
+void kcons_write_dom0(const char *s, unsigned int count)
 {
        int rc;
 
-- 
1.5.4.1


linux-2.6-xen-0116-Disable-the-weird-count-loop-on-kcons_write_dom0.patch:

--- NEW FILE linux-2.6-xen-0116-Disable-the-weird-count-loop-on-kcons_write_dom0.patch ---
>From 52017942a0817a85ded61b7921cf62b490133ce4 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 15:15:34 -0200
Subject: [PATCH] Disable the weird count loop on kcons_write_dom0()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 5c74aef..ce3961b 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -149,6 +149,7 @@ static void __init xen_vcpu_setup(int cpu)
 
 void kcons_write_dom0(const char *s, unsigned int count)
 {
+#if 0
        int rc;
 
        while ((count > 0) &&
@@ -157,6 +158,9 @@ void kcons_write_dom0(const char *s, unsigned int count)
                count -= rc;
                s += rc;
        }
+#else
+	HYPERVISOR_console_io(CONSOLEIO_write, count, (char *)s);
+#endif
 }
 
 
-- 
1.5.4.1


linux-2.6-xen-0117-Make-xen_start_info-read-only.patch:

--- NEW FILE linux-2.6-xen-0117-Make-xen_start_info-read-only.patch ---
>From d979c416c1e34fea6f33d692a7cba70f033a1db8 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 14 Jan 2008 20:20:55 -0200
Subject: [PATCH] Make xen_start_info read-only

It will aid debugging, catching if anybody tries to write to it.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 48f9912..0e017e5 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -495,6 +495,12 @@ static void xen_finish_init_mapping(void)
 			__va(__pa(xen_start_info->mod_start));
 
 	xprintk("messed with start_info.\n");
+	xprintk("making it read-only:\n");
+
+	/* Make it read-only to catch if anybody touches it by accident.
+	 */
+	__make_page_readonly(xen_start_info);
+
 	xprintk("unmapping:\n");
 
 	/* Destroy the Xen-created mappings beyond the kernel image as
-- 
1.5.4.1


linux-2.6-xen-0118-Hack-to-implement-return-to-userspace-without-SWAPGS.patch:

--- NEW FILE linux-2.6-xen-0118-Hack-to-implement-return-to-userspace-without-SWAPGS.patch ---
>From e0cb0ee7c19f296ec242d60fb63525daf31e8a18 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 18 Jan 2008 17:12:43 -0200
Subject: [PATCH] Hack to implement return to userspace without SWAPGS (CLEANME)

Implementing SWAPGS as nop wouldn't be good, because code using it may
really expect a swapgs operation to be done. It is better to make each
operation that use swapgs to be a paravirt op.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/entry_64.S |   15 ++++++++++++++-
 arch/x86/xen/entry_64.S    |   10 ++++++++++
 2 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 9952c3f..1182250 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -66,6 +66,17 @@ ENTRY(native_irq_enable_syscall_ret)
 #endif /* CONFIG_PARAVIRT */
 
 
+/*FIXME: implement this as a paravirt op */
+#ifdef CONFIG_XEN
+#define retint_swapgs xen_retint_swapgs
+#define error_userspace error_sti
+#else
+#define retint_swapgs native_retint_swapgs
+#define error_userspace error_swapgs
+#endif
+
+
+
 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
 #ifdef CONFIG_TRACE_IRQFLAGS
 	bt   $9,EFLAGS-\offset(%rsp)	/* interrupts off? */
@@ -564,8 +575,9 @@ retint_check:
 	andl %edi,%edx
 	CFI_REMEMBER_STATE
 	jnz  retint_careful
+	jmp retint_swapgs
 
-retint_swapgs:		/* return to user-space */
+native_retint_swapgs:		/* return to user-space */
 	/*
 	 * The iretq could re-enable interrupts:
 	 */
@@ -912,6 +924,7 @@ KPROBE_ENTRY(error_entry)
 	xorl %ebx,%ebx	
 	testl $3,CS(%rsp)
 	je  error_kernelspace
+	jmp error_userspace
 error_swapgs:	
 	SWAPGS
 error_sti:	
diff --git a/arch/x86/xen/entry_64.S b/arch/x86/xen/entry_64.S
index 927108c..2a2a0a0 100644
--- a/arch/x86/xen/entry_64.S
+++ b/arch/x86/xen/entry_64.S
@@ -41,3 +41,13 @@ ENTRY(do_hypervisor_callback)   # do_hypervisor_callback(struct *pt_regs)
 	jmp  error_exit
 	CFI_ENDPROC
 END(do_hypervisor_callback)
+
+
+ENTRY(xen_retint_swapgs)		/* return to user-space */
+	/*
+	 * The iretq could re-enable interrupts:
+	 */
+	DISABLE_INTERRUPTS(CLBR_ANY)
+	TRACE_IRQS_IRETQ
+	jmp restore_args
+END(xen_retint_swapgs)
-- 
1.5.4.1


linux-2.6-xen-0119-Xen-SEGBASE_-defines.patch:

--- NEW FILE linux-2.6-xen-0119-Xen-SEGBASE_-defines.patch ---
>From 1b54824286552da7c3ff179645ecfaa7022073d2 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 15:36:24 -0200
Subject: [PATCH] Xen: SEGBASE_* defines

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/xen/interface.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/xen/interface.h b/include/asm-x86/xen/interface.h
index ab69adb..cb77b3f 100644
--- a/include/asm-x86/xen/interface.h
+++ b/include/asm-x86/xen/interface.h
@@ -96,6 +96,17 @@ DEFINE_GUEST_HANDLE(void);
 #ifndef __ASSEMBLY__
 
 /*
+ * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base)
+ *  @which == SEGBASE_*  ;  @base == 64-bit base address
+ * Returns 0 on success.
+ */
+#define SEGBASE_FS          0
+#define SEGBASE_GS_USER     1
+#define SEGBASE_GS_KERNEL   2
+#define SEGBASE_GS_USER_SEL 3 /* Set user %gs specified in base[15:0] */
+
+
+/*
  * Send an array of these to HYPERVISOR_set_trap_table()
  */
 #define TI_GET_DPL(_ti)		((_ti)->flags & 3)
-- 
1.5.4.1


linux-2.6-xen-0120-Xen-HYPERVISOR_set_segment_base-implementation.patch:

--- NEW FILE linux-2.6-xen-0120-Xen-HYPERVISOR_set_segment_base-implementation.patch ---
>From fee88f76dd229e39d3f401ef80874e64c6b375f7 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 15:37:20 -0200
Subject: [PATCH] Xen: HYPERVISOR_set_segment_base() implementation

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/xen/hypercall.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
index 0588d6d..965b823 100644
--- a/include/asm-x86/xen/hypercall.h
+++ b/include/asm-x86/xen/hypercall.h
@@ -400,6 +400,16 @@ HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args)
 	return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
 }
 
+#ifdef CONFIG_X86_64
+static inline int
+HYPERVISOR_set_segment_base(
+	int reg, unsigned long value)
+{
+	return _hypercall2(int, set_segment_base, reg, value);
+}
+#endif
+
+
 static inline int
 HYPERVISOR_suspend(unsigned long srec)
 {
-- 
1.5.4.1


linux-2.6-xen-0121-Change-signature-of-paravirt_alloc_-pt-pd-REVIEWME.patch:

--- NEW FILE linux-2.6-xen-0121-Change-signature-of-paravirt_alloc_-pt-pd-REVIEWME.patch ---
>From 516a41002c57b63cc26f142afe34b40e4e85159b Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 16:02:24 -0200
Subject: [PATCH] Change signature of paravirt_alloc_{pt,pd} (REVIEWME)

Use 'unsigned long' instead of u32.

Question: will 'unsigned long' work on 32-bit PAE?

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c   |   17 +++++++++--------
 include/asm-x86/paravirt.h |   18 +++++++++---------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index ce3961b..64bfde9 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -815,7 +815,7 @@ static void xen_new_user_baseptr(unsigned long pfn)
 
 /* Early in boot, while setting up the initial pagetable, assume
    everything is pinned. */
-static __init void xen_alloc_pt_init(struct mm_struct *mm, u32 pfn)
+static __init void xen_alloc_pt_init(struct mm_struct *mm, unsigned long pfn)
 {
 	BUG_ON(mem_map);	/* should only be used early */
 	make_lowmem_page_readonly(__va(PFN_PHYS(pfn)));
@@ -823,7 +823,7 @@ static __init void xen_alloc_pt_init(struct mm_struct *mm, u32 pfn)
 
 /* Early release_pt assumes that all pts are pinned, since there's
    only init_mm and anything attached to that is pinned. */
-static void xen_release_pt_init(u32 pfn)
+static void xen_release_pt_init(unsigned long pfn)
 {
 	make_lowmem_page_readwrite(__va(PFN_PHYS(pfn)));
 }
@@ -839,7 +839,8 @@ static void pin_pagetable_pfn(unsigned cmd, unsigned long pfn)
 
 /* This needs to make sure the new pte page is pinned iff its being
    attached to a pinned pagetable. */
-static void xen_alloc_ptpage(struct mm_struct *mm, u32 pfn, unsigned level)
+static void xen_alloc_ptpage(struct mm_struct *mm, unsigned long pfn,
+			     unsigned level)
 {
 	struct page *page = pfn_to_page(pfn);
 
@@ -857,18 +858,18 @@ static void xen_alloc_ptpage(struct mm_struct *mm, u32 pfn, unsigned level)
 	}
 }
 
-static void xen_alloc_pt(struct mm_struct *mm, u32 pfn)
+static void xen_alloc_pt(struct mm_struct *mm, unsigned long pfn)
 {
 	xen_alloc_ptpage(mm, pfn, PT_PTE);
 }
 
-static void xen_alloc_pd(struct mm_struct *mm, u32 pfn)
+static void xen_alloc_pd(struct mm_struct *mm, unsigned long pfn)
 {
 	xen_alloc_ptpage(mm, pfn, PT_PMD);
 }
 
 /* This should never happen until we're OK to use struct page */
-static void xen_release_ptpage(u32 pfn, unsigned level)
+static void xen_release_ptpage(unsigned long pfn, unsigned level)
 {
 	struct page *page = pfn_to_page(pfn);
 
@@ -882,12 +883,12 @@ static void xen_release_ptpage(u32 pfn, unsigned level)
 	}
 }
 
-static void xen_release_pt(u32 pfn)
+static void xen_release_pt(unsigned long pfn)
 {
 	xen_release_ptpage(pfn, PT_PTE);
 }
 
-static void xen_release_pd(u32 pfn)
+static void xen_release_pd(unsigned long pfn)
 {
 	xen_release_ptpage(pfn, PT_PMD);
 }
diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
index 292db13..20a930f 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -236,11 +236,11 @@ struct pv_mmu_ops {
 				 unsigned long va);
 
 	/* Hooks for allocating/releasing pagetable pages */
-	void (*alloc_pt)(struct mm_struct *mm, u32 pfn);
-	void (*alloc_pd)(struct mm_struct *mm, u32 pfn);
-	void (*alloc_pd_clone)(u32 pfn, u32 clonepfn, u32 start, u32 count);
-	void (*release_pt)(u32 pfn);
-	void (*release_pd)(u32 pfn);
+	void (*alloc_pt)(struct mm_struct *mm, unsigned long pfn);
+	void (*alloc_pd)(struct mm_struct *mm, unsigned long pfn);
+	void (*alloc_pd_clone)(unsigned long pfn, unsigned long clonepfn, unsigned long start, unsigned long count);
+	void (*release_pt)(unsigned long pfn);
+	void (*release_pd)(unsigned long pfn);
 
 	/* Pagetable manipulation functions */
 	void (*set_pte)(pte_t *ptep, pte_t pteval);
@@ -929,11 +929,11 @@ static inline void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
 	PVOP_VCALL3(pv_mmu_ops.flush_tlb_others, &cpumask, mm, va);
 }
 
-static inline void paravirt_alloc_pt(struct mm_struct *mm, unsigned pfn)
+static inline void paravirt_alloc_pt(struct mm_struct *mm, unsigned long pfn)
 {
 	PVOP_VCALL2(pv_mmu_ops.alloc_pt, mm, pfn);
 }
-static inline void paravirt_release_pt(unsigned pfn)
+static inline void paravirt_release_pt(unsigned long pfn)
 {
 	PVOP_VCALL1(pv_mmu_ops.release_pt, pfn);
 }
@@ -943,8 +943,8 @@ static inline void paravirt_alloc_pd(struct mm_struct *mm, unsigned pfn)
 	PVOP_VCALL2(pv_mmu_ops.alloc_pd, mm, pfn);
 }
 
-static inline void paravirt_alloc_pd_clone(unsigned pfn, unsigned clonepfn,
-					   unsigned start, unsigned count)
+static inline void paravirt_alloc_pd_clone(unsigned long pfn, unsigned long clonepfn,
+					   unsigned long start, unsigned long count)
 {
 	PVOP_VCALL4(pv_mmu_ops.alloc_pd_clone, pfn, clonepfn, start, count);
 }
-- 
1.5.4.1


linux-2.6-xen-0122-Comment-e820_print_map-call-TEMPORARY.patch:

--- NEW FILE linux-2.6-xen-0122-Comment-e820_print_map-call-TEMPORARY.patch ---
>From bd49ae20b61ea55ca9b95811aeab4e8dab6924b6 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 16:03:11 -0200
Subject: [PATCH] Comment e820_print_map() call (TEMPORARY)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 99b7463..1409021 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -50,7 +50,7 @@ char * __init xen_memory_setup(void)
 
 #ifdef CONFIG_X86_64
 	early_printk(KERN_INFO "Xen-provided physical RAM map:\n");
-	e820_print_map("Xen");
+	//e820_print_map("Xen");
 #endif
 	return "Xen";
 }
-- 
1.5.4.1


linux-2.6-xen-0123-Xen-missing-includes.patch:

--- NEW FILE linux-2.6-xen-0123-Xen-missing-includes.patch ---
>From b0d51d9ca43088fab22946229506aae3a6ef7a63 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 16:13:41 -0200
Subject: [PATCH] Xen: missing #includes

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/xen/events.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/xen/events.h b/include/xen/events.h
index 2bde54d..c18d2bf 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -3,6 +3,8 @@
 
 #include <linux/interrupt.h>
 
+#include <asm/xen/interface.h>
+#include <xen/interface/xen.h>
 #include <xen/interface/event_channel.h>
 #include <asm/xen/hypercall.h>
 
-- 
1.5.4.1


linux-2.6-xen-0124-asm-x86-pgtable_64.h-include-linux-spinlock.h.patch:

--- NEW FILE linux-2.6-xen-0124-asm-x86-pgtable_64.h-include-linux-spinlock.h.patch ---
>From f9d0c64d63bb7ba9fdc30c9a0ddd8bddf749004a Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 16:14:04 -0200
Subject: [PATCH] asm-x86/pgtable_64.h: #include <linux/spinlock.h>

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/pgtable_64.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
index d96a272..6c6e29d 100644
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -11,6 +11,7 @@
 #include <asm/processor.h>
 #include <linux/bitops.h>
 #include <linux/threads.h>
+#include <linux/spinlock.h>
 #include <asm/pda.h>
 
 extern pud_t level3_kernel_pgt[512];
-- 
1.5.4.1


linux-2.6-xen-0125-asm-x86-pgtable.h-include-asm-page.h.patch:

--- NEW FILE linux-2.6-xen-0125-asm-x86-pgtable.h-include-asm-page.h.patch ---
>From 3313946e4c3e2531993fe1a40f5b4e2d8115c2cb Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 16:14:25 -0200
Subject: [PATCH] asm-x86/pgtable.h: #include <asm/page.h>

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/pgtable.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 6b3979e..e6e22db 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -1,6 +1,8 @@
 #ifndef _ASM_X86_PGTABLE_H
 #define _ASM_X86_PGTABLE_H
 
+#include <asm/page.h>
+
 #define USER_PTRS_PER_PGD	((TASK_SIZE-1)/PGDIR_SIZE+1)
 #define FIRST_USER_ADDRESS	0
 
-- 
1.5.4.1


linux-2.6-xen-0126-fix-pxxval_t-usage-on-mm-init_64.c.patch:

--- NEW FILE linux-2.6-xen-0126-fix-pxxval_t-usage-on-mm-init_64.c.patch ---
>From 60819cab41dec4fa8f5b75dc3dd5ad0c30da600c Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 16:15:55 -0200
Subject: [PATCH] fix pxxval_t usage on mm/init_64.c

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 0e017e5..44bf3fd 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -78,7 +78,7 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 void show_pgtable1(pte_t *tbl, unsigned long addr)
 {
 	pte_t *pte = tbl + pte_index(addr);
-	pte_val_t pv;
+	pteval_t pv;
 	unsigned long *page;
 
 	xprintk("\npte: %p\n", pte);
@@ -97,7 +97,7 @@ void show_pgtable1(pte_t *tbl, unsigned long addr)
 void show_pgtable2(pmd_t *tbl, unsigned long addr)
 {
 	pmd_t *pmd = tbl + pmd_index(addr);
-	pmd_val_t pv;
+	pmdval_t pv;
 
 	xprintk("\npmd: %p\n", pmd);
 	xprintk("\npmd val: %lx\n", pmd->pmd);
-- 
1.5.4.1


linux-2.6-xen-0127-Missing-Xen-include.patch:

--- NEW FILE linux-2.6-xen-0127-Missing-Xen-include.patch ---
>From d5d1513fc1d0371b846f8e9dca4604d87ad22749 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 16:18:18 -0200
Subject: [PATCH] Missing Xen #include

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 44bf3fd..e151e93 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -53,6 +53,7 @@
 #include <xen/page.h>
 #include <xen/hvc-console.h>
 #include <asm/xen/hypercall.h>
+#include <asm/xen/hypervisor.h>
 #include "../xen/init.h"
 #include "../xen/xen-ops.h"
 #endif
-- 
1.5.4.1


linux-2.6-xen-0128-un-static-ipi_to_irq.patch:

--- NEW FILE linux-2.6-xen-0128-un-static-ipi_to_irq.patch ---
>From 1364e55258572f5f12468184bd87d4fb9d5279f3 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 16:26:52 -0200
Subject: [PATCH] un-static ipi_to_irq

It is used by xen/genapic.c

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/events.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/events.c b/arch/x86/xen/events.c
index fa67e61..050fa52 100644
--- a/arch/x86/xen/events.c
+++ b/arch/x86/xen/events.c
@@ -49,7 +49,7 @@ static DEFINE_SPINLOCK(irq_mapping_update_lock);
 static DEFINE_PER_CPU(int, virq_to_irq[NR_VIRQS]) = {[0 ... NR_VIRQS-1] = -1};
 
 /* IRQ <-> IPI mapping */
-static DEFINE_PER_CPU(int, ipi_to_irq[XEN_NR_IPIS]) = {[0 ... XEN_NR_IPIS-1] = -1};
+DEFINE_PER_CPU(int, ipi_to_irq[XEN_NR_IPIS]) = {[0 ... XEN_NR_IPIS-1] = -1};
 
 /* Packed IRQ information: binding type, sub-type index, and event channel. */
 struct packed_irq
-- 
1.5.4.1


linux-2.6-xen-0129-Don-t-use-_PAGE_GLOBAL-bit-under-Xen-FIXME.patch:

--- NEW FILE linux-2.6-xen-0129-Don-t-use-_PAGE_GLOBAL-bit-under-Xen-FIXME.patch ---
>From 81aee7249580a09d0a8a1d286d6b8dec8b6f327b Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 17:26:40 -0200
Subject: [PATCH] Don't use _PAGE_GLOBAL bit under Xen (FIXME)

This needs to be done using pvops.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/pgtable.h |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index e6e22db..4d8d1b9 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -96,7 +96,12 @@ extern pteval_t __PAGE_KERNEL, __PAGE_KERNEL_EXEC;
 #ifdef CONFIG_X86_32
 # define MAKE_GLOBAL(x)			__pgprot((x))
 #else
-# define MAKE_GLOBAL(x)			__pgprot((x) | _PAGE_GLOBAL)
+# ifdef CONFIG_XEN
+/*FIXME: this need to be handled at runtime using pvops */
+#  define MAKE_GLOBAL(x)			__pgprot((x))
+# else
+#  define MAKE_GLOBAL(x)			__pgprot((x) | _PAGE_GLOBAL)
+# endif
 #endif
 
 #define PAGE_KERNEL			MAKE_GLOBAL(__PAGE_KERNEL)
-- 
1.5.4.1


linux-2.6-xen-0130-Trying-to-organize-the-xen-bootmem-allocation-mess.patch:

--- NEW FILE linux-2.6-xen-0130-Trying-to-organize-the-xen-bootmem-allocation-mess.patch ---
>From d3a9509b325a4cb4086238af0a197bdfbd00c08c Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 18:51:58 -0200
Subject: [PATCH] Trying to organize the xen bootmem allocation mess (REVIEWME)

See comments added to code to understand this.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c    |   47 +++++++++++++++++++++++++++++++++------------
 arch/x86/xen/enlighten.c |   15 +++++++++++++-
 arch/x86/xen/init.h      |    2 +-
 3 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index e151e93..e1a071f 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -275,9 +275,9 @@ static __init void *spp_getpage(void)
 
 	if (after_bootmem)
 		ptr = (void *) get_zeroed_page(GFP_ATOMIC);
-	else if (start_pfn < table_end) {
-		ptr = __va(start_pfn << PAGE_SHIFT);
-		start_pfn++;
+	else if (xen_alloc_pfn < table_end) {
+		ptr = __va(xen_alloc_pfn << PAGE_SHIFT);
+		xen_alloc_pfn++;
 		memset(ptr, 0, PAGE_SIZE);
 	} else
 		ptr = alloc_bootmem_pages(PAGE_SIZE);
@@ -410,7 +410,7 @@ native_set_fixmap(enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
 
 /*FIXME: this code should be enabled at runtime, somehow */
 
-unsigned long start_pfn;
+unsigned long xen_alloc_pfn;
 
 static __meminit void *alloc_low_page(unsigned long *phys)
 {
@@ -423,7 +423,7 @@ static __meminit void *alloc_low_page(unsigned long *phys)
 		return adr;
 	}
 
-	pfn = start_pfn++;
+	pfn = xen_alloc_pfn++;
 	*phys  = pfn << PAGE_SHIFT;
 
 	/* The address returned by __va() is not available yet.
@@ -456,7 +456,7 @@ int make_readonly(unsigned long paddr)
 	/* Make old page tables read-only. */
 	if (!xen_feature(XENFEAT_writable_page_tables)
 	    && (paddr >= (xen_start_info->pt_base - __START_KERNEL_map))
-	    && (paddr < (start_pfn << PAGE_SHIFT)))
+	    && (paddr < (xen_alloc_pfn << PAGE_SHIFT)))
 		readonly = 1;
 
 	/*
@@ -516,7 +516,7 @@ static void xen_finish_init_mapping(void)
 		WARN_ON(HYPERVISOR_update_va_mapping(
 			start, __pte_ma(0), 0));
 
-	/* Allocate pte's for initial fixmaps from 'start_pfn' allocator. */
+	/* Allocate pte's for initial fixmaps from 'xen_alloc_pfn' allocator. */
 	table_end = ~0UL;
 
 
@@ -551,8 +551,8 @@ static void xen_finish_init_mapping(void)
 					        >> PAGE_SHIFT,
 					    PAGE_KERNEL_RO));
 
-	/* Disable the 'start_pfn' allocator. */
-	table_end = start_pfn;
+	/* Disable the 'xen_alloc_pfn' allocator. */
+	table_end = xen_alloc_pfn;
 
 	xprintk("finished!\n");
 }
@@ -578,7 +578,7 @@ static void __init xen_extend_init_mapping(unsigned long tables_space)
 
 	/* Ensure init mappings cover kernel text/data and initial tables. */
 	while (va < (__START_KERNEL_map
-		     + (start_pfn << PAGE_SHIFT)
+		     + (xen_alloc_pfn << PAGE_SHIFT)
 		     + tables_space)) {
 		pmd = (pmd_t *)&page[pmd_index(va)];
 		if (pmd_none(*pmd)) {
@@ -753,6 +753,7 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end)
 				 */
 				if (make_readonly(address))
 					attrs &= ~_PAGE_RW;
+
 				__set_pte(pte, __pte(address | attrs));
 			}
 			pte = pte_save;
@@ -833,10 +834,10 @@ static void __init find_early_table_space(unsigned long end)
 	/*FIXME: what does this do? */
 	xen_extend_init_mapping(tables);
 
-	table_start = start_pfn;
+	table_start = xen_alloc_pfn;
 	table_end = table_start + (tables>>PAGE_SHIFT);
 
-	early_printk("kernel direct mapping tables up to %lx @ %lx-%lx\n",
+	printk("kernel direct mapping tables up to %lx @ %lx-%lx\n",
 		end, table_start << PAGE_SHIFT,
 		(table_start << PAGE_SHIFT) + tables);
 }
@@ -917,16 +918,36 @@ void __init_refok init_memory_mapping(unsigned long start, unsigned long end)
 
 	if (!after_bootmem) {
 #ifdef CONFIG_XEN
-		BUG_ON(start_pfn != table_end);
+		BUG_ON(xen_alloc_pfn != table_end);
 		xen_finish_init_mapping();
 #endif
 		mmu_cr4_features = read_cr4();
 	}
 	__flush_tlb_all();
 
+	/*FIXME: Xen early allocation is messy-messy-messy:
+	 *
+	 * - memory from spp_getpage() needs to be reserved
+	 * - memory from alloc_low_page() needs to be reserved
+	 * - memory from spp_getpage() is being reserved on
+	 *   xen_pagetable_setup_start(), using xen_alloc_pfn and
+	 *   xen_start_pfn
+	 * - memory from alloc_low_page() should be reserved here,
+	 *   like on non-Xen. But it is already being reserved
+	 *   with the spp_getpage() memory. This is why there is
+	 *   a #ifndef below
+	 *
+	 * - Probably keeping spp_getpage() as-is would work,
+	 *   but first I need to understand how the non-Xen version
+	 *   of it works and why XS upstream has different code
+	 *   - If that works, we may remove lots of xen-specific
+	 *     bootmem reservation
+	 */
+#ifndef CONFIG_XEN
 	if (!after_bootmem)
 		reserve_early(table_start << PAGE_SHIFT,
 				 table_end << PAGE_SHIFT, "PGTABLE");
+#endif
 }
 
 #ifndef CONFIG_NUMA
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 64bfde9..ba9e4d1 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -929,6 +929,11 @@ static __init void xen_set_pte_init(pte_t *ptep, pte_t pte)
 	xen_set_pte(ptep, pte);
 }
 
+
+#ifdef CONFIG_X86_64
+static unsigned long xen_start_pfn;
+#endif
+
 static __init void xen_pagetable_setup_start(pgd_t *base)
 {
 #ifdef CONFIG_X86_32
@@ -1042,6 +1047,12 @@ static __init void xen_pagetable_setup_done(pgd_t *base)
 		pin_pagetable_pfn(level, PFN_DOWN(__pa(base)));
 	}
 #endif
+
+#ifdef CONFIG_X86_64
+	reserve_bootmem(xen_start_pfn << PAGE_SHIFT,
+			(xen_alloc_pfn - xen_start_pfn) << PAGE_SHIFT,
+			BOOTMEM_DEFAULT);
+#endif
 }
 
 /* This is called once we have the cpu_possible_map */
@@ -1393,6 +1404,8 @@ static void __init xen_reserve_top(void)
 #define xen_reserve_top() do { } while (0)
 #endif
 
+
+
 /* First C function to be called on Xen boot */
 asmlinkage void __init xen_start_kernel(void)
 {
@@ -1451,7 +1464,7 @@ asmlinkage void __init xen_start_kernel(void)
 
 #ifdef CONFIG_X86_64
 	/* used by alloc_low_page() */
-	start_pfn = PFN_UP(__pa_symbol(xen_start_info->pt_base)) + xen_start_info->nr_pt_frames;
+	xen_start_pfn = xen_alloc_pfn = PFN_UP(__pa_symbol(xen_start_info->pt_base)) + xen_start_info->nr_pt_frames;
 #endif
 
 #ifdef CONFIG_X86_32
diff --git a/arch/x86/xen/init.h b/arch/x86/xen/init.h
index fee0c05..6d91d3e 100644
--- a/arch/x86/xen/init.h
+++ b/arch/x86/xen/init.h
@@ -6,7 +6,7 @@ void xen_init_pt(void);
 extern pud_t level3_user_pgt[512];
 extern pgd_t init_level4_user_pgt[];
 
-extern unsigned long start_pfn;
+extern unsigned long xen_alloc_pfn;
 
 void early_make_page_readonly(void *va, unsigned int feature);
 
-- 
1.5.4.1


linux-2.6-xen-0131-Don-t-call-xprintk-when-writing-to-hvc-console.patch:

--- NEW FILE linux-2.6-xen-0131-Don-t-call-xprintk-when-writing-to-hvc-console.patch ---
>From 5fa561fc4264fba7a996f3235d62f2660caccd7d Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 23 Jan 2008 18:54:07 -0200
Subject: [PATCH] Don't call xprintk() when writing to hvc console

This doesn't work after some point on boot.

As it was being used just for debugging, I am dropping
the code instead of investigating why.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 drivers/char/hvc_xen.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c
index 6e0ec3a..dd68f85 100644
--- a/drivers/char/hvc_xen.c
+++ b/drivers/char/hvc_xen.c
@@ -55,9 +55,6 @@ static int write_console(uint32_t vtermno, const char *data, int len)
 	struct xencons_interface *intf = xencons_interface();
 	XENCONS_RING_IDX cons, prod;
 	int sent = 0;
-	char fmt[16];
-	sprintf(fmt, "%%%ds", len);
-	xprintk(fmt, data);
 
 	cons = intf->out_cons;
 	prod = intf->out_prod;
-- 
1.5.4.1


linux-2.6-xen-0132-Xen-reserve_bootmem-xenstore-and-console-interfac.patch:

--- NEW FILE linux-2.6-xen-0132-Xen-reserve_bootmem-xenstore-and-console-interfac.patch ---
>From 517231df8e4eab4a3721e465b132cfeca4b98e95 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 25 Jan 2008 11:16:57 -0200
Subject: [PATCH] Xen: reserve_bootmem() xenstore and console interface pages

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/setup_64.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index 479c782..e2ba835 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -424,6 +424,14 @@ void __init setup_arch(char **cmdline_p)
 	reserve_bootmem(__pa(xen_start_info),
 			sizeof(*xen_start_info),
 			BOOTMEM_DEFAULT);
+
+	if (!is_initial_xendomain()) {
+		/* Reserve the xenstore and console interface pages */
+		reserve_bootmem(mfn_to_pfn(xen_start_info->store_mfn) << PAGE_SHIFT,
+				PAGE_SIZE, BOOTMEM_DEFAULT);
+		reserve_bootmem(mfn_to_pfn(xen_start_info->console.domU.mfn) << PAGE_SHIFT,
+				PAGE_SIZE, BOOTMEM_DEFAULT);
+	}
 #endif
 
        /*
-- 
1.5.4.1


linux-2.6-xen-0133-pvops-64-call-paravirt_activate_mm-on-activate_mm.patch:

--- NEW FILE linux-2.6-xen-0133-pvops-64-call-paravirt_activate_mm-on-activate_mm.patch ---
>From 9d189087606508e5ff87bd2235a62aba3862038e Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 25 Jan 2008 12:01:11 -0200
Subject: [PATCH] pvops-64: call paravirt_activate_mm() on activate_mm()

This hook was forgotten on 64-bit paravirt_ops.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/mmu_context_64.h |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/asm-x86/mmu_context_64.h b/include/asm-x86/mmu_context_64.h
index ad6dc82..1327119 100644
--- a/include/asm-x86/mmu_context_64.h
+++ b/include/asm-x86/mmu_context_64.h
@@ -65,7 +65,9 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 } while(0)
 
 #define activate_mm(prev, next) \
-	switch_mm((prev),(next),NULL)
-
+	do {						\
+		paravirt_activate_mm(prev, next);	\
+		switch_mm((prev),(next),NULL);		\
+	} while (0)
 
 #endif
-- 
1.5.4.1


linux-2.6-xen-0134-Xen-64-bit-support-on-xen_pgd_pin.patch:

--- NEW FILE linux-2.6-xen-0134-Xen-64-bit-support-on-xen_pgd_pin.patch ---
>From 5283942234603065e6d9993b4ceec84d3bcb2d96 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 25 Jan 2008 12:04:10 -0200
Subject: [PATCH] Xen: 64-bit support on xen_pgd_pin()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/mmu.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index eaf9652..fad7f1d 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -494,7 +494,9 @@ void xen_pgd_pin(pgd_t *pgd)
 		xen_mc_batch();
 	}
 
-#ifdef CONFIG_X86_PAE
+#ifdef CONFIG_X86_64
+	level = MMUEXT_PIN_L4_TABLE;
+#elif defined(CONFIG_X86_PAE)
 	level = MMUEXT_PIN_L3_TABLE;
 #else
 	level = MMUEXT_PIN_L2_TABLE;
-- 
1.5.4.1


linux-2.6-xen-0135-Xen-64-pin-user-PGD-on-activate_mm-and-dup_mmap.patch:

--- NEW FILE linux-2.6-xen-0135-Xen-64-pin-user-PGD-on-activate_mm-and-dup_mmap.patch ---
>From 3f06b5e990d7ffc97a36c27dfe60d948352cfc37 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 25 Jan 2008 12:05:30 -0200
Subject: [PATCH] Xen-64: pin user PGD on activate_mm() and dup_mmap()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/mmu.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index fad7f1d..59d8306 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -578,6 +578,9 @@ void xen_activate_mm(struct mm_struct *prev, struct mm_struct *next)
 {
 	spin_lock(&next->page_table_lock);
 	xen_pgd_pin(next->pgd);
+#ifdef CONFIG_X86_64
+	xen_pgd_pin(__user_pgd(next->pgd));
+#endif
 	spin_unlock(&next->page_table_lock);
 }
 
@@ -585,6 +588,9 @@ void xen_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
 {
 	spin_lock(&mm->page_table_lock);
 	xen_pgd_pin(mm->pgd);
+#ifdef CONFIG_X86_64
+	xen_pgd_pin(__user_pgd(mm->pgd));
+#endif
 	spin_unlock(&mm->page_table_lock);
 }
 
-- 
1.5.4.1


linux-2.6-xen-0136-pgd_walk-changes-to-make-pgd-pinning-work-FIXME.patch:

--- NEW FILE linux-2.6-xen-0136-pgd_walk-changes-to-make-pgd-pinning-work-FIXME.patch ---
>From c99b22335f498f473ceb987d15822107e83aadd3 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 25 Jan 2008 12:20:28 -0200
Subject: [PATCH] pgd_walk() changes to make pgd pinning work (FIXME)

To be investigated:
- Why walking to TASK_SIZE isn't enough
- The child-first walking probably won't work for unpinning
- Check if lock_pte() usage is correct for x86_64 also

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/mmu.c |   30 ++++++++++++++++++++----------
 1 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 59d8306..92a8252 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -356,12 +356,20 @@ static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 	unsigned long addr = start;
 	unsigned long pgd_next;
 
+	/*FIXME: the child-first walk order probably won't work for unpin_page()
+	 */
+
+#ifdef CONFIG_X86_64
+	/*FIXME: investigate why walking to TASK_SIZE isn't enough on x86_64 */
+	limit += PAGE_SIZE;
+#endif
+
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return 0;
 
 	pgd = pgd_base + pgd_index(addr);
 	for (; addr != limit; pgd++, addr = pgd_next) {
-		pud_t *pud;
+		pud_t *pud, *pud0;
 		unsigned long pud_limit, pud_next;
 
 		pgd_next = pud_limit = pgd_addr_end(addr, limit);
@@ -369,13 +377,10 @@ static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 		if (!pgd_val(*pgd))
 			continue;
 
-		pud = pud_offset(pgd, 0);
-
-		if (PTRS_PER_PUD > 1) /* not folded */
-			flush |= (*func)(virt_to_page(pud), PT_PUD);
+		pud0 = pud = pud_offset(pgd, 0);
 
 		for (; addr != pud_limit; pud++, addr = pud_next) {
-			pmd_t *pmd;
+			pmd_t *pmd, *pmd0;
 			unsigned long pmd_limit;
 
 			pud_next = pmd_limit = pud_addr_end(addr, pud_limit);
@@ -383,10 +388,7 @@ static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 			if (pud_none(*pud))
 				continue;
 
-			pmd = pmd_offset(pud, 0);
-
-			if (PTRS_PER_PMD > 1) /* not folded */
-				flush |= (*func)(virt_to_page(pmd), PT_PMD);
+			pmd0 = pmd = pmd_offset(pud, 0);
 
 			for (; addr != pmd_limit; pmd++) {
 				addr += (PAGE_SIZE * PTRS_PER_PTE);
@@ -400,7 +402,15 @@ static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 
 				flush |= (*func)(pmd_page(*pmd), PT_PTE);
 			}
+
+			if (PTRS_PER_PMD > 1) /* not folded */
+				flush |= (*func)(virt_to_page(pmd0), PT_PMD);
+
 		}
+
+		if (PTRS_PER_PUD > 1) /* not folded */
+			flush |= (*func)(virt_to_page(pud0), PT_PUD);
+
 	}
 
 	flush |= (*func)(virt_to_page(pgd_base), PT_PGD);
-- 
1.5.4.1


linux-2.6-xen-0137-Xen-Add-a-order-parameter-to-pgd_walk.patch:

--- NEW FILE linux-2.6-xen-0137-Xen-Add-a-order-parameter-to-pgd_walk.patch ---
>From d28fb0a32782e769f6858c66497bd17710dcf53b Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 8 Feb 2008 13:38:09 -0200
Subject: [PATCH] Xen: Add a order parameter to pgd_walk()

When pinning, we should pin the lower level pagetables first. When
unpinning, we should unpin the higher level pagetables first. The 'order'
parameter for pgd_walk() specifies which order should be used.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/mmu.c |   33 +++++++++++++++++++++++----------
 1 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 92a8252..186d780 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -338,6 +338,12 @@ void xen_set_pte(pte_t *ptep, pte_t pte)
 #endif
 
 
+/* pgd_walk() walk order */
+enum walk_order {
+	CHILD_FIRST,
+	PARENT_FIRST,
+};
+
 /*
   (Yet another) pagetable walker.  This one is intended for pinning a
   pagetable.  This means that it walks a pagetable and calls the
@@ -348,7 +354,7 @@ void xen_set_pte(pte_t *ptep, pte_t pte)
   FIXADDR_TOP.  But the important bit is that we don't pin beyond
   there, because then we start getting into Xen's ptes.
 */
-static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
+static int pgd_walk(enum walk_order order, pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 		    unsigned long start, unsigned long limit)
 {
 	pgd_t *pgd;
@@ -356,9 +362,6 @@ static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 	unsigned long addr = start;
 	unsigned long pgd_next;
 
-	/*FIXME: the child-first walk order probably won't work for unpin_page()
-	 */
-
 #ifdef CONFIG_X86_64
 	/*FIXME: investigate why walking to TASK_SIZE isn't enough on x86_64 */
 	limit += PAGE_SIZE;
@@ -367,6 +370,9 @@ static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return 0;
 
+	if (order == PARENT_FIRST)
+		flush |= (*func)(virt_to_page(pgd_base), PT_PGD);
+
 	pgd = pgd_base + pgd_index(addr);
 	for (; addr != limit; pgd++, addr = pgd_next) {
 		pud_t *pud, *pud0;
@@ -379,6 +385,9 @@ static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 
 		pud0 = pud = pud_offset(pgd, 0);
 
+		if (order == PARENT_FIRST && PTRS_PER_PUD > 1) /* not folded */
+			flush |= (*func)(virt_to_page(pud0), PT_PUD);
+
 		for (; addr != pud_limit; pud++, addr = pud_next) {
 			pmd_t *pmd, *pmd0;
 			unsigned long pmd_limit;
@@ -390,6 +399,9 @@ static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 
 			pmd0 = pmd = pmd_offset(pud, 0);
 
+			if (order == PARENT_FIRST && PTRS_PER_PMD > 1) /* not folded */
+				flush |= (*func)(virt_to_page(pmd0), PT_PMD);
+
 			for (; addr != pmd_limit; pmd++) {
 				addr += (PAGE_SIZE * PTRS_PER_PTE);
 				if ((pmd_limit-1) < (addr-1)) {
@@ -403,17 +415,18 @@ static int pgd_walk(pgd_t *pgd_base, int (*func)(struct page *, enum pt_level),
 				flush |= (*func)(pmd_page(*pmd), PT_PTE);
 			}
 
-			if (PTRS_PER_PMD > 1) /* not folded */
+			if (order == CHILD_FIRST && PTRS_PER_PMD > 1) /* not folded */
 				flush |= (*func)(virt_to_page(pmd0), PT_PMD);
 
 		}
 
-		if (PTRS_PER_PUD > 1) /* not folded */
+		if (order == CHILD_FIRST && PTRS_PER_PUD > 1) /* not folded */
 			flush |= (*func)(virt_to_page(pud0), PT_PUD);
 
 	}
 
-	flush |= (*func)(virt_to_page(pgd_base), PT_PGD);
+	if (order == CHILD_FIRST)
+		flush |= (*func)(virt_to_page(pgd_base), PT_PGD);
 
 	return flush;
 }
@@ -497,7 +510,7 @@ void xen_pgd_pin(pgd_t *pgd)
 
 	xen_mc_batch();
 
-	if (pgd_walk(pgd, pin_page, 0, TASK_SIZE)) {
+	if (pgd_walk(CHILD_FIRST, pgd, pin_page, 0, TASK_SIZE)) {
 		/* re-enable interrupts for kmap_flush_unused */
 		xen_mc_issue(0);
 		kmap_flush_unused();
@@ -538,7 +551,7 @@ static __init int mark_pinned(struct page *page, enum pt_level level)
 
 void __init xen_mark_init_mm_pinned(void)
 {
-	pgd_walk(init_mm.pgd, mark_pinned, INIT_MM_WALK_BEGIN, INIT_MM_WALK_END);
+	pgd_walk(CHILD_FIRST, init_mm.pgd, mark_pinned, INIT_MM_WALK_BEGIN, INIT_MM_WALK_END);
 }
 
 static int unpin_page(struct page *page, enum pt_level level)
@@ -579,7 +592,7 @@ static void xen_pgd_unpin(pgd_t *pgd)
 
 	xen_do_pin(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(pgd)));
 
-	pgd_walk(pgd, unpin_page, 0, TASK_SIZE);
+	pgd_walk(PARENT_FIRST, pgd, unpin_page, 0, TASK_SIZE);
 
 	xen_mc_issue(0);
 }
-- 
1.5.4.1


linux-2.6-xen-0138-Xen-64-Unpin-user-pagetable-on-xen_pgd_unpin.patch:

--- NEW FILE linux-2.6-xen-0138-Xen-64-Unpin-user-pagetable-on-xen_pgd_unpin.patch ---
>From 5393faca4c05356561746fca1f0159d7f41fbcb0 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 8 Feb 2008 13:41:33 -0200
Subject: [PATCH] Xen-64: Unpin user pagetable on xen_pgd_unpin()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/mmu.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 186d780..20a5f45 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -590,8 +590,14 @@ static void xen_pgd_unpin(pgd_t *pgd)
 {
 	xen_mc_batch();
 
+#ifdef CONFIG_X86_64
+	xen_do_pin(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(__user_pgd(pgd))));
+#endif
 	xen_do_pin(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(pgd)));
 
+#ifdef CONFIG_X86_64
+	pgd_walk(PARENT_FIRST, __user_pgd(pgd), unpin_page, 0, TASK_SIZE);
+#endif
 	pgd_walk(PARENT_FIRST, pgd, unpin_page, 0, TASK_SIZE);
 
 	xen_mc_issue(0);
-- 
1.5.4.1


linux-2.6-xen-0139-Use-un-pin_page-when-un-pinning-pgd.patch:

--- NEW FILE linux-2.6-xen-0139-Use-un-pin_page-when-un-pinning-pgd.patch ---
>From a395a498132c820819c720db1d5ef3ed8a466ec8 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 13 Feb 2008 13:24:31 -0200
Subject: [PATCH] Use (un)pin_page() when (un)pinning pgd

This will check the PG_pinned flag, so we avoid unpinning or pinning
pages twice.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/mmu.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 20a5f45..254cae6 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -525,7 +525,7 @@ void xen_pgd_pin(pgd_t *pgd)
 	level = MMUEXT_PIN_L2_TABLE;
 #endif
 
-	xen_do_pin(level, PFN_DOWN(__pa(pgd)));
+	pin_page(virt_to_page(pgd), PT_PGD);
 
 	xen_mc_issue(0);
 }
@@ -591,9 +591,9 @@ static void xen_pgd_unpin(pgd_t *pgd)
 	xen_mc_batch();
 
 #ifdef CONFIG_X86_64
-	xen_do_pin(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(__user_pgd(pgd))));
+	unpin_page(virt_to_page(__user_pgd(pgd)), PT_PGD);
 #endif
-	xen_do_pin(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(pgd)));
+	unpin_page(virt_to_page(pgd), PT_PGD);
 
 #ifdef CONFIG_X86_64
 	pgd_walk(PARENT_FIRST, __user_pgd(pgd), unpin_page, 0, TASK_SIZE);
-- 
1.5.4.1


linux-2.6-xen-0140-Allow-enabling-Xen-on-x86_64.patch:

--- NEW FILE linux-2.6-xen-0140-Allow-enabling-Xen-on-x86_64.patch ---
>From da6910d286150f520b0f7e2a48d30695966997e5 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 29 Feb 2008 13:07:13 -0300
Subject: [PATCH] Allow enabling Xen on x86_64

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/Kconfig |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
index ff6a56a..ef1aaf2 100644
--- a/arch/x86/xen/Kconfig
+++ b/arch/x86/xen/Kconfig
@@ -5,7 +5,6 @@
 config XEN
 	bool "Xen guest support"
 	select PARAVIRT
-	depends on X86_32
 	depends on X86_CMPXCHG && X86_TSC && !NEED_MULTIPLE_NODES && !(X86_VISWS || X86_VOYAGER)
 	help
 	  This is the Linux Xen port.  Enabling this will allow the
-- 
1.5.4.1


linux-2.6-xen-0141-Add-include-linux-spinlock_types.h-to-asm-x86-pgt.patch:

--- NEW FILE linux-2.6-xen-0141-Add-include-linux-spinlock_types.h-to-asm-x86-pgt.patch ---
>From 5fd90df9b76ff4725414e3d44327267ab7841bae Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 29 Feb 2008 13:21:11 -0300
Subject: [PATCH] Add #include <linux/spinlock_types.h> to asm-x86/pgtable.h

Needed for spinlock_t type.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/pgtable.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 4d8d1b9..29824af 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -137,6 +137,8 @@ extern pteval_t __PAGE_KERNEL, __PAGE_KERNEL_EXEC;
 
 #ifndef __ASSEMBLY__
 
+#include <linux/spinlock_types.h>
+
 /*
  * ZERO_PAGE is a global shared page that is always zero: used
  * for zero-mapped memory areas etc..
-- 
1.5.4.1


linux-2.6-xen-0142-Restore-some-sanity-on-the-initial-pagetable-bootmem.patch:

--- NEW FILE linux-2.6-xen-0142-Restore-some-sanity-on-the-initial-pagetable-bootmem.patch ---
>From 7d6117f330711b769911634cffd5d49e8845f3a3 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 29 Feb 2008 17:29:45 -0300
Subject: [PATCH] Restore some sanity on the initial pagetable bootmem reservation

One less #ifdef!  :)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c    |    8 +++-----
 arch/x86/xen/enlighten.c |    6 ------
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index e1a071f..e21c9a4 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -831,11 +831,11 @@ static void __init find_early_table_space(unsigned long end)
 		round_up(pmds * 8, PAGE_SIZE) + 
 		round_up(ptes * 8, PAGE_SIZE); 
 
-	/*FIXME: what does this do? */
+	table_start = xen_alloc_pfn;
+
 	xen_extend_init_mapping(tables);
 
-	table_start = xen_alloc_pfn;
-	table_end = table_start + (tables>>PAGE_SHIFT);
+	table_end = xen_alloc_pfn + (tables>>PAGE_SHIFT);
 
 	printk("kernel direct mapping tables up to %lx @ %lx-%lx\n",
 		end, table_start << PAGE_SHIFT,
@@ -943,11 +943,9 @@ void __init_refok init_memory_mapping(unsigned long start, unsigned long end)
 	 *   - If that works, we may remove lots of xen-specific
 	 *     bootmem reservation
 	 */
-#ifndef CONFIG_XEN
 	if (!after_bootmem)
 		reserve_early(table_start << PAGE_SHIFT,
 				 table_end << PAGE_SHIFT, "PGTABLE");
-#endif
 }
 
 #ifndef CONFIG_NUMA
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index ba9e4d1..c349af6 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1047,12 +1047,6 @@ static __init void xen_pagetable_setup_done(pgd_t *base)
 		pin_pagetable_pfn(level, PFN_DOWN(__pa(base)));
 	}
 #endif
-
-#ifdef CONFIG_X86_64
-	reserve_bootmem(xen_start_pfn << PAGE_SHIFT,
-			(xen_alloc_pfn - xen_start_pfn) << PAGE_SHIFT,
-			BOOTMEM_DEFAULT);
-#endif
 }
 
 /* This is called once we have the cpu_possible_map */
-- 
1.5.4.1


linux-2.6-xen-0143-Xen-Use-system_call_after_swapgs-as-the-syscall-c.patch:

--- NEW FILE linux-2.6-xen-0143-Xen-Use-system_call_after_swapgs-as-the-syscall-c.patch ---
>From 5e4175335c6aab9f17ea289f57d2fe9e36309192 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 25 Jan 2008 13:05:29 -0200
Subject: [PATCH] Xen: Use system_call_after_swapgs() as the syscall callback

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/setup.c    |    2 +-
 include/asm-x86/proto.h |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 1409021..a64385d 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -100,7 +100,7 @@ void __init xen_arch_setup(void)
 #else
 	HYPERVISOR_set_callbacks((unsigned long)xen_hypervisor_callback,
 				 (unsigned long)xen_failsafe_callback,
-				 (unsigned long)system_call);
+				 (unsigned long)system_call_after_swapgs);
 #endif
 
 	set_iopl.iopl = 1;
diff --git a/include/asm-x86/proto.h b/include/asm-x86/proto.h
index 68563c0..b562df5 100644
--- a/include/asm-x86/proto.h
+++ b/include/asm-x86/proto.h
@@ -10,6 +10,7 @@ extern void early_idt_handler(void);
 extern void init_memory_mapping(unsigned long start, unsigned long end);
 
 extern void system_call(void);
+extern void system_call_after_swapgs(void);
 extern void syscall_init(void);
 
 extern void ia32_syscall(void);
-- 
1.5.4.1


linux-2.6-xen-0144-DEBUG-write-to-HV-console-on-printk.patch:

--- NEW FILE linux-2.6-xen-0144-DEBUG-write-to-HV-console-on-printk.patch ---
>From 6c710216d0cfd3d6922eefb2d90be0c7b3f55449 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 25 Jan 2008 13:34:56 -0200
Subject: [PATCH] DEBUG: write to HV console on printk()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 drivers/char/hvc_xen.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c
index dd68f85..6d9981c 100644
--- a/drivers/char/hvc_xen.c
+++ b/drivers/char/hvc_xen.c
@@ -50,12 +50,18 @@ static inline void notify_daemon(void)
 	notify_remote_via_evtchn(xen_start_info->console.domU.evtchn);
 }
 
+
+void kcons_write_dom0(const char *s, unsigned int count);
+
 static int write_console(uint32_t vtermno, const char *data, int len)
 {
 	struct xencons_interface *intf = xencons_interface();
 	XENCONS_RING_IDX cons, prod;
 	int sent = 0;
 
+	if (len >= 1)
+		kcons_write_dom0(data, len);
+
 	cons = intf->out_cons;
 	prod = intf->out_prod;
 	mb();			/* update queue values before going on */
-- 
1.5.4.1


linux-2.6-xen-0145-Add-a-system_call_after_saveargs-label-to-entry_64.S.patch:

--- NEW FILE linux-2.6-xen-0145-Add-a-system_call_after_saveargs-label-to-entry_64.S.patch ---
>From e678014ddf212a4726b466f673d8d3e4ce47b6e2 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 4 Feb 2008 17:26:46 -0200
Subject: [PATCH] Add a system_call_after_saveargs label to entry_64.S

It will be used by Xen syscall entry point.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/entry_64.S |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 1182250..7961d22 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -252,8 +252,11 @@ ENTRY(system_call_after_swapgs)
 	 */
 	ENABLE_INTERRUPTS(CLBR_NONE)
 	SAVE_ARGS 8,1
-	movq  %rax,ORIG_RAX-ARGOFFSET(%rsp) 
 	movq  %rcx,RIP-ARGOFFSET(%rsp)
+
+system_call_after_saveargs:
+
+	movq  %rax,ORIG_RAX-ARGOFFSET(%rsp) 
 	CFI_REL_OFFSET rip,RIP-ARGOFFSET
 	GET_THREAD_INFO(%rcx)
 	testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%rcx)
-- 
1.5.4.1


linux-2.6-xen-0146-Create-xen-specific-syscall-entry.patch:

--- NEW FILE linux-2.6-xen-0146-Create-xen-specific-syscall-entry.patch ---
>From 584dcd8171fee20dde5d1e553a6430eb361c72d4 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 4 Feb 2008 17:36:08 -0200
Subject: [PATCH] Create xen-specific syscall entry

The stack and register saving for syscall entry is very different under
xen. xen_system_call_entry just handle the register saving and jumps
to system_call_after_saveargs, inside system_call.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/entry_64.S |   15 +++++++++++++++
 arch/x86/xen/setup.c    |    2 +-
 arch/x86/xen/xen-ops.h  |    1 +
 3 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/entry_64.S b/arch/x86/xen/entry_64.S
index 2a2a0a0..5c8910b 100644
--- a/arch/x86/xen/entry_64.S
+++ b/arch/x86/xen/entry_64.S
@@ -51,3 +51,18 @@ ENTRY(xen_retint_swapgs)		/* return to user-space */
 	TRACE_IRQS_IRETQ
 	jmp restore_args
 END(xen_retint_swapgs)
+
+
+ENTRY(xen_system_call_entry)
+	CFI_STARTPROC	simple
+
+	//FIXME: CFI directives here
+
+	// We need additional space for orig_ax.
+	// That would be SAVE_ARGS 8, but we already have
+	// r11 and rcx saved on the stack
+	SAVE_ARGS -8
+
+	jmp system_call_after_saveargs
+	CFI_ENDPROC
+END(xen_system_call_entry)
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index a64385d..7b0468f 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -100,7 +100,7 @@ void __init xen_arch_setup(void)
 #else
 	HYPERVISOR_set_callbacks((unsigned long)xen_hypervisor_callback,
 				 (unsigned long)xen_failsafe_callback,
-				 (unsigned long)system_call_after_swapgs);
+				 (unsigned long)xen_system_call_entry);
 #endif
 
 	set_iopl.iopl = 1;
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index b523062..4bd901c 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -74,4 +74,5 @@ void xen_iret_direct(void);
 void xen_iret(void);
 void xen_irqenable_syscall_ret(void);
 
+void xen_system_call_entry(void);
 #endif /* XEN_OPS_H */
-- 
1.5.4.1


linux-2.6-xen-0147-syscall-related-Xen-ifdefs-FIXME.patch:

--- NEW FILE linux-2.6-xen-0147-syscall-related-Xen-ifdefs-FIXME.patch ---
>From 43bffc2aeee4f4183d0a00e1d1ea2b41939d1489 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 4 Feb 2008 17:38:24 -0200
Subject: [PATCH] syscall-related Xen #ifdefs (FIXME)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/kernel/entry_64.S |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 7961d22..215b16d 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -96,20 +96,29 @@ ENTRY(native_irq_enable_syscall_ret)
 		
 	/* %rsp:at FRAMEEND */ 
 	.macro FIXUP_TOP_OF_STACK tmp
+#ifndef CONFIG_XEN
+	/*FIXME: check this at runtime */
 	movq	%gs:pda_oldrsp,\tmp
 	movq  	\tmp,RSP(%rsp)
+#endif
 	movq    $__USER_DS,SS(%rsp)
 	movq    $__USER_CS,CS(%rsp)
 	movq 	$-1,RCX(%rsp)
+#ifndef CONFIG_XEN
+	/*FIXME: check this at runtime */
 	movq	R11(%rsp),\tmp  /* get eflags */
 	movq	\tmp,EFLAGS(%rsp)
+#endif
 	.endm
 
 	.macro RESTORE_TOP_OF_STACK tmp,offset=0
+#ifndef CONFIG_XEN
+	/*FIXME: check this at runtime */
 	movq   RSP-\offset(%rsp),\tmp
 	movq   \tmp,%gs:pda_oldrsp
 	movq   EFLAGS-\offset(%rsp),\tmp
 	movq   \tmp,R11-\offset(%rsp)
+#endif
 	.endm
 
 	.macro FAKE_STACK_FRAME child_rip
@@ -288,7 +297,12 @@ sysret_check:
 	TRACE_IRQS_ON
 	movq RIP-ARGOFFSET(%rsp),%rcx
 	CFI_REGISTER	rip,rcx
+#ifndef CONFIG_XEN
+	/*FIXME: change this at runtime */
 	RESTORE_ARGS 0,-ARG_SKIP,1
+#else
+	RESTORE_ARGS 0,8,0
+#endif
 	/*CFI_REGISTER	rflags,r11*/
 	ENABLE_INTERRUPTS_SYSCALL_RET
 
-- 
1.5.4.1


linux-2.6-xen-0148-Point-set_pte-to-xen_set_pte-since-the-beginning.patch:

--- NEW FILE linux-2.6-xen-0148-Point-set_pte-to-xen_set_pte-since-the-beginning.patch ---
>From bd1e0d145d4816cdb4be98a41b2b558d0733b400 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 8 Feb 2008 12:36:28 -0200
Subject: [PATCH] Point set_pte() to xen_set_pte() since the beginning

On x86_64, set_pte() may end up being called before
paravirt_pagetable_setup_start().

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index c349af6..c100ad6 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1289,7 +1289,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = {
 	.kmap_atomic_pte = xen_kmap_atomic_pte,
 #endif
 
-	.set_pte = NULL,	/* see xen_pagetable_setup_* */
+	.set_pte = xen_set_pte,
 	.set_pte_at = xen_set_pte_at,
 	.set_pmd = xen_set_pmd,
 
-- 
1.5.4.1


linux-2.6-xen-0149-DEBUG-slab-debugging.patch:

--- NEW FILE linux-2.6-xen-0149-DEBUG-slab-debugging.patch ---
>From 14cf6c8d74980f79a335f8283c0723cefa8dad5c Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Fri, 8 Feb 2008 16:37:16 -0200
Subject: [PATCH] DEBUG: slab debugging

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 mm/slab.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index ed27eb8..d434cc3 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3201,6 +3201,8 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
 		STATS_INC_ALLOCHIT(cachep);
 		ac->touched = 1;
 		objp = ac->entry[--ac->avail];
+		if (!objp)
+			printk("really weird: avail objp for cache %s is null\n", cachep->name);
 	} else {
 		STATS_INC_ALLOCMISS(cachep);
 		objp = cache_alloc_refill(cachep, flags);
@@ -3463,8 +3465,10 @@ __cache_alloc(struct kmem_cache *cachep, gfp_t flags, void *caller)
 	unsigned long save_flags;
 	void *objp;
 
-	if (should_failslab(cachep, flags))
+	if (should_failslab(cachep, flags)) {
+		printk("cache %s should fail\n", cachep->name);
 		return NULL;
+	}
 
 	cache_alloc_debugcheck_before(cachep, flags);
 	local_irq_save(save_flags);
@@ -3476,6 +3480,8 @@ __cache_alloc(struct kmem_cache *cachep, gfp_t flags, void *caller)
 	if (unlikely((flags & __GFP_ZERO) && objp))
 		memset(objp, 0, obj_size(cachep));
 
+	if (!objp)
+		printk("allocation from cache %s failed!!!\n", cachep->name);
 	return objp;
 }
 
-- 
1.5.4.1


linux-2.6-xen-0150-pvops-64-Include-rsi-on-the-register-clobber-list.patch:

--- NEW FILE linux-2.6-xen-0150-pvops-64-Include-rsi-on-the-register-clobber-list.patch ---
>From 407b6f84786b352c1d5ba8afb7d253dd8387b293 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 20 Feb 2008 19:03:55 -0300
Subject: [PATCH] pvops-64: Include %rsi on the register clobber list for IRQ functions (REVIEWME)

The IRQ functions may be C functions, and they may clobber RSI.

Probably the best option will be saving it to avoid clobbering it after
the IRQ functions' call places are patched. Clobbering too much registers
when most IRQ functions will use none on few of them isn't a good idea.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/paravirt.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
index 20a930f..784ea98 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -1291,8 +1291,8 @@ extern struct paravirt_patch_site __parainstructions[],
  * caller saved registers but the argument parameter */
 #define PV_SAVE_REGS "pushq %%rdi;"
 #define PV_RESTORE_REGS "popq %%rdi;"
-#define PV_EXTRA_CLOBBERS EXTRA_CLOBBERS, "rcx" , "rdx"
-#define PV_VEXTRA_CLOBBERS EXTRA_CLOBBERS, "rdi", "rcx" , "rdx"
+#define PV_EXTRA_CLOBBERS EXTRA_CLOBBERS, "rsi", "rcx" , "rdx"
+#define PV_VEXTRA_CLOBBERS EXTRA_CLOBBERS, "rdi", "rsi", "rcx" , "rdx"
 #define PV_FLAGS_ARG "D"
 #endif
 
-- 
1.5.4.1


linux-2.6-xen-0151-Xen-64-quick-ugly-hack-to-fix-pgd_clear-pagetabl.patch:

--- NEW FILE linux-2.6-xen-0151-Xen-64-quick-ugly-hack-to-fix-pgd_clear-pagetabl.patch ---
>From 5ac4a7356297541253ec8533cec3df8ccdedbfa3 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Wed, 20 Feb 2008 19:04:43 -0300
Subject: [PATCH] Xen-64: quick, ugly hack to fix pgd_clear() pagetable unpinning (FIXME)

Should be fixed properly later.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 include/asm-x86/paravirt.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
index 784ea98..3fddadc 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -1146,6 +1146,10 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
 static inline void pgd_clear(pgd_t *pgdp)
 {
 	set_pgd(pgdp, __pgd(0));
+#ifdef CONFIG_X86_64
+	/*FIXME: ugly ugly ugly ugly ugly ugly hack */
+	set_pgd((pgd_t*)(((unsigned long)pgdp)+PAGE_SIZE), __pgd(0));
+#endif
 }
 
 static inline void pud_clear(pud_t *pudp)
-- 
1.5.4.1


linux-2.6-xen-0152-Add-missing-acpi-include-to-xen-setup.c.patch:

--- NEW FILE linux-2.6-xen-0152-Add-missing-acpi-include-to-xen-setup.c.patch ---
>From a44ba4f7dfa279fdb179ff2205ca1046fdeecf51 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Tue, 4 Mar 2008 16:59:21 -0300
Subject: [PATCH] Add missing acpi #include to xen/setup.c

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/setup.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 7b0468f..f731e0b 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -21,6 +21,7 @@
 #include <xen/features.h>
 
 #include <asm/proto.h>
+#include <asm/acpi.h>
 
 #include "xen-ops.h"
 #include "vdso.h"
-- 
1.5.4.1


linux-2.6-xen-0153-Don-t-use-FIX_VDSO-on-64-bit.patch:

--- NEW FILE linux-2.6-xen-0153-Don-t-use-FIX_VDSO-on-64-bit.patch ---
>From 8ccd2d686eab3bdb401e13fd65371f027b44dc97 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Mon, 3 Mar 2008 14:46:56 -0300
Subject: [PATCH] Don't use FIX_VDSO on 64-bit

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index c100ad6..feb58bf 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1137,7 +1137,9 @@ static void xen_set_fixmap(unsigned idx, unsigned long phys, pgprot_t prot)
 	case FIX_F00F_IDT:
 #endif
 	case FIX_WP_TEST:
+#ifndef CONFIG_X86_64
 	case FIX_VDSO:
+#endif
 #ifdef CONFIG_X86_LOCAL_APIC
 	case FIX_APIC_BASE:	/* maps dummy local APIC */
 #endif
-- 
1.5.4.1


linux-2.6-xen-0154-Mark-init-pages-read-write-again-on-free_init_pages.patch:

--- NEW FILE linux-2.6-xen-0154-Mark-init-pages-read-write-again-on-free_init_pages.patch ---
>From 6cef3aa6c9ca4fc024175094bbc5230bedfbd6c1 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Thu, 3 Apr 2008 19:09:09 -0300
Subject: [PATCH] Mark init pages read-write again on free_init_pages()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/mm/init_64.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index e21c9a4..763914c 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1073,6 +1073,13 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
 		begin, PAGE_ALIGN(end));
 	set_memory_np(begin, (end - begin) >> PAGE_SHIFT);
 #else
+	/*
+	 * We just marked the kernel text read only above, now that
+	 * we are going to free part of that, we need to make that
+	 * writeable first.
+	 */
+	set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
+
 	printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
 
 	for (; addr < end; addr += PAGE_SIZE) {
-- 
1.5.4.1


linux-2.6-xen-0155-reserve_early-kernel-text-and-data-segments.patch:

--- NEW FILE linux-2.6-xen-0155-reserve_early-kernel-text-and-data-segments.patch ---
>From bf795bede43d3db0489508826b2ba5a53302fecf Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost at redhat.com>
Date: Thu, 3 Apr 2008 19:10:10 -0300
Subject: [PATCH] reserve_early() kernel text and data segments

Just like on start_kernel()

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 arch/x86/xen/enlighten.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index feb58bf..4cf75d5 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -48,6 +48,7 @@
 #include <asm/tlbflush.h>
 #include <asm/reboot.h>
 #include <asm/proto.h>
+#include <asm/sections.h>
 
 #include "xen-ops.h"
 #include "mmu.h"
@@ -1476,6 +1477,8 @@ asmlinkage void __init xen_start_kernel(void)
 	   possible map and a non-dummy shared_info. */
 	per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0];
 
+	reserve_early(__pa_symbol(&_text), __pa_symbol(&_end), "TEXT DATA BSS");
+
 	xprintk("xen_init_pt:\n");
 	xen_init_pt();
 	xprintk("xen_init_pt returned.\n");
-- 
1.5.4.1



--- NEW FILE patch-2.6.25-rc9.bz2.sign ---
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: See http://www.kernel.org/signature.html for info

iD8DBQBH/9EzyGugalF9Dw4RAk4EAJ0ant6YuoxLZNtYzbdw9037RODXmwCfXE2Z
zINwcLH4e+e8HuBh1XhkMvg=
=Zgmu
-----END PGP SIGNATURE-----


Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/.cvsignore,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- .cvsignore	2 Apr 2008 08:55:25 -0000	1.14
+++ .cvsignore	14 Apr 2008 16:06:52 -0000	1.15
@@ -4,5 +4,5 @@
 temp-*
 kernel-2.6.24
 linux-2.6.24.tar.bz2
-patch-2.6.25-rc8.bz2
+patch-2.6.25-rc9.bz2
 xen-3.2.0.tar.gz


Index: .gitignore
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/.gitignore,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- .gitignore	2 Apr 2008 08:55:25 -0000	1.4
+++ .gitignore	14 Apr 2008 16:06:53 -0000	1.5
@@ -4,6 +4,5 @@
 temp-*
 kernel-2.6.24
 linux-2.6.24.tar.bz2
-patch-2.6.25-rc8.bz2
+patch-2.6.25-rc9.bz2
 xen-3.2.0.tar.gz
-


Index: Makefile
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/Makefile,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Makefile	8 Apr 2008 16:43:44 -0000	1.14
+++ Makefile	14 Apr 2008 16:06:53 -0000	1.15
@@ -58,8 +58,7 @@
 	@perl -pi -e 's/# CONFIG_FAULT_INJECTION_DEBUG_FS is not set/CONFIG_FAULT_INJECTION_DEBUG_FS=y/' config-nodebug
 	@perl -pi -e 's/# CONFIG_FAULT_INJECTION_STACKTRACE_FILTER is not set/CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y/' config-nodebug
 	@perl -pi -e 's/# CONFIG_DEBUG_SG is not set/CONFIG_DEBUG_SG=y/' config-nodebug
-	@perl -pi -e 's/# CONFIG_EXT4DEV_FS is not set/CONFIG_EXT4DEV_FS=m/' config-generic
-	@perl -pi -e 's/# CONFIG_USB_DEBUG is not set/CONFIG_USB_DEBUG=y/' config-generic
+	@perl -pi -e 's/# CONFIG_USB_DEBUG is not set/CONFIG_USB_DEBUG=y/' config-nodebug
 
 	@perl -pi -e 's/^%define debugbuildsenabled 1/%define debugbuildsenabled 0/' kernel.spec
 
@@ -86,8 +85,7 @@
 	@perl -pi -e 's/CONFIG_FAULT_INJECTION_DEBUG_FS=y/# CONFIG_FAULT_INJECTION_DEBUG_FS is not set/' config-nodebug
 	@perl -pi -e 's/CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y/# CONFIG_FAULT_INJECTION_STACKTRACE_FILTER is not set/' config-nodebug
 	@perl -pi -e 's/CONFIG_DEBUG_SG=y/# CONFIG_DEBUG_SG is not set/' config-nodebug
-	@perl -pi -e 's/CONFIG_EXT4DEV_FS=m/# CONFIG_EXT4DEV_FS is not set/' config-generic
-	@perl -pi -e 's/CONFIG_USB_DEBUG=y/# CONFIG_USB_DEBUG is not set/' config-generic
+	@perl -pi -e 's/CONFIG_USB_DEBUG=y/# CONFIG_USB_DEBUG is not set/' config-nodebug
 
 	@perl -pi -e 's/^%define debugbuildsenabled 0/%define debugbuildsenabled 1/' kernel.spec
 


Index: Makefile.config
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/Makefile.config,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Makefile.config	8 Apr 2008 16:43:44 -0000	1.14
+++ Makefile.config	14 Apr 2008 16:06:53 -0000	1.15
@@ -7,7 +7,7 @@
 CONFIGFILES	= \
 	$(CFG)-i586.config \
 	$(CFG)-i686.config $(CFG)-i686-PAE.config \
-	$(CFG)-i686-debug.config $(CFG)-i686-PAE-debug.config \
+	$(CFG)-i686-debug.config $(CFG)-i686-PAEdebug.config \
 	$(CFG)-x86_64.config $(CFG)-x86_64-debug.config \
 	$(CFG)-s390x.config \
 	$(CFG)-ppc.config $(CFG)-ppc-smp.config \
@@ -88,7 +88,7 @@
 kernel-$(VERSION)-i686-PAE.config: config-i686-PAE temp-x86-generic
 	perl merge.pl $^ i386 > $@
 
-kernel-$(VERSION)-i686-PAE-debug.config: config-i686-PAE temp-x86-debug-generic
+kernel-$(VERSION)-i686-PAEdebug.config: config-i686-PAE temp-x86-debug-generic
 	perl merge.pl $^ i386 > $@
 
 kernel-$(VERSION)-i586.config: config-i586 temp-x86-generic


Index: config-generic
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/config-generic,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- config-generic	2 Apr 2008 08:55:25 -0000	1.5
+++ config-generic	14 Apr 2008 16:06:53 -0000	1.6
@@ -1303,7 +1303,7 @@
 CONFIG_IWLWIFI_LEDS=y
 CONFIG_IWLCORE_RFKILL=y
 CONFIG_IWL4965=m
-CONFIG_IWLWIFI_DEBUG=y
+CONFIG_IWL4965_DEBUG=y
 CONFIG_IWLWIFI_DEBUGFS=y
 CONFIG_IWL4965_SENSITIVITY=y
 CONFIG_IWL4965_SPECTRUM_MEASUREMENT=y
@@ -1896,18 +1896,20 @@
 CONFIG_SENSORS_W83792D=m
 CONFIG_SENSORS_W83793=m
 
+CONFIG_W1=m
+CONFIG_W1_CON=y
 # This is busted.
 # If we enable it, it steals Matrox cards, and the
 # framebuffer drivers stop working.
-# CONFIG_W1 is not set
-CONFIG_W1_MASTER_MATROX=m
+# CONFIG_W1_MASTER_MATROX is not set
 CONFIG_W1_MASTER_DS2482=m
+CONFIG_W1_MASTER_DS2490=m
+CONFIG_W1_MASTER_DS1WM=m
 CONFIG_W1_SLAVE_THERM=m
 CONFIG_W1_SLAVE_SMEM=m
 CONFIG_W1_SLAVE_DS2433=m
 CONFIG_W1_SLAVE_DS2433_CRC=y
-CONFIG_W1_CON=y
-CONFIG_W1_MASTER_DS2490=m
+CONFIG_W1_SLAVE_DS2760=m
 
 #
 # Mice
@@ -3009,7 +3011,7 @@
 CONFIG_DEBUG_KERNEL=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_INFO=y
-# CONFIG_FRAME_POINTER is not set
+CONFIG_FRAME_POINTER=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 # CONFIG_DEBUG_DRIVER is not set
 CONFIG_HEADERS_CHECK=y


Index: config-nodebug
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/config-nodebug,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- config-nodebug	1 Apr 2008 10:38:06 -0000	1.4
+++ config-nodebug	14 Apr 2008 16:06:53 -0000	1.5
@@ -3,31 +3,31 @@
 CONFIG_SND_DEBUG_DETECT=y
 CONFIG_SND_PCM_XRUN_DEBUG=y
 
-CONFIG_DEBUG_IGNORE_QUIET=y
-CONFIG_DEBUG_MUTEXES=y
-CONFIG_DEBUG_RT_MUTEXES=y
-CONFIG_DEBUG_LOCK_ALLOC=y
-CONFIG_PROVE_LOCKING=y
-CONFIG_DEBUG_VM=y
-CONFIG_DEBUG_SPINLOCK=y
-
-CONFIG_FAULT_INJECTION=y
-CONFIG_FAILSLAB=y
-CONFIG_FAIL_PAGE_ALLOC=y
-CONFIG_FAIL_MAKE_REQUEST=y
-CONFIG_FAULT_INJECTION_DEBUG_FS=y
-CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y
+# CONFIG_DEBUG_IGNORE_QUIET is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_FAILSLAB is not set
+# CONFIG_FAIL_PAGE_ALLOC is not set
+# CONFIG_FAIL_MAKE_REQUEST is not set
+# CONFIG_FAULT_INJECTION_DEBUG_FS is not set
+# CONFIG_FAULT_INJECTION_STACKTRACE_FILTER is not set
 
-CONFIG_SLUB_DEBUG_ON=y
+# CONFIG_SLUB_DEBUG_ON is not set
 
-CONFIG_LOCK_STAT=y
+# CONFIG_LOCK_STAT is not set
 
-CONFIG_DEBUG_STACK_USAGE=y
+# CONFIG_DEBUG_STACK_USAGE is not set
 
 # CONFIG_ACPI_DEBUG is not set
 
-CONFIG_DEBUG_SG=y
+# CONFIG_DEBUG_SG is not set
 
 # CONFIG_DEBUG_PAGEALLOC is not set
 
-CONFIG_USB_DEBUG=y
+# CONFIG_USB_DEBUG is not set


Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/kernel.spec,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- kernel.spec	8 Apr 2008 16:43:44 -0000	1.34
+++ kernel.spec	14 Apr 2008 16:06:53 -0000	1.35
@@ -43,7 +43,7 @@
 # The next upstream release sublevel (base_sublevel+1)
 %define upstream_sublevel %(expr %{base_sublevel} + 1)
 # The rc snapshot level
-%define rcrev 8
+%define rcrev 9
 # The git snapshot level
 %define gitrev 0
 # Set rpm version accordingly
@@ -104,7 +104,7 @@
 # Set debugbuildsenabled to 1 for production (build separate debug kernels)
 #  and 0 for rawhide (all kernels are debug kernels).
 # See also 'make debug' and 'make release'.
-%define debugbuildsenabled 0
+%define debugbuildsenabled 1
 
 # Want to build a vanilla kernel build without any non-upstream patches?
 # (well, almost none, we need nonintconfig for build purposes). Default to 0 (off).
@@ -585,6 +585,7 @@
 Patch41: linux-2.6-sysrq-c.patch
 Patch42: linux-2.6-x86-tune-generic.patch
 Patch75: linux-2.6-x86-debug-boot.patch
+Patch80: linux-2.6-smp-boot-delay.patch
 
 Patch123: linux-2.6-ppc-rtc.patch
 Patch140: linux-2.6-ps3-ehci-iso.patch
@@ -596,6 +597,7 @@
 Patch146: linux-2.6-windfarm-pm121-fix.patch
 Patch147: linux-2.6-imac-transparent-bridge.patch
 Patch148: linux-2.6-powerpc-zImage-32MiB.patch
+Patch149: linux-2.6-efika-not-chrp.patch
 
 Patch160: linux-2.6-execshield.patch
 Patch250: linux-2.6-debug-sizeof-structs.patch
@@ -612,19 +614,19 @@
 Patch420: linux-2.6-squashfs.patch
 Patch430: linux-2.6-net-silence-noisy-printks.patch
 Patch450: linux-2.6-input-kill-stupid-messages.patch
-Patch451: linux-2.6-input-macbook-appletouch.patch
 Patch460: linux-2.6-serial-460800.patch
 Patch510: linux-2.6-silence-noise.patch
 Patch570: linux-2.6-selinux-mprotect-checks.patch
 Patch580: linux-2.6-sparc-selinux-mprotect-checks.patch
 Patch610: linux-2.6-defaults-fat-utf8.patch
-Patch660: linux-2.6-libata-ali-atapi-dma.patch
 Patch670: linux-2.6-ata-quirk.patch
 
 Patch680: linux-2.6-wireless.patch
 Patch681: linux-2.6-wireless-pending.patch
 Patch690: linux-2.6-at76.patch
 
+Patch700: linux-2.6-nfs-client-mounts-hang.patch
+
 Patch1101: linux-2.6-default-mmf_dump_elf_headers.patch
 Patch1400: linux-2.6-smarter-relatime.patch
 Patch1515: linux-2.6-lirc.patch
@@ -671,23 +673,158 @@
 Patch5000: linux-2.6-xen-0001-squashfs-Fix-build-without-CONFIG_SMP.patch
 Patch5001: linux-2.6-xen-0002-xen-execshield-Add-xen-specific-load_user_cs_desc.patch
 Patch5002: linux-2.6-xen-0003-xen-execshield-fix-endless-GPF-fault-loop.patch
-Patch5003: linux-2.6-xen-0004-xen-Do-not-pin-unpin-PMD-pages.patch
-Patch5004: linux-2.6-xen-0005-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch
-Patch5005: linux-2.6-xen-0006-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch
-Patch5006: linux-2.6-xen-0007-xen-Enable-Xen-console-by-default-in-domU.patch
-Patch5007: linux-2.6-xen-0008-xen-Module-autoprobing-support-for-frontend-drivers.patch
-Patch5008: linux-2.6-xen-0009-xen-Add-compatibility-aliases-for-frontend-drivers.patch
-Patch5009: linux-2.6-xen-0010-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch
-Patch5010: linux-2.6-xen-0011-xen-Add-a-vmlinuz-target.patch
-Patch5011: linux-2.6-xen-0012-xen-Add-empty-xenctrl-module.patch
-Patch5012: linux-2.6-xen-0013-xen-Add-proc-xen-capabilities.patch
-Patch5013: linux-2.6-xen-0014-xen-Add-proc-xen-privcmd.patch
-Patch5014: linux-2.6-xen-0015-xen-Add-proc-xen-xenbus.patch
-Patch5015: linux-2.6-xen-0016-xen-Add-Xen-s-sys-hypervisor-interface.patch
-Patch5016: linux-2.6-xen-0017-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch
-Patch5017: linux-2.6-xen-0018-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch
-Patch5018: linux-2.6-xen-0019-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch
-Patch5019: linux-2.6-xen-0020-xen-x86_64-Initial-x86_64-support-for-Xen-paravirt_.patch
+Patch5003: linux-2.6-xen-0004-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch
+Patch5004: linux-2.6-xen-0005-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch
+Patch5005: linux-2.6-xen-0006-xen-Enable-Xen-console-by-default-in-domU.patch
+Patch5006: linux-2.6-xen-0007-xen-Module-autoprobing-support-for-frontend-drivers.patch
+Patch5007: linux-2.6-xen-0008-xen-Add-compatibility-aliases-for-frontend-drivers.patch
+Patch5008: linux-2.6-xen-0009-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch
+Patch5009: linux-2.6-xen-0010-xen-Add-a-vmlinuz-target.patch
+Patch5010: linux-2.6-xen-0011-xen-Add-empty-xenctrl-module.patch
+Patch5011: linux-2.6-xen-0012-xen-Add-proc-xen-capabilities.patch
+Patch5012: linux-2.6-xen-0013-xen-Add-proc-xen-privcmd.patch
+Patch5013: linux-2.6-xen-0014-xen-Add-proc-xen-xenbus.patch
+Patch5014: linux-2.6-xen-0015-xen-Add-Xen-s-sys-hypervisor-interface.patch
+Patch5015: linux-2.6-xen-0016-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch
+Patch5016: linux-2.6-xen-0017-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch
+Patch5017: linux-2.6-xen-0018-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch
+Patch5018: linux-2.6-xen-0019-xen-expose-set_pte_vaddr-and-make-xen-use-it.patch
+Patch5019: linux-2.6-xen-0020-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch
+Patch5020: linux-2.6-xen-0021-x86_64-Expose-set_pte_vaddr.patch
+Patch5021: linux-2.6-xen-0022-x86_64-Split-set_pte_vaddr.patch
+Patch5022: linux-2.6-xen-0023-x86_64-Add-clear_fixmap.patch
+Patch5023: linux-2.6-xen-0024-xen-x86_64-Make-set_fixmap-a-paravirt-op-on-64-bi.patch
+Patch5024: linux-2.6-xen-0025-xen-x86_64-Hack-to-set-vsyscall-pages-on-user-space.patch
+Patch5025: linux-2.6-xen-0026-Handle-VSYSCALL_FIRST_PAGE-on-xen_set_pte.patch
+Patch5026: linux-2.6-xen-0027-DMI-Define-dmi_scan_machine-as-no-op-if-CONFIG_DM.patch
+Patch5027: linux-2.6-xen-0028-ACPI-thermal-Compile-without-CONFIG_DMI.patch
+Patch5028: linux-2.6-xen-0029-xen-x86_64-Remove-the-640K-1M-hole-and-disable-DMI.patch
+Patch5029: linux-2.6-xen-0030-xen-x86_64-Add-update_va_mapping-64-bit-code.patch
+Patch5030: linux-2.6-xen-0031-x86_64-Add-sync_cmpxchg.patch
+Patch5031: linux-2.6-xen-0032-xen-x86_64-Implement-HYPERVISOR-MULTI-_update_desc.patch
+Patch5032: linux-2.6-xen-0033-xen-x86_64-Add-hacky-64-bit-x86_-read-write-_percpu.patch
+Patch5033: linux-2.6-xen-0034-xen-x86_64-Use-x86_read_percpu-only-to-refer-to-a.patch
+Patch5034: linux-2.6-xen-0035-Better-implementation-of-pte-functions.patch
+Patch5035: linux-2.6-xen-0036-Add-FIX_PARAVIRT_BOOTAP-to-fixmap_64.h-too.patch
+Patch5036: linux-2.6-xen-0037-Add-gate_offset-and-gate_segment-macros.patch
+Patch5037: linux-2.6-xen-0038-xen_write_idt_entry-and-cvt_gate_to_trap.patch
+Patch5038: linux-2.6-xen-0039-typedefs-for-pte_val-and-friends.patch
+Patch5039: linux-2.6-xen-0040-x86_64-implementation-of-some-page.h-macros.patch
+Patch5040: linux-2.6-xen-0041-Chainsaw-style-ifdefs.patch
+Patch5041: linux-2.6-xen-0042-xen-Make-xen_pte_val-generic.patch
+Patch5042: linux-2.6-xen-0043-More-chainsaw-ifdefs.patch
+Patch5043: linux-2.6-xen-0044-Chainsaw-ifdefs-on-assembly-percpu-handling.patch
+Patch5044: linux-2.6-xen-0045-x86_64-percpu-assembly-macros.patch
+Patch5045: linux-2.6-xen-0046-Some-xen-asm.S-x86_64-code.patch
+Patch5046: linux-2.6-xen-0047-Chainsaw-party-SPLITME.patch
+Patch5047: linux-2.6-xen-0048-xen-asm.S-x86_64-notes.patch
+Patch5048: linux-2.6-xen-0049-xen-x86_64-Make-hypercall-assembly-code-work.patch
+Patch5049: linux-2.6-xen-0050-xen-x86_64-pda-initialization.patch
+Patch5050: linux-2.6-xen-0051-Disable-discover_ebda-under-paravirt.patch
+Patch5051: linux-2.6-xen-0052-Disable-early_printk-by-default.patch
+Patch5052: linux-2.6-xen-0053-xen-Set-__HYPERVISOR_VIRT_START-for-x86_64.patch
+Patch5053: linux-2.6-xen-0054-Set-__PAGE_OFFSET-as-required-by-Xen.patch
+Patch5054: linux-2.6-xen-0055-DEBUG-Add-xprintk-to-log-directly-via-hypercall-fo.patch
+Patch5055: linux-2.6-xen-0056-Use-__pgd-on-mk_kernel_pgd.patch
+Patch5056: linux-2.6-xen-0057-Include-user-page-tables-on-head_64.S.patch
+Patch5057: linux-2.6-xen-0058-Avoid-using-mk_unsigned_long.patch
+Patch5058: linux-2.6-xen-0059-Lots-of-unrelated-changes.patch
+Patch5059: linux-2.6-xen-0060-Hack-disable-vsmp.patch
+Patch5060: linux-2.6-xen-0061-Export-early_make_page_readonly.patch
+Patch5061: linux-2.6-xen-0062-Disable-multicalls.c-too-verbose-debugging.patch
+Patch5062: linux-2.6-xen-0063-Xen-64-bit-ready-MMU-operations.patch
+Patch5063: linux-2.6-xen-0064-Some-xen-mmu-pv-ops-implemented.patch
+Patch5064: linux-2.6-xen-0065-Trying-to-make-the-pagetable-initialization-code-wor.patch
+Patch5065: linux-2.6-xen-0066-Xen-specific-find_early_table_space-FIXME.patch
+Patch5066: linux-2.6-xen-0067-Xen-call-e820_print_map-when-setting-up-memory.patch
+Patch5067: linux-2.6-xen-0068-Comment-debugging-msgs.patch
+Patch5068: linux-2.6-xen-0069-Try-to-make-pagetables-read-only.patch
+Patch5069: linux-2.6-xen-0070-Debug-dump-pgtables-on-make_page_readonly.patch
+Patch5070: linux-2.6-xen-0071-Disable-apic-at-compile-time-FIXME.patch
+Patch5071: linux-2.6-xen-0072-Parse-early-params-after-init_memory_mapping.patch
+Patch5072: linux-2.6-xen-0073-xen-Move-addr_to_page-to-init.h.patch
+Patch5073: linux-2.6-xen-0074-Make-xen_pxx_val-and-xen_make_pxx-handle-attr-bi.patch
+Patch5074: linux-2.6-xen-0075-Pull-xen_finish_init_mappin-from-XS-upstream.patch
+Patch5075: linux-2.6-xen-0076-Pull-spp_getpage-changes-from-XS-upstream-REVIEWM.patch
+Patch5076: linux-2.6-xen-0077-Pull-xen_extend_init_mapping-from-XS-upstream-FIX.patch
+Patch5077: linux-2.6-xen-0078-New-enum-fixed_addresses-values-REVIEWME.patch
+Patch5078: linux-2.6-xen-0079-Reserve-bootmem-areas-used-by-Xen-FIXME.patch
+Patch5079: linux-2.6-xen-0080-xen_convert_trap_info-use-sizeof-struct-gate_desc.patch
+Patch5080: linux-2.6-xen-0081-Call-paravirt_pagetable_setup_-start-done-REVIEW.patch
+Patch5081: linux-2.6-xen-0082-ifdef-CONFIG_X86_32-on-xen-enlighten.c-REVIEWME.patch
+Patch5082: linux-2.6-xen-0083-Handle-Xen-exception-stack-it-is-different-from-bar.patch
+Patch5083: linux-2.6-xen-0084-Make-hvc_xen-console-use-xprintk-TEMPORARY.patch
+Patch5084: linux-2.6-xen-0085-Implement-64-bit-version-of-HYPERVISOR_set_callbacks.patch
+Patch5085: linux-2.6-xen-0086-Make-arch_vcpu_info-be-of-the-right-size-on-both-32.patch
+Patch5086: linux-2.6-xen-0087-Implement-asm-xen_iret.patch
+Patch5087: linux-2.6-xen-0088-xen-64-xen_iret-use-iretq-directly-if-returning-t.patch
+Patch5088: linux-2.6-xen-0089-Implement-xen_irqenable_syscall_ret.patch
+Patch5089: linux-2.6-xen-0090-DEBUG-xen_iret-always-return-through-the-hyperviso.patch
+Patch5090: linux-2.6-xen-0091-Implement-some-xen-callbacks-on-xen-entry_64.S.patch
+Patch5091: linux-2.6-xen-0092-Xen-specific-ifdef-hacks-on-kernel-entry_64.S-FIXM.patch
+Patch5092: linux-2.6-xen-0093-Disable-syscall32-code-temporarily-FIXME.patch
+Patch5093: linux-2.6-xen-0094-Use-__KERNEL_DS-as-SS-when-returning-to-a-kernel-thr.patch
+Patch5094: linux-2.6-xen-0095-Use-apic_xen-on-genapic-by-default-FIXME.patch
+Patch5095: linux-2.6-xen-0096-irq-vector-ifdef-chainsaw-FIXME.patch
+Patch5096: linux-2.6-xen-0097-ifdef-chainsaw-on-syscall_init-FIXME.patch
+Patch5097: linux-2.6-xen-0098-Pull-xen-genapic-implementation-from-upstream-Xen.patch
+Patch5098: linux-2.6-xen-0099-Debugging-printk-s.patch
+Patch5099: linux-2.6-xen-0100-Leave-lazy_cpu_mode-on-__switch_to.patch
+Patch5100: linux-2.6-xen-0101-xen-64-Handle-fs-and-gs-on-xen_load_tls-properl.patch
+Patch5101: linux-2.6-xen-0102-Disable-vcpu_info_placement-temporarily-FIXME.patch
+Patch5102: linux-2.6-xen-0103-Fix-typo-on-ifdef-again.patch
+Patch5103: linux-2.6-xen-0104-DEBUG-Don-t-try-to-actually-read-the-page-on-show_.patch
+Patch5104: linux-2.6-xen-0105-Make-load_gs_index-a-paravirt-operation.patch
+Patch5105: linux-2.6-xen-0106-xen-pgd_walk-use-limit-argument-instead-of-FIXADD.patch
+Patch5106: linux-2.6-xen-0107-xen-pgd_walk-Eliminate-BUG_ON-limit-FIXADDR_TOP.patch
+Patch5107: linux-2.6-xen-0108-xen-pgd_walk-accept-start-parameter.patch
+Patch5108: linux-2.6-xen-0109-xen-64-reserve_bootmem-xen_start_info-area.patch
+Patch5109: linux-2.6-xen-0110-pvops-64-call-paravirt_post_allocator_init-on-set.patch
+Patch5110: linux-2.6-xen-0111-use-write_gdt_entry-on-vsyscall_set_cpu-CLEANME.patch
+Patch5111: linux-2.6-xen-0112-xen-64-implement-xen_load_gs_index.patch
+Patch5112: linux-2.6-xen-0113-include-asm-x86-pgalloc_64.h-pvops-hacks-SPLITME.patch
+Patch5113: linux-2.6-xen-0114-Multi-pagetable-write_cr3-implementation-FIXME.patch
+Patch5114: linux-2.6-xen-0115-Make-kcons_write_dom0-non-static-TEMPORARY.patch
+Patch5115: linux-2.6-xen-0116-Disable-the-weird-count-loop-on-kcons_write_dom0.patch
+Patch5116: linux-2.6-xen-0117-Make-xen_start_info-read-only.patch
+Patch5117: linux-2.6-xen-0118-Hack-to-implement-return-to-userspace-without-SWAPGS.patch
+Patch5118: linux-2.6-xen-0119-Xen-SEGBASE_-defines.patch
+Patch5119: linux-2.6-xen-0120-Xen-HYPERVISOR_set_segment_base-implementation.patch
+Patch5120: linux-2.6-xen-0121-Change-signature-of-paravirt_alloc_-pt-pd-REVIEWME.patch
+Patch5121: linux-2.6-xen-0122-Comment-e820_print_map-call-TEMPORARY.patch
+Patch5122: linux-2.6-xen-0123-Xen-missing-includes.patch
+Patch5123: linux-2.6-xen-0124-asm-x86-pgtable_64.h-include-linux-spinlock.h.patch
+Patch5124: linux-2.6-xen-0125-asm-x86-pgtable.h-include-asm-page.h.patch
+Patch5125: linux-2.6-xen-0126-fix-pxxval_t-usage-on-mm-init_64.c.patch
+Patch5126: linux-2.6-xen-0127-Missing-Xen-include.patch
+Patch5127: linux-2.6-xen-0128-un-static-ipi_to_irq.patch
+Patch5128: linux-2.6-xen-0129-Don-t-use-_PAGE_GLOBAL-bit-under-Xen-FIXME.patch
+Patch5129: linux-2.6-xen-0130-Trying-to-organize-the-xen-bootmem-allocation-mess.patch
+Patch5130: linux-2.6-xen-0131-Don-t-call-xprintk-when-writing-to-hvc-console.patch
+Patch5131: linux-2.6-xen-0132-Xen-reserve_bootmem-xenstore-and-console-interfac.patch
+Patch5132: linux-2.6-xen-0133-pvops-64-call-paravirt_activate_mm-on-activate_mm.patch
+Patch5133: linux-2.6-xen-0134-Xen-64-bit-support-on-xen_pgd_pin.patch
+Patch5134: linux-2.6-xen-0135-Xen-64-pin-user-PGD-on-activate_mm-and-dup_mmap.patch
+Patch5135: linux-2.6-xen-0136-pgd_walk-changes-to-make-pgd-pinning-work-FIXME.patch
+Patch5136: linux-2.6-xen-0137-Xen-Add-a-order-parameter-to-pgd_walk.patch
+Patch5137: linux-2.6-xen-0138-Xen-64-Unpin-user-pagetable-on-xen_pgd_unpin.patch
+Patch5138: linux-2.6-xen-0139-Use-un-pin_page-when-un-pinning-pgd.patch
+Patch5139: linux-2.6-xen-0140-Allow-enabling-Xen-on-x86_64.patch
+Patch5140: linux-2.6-xen-0141-Add-include-linux-spinlock_types.h-to-asm-x86-pgt.patch
+Patch5141: linux-2.6-xen-0142-Restore-some-sanity-on-the-initial-pagetable-bootmem.patch
+Patch5142: linux-2.6-xen-0143-Xen-Use-system_call_after_swapgs-as-the-syscall-c.patch
+Patch5143: linux-2.6-xen-0144-DEBUG-write-to-HV-console-on-printk.patch
+Patch5144: linux-2.6-xen-0145-Add-a-system_call_after_saveargs-label-to-entry_64.S.patch
+Patch5145: linux-2.6-xen-0146-Create-xen-specific-syscall-entry.patch
+Patch5146: linux-2.6-xen-0147-syscall-related-Xen-ifdefs-FIXME.patch
+Patch5147: linux-2.6-xen-0148-Point-set_pte-to-xen_set_pte-since-the-beginning.patch
+Patch5148: linux-2.6-xen-0149-DEBUG-slab-debugging.patch
+Patch5149: linux-2.6-xen-0150-pvops-64-Include-rsi-on-the-register-clobber-list.patch
+Patch5150: linux-2.6-xen-0151-Xen-64-quick-ugly-hack-to-fix-pgd_clear-pagetabl.patch
+Patch5151: linux-2.6-xen-0152-Add-missing-acpi-include-to-xen-setup.c.patch
+Patch5152: linux-2.6-xen-0153-Don-t-use-FIX_VDSO-on-64-bit.patch
+Patch5153: linux-2.6-xen-0154-Mark-init-pages-read-write-again-on-free_init_pages.patch
+Patch5154: linux-2.6-xen-0155-reserve_early-kernel-text-and-data-segments.patch
 # kernel-xen patches end
 
 # Xen hypervisor patches (20000+)
@@ -1065,6 +1202,8 @@
 # x86(-64)
 # Compile 686 kernels tuned for Pentium4.
 ApplyPatch linux-2.6-x86-tune-generic.patch
+# Delay longer during boot on x86 while waiting for secondary processors
+ApplyPatch linux-2.6-smp-boot-delay.patch
 
 #
 # PowerPC
@@ -1094,6 +1233,8 @@
 ApplyPatch linux-2.6-imac-transparent-bridge.patch
 # Link zImage at 32MiB (for POWER machines, Efika)
 ApplyPatch linux-2.6-powerpc-zImage-32MiB.patch
+# Don't show 'CHRP' in /proc/cpuinfo on Efika
+ApplyPatch linux-2.6-efika-not-chrp.patch
 
 #
 # Exec shield
@@ -1154,7 +1295,6 @@
 # Misc fixes
 # The input layer spews crap no-one cares about.
 ApplyPatch linux-2.6-input-kill-stupid-messages.patch
-ApplyPatch linux-2.6-input-macbook-appletouch.patch
 
 # Allow to use 480600 baud on 16C950 UARTs
 ApplyPatch linux-2.6-serial-460800.patch
@@ -1170,22 +1310,23 @@
 # Use UTF-8 by default on VFAT.
 ApplyPatch linux-2.6-defaults-fat-utf8.patch
 
-# Disable ATAPI DMA on ALI chipsets.
-ApplyPatch linux-2.6-libata-ali-atapi-dma.patch
 # ia64 ata quirk
 ApplyPatch linux-2.6-ata-quirk.patch
 
 # wireless patches headed for 2.6.25
-ApplyPatch linux-2.6-wireless.patch
+#ApplyPatch linux-2.6-wireless.patch
 # wireless patches headed for 2.6.26
-ApplyPatch linux-2.6-wireless-pending.patch
+#ApplyPatch linux-2.6-wireless-pending.patch
 
 # Add misc wireless bits from upstream wireless tree
-ApplyPatch linux-2.6-at76.patch
+#ApplyPatch linux-2.6-at76.patch
 
 # implement smarter atime updates support.
 ApplyPatch linux-2.6-smarter-relatime.patch
 
+# NFS Client mounts hang when exported directory do not exist
+ApplyPatch linux-2.6-nfs-client-mounts-hang.patch
+
 # build id related enhancements
 ApplyPatch linux-2.6-default-mmf_dump_elf_headers.patch
 
@@ -1210,9 +1351,9 @@
 # linux1394 git patches
 ApplyPatch linux-2.6-firewire-git-update.patch
 C=$(wc -l $RPM_SOURCE_DIR/linux-2.6-firewire-git-pending.patch | awk '{print $1}')
-#if [ "$C" -gt 10 ]; then
-#ApplyPatch linux-2.6-firewire-git-pending.patch
-#fi
+if [ "$C" -gt 10 ]; then
+ApplyPatch linux-2.6-firewire-git-pending.patch
+fi
 
 # usb video
 ApplyPatch linux-2.6-uvcvideo.patch
@@ -1228,24 +1369,159 @@
 ApplyPatch linux-2.6-xen-0001-squashfs-Fix-build-without-CONFIG_SMP.patch
 ApplyPatch linux-2.6-xen-0002-xen-execshield-Add-xen-specific-load_user_cs_desc.patch
 ApplyPatch linux-2.6-xen-0003-xen-execshield-fix-endless-GPF-fault-loop.patch
-ApplyPatch linux-2.6-xen-0004-xen-Do-not-pin-unpin-PMD-pages.patch
-ApplyPatch linux-2.6-xen-0005-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch
-ApplyPatch linux-2.6-xen-0006-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch
-ApplyPatch linux-2.6-xen-0007-xen-Enable-Xen-console-by-default-in-domU.patch
-ApplyPatch linux-2.6-xen-0008-xen-Module-autoprobing-support-for-frontend-drivers.patch
-ApplyPatch linux-2.6-xen-0009-xen-Add-compatibility-aliases-for-frontend-drivers.patch
-ApplyPatch linux-2.6-xen-0010-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch
-ApplyPatch linux-2.6-xen-0011-xen-Add-a-vmlinuz-target.patch
-ApplyPatch linux-2.6-xen-0012-xen-Add-empty-xenctrl-module.patch
-ApplyPatch linux-2.6-xen-0013-xen-Add-proc-xen-capabilities.patch
-ApplyPatch linux-2.6-xen-0014-xen-Add-proc-xen-privcmd.patch
-ApplyPatch linux-2.6-xen-0015-xen-Add-proc-xen-xenbus.patch
-ApplyPatch linux-2.6-xen-0016-xen-Add-Xen-s-sys-hypervisor-interface.patch
-ApplyPatch linux-2.6-xen-0017-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch
-ApplyPatch linux-2.6-xen-0018-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch
-ApplyPatch linux-2.6-xen-0019-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch
+ApplyPatch linux-2.6-xen-0004-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch
+ApplyPatch linux-2.6-xen-0005-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch
+ApplyPatch linux-2.6-xen-0006-xen-Enable-Xen-console-by-default-in-domU.patch
+ApplyPatch linux-2.6-xen-0007-xen-Module-autoprobing-support-for-frontend-drivers.patch
+ApplyPatch linux-2.6-xen-0008-xen-Add-compatibility-aliases-for-frontend-drivers.patch
+ApplyPatch linux-2.6-xen-0009-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch
+ApplyPatch linux-2.6-xen-0010-xen-Add-a-vmlinuz-target.patch
+ApplyPatch linux-2.6-xen-0011-xen-Add-empty-xenctrl-module.patch
+ApplyPatch linux-2.6-xen-0012-xen-Add-proc-xen-capabilities.patch
+ApplyPatch linux-2.6-xen-0013-xen-Add-proc-xen-privcmd.patch
+ApplyPatch linux-2.6-xen-0014-xen-Add-proc-xen-xenbus.patch
+ApplyPatch linux-2.6-xen-0015-xen-Add-Xen-s-sys-hypervisor-interface.patch
 %ifarch x86_64
-ApplyPatch linux-2.6-xen-0020-xen-x86_64-Initial-x86_64-support-for-Xen-paravirt_.patch
+ApplyPatch linux-2.6-xen-0016-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch
+ApplyPatch linux-2.6-xen-0017-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch
+ApplyPatch linux-2.6-xen-0018-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch
+ApplyPatch linux-2.6-xen-0019-xen-expose-set_pte_vaddr-and-make-xen-use-it.patch
+ApplyPatch linux-2.6-xen-0020-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch
+ApplyPatch linux-2.6-xen-0021-x86_64-Expose-set_pte_vaddr.patch
+ApplyPatch linux-2.6-xen-0022-x86_64-Split-set_pte_vaddr.patch
+ApplyPatch linux-2.6-xen-0023-x86_64-Add-clear_fixmap.patch
+ApplyPatch linux-2.6-xen-0024-xen-x86_64-Make-set_fixmap-a-paravirt-op-on-64-bi.patch
+ApplyPatch linux-2.6-xen-0025-xen-x86_64-Hack-to-set-vsyscall-pages-on-user-space.patch
+ApplyPatch linux-2.6-xen-0026-Handle-VSYSCALL_FIRST_PAGE-on-xen_set_pte.patch
+ApplyPatch linux-2.6-xen-0027-DMI-Define-dmi_scan_machine-as-no-op-if-CONFIG_DM.patch
+ApplyPatch linux-2.6-xen-0028-ACPI-thermal-Compile-without-CONFIG_DMI.patch
+ApplyPatch linux-2.6-xen-0029-xen-x86_64-Remove-the-640K-1M-hole-and-disable-DMI.patch
+ApplyPatch linux-2.6-xen-0030-xen-x86_64-Add-update_va_mapping-64-bit-code.patch
+ApplyPatch linux-2.6-xen-0031-x86_64-Add-sync_cmpxchg.patch
+ApplyPatch linux-2.6-xen-0032-xen-x86_64-Implement-HYPERVISOR-MULTI-_update_desc.patch
+ApplyPatch linux-2.6-xen-0033-xen-x86_64-Add-hacky-64-bit-x86_-read-write-_percpu.patch
+ApplyPatch linux-2.6-xen-0034-xen-x86_64-Use-x86_read_percpu-only-to-refer-to-a.patch
+ApplyPatch linux-2.6-xen-0035-Better-implementation-of-pte-functions.patch
+ApplyPatch linux-2.6-xen-0036-Add-FIX_PARAVIRT_BOOTAP-to-fixmap_64.h-too.patch
+ApplyPatch linux-2.6-xen-0037-Add-gate_offset-and-gate_segment-macros.patch
+ApplyPatch linux-2.6-xen-0038-xen_write_idt_entry-and-cvt_gate_to_trap.patch
+ApplyPatch linux-2.6-xen-0039-typedefs-for-pte_val-and-friends.patch
+ApplyPatch linux-2.6-xen-0040-x86_64-implementation-of-some-page.h-macros.patch
+ApplyPatch linux-2.6-xen-0041-Chainsaw-style-ifdefs.patch
+ApplyPatch linux-2.6-xen-0042-xen-Make-xen_pte_val-generic.patch
+ApplyPatch linux-2.6-xen-0043-More-chainsaw-ifdefs.patch
+ApplyPatch linux-2.6-xen-0044-Chainsaw-ifdefs-on-assembly-percpu-handling.patch
+ApplyPatch linux-2.6-xen-0045-x86_64-percpu-assembly-macros.patch
+ApplyPatch linux-2.6-xen-0046-Some-xen-asm.S-x86_64-code.patch
+ApplyPatch linux-2.6-xen-0047-Chainsaw-party-SPLITME.patch
+ApplyPatch linux-2.6-xen-0048-xen-asm.S-x86_64-notes.patch
+ApplyPatch linux-2.6-xen-0049-xen-x86_64-Make-hypercall-assembly-code-work.patch
+ApplyPatch linux-2.6-xen-0050-xen-x86_64-pda-initialization.patch
+ApplyPatch linux-2.6-xen-0051-Disable-discover_ebda-under-paravirt.patch
+ApplyPatch linux-2.6-xen-0052-Disable-early_printk-by-default.patch
+ApplyPatch linux-2.6-xen-0053-xen-Set-__HYPERVISOR_VIRT_START-for-x86_64.patch
+ApplyPatch linux-2.6-xen-0054-Set-__PAGE_OFFSET-as-required-by-Xen.patch
+ApplyPatch linux-2.6-xen-0055-DEBUG-Add-xprintk-to-log-directly-via-hypercall-fo.patch
+ApplyPatch linux-2.6-xen-0056-Use-__pgd-on-mk_kernel_pgd.patch
+ApplyPatch linux-2.6-xen-0057-Include-user-page-tables-on-head_64.S.patch
+ApplyPatch linux-2.6-xen-0058-Avoid-using-mk_unsigned_long.patch
+ApplyPatch linux-2.6-xen-0059-Lots-of-unrelated-changes.patch
+ApplyPatch linux-2.6-xen-0060-Hack-disable-vsmp.patch
+ApplyPatch linux-2.6-xen-0061-Export-early_make_page_readonly.patch
+ApplyPatch linux-2.6-xen-0062-Disable-multicalls.c-too-verbose-debugging.patch
+ApplyPatch linux-2.6-xen-0063-Xen-64-bit-ready-MMU-operations.patch
+ApplyPatch linux-2.6-xen-0064-Some-xen-mmu-pv-ops-implemented.patch
+ApplyPatch linux-2.6-xen-0065-Trying-to-make-the-pagetable-initialization-code-wor.patch
+ApplyPatch linux-2.6-xen-0066-Xen-specific-find_early_table_space-FIXME.patch
+ApplyPatch linux-2.6-xen-0067-Xen-call-e820_print_map-when-setting-up-memory.patch
+ApplyPatch linux-2.6-xen-0068-Comment-debugging-msgs.patch
+ApplyPatch linux-2.6-xen-0069-Try-to-make-pagetables-read-only.patch
+ApplyPatch linux-2.6-xen-0070-Debug-dump-pgtables-on-make_page_readonly.patch
+ApplyPatch linux-2.6-xen-0071-Disable-apic-at-compile-time-FIXME.patch
+ApplyPatch linux-2.6-xen-0072-Parse-early-params-after-init_memory_mapping.patch
+ApplyPatch linux-2.6-xen-0073-xen-Move-addr_to_page-to-init.h.patch
+ApplyPatch linux-2.6-xen-0074-Make-xen_pxx_val-and-xen_make_pxx-handle-attr-bi.patch
+ApplyPatch linux-2.6-xen-0075-Pull-xen_finish_init_mappin-from-XS-upstream.patch
+ApplyPatch linux-2.6-xen-0076-Pull-spp_getpage-changes-from-XS-upstream-REVIEWM.patch
+ApplyPatch linux-2.6-xen-0077-Pull-xen_extend_init_mapping-from-XS-upstream-FIX.patch
+ApplyPatch linux-2.6-xen-0078-New-enum-fixed_addresses-values-REVIEWME.patch
+ApplyPatch linux-2.6-xen-0079-Reserve-bootmem-areas-used-by-Xen-FIXME.patch
+ApplyPatch linux-2.6-xen-0080-xen_convert_trap_info-use-sizeof-struct-gate_desc.patch
+ApplyPatch linux-2.6-xen-0081-Call-paravirt_pagetable_setup_-start-done-REVIEW.patch
+ApplyPatch linux-2.6-xen-0082-ifdef-CONFIG_X86_32-on-xen-enlighten.c-REVIEWME.patch
+ApplyPatch linux-2.6-xen-0083-Handle-Xen-exception-stack-it-is-different-from-bar.patch
+ApplyPatch linux-2.6-xen-0084-Make-hvc_xen-console-use-xprintk-TEMPORARY.patch
+ApplyPatch linux-2.6-xen-0085-Implement-64-bit-version-of-HYPERVISOR_set_callbacks.patch
+ApplyPatch linux-2.6-xen-0086-Make-arch_vcpu_info-be-of-the-right-size-on-both-32.patch
+ApplyPatch linux-2.6-xen-0087-Implement-asm-xen_iret.patch
+ApplyPatch linux-2.6-xen-0088-xen-64-xen_iret-use-iretq-directly-if-returning-t.patch
+ApplyPatch linux-2.6-xen-0089-Implement-xen_irqenable_syscall_ret.patch
+ApplyPatch linux-2.6-xen-0090-DEBUG-xen_iret-always-return-through-the-hyperviso.patch
+ApplyPatch linux-2.6-xen-0091-Implement-some-xen-callbacks-on-xen-entry_64.S.patch
+ApplyPatch linux-2.6-xen-0092-Xen-specific-ifdef-hacks-on-kernel-entry_64.S-FIXM.patch
+ApplyPatch linux-2.6-xen-0093-Disable-syscall32-code-temporarily-FIXME.patch
+ApplyPatch linux-2.6-xen-0094-Use-__KERNEL_DS-as-SS-when-returning-to-a-kernel-thr.patch
+ApplyPatch linux-2.6-xen-0095-Use-apic_xen-on-genapic-by-default-FIXME.patch
+ApplyPatch linux-2.6-xen-0096-irq-vector-ifdef-chainsaw-FIXME.patch
+ApplyPatch linux-2.6-xen-0097-ifdef-chainsaw-on-syscall_init-FIXME.patch
+ApplyPatch linux-2.6-xen-0098-Pull-xen-genapic-implementation-from-upstream-Xen.patch
+ApplyPatch linux-2.6-xen-0099-Debugging-printk-s.patch
+ApplyPatch linux-2.6-xen-0100-Leave-lazy_cpu_mode-on-__switch_to.patch
+ApplyPatch linux-2.6-xen-0101-xen-64-Handle-fs-and-gs-on-xen_load_tls-properl.patch
+ApplyPatch linux-2.6-xen-0102-Disable-vcpu_info_placement-temporarily-FIXME.patch
+ApplyPatch linux-2.6-xen-0103-Fix-typo-on-ifdef-again.patch
+ApplyPatch linux-2.6-xen-0104-DEBUG-Don-t-try-to-actually-read-the-page-on-show_.patch
+ApplyPatch linux-2.6-xen-0105-Make-load_gs_index-a-paravirt-operation.patch
+ApplyPatch linux-2.6-xen-0106-xen-pgd_walk-use-limit-argument-instead-of-FIXADD.patch
+ApplyPatch linux-2.6-xen-0107-xen-pgd_walk-Eliminate-BUG_ON-limit-FIXADDR_TOP.patch
+ApplyPatch linux-2.6-xen-0108-xen-pgd_walk-accept-start-parameter.patch
+ApplyPatch linux-2.6-xen-0109-xen-64-reserve_bootmem-xen_start_info-area.patch
+ApplyPatch linux-2.6-xen-0110-pvops-64-call-paravirt_post_allocator_init-on-set.patch
+ApplyPatch linux-2.6-xen-0111-use-write_gdt_entry-on-vsyscall_set_cpu-CLEANME.patch
+ApplyPatch linux-2.6-xen-0112-xen-64-implement-xen_load_gs_index.patch
+ApplyPatch linux-2.6-xen-0113-include-asm-x86-pgalloc_64.h-pvops-hacks-SPLITME.patch
+ApplyPatch linux-2.6-xen-0114-Multi-pagetable-write_cr3-implementation-FIXME.patch
+ApplyPatch linux-2.6-xen-0115-Make-kcons_write_dom0-non-static-TEMPORARY.patch
+ApplyPatch linux-2.6-xen-0116-Disable-the-weird-count-loop-on-kcons_write_dom0.patch
+ApplyPatch linux-2.6-xen-0117-Make-xen_start_info-read-only.patch
+ApplyPatch linux-2.6-xen-0118-Hack-to-implement-return-to-userspace-without-SWAPGS.patch
+ApplyPatch linux-2.6-xen-0119-Xen-SEGBASE_-defines.patch
+ApplyPatch linux-2.6-xen-0120-Xen-HYPERVISOR_set_segment_base-implementation.patch
+ApplyPatch linux-2.6-xen-0121-Change-signature-of-paravirt_alloc_-pt-pd-REVIEWME.patch
+ApplyPatch linux-2.6-xen-0122-Comment-e820_print_map-call-TEMPORARY.patch
+ApplyPatch linux-2.6-xen-0123-Xen-missing-includes.patch
+ApplyPatch linux-2.6-xen-0124-asm-x86-pgtable_64.h-include-linux-spinlock.h.patch
+ApplyPatch linux-2.6-xen-0125-asm-x86-pgtable.h-include-asm-page.h.patch
+ApplyPatch linux-2.6-xen-0126-fix-pxxval_t-usage-on-mm-init_64.c.patch
+ApplyPatch linux-2.6-xen-0127-Missing-Xen-include.patch
+ApplyPatch linux-2.6-xen-0128-un-static-ipi_to_irq.patch
+ApplyPatch linux-2.6-xen-0129-Don-t-use-_PAGE_GLOBAL-bit-under-Xen-FIXME.patch
+ApplyPatch linux-2.6-xen-0130-Trying-to-organize-the-xen-bootmem-allocation-mess.patch
+ApplyPatch linux-2.6-xen-0131-Don-t-call-xprintk-when-writing-to-hvc-console.patch
+ApplyPatch linux-2.6-xen-0132-Xen-reserve_bootmem-xenstore-and-console-interfac.patch
+ApplyPatch linux-2.6-xen-0133-pvops-64-call-paravirt_activate_mm-on-activate_mm.patch
+ApplyPatch linux-2.6-xen-0134-Xen-64-bit-support-on-xen_pgd_pin.patch
+ApplyPatch linux-2.6-xen-0135-Xen-64-pin-user-PGD-on-activate_mm-and-dup_mmap.patch
+ApplyPatch linux-2.6-xen-0136-pgd_walk-changes-to-make-pgd-pinning-work-FIXME.patch
+ApplyPatch linux-2.6-xen-0137-Xen-Add-a-order-parameter-to-pgd_walk.patch
+ApplyPatch linux-2.6-xen-0138-Xen-64-Unpin-user-pagetable-on-xen_pgd_unpin.patch
+ApplyPatch linux-2.6-xen-0139-Use-un-pin_page-when-un-pinning-pgd.patch
+ApplyPatch linux-2.6-xen-0140-Allow-enabling-Xen-on-x86_64.patch
+ApplyPatch linux-2.6-xen-0141-Add-include-linux-spinlock_types.h-to-asm-x86-pgt.patch
+ApplyPatch linux-2.6-xen-0142-Restore-some-sanity-on-the-initial-pagetable-bootmem.patch
+ApplyPatch linux-2.6-xen-0143-Xen-Use-system_call_after_swapgs-as-the-syscall-c.patch
+ApplyPatch linux-2.6-xen-0144-DEBUG-write-to-HV-console-on-printk.patch
+ApplyPatch linux-2.6-xen-0145-Add-a-system_call_after_saveargs-label-to-entry_64.S.patch
+ApplyPatch linux-2.6-xen-0146-Create-xen-specific-syscall-entry.patch
+ApplyPatch linux-2.6-xen-0147-syscall-related-Xen-ifdefs-FIXME.patch
+ApplyPatch linux-2.6-xen-0148-Point-set_pte-to-xen_set_pte-since-the-beginning.patch
+ApplyPatch linux-2.6-xen-0149-DEBUG-slab-debugging.patch
+ApplyPatch linux-2.6-xen-0150-pvops-64-Include-rsi-on-the-register-clobber-list.patch
+ApplyPatch linux-2.6-xen-0151-Xen-64-quick-ugly-hack-to-fix-pgd_clear-pagetabl.patch
+ApplyPatch linux-2.6-xen-0152-Add-missing-acpi-include-to-xen-setup.c.patch
+ApplyPatch linux-2.6-xen-0153-Don-t-use-FIX_VDSO-on-64-bit.patch
+ApplyPatch linux-2.6-xen-0154-Mark-init-pages-read-write-again-on-free_init_pages.patch
+ApplyPatch linux-2.6-xen-0155-reserve_early-kernel-text-and-data-segments.patch
 %endif
 # kernel-xen apply end
 
@@ -1271,8 +1547,8 @@
   fi
 done
 
-%if !%{with_debug}
-rm -f kernel-%{version}-*-debug.config
+%if !%{debugbuildsenabled}
+rm -f kernel-%{version}-*debug.config
 %endif
 
 # now run oldconfig over all the config files
@@ -1855,6 +2131,10 @@
 %kernel_variant_files -a /%{image_install_path}/xen*-%{KVERREL}.xen -e /etc/ld.so.conf.d/kernelcap-%{KVERREL}.xen.conf %{with_xen} xen
 
 %changelog
+* Mon Apr 14 2008 Mark McLoughlin <markmc at redhat.com>
+- Rebase to kernel-2.6.25-0.228.rc9.fc9
+- Include Markus's latest console handling patch
+
 * Tue Apr  8 2008 Mark McLoughlin <markmc at redhat.com>
 - Fix the requires on kernel-xen-debuginfo
 

linux-2.6-compile-fixes.patch:

Index: linux-2.6-compile-fixes.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/linux-2.6-compile-fixes.patch,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- linux-2.6-compile-fixes.patch	6 Mar 2008 13:59:25 -0000	1.4
+++ linux-2.6-compile-fixes.patch	14 Apr 2008 16:06:53 -0000	1.5
@@ -4,4 +4,3 @@
 # Please add the errors from gcc before the diffs to save others having
 # to do a compile to figure out what your diff is fixing. Thanks.
 #
-

linux-2.6-drm-i915-modeset.patch:

Index: linux-2.6-drm-i915-modeset.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/linux-2.6-drm-i915-modeset.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- linux-2.6-drm-i915-modeset.patch	1 Apr 2008 10:38:06 -0000	1.1
+++ linux-2.6-drm-i915-modeset.patch	14 Apr 2008 16:06:53 -0000	1.2
@@ -884,23 +884,38 @@
  static int drm_copy_io_page(void *dst, void *src, unsigned long page)
  {
 diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
-index f3aac97..e9b0bdb 100644
+index f3aac97..b8e1dd6 100644
 --- a/drivers/char/drm/drm_bufs.c
 +++ b/drivers/char/drm/drm_bufs.c
-@@ -53,9 +53,9 @@ struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
+@@ -48,14 +48,24 @@ unsigned long drm_get_resource_len(struct drm_device *dev, unsigned int resource
+ }
+ EXPORT_SYMBOL(drm_get_resource_len);
+ 
++static __inline__ bool map_has_master(struct drm_device *dev,
++				      struct drm_map_list *entry)
++{
++	if (entry->master && entry->master == dev->primary->master)
++		return true;
++	if (!entry->master && entry->map->flags & _DRM_DRIVER)
++		return true;
++	return false;
++}
++
+ struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
+ 					   drm_local_map_t *map)
  {
  	struct drm_map_list *entry;
  	list_for_each_entry(entry, &dev->maplist, head) {
 -		if (entry->map && map->type == entry->map->type &&
 -		    ((entry->map->offset == map->offset) ||
 -		     (map->type == _DRM_SHM && map->flags == _DRM_CONTAINS_LOCK))) {
-+		if (entry->map && (entry->master == dev->primary->master) && (map->type == entry->map->type) &&
++		if (entry->map && map_has_master(dev, entry) && (map->type == entry->map->type) &&
 +		    ((entry->map->offset == map->offset) || 
 +		     ((map->type == _DRM_SHM) && (map->flags&_DRM_CONTAINS_LOCK)))) {
  			return entry;
  		}
  	}
-@@ -210,12 +210,12 @@ static int drm_addmap_core(struct drm_device *dev, unsigned int offset,
+@@ -210,12 +220,12 @@ static int drm_addmap_core(struct drm_device *dev, unsigned int offset,
  		map->offset = (unsigned long)map->handle;
  		if (map->flags & _DRM_CONTAINS_LOCK) {
  			/* Prevent a 2nd X Server from creating a 2nd lock */
@@ -915,7 +930,7 @@
  		}
  		break;
  	case _DRM_AGP: {
-@@ -319,6 +319,7 @@ static int drm_addmap_core(struct drm_device *dev, unsigned int offset,
+@@ -319,6 +329,7 @@ static int drm_addmap_core(struct drm_device *dev, unsigned int offset,
  	list->user_token = list->hash.key << PAGE_SHIFT;
  	mutex_unlock(&dev->struct_mutex);
  
@@ -923,7 +938,7 @@
  	*maplist = list;
  	return 0;
  	}
-@@ -408,6 +409,9 @@ int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t *map)
+@@ -408,6 +419,9 @@ int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t *map)
  		break;
  	case _DRM_SHM:
  		vfree(map->handle);
@@ -6606,10 +6621,10 @@
  
  	mutex_lock(&dev->struct_mutex);
 diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stub.c
-index af0105c..4d7e7b3 100644
+index af0105c..3b797b5 100644
 --- a/drivers/char/drm/drm_stub.c
 +++ b/drivers/char/drm/drm_stub.c
-@@ -36,38 +36,127 @@
+@@ -36,38 +36,135 @@
  #include "drmP.h"
  #include "drm_core.h"
  
@@ -6693,6 +6708,7 @@
 +{
 +	struct drm_magic_entry *pt, *next;
 +	struct drm_device *dev = master->minor->dev;
++	struct drm_map_list *r_list, *list_t;
 +
 +	list_del(&master->head);
 +
@@ -6721,6 +6737,13 @@
 +		wake_up_interruptible(&master->lock.lock_queue);
 +	}
 +
++	list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) {
++		if (!(r_list->map->flags & _DRM_DRIVER) && (r_list->master == master)) {
++			drm_rmmap_locked(dev, r_list->map);
++			r_list = NULL;
++		}
++	}
++
 +	drm_free(master, sizeof(*master), DRM_MEM_DRIVER);
 +}
 +
@@ -6744,7 +6767,7 @@
  	init_timer(&dev->timer);
  	mutex_init(&dev->struct_mutex);
  	mutex_init(&dev->ctxlist_mutex);
-@@ -83,6 +172,7 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
+@@ -83,6 +180,7 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
  	dev->hose = pdev->sysdata;
  #endif
  	dev->irq = pdev->irq;
@@ -6752,7 +6775,7 @@
  
  	if (drm_ht_create(&dev->map_hash, DRM_MAP_HASH_ORDER)) {
  		return -ENOMEM;
-@@ -129,10 +219,6 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
+@@ -129,10 +227,6 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
  		}
  	}
  
@@ -6763,7 +6786,7 @@
  	retcode = drm_ctxbitmap_init(dev);
  	if (retcode) {
  		DRM_ERROR("Cannot allocate memory for context bitmap.\n");
-@@ -159,48 +245,61 @@ error_out_unreg:
+@@ -159,48 +253,61 @@ error_out_unreg:
   * create the proc init entry via proc_init(). This routines assigns
   * minor numbers to secondary heads of multi-headed cards
   */
@@ -6859,7 +6882,7 @@
  	return ret;
  }
  
-@@ -229,28 +328,45 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
+@@ -229,28 +336,45 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
  
  	ret = pci_enable_device(pdev);
  	if (ret)
@@ -6914,7 +6937,7 @@
  
  /**
   * Put a device minor number.
-@@ -266,11 +382,6 @@ int drm_put_dev(struct drm_device * dev)
+@@ -266,11 +390,6 @@ int drm_put_dev(struct drm_device * dev)
  {
  	DRM_DEBUG("release primary %s\n", dev->driver->pci_driver.name);
  
@@ -6926,7 +6949,7 @@
  	if (dev->devname) {
  		drm_free(dev->devname, strlen(dev->devname) + 1,
  			 DRM_MEM_DRIVER);
-@@ -290,18 +401,18 @@ int drm_put_dev(struct drm_device * dev)
+@@ -290,18 +409,18 @@ int drm_put_dev(struct drm_device * dev)
   * last minor released.
   *
   */
@@ -7088,10 +7111,10 @@
 +	device_unregister(&minor->kdev);
  }
 diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
-index 6184b98..832c927 100644
+index 77576e3..a249023 100644
 --- a/drivers/char/drm/drm_vm.c
 +++ b/drivers/char/drm/drm_vm.c
-@@ -83,7 +83,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma)
+@@ -94,7 +94,7 @@ static pgprot_t drm_dma_prot(uint32_t map_type, struct vm_area_struct *vma)
  static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
  {
  	struct drm_file *priv = vma->vm_file->private_data;
@@ -7100,7 +7123,7 @@
  	struct drm_map *map = NULL;
  	struct drm_map_list *r_list;
  	struct drm_hash_item *hash;
-@@ -200,7 +200,7 @@ static int drm_do_vm_shm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+@@ -211,7 +211,7 @@ static int drm_do_vm_shm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
  static void drm_vm_shm_close(struct vm_area_struct *vma)
  {
  	struct drm_file *priv = vma->vm_file->private_data;
@@ -7109,7 +7132,7 @@
  	struct drm_vma_entry *pt, *temp;
  	struct drm_map *map;
  	struct drm_map_list *r_list;
-@@ -282,7 +282,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
+@@ -293,7 +293,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
  static int drm_do_vm_dma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
  {
  	struct drm_file *priv = vma->vm_file->private_data;
@@ -7118,7 +7141,7 @@
  	struct drm_device_dma *dma = dev->dma;
  	unsigned long offset;
  	unsigned long page_nr;
-@@ -317,7 +317,7 @@ static int drm_do_vm_sg_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+@@ -328,7 +328,7 @@ static int drm_do_vm_sg_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
  {
  	struct drm_map *map = (struct drm_map *) vma->vm_private_data;
  	struct drm_file *priv = vma->vm_file->private_data;
@@ -7127,7 +7150,7 @@
  	struct drm_sg_mem *entry = dev->sg;
  	unsigned long offset;
  	unsigned long map_offset;
-@@ -398,7 +398,7 @@ static struct vm_operations_struct drm_vm_sg_ops = {
+@@ -409,7 +409,7 @@ static struct vm_operations_struct drm_vm_sg_ops = {
  static void drm_vm_open_locked(struct vm_area_struct *vma)
  {
  	struct drm_file *priv = vma->vm_file->private_data;
@@ -7136,7 +7159,7 @@
  	struct drm_vma_entry *vma_entry;
  
  	DRM_DEBUG("0x%08lx,0x%08lx\n",
-@@ -416,7 +416,7 @@ static void drm_vm_open_locked(struct vm_area_struct *vma)
+@@ -427,7 +427,7 @@ static void drm_vm_open_locked(struct vm_area_struct *vma)
  static void drm_vm_open(struct vm_area_struct *vma)
  {
  	struct drm_file *priv = vma->vm_file->private_data;
@@ -7145,7 +7168,7 @@
  
  	mutex_lock(&dev->struct_mutex);
  	drm_vm_open_locked(vma);
-@@ -434,7 +434,7 @@ static void drm_vm_open(struct vm_area_struct *vma)
+@@ -445,7 +445,7 @@ static void drm_vm_open(struct vm_area_struct *vma)
  static void drm_vm_close(struct vm_area_struct *vma)
  {
  	struct drm_file *priv = vma->vm_file->private_data;
@@ -7154,7 +7177,7 @@
  	struct drm_vma_entry *pt, *temp;
  
  	DRM_DEBUG("0x%08lx,0x%08lx\n",
-@@ -469,7 +469,7 @@ static int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma)
+@@ -480,7 +480,7 @@ static int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma)
  	struct drm_device_dma *dma;
  	unsigned long length = vma->vm_end - vma->vm_start;
  
@@ -7163,7 +7186,7 @@
  	dma = dev->dma;
  	DRM_DEBUG("start = 0x%lx, end = 0x%lx, page offset = 0x%lx\n",
  		  vma->vm_start, vma->vm_end, vma->vm_pgoff);
-@@ -539,7 +539,7 @@ EXPORT_SYMBOL(drm_core_get_reg_ofs);
+@@ -550,7 +550,7 @@ EXPORT_SYMBOL(drm_core_get_reg_ofs);
  static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
  {
  	struct drm_file *priv = filp->private_data;
@@ -7172,7 +7195,7 @@
  	struct drm_map *map = NULL;
  	unsigned long offset = 0;
  	struct drm_hash_item *hash;
-@@ -660,7 +660,7 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
+@@ -670,7 +670,7 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
  int drm_mmap(struct file *filp, struct vm_area_struct *vma)
  {
  	struct drm_file *priv = filp->private_data;
@@ -7181,7 +7204,7 @@
  	int ret;
  
  	mutex_lock(&dev->struct_mutex);
-@@ -679,8 +679,8 @@ EXPORT_SYMBOL(drm_mmap);
+@@ -689,8 +689,8 @@ EXPORT_SYMBOL(drm_mmap);
   * \c Pagefault method for buffer objects.
   *
   * \param vma Virtual memory area.
@@ -7192,7 +7215,7 @@
   *
   * It's important that pfns are inserted while holding the bo->mutex lock.
   * otherwise we might race with unmap_mapping_range() which is always
-@@ -692,7 +692,8 @@ EXPORT_SYMBOL(drm_mmap);
+@@ -702,7 +702,8 @@ EXPORT_SYMBOL(drm_mmap);
   * protected by the bo->mutex lock.
   */
  
@@ -7202,7 +7225,7 @@
  {
  	struct drm_buffer_object *bo = (struct drm_buffer_object *) vma->vm_private_data;
  	unsigned long page_offset;
-@@ -704,22 +705,25 @@ static int drm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+@@ -714,22 +715,25 @@ static int drm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
  	unsigned long bus_base;
  	unsigned long bus_offset;
  	unsigned long bus_size;
@@ -7232,7 +7255,7 @@
  		goto out_unlock;
  	}
  
-@@ -734,7 +738,7 @@ static int drm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+@@ -744,7 +748,7 @@ static int drm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
  			DRM_BO_FLAG_FORCE_MAPPABLE;
  		err = drm_bo_move_buffer(bo, new_flags, 0, 0);
  		if (err) {
@@ -7241,7 +7264,7 @@
  			goto out_unlock;
  		}
  	}
-@@ -743,12 +747,11 @@ static int drm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+@@ -753,12 +757,11 @@ static int drm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
  				&bus_size);
  
  	if (err) {
@@ -7256,7 +7279,7 @@
  
  	if (bus_size) {
  		struct drm_mem_type_manager *man = &dev->bm.man[bo->mem.mem_type];
-@@ -761,7 +764,7 @@ static int drm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+@@ -771,7 +774,7 @@ static int drm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
  		drm_ttm_fixup_caching(ttm);
  		page = drm_ttm_get_page(ttm, page_offset);
  		if (!page) {
@@ -7265,7 +7288,7 @@
  			goto out_unlock;
  		}
  		pfn = page_to_pfn(page);
-@@ -770,9 +773,9 @@ static int drm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+@@ -780,9 +783,9 @@ static int drm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
  			drm_io_prot(_DRM_TTM, vma);
  	}
  
@@ -7277,7 +7300,7 @@
  		goto out_unlock;
  	}
  out_unlock:
-@@ -827,7 +830,7 @@ static void drm_bo_vm_close(struct vm_area_struct *vma)
+@@ -837,7 +840,7 @@ static void drm_bo_vm_close(struct vm_area_struct *vma)
  }
  
  static struct vm_operations_struct drm_bo_vm_ops = {
@@ -7354,7 +7377,7 @@
  		DRM_ERROR("Unsupported memory type %u\n", (unsigned)type);
  		return -EINVAL;
 diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
-index d2b7d3f..9ca655d 100644
+index f3d0dd1..9ca655d 100644
 --- a/drivers/char/drm/i915_dma.c
 +++ b/drivers/char/drm/i915_dma.c
 @@ -38,8 +38,8 @@
@@ -7788,11 +7811,11 @@
  {
 -	drm_i915_private_t *dev_priv = dev->dev_private;
 -	int i, planes, num_pages = dev_priv->sarea_priv->third_handle ? 3 : 2;
--
--	DRM_DEBUG("%s\n", __FUNCTION__);
 +	struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
 +	int i, planes, num_pages;
  
+-	DRM_DEBUG("%s\n", __FUNCTION__);
+-
 -	for (i = 0, planes = 0; i < 2; i++)
 -		if (dev_priv->sarea_priv->pf_current_page & (0x3 << (2 * i))) {
 -			dev_priv->sarea_priv->pf_current_page =
@@ -7848,7 +7871,7 @@
  	drm_i915_hws_addr_t *hws = data;
  
  	if (!I915_NEED_GFX_HWS(dev))
-@@ -1540,84 +1556,6 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
+@@ -1538,84 +1556,6 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
  	return 0;
  }
  
@@ -7933,7 +7956,7 @@
  struct drm_ioctl_desc i915_ioctls[] = {
  	DRM_IOCTL_DEF(DRM_I915_INIT, i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  	DRM_IOCTL_DEF(DRM_I915_FLUSH, i915_flush_ioctl, DRM_AUTH),
-@@ -1654,8 +1596,3 @@ int i915_driver_device_is_agp(struct drm_device *dev)
+@@ -1658,8 +1598,3 @@ int i915_driver_device_is_agp(struct drm_device *dev)
  	return 1;
  }
  
@@ -8954,10 +8977,10 @@
  	int ret;
 diff --git a/drivers/char/drm/i915_init.c b/drivers/char/drm/i915_init.c
 new file mode 100644
-index 0000000..1234ac0
+index 0000000..4a53fc8
 --- /dev/null
 +++ b/drivers/char/drm/i915_init.c
-@@ -0,0 +1,408 @@
+@@ -0,0 +1,411 @@
 +/*
 + * Copyright (c) 2007 Intel Corporation
 + *   Jesse Barnes <jesse.barnes at intel.com>
@@ -9349,6 +9372,9 @@
 +{
 +	struct drm_i915_private *dev_priv = dev->dev_private;
 +
++	if (!dev_priv)
++		return;
++
 +	if (drm_core_check_feature(dev, DRIVER_MODESET))
 +		return;
 +
@@ -16321,8 +16347,63 @@
  		DRM_ERROR("Failed TT mm init: %d\n", ret);
  		return ret;
  	}
+diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
+index 9072e4a..dd9bb45 100644
+--- a/drivers/char/drm/radeon_cp.c
++++ b/drivers/char/drm/radeon_cp.c
+@@ -2393,6 +2393,9 @@ int radeon_driver_load(struct drm_device *dev, unsigned long flags)
+ 
+ 	DRM_DEBUG("%s card detected\n",
+ 		  ((dev_priv->flags & RADEON_IS_AGP) ? "AGP" : (((dev_priv->flags & RADEON_IS_PCIE) ? "PCIE" : "PCI"))));
++	ret = drm_addmap(dev, drm_get_resource_start(dev, 2),
++			 drm_get_resource_len(dev, 2), _DRM_REGISTERS,
++			 _DRM_READ_ONLY|_DRM_DRIVER, &dev_priv->mmio);
+ 	return ret;
+ }
+ 
+@@ -2407,12 +2410,6 @@ int radeon_driver_firstopen(struct drm_device *dev)
+ 
+ 	dev_priv->gart_info.table_size = RADEON_PCIGART_TABLE_SIZE;
+ 
+-	ret = drm_addmap(dev, drm_get_resource_start(dev, 2),
+-			 drm_get_resource_len(dev, 2), _DRM_REGISTERS,
+-			 _DRM_READ_ONLY, &dev_priv->mmio);
+-	if (ret != 0)
+-		return ret;
+-
+ 	dev_priv->fb_aper_offset = drm_get_resource_start(dev, 0);
+ 	ret = drm_addmap(dev, dev_priv->fb_aper_offset,
+ 			 drm_get_resource_len(dev, 0), _DRM_FRAME_BUFFER,
+@@ -2428,6 +2425,7 @@ int radeon_driver_unload(struct drm_device *dev)
+ 	drm_radeon_private_t *dev_priv = dev->dev_private;
+ 
+ 	DRM_DEBUG("\n");
++	drm_rmmap(dev, dev_priv->mmio);
+ 	drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ 
+ 	dev->dev_private = NULL;
+diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h
+index 173ae62..20faa2a 100644
+--- a/drivers/char/drm/radeon_drv.h
++++ b/drivers/char/drm/radeon_drv.h
+@@ -280,7 +280,6 @@ typedef struct drm_radeon_private {
+ 	unsigned long gart_textures_offset;
+ 
+ 	drm_local_map_t *sarea;
+-	drm_local_map_t *mmio;
+ 	drm_local_map_t *cp_ring;
+ 	drm_local_map_t *ring_rptr;
+ 	drm_local_map_t *gart_textures;
+@@ -307,6 +306,7 @@ typedef struct drm_radeon_private {
+ 	/* starting from here on, data is preserved accross an open */
+ 	uint32_t flags;		/* see radeon_chip_flags */
+ 	unsigned long fb_aper_offset;
++	drm_local_map_t *mmio;
+ } drm_radeon_private_t;
+ 
+ typedef struct drm_radeon_buf_priv {
 diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c
-index 6f75512..8e4a494 100644
+index 6f75512..3cd3972 100644
 --- a/drivers/char/drm/radeon_state.c
 +++ b/drivers/char/drm/radeon_state.c
 @@ -3012,7 +3012,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
@@ -16334,3 +16415,20 @@
  		break;
  #endif
  	case RADEON_PARAM_GART_TEX_HANDLE:
+@@ -3067,12 +3067,14 @@ static int radeon_cp_setparam(struct drm_device *dev, void *data, struct drm_fil
+ 			DRM_DEBUG("color tiling disabled\n");
+ 			dev_priv->front_pitch_offset &= ~RADEON_DST_TILE_MACRO;
+ 			dev_priv->back_pitch_offset &= ~RADEON_DST_TILE_MACRO;
+-			dev_priv->sarea_priv->tiling_enabled = 0;
++			if (dev_priv->sarea_priv)
++				dev_priv->sarea_priv->tiling_enabled = 0;
+ 		} else if (sp->value == 1) {
+ 			DRM_DEBUG("color tiling enabled\n");
+ 			dev_priv->front_pitch_offset |= RADEON_DST_TILE_MACRO;
+ 			dev_priv->back_pitch_offset |= RADEON_DST_TILE_MACRO;
+-			dev_priv->sarea_priv->tiling_enabled = 1;
++			if (dev_priv->sarea_priv)
++				dev_priv->sarea_priv->tiling_enabled = 1;
+ 		}
+ 		break;
+ 	case RADEON_SETPARAM_PCIGART_LOCATION:

linux-2.6-firewire-git-pending.patch:

Index: linux-2.6-firewire-git-pending.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/linux-2.6-firewire-git-pending.patch,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- linux-2.6-firewire-git-pending.patch	1 Apr 2008 10:38:06 -0000	1.3
+++ linux-2.6-firewire-git-pending.patch	14 Apr 2008 16:06:53 -0000	1.4
@@ -3,843 +3,104 @@
 # tree, which we think we're going to want...
 #
 
-
-Increase reconnect management orb timeout.
-
-Signed-off-by: Jarod Wilson <jwilson at redhat.com>
-
----
-
- drivers/firewire/fw-sbp2.c |   15 +++++++++++++--
- 1 files changed, 13 insertions(+), 2 deletions(-)
-
-diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
-index d6d62c6..da315cf 100644
---- a/drivers/firewire/fw-sbp2.c
-+++ b/drivers/firewire/fw-sbp2.c
-@@ -170,6 +170,7 @@ struct sbp2_target {
-  */
- #define SBP2_MIN_LOGIN_ORB_TIMEOUT	5000U	/* Timeout in ms */
- #define SBP2_MAX_LOGIN_ORB_TIMEOUT	40000U	/* Timeout in ms */
-+#define SBP2_MAX_RECONNECT_ORB_TIMEOUT	10000U	/* Timeout in ms */
- #define SBP2_ORB_TIMEOUT		2000U	/* Timeout in ms */
- #define SBP2_ORB_NULL			0x80000000
- #define SBP2_MAX_SG_ELEMENT_LENGTH	0xf000
-@@ -538,14 +539,24 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
- 	orb->request.status_fifo.low  =
- 		cpu_to_be32(lu->address_handler.offset);
- 
--	if (function == SBP2_LOGIN_REQUEST) {
-+	switch (function) {
-+
-+	case SBP2_LOGIN_REQUEST:
- 		/* Ask for 2^2 == 4 seconds reconnect grace period */
- 		orb->request.misc |= cpu_to_be32(
- 			MANAGEMENT_ORB_RECONNECT(2) |
- 			MANAGEMENT_ORB_EXCLUSIVE(sbp2_param_exclusive_login));
- 		timeout = lu->tgt->mgt_orb_timeout;
--	} else {
-+		break;
-+
-+	case SBP2_RECONNECT_REQUEST:
-+		timeout = min(SBP2_MAX_RECONNECT_ORB_TIMEOUT,
-+			      lu->tgt->mgt_orb_timeout);
-+		break;
-+
-+	default:
- 		timeout = SBP2_ORB_TIMEOUT;
-+		break;
- 	}
- 
- 	init_completion(&orb->done);
-
-
-
-Adds a goofy routine to dump the configuration ROM as far as it could be
-read, if fw-core failed to get it all.
-
-Signed-off-by: Stefan Richter <stefanr at s5r6.in-berlin.de>
----
-
-We may want to reduce it to printing
-  - any encountered Extended ROM keys,
-  - the number of quadlets that were successfully read
-    (in the last attempt, or in the most successfull attempt?),
-  - the return code of the last attempt
-before submitting to mainline.
-
- drivers/firewire/fw-device.c |  126 ++++++++++++++++++++++-------------
- drivers/firewire/fw-device.h |    1 
- 2 files changed, 82 insertions(+), 45 deletions(-)
-
-Index: linux/drivers/firewire/fw-device.c
-===================================================================
---- linux.orig/drivers/firewire/fw-device.c
-+++ linux/drivers/firewire/fw-device.c
-@@ -18,6 +18,7 @@
-  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-  */
- 
-+#include <linux/bitops.h>
- #include <linux/module.h>
- #include <linux/wait.h>
- #include <linux/errno.h>
-@@ -422,8 +423,12 @@ read_rom(struct fw_device *device, int g
- 	return callback_data.rcode;
- }
- 
--#define READ_BIB_ROM_SIZE	256
--#define READ_BIB_STACK_SIZE	16
-+#define MAX_CONFIG_ROM_SIZE ((CSR_CONFIG_ROM_END - CSR_CONFIG_ROM) / 4)
-+
-+struct config_rom_image {
-+	u32 rom[MAX_CONFIG_ROM_SIZE];
-+	DECLARE_BITMAP(read, MAX_CONFIG_ROM_SIZE);
-+};
- 
- /*
-  * Read the bus info block, perform a speed probe, and read all of the rest of
-@@ -432,35 +437,36 @@ read_rom(struct fw_device *device, int g
-  * It's better to start all over in this case because the node from which we
-  * are reading the ROM may have changed the ROM during the reset.
-  */
--static int read_bus_info_block(struct fw_device *device, int generation)
-+static int read_bus_info_block(struct fw_device *device, int generation,
-+			       struct config_rom_image *rom_img)
- {
--	u32 *rom, *stack, *old_rom, *new_rom;
-+	u32 *rom, *old_rom, *new_rom;
-+	u32 stack[16];
- 	u32 sp, key;
--	int i, end, length, ret = -1;
-+	int i, end, length, ret;
- 
--	rom = kmalloc(sizeof(*rom) * READ_BIB_ROM_SIZE +
--		      sizeof(*stack) * READ_BIB_STACK_SIZE, GFP_KERNEL);
--	if (rom == NULL)
-+	if (rom_img == NULL)
- 		return -ENOMEM;
--
--	stack = &rom[READ_BIB_ROM_SIZE];
-+	rom = rom_img->rom;
- 
- 	device->max_speed = SCODE_100;
- 
- 	/* First read the bus info block. */
- 	for (i = 0; i < 5; i++) {
--		if (read_rom(device, generation, i, &rom[i]) != RCODE_COMPLETE)
--			goto out;
-+		ret = read_rom(device, generation, i, &rom[i]);
-+		if (ret != RCODE_COMPLETE)
-+			return ret;
-+		__set_bit(i, rom_img->read);
- 		/*
- 		 * As per IEEE1212 7.2, during power-up, devices can
- 		 * reply with a 0 for the first quadlet of the config
--		 * rom to indicate that they are booting (for example,
-+		 * ROM to indicate that they are booting (for example,
- 		 * if the firmware is on the disk of a external
- 		 * harddisk).  In that case we just fail, and the
- 		 * retry mechanism will try again later.
- 		 */
- 		if (i == 0 && rom[i] == 0)
--			goto out;
-+			return -EAGAIN;
- 	}
- 
- 	device->max_speed = device->node->max_speed;
-@@ -484,15 +490,17 @@ static int read_bus_info_block(struct fw
- 			device->max_speed = device->card->link_speed;
- 
- 		while (device->max_speed > SCODE_100) {
--			if (read_rom(device, generation, 0, &dummy) ==
--			    RCODE_COMPLETE)
-+			ret = read_rom(device, generation, 0, &dummy);
-+			if (ret == RCODE_COMPLETE)
- 				break;
-+			if (ret == RCODE_GENERATION)
-+				return ret;
- 			device->max_speed--;
- 		}
- 	}
- 
- 	/*
--	 * Now parse the config rom.  The config rom is a recursive
-+	 * Now parse the config ROM.  The config ROM is a recursive
- 	 * directory structure so we parse it using a stack of
- 	 * references to the blocks that make up the structure.  We
- 	 * push a reference to the root directory on the stack to
-@@ -504,44 +512,49 @@ static int read_bus_info_block(struct fw
- 	while (sp > 0) {
- 		/*
- 		 * Pop the next block reference of the stack.  The
--		 * lower 24 bits is the offset into the config rom,
-+		 * lower 24 bits is the offset into the config ROM,
- 		 * the upper 8 bits are the type of the reference the
- 		 * block.
- 		 */
- 		key = stack[--sp];
- 		i = key & 0xffffff;
--		if (i >= READ_BIB_ROM_SIZE)
-+		if (i >= MAX_CONFIG_ROM_SIZE) {
- 			/*
- 			 * The reference points outside the standard
--			 * config rom area, something's fishy.
-+			 * config ROM area.
- 			 */
--			goto out;
--
-+			if (key >> 24 == (CSR_EXTENDED_ROM | CSR_LEAF))
-+				fw_error("Extended ROM not supported\n");
-+			return -EINVAL;
-+		}
- 		/* Read header quadlet for the block to get the length. */
--		if (read_rom(device, generation, i, &rom[i]) != RCODE_COMPLETE)
--			goto out;
-+		ret = read_rom(device, generation, i, &rom[i]);
-+		if (ret != RCODE_COMPLETE)
-+			return ret;
-+		__set_bit(i, rom_img->read);
- 		end = i + (rom[i] >> 16) + 1;
- 		i++;
--		if (end > READ_BIB_ROM_SIZE)
-+		if (end > MAX_CONFIG_ROM_SIZE) {
- 			/*
- 			 * This block extends outside standard config
- 			 * area (and the array we're reading it
- 			 * into).  That's broken, so ignore this
- 			 * device.
- 			 */
--			goto out;
--
-+			return -EINVAL;
-+		}
- 		/*
- 		 * Now read in the block.  If this is a directory
- 		 * block, check the entries as we read them to see if
- 		 * it references another block, and push it in that case.
- 		 */
- 		while (i < end) {
--			if (read_rom(device, generation, i, &rom[i]) !=
--			    RCODE_COMPLETE)
--				goto out;
-+			ret = read_rom(device, generation, i, &rom[i]);
-+			if (ret != RCODE_COMPLETE)
-+				return ret;
-+			__set_bit(i, rom_img->read);
- 			if ((key >> 30) == 3 && (rom[i] >> 30) > 1 &&
--			    sp < READ_BIB_STACK_SIZE)
-+			    sp < ARRAY_SIZE(stack))
- 				stack[sp++] = i + rom[i];
- 			i++;
- 		}
-@@ -552,7 +565,7 @@ static int read_bus_info_block(struct fw
- 	old_rom = device->config_rom;
- 	new_rom = kmemdup(rom, length * 4, GFP_KERNEL);
- 	if (new_rom == NULL)
--		goto out;
-+		return -ENOMEM;
- 
- 	down_write(&fw_device_rwsem);
- 	device->config_rom = new_rom;
-@@ -560,14 +573,25 @@ static int read_bus_info_block(struct fw
- 	up_write(&fw_device_rwsem);
- 
- 	kfree(old_rom);
--	ret = 0;
- 	device->cmc = rom[2] & 1 << 30;
-- out:
--	kfree(rom);
- 
--	return ret;
-+	return 0;
-+}
-+
-+static void dump_config_rom(struct config_rom_image *rom_img)
-+{
-+	int i;
-+
-+	if (rom_img == NULL || !test_bit(0, rom_img->read))
-+		return;
-+
-+	fw_notify("config ROM read so far:\n");
-+	for_each_bit(i, rom_img->read, MAX_CONFIG_ROM_SIZE)
-+		printk(KERN_NOTICE "%x: %08x\n",
-+		       CSR_CONFIG_ROM + i * 4, rom_img->rom[i]);
- }
- 
-+
- static void fw_unit_release(struct device *dev)
- {
- 	struct fw_unit *unit = fw_unit(dev);
-@@ -697,27 +721,32 @@ static void fw_device_init(struct work_s
- {
- 	struct fw_device *device =
- 		container_of(work, struct fw_device, work.work);
-+	struct config_rom_image *rom_img;
- 	int minor, err;
- 
-+	rom_img = kzalloc(sizeof(*rom_img), GFP_KERNEL);
-+
- 	/*
- 	 * All failure paths here set node->data to NULL, so that we
- 	 * don't try to do device_for_each_child() on a kfree()'d
- 	 * device.
- 	 */
- 
--	if (read_bus_info_block(device, device->generation) < 0) {
-+	err = read_bus_info_block(device, device->generation, rom_img);
-+	if (err) {
- 		if (device->config_rom_retries < MAX_RETRIES &&
- 		    atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
- 			device->config_rom_retries++;
- 			schedule_delayed_work(&device->work, RETRY_DELAY);
- 		} else {
--			fw_notify("giving up on config rom for node id %x\n",
--				  device->node_id);
-+			fw_notify("giving up on config ROM for node id %x "
-+				  "(returned %d)\n", device->node_id, err);
-+			dump_config_rom(rom_img);
- 			if (device->node == device->card->root_node)
- 				schedule_delayed_work(&device->card->work, 0);
- 			fw_device_release(&device->device);
- 		}
--		return;
-+		goto out;
- 	}
- 
- 	err = -ENOMEM;
-@@ -786,7 +815,7 @@ static void fw_device_init(struct work_s
- 	if (device->node == device->card->root_node)
- 		schedule_delayed_work(&device->card->work, 0);
- 
--	return;
-+	goto out;
- 
-  error_with_cdev:
- 	down_write(&fw_device_rwsem);
-@@ -796,6 +825,8 @@ static void fw_device_init(struct work_s
- 	fw_device_put(device);		/* fw_device_idr's reference */
- 
- 	put_device(&device->device);	/* our reference */
-+ out:
-+	kfree(rom_img);
- }
- 
- static int update_unit(struct device *dev, void *data)
-@@ -854,6 +885,7 @@ static void fw_device_refresh(struct wor
- 		container_of(work, struct fw_device, work.work);
- 	struct fw_card *card = device->card;
- 	int node_id = device->node_id;
-+	struct config_rom_image *rom_img = NULL;
- 
- 	switch (reread_bus_info_block(device, device->generation)) {
- 	case REREAD_BIB_ERROR:
-@@ -890,13 +922,15 @@ static void fw_device_refresh(struct wor
- 	 */
- 	device_for_each_child(&device->device, NULL, shutdown_unit);
- 
--	if (read_bus_info_block(device, device->generation) < 0) {
-+	rom_img = kzalloc(sizeof(*rom_img), GFP_KERNEL);
-+
-+	if (read_bus_info_block(device, device->generation, rom_img) != 0) {
- 		if (device->config_rom_retries < MAX_RETRIES &&
- 		    atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
- 			device->config_rom_retries++;
- 			schedule_delayed_work(&device->work, RETRY_DELAY);
- 
--			return;
-+			goto out;
- 		}
- 		goto give_up;
- 	}
-@@ -910,16 +944,18 @@ static void fw_device_refresh(struct wor
- 
- 	fw_notify("refreshed device %s\n", device->device.bus_id);
- 	device->config_rom_retries = 0;
--	goto out;
-+	goto out_bm;
- 
-  give_up:
- 	fw_notify("giving up on refresh of device %s\n", device->device.bus_id);
-  gone:
- 	atomic_set(&device->state, FW_DEVICE_SHUTDOWN);
- 	fw_device_shutdown(work);
-- out:
-+ out_bm:
- 	if (node_id == card->root_node->node_id)
- 		schedule_delayed_work(&card->work, 0);
-+ out:
-+	kfree(rom_img);
- }
- 
- void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
-Index: linux/drivers/firewire/fw-device.h
-===================================================================
---- linux.orig/drivers/firewire/fw-device.h
-+++ linux/drivers/firewire/fw-device.h
-@@ -142,6 +142,7 @@ static inline void fw_unit_put(struct fw
- #define CSR_DEPENDENT_INFO	0x14
- #define CSR_MODEL		0x17
- #define CSR_INSTANCE		0x18
-+#define CSR_EXTENDED_ROM	0x1b
- #define CSR_DIRECTORY_ID	0x20
- 
- struct fw_csr_iterator {
-
--- 
-Stefan Richter
--=====-==--- --== -=---
-http://arcgraph.de/sr/
-
-
-
-Date: Thu, 20 Mar 2008 22:04:36 +0100 (CET)
+Date: Sat, 12 Apr 2008 22:31:25 +0200 (CEST)
 From: Stefan Richter <stefanr at s5r6.in-berlin.de>
-Subject: [PATCH] firewire: debug interrupt events
+Subject: [PATCH update] firewire: fw-ohci: work around generation bug in TI
+	controllers (fix AV/C and more)
 To: linux1394-devel at lists.sourceforge.net
-cc: linux-kernel at vger.kernel.org,
- Jarod Wilson <jwilson at redhat.com>
+Cc: linux-kernel at vger.kernel.org
 
-This adds debug printks for asynchronous transmission and reception and
-for self ID reception.  They can be enabled at module load time, and at
-runtime via /sys/module/firewire_ohci/parameters/debug.
+Unlike the ohci1394 driver, fw-ohci uses the selfIDGeneration field of
+bus reset packets to determine the generation of incoming requests as
+per OHCI 1.1 clause 8.4.2.3.  This is more precise --- provided that the
+controller inserts the correct generation.  Texas Instruments chips
+often don't.
+
+This prevented the transmission of response packets, which for example
+broke AV/C transactions as used when communicating with miniDV cameras
+and any other AV/C devices.
+
+There is apparently no way to detect and adjust incorrect generations.
+Therefore we ignore the generation of bus reset packets from TI chips
+and use the generation of the self ID buffer instead.  Alas this is
+received at a slightly wrong time.  In rare cases, this could cause us
+to not respond to legitimate requests or to respond to expired requests.
+(The latter is less likely because the bus reset packet AR event is
+typically handled before the self ID complete event.)
+
+Bug reported by Mladen Kuntner, who was extraordinarily patient while
+dealing with the driver maintainers.
+https://bugzilla.redhat.com/show_bug.cgi?id=243081
 
+Signed-off-by: Stefan Richter <stefanr at s5r6.in-berlin.de>
 Signed-off-by: Jarod Wilson <jwilson at redhat.com>
+---
 
-Also added:  Logging of interrupt event codes and of cancelled AT
-packets.
-
-The code now depends on a Kconfig variable.  This makes it easier to
-build firewire-ohci without the feature or to make it an option in the
-future.  The variable is currently hidden and always on.
-
-This feature inflates firewire-ohci.ko by 7 kB = 27% on x86-64 and by
-4 kB = 23% on i686.
+update: use a quirk flag for simpler code
 
-Signed-off-by: Stefan Richter <stefanr at s5r6.in-berlin.de>
----
- drivers/firewire/Kconfig   |    5 +
- drivers/firewire/fw-ohci.c |  182 +++++++++++++++++++++++++++++++++++++
- 2 files changed, 187 insertions(+)
+ drivers/firewire/fw-ohci.c |   21 ++++++++++++++++-----
+ 1 file changed, 16 insertions(+), 5 deletions(-)
 
-Index: linux/drivers/firewire/Kconfig
-===================================================================
---- linux.orig/drivers/firewire/Kconfig
-+++ linux/drivers/firewire/Kconfig
-@@ -54,6 +54,11 @@ config FIREWIRE_OHCI
- 	  directive, use "install modulename /bin/true" for the modules to be
- 	  blacklisted.
- 
-+config FIREWIRE_OHCI_DEBUG
-+	bool
-+	depends on FIREWIRE_OHCI
-+	default y
-+
- config FIREWIRE_SBP2
- 	tristate "Support for storage devices (SBP-2 protocol driver)"
- 	depends on FIREWIRE && SCSI
 Index: linux/drivers/firewire/fw-ohci.c
 ===================================================================
 --- linux.orig/drivers/firewire/fw-ohci.c
 +++ linux/drivers/firewire/fw-ohci.c
-@@ -27,6 +27,7 @@
- #include <linux/kernel.h>
- #include <linux/mm.h>
- #include <linux/module.h>
-+#include <linux/moduleparam.h>
- #include <linux/pci.h>
- #include <linux/spinlock.h>
+@@ -181,6 +181,7 @@ struct fw_ohci {
+ 	int request_generation;	/* for timestamping incoming requests */
+ 	u32 bus_seconds;
+ 	bool old_uninorth;
++	bool bus_reset_packet_quirk;
  
-@@ -237,6 +238,179 @@ static inline struct fw_ohci *fw_ohci(st
- 
- static char ohci_driver_name[] = KBUILD_MODNAME;
- 
-+#ifdef CONFIG_FIREWIRE_OHCI_DEBUG
-+
-+#define OHCI_PARAM_DEBUG_IRQS		1
-+#define OHCI_PARAM_DEBUG_SELFIDS	2
-+#define OHCI_PARAM_DEBUG_AT_AR		4
-+
-+static int param_debug;
-+module_param_named(debug, param_debug, int, 0644);
-+MODULE_PARM_DESC(debug, "Verbose logging (default = 0"
-+	", IRQs = "		__stringify(OHCI_PARAM_DEBUG_IRQS)
-+	", self-IDs = "		__stringify(OHCI_PARAM_DEBUG_SELFIDS)
-+	", AT/AR events = "	__stringify(OHCI_PARAM_DEBUG_AT_AR)
-+	", or a combination, or all = -1)");
-+
-+static void log_irqs(u32 evt)
-+{
-+	if (likely(!(param_debug & OHCI_PARAM_DEBUG_IRQS)))
-+		return;
-+
-+	printk(KERN_DEBUG KBUILD_MODNAME ": IRQ %08x%s%s%s%s%s%s%s%s%s%s%s\n",
-+	       evt,
-+	       evt & OHCI1394_selfIDComplete	? " selfID"		: "",
-+	       evt & OHCI1394_RQPkt		? " AR_req"		: "",
-+	       evt & OHCI1394_RSPkt		? " AR_resp"		: "",
-+	       evt & OHCI1394_reqTxComplete	? " AT_req"		: "",
-+	       evt & OHCI1394_respTxComplete	? " AT_resp"		: "",
-+	       evt & OHCI1394_isochRx		? " IR"			: "",
-+	       evt & OHCI1394_isochTx		? " IT"			: "",
-+	       evt & OHCI1394_postedWriteErr	? " postedWriteErr"	: "",
-+	       evt & OHCI1394_cycleTooLong	? " cycleTooLong"	: "",
-+	       evt & OHCI1394_cycle64Seconds	? " cycle64Seconds"	: "",
-+	       evt & ~(OHCI1394_selfIDComplete | OHCI1394_RQPkt |
-+		       OHCI1394_RSPkt | OHCI1394_reqTxComplete |
-+		       OHCI1394_respTxComplete | OHCI1394_isochRx |
-+		       OHCI1394_isochTx | OHCI1394_postedWriteErr |
-+		       OHCI1394_cycleTooLong | OHCI1394_cycle64Seconds)
-+						? " ?"			: "");
-+}
-+
-+static const char *speed[] = {
-+	[0] = "S100", [1] = "S200", [2] = "S400",    [3] = "beta",
-+};
-+static const char *power[] = {
-+	[0] = "+0W",  [1] = "+15W", [2] = "+30W",    [3] = "+45W",
-+	[4] = "-3W",  [5] = " ?W",  [6] = "-3..-6W", [7] = "-3..-10W",
-+};
-+static const char port[] = { '.', '-', 'p', 'c', };
-+
-+static char _p(u32 *s, int shift)
-+{
-+	return port[*s >> shift & 3];
-+}
-+
-+static void log_selfids(int generation, int self_id_count, u32 *s)
-+{
-+	if (likely(!(param_debug & OHCI_PARAM_DEBUG_SELFIDS)))
-+		return;
-+
-+	printk(KERN_DEBUG KBUILD_MODNAME ": %d selfIDs, generation %d\n",
-+	       self_id_count, generation);
-+
-+	for (; self_id_count--; ++s)
-+		if ((*s & 1 << 23) == 0)
-+			printk(KERN_DEBUG "selfID 0: %08x, phy %d [%c%c%c] "
-+			       "%s gc=%d %s %s%s%s\n",
-+			       *s, *s >> 24 & 63, _p(s, 6), _p(s, 4), _p(s, 2),
-+			       speed[*s >> 14 & 3], *s >> 16 & 63,
-+			       power[*s >> 8 & 7], *s >> 22 & 1 ? "L" : "",
-+			       *s >> 11 & 1 ? "c" : "", *s & 2 ? "i" : "");
-+		else
-+			printk(KERN_DEBUG "selfID n: %08x, phy %d "
-+			       "[%c%c%c%c%c%c%c%c]\n",
-+			       *s, *s >> 24 & 63,
-+			       _p(s, 16), _p(s, 14), _p(s, 12), _p(s, 10),
-+			       _p(s,  8), _p(s,  6), _p(s,  4), _p(s,  2));
-+}
-+
-+static const char *evts[] = {
-+	[0x00] = "evt_no_status",	[0x01] = "-reserved-",
-+	[0x02] = "evt_long_packet",	[0x03] = "evt_missing_ack",
-+	[0x04] = "evt_underrun",	[0x05] = "evt_overrun",
-+	[0x06] = "evt_descriptor_read",	[0x07] = "evt_data_read",
-+	[0x08] = "evt_data_write",	[0x09] = "evt_bus_reset",
-+	[0x0a] = "evt_timeout",		[0x0b] = "evt_tcode_err",
-+	[0x0c] = "-reserved-",		[0x0d] = "-reserved-",
-+	[0x0e] = "evt_unknown",		[0x0f] = "evt_flushed",
-+	[0x10] = "-reserved-",		[0x11] = "ack_complete",
-+	[0x12] = "ack_pending ",	[0x13] = "-reserved-",
-+	[0x14] = "ack_busy_X",		[0x15] = "ack_busy_A",
-+	[0x16] = "ack_busy_B",		[0x17] = "-reserved-",
-+	[0x18] = "-reserved-",		[0x19] = "-reserved-",
-+	[0x1a] = "-reserved-",		[0x1b] = "ack_tardy",
-+	[0x1c] = "-reserved-",		[0x1d] = "ack_data_error",
-+	[0x1e] = "ack_type_error",	[0x1f] = "-reserved-",
-+	[0x20] = "pending/cancelled",
-+};
-+static const char *tcodes[] = {
-+	[0x0] = "QW req",		[0x1] = "BW req",
-+	[0x2] = "W resp",		[0x3] = "-reserved-",
-+	[0x4] = "QR req",		[0x5] = "BR req",
-+	[0x6] = "QR resp",		[0x7] = "BR resp",
-+	[0x8] = "cycle start",		[0x9] = "Lk req",
-+	[0xa] = "async stream packet",	[0xb] = "Lk resp",
-+	[0xc] = "-reserved-",		[0xd] = "-reserved-",
-+	[0xe] = "link internal",	[0xf] = "-reserved-",
-+};
-+static const char *phys[] = {
-+	[0x0] = "phy config packet",	[0x1] = "link-on packet",
-+	[0x2] = "self-id packet",	[0x3] = "-reserved-",
-+};
-+
-+static void log_ar_at_event(char dir, int speed, u32 *header, int evt)
-+{
-+	int tcode = header[0] >> 4 & 0xf;
-+	char specific[12];
-+
-+	if (likely(!(param_debug & OHCI_PARAM_DEBUG_AT_AR)))
-+		return;
-+
-+	if (unlikely(evt >= ARRAY_SIZE(evts)))
-+			evt = 0x1f;
-+
-+	if (header[0] == ~header[1]) {
-+		printk(KERN_DEBUG "A%c %s, %s, %08x\n",
-+		       dir, evts[evt], phys[header[0] >> 30 & 0x3],
-+		       header[0]);
-+		return;
-+	}
-+
-+	switch (tcode) {
-+	case 0x0: case 0x6: case 0x8:
-+		snprintf(specific, sizeof(specific), " = %08x",
-+			 be32_to_cpu((__force __be32)header[3]));
-+		break;
-+	case 0x1: case 0x5: case 0x7: case 0x9: case 0xb:
-+		snprintf(specific, sizeof(specific), " %x,%x",
-+			 header[3] >> 16, header[3] & 0xffff);
-+		break;
-+	default:
-+		specific[0] = '\0';
-+	}
-+
-+	switch (tcode) {
-+	case 0xe: case 0xa:
-+		printk(KERN_DEBUG "A%c %s, %s\n",
-+		       dir, evts[evt], tcodes[tcode]);
-+		break;
-+	case 0x0: case 0x1: case 0x4: case 0x5: case 0x9:
-+		printk(KERN_DEBUG "A%c spd %x tl %02x, "
-+		       "%04x -> %04x, %s, "
-+		       "%s, %04x%08x%s\n",
-+		       dir, speed, header[0] >> 10 & 0x3f,
-+		       header[1] >> 16, header[0] >> 16, evts[evt],
-+		       tcodes[tcode], header[1] & 0xffff, header[2], specific);
-+		break;
-+	default:
-+		printk(KERN_DEBUG "A%c spd %x tl %02x, "
-+		       "%04x -> %04x, %s, "
-+		       "%s%s\n",
-+		       dir, speed, header[0] >> 10 & 0x3f,
-+		       header[1] >> 16, header[0] >> 16, evts[evt],
-+		       tcodes[tcode], specific);
-+	}
-+}
-+
-+#else
-+
-+#define log_irqs(evt)
-+#define log_selfids(generation, self_id_count, sid)
-+#define log_ar_at_event(dir, speed, header, evt)
-+
-+#endif /* CONFIG_FIREWIRE_OHCI_DEBUG */
-+
- static inline void reg_write(const struct fw_ohci *ohci, int offset, u32 data)
- {
- 	writel(data, ohci->registers + offset);
-@@ -368,6 +542,8 @@ static __le32 *handle_ar_packet(struct a
- 	p.timestamp  = status & 0xffff;
- 	p.generation = ohci->request_generation;
- 
-+	log_ar_at_event('R', p.speed, p.header, status >> 16 & 0x1f);
-+
  	/*
- 	 * The OHCI bus reset handler synthesizes a phy packet with
- 	 * the new generation number when a bus reset happens (see
-@@ -816,6 +992,8 @@ static int handle_at_packet(struct conte
- 	evt = le16_to_cpu(last->transfer_status) & 0x1f;
- 	packet->timestamp = le16_to_cpu(last->res_count);
- 
-+	log_ar_at_event('T', packet->speed, packet->header, evt);
-+
- 	switch (evt) {
- 	case OHCI1394_evt_timeout:
- 		/* Async response transmit timed out. */
-@@ -1117,6 +1295,8 @@ static void bus_reset_tasklet(unsigned l
- 		dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE,
- 				  free_rom, free_rom_bus);
- 
-+	log_selfids(generation, self_id_count, ohci->self_id_buffer);
-+
- 	fw_core_handle_bus_reset(&ohci->card, ohci->node_id, generation,
- 				 self_id_count, ohci->self_id_buffer);
- }
-@@ -1133,6 +1313,7 @@ static irqreturn_t irq_handler(int irq, 
- 		return IRQ_NONE;
- 
- 	reg_write(ohci, OHCI1394_IntEventClear, event);
-+	log_irqs(event);
- 
- 	if (event & OHCI1394_selfIDComplete)
- 		tasklet_schedule(&ohci->bus_reset_tasklet);
-@@ -1435,6 +1616,7 @@ static int ohci_cancel_packet(struct fw_
- 	if (packet->ack != 0)
- 		goto out;
- 
-+	log_ar_at_event('T', packet->speed, packet->header, 0x20);
- 	driver_data->packet = NULL;
- 	packet->ack = RCODE_CANCELLED;
- 	packet->callback(packet, &ohci->card, packet->ack);
-
--- 
-Stefan Richter
--=====-==--- --== =-=--
-http://arcgraph.de/sr/
-
-
-Date: Thu, 20 Mar 2008 23:48:23 +0100 (CET)
-From: Stefan Richter <stefanr at s5r6.in-berlin.de>
-Subject: [PATCH] firewire: wait until PHY configuration packet was transmitted
-To: linux1394-devel at lists.sourceforge.net
-cc: linux-kernel at vger.kernel.org,
- Jarod Wilson <jwilson at redhat.com>
-
-We now exit fw_send_phy_config /after/ the PHY config packet has been
-transmitted, instead of before.  A subsequent fw_core_initiate_bus_reset
-will therefore not overlap with the transmission.  This is meant to make
-the send PHY config packet + reset bus routine more deterministic.
-
-Signed-off-by: Stefan Richter <stefanr at s5r6.in-berlin.de>
-Signed-off-by: Jarod Wilson <jwilson at redhat.com>
----
- drivers/firewire/fw-transaction.c |   49 ++++++++++++++----------------
- 1 file changed, 24 insertions(+), 25 deletions(-)
-
-Index: linux/drivers/firewire/fw-transaction.c
-===================================================================
---- linux.orig/drivers/firewire/fw-transaction.c
-+++ linux/drivers/firewire/fw-transaction.c
-@@ -18,6 +18,7 @@
-  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-  */
- 
-+#include <linux/completion.h>
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <linux/init.h>
-@@ -294,42 +295,40 @@ fw_send_request(struct fw_card *card, st
- }
- EXPORT_SYMBOL(fw_send_request);
- 
-+struct fw_phy_packet {
-+	struct fw_packet packet;
-+	struct completion done;
-+};
-+
- static void
- transmit_phy_packet_callback(struct fw_packet *packet,
- 			     struct fw_card *card, int status)
- {
--	kfree(packet);
--}
+ 	 * Spinlock for accessing fw_ohci data.  Never call out of
+@@ -571,14 +572,19 @@ static __le32 *handle_ar_packet(struct a
+ 	 * generation.  We only need this for requests; for responses
+ 	 * we use the unique tlabel for finding the matching
+ 	 * request.
++	 *
++	 * Alas some chips sometimes emit bus reset packets with a
++	 * wrong generation.  We set the correct generation for these
++	 * at a slightly incorrect time (in bus_reset_tasklet).
+ 	 */
 -
--static void send_phy_packet(struct fw_card *card, u32 data, int generation)
--{
--	struct fw_packet *packet;
-+	struct fw_phy_packet *p =
-+			container_of(packet, struct fw_phy_packet, packet);
+-	if (evt == OHCI1394_evt_bus_reset)
+-		ohci->request_generation = (p.header[2] >> 16) & 0xff;
+-	else if (ctx == &ohci->ar_request_ctx)
++	if (evt == OHCI1394_evt_bus_reset) {
++		if (!ohci->bus_reset_packet_quirk)
++			ohci->request_generation = (p.header[2] >> 16) & 0xff;
++	} else if (ctx == &ohci->ar_request_ctx) {
+ 		fw_core_handle_request(&ohci->card, &p);
+-	else
++	} else {
+ 		fw_core_handle_response(&ohci->card, &p);
++	}
  
--	packet = kzalloc(sizeof(*packet), GFP_ATOMIC);
--	if (packet == NULL)
--		return;
--
--	packet->header[0] = data;
--	packet->header[1] = ~data;
--	packet->header_length = 8;
--	packet->payload_length = 0;
--	packet->speed = SCODE_100;
--	packet->generation = generation;
--	packet->callback = transmit_phy_packet_callback;
--
--	card->driver->send_request(card, packet);
-+	complete(&p->done);
+ 	return buffer + length + 1;
  }
+@@ -1285,6 +1291,9 @@ static void bus_reset_tasklet(unsigned l
+ 	context_stop(&ohci->at_response_ctx);
+ 	reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset);
  
- void fw_send_phy_config(struct fw_card *card,
- 			int node_id, int generation, int gap_count)
- {
--	u32 q;
--
--	q = PHY_IDENTIFIER(PHY_PACKET_CONFIG) |
--		PHY_CONFIG_ROOT_ID(node_id) |
--		PHY_CONFIG_GAP_COUNT(gap_count);
-+	struct fw_phy_packet p;
-+	u32 data = PHY_IDENTIFIER(PHY_PACKET_CONFIG) |
-+		   PHY_CONFIG_ROOT_ID(node_id) |
-+		   PHY_CONFIG_GAP_COUNT(gap_count);
++	if (ohci->bus_reset_packet_quirk)
++		ohci->request_generation = generation;
 +
-+	p.packet.header[0] = data;
-+	p.packet.header[1] = ~data;
-+	p.packet.header_length = 8;
-+	p.packet.payload_length = 0;
-+	p.packet.speed = SCODE_100;
-+	p.packet.generation = generation;
-+	p.packet.callback = transmit_phy_packet_callback;
-+	init_completion(&p.done);
- 
--	send_phy_packet(card, q, generation);
-+	card->driver->send_request(card, &p.packet);
-+	wait_for_completion(&p.done);
- }
+ 	/*
+ 	 * This next bit is unrelated to the AT context stuff but we
+ 	 * have to do it under the spinlock also.  If a new config rom
+@@ -2360,6 +2369,8 @@ pci_probe(struct pci_dev *dev, const str
+ 	ohci->old_uninorth = dev->vendor == PCI_VENDOR_ID_APPLE &&
+ 			     dev->device == PCI_DEVICE_ID_APPLE_UNI_N_FW;
+ #endif
++	ohci->bus_reset_packet_quirk = dev->vendor == PCI_VENDOR_ID_TI;
++
+ 	spin_lock_init(&ohci->lock);
  
- void fw_flush_transactions(struct fw_card *card)
+ 	tasklet_init(&ohci->bus_reset_tasklet,
 
 -- 
 Stefan Richter
--=====-==--- --== =-=--
+-=====-==--- -=-- -==--
 http://arcgraph.de/sr/
 
 
-There's a minor memory leak in firewire-ohci's ar_context_tasklet(), in that
-we're not freeing up some of the memory we use for each ar_buffer, due to a
-moving pointer. The problem has been there for a while, but didn't start
-to be noticed until we were doing a coherent allocation for the ar_buffer --
-meaning we have a smaller pool of memory to work with now, so the problem
-crops up sooner. The manifestation of this comes after doing a bunch of I/O to
-a firewire disk, which eventually stalls, and this starts spewing to the
-console:
-
-PCI-DMA: Out of IOMMU space for 53248 bytes at device 0000:04:09.0
-
-The device there is one of my FireWire controllers trying to do I/O. The host
-is a fairly new rev. opteron.
-
-Just need to make sure we're freeing the correct memory range is pass through
-ar_context_tasklet to fix it. Probably something we ought to sneak into 2.6.25
-if its still doable...
-
-Signed-off-by: Jarod Wilson <jwilson at redhat.com>
----
-
- drivers/firewire/fw-ohci.c |    9 +++++----
- 1 files changed, 5 insertions(+), 4 deletions(-)
-
-diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
-index 8ff9059..e1d50f7 100644
---- a/drivers/firewire/fw-ohci.c
-+++ b/drivers/firewire/fw-ohci.c
-@@ -579,7 +579,8 @@ static void ar_context_tasklet(unsigned long data)
- 
- 	if (d->res_count == 0) {
- 		size_t size, rest, offset;
--		dma_addr_t buffer_bus;
-+		dma_addr_t start_bus;
-+		void *start;
- 
- 		/*
- 		 * This descriptor is finished and we may have a
-@@ -588,9 +589,9 @@ static void ar_context_tasklet(unsigned long data)
- 		 */
- 
- 		offset = offsetof(struct ar_buffer, data);
--		buffer_bus = le32_to_cpu(ab->descriptor.data_address) - offset;
-+		start = buffer = ab;
-+		start_bus = le32_to_cpu(ab->descriptor.data_address) - offset;
- 
--		buffer = ab;
- 		ab = ab->next;
- 		d = &ab->descriptor;
- 		size = buffer + PAGE_SIZE - ctx->pointer;
-@@ -605,7 +606,7 @@ static void ar_context_tasklet(unsigned long data)
- 			buffer = handle_ar_packet(ctx, buffer);
- 
- 		dma_free_coherent(ohci->card.device, PAGE_SIZE,
--				  buffer, buffer_bus);
-+				  start, start_bus);
- 		ar_context_add_page(ctx);
- 	} else {
- 		buffer = ctx->pointer;

linux-2.6-firewire-git-update.patch:

Index: linux-2.6-firewire-git-update.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/linux-2.6-firewire-git-update.patch,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- linux-2.6-firewire-git-update.patch	1 Apr 2008 10:38:06 -0000	1.3
+++ linux-2.6-firewire-git-update.patch	14 Apr 2008 16:06:53 -0000	1.4
@@ -1,58 +1,85 @@
-git diff in linux1394-2.6.git vs. v2.6.25-rc6, March 17, 2008.
+git diff in linux1394-2.6.git vs. v2.6.25-rc9, April 12, 2008
 
- Documentation/debugging-via-ohci1394.txt |   13 +-
- drivers/firewire/fw-card.c               |   40 +-----
- drivers/firewire/fw-cdev.c               |   13 +-
- drivers/firewire/fw-device.c             |  263 ++++++++++++++++++++++++------
- drivers/firewire/fw-device.h             |   38 +++-
- drivers/firewire/fw-ohci.c               |  114 +++++++-------
- drivers/firewire/fw-sbp2.c               |  150 ++++++++---------
- drivers/firewire/fw-topology.c           |    3 +
- drivers/firewire/fw-topology.h           |   11 +-
- drivers/firewire/fw-transaction.c        |   11 +-
- drivers/firewire/fw-transaction.h        |    6 -
- drivers/ieee1394/csr.c                   |    6 +-
- drivers/ieee1394/dv1394.c                |    3 +-
- drivers/ieee1394/highlevel.c             |    6 +-
- drivers/ieee1394/ieee1394_core.c         |    2 +-
- drivers/ieee1394/nodemgr.c               |    6 +-
- drivers/ieee1394/ohci1394.c              |  111 ++++++-------
- drivers/ieee1394/pcilynx.c               |   12 +-
- drivers/ieee1394/raw1394.c               |    1 -
- drivers/ieee1394/sbp2.c                  |   11 +-
- drivers/ieee1394/video1394.c             |    3 +-
- lib/Kconfig.debug                        |   10 +
- 22 files changed, 487 insertions(+), 346 deletions(-)
+ drivers/firewire/Kconfig          |    5 +
+ drivers/firewire/fw-card.c        |   52 +-----
+ drivers/firewire/fw-cdev.c        |   13 +-
+ drivers/firewire/fw-device.c      |  263 +++++++++++++++++++++-----
+ drivers/firewire/fw-device.h      |   38 +++-
+ drivers/firewire/fw-iso.c         |    5 -
+ drivers/firewire/fw-ohci.c        |  383 ++++++++++++++++++++++++++++++-------
+ drivers/firewire/fw-ohci.h        |    2 +
+ drivers/firewire/fw-sbp2.c        |  150 +++++++--------
+ drivers/firewire/fw-topology.c    |   22 ++-
+ drivers/firewire/fw-topology.h    |   11 +-
+ drivers/firewire/fw-transaction.c |   75 ++++----
+ drivers/firewire/fw-transaction.h |   17 +-
+ drivers/ieee1394/csr.c            |    6 +-
+ drivers/ieee1394/dv1394.c         |    4 +-
+ drivers/ieee1394/highlevel.c      |    6 +-
+ drivers/ieee1394/ieee1394_core.c  |    2 +-
+ drivers/ieee1394/nodemgr.c        |    6 +-
+ drivers/ieee1394/ohci1394.c       |  229 +++++++++++-----------
+ drivers/ieee1394/pcilynx.c        |   15 +-
+ drivers/ieee1394/raw1394.c        |    2 -
+ drivers/ieee1394/sbp2.c           |   11 +-
+ drivers/ieee1394/video1394.c      |    4 +-
+ 23 files changed, 859 insertions(+), 462 deletions(-)
 
-diff --git a/Documentation/debugging-via-ohci1394.txt b/Documentation/debugging-via-ohci1394.txt
-index c360d4e..371ba27 100644
---- a/Documentation/debugging-via-ohci1394.txt
-+++ b/Documentation/debugging-via-ohci1394.txt
-@@ -41,11 +41,14 @@ to a working state and enables physical DMA by default for all remote nodes.
- This can be turned off by ohci1394's module parameter phys_dma=0.
- 
- The alternative firewire-ohci driver in drivers/firewire uses filtered physical
--DMA, hence is not yet suitable for remote debugging.
--
--Because ohci1394 depends on the PCI enumeration to be completed, an
--initialization routine which runs pretty early (long before console_init()
--which makes the printk buffer appear on the console can be called) was written.
-+DMA by default, which is more secure but not suitable for remote debugging.
-+Compile the driver with CONFIG_FIREWIRE_OHCI_REMOTE_DMA to get unfiltered
-+physical DMA.
-+
-+Because ohci1394 and firewire-ohci depend on the PCI enumeration to be
-+completed, an initialization routine which runs pretty early has been
-+implemented for x86.  This routine runs long before console_init() can be
-+called, i.e. before the printk buffer appears on the console.
+diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig
+index 25bdc2d..fb4d391 100644
+--- a/drivers/firewire/Kconfig
++++ b/drivers/firewire/Kconfig
+@@ -54,6 +54,11 @@ config FIREWIRE_OHCI
+ 	  directive, use "install modulename /bin/true" for the modules to be
+ 	  blacklisted.
  
- To activate it, enable CONFIG_PROVIDE_OHCI1394_DMA_INIT (Kernel hacking menu:
- Provide code for enabling DMA over FireWire early on boot) and pass the
++config FIREWIRE_OHCI_DEBUG
++	bool
++	depends on FIREWIRE_OHCI
++	default y
++
+ config FIREWIRE_SBP2
+ 	tristate "Support for storage devices (SBP-2 protocol driver)"
+ 	depends on FIREWIRE && SCSI
 diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
-index a034627..7e4012d 100644
+index a034627..102e809 100644
 --- a/drivers/firewire/fw-card.c
 +++ b/drivers/firewire/fw-card.c
-@@ -331,7 +331,7 @@ fw_card_bm_work(struct work_struct *work)
+@@ -167,7 +167,6 @@ fw_core_add_descriptor(struct fw_descriptor *desc)
+ 
+ 	return 0;
+ }
+-EXPORT_SYMBOL(fw_core_add_descriptor);
+ 
+ void
+ fw_core_remove_descriptor(struct fw_descriptor *desc)
+@@ -182,7 +181,6 @@ fw_core_remove_descriptor(struct fw_descriptor *desc)
+ 
+ 	mutex_unlock(&card_mutex);
+ }
+-EXPORT_SYMBOL(fw_core_remove_descriptor);
+ 
+ static const char gap_count_table[] = {
+ 	63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40
+@@ -220,7 +218,7 @@ fw_card_bm_work(struct work_struct *work)
+ 	struct bm_data bmd;
+ 	unsigned long flags;
+ 	int root_id, new_root_id, irm_id, gap_count, generation, grace;
+-	int do_reset = 0;
++	bool do_reset = false;
+ 
+ 	spin_lock_irqsave(&card->lock, flags);
+ 	local_node = card->local_node;
+@@ -240,7 +238,7 @@ fw_card_bm_work(struct work_struct *work)
+ 	root_id = root_node->node_id;
+ 	grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10));
+ 
+-	if (card->bm_generation + 1 == generation ||
++	if (is_next_generation(generation, card->bm_generation) ||
+ 	    (card->bm_generation != generation && grace)) {
+ 		/*
+ 		 * This first step is to figure out who is IRM and
+@@ -331,7 +329,7 @@ fw_card_bm_work(struct work_struct *work)
  		 */
  		spin_unlock_irqrestore(&card->lock, flags);
  		goto out;
@@ -61,7 +88,25 @@
  		/*
  		 * FIXME: I suppose we should set the cmstr bit in the
  		 * STATE_CLEAR register of this node, as described in
-@@ -398,7 +398,6 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver,
+@@ -360,14 +358,14 @@ fw_card_bm_work(struct work_struct *work)
+ 		gap_count = 63;
+ 
+ 	/*
+-	 * Finally, figure out if we should do a reset or not.  If we've
+-	 * done less that 5 resets with the same physical topology and we
++	 * Finally, figure out if we should do a reset or not.  If we have
++	 * done less than 5 resets with the same physical topology and we
+ 	 * have either a new root or a new gap count setting, let's do it.
+ 	 */
+ 
+ 	if (card->bm_retries++ < 5 &&
+ 	    (card->gap_count != gap_count || new_root_id != root_id))
+-		do_reset = 1;
++		do_reset = true;
+ 
+ 	spin_unlock_irqrestore(&card->lock, flags);
+ 
+@@ -398,7 +396,6 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver,
  {
  	static atomic_t index = ATOMIC_INIT(-1);
  
@@ -69,7 +114,7 @@
  	atomic_set(&card->device_count, 0);
  	card->index = atomic_inc_return(&index);
  	card->driver = driver;
-@@ -429,12 +428,6 @@ fw_card_add(struct fw_card *card,
+@@ -429,12 +426,6 @@ fw_card_add(struct fw_card *card,
  	card->link_speed = link_speed;
  	card->guid = guid;
  
@@ -82,7 +127,7 @@
  	mutex_lock(&card_mutex);
  	config_rom = generate_config_rom(card, &length);
  	list_add_tail(&card->link, &card_list);
-@@ -540,40 +533,9 @@ fw_core_remove_card(struct fw_card *card)
+@@ -540,40 +531,9 @@ fw_core_remove_card(struct fw_card *card)
  	cancel_delayed_work_sync(&card->work);
  	fw_flush_transactions(card);
  	del_timer_sync(&card->flush_timer);
@@ -160,7 +205,7 @@
  	if (get_info->bus_reset != 0) {
  		void __user *uptr = u64_to_uptr(get_info->bus_reset);
 diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
-index 870125a..f559c63 100644
+index 870125a..2d01bc1 100644
 --- a/drivers/firewire/fw-device.c
 +++ b/drivers/firewire/fw-device.c
 @@ -25,7 +25,7 @@
@@ -513,7 +558,7 @@
   error:
  	fw_device_put(device);		/* fw_device_idr's reference */
  
-@@ -771,6 +821,107 @@ static void fw_device_update(struct work_struct *work)
+@@ -771,6 +821,106 @@ static void fw_device_update(struct work_struct *work)
  	device_for_each_child(&device->device, NULL, update_unit);
  }
  
@@ -573,8 +618,7 @@
 +
 +		fw_device_update(work);
 +		device->config_rom_retries = 0;
-+
-+		return;
++		goto out;
 +
 +	case REREAD_BIB_CHANGED:
 +		break;
@@ -621,7 +665,7 @@
  void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
  {
  	struct fw_device *device;
-@@ -780,7 +931,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
+@@ -780,7 +930,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
  	case FW_NODE_LINK_ON:
  		if (!node->link_on)
  			break;
@@ -630,7 +674,7 @@
  		device = kzalloc(sizeof(*device), GFP_ATOMIC);
  		if (device == NULL)
  			break;
-@@ -819,6 +970,22 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
+@@ -819,6 +969,23 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
  		schedule_delayed_work(&device->work, INITIAL_DELAY);
  		break;
  
@@ -646,7 +690,8 @@
 +			    FW_DEVICE_RUNNING,
 +			    FW_DEVICE_INITIALIZING) == FW_DEVICE_RUNNING) {
 +			PREPARE_DELAYED_WORK(&device->work, fw_device_refresh);
-+			schedule_delayed_work(&device->work, INITIAL_DELAY);
++			schedule_delayed_work(&device->work,
++				node == card->local_node ? 0 : INITIAL_DELAY);
 +		}
 +		break;
 +
@@ -756,11 +801,58 @@
  #define CSR_OFFSET	0x40
  #define CSR_LEAF	0x80
  #define CSR_DIRECTORY	0xc0
+diff --git a/drivers/firewire/fw-iso.c b/drivers/firewire/fw-iso.c
+index 2b640e9..bcbe794 100644
+--- a/drivers/firewire/fw-iso.c
++++ b/drivers/firewire/fw-iso.c
+@@ -126,7 +126,6 @@ fw_iso_context_create(struct fw_card *card, int type,
+ 
+ 	return ctx;
+ }
+-EXPORT_SYMBOL(fw_iso_context_create);
+ 
+ void fw_iso_context_destroy(struct fw_iso_context *ctx)
+ {
+@@ -134,14 +133,12 @@ void fw_iso_context_destroy(struct fw_iso_context *ctx)
+ 
+ 	card->driver->free_iso_context(ctx);
+ }
+-EXPORT_SYMBOL(fw_iso_context_destroy);
+ 
+ int
+ fw_iso_context_start(struct fw_iso_context *ctx, int cycle, int sync, int tags)
+ {
+ 	return ctx->card->driver->start_iso(ctx, cycle, sync, tags);
+ }
+-EXPORT_SYMBOL(fw_iso_context_start);
+ 
+ int
+ fw_iso_context_queue(struct fw_iso_context *ctx,
+@@ -153,11 +150,9 @@ fw_iso_context_queue(struct fw_iso_context *ctx,
+ 
+ 	return card->driver->queue_iso(ctx, packet, buffer, payload);
+ }
+-EXPORT_SYMBOL(fw_iso_context_queue);
+ 
+ int
+ fw_iso_context_stop(struct fw_iso_context *ctx)
+ {
+ 	return ctx->card->driver->stop_iso(ctx);
+ }
+-EXPORT_SYMBOL(fw_iso_context_stop);
 diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
-index 996d61f..0f02b8d 100644
+index ca6d51e..67a8797 100644
 --- a/drivers/firewire/fw-ohci.c
 +++ b/drivers/firewire/fw-ohci.c
-@@ -177,7 +177,7 @@ struct fw_ohci {
+@@ -27,6 +27,7 @@
+ #include <linux/kernel.h>
+ #include <linux/mm.h>
+ #include <linux/module.h>
++#include <linux/moduleparam.h>
+ #include <linux/pci.h>
+ #include <linux/spinlock.h>
+ 
+@@ -177,7 +178,7 @@ struct fw_ohci {
  	struct tasklet_struct bus_reset_tasklet;
  	int node_id;
  	int generation;
@@ -769,7 +861,304 @@
  	u32 bus_seconds;
  	bool old_uninorth;
  
-@@ -1096,6 +1096,11 @@ static void bus_reset_tasklet(unsigned long data)
+@@ -237,6 +238,196 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card)
+ 
+ static char ohci_driver_name[] = KBUILD_MODNAME;
+ 
++#ifdef CONFIG_FIREWIRE_OHCI_DEBUG
++
++#define OHCI_PARAM_DEBUG_AT_AR		1
++#define OHCI_PARAM_DEBUG_SELFIDS	2
++#define OHCI_PARAM_DEBUG_IRQS		4
++#define OHCI_PARAM_DEBUG_BUSRESETS	8 /* only effective before chip init */
++
++static int param_debug;
++module_param_named(debug, param_debug, int, 0644);
++MODULE_PARM_DESC(debug, "Verbose logging (default = 0"
++	", AT/AR events = "	__stringify(OHCI_PARAM_DEBUG_AT_AR)
++	", self-IDs = "		__stringify(OHCI_PARAM_DEBUG_SELFIDS)
++	", IRQs = "		__stringify(OHCI_PARAM_DEBUG_IRQS)
++	", busReset events = "	__stringify(OHCI_PARAM_DEBUG_BUSRESETS)
++	", or a combination, or all = -1)");
++
++static void log_irqs(u32 evt)
++{
++	if (likely(!(param_debug &
++			(OHCI_PARAM_DEBUG_IRQS | OHCI_PARAM_DEBUG_BUSRESETS))))
++		return;
++
++	if (!(param_debug & OHCI_PARAM_DEBUG_IRQS) &&
++	    !(evt & OHCI1394_busReset))
++		return;
++
++	printk(KERN_DEBUG KBUILD_MODNAME ": IRQ "
++	       "%08x%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
++	       evt,
++	       evt & OHCI1394_selfIDComplete	? " selfID"		: "",
++	       evt & OHCI1394_RQPkt		? " AR_req"		: "",
++	       evt & OHCI1394_RSPkt		? " AR_resp"		: "",
++	       evt & OHCI1394_reqTxComplete	? " AT_req"		: "",
++	       evt & OHCI1394_respTxComplete	? " AT_resp"		: "",
++	       evt & OHCI1394_isochRx		? " IR"			: "",
++	       evt & OHCI1394_isochTx		? " IT"			: "",
++	       evt & OHCI1394_postedWriteErr	? " postedWriteErr"	: "",
++	       evt & OHCI1394_cycleTooLong	? " cycleTooLong"	: "",
++	       evt & OHCI1394_cycle64Seconds	? " cycle64Seconds"	: "",
++	       evt & OHCI1394_regAccessFail	? " regAccessFail"	: "",
++	       evt & OHCI1394_busReset		? " busReset"		: "",
++	       evt & ~(OHCI1394_selfIDComplete | OHCI1394_RQPkt |
++		       OHCI1394_RSPkt | OHCI1394_reqTxComplete |
++		       OHCI1394_respTxComplete | OHCI1394_isochRx |
++		       OHCI1394_isochTx | OHCI1394_postedWriteErr |
++		       OHCI1394_cycleTooLong | OHCI1394_cycle64Seconds |
++		       OHCI1394_regAccessFail | OHCI1394_busReset)
++						? " ?"			: "");
++}
++
++static const char *speed[] = {
++	[0] = "S100", [1] = "S200", [2] = "S400",    [3] = "beta",
++};
++static const char *power[] = {
++	[0] = "+0W",  [1] = "+15W", [2] = "+30W",    [3] = "+45W",
++	[4] = "-3W",  [5] = " ?W",  [6] = "-3..-6W", [7] = "-3..-10W",
++};
++static const char port[] = { '.', '-', 'p', 'c', };
++
++static char _p(u32 *s, int shift)
++{
++	return port[*s >> shift & 3];
++}
++
++static void log_selfids(int node_id, int generation, int self_id_count, u32 *s)
++{
++	if (likely(!(param_debug & OHCI_PARAM_DEBUG_SELFIDS)))
++		return;
++
++	printk(KERN_DEBUG KBUILD_MODNAME ": %d selfIDs, generation %d, "
++	       "local node ID %04x\n", self_id_count, generation, node_id);
++
++	for (; self_id_count--; ++s)
++		if ((*s & 1 << 23) == 0)
++			printk(KERN_DEBUG "selfID 0: %08x, phy %d [%c%c%c] "
++			       "%s gc=%d %s %s%s%s\n",
++			       *s, *s >> 24 & 63, _p(s, 6), _p(s, 4), _p(s, 2),
++			       speed[*s >> 14 & 3], *s >> 16 & 63,
++			       power[*s >> 8 & 7], *s >> 22 & 1 ? "L" : "",
++			       *s >> 11 & 1 ? "c" : "", *s & 2 ? "i" : "");
++		else
++			printk(KERN_DEBUG "selfID n: %08x, phy %d "
++			       "[%c%c%c%c%c%c%c%c]\n",
++			       *s, *s >> 24 & 63,
++			       _p(s, 16), _p(s, 14), _p(s, 12), _p(s, 10),
++			       _p(s,  8), _p(s,  6), _p(s,  4), _p(s,  2));
++}
++
++static const char *evts[] = {
++	[0x00] = "evt_no_status",	[0x01] = "-reserved-",
++	[0x02] = "evt_long_packet",	[0x03] = "evt_missing_ack",
++	[0x04] = "evt_underrun",	[0x05] = "evt_overrun",
++	[0x06] = "evt_descriptor_read",	[0x07] = "evt_data_read",
++	[0x08] = "evt_data_write",	[0x09] = "evt_bus_reset",
++	[0x0a] = "evt_timeout",		[0x0b] = "evt_tcode_err",
++	[0x0c] = "-reserved-",		[0x0d] = "-reserved-",
++	[0x0e] = "evt_unknown",		[0x0f] = "evt_flushed",
++	[0x10] = "-reserved-",		[0x11] = "ack_complete",
++	[0x12] = "ack_pending ",	[0x13] = "-reserved-",
++	[0x14] = "ack_busy_X",		[0x15] = "ack_busy_A",
++	[0x16] = "ack_busy_B",		[0x17] = "-reserved-",
++	[0x18] = "-reserved-",		[0x19] = "-reserved-",
++	[0x1a] = "-reserved-",		[0x1b] = "ack_tardy",
++	[0x1c] = "-reserved-",		[0x1d] = "ack_data_error",
++	[0x1e] = "ack_type_error",	[0x1f] = "-reserved-",
++	[0x20] = "pending/cancelled",
++};
++static const char *tcodes[] = {
++	[0x0] = "QW req",		[0x1] = "BW req",
++	[0x2] = "W resp",		[0x3] = "-reserved-",
++	[0x4] = "QR req",		[0x5] = "BR req",
++	[0x6] = "QR resp",		[0x7] = "BR resp",
++	[0x8] = "cycle start",		[0x9] = "Lk req",
++	[0xa] = "async stream packet",	[0xb] = "Lk resp",
++	[0xc] = "-reserved-",		[0xd] = "-reserved-",
++	[0xe] = "link internal",	[0xf] = "-reserved-",
++};
++static const char *phys[] = {
++	[0x0] = "phy config packet",	[0x1] = "link-on packet",
++	[0x2] = "self-id packet",	[0x3] = "-reserved-",
++};
++
++static void log_ar_at_event(char dir, int speed, u32 *header, int evt)
++{
++	int tcode = header[0] >> 4 & 0xf;
++	char specific[12];
++
++	if (likely(!(param_debug & OHCI_PARAM_DEBUG_AT_AR)))
++		return;
++
++	if (unlikely(evt >= ARRAY_SIZE(evts)))
++			evt = 0x1f;
++
++	if (evt == OHCI1394_evt_bus_reset) {
++		printk(KERN_DEBUG "A%c evt_bus_reset, generation %d\n",
++		       dir, (header[2] >> 16) & 0xff);
++		return;
++	}
++
++	if (header[0] == ~header[1]) {
++		printk(KERN_DEBUG "A%c %s, %s, %08x\n",
++		       dir, evts[evt], phys[header[0] >> 30 & 0x3],
++		       header[0]);
++		return;
++	}
++
++	switch (tcode) {
++	case 0x0: case 0x6: case 0x8:
++		snprintf(specific, sizeof(specific), " = %08x",
++			 be32_to_cpu((__force __be32)header[3]));
++		break;
++	case 0x1: case 0x5: case 0x7: case 0x9: case 0xb:
++		snprintf(specific, sizeof(specific), " %x,%x",
++			 header[3] >> 16, header[3] & 0xffff);
++		break;
++	default:
++		specific[0] = '\0';
++	}
++
++	switch (tcode) {
++	case 0xe: case 0xa:
++		printk(KERN_DEBUG "A%c %s, %s\n",
++		       dir, evts[evt], tcodes[tcode]);
++		break;
++	case 0x0: case 0x1: case 0x4: case 0x5: case 0x9:
++		printk(KERN_DEBUG "A%c spd %x tl %02x, "
++		       "%04x -> %04x, %s, "
++		       "%s, %04x%08x%s\n",
++		       dir, speed, header[0] >> 10 & 0x3f,
++		       header[1] >> 16, header[0] >> 16, evts[evt],
++		       tcodes[tcode], header[1] & 0xffff, header[2], specific);
++		break;
++	default:
++		printk(KERN_DEBUG "A%c spd %x tl %02x, "
++		       "%04x -> %04x, %s, "
++		       "%s%s\n",
++		       dir, speed, header[0] >> 10 & 0x3f,
++		       header[1] >> 16, header[0] >> 16, evts[evt],
++		       tcodes[tcode], specific);
++	}
++}
++
++#else
++
++#define log_irqs(evt)
++#define log_selfids(node_id, generation, self_id_count, sid)
++#define log_ar_at_event(dir, speed, header, evt)
++
++#endif /* CONFIG_FIREWIRE_OHCI_DEBUG */
++
+ static inline void reg_write(const struct fw_ohci *ohci, int offset, u32 data)
+ {
+ 	writel(data, ohci->registers + offset);
+@@ -320,6 +511,7 @@ static __le32 *handle_ar_packet(struct ar_context *ctx, __le32 *buffer)
+ 	struct fw_ohci *ohci = ctx->ohci;
+ 	struct fw_packet p;
+ 	u32 status, length, tcode;
++	int evt;
+ 
+ 	p.header[0] = cond_le32_to_cpu(buffer[0]);
+ 	p.header[1] = cond_le32_to_cpu(buffer[1]);
+@@ -362,12 +554,15 @@ static __le32 *handle_ar_packet(struct ar_context *ctx, __le32 *buffer)
+ 	/* FIXME: What to do about evt_* errors? */
+ 	length = (p.header_length + p.payload_length + 3) / 4;
+ 	status = cond_le32_to_cpu(buffer[length]);
++	evt    = (status >> 16) & 0x1f;
+ 
+-	p.ack        = ((status >> 16) & 0x1f) - 16;
++	p.ack        = evt - 16;
+ 	p.speed      = (status >> 21) & 0x7;
+ 	p.timestamp  = status & 0xffff;
+ 	p.generation = ohci->request_generation;
+ 
++	log_ar_at_event('R', p.speed, p.header, evt);
++
+ 	/*
+ 	 * The OHCI bus reset handler synthesizes a phy packet with
+ 	 * the new generation number when a bus reset happens (see
+@@ -378,7 +573,7 @@ static __le32 *handle_ar_packet(struct ar_context *ctx, __le32 *buffer)
+ 	 * request.
+ 	 */
+ 
+-	if (p.ack + 16 == 0x09)
++	if (evt == OHCI1394_evt_bus_reset)
+ 		ohci->request_generation = (p.header[2] >> 16) & 0xff;
+ 	else if (ctx == &ohci->ar_request_ctx)
+ 		fw_core_handle_request(&ohci->card, &p);
+@@ -770,8 +965,19 @@ at_context_queue_packet(struct context *ctx, struct fw_packet *packet)
+ 				     DESCRIPTOR_IRQ_ALWAYS |
+ 				     DESCRIPTOR_BRANCH_ALWAYS);
+ 
+-	/* FIXME: Document how the locking works. */
+-	if (ohci->generation != packet->generation) {
++	/*
++	 * If the controller and packet generations don't match, we need to
++	 * bail out and try again.  If IntEvent.busReset is set, the AT context
++	 * is halted, so appending to the context and trying to run it is
++	 * futile.  Most controllers do the right thing and just flush the AT
++	 * queue (per section 7.2.3.2 of the OHCI 1.1 specification), but
++	 * some controllers (like a JMicron JMB381 PCI-e) misbehave and wind
++	 * up stalling out.  So we just bail out in software and try again
++	 * later, and everyone is happy.
++	 * FIXME: Document how the locking works.
++	 */
++	if (ohci->generation != packet->generation ||
++	    reg_read(ohci, OHCI1394_IntEventSet) & OHCI1394_busReset) {
+ 		if (packet->payload_length > 0)
+ 			dma_unmap_single(ohci->card.device, payload_bus,
+ 					 packet->payload_length, DMA_TO_DEVICE);
+@@ -817,6 +1023,8 @@ static int handle_at_packet(struct context *context,
+ 	evt = le16_to_cpu(last->transfer_status) & 0x1f;
+ 	packet->timestamp = le16_to_cpu(last->res_count);
+ 
++	log_ar_at_event('T', packet->speed, packet->header, evt);
++
+ 	switch (evt) {
+ 	case OHCI1394_evt_timeout:
+ 		/* Async response transmit timed out. */
+@@ -1019,20 +1227,30 @@ static void bus_reset_tasklet(unsigned long data)
+ 	ohci->node_id = reg & (OHCI1394_NodeID_busNumber |
+ 			       OHCI1394_NodeID_nodeNumber);
+ 
++	reg = reg_read(ohci, OHCI1394_SelfIDCount);
++	if (reg & OHCI1394_SelfIDCount_selfIDError) {
++		fw_notify("inconsistent self IDs\n");
++		return;
++	}
+ 	/*
+ 	 * The count in the SelfIDCount register is the number of
+ 	 * bytes in the self ID receive buffer.  Since we also receive
+ 	 * the inverted quadlets and a header quadlet, we shift one
+ 	 * bit extra to get the actual number of self IDs.
+ 	 */
+-
+-	self_id_count = (reg_read(ohci, OHCI1394_SelfIDCount) >> 3) & 0x3ff;
++	self_id_count = (reg >> 3) & 0x3ff;
++	if (self_id_count == 0) {
++		fw_notify("inconsistent self IDs\n");
++		return;
++	}
+ 	generation = (cond_le32_to_cpu(ohci->self_id_cpu[0]) >> 16) & 0xff;
+ 	rmb();
+ 
+ 	for (i = 1, j = 0; j < self_id_count; i += 2, j++) {
+-		if (ohci->self_id_cpu[i] != ~ohci->self_id_cpu[i + 1])
+-			fw_error("inconsistent self IDs\n");
++		if (ohci->self_id_cpu[i] != ~ohci->self_id_cpu[i + 1]) {
++			fw_notify("inconsistent self IDs\n");
++			return;
++		}
+ 		ohci->self_id_buffer[j] =
+ 				cond_le32_to_cpu(ohci->self_id_cpu[i]);
+ 	}
+@@ -1097,12 +1315,20 @@ static void bus_reset_tasklet(unsigned long data)
  		reg_write(ohci, OHCI1394_ConfigROMhdr, ohci->next_header);
  	}
  
@@ -781,7 +1170,94 @@
  	spin_unlock_irqrestore(&ohci->lock, flags);
  
  	if (free_rom)
-@@ -1434,6 +1439,9 @@ static int ohci_cancel_packet(struct fw_card *card, struct fw_packet *packet)
+ 		dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE,
+ 				  free_rom, free_rom_bus);
+ 
++	log_selfids(ohci->node_id, generation,
++		    self_id_count, ohci->self_id_buffer);
++
+ 	fw_core_handle_bus_reset(&ohci->card, ohci->node_id, generation,
+ 				 self_id_count, ohci->self_id_buffer);
+ }
+@@ -1118,7 +1344,9 @@ static irqreturn_t irq_handler(int irq, void *data)
+ 	if (!event || !~event)
+ 		return IRQ_NONE;
+ 
+-	reg_write(ohci, OHCI1394_IntEventClear, event);
++	/* busReset must not be cleared yet, see OHCI 1.1 clause 7.2.3.2 */
++	reg_write(ohci, OHCI1394_IntEventClear, event & ~OHCI1394_busReset);
++	log_irqs(event);
+ 
+ 	if (event & OHCI1394_selfIDComplete)
+ 		tasklet_schedule(&ohci->bus_reset_tasklet);
+@@ -1153,6 +1381,10 @@ static irqreturn_t irq_handler(int irq, void *data)
+ 		iso_event &= ~(1 << i);
+ 	}
+ 
++	if (unlikely(event & OHCI1394_regAccessFail))
++		fw_error("Register access failure - "
++			 "please notify linux1394-devel at lists.sf.net\n");
++
+ 	if (unlikely(event & OHCI1394_postedWriteErr))
+ 		fw_error("PCI posted write error\n");
+ 
+@@ -1192,6 +1424,8 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length)
+ {
+ 	struct fw_ohci *ohci = fw_ohci(card);
+ 	struct pci_dev *dev = to_pci_dev(card->device);
++	u32 lps;
++	int i;
+ 
+ 	if (software_reset(ohci)) {
+ 		fw_error("Failed to reset ohci card.\n");
+@@ -1203,13 +1437,24 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length)
+ 	 * most of the registers.  In fact, on some cards (ALI M5251),
+ 	 * accessing registers in the SClk domain without LPS enabled
+ 	 * will lock up the machine.  Wait 50msec to make sure we have
+-	 * full link enabled.
++	 * full link enabled.  However, with some cards (well, at least
++	 * a JMicron PCIe card), we have to try again sometimes.
+ 	 */
+ 	reg_write(ohci, OHCI1394_HCControlSet,
+ 		  OHCI1394_HCControl_LPS |
+ 		  OHCI1394_HCControl_postedWriteEnable);
+ 	flush_writes(ohci);
+-	msleep(50);
++
++	for (lps = 0, i = 0; !lps && i < 3; i++) {
++		msleep(50);
++		lps = reg_read(ohci, OHCI1394_HCControlSet) &
++		      OHCI1394_HCControl_LPS;
++	}
++
++	if (!lps) {
++		fw_error("Failed to set Link Power Status\n");
++		return -EIO;
++	}
+ 
+ 	reg_write(ohci, OHCI1394_HCControlClear,
+ 		  OHCI1394_HCControl_noByteSwapData);
+@@ -1237,7 +1482,10 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length)
+ 		  OHCI1394_reqTxComplete | OHCI1394_respTxComplete |
+ 		  OHCI1394_isochRx | OHCI1394_isochTx |
+ 		  OHCI1394_postedWriteErr | OHCI1394_cycleTooLong |
+-		  OHCI1394_cycle64Seconds | OHCI1394_masterIntEnable);
++		  OHCI1394_cycle64Seconds | OHCI1394_regAccessFail |
++		  OHCI1394_masterIntEnable);
++	if (param_debug & OHCI_PARAM_DEBUG_BUSRESETS)
++		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_busReset);
+ 
+ 	/* Activate link_on bit and contender bit in our self ID packets.*/
+ 	if (ohci_update_phy_reg(card, 4, 0,
+@@ -1421,6 +1669,7 @@ static int ohci_cancel_packet(struct fw_card *card, struct fw_packet *packet)
+ 	if (packet->ack != 0)
+ 		goto out;
+ 
++	log_ar_at_event('T', packet->speed, packet->header, 0x20);
+ 	driver_data->packet = NULL;
+ 	packet->ack = RCODE_CANCELLED;
+ 	packet->callback(packet, &ohci->card, packet->ack);
+@@ -1435,6 +1684,9 @@ static int ohci_cancel_packet(struct fw_card *card, struct fw_packet *packet)
  static int
  ohci_enable_phys_dma(struct fw_card *card, int node_id, int generation)
  {
@@ -791,7 +1267,7 @@
  	struct fw_ohci *ohci = fw_ohci(card);
  	unsigned long flags;
  	int n, retval = 0;
-@@ -1465,6 +1473,7 @@ ohci_enable_phys_dma(struct fw_card *card, int node_id, int generation)
+@@ -1466,6 +1718,7 @@ ohci_enable_phys_dma(struct fw_card *card, int node_id, int generation)
   out:
  	spin_unlock_irqrestore(&ohci->lock, flags);
  	return retval;
@@ -799,7 +1275,7 @@
  }
  
  static u64
-@@ -2044,17 +2053,9 @@ static const struct fw_card_driver ohci_driver = {
+@@ -2045,17 +2298,9 @@ static const struct fw_card_driver ohci_driver = {
  	.stop_iso		= ohci_stop_iso,
  };
  
@@ -819,7 +1295,7 @@
  	if (machine_is(powermac)) {
  		struct device_node *ofn = pci_device_to_OF_node(dev);
  
-@@ -2063,8 +2064,35 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
+@@ -2064,8 +2309,33 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
  			pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 1);
  		}
  	}
@@ -850,12 +1326,15 @@
 +	int err;
 +	size_t size;
 +
-+	ohci_pmac_on(dev);
-+
  	ohci = kzalloc(sizeof(*ohci), GFP_KERNEL);
  	if (ohci == NULL) {
  		fw_error("Could not malloc fw_ohci data.\n");
-@@ -2076,7 +2104,7 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
+@@ -2074,10 +2344,12 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
+ 
+ 	fw_card_initialize(&ohci->card, &ohci_driver, &dev->dev);
+ 
++	ohci_pmac_on(dev);
++
  	err = pci_enable_device(dev);
  	if (err) {
  		fw_error("Failed to enable OHCI hardware.\n");
@@ -864,7 +1343,7 @@
  	}
  
  	pci_set_master(dev);
-@@ -2172,8 +2200,8 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
+@@ -2173,8 +2445,9 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
  	pci_release_region(dev, 0);
   fail_disable:
  	pci_disable_device(dev);
@@ -872,10 +1351,11 @@
 -	fw_card_put(&ohci->card);
 + fail_free:
 +	kfree(&ohci->card);
++	ohci_pmac_off(dev);
  
  	return err;
  }
-@@ -2201,72 +2229,42 @@ static void pci_remove(struct pci_dev *dev)
+@@ -2202,72 +2475,42 @@ static void pci_remove(struct pci_dev *dev)
  	pci_iounmap(dev, ohci->registers);
  	pci_release_region(dev, 0);
  	pci_disable_device(dev);
@@ -962,6 +1442,26 @@
  	if (err) {
  		fw_error("pci_enable_device failed\n");
  		return err;
+diff --git a/drivers/firewire/fw-ohci.h b/drivers/firewire/fw-ohci.h
+index dec4f04..a2fbb62 100644
+--- a/drivers/firewire/fw-ohci.h
++++ b/drivers/firewire/fw-ohci.h
+@@ -30,6 +30,7 @@
+ #define  OHCI1394_HCControl_softReset		0x00010000
+ #define OHCI1394_SelfIDBuffer                 0x064
+ #define OHCI1394_SelfIDCount                  0x068
++#define  OHCI1394_SelfIDCount_selfIDError	0x80000000
+ #define OHCI1394_IRMultiChanMaskHiSet         0x070
+ #define OHCI1394_IRMultiChanMaskHiClear       0x074
+ #define OHCI1394_IRMultiChanMaskLoSet         0x078
+@@ -124,6 +125,7 @@
+ #define OHCI1394_lockRespErr		0x00000200
+ #define OHCI1394_selfIDComplete		0x00010000
+ #define OHCI1394_busReset		0x00020000
++#define OHCI1394_regAccessFail		0x00040000
+ #define OHCI1394_phy			0x00080000
+ #define OHCI1394_cycleSynch		0x00100000
+ #define OHCI1394_cycle64Seconds		0x00200000
 diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
 index 62b4e47..2a99937 100644
 --- a/drivers/firewire/fw-sbp2.c
@@ -1336,7 +1836,7 @@
  }
  
 diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c
-index d2c7a3d..ebdec4c 100644
+index d2c7a3d..ffbf7d1 100644
 --- a/drivers/firewire/fw-topology.c
 +++ b/drivers/firewire/fw-topology.c
 @@ -108,6 +108,7 @@ static struct fw_node *fw_node_create(u32 sid, int port_count, int color)
@@ -1347,7 +1847,23 @@
  	node->port_count = port_count;
  
  	atomic_set(&node->ref_count, 1);
-@@ -431,6 +432,8 @@ update_tree(struct fw_card *card, struct fw_node *root)
+@@ -289,12 +290,11 @@ static struct fw_node *build_tree(struct fw_card *card,
+ 			beta_repeaters_present = true;
+ 
+ 		/*
+-		 * If all PHYs does not report the same gap count
+-		 * setting, we fall back to 63 which will force a gap
+-		 * count reconfiguration and a reset.
++		 * If PHYs report different gap counts, set an invalid count
++		 * which will force a gap count reconfiguration and a reset.
+ 		 */
+ 		if (SELF_ID_GAP_COUNT(q) != gap_count)
+-			gap_count = 63;
++			gap_count = 0;
+ 
+ 		update_hop_count(node);
+ 
+@@ -431,6 +431,8 @@ update_tree(struct fw_card *card, struct fw_node *root)
  			event = FW_NODE_LINK_OFF;
  		else if (!node0->link_on && node1->link_on)
  			event = FW_NODE_LINK_ON;
@@ -1356,6 +1872,25 @@
  		else
  			event = FW_NODE_UPDATED;
  
+@@ -510,6 +512,18 @@ fw_core_handle_bus_reset(struct fw_card *card,
+ 
+ 	fw_flush_transactions(card);
+ 
++	/*
++	 * If the selfID buffer is not the immediate successor of the
++	 * previously processed one, we cannot reliably compare the
++	 * old and new topologies.
++	 */
++	if (!is_next_generation(generation, card->generation) &&
++	    card->local_node != NULL) {
++		fw_notify("skipped bus generations, destroying all nodes\n");
++		fw_destroy_nodes(card);
++		card->bm_retries = 0;
++	}
++
+ 	spin_lock_irqsave(&card->lock, flags);
+ 
+ 	/*
 diff --git a/drivers/firewire/fw-topology.h b/drivers/firewire/fw-topology.h
 index cedc1ec..addb9f8 100644
 --- a/drivers/firewire/fw-topology.h
@@ -1379,10 +1914,97 @@
  
  struct fw_node {
 diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
-index 99529e5..e550535 100644
+index e6f1bda..3a59e9b 100644
 --- a/drivers/firewire/fw-transaction.c
 +++ b/drivers/firewire/fw-transaction.c
-@@ -396,7 +396,8 @@ const struct fw_address_region fw_high_memory_region =
+@@ -18,6 +18,7 @@
+  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+  */
+ 
++#include <linux/completion.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -294,42 +295,40 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
+ }
+ EXPORT_SYMBOL(fw_send_request);
+ 
++struct fw_phy_packet {
++	struct fw_packet packet;
++	struct completion done;
++};
++
+ static void
+ transmit_phy_packet_callback(struct fw_packet *packet,
+ 			     struct fw_card *card, int status)
+ {
+-	kfree(packet);
+-}
+-
+-static void send_phy_packet(struct fw_card *card, u32 data, int generation)
+-{
+-	struct fw_packet *packet;
+-
+-	packet = kzalloc(sizeof(*packet), GFP_ATOMIC);
+-	if (packet == NULL)
+-		return;
+-
+-	packet->header[0] = data;
+-	packet->header[1] = ~data;
+-	packet->header_length = 8;
+-	packet->payload_length = 0;
+-	packet->speed = SCODE_100;
+-	packet->generation = generation;
+-	packet->callback = transmit_phy_packet_callback;
++	struct fw_phy_packet *p =
++			container_of(packet, struct fw_phy_packet, packet);
+ 
+-	card->driver->send_request(card, packet);
++	complete(&p->done);
+ }
+ 
+ void fw_send_phy_config(struct fw_card *card,
+ 			int node_id, int generation, int gap_count)
+ {
+-	u32 q;
+-
+-	q = PHY_IDENTIFIER(PHY_PACKET_CONFIG) |
+-		PHY_CONFIG_ROOT_ID(node_id) |
+-		PHY_CONFIG_GAP_COUNT(gap_count);
+-
+-	send_phy_packet(card, q, generation);
++	struct fw_phy_packet p;
++	u32 data = PHY_IDENTIFIER(PHY_PACKET_CONFIG) |
++		   PHY_CONFIG_ROOT_ID(node_id) |
++		   PHY_CONFIG_GAP_COUNT(gap_count);
++
++	p.packet.header[0] = data;
++	p.packet.header[1] = ~data;
++	p.packet.header_length = 8;
++	p.packet.payload_length = 0;
++	p.packet.speed = SCODE_100;
++	p.packet.generation = generation;
++	p.packet.callback = transmit_phy_packet_callback;
++	init_completion(&p.done);
++
++	card->driver->send_request(card, &p.packet);
++	wait_for_completion(&p.done);
+ }
+ 
+ void fw_flush_transactions(struct fw_card *card)
+@@ -389,21 +388,21 @@ lookup_enclosing_address_handler(struct list_head *list,
+ static DEFINE_SPINLOCK(address_handler_lock);
+ static LIST_HEAD(address_handler_list);
+ 
+-const struct fw_address_region fw_low_memory_region =
+-	{ .start = 0x000000000000ULL, .end = 0x000100000000ULL,  };
+ const struct fw_address_region fw_high_memory_region =
+ 	{ .start = 0x000100000000ULL, .end = 0xffffe0000000ULL,  };
++EXPORT_SYMBOL(fw_high_memory_region);
++
++#if 0
++const struct fw_address_region fw_low_memory_region =
++	{ .start = 0x000000000000ULL, .end = 0x000100000000ULL,  };
  const struct fw_address_region fw_private_region =
  	{ .start = 0xffffe0000000ULL, .end = 0xfffff0000000ULL,  };
  const struct fw_address_region fw_csr_region =
@@ -1391,8 +2013,16 @@
 +	  .end   = CSR_REGISTER_BASE | CSR_CONFIG_ROM_END,  };
  const struct fw_address_region fw_unit_space_region =
  	{ .start = 0xfffff0000900ULL, .end = 0x1000000000000ULL, };
- EXPORT_SYMBOL(fw_low_memory_region);
-@@ -741,7 +742,8 @@ fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
+-EXPORT_SYMBOL(fw_low_memory_region);
+-EXPORT_SYMBOL(fw_high_memory_region);
+-EXPORT_SYMBOL(fw_private_region);
+-EXPORT_SYMBOL(fw_csr_region);
+-EXPORT_SYMBOL(fw_unit_space_region);
++#endif  /*  0  */
+ 
+ /**
+  * Allocate a range of addresses in the node space of the OHCI
+@@ -747,7 +746,8 @@ fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
  EXPORT_SYMBOL(fw_core_handle_response);
  
  static const struct fw_address_region topology_map_region =
@@ -1402,7 +2032,7 @@
  
  static void
  handle_topology_map(struct fw_card *card, struct fw_request *request,
-@@ -779,7 +781,8 @@ static struct fw_address_handler topology_map = {
+@@ -785,7 +785,8 @@ static struct fw_address_handler topology_map = {
  };
  
  static const struct fw_address_region registers_region =
@@ -1412,7 +2042,7 @@
  
  static void
  handle_registers(struct fw_card *card, struct fw_request *request,
-@@ -788,7 +791,7 @@ handle_registers(struct fw_card *card, struct fw_request *request,
+@@ -794,7 +795,7 @@ handle_registers(struct fw_card *card, struct fw_request *request,
  		 unsigned long long offset,
  		 void *payload, size_t length, void *callback_data)
  {
@@ -1422,10 +2052,22 @@
  	__be32 *data = payload;
  
 diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h
-index a43bb22..8d1987f 100644
+index a43bb22..eb01e5c 100644
 --- a/drivers/firewire/fw-transaction.h
 +++ b/drivers/firewire/fw-transaction.h
-@@ -221,12 +221,9 @@ struct fw_card {
+@@ -201,11 +201,7 @@ struct fw_address_region {
+ 	u64 end;
+ };
+ 
+-extern const struct fw_address_region fw_low_memory_region;
+ extern const struct fw_address_region fw_high_memory_region;
+-extern const struct fw_address_region fw_private_region;
+-extern const struct fw_address_region fw_csr_region;
+-extern const struct fw_address_region fw_unit_space_region;
+ 
+ int fw_core_add_address_handler(struct fw_address_handler *handler,
+ 				const struct fw_address_region *region);
+@@ -221,12 +217,9 @@ struct fw_card {
  	const struct fw_card_driver *driver;
  	struct device *device;
  	atomic_t device_count;
@@ -1438,16 +2080,23 @@
  	int current_tlabel, tlabel_mask;
  	struct list_head transaction_list;
  	struct timer_list flush_timer;
-@@ -263,9 +260,6 @@ struct fw_card {
+@@ -263,8 +256,14 @@ struct fw_card {
  	int bm_generation;
  };
  
 -struct fw_card *fw_card_get(struct fw_card *card);
 -void fw_card_put(struct fw_card *card);
--
++/*
++ * Check whether new_generation is the immediate successor of old_generation.
++ * Take counter roll-over at 255 (as per to OHCI) into account.
++ */
++static inline bool is_next_generation(int new_generation, int old_generation)
++{
++	return (new_generation & 0xff) == ((old_generation + 1) & 0xff);
++}
+ 
  /*
   * The iso packet format allows for an immediate header/payload part
-  * stored in 'header' immediately after the packet info plus an
 diff --git a/drivers/ieee1394/csr.c b/drivers/ieee1394/csr.c
 index 52ac83e..c90be40 100644
 --- a/drivers/ieee1394/csr.c
@@ -1473,7 +2122,7 @@
                                               | csr_crc16(host->csr.speed_map+1,
                                                           0x3f1));
 diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
-index 6572211..8c72f36 100644
+index 6572211..6228fad 100644
 --- a/drivers/ieee1394/dv1394.c
 +++ b/drivers/ieee1394/dv1394.c
 @@ -2179,8 +2179,7 @@ static struct ieee1394_device_id dv1394_id_table[] = {
@@ -1486,6 +2135,14 @@
  };
  
  
+@@ -2568,7 +2567,6 @@ static int __init dv1394_init_module(void)
+ 
+ 	cdev_init(&dv1394_cdev, &dv1394_fops);
+ 	dv1394_cdev.owner = THIS_MODULE;
+-	kobject_set_name(&dv1394_cdev.kobj, "dv1394");
+ 	ret = cdev_add(&dv1394_cdev, IEEE1394_DV1394_DEV, 16);
+ 	if (ret) {
+ 		printk(KERN_ERR "dv1394: unable to register character device\n");
 diff --git a/drivers/ieee1394/highlevel.c b/drivers/ieee1394/highlevel.c
 index b642546..fa2bfec 100644
 --- a/drivers/ieee1394/highlevel.c
@@ -1548,9 +2205,18 @@
  		    id->vendor_id != ud->vendor_id)
  			continue;
 diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
-index 969de2a..0808bae 100644
+index 969de2a..0690469 100644
 --- a/drivers/ieee1394/ohci1394.c
 +++ b/drivers/ieee1394/ohci1394.c
+@@ -149,7 +149,7 @@ printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id ,
+ /* Module Parameters */
+ static int phys_dma = 1;
+ module_param(phys_dma, int, 0444);
+-MODULE_PARM_DESC(phys_dma, "Enable physical dma (default = 1).");
++MODULE_PARM_DESC(phys_dma, "Enable physical DMA (default = 1).");
+ 
+ static void dma_trm_tasklet(unsigned long data);
+ static void dma_trm_reset(struct dma_trm_ctx *d);
 @@ -708,7 +708,7 @@ static void insert_packet(struct ti_ohci *ohci,
                                  /* FIXME: do something about it */
                                  PRINT(KERN_ERR,
@@ -1560,10 +2226,93 @@
                                        packet->data, packet->data_size);
                          }
  #endif
-@@ -2993,15 +2993,9 @@ do {						\
- 	return err;				\
- } while (0)
+@@ -2089,10 +2089,8 @@ static void dma_trm_reset(struct dma_trm_ctx *d)
  
+ 	spin_lock_irqsave(&d->lock, flags);
+ 
+-	list_splice(&d->fifo_list, &packet_list);
+-	list_splice(&d->pending_list, &packet_list);
+-	INIT_LIST_HEAD(&d->fifo_list);
+-	INIT_LIST_HEAD(&d->pending_list);
++	list_splice_init(&d->fifo_list, &packet_list);
++	list_splice_init(&d->pending_list, &packet_list);
+ 
+ 	d->branchAddrPtr = NULL;
+ 	d->sent_ind = d->prg_ind;
+@@ -2787,7 +2785,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
+ 	d->buf_bus = kzalloc(d->num_desc * sizeof(*d->buf_bus), GFP_ATOMIC);
+ 
+ 	if (d->buf_cpu == NULL || d->buf_bus == NULL) {
+-		PRINT(KERN_ERR, "Failed to allocate dma buffer");
++		PRINT(KERN_ERR, "Failed to allocate %s", "DMA buffer");
+ 		free_dma_rcv_ctx(d);
+ 		return -ENOMEM;
+ 	}
+@@ -2796,7 +2794,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
+ 	d->prg_bus = kzalloc(d->num_desc * sizeof(*d->prg_bus), GFP_ATOMIC);
+ 
+ 	if (d->prg_cpu == NULL || d->prg_bus == NULL) {
+-		PRINT(KERN_ERR, "Failed to allocate dma prg");
++		PRINT(KERN_ERR, "Failed to allocate %s", "DMA prg");
+ 		free_dma_rcv_ctx(d);
+ 		return -ENOMEM;
+ 	}
+@@ -2804,7 +2802,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
+ 	d->spb = kmalloc(d->split_buf_size, GFP_ATOMIC);
+ 
+ 	if (d->spb == NULL) {
+-		PRINT(KERN_ERR, "Failed to allocate split buffer");
++		PRINT(KERN_ERR, "Failed to allocate %s", "split buffer");
+ 		free_dma_rcv_ctx(d);
+ 		return -ENOMEM;
+ 	}
+@@ -2830,7 +2828,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
+ 			memset(d->buf_cpu[i], 0, d->buf_size);
+ 		} else {
+ 			PRINT(KERN_ERR,
+-			      "Failed to allocate dma buffer");
++			      "Failed to allocate %s", "DMA buffer");
+ 			free_dma_rcv_ctx(d);
+ 			return -ENOMEM;
+ 		}
+@@ -2841,7 +2839,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
+                         memset(d->prg_cpu[i], 0, sizeof(struct dma_cmd));
+ 		} else {
+ 			PRINT(KERN_ERR,
+-			      "Failed to allocate dma prg");
++			      "Failed to allocate %s", "DMA prg");
+ 			free_dma_rcv_ctx(d);
+ 			return -ENOMEM;
+ 		}
+@@ -2902,7 +2900,7 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
+ 	d->prg_bus = kzalloc(d->num_desc * sizeof(*d->prg_bus), GFP_KERNEL);
+ 
+ 	if (d->prg_cpu == NULL || d->prg_bus == NULL) {
+-		PRINT(KERN_ERR, "Failed to allocate at dma prg");
++		PRINT(KERN_ERR, "Failed to allocate %s", "AT DMA prg");
+ 		free_dma_trm_ctx(d);
+ 		return -ENOMEM;
+ 	}
+@@ -2925,7 +2923,7 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
+                         memset(d->prg_cpu[i], 0, sizeof(struct at_dma_prg));
+ 		} else {
+ 			PRINT(KERN_ERR,
+-			      "Failed to allocate at dma prg");
++			      "Failed to allocate %s", "AT DMA prg");
+ 			free_dma_trm_ctx(d);
+ 			return -ENOMEM;
+ 		}
+@@ -2986,22 +2984,9 @@ static struct hpsb_host_driver ohci1394_driver = {
+  * PCI Driver Interface functions  *
+  ***********************************/
+ 
+-#define FAIL(err, fmt, args...)			\
+-do {						\
+-	PRINT_G(KERN_ERR, fmt , ## args);	\
+-        ohci1394_pci_remove(dev);               \
+-	return err;				\
+-} while (0)
+-
 -static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
 -					const struct pci_device_id *ent)
 -{
@@ -1578,7 +2327,7 @@
  	if (machine_is(powermac)) {
  		struct device_node *ofn = pci_device_to_OF_node(dev);
  
-@@ -3010,8 +3004,32 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
+@@ -3010,15 +2995,45 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
  			pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 1);
  		}
  	}
@@ -1600,19 +2349,161 @@
 +#define ohci1394_pmac_off(dev)
  #endif /* CONFIG_PPC_PMAC */
  
+-        if (pci_enable_device(dev))
+-		FAIL(-ENXIO, "Failed to enable OHCI hardware");
 +static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
 +					const struct pci_device_id *ent)
 +{
 +	struct hpsb_host *host;
 +	struct ti_ohci *ohci;	/* shortcut to currently handled device */
 +	resource_size_t ohci_base;
++	int err = -ENOMEM;
 +
 +	ohci1394_pmac_on(dev);
-         if (pci_enable_device(dev))
- 		FAIL(-ENXIO, "Failed to enable OHCI hardware");
++	if (pci_enable_device(dev)) {
++		PRINT_G(KERN_ERR, "Failed to enable OHCI hardware");
++		err = -ENXIO;
++		goto err;
++	}
          pci_set_master(dev);
-@@ -3203,16 +3221,16 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
- #undef FAIL
+ 
+ 	host = hpsb_alloc_host(&ohci1394_driver, sizeof(struct ti_ohci), &dev->dev);
+-	if (!host) FAIL(-ENOMEM, "Failed to allocate host structure");
+-
++	if (!host) {
++		PRINT_G(KERN_ERR, "Failed to allocate %s", "host structure");
++		goto err;
++	}
+ 	ohci = host->hostdata;
+ 	ohci->dev = dev;
+ 	ohci->host = host;
+@@ -3067,15 +3082,20 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
+ 		      (unsigned long long)pci_resource_len(dev, 0));
+ 
+ 	if (!request_mem_region(ohci_base, OHCI1394_REGISTER_SIZE,
+-				OHCI1394_DRIVER_NAME))
+-		FAIL(-ENOMEM, "MMIO resource (0x%llx - 0x%llx) unavailable",
++				OHCI1394_DRIVER_NAME)) {
++		PRINT_G(KERN_ERR, "MMIO resource (0x%llx - 0x%llx) unavailable",
+ 			(unsigned long long)ohci_base,
+ 			(unsigned long long)ohci_base + OHCI1394_REGISTER_SIZE);
++		goto err;
++	}
+ 	ohci->init_state = OHCI_INIT_HAVE_MEM_REGION;
+ 
+ 	ohci->registers = ioremap(ohci_base, OHCI1394_REGISTER_SIZE);
+-	if (ohci->registers == NULL)
+-		FAIL(-ENXIO, "Failed to remap registers - card not accessible");
++	if (ohci->registers == NULL) {
++		PRINT_G(KERN_ERR, "Failed to remap registers");
++		err = -ENXIO;
++		goto err;
++	}
+ 	ohci->init_state = OHCI_INIT_HAVE_IOMAPPING;
+ 	DBGMSG("Remapped memory spaces reg 0x%p", ohci->registers);
+ 
+@@ -3083,16 +3103,20 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
+ 	ohci->csr_config_rom_cpu =
+ 		pci_alloc_consistent(ohci->dev, OHCI_CONFIG_ROM_LEN,
+ 				     &ohci->csr_config_rom_bus);
+-	if (ohci->csr_config_rom_cpu == NULL)
+-		FAIL(-ENOMEM, "Failed to allocate buffer config rom");
++	if (ohci->csr_config_rom_cpu == NULL) {
++		PRINT_G(KERN_ERR, "Failed to allocate %s", "buffer config rom");
++		goto err;
++	}
+ 	ohci->init_state = OHCI_INIT_HAVE_CONFIG_ROM_BUFFER;
+ 
+ 	/* self-id dma buffer allocation */
+ 	ohci->selfid_buf_cpu =
+ 		pci_alloc_consistent(ohci->dev, OHCI1394_SI_DMA_BUF_SIZE,
+                       &ohci->selfid_buf_bus);
+-	if (ohci->selfid_buf_cpu == NULL)
+-		FAIL(-ENOMEM, "Failed to allocate DMA buffer for self-id packets");
++	if (ohci->selfid_buf_cpu == NULL) {
++		PRINT_G(KERN_ERR, "Failed to allocate %s", "self-ID buffer");
++		goto err;
++	}
+ 	ohci->init_state = OHCI_INIT_HAVE_SELFID_BUFFER;
+ 
+ 	if ((unsigned long)ohci->selfid_buf_cpu & 0x1fff)
+@@ -3108,28 +3132,32 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
+ 	if (alloc_dma_rcv_ctx(ohci, &ohci->ar_req_context,
+ 			      DMA_CTX_ASYNC_REQ, 0, AR_REQ_NUM_DESC,
+ 			      AR_REQ_BUF_SIZE, AR_REQ_SPLIT_BUF_SIZE,
+-			      OHCI1394_AsReqRcvContextBase) < 0)
+-		FAIL(-ENOMEM, "Failed to allocate AR Req context");
+-
++			      OHCI1394_AsReqRcvContextBase) < 0) {
++		PRINT_G(KERN_ERR, "Failed to allocate %s", "AR Req context");
++		goto err;
++	}
+ 	/* AR DMA response context allocation */
+ 	if (alloc_dma_rcv_ctx(ohci, &ohci->ar_resp_context,
+ 			      DMA_CTX_ASYNC_RESP, 0, AR_RESP_NUM_DESC,
+ 			      AR_RESP_BUF_SIZE, AR_RESP_SPLIT_BUF_SIZE,
+-			      OHCI1394_AsRspRcvContextBase) < 0)
+-		FAIL(-ENOMEM, "Failed to allocate AR Resp context");
+-
++			      OHCI1394_AsRspRcvContextBase) < 0) {
++		PRINT_G(KERN_ERR, "Failed to allocate %s", "AR Resp context");
++		goto err;
++	}
+ 	/* AT DMA request context */
+ 	if (alloc_dma_trm_ctx(ohci, &ohci->at_req_context,
+ 			      DMA_CTX_ASYNC_REQ, 0, AT_REQ_NUM_DESC,
+-			      OHCI1394_AsReqTrContextBase) < 0)
+-		FAIL(-ENOMEM, "Failed to allocate AT Req context");
+-
++			      OHCI1394_AsReqTrContextBase) < 0) {
++		PRINT_G(KERN_ERR, "Failed to allocate %s", "AT Req context");
++		goto err;
++	}
+ 	/* AT DMA response context */
+ 	if (alloc_dma_trm_ctx(ohci, &ohci->at_resp_context,
+ 			      DMA_CTX_ASYNC_RESP, 1, AT_RESP_NUM_DESC,
+-			      OHCI1394_AsRspTrContextBase) < 0)
+-		FAIL(-ENOMEM, "Failed to allocate AT Resp context");
+-
++			      OHCI1394_AsRspTrContextBase) < 0) {
++		PRINT_G(KERN_ERR, "Failed to allocate %s", "AT Resp context");
++		goto err;
++	}
+ 	/* Start off with a soft reset, to clear everything to a sane
+ 	 * state. */
+ 	ohci_soft_reset(ohci);
+@@ -3172,9 +3200,10 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
+ 	 * by that point.
+ 	 */
+ 	if (request_irq(dev->irq, ohci_irq_handler, IRQF_SHARED,
+-			 OHCI1394_DRIVER_NAME, ohci))
+-		FAIL(-ENOMEM, "Failed to allocate shared interrupt %d", dev->irq);
+-
++			 OHCI1394_DRIVER_NAME, ohci)) {
++		PRINT_G(KERN_ERR, "Failed to allocate interrupt %d", dev->irq);
++		goto err;
++	}
+ 	ohci->init_state = OHCI_INIT_HAVE_IRQ;
+ 	ohci_initialize(ohci);
+ 
+@@ -3194,25 +3223,28 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
+ 	host->middle_addr_space = OHCI1394_MIDDLE_ADDRESS_SPACE;
+ 
+ 	/* Tell the highlevel this host is ready */
+-	if (hpsb_add_host(host))
+-		FAIL(-ENOMEM, "Failed to register host with highlevel");
+-
++	if (hpsb_add_host(host)) {
++		PRINT_G(KERN_ERR, "Failed to register host with highlevel");
++		goto err;
++	}
+ 	ohci->init_state = OHCI_INIT_DONE;
+ 
+ 	return 0;
+-#undef FAIL
++err:
++	ohci1394_pci_remove(dev);
++	return err;
  }
  
 -static void ohci1394_pci_remove(struct pci_dev *pdev)
@@ -1625,14 +2516,15 @@
 -	ohci = pci_get_drvdata(pdev);
 +	ohci = pci_get_drvdata(dev);
  	if (!ohci)
- 		return;
+-		return;
++		goto out;
  
 -	dev = get_device(&ohci->host->device);
 +	device = get_device(&ohci->host->device);
  
  	switch (ohci->init_state) {
  	case OHCI_INIT_DONE:
-@@ -3246,7 +3264,7 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
+@@ -3246,7 +3278,7 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
  		/* Soft reset before we start - this disables
  		 * interrupts and clears linkEnable and LPS. */
  		ohci_soft_reset(ohci);
@@ -1641,7 +2533,7 @@
  
  	case OHCI_INIT_HAVE_TXRX_BUFFERS__MAYBE:
  		/* The ohci_soft_reset() stops all DMA contexts, so we
-@@ -3257,12 +3275,12 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
+@@ -3257,12 +3289,12 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
  		free_dma_trm_ctx(&ohci->at_resp_context);
  
  	case OHCI_INIT_HAVE_SELFID_BUFFER:
@@ -1656,7 +2548,7 @@
  				    ohci->csr_config_rom_cpu,
  				    ohci->csr_config_rom_bus);
  
-@@ -3270,35 +3288,24 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
+@@ -3270,35 +3302,24 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
  		iounmap(ohci->registers);
  
  	case OHCI_INIT_HAVE_MEM_REGION:
@@ -1676,8 +2568,7 @@
 -		}
 -	}
 -#endif /* CONFIG_PPC_PMAC */
-+		ohci1394_pmac_off(dev);
- 
+-
  	case OHCI_INIT_ALLOC_HOST:
 -		pci_set_drvdata(ohci->dev, NULL);
 +		pci_set_drvdata(dev, NULL);
@@ -1687,6 +2578,8 @@
 -		put_device(dev);
 +	if (device)
 +		put_device(device);
++out:
++	ohci1394_pmac_off(dev);
  }
  
  #ifdef CONFIG_PM
@@ -1699,7 +2592,7 @@
  
  	if (!ohci) {
  		printk(KERN_ERR "%s: tried to suspend nonexisting host\n",
-@@ -3326,32 +3333,23 @@ static int ohci1394_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+@@ -3326,32 +3347,23 @@ static int ohci1394_pci_suspend(struct pci_dev *pdev, pm_message_t state)
  	ohci_devctl(ohci->host, RESET_BUS, LONG_RESET_NO_FORCE_ROOT);
  	ohci_soft_reset(ohci);
  
@@ -1737,7 +2630,7 @@
  
  	if (!ohci) {
  		printk(KERN_ERR "%s: tried to resume nonexisting host\n",
-@@ -3360,19 +3358,10 @@ static int ohci1394_pci_resume(struct pci_dev *pdev)
+@@ -3360,19 +3372,10 @@ static int ohci1394_pci_resume(struct pci_dev *pdev)
  	}
  	DBGMSG("resume called");
  
@@ -1762,7 +2655,7 @@
  		PRINT(KERN_ERR, "pci_enable_device failed with %d", err);
  		return err;
 diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
-index 8af01ab..9c35e0d 100644
+index 8af01ab..7aee1ac 100644
 --- a/drivers/ieee1394/pcilynx.c
 +++ b/drivers/ieee1394/pcilynx.c
 @@ -226,7 +226,7 @@ static int get_phy_reg(struct ti_lynx *lynx, int addr)
@@ -1817,8 +2710,18 @@
                  return -1;
          }
  
+@@ -738,8 +738,7 @@ static int lynx_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
+                 spin_lock_irqsave(&lynx->async.queue_lock, flags);
+ 
+                 reg_write(lynx, DMA_CHAN_CTRL(CHANNEL_ASYNC_SEND), 0);
+-		list_splice(&lynx->async.queue, &packet_list);
+-		INIT_LIST_HEAD(&lynx->async.queue);
++		list_splice_init(&lynx->async.queue, &packet_list);
+ 
+                 if (list_empty(&lynx->async.pcl_queue)) {
+                         spin_unlock_irqrestore(&lynx->async.queue_lock, flags);
 diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
-index 37e7e10..3634785 100644
+index 37e7e10..04e96ba 100644
 --- a/drivers/ieee1394/raw1394.c
 +++ b/drivers/ieee1394/raw1394.c
 @@ -2959,7 +2959,6 @@ MODULE_DEVICE_TABLE(ieee1394, raw1394_id_table);
@@ -1829,6 +2732,14 @@
  };
  
  /******************************************************************************/
+@@ -3004,7 +3003,6 @@ static int __init init_raw1394(void)
+ 
+ 	cdev_init(&raw1394_cdev, &raw1394_fops);
+ 	raw1394_cdev.owner = THIS_MODULE;
+-	kobject_set_name(&raw1394_cdev.kobj, RAW1394_DEVICE_NAME);
+ 	ret = cdev_add(&raw1394_cdev, IEEE1394_RAW1394_DEV, 1);
+ 	if (ret) {
+ 		HPSB_ERR("raw1394 failed to register minor device block");
 diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
 index f53f72d..16b9d0a 100644
 --- a/drivers/ieee1394/sbp2.c
@@ -1866,7 +2777,7 @@
  	if (lu->workarounds & SBP2_WORKAROUND_INQUIRY_36)
  		sdev->inquiry_len = 36;
 diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
-index bd28adf..cc240b2 100644
+index bd28adf..e03024e 100644
 --- a/drivers/ieee1394/video1394.c
 +++ b/drivers/ieee1394/video1394.c
 @@ -1315,8 +1315,7 @@ static struct ieee1394_device_id video1394_id_table[] = {
@@ -1879,24 +2790,11 @@
  };
  
  
-diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
-index 0796c1a..4e370e1 100644
---- a/lib/Kconfig.debug
-+++ b/lib/Kconfig.debug
-@@ -592,6 +592,16 @@ config LATENCYTOP
- 	  Enable this option if you want to use the LatencyTOP tool
- 	  to find out which userspace is blocking on what kernel operations.
+@@ -1504,7 +1503,6 @@ static int __init video1394_init_module (void)
  
-+config FIREWIRE_OHCI_REMOTE_DMA
-+	bool "Remote debugging via firewire-ohci"
-+	depends on FIREWIRE_OHCI
-+	help
-+	  This option lets you use the FireWire bus for remote debugging.
-+	  It enables unfiltered remote DMA in the firewire-ohci driver.
-+	  See Documentation/debugging-via-ohci1394.txt for more information.
-+
-+	  If unsure, say N.
-+
- config PROVIDE_OHCI1394_DMA_INIT
- 	bool "Provide code for enabling DMA over FireWire early on boot"
- 	depends on PCI && X86
+ 	cdev_init(&video1394_cdev, &video1394_fops);
+ 	video1394_cdev.owner = THIS_MODULE;
+-	kobject_set_name(&video1394_cdev.kobj, VIDEO1394_DRIVER_NAME);
+ 	ret = cdev_add(&video1394_cdev, IEEE1394_VIDEO1394_DEV, 16);
+ 	if (ret) {
+ 		PRINT_G(KERN_ERR, "video1394: unable to get minor device block");

linux-2.6-merge-efifb-imacfb.patch:

Index: linux-2.6-merge-efifb-imacfb.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/linux-2.6-merge-efifb-imacfb.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- linux-2.6-merge-efifb-imacfb.patch	2 Apr 2008 08:55:25 -0000	1.1
+++ linux-2.6-merge-efifb-imacfb.patch	14 Apr 2008 16:06:53 -0000	1.2
@@ -1,9 +1,9 @@
 
  Kconfig  |   15 --
  Makefile |    1 
- efifb.c  |  175 +++++++++++++++++++++++++++--
+ efifb.c  |  178 ++++++++++++++++++++++++++++-
  imacfb.c |  376 ---------------------------------------------------------------
- 4 files changed, 168 insertions(+), 399 deletions(-)
+ 4 files changed, 171 insertions(+), 399 deletions(-)
 
 diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
 index 1bd5fb3..474c375 100644
@@ -49,7 +49,7 @@
  obj-$(CONFIG_FB_VGA16)            += vga16fb.o
  obj-$(CONFIG_FB_OF)               += offb.o
 diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
-index bd779ae..489f030 100644
+index bd779ae..d4b47d4 100644
 --- a/drivers/video/efifb.c
 +++ b/drivers/video/efifb.c
 @@ -12,6 +12,7 @@
@@ -60,7 +60,7 @@
  
  #include <video/vga.h>
  
-@@ -33,6 +34,89 @@ static struct fb_fix_screeninfo efifb_fix __initdata = {
+@@ -33,6 +34,92 @@ static struct fb_fix_screeninfo efifb_fix __initdata = {
  	.visual			= FB_VISUAL_TRUECOLOR,
  };
  
@@ -71,6 +71,7 @@
 +	M_I24,		/* 24-Inch iMac */
 +	M_MINI,		/* Mac Mini */
 +	M_MB,		/* MacBook */
++	M_MBA,		/* MacBook Air */
 +	M_MBP,		/* MacBook Pro */
 +	M_MBP_2,	/* MacBook Pro 2nd gen */
 +	M_MBP_SR,	/* MacBook Pro (Santa Rosa) */
@@ -90,6 +91,7 @@
 +	[M_I24] = { "i24", 0x80010000, 2048 * 4, 1920, 1200 }, /* guess */
 +	[M_MINI]= { "mini", 0x80000000, 2048 * 4, 1024, 768 },
 +	[M_MB] = { "macbook", 0x80000000, 2048 * 4, 1280, 800 },
++	[M_MBA] = { "mba", 0x80000000, 2048 * 4, 1280, 800 },
 +	[M_MBP] = { "mbp", 0x80010000, 1472 * 4, 1440, 900 },
 +	[M_MBP_2] = { "mbp2", 0, 0, 0, 0 }, /* placeholder */
 +	[M_MBP_SR] = { "mbp3", 0x80030000, 2048 * 4, 1440, 900 },
@@ -115,6 +117,7 @@
 +	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac7,1", M_I20_SR),
 +	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "Macmini1,1", M_MINI),
 +	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook1,1", M_MB),
++	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookAir1,1", M_MBA),
 +	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro1,1", M_MBP),
 +	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro2,1", M_MBP_2),
 +	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro2,1", M_MBP_2),
@@ -150,7 +153,7 @@
  static int efifb_setcolreg(unsigned regno, unsigned red, unsigned green,
  			   unsigned blue, unsigned transp,
  			   struct fb_info *info)
-@@ -67,6 +151,38 @@ static struct fb_ops efifb_ops = {
+@@ -67,6 +154,38 @@ static struct fb_ops efifb_ops = {
  	.fb_imageblit	= cfb_imageblit,
  };
  
@@ -189,7 +192,7 @@
  static int __init efifb_probe(struct platform_device *dev)
  {
  	struct fb_info *info;
-@@ -74,6 +190,26 @@ static int __init efifb_probe(struct platform_device *dev)
+@@ -74,6 +193,26 @@ static int __init efifb_probe(struct platform_device *dev)
  	unsigned int size_vmode;
  	unsigned int size_remap;
  	unsigned int size_total;
@@ -216,7 +219,7 @@
  
  	efifb_fix.smem_start = screen_info.lfb_base;
  	efifb_defined.bits_per_pixel = screen_info.lfb_depth;
-@@ -98,21 +234,25 @@ static int __init efifb_probe(struct platform_device *dev)
+@@ -98,21 +237,25 @@ static int __init efifb_probe(struct platform_device *dev)
  	 *                 option to simply use size_total as that
  	 *                 wastes plenty of kernel address space. */
  	size_remap  = size_vmode * 2;
@@ -245,7 +248,7 @@
  		err = -ENOMEM;
  		goto err_release_mem;
  	}
-@@ -125,7 +265,7 @@ static int __init efifb_probe(struct platform_device *dev)
+@@ -125,7 +268,7 @@ static int __init efifb_probe(struct platform_device *dev)
  				"0x%x @ 0x%lx\n",
  			efifb_fix.smem_len, efifb_fix.smem_start);
  		err = -EIO;
@@ -254,7 +257,7 @@
  	}
  
  	printk(KERN_INFO "efifb: framebuffer at 0x%lx, mapped to 0x%p, "
-@@ -178,25 +318,27 @@ static int __init efifb_probe(struct platform_device *dev)
+@@ -178,25 +321,27 @@ static int __init efifb_probe(struct platform_device *dev)
  	info->fix = efifb_fix;
  	info->flags = FBINFO_FLAG_DEFAULT;
  
@@ -288,7 +291,7 @@
  	return err;
  }
  
-@@ -214,9 +356,22 @@ static struct platform_device efifb_device = {
+@@ -214,9 +359,22 @@ static struct platform_device efifb_device = {
  static int __init efifb_init(void)
  {
  	int ret;

linux-2.6-silence-noise.patch:

Index: linux-2.6-silence-noise.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/linux-2.6-silence-noise.patch,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- linux-2.6-silence-noise.patch	6 Mar 2008 13:59:25 -0000	1.4
+++ linux-2.6-silence-noise.patch	14 Apr 2008 16:06:53 -0000	1.5
@@ -102,3 +102,31 @@
  	mutex_lock(&dpm_list_mtx);
  	dpm_sysfs_remove(dev);
  	list_del_init(&dev->power.entry);
+--- linux-2.6.24.noarch/arch/x86/pci/mmconfig-shared.c~	2008-04-12 20:04:01.000000000 -0400
++++ linux-2.6.24.noarch/arch/x86/pci/mmconfig-shared.c	2008-04-12 20:05:35.000000000 -0400
+@@ -191,7 +191,7 @@ static void __init pci_mmcfg_reject_brok
+ 	if (pci_mmcfg_config_num == 1 &&
+ 	    cfg->pci_segment == 0 &&
+ 	    (cfg->start_bus_number | cfg->end_bus_number) == 0) {
+-		printk(KERN_ERR "PCI: start and end of bus number is 0. "
++		printk(KERN_DEBUG "PCI: start and end of bus number is 0. "
+ 		       "Rejected as broken MCFG.\n");
+ 		goto reject;
+ 	}
+@@ -203,14 +203,14 @@ static void __init pci_mmcfg_reject_brok
+ 	if (type == 1 && !e820_all_mapped(cfg->address,
+ 					  cfg->address + MMCONFIG_APER_MIN,
+ 					  E820_RESERVED)) {
+-		printk(KERN_ERR "PCI: BIOS Bug: MCFG area at %Lx is not"
++		printk(KERN_DEBUG "PCI: BIOS Bug: MCFG area at %Lx is not"
+ 		       " E820-reserved\n", cfg->address);
+ 		goto reject;
+ 	}
+ 	return;
+ 
+ reject:
+-	printk(KERN_ERR "PCI: Not using MMCONFIG.\n");
++	printk(KERN_DEBUG "PCI: Not using MMCONFIG.\n");
+ 	kfree(pci_mmcfg_config);
+ 	pci_mmcfg_config = NULL;
+ 	pci_mmcfg_config_num = 0;

linux-2.6-uvcvideo.patch:

Index: linux-2.6-uvcvideo.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/linux-2.6-uvcvideo.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- linux-2.6-uvcvideo.patch	6 Mar 2008 13:59:26 -0000	1.2
+++ linux-2.6-uvcvideo.patch	14 Apr 2008 16:06:53 -0000	1.3
@@ -1,8 +1,8 @@
 diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
-index c9f14bf..19acd71 100644
+index 1832966..1be8bb6 100644
 --- a/drivers/media/video/Kconfig
 +++ b/drivers/media/video/Kconfig
-@@ -718,6 +718,7 @@ source "drivers/media/video/em28xx/Kconfig"
+@@ -737,6 +737,7 @@ source "drivers/media/video/em28xx/Kconfig"
  source "drivers/media/video/usbvision/Kconfig"
  
  source "drivers/media/video/usbvideo/Kconfig"
@@ -11,10 +11,10 @@
  source "drivers/media/video/et61x251/Kconfig"
  
 diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
-index b5a0641..91033cf 100644
+index 3f209b3..dda5db0 100644
 --- a/drivers/media/video/Makefile
 +++ b/drivers/media/video/Makefile
-@@ -123,6 +123,8 @@ obj-$(CONFIG_USB_KONICAWC)      += usbvideo/
+@@ -130,6 +130,8 @@ obj-$(CONFIG_USB_KONICAWC)      += usbvideo/
  obj-$(CONFIG_USB_VICAM)         += usbvideo/
  obj-$(CONFIG_USB_QUICKCAM_MESSENGER)	+= usbvideo/
  
@@ -38,18 +38,18 @@
 +	If unsure, jump up and down and look confused.
 diff --git a/drivers/media/video/uvcvideo/Makefile b/drivers/media/video/uvcvideo/Makefile
 new file mode 100644
-index 0000000..ada681c
+index 0000000..fe006fb
 --- /dev/null
 +++ b/drivers/media/video/uvcvideo/Makefile
 @@ -0,0 +1,2 @@
 +obj-$(CONFIG_USB_UVCVIDEO)	:= uvcvideo.o
-+uvcvideo-objs   := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o uvc_status.o uvc_isight.o
++uvcvideo-objs	:= uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o uvc_status.o uvc_isight.o
 diff --git a/drivers/media/video/uvcvideo/uvc_compat.h b/drivers/media/video/uvcvideo/uvc_compat.h
 new file mode 100644
-index 0000000..321f3d3
+index 0000000..7152561
 --- /dev/null
 +++ b/drivers/media/video/uvcvideo/uvc_compat.h
-@@ -0,0 +1,263 @@
+@@ -0,0 +1,316 @@
 +#ifndef _UVC_COMPAT_H
 +#define _UVC_COMPAT_H
 +
@@ -191,6 +191,51 @@
 +#define VIDIOC_ENUM_FRAMEINTERVALS	_IOWR ('V', 75, struct v4l2_frmivalenum)
 +#endif
 +
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
++/*
++ * V4L2 Control identifiers.
++ */
++#define V4L2_CTRL_CLASS_CAMERA 0x009A0000	/* Camera class controls */
++ 
++#define V4L2_CID_POWER_LINE_FREQUENCY		(V4L2_CID_BASE+24) 
++enum v4l2_power_line_frequency {
++	V4L2_CID_POWER_LINE_FREQUENCY_DISABLED	= 0,
++	V4L2_CID_POWER_LINE_FREQUENCY_50HZ	= 1,
++	V4L2_CID_POWER_LINE_FREQUENCY_60HZ	= 2,
++};
++
++#define V4L2_CID_HUE_AUTO			(V4L2_CID_BASE+25) 
++#define V4L2_CID_WHITE_BALANCE_TEMPERATURE	(V4L2_CID_BASE+26) 
++#define V4L2_CID_SHARPNESS			(V4L2_CID_BASE+27) 
++#define V4L2_CID_BACKLIGHT_COMPENSATION 	(V4L2_CID_BASE+28) 
++
++#define V4L2_CID_CAMERA_CLASS_BASE 		(V4L2_CTRL_CLASS_CAMERA | 0x900)
++#define V4L2_CID_CAMERA_CLASS 			(V4L2_CTRL_CLASS_CAMERA | 1)
++
++#define V4L2_CID_EXPOSURE_AUTO			(V4L2_CID_CAMERA_CLASS_BASE+1)
++enum  v4l2_exposure_auto_type {
++	V4L2_EXPOSURE_MANUAL = 0,
++	V4L2_EXPOSURE_AUTO = 1,
++	V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
++	V4L2_EXPOSURE_APERTURE_PRIORITY = 3
++};
++#define V4L2_CID_EXPOSURE_ABSOLUTE		(V4L2_CID_CAMERA_CLASS_BASE+2)
++#define V4L2_CID_EXPOSURE_AUTO_PRIORITY		(V4L2_CID_CAMERA_CLASS_BASE+3)
++
++#define V4L2_CID_PAN_RELATIVE			(V4L2_CID_CAMERA_CLASS_BASE+4)
++#define V4L2_CID_TILT_RELATIVE			(V4L2_CID_CAMERA_CLASS_BASE+5)
++#define V4L2_CID_PAN_RESET			(V4L2_CID_CAMERA_CLASS_BASE+6)
++#define V4L2_CID_TILT_RESET			(V4L2_CID_CAMERA_CLASS_BASE+7)
++
++#define V4L2_CID_PAN_ABSOLUTE			(V4L2_CID_CAMERA_CLASS_BASE+8)
++#define V4L2_CID_TILT_ABSOLUTE			(V4L2_CID_CAMERA_CLASS_BASE+9)
++
++#define V4L2_CID_FOCUS_ABSOLUTE			(V4L2_CID_CAMERA_CLASS_BASE+10)
++#define V4L2_CID_FOCUS_RELATIVE			(V4L2_CID_CAMERA_CLASS_BASE+11)
++#define V4L2_CID_FOCUS_AUTO			(V4L2_CID_CAMERA_CLASS_BASE+12)
++ 
++#endif
++
 +#ifdef __KERNEL__
 +
 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
@@ -309,16 +354,24 @@
 +
 +#endif
 +
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
++/*
++ * Linked list API
++ */
++#define list_first_entry(ptr, type, member) \
++	list_entry((ptr)->next, type, member)
++#endif
++
 +#endif /* __KERNEL__ */
 +
 +#endif /* _UVC_COMPAT_H */
 +
 diff --git a/drivers/media/video/uvcvideo/uvc_ctrl.c b/drivers/media/video/uvcvideo/uvc_ctrl.c
 new file mode 100644
-index 0000000..8b7caf9
+index 0000000..dce576b
 --- /dev/null
 +++ b/drivers/media/video/uvcvideo/uvc_ctrl.c
-@@ -0,0 +1,1169 @@
+@@ -0,0 +1,1245 @@
 +/*
 + *      uvcvideo.c  --  USB Video Class driver
 + *
@@ -493,6 +546,14 @@
 +		.flags		= UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
 +				| UVC_CONTROL_RESTORE | UVC_CONTROL_AUTO_UPDATE,
 +	},
++	{
++		.entity		= UVC_GUID_UVC_PROCESSING,
++		.selector	= PU_WHITE_BALANCE_COMPONENT_CONTROL,
++		.index		= 7,
++		.size		= 4,
++		.flags		= UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
++				| UVC_CONTROL_RESTORE | UVC_CONTROL_AUTO_UPDATE,
++	},
 +};
 +
 +static struct uvc_menu_info power_line_frequency_controls[] = {
@@ -644,7 +705,7 @@
 +		.data_type	= UVC_CTRL_DATA_TYPE_UNSIGNED,
 +	},
 +	{
-+		.id		= V4L2_CID_WHITE_BALANCE_TEMPERATURE_AUTO,
++		.id		= V4L2_CID_AUTO_WHITE_BALANCE,
 +		.name		= "White Balance Temperature, Auto",
 +		.entity		= UVC_GUID_UVC_PROCESSING,
 +		.selector	= PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL,
@@ -664,6 +725,36 @@
 +		.data_type	= UVC_CTRL_DATA_TYPE_UNSIGNED,
 +	},
 +	{
++		.id		= V4L2_CID_AUTO_WHITE_BALANCE,
++		.name		= "White Balance Component, Auto",
++		.entity		= UVC_GUID_UVC_PROCESSING,
++		.selector	= PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL,
++		.size		= 1,
++		.offset		= 0,
++		.v4l2_type	= V4L2_CTRL_TYPE_BOOLEAN,
++		.data_type	= UVC_CTRL_DATA_TYPE_BOOLEAN,
++	},
++	{
++		.id		= V4L2_CID_BLUE_BALANCE,
++		.name		= "White Balance Blue Component",
++		.entity		= UVC_GUID_UVC_PROCESSING,
++		.selector	= PU_WHITE_BALANCE_COMPONENT_CONTROL,
++		.size		= 16,
++		.offset		= 0,
++		.v4l2_type	= V4L2_CTRL_TYPE_INTEGER,
++		.data_type	= UVC_CTRL_DATA_TYPE_SIGNED,
++	},
++	{
++		.id		= V4L2_CID_RED_BALANCE,
++		.name		= "White Balance Red Component",
++		.entity		= UVC_GUID_UVC_PROCESSING,
++		.selector	= PU_WHITE_BALANCE_COMPONENT_CONTROL,
++		.size		= 16,
++		.offset		= 16,
++		.v4l2_type	= V4L2_CTRL_TYPE_INTEGER,
++		.data_type	= UVC_CTRL_DATA_TYPE_SIGNED,
++	},
++	{
 +		.id		= V4L2_CID_FOCUS_ABSOLUTE,
 +		.name		= "Focus (absolute)",
 +		.entity		= UVC_GUID_UVC_CAMERA,
@@ -857,6 +948,8 @@
 +{
 +	struct uvc_control *ctrl;
 +	struct uvc_control_mapping *mapping;
++	struct uvc_menu_info *menu;
++	unsigned int i;
 +	__u8 data[8];
 +	int ret;
 +
@@ -879,6 +972,23 @@
 +			return ret;
 +		v4l2_ctrl->default_value = uvc_get_le_value(data, mapping);
 +	}
++
++	if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) {
++		v4l2_ctrl->minimum = 0;
++		v4l2_ctrl->maximum = mapping->menu_count - 1;
++		v4l2_ctrl->step = 1;
++
++		menu = mapping->menu_info;
++		for (i = 0; i < mapping->menu_count; ++i, ++menu) {
++			if (menu->value == v4l2_ctrl->default_value) {
++				v4l2_ctrl->default_value = i;
++				break;
++			}
++		}
++
++		return 0;
++	}
++
 +	if (ctrl->info->flags & UVC_CONTROL_GET_MIN) {
 +		if ((ret = uvc_query_ctrl(video->dev, GET_MIN, ctrl->entity->id,
 +					video->dev->intfnum, ctrl->info->selector,
@@ -1006,6 +1116,8 @@
 +{
 +	struct uvc_control *ctrl;
 +	struct uvc_control_mapping *mapping;
++	struct uvc_menu_info *menu;
++	unsigned int i;
 +	int ret;
 +
 +	ctrl = uvc_find_control(video, xctrl->id, &mapping);
@@ -1027,6 +1139,16 @@
 +	xctrl->value = uvc_get_le_value(
 +		uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), mapping);
 +
++	if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) {
++		menu = mapping->menu_info;
++		for (i = 0; i < mapping->menu_count; ++i, ++menu) {
++			if (menu->value == xctrl->value) {
++				xctrl->value = i;
++				break;
++			}
++		}
++	}
++
 +	return 0;
 +}
 +
@@ -1035,12 +1157,19 @@
 +{
 +	struct uvc_control *ctrl;
 +	struct uvc_control_mapping *mapping;
++	s32 value = xctrl->value;
 +	int ret;
 +
 +	ctrl = uvc_find_control(video, xctrl->id, &mapping);
 +	if (ctrl == NULL || (ctrl->info->flags & UVC_CONTROL_SET_CUR) == 0)
 +		return -EINVAL;
 +
++	if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) {
++		if (value < 0 || value >= mapping->menu_count)
++			return -EINVAL;
++		value = mapping->menu_info[value].value;
++	}
++
 +	if (!ctrl->loaded && (ctrl->info->size * 8) != mapping->size) {
 +		if ((ctrl->info->flags & UVC_CONTROL_GET_CUR) == 0) {
 +			memset(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
@@ -1065,7 +1194,7 @@
 +		       ctrl->info->size);
 +	}
 +
-+	uvc_set_le_value(xctrl->value,
++	uvc_set_le_value(value,
 +		uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), mapping);
 +
 +	ctrl->dirty = 1;
@@ -1490,10 +1619,10 @@
 +
 diff --git a/drivers/media/video/uvcvideo/uvc_driver.c b/drivers/media/video/uvcvideo/uvc_driver.c
 new file mode 100644
-index 0000000..bd194fb
+index 0000000..6acfce1
 --- /dev/null
 +++ b/drivers/media/video/uvcvideo/uvc_driver.c
-@@ -0,0 +1,1877 @@
+@@ -0,0 +1,1920 @@
 +/*
 + *      uvcvideo.c  --  USB Video Class driver
 + *
@@ -1539,10 +1668,16 @@
 +#endif
 +
 +#include "uvcvideo.h"
++#include "version.h"
 +
 +#define DRIVER_AUTHOR		"Laurent Pinchart <laurent.pinchart at skynet.be>"
 +#define DRIVER_DESC		"USB Video Class driver"
-+#define DRIVER_VERSION		"0.1.0"
++#ifndef DRIVER_VERSION
++#define DRIVER_VERSION		"v0.1.0"
++#endif
++
++static unsigned int uvc_quirks_param = 0;
++unsigned int uvc_trace_param = 0;
 +
 +/* ------------------------------------------------------------------------
 + * Control, formats, ...
@@ -1579,6 +1714,16 @@
 +		.guid		= UVC_GUID_FORMAT_UYVY,
 +		.fcc		= V4L2_PIX_FMT_UYVY,
 +	},
++	{
++		.name		= "Greyscale",
++		.guid		= UVC_GUID_FORMAT_Y800,
++		.fcc		= V4L2_PIX_FMT_GREY,
++	},
++	{
++		.name		= "RGB Bayer",
++		.guid		= UVC_GUID_FORMAT_BY8,
++		.fcc		= V4L2_PIX_FMT_SBGGR8,
++	},
 +};
 +
 +#if 0
@@ -2520,8 +2665,9 @@
 +
 +		case VC_PROCESSING_UNIT:
 +			n = buflen >= 8 ? buffer[7] : 0;
++			p = dev->uvc_version >= 0x0110 ? 10 : 9;
 +
-+			if (buflen < 8 + n) {
++			if (buflen < p + n) {
 +				uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
 +				       "interface %d PROCESSING_UNIT error\n", udev->devnum,
 +				       dev->intf->cur_altsetting->desc.bInterfaceNumber);
@@ -2539,7 +2685,8 @@
 +			unit->processing.bControlSize = buffer[7];
 +			unit->processing.bmControls = (__u8*)unit + sizeof *unit;
 +			memcpy(unit->processing.bmControls, &buffer[8], n);
-+			unit->processing.bmVideoStandards = buffer[9+n];
++			if (dev->uvc_version >= 0x0110)
++				unit->processing.bmVideoStandards = buffer[9+n];
 +
 +			if (buffer[8+n] != 0)
 +				usb_string(udev, buffer[8+n], unit->name, sizeof unit->name);
@@ -2919,14 +3066,6 @@
 +	if (vdev == NULL)
 +		return -1;
 +
-+	if (dev->udev->product != NULL)
-+		strncpy(vdev->name, dev->udev->product, sizeof vdev->name);
-+	else
-+		snprintf(vdev->name, sizeof vdev->name,
-+			"UVC Camera (%04x:%04x)",
-+			le16_to_cpu(dev->udev->descriptor.idVendor),
-+			le16_to_cpu(dev->udev->descriptor.idProduct));
-+
 +	/* We already hold a reference to dev->udev. The video device will be
 +	 * unregistered before the reference is released, so we don't need to
 +	 * get another one.
@@ -2937,6 +3076,7 @@
 +	vdev->minor = -1;
 +	vdev->fops = &uvc_fops;
 +	vdev->release = video_device_release;
++	strncpy(vdev->name, dev->name, sizeof vdev->name);
 +
 +	/* Set the driver data before calling video_register_device, otherwise
 +	 * uvc_v4l2_open might race us.
@@ -3030,7 +3170,15 @@
 +	dev->udev = usb_get_dev(udev);
 +	dev->intf = usb_get_intf(intf);
 +	dev->intfnum = intf->cur_altsetting->desc.bInterfaceNumber;
-+	dev->quirks = id->driver_info;
++	dev->quirks = id->driver_info | uvc_quirks_param;
++
++	if (udev->product != NULL)
++		strncpy(dev->name, udev->product, sizeof dev->name);
++	else
++		snprintf(dev->name, sizeof dev->name,
++			"UVC Camera (%04x:%04x)",
++			le16_to_cpu(udev->descriptor.idVendor),
++			le16_to_cpu(udev->descriptor.idProduct));
 +
 +	/* Parse the Video Class control descriptor */
 +	if (uvc_parse_control(dev) < 0) {
@@ -3044,6 +3192,13 @@
 +		le16_to_cpu(udev->descriptor.idVendor),
 +		le16_to_cpu(udev->descriptor.idProduct));
 +
++	if (uvc_quirks_param != 0) {
++		uvc_printk(KERN_INFO, "Forcing device quirks 0x%x by module "
++			"parameter for testing purpose.\n", uvc_quirks_param);
++		uvc_printk(KERN_INFO, "Please report required quirks to the "
++			"linux-uvc-devel mailing list.\n");
++	}
++
 +	/* Initialize controls */
 +	if (uvc_ctrl_init_device(dev) < 0)
 +		goto error;
@@ -3213,14 +3368,6 @@
 +	  .bInterfaceClass	= USB_CLASS_VENDOR_SPEC,
 +	  .bInterfaceSubClass	= 1,
 +	  .bInterfaceProtocol	= 0 },
-+	/* Logitech Quickcam Communicator */
-+	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
-+				| USB_DEVICE_ID_MATCH_INT_INFO,
-+	  .idVendor		= 0x046d,
-+	  .idProduct		= 0x08d7,
-+	  .bInterfaceClass	= USB_CLASS_VENDOR_SPEC,
-+	  .bInterfaceSubClass	= 1,
-+	  .bInterfaceProtocol	= 0 },
 +	/* Logitech Quickcam OEM Dell Notebook */
 +	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
 +				| USB_DEVICE_ID_MATCH_INT_INFO,
@@ -3238,11 +3385,24 @@
 +	  .bInterfaceSubClass	= 1,
 +	  .bInterfaceProtocol	= 0 },
 +	/* Apple Built-In iSight */
-+	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE,
++	{ .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
++				| USB_DEVICE_ID_MATCH_INT_INFO,
 +	  .idVendor		= 0x05ac,
 +	  .idProduct		= 0x8501,
++	  .bInterfaceClass      = USB_CLASS_VIDEO,
++	  .bInterfaceSubClass   = 1,
++	  .bInterfaceProtocol   = 0,
 +	  .driver_info 		= UVC_QUIRK_PROBE_MINMAX
 +	                        | UVC_QUIRK_BUILTIN_ISIGHT },
++	/* Genesys Logic USB 2.0 PC Camera */
++	{ .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
++				| USB_DEVICE_ID_MATCH_INT_INFO,
++	  .idVendor             = 0x05e3,
++	  .idProduct            = 0x0505,
++	  .bInterfaceClass      = USB_CLASS_VIDEO,
++	  .bInterfaceSubClass   = 1,
++	  .bInterfaceProtocol   = 0,
++	  .driver_info          = UVC_QUIRK_STREAM_NO_FID },
 +	/* Silicon Motion SM371 */
 +	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
 +				| USB_DEVICE_ID_MATCH_INT_INFO,
@@ -3297,6 +3457,15 @@
 +	  .bInterfaceSubClass	= 1,
 +	  .bInterfaceProtocol	= 0,
 +	  .driver_info		= UVC_QUIRK_PROBE_MINMAX },
++	/* Packard Bell OEM Webcam */
++	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
++				| USB_DEVICE_ID_MATCH_INT_INFO,
++	  .idVendor		= 0x5986,
++	  .idProduct		= 0x0101,
++	  .bInterfaceClass	= USB_CLASS_VIDEO,
++	  .bInterfaceSubClass	= 1,
++	  .bInterfaceProtocol	= 0,
++	  .driver_info		= UVC_QUIRK_PROBE_MINMAX },
 +	/* Acer Crystal Eye webcam */
 +	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
 +				| USB_DEVICE_ID_MATCH_INT_INFO,
@@ -3352,7 +3521,7 @@
 +
 +	result = usb_register(&uvc_driver.driver);
 +	if (result == 0)
-+		printk(KERN_INFO DRIVER_DESC " (v" DRIVER_VERSION ")\n");
++		printk(KERN_INFO DRIVER_DESC " (" DRIVER_VERSION ")\n");
 +	return result;
 +}
 +
@@ -3364,12 +3533,15 @@
 +module_init(uvc_init);
 +module_exit(uvc_cleanup);
 +
-+unsigned int uvc_trace_param = 0;
++module_param_named(quirks, uvc_quirks_param, uint, S_IRUGO|S_IWUSR);
++MODULE_PARM_DESC(quirks, "Forced device quirks");
 +module_param_named(trace, uvc_trace_param, uint, S_IRUGO|S_IWUSR);
++MODULE_PARM_DESC(trace, "Trace level bitmask");
 +
 +MODULE_AUTHOR(DRIVER_AUTHOR);
 +MODULE_DESCRIPTION(DRIVER_DESC);
 +MODULE_LICENSE("GPL");
++MODULE_VERSION(DRIVER_VERSION);
 +
 diff --git a/drivers/media/video/uvcvideo/uvc_isight.c b/drivers/media/video/uvcvideo/uvc_isight.c
 new file mode 100644
@@ -3519,10 +3691,10 @@
 +}
 diff --git a/drivers/media/video/uvcvideo/uvc_queue.c b/drivers/media/video/uvcvideo/uvc_queue.c
 new file mode 100644
-index 0000000..4957109
+index 0000000..d7e4461
 --- /dev/null
 +++ b/drivers/media/video/uvcvideo/uvc_queue.c
-@@ -0,0 +1,414 @@
+@@ -0,0 +1,463 @@
 +/*
 + *      uvcvideo.c  --  USB Video Class driver
 + *
@@ -3705,7 +3877,7 @@
 +	return 0;
 +}
 +
-+void uvc_query_buffer(struct uvc_buffer *buf,
++static void __uvc_query_buffer(struct uvc_buffer *buf,
 +		struct v4l2_buffer *v4l2_buf)
 +{
 +	memcpy(v4l2_buf, &buf->buf, sizeof *v4l2_buf);
@@ -3728,6 +3900,24 @@
 +	}
 +}
 +
++int uvc_query_buffer(struct uvc_video_queue *queue,
++		struct v4l2_buffer *v4l2_buf)
++{
++	int ret = 0;
++
++	mutex_lock(&queue->mutex);
++	if (v4l2_buf->index >= queue->count) {
++		ret = -EINVAL;
++		goto done;
++	}
++
++	__uvc_query_buffer(&queue->buffer[v4l2_buf->index], v4l2_buf);
++
++done:
++       mutex_unlock(&queue->mutex);
++       return ret;
++}
++
 +/*
 + * Queue a video buffer. Attempting to queue a buffer that has already been
 + * queued will return -EINVAL.
@@ -3813,11 +4003,13 @@
 +		goto done;
 +	}
 +
-+	buf = list_entry(queue->mainqueue.next, struct uvc_buffer, stream);
-+	uvc_trace(UVC_TRACE_CAPTURE, "Dequeuing buffer %u.\n", buf->buf.index);
++	buf = list_first_entry(&queue->mainqueue, struct uvc_buffer, stream);
 +	if ((ret = uvc_queue_waiton(buf, nonblocking)) < 0)
 +		goto done;
 +
++	uvc_trace(UVC_TRACE_CAPTURE, "Dequeuing buffer %u (%u, %u bytes).\n",
++		buf->buf.index, buf->state, buf->buf.bytesused);
++
 +	switch (buf->state) {
 +	case UVC_BUF_STATE_ERROR:
 +		uvc_trace(UVC_TRACE_CAPTURE, "[W] Corrupted data "
@@ -3838,7 +4030,7 @@
 +	}
 +
 +	list_del(&buf->stream);
-+	uvc_query_buffer(buf, v4l2_buf);
++	__uvc_query_buffer(buf, v4l2_buf);
 +
 +done:
 +	mutex_unlock(&queue->mutex);
@@ -3846,6 +4038,35 @@
 +}
 +
 +/*
++ * Poll the video queue.
++ *
++ * This function implements video queue polling and is intended to be used by
++ * the device poll handler.
++ */
++unsigned int uvc_queue_poll(struct uvc_video_queue *queue, struct file *file,
++		poll_table *wait)
++{
++	struct uvc_buffer *buf;
++	unsigned int mask = 0;
++
++	mutex_lock(&queue->mutex);
++	if (list_empty(&queue->mainqueue)) {
++		mask |= POLLERR;
++		goto done;
++	}
++	buf = list_first_entry(&queue->mainqueue, struct uvc_buffer, stream);
++
++	poll_wait(file, &buf->wait, wait);
++	if (buf->state == UVC_BUF_STATE_DONE ||
++	    buf->state == UVC_BUF_STATE_ERROR)
++		mask |= POLLIN | POLLRDNORM;
++
++done:
++	mutex_unlock(&queue->mutex);
++	return mask;
++}
++
++/*
 + * Enable or disable the video buffers queue.
 + *
 + * The queue must be enabled before starting video acquisition and must be
@@ -3907,7 +4128,7 @@
 +
 +	spin_lock_irqsave(&queue->irqlock, flags);
 +	while (!list_empty(&queue->irqqueue)) {
-+		buf = list_entry(queue->irqqueue.next, struct uvc_buffer, queue);
++		buf = list_first_entry(&queue->irqqueue, struct uvc_buffer, queue);
 +		list_del(&buf->queue);
 +		buf->state = UVC_BUF_STATE_ERROR;
 +		wake_up(&buf->wait);
@@ -3924,7 +4145,7 @@
 +	spin_lock_irqsave(&queue->irqlock, flags);
 +	list_del(&buf->queue);
 +	if (!list_empty(&queue->irqqueue))
-+		nextbuf = list_entry(queue->irqqueue.next, struct uvc_buffer,
++		nextbuf = list_first_entry(&queue->irqqueue, struct uvc_buffer,
 +					queue);
 +	else
 +		nextbuf = NULL;
@@ -3939,10 +4160,10 @@
 +
 diff --git a/drivers/media/video/uvcvideo/uvc_status.c b/drivers/media/video/uvcvideo/uvc_status.c
 new file mode 100644
-index 0000000..a944152
+index 0000000..4be8de4
 --- /dev/null
 +++ b/drivers/media/video/uvcvideo/uvc_status.c
-@@ -0,0 +1,153 @@
+@@ -0,0 +1,220 @@
 +/*
 + *      uvc_status.c  --  USB Video Class driver
 + *
@@ -3957,10 +4178,72 @@
 + */
 +
 +#include <linux/kernel.h>
++#include <linux/version.h>
++#include <linux/input.h>
 +#include <linux/usb.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
++#include <linux/usb_input.h>
++#else
++#include <linux/usb/input.h>
++#endif
 +
 +#include "uvcvideo.h"
 +
++/* --------------------------------------------------------------------------
++ * Input device
++ */
++static int uvc_input_init(struct uvc_device *dev)
++{
++	struct usb_device *udev = dev->udev;
++	struct input_dev *input;
++	char *phys = NULL;
++	int ret;
++
++	input = input_allocate_device();
++	if (input == NULL)
++		return -ENOMEM;
++
++	phys = kmalloc(6 + strlen(udev->bus->bus_name) + strlen(udev->devpath),
++			GFP_KERNEL);
++	if (phys == NULL) {
++		ret = -ENOMEM;
++		goto error;
++	}
++	sprintf(phys, "usb-%s-%s", udev->bus->bus_name, udev->devpath);
++
++	input->name = dev->name;
++	input->phys = phys;
++	usb_to_input_id(udev, &input->id);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
++	input->dev.parent = &dev->intf->dev;
++#else
++	input->cdev.dev = &dev->intf->dev;
++#endif
++
++	set_bit(EV_KEY, input->evbit);
++	set_bit(BTN_0, input->keybit);
++
++	if ((ret = input_register_device(input)) < 0)
++		goto error;
++
++	dev->input = input;
++	return 0;
++
++error:
++	input_free_device(input);
++	kfree(phys);
++	return ret;
++}
++
++static void uvc_input_cleanup(struct uvc_device *dev)
++{
++	if (dev->input)
++		input_unregister_device(dev->input);
++}
++
++/* --------------------------------------------------------------------------
++ * Status interrupt endpoint
++ */
 +static void uvc_event_streaming(struct uvc_device *dev, __u8 *data, int len)
 +{
 +	if (len < 3) {
@@ -3974,6 +4257,8 @@
 +			return;
 +		uvc_trace(UVC_TRACE_STATUS, "Button (intf %u) %s len %d\n",
 +			data[1], data[3] ? "pressed" : "released", len);
++		if (dev->input)
++			input_report_key(dev->input, BTN_0, data[3]);
 +	} else {
 +		uvc_trace(UVC_TRACE_STATUS, "Stream %u error event %02x %02x "
 +			"len %d.\n", data[1], data[2], data[3], len);
@@ -4055,6 +4340,8 @@
 +	if (ep == NULL)
 +		return 0;
 +
++	uvc_input_init(dev);
++
 +	dev->int_urb = usb_alloc_urb(0, GFP_KERNEL);
 +	if (dev->int_urb == NULL)
 +		return -ENOMEM;
@@ -4080,6 +4367,7 @@
 +{
 +	usb_kill_urb(dev->int_urb);
 +	usb_free_urb(dev->int_urb);
++	uvc_input_cleanup(dev);
 +}
 +
 +int uvc_status_suspend(struct uvc_device *dev)
@@ -4098,10 +4386,10 @@
 +
 diff --git a/drivers/media/video/uvcvideo/uvc_v4l2.c b/drivers/media/video/uvcvideo/uvc_v4l2.c
 new file mode 100644
-index 0000000..fcd2c6e
+index 0000000..c335758
 --- /dev/null
 +++ b/drivers/media/video/uvcvideo/uvc_v4l2.c
-@@ -0,0 +1,1112 @@
+@@ -0,0 +1,1087 @@
 +/*
 + *      uvcvideo.c  --  USB Video Class driver
 + *
@@ -4150,22 +4438,17 @@
 +	struct uvc_menu_info *menu_info;
 +	struct uvc_control_mapping *mapping;
 +	struct uvc_control *ctrl;
-+	__u32 i;
 +
 +	ctrl = uvc_find_control(video, query_menu->id, &mapping);
 +	if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU)
 +		return -EINVAL;
 +
-+	menu_info = mapping->menu_info;
-+
-+	for (i = 0; i < mapping->menu_count; ++i, ++menu_info) {
-+		if (query_menu->index == menu_info->index) {
-+			strncpy(query_menu->name, menu_info->name, 32);
-+			return 0;
-+		}
-+	}
++	if (query_menu->index >= mapping->menu_count)
++		return -EINVAL;
 +
-+	return -EINVAL;
++	menu_info = &mapping->menu_info[query_menu->index];
++	strncpy(query_menu->name, menu_info->name, 32);
++	return 0;
 +}
 +
 +/*
@@ -4706,7 +4989,7 @@
 +		if (selector == NULL) {
 +			if (index != 0)
 +				return -EINVAL;
-+			iterm = list_entry(video->iterms.next,
++			iterm = list_first_entry(&video->iterms,
 +					struct uvc_entity, chain);
 +			pin = iterm->id;
 +		} else if (pin < selector->selector.bNrInPins) {
@@ -4949,19 +5232,15 @@
 +	case VIDIOC_QUERYBUF:
 +	{
 +		struct v4l2_buffer *buf = arg;
-+		struct uvc_buffer *ubuf;
 +
-+		if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
-+		    buf->index >= video->queue.count)
++		if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
 +			return -EINVAL;
 +
 +		if (!uvc_has_privileges(handle))
 +			return -EBUSY;
 +
-+		ubuf = &video->queue.buffer[buf->index];
-+		uvc_query_buffer(ubuf, buf);
++		return uvc_query_buffer(&video->queue, buf);
 +	}
-+		break;
 +
 +	case VIDIOC_QBUF:
 +		if (!uvc_has_privileges(handle))
@@ -5178,26 +5457,10 @@
 +{
 +	struct video_device *vdev = video_devdata(file);
 +	struct uvc_video_device *video = video_get_drvdata(vdev);
-+	struct uvc_buffer *buf;
-+	unsigned int mask = 0;
 +
 +	uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_poll\n");
 +
-+	mutex_lock(&video->queue.mutex);
-+	if (list_empty(&video->queue.mainqueue)) {
-+		mask |= POLLERR;
-+		goto done;
-+	}
-+	buf = list_entry(video->queue.mainqueue.next, struct uvc_buffer, stream);
-+
-+	poll_wait(file, &buf->wait, wait);
-+	if (buf->state == UVC_BUF_STATE_DONE ||
-+	    buf->state == UVC_BUF_STATE_ERROR)
-+		mask |= POLLIN | POLLRDNORM;
-+
-+done:
-+	mutex_unlock(&video->queue.mutex);
-+	return mask;
++	return uvc_queue_poll(&video->queue, file, wait);
 +}
 +
 +struct file_operations uvc_fops = {
@@ -5216,10 +5479,10 @@
 +
 diff --git a/drivers/media/video/uvcvideo/uvc_video.c b/drivers/media/video/uvcvideo/uvc_video.c
 new file mode 100644
-index 0000000..2f33732
+index 0000000..cb89a7a
 --- /dev/null
 +++ b/drivers/media/video/uvcvideo/uvc_video.c
-@@ -0,0 +1,913 @@
+@@ -0,0 +1,922 @@
 +/*
 + *      uvcvideo.c  --  USB Video Class driver
 + *
@@ -5242,6 +5505,7 @@
 +#include <linux/vmalloc.h>
 +#include <linux/wait.h>
 +#include <asm/atomic.h>
++#include <asm/unaligned.h>
 +
 +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
 +#include <media/v4l2-common.h>
@@ -5309,11 +5573,14 @@
 +	ctrl->wCompQuality = le16_to_cpup((__le16*)&data[12]);
 +	ctrl->wCompWindowSize = le16_to_cpup((__le16*)&data[14]);
 +	ctrl->wDelay = le16_to_cpup((__le16*)&data[16]);
-+	ctrl->dwMaxVideoFrameSize = le32_to_cpup((__le32*)&data[18]);
-+	ctrl->dwMaxPayloadTransferSize = le32_to_cpup((__le32*)&data[22]);
++	ctrl->dwMaxVideoFrameSize =
++		le32_to_cpu(get_unaligned((__le32*)&data[18]));
++	ctrl->dwMaxPayloadTransferSize =
++		le32_to_cpu(get_unaligned((__le32*)&data[22]));
 +
 +	if (size == 34) {
-+		ctrl->dwClockFrequency = le32_to_cpup((__le32*)&data[26]);
++		ctrl->dwClockFrequency =
++			le32_to_cpu(get_unaligned((__le32*)&data[26]));
 +		ctrl->bmFramingInfo = data[30];
 +		ctrl->bPreferedVersion = data[31];
 +		ctrl->bMinVersion = data[32];
@@ -5335,9 +5602,11 @@
 +		struct uvc_format *format = NULL;
 +		struct uvc_frame *frame = NULL;
 +
-+		if (ctrl->bFormatIndex <= video->streaming->nformats)
++		if (ctrl->bFormatIndex <= video->streaming->nformats &&
++		    ctrl->bFormatIndex != 0)
 +			format = &video->streaming->format[ctrl->bFormatIndex - 1];
-+		if (format && ctrl->bFrameIndex <= format->nframes) {
++		if (format && ctrl->bFrameIndex <= format->nframes &&
++		    ctrl->bFrameIndex != 0) {
 +			frame = &format->frame[ctrl->bFrameIndex - 1];
 +			ctrl->dwMaxVideoFrameSize = frame->dwMaxVideoFrameBufferSize;
 +		}
@@ -5367,11 +5636,14 @@
 +	/* Note: Some of the fields below are not required for IN devices (see
 +	 * UVC spec, 4.3.1.1), but we still copy them in case support for OUT
 +	 * devices is added in the future. */
-+	*(__le32*)&data[18] = cpu_to_le32(ctrl->dwMaxVideoFrameSize);
-+	*(__le32*)&data[22] = cpu_to_le32(ctrl->dwMaxPayloadTransferSize);
++	put_unaligned(cpu_to_le32(ctrl->dwMaxVideoFrameSize),
++		(__le32*)&data[18]);
++	put_unaligned(cpu_to_le32(ctrl->dwMaxPayloadTransferSize),
++		(__le32*)&data[22]);
 +
 +	if (size == 34) {
-+		*(__le32*)&data[26] = cpu_to_le32(ctrl->dwClockFrequency);
++		put_unaligned(cpu_to_le32(ctrl->dwClockFrequency),
++			(__le32*)&data[26]);
 +		data[30] = ctrl->bmFramingInfo;
 +		data[31] = ctrl->bPreferedVersion;
 +		data[32] = ctrl->bMinVersion;
@@ -5744,7 +6016,7 @@
 +
 +	spin_lock_irqsave(&queue->irqlock, flags);
 +	if (!list_empty(&queue->irqqueue))
-+		buf = list_entry(queue->irqqueue.next, struct uvc_buffer, queue);
++		buf = list_first_entry(&queue->irqqueue, struct uvc_buffer, queue);
 +	spin_unlock_irqrestore(&queue->irqlock, flags);
 +
 +	video->decode(urb, video, buf);
@@ -6135,10 +6407,10 @@
 +
 diff --git a/drivers/media/video/uvcvideo/uvcvideo.h b/drivers/media/video/uvcvideo/uvcvideo.h
 new file mode 100644
-index 0000000..73b2146
+index 0000000..fb755c2
 --- /dev/null
 +++ b/drivers/media/video/uvcvideo/uvcvideo.h
-@@ -0,0 +1,787 @@
+@@ -0,0 +1,771 @@
 +#ifndef _USB_VIDEO_H_
 +#define _USB_VIDEO_H_
 +
@@ -6149,32 +6421,6 @@
 +#include "uvc_compat.h"
 +
 +/*
-+ * Private V4L2 control identifiers.
-+ */
-+
-+#define V4L2_CID_BACKLIGHT_COMPENSATION		(V4L2_CID_PRIVATE_BASE+0)
-+#define V4L2_CID_POWER_LINE_FREQUENCY		(V4L2_CID_PRIVATE_BASE+1)
-+#define V4L2_CID_SHARPNESS			(V4L2_CID_PRIVATE_BASE+2)
-+#define V4L2_CID_HUE_AUTO			(V4L2_CID_PRIVATE_BASE+3)
-+
-+#define V4L2_CID_FOCUS_AUTO			(V4L2_CID_PRIVATE_BASE+4)
-+#define V4L2_CID_FOCUS_ABSOLUTE			(V4L2_CID_PRIVATE_BASE+5)
-+#define V4L2_CID_FOCUS_RELATIVE			(V4L2_CID_PRIVATE_BASE+6)
-+
-+#define V4L2_CID_PAN_RELATIVE			(V4L2_CID_PRIVATE_BASE+7)
-+#define V4L2_CID_TILT_RELATIVE			(V4L2_CID_PRIVATE_BASE+8)
-+#define V4L2_CID_PANTILT_RESET			(V4L2_CID_PRIVATE_BASE+9)
-+
-+#define V4L2_CID_EXPOSURE_AUTO			(V4L2_CID_PRIVATE_BASE+10)
-+#define V4L2_CID_EXPOSURE_ABSOLUTE		(V4L2_CID_PRIVATE_BASE+11)
-+#define V4L2_CID_EXPOSURE_AUTO_PRIORITY		(V4L2_CID_PRIVATE_BASE+14)
-+
-+#define V4L2_CID_WHITE_BALANCE_TEMPERATURE_AUTO	(V4L2_CID_PRIVATE_BASE+12)
-+#define V4L2_CID_WHITE_BALANCE_TEMPERATURE	(V4L2_CID_PRIVATE_BASE+13)
-+
-+#define V4L2_CID_PRIVATE_LAST			V4L2_CID_EXPOSURE_AUTO_PRIORITY
-+
-+/*
 + * Dynamic controls
 + */
 +/* Data types for UVC control data */
@@ -6236,6 +6482,8 @@
 +
 +#ifdef __KERNEL__
 +
++#include <linux/poll.h>
++
 +/* --------------------------------------------------------------------------
 + * UVC constants
 + */
@@ -6434,6 +6682,10 @@
 +				 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
 +#define UVC_GUID_FORMAT_UYVY	{ 'U',  'Y',  'V',  'Y', 0x00, 0x00, 0x10, 0x00, \
 +				 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
++#define UVC_GUID_FORMAT_Y800	{ 'Y',  '8',  '0',  '0', 0x00, 0x00, 0x10, 0x00, \
++				 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
++#define UVC_GUID_FORMAT_BY8	{ 'B',  'Y',  '8',  ' ', 0x00, 0x00, 0x10, 0x00, \
++				 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
 +
 +
 +/* ------------------------------------------------------------------------
@@ -6494,7 +6746,7 @@
 +};
 +
 +struct uvc_menu_info {
-+	__u32 index;
++	__u32 value;
 +	__u8 name[32];
 +};
 +
@@ -6705,8 +6957,8 @@
 +	unsigned int count;
 +	unsigned int buf_size;
 +	struct uvc_buffer buffer[UVC_MAX_VIDEO_BUFFERS];
-+	struct mutex mutex;
-+	spinlock_t irqlock;
++	struct mutex mutex;	/* protects buffers and mainqueue */
++	spinlock_t irqlock;	/* protects irqqueue */
 +
 +	struct list_head mainqueue;
 +	struct list_head irqqueue;
@@ -6756,6 +7008,7 @@
 +	struct usb_interface *intf;
 +	__u32 quirks;
 +	int intfnum;
++	char name[32];
 +
 +	enum uvc_device_state state;
 +	struct kref kref;
@@ -6773,6 +7026,7 @@
 +	struct usb_host_endpoint *int_ep;
 +	struct urb *int_urb;
 +	__u8 status[16];
++	struct input_dev *input;
 +
 +	/* Video Streaming interfaces */
 +	struct list_head streaming;
@@ -6846,7 +7100,7 @@
 +extern int uvc_alloc_buffers(struct uvc_video_queue *queue,
 +		unsigned int nbuffers, unsigned int buflength);
 +extern int uvc_free_buffers(struct uvc_video_queue *queue);
-+extern void uvc_query_buffer(struct uvc_buffer *buf,
++extern int uvc_query_buffer(struct uvc_video_queue *queue,
 +		struct v4l2_buffer *v4l2_buf);
 +extern int uvc_queue_buffer(struct uvc_video_queue *queue,
 +		struct v4l2_buffer *v4l2_buf);
@@ -6856,6 +7110,8 @@
 +extern void uvc_queue_cancel(struct uvc_video_queue *queue);
 +extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
 +		struct uvc_buffer *buf);
++extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
++		struct file *file, poll_table *wait);
 +
 +/* V4L2 interface */
 +extern struct file_operations uvc_fops;
@@ -6926,3 +7182,10 @@
 +
 +#endif
 +
+diff --git a/drivers/media/video/uvcvideo/version.h b/drivers/media/video/uvcvideo/version.h
+new file mode 100644
+index 0000000..503c00c
+--- /dev/null
++++ b/drivers/media/video/uvcvideo/version.h
+@@ -0,0 +1 @@
++#define	DRIVER_VERSION	"SVN r200"

linux-2.6-wireless-pending.patch:

View full diff with command:
/usr/bin/cvs -f diff  -kk -u -N -r 1.4 -r 1.5 linux-2.6-wireless-pending.patch
Index: linux-2.6-wireless-pending.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/linux-2.6-wireless-pending.patch,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- linux-2.6-wireless-pending.patch	2 Apr 2008 08:55:25 -0000	1.4
+++ linux-2.6-wireless-pending.patch	14 Apr 2008 16:06:53 -0000	1.5
@@ -5468,8 +5468,8 @@
     Signed-off-by: John W. Linville <linville at tuxdriver.com>
 
 diff -up linux-2.6.24.noarch/include/linux/nl80211.h.orig linux-2.6.24.noarch/include/linux/nl80211.h
---- linux-2.6.24.noarch/include/linux/nl80211.h.orig	2008-04-01 20:38:38.000000000 -0400
-+++ linux-2.6.24.noarch/include/linux/nl80211.h	2008-04-01 20:48:57.000000000 -0400
+--- linux-2.6.24.noarch/include/linux/nl80211.h.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/include/linux/nl80211.h	2008-04-08 00:15:32.000000000 -0400
 @@ -78,6 +78,18 @@
   *	or, if no MAC address given, all stations, on the interface identified
   *	by %NL80211_ATTR_IFINDEX.
@@ -5749,8 +5749,8 @@
  
  #endif /* __LINUX_NL80211_H */
 diff -up linux-2.6.24.noarch/include/linux/wireless.h.orig linux-2.6.24.noarch/include/linux/wireless.h
---- linux-2.6.24.noarch/include/linux/wireless.h.orig	2008-04-01 20:38:38.000000000 -0400
-+++ linux-2.6.24.noarch/include/linux/wireless.h	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/include/linux/wireless.h.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/include/linux/wireless.h	2008-04-08 00:15:32.000000000 -0400
 @@ -455,6 +455,7 @@
  #define IW_MODE_REPEAT	4	/* Wireless Repeater (forwarder) */
  #define IW_MODE_SECOND	5	/* Secondary master/repeater (backup) */
@@ -5760,8 +5760,8 @@
  /* Statistics flags (bitmask in updated) */
  #define IW_QUAL_QUAL_UPDATED	0x01	/* Value was updated since last read */
 diff -up linux-2.6.24.noarch/include/linux/ieee80211.h.orig linux-2.6.24.noarch/include/linux/ieee80211.h
---- linux-2.6.24.noarch/include/linux/ieee80211.h.orig	2008-04-01 20:38:38.000000000 -0400
-+++ linux-2.6.24.noarch/include/linux/ieee80211.h	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/include/linux/ieee80211.h.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/include/linux/ieee80211.h	2008-04-08 00:15:32.000000000 -0400
 @@ -97,6 +97,7 @@
  #define IEEE80211_MAX_FRAME_LEN		2352
  
@@ -5826,8 +5826,8 @@
  	WLAN_EID_PWR_CONSTRAINT = 32,
  	WLAN_EID_PWR_CAPABILITY = 33,
 diff -up linux-2.6.24.noarch/include/linux/ssb/ssb_driver_chipcommon.h.orig linux-2.6.24.noarch/include/linux/ssb/ssb_driver_chipcommon.h
---- linux-2.6.24.noarch/include/linux/ssb/ssb_driver_chipcommon.h.orig	2008-04-01 20:38:38.000000000 -0400
-+++ linux-2.6.24.noarch/include/linux/ssb/ssb_driver_chipcommon.h	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/include/linux/ssb/ssb_driver_chipcommon.h.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/include/linux/ssb/ssb_driver_chipcommon.h	2008-04-08 00:15:32.000000000 -0400
 @@ -390,6 +390,10 @@ extern void ssb_chipco_set_clockmode(str
  extern void ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc,
  					  u32 ticks);
@@ -5840,8 +5840,8 @@
  u32 ssb_chipco_gpio_in(struct ssb_chipcommon *cc, u32 mask);
  u32 ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value);
 diff -up /dev/null linux-2.6.24.noarch/include/linux/ssb/ssb_driver_gige.h
---- /dev/null	2008-04-01 10:36:34.721293558 -0400
-+++ linux-2.6.24.noarch/include/linux/ssb/ssb_driver_gige.h	2008-04-01 20:48:58.000000000 -0400
+--- /dev/null	2008-04-08 00:00:49.269005103 -0400
++++ linux-2.6.24.noarch/include/linux/ssb/ssb_driver_gige.h	2008-04-08 00:15:32.000000000 -0400
 @@ -0,0 +1,174 @@
 +#ifndef LINUX_SSB_DRIVER_GIGE_H_
 +#define LINUX_SSB_DRIVER_GIGE_H_
@@ -6018,8 +6018,8 @@
 +#endif /* CONFIG_SSB_DRIVER_GIGE */
 +#endif /* LINUX_SSB_DRIVER_GIGE_H_ */
 diff -up linux-2.6.24.noarch/include/linux/ssb/ssb_driver_pci.h.orig linux-2.6.24.noarch/include/linux/ssb/ssb_driver_pci.h
---- linux-2.6.24.noarch/include/linux/ssb/ssb_driver_pci.h.orig	2008-04-01 20:38:38.000000000 -0400
-+++ linux-2.6.24.noarch/include/linux/ssb/ssb_driver_pci.h	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/include/linux/ssb/ssb_driver_pci.h.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/include/linux/ssb/ssb_driver_pci.h	2008-04-08 00:15:32.000000000 -0400
 @@ -1,6 +1,11 @@
  #ifndef LINUX_SSB_PCICORE_H_
  #define LINUX_SSB_PCICORE_H_
@@ -6060,8 +6060,8 @@
  #endif /* CONFIG_SSB_DRIVER_PCICORE */
  #endif /* LINUX_SSB_PCICORE_H_ */
 diff -up linux-2.6.24.noarch/include/linux/ssb/ssb.h.orig linux-2.6.24.noarch/include/linux/ssb/ssb.h
---- linux-2.6.24.noarch/include/linux/ssb/ssb.h.orig	2008-04-01 20:38:38.000000000 -0400
-+++ linux-2.6.24.noarch/include/linux/ssb/ssb.h	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/include/linux/ssb/ssb.h.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/include/linux/ssb/ssb.h	2008-04-08 00:15:32.000000000 -0400
 @@ -72,8 +72,10 @@ struct ssb_device;
  /* Lowlevel read/write operations on the device MMIO.
   * Internal, don't use that outside of ssb. */
@@ -6121,8 +6121,8 @@
  
  #endif /* LINUX_SSB_H_ */
 diff -up linux-2.6.24.noarch/include/net/wireless.h.orig linux-2.6.24.noarch/include/net/wireless.h
---- linux-2.6.24.noarch/include/net/wireless.h.orig	2008-01-24 17:58:37.000000000 -0500
-+++ linux-2.6.24.noarch/include/net/wireless.h	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/include/net/wireless.h.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/include/net/wireless.h	2008-04-08 00:15:32.000000000 -0400
 @@ -13,6 +13,162 @@
  #include <net/cfg80211.h>
  
@@ -6329,8 +6329,8 @@
 +}
  #endif /* __NET_WIRELESS_H */
 diff -up linux-2.6.24.noarch/include/net/cfg80211.h.orig linux-2.6.24.noarch/include/net/cfg80211.h
---- linux-2.6.24.noarch/include/net/cfg80211.h.orig	2008-04-01 20:38:39.000000000 -0400
-+++ linux-2.6.24.noarch/include/net/cfg80211.h	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/include/net/cfg80211.h.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/include/net/cfg80211.h	2008-04-08 00:15:32.000000000 -0400
 @@ -12,6 +12,16 @@
   * Copyright 2006, 2007	Johannes Berg <johannes at sipsolutions.net>
   */
@@ -6552,8 +6552,8 @@
  
  #endif /* __NET_CFG80211_H */
 diff -up linux-2.6.24.noarch/include/net/ieee80211.h.orig linux-2.6.24.noarch/include/net/ieee80211.h
---- linux-2.6.24.noarch/include/net/ieee80211.h.orig	2008-04-01 20:38:39.000000000 -0400
-+++ linux-2.6.24.noarch/include/net/ieee80211.h	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/include/net/ieee80211.h.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/include/net/ieee80211.h	2008-04-08 00:15:32.000000000 -0400
 @@ -183,7 +183,6 @@ const char *escape_essid(const char *ess
  #define IEEE80211_DEBUG_RX(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
  #define IEEE80211_DEBUG_QOS(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
@@ -6563,8 +6563,8 @@
  
  #ifndef WIRELESS_SPY
 diff -up linux-2.6.24.noarch/include/net/mac80211.h.orig linux-2.6.24.noarch/include/net/mac80211.h
---- linux-2.6.24.noarch/include/net/mac80211.h.orig	2008-04-01 20:38:39.000000000 -0400
-+++ linux-2.6.24.noarch/include/net/mac80211.h	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/include/net/mac80211.h.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/include/net/mac80211.h	2008-04-08 00:15:32.000000000 -0400
 @@ -38,7 +38,11 @@
   * called in hardware interrupt context. The low-level driver must not call any
   * other functions in hardware interrupt context. If there is a need for such
@@ -7413,8 +7413,8 @@
 +
  #endif /* MAC80211_H */
 diff -up linux-2.6.24.noarch/include/net/ieee80211softmac.h.orig linux-2.6.24.noarch/include/net/ieee80211softmac.h
---- linux-2.6.24.noarch/include/net/ieee80211softmac.h.orig	2008-01-24 17:58:37.000000000 -0500
-+++ linux-2.6.24.noarch/include/net/ieee80211softmac.h	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/include/net/ieee80211softmac.h.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/include/net/ieee80211softmac.h	2008-04-08 00:15:32.000000000 -0400
 @@ -1,373 +0,0 @@
 -/*
 - * ieee80211softmac.h - public interface to the softmac
@@ -7790,8 +7790,8 @@
 -
 -#endif /* IEEE80211SOFTMAC_H_ */
 diff -up linux-2.6.24.noarch/include/net/ieee80211softmac_wx.h.orig linux-2.6.24.noarch/include/net/ieee80211softmac_wx.h
---- linux-2.6.24.noarch/include/net/ieee80211softmac_wx.h.orig	2008-01-24 17:58:37.000000000 -0500
-+++ linux-2.6.24.noarch/include/net/ieee80211softmac_wx.h	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/include/net/ieee80211softmac_wx.h.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/include/net/ieee80211softmac_wx.h	2008-04-08 00:15:32.000000000 -0400
 @@ -1,99 +0,0 @@
 -/*
 - * This file contains the prototypes for the wireless extension
@@ -7893,8 +7893,8 @@
 -			     char *extra);
 -#endif /* _IEEE80211SOFTMAC_WX */
 diff -up linux-2.6.24.noarch/MAINTAINERS.orig linux-2.6.24.noarch/MAINTAINERS
---- linux-2.6.24.noarch/MAINTAINERS.orig	2008-04-01 20:38:04.000000000 -0400
-+++ linux-2.6.24.noarch/MAINTAINERS	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/MAINTAINERS.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/MAINTAINERS	2008-04-08 00:15:32.000000000 -0400
 @@ -840,15 +840,6 @@ L:	linux-wireless at vger.kernel.org
  W:	http://linuxwireless.org/en/users/Drivers/b43
  S:	Maintained
@@ -7925,16 +7925,16 @@
  P:	Ingo Molnar
  M:	mingo at redhat.com
 diff -up linux-2.6.24.noarch/net/ieee80211/Makefile.orig linux-2.6.24.noarch/net/ieee80211/Makefile
---- linux-2.6.24.noarch/net/ieee80211/Makefile.orig	2008-01-24 17:58:37.000000000 -0500
-+++ linux-2.6.24.noarch/net/ieee80211/Makefile	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/net/ieee80211/Makefile.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/net/ieee80211/Makefile	2008-04-08 00:15:33.000000000 -0400
 @@ -10,4 +10,3 @@ ieee80211-objs := \
  	ieee80211_wx.o \
  	ieee80211_geo.o
  
 -obj-$(CONFIG_IEEE80211_SOFTMAC) += softmac/
 diff -up linux-2.6.24.noarch/net/ieee80211/softmac/Makefile.orig linux-2.6.24.noarch/net/ieee80211/softmac/Makefile
---- linux-2.6.24.noarch/net/ieee80211/softmac/Makefile.orig	2008-01-24 17:58:37.000000000 -0500
-+++ linux-2.6.24.noarch/net/ieee80211/softmac/Makefile	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/net/ieee80211/softmac/Makefile.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/net/ieee80211/softmac/Makefile	2008-04-08 00:15:33.000000000 -0400
 @@ -1,9 +0,0 @@
 -obj-$(CONFIG_IEEE80211_SOFTMAC) += ieee80211softmac.o
 -ieee80211softmac-objs := \
@@ -7946,8 +7946,8 @@
 -			ieee80211softmac_assoc.o \
 -			ieee80211softmac_event.o
 diff -up linux-2.6.24.noarch/net/ieee80211/softmac/ieee80211softmac_assoc.c.orig linux-2.6.24.noarch/net/ieee80211/softmac/ieee80211softmac_assoc.c
---- linux-2.6.24.noarch/net/ieee80211/softmac/ieee80211softmac_assoc.c.orig	2008-01-24 17:58:37.000000000 -0500
-+++ linux-2.6.24.noarch/net/ieee80211/softmac/ieee80211softmac_assoc.c	2008-04-01 20:48:58.000000000 -0400
+--- linux-2.6.24.noarch/net/ieee80211/softmac/ieee80211softmac_assoc.c.orig	2008-04-08 00:15:25.000000000 -0400
++++ linux-2.6.24.noarch/net/ieee80211/softmac/ieee80211softmac_assoc.c	2008-04-08 00:15:33.000000000 -0400
 @@ -1,489 +0,0 @@
 -/*
 - * This file contains the softmac's association logic.
@@ -8439,8 +8439,8 @@
 -	return 0;
 -}
 diff -up linux-2.6.24.noarch/net/ieee80211/softmac/ieee80211softmac_io.c.orig linux-2.6.24.noarch/net/ieee80211/softmac/ieee80211softmac_io.c
---- linux-2.6.24.noarch/net/ieee80211/softmac/ieee80211softmac_io.c.orig	2008-04-01 20:38:40.000000000 -0400
-+++ linux-2.6.24.noarch/net/ieee80211/softmac/ieee80211softmac_io.c	2008-04-01 20:48:58.000000000 -0400
[...2641 lines suppressed...]
-+++ linux-2.6.24.noarch/drivers/ssb/Makefile	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/drivers/ssb/Makefile.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/drivers/ssb/Makefile	2008-04-08 00:15:33.000000000 -0400
 @@ -1,6 +1,7 @@
  # core
  ssb-y					+= main.o scan.o
@@ -93204,8 +93201,8 @@
  # b43 pci-ssb-bridge driver
  # Not strictly a part of SSB, but kept here for convenience
 diff -up linux-2.6.24.noarch/drivers/ssb/pcmcia.c.orig linux-2.6.24.noarch/drivers/ssb/pcmcia.c
---- linux-2.6.24.noarch/drivers/ssb/pcmcia.c.orig	2008-04-01 20:38:33.000000000 -0400
-+++ linux-2.6.24.noarch/drivers/ssb/pcmcia.c	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/drivers/ssb/pcmcia.c.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/drivers/ssb/pcmcia.c	2008-04-08 00:15:33.000000000 -0400
 @@ -3,7 +3,7 @@
   * PCMCIA-Hostbus related functions
   *
@@ -93878,8 +93875,8 @@
 +	return err;
  }
 diff -up linux-2.6.24.noarch/drivers/ssb/main.c.orig linux-2.6.24.noarch/drivers/ssb/main.c
---- linux-2.6.24.noarch/drivers/ssb/main.c.orig	2008-04-01 20:38:33.000000000 -0400
-+++ linux-2.6.24.noarch/drivers/ssb/main.c	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/drivers/ssb/main.c.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/drivers/ssb/main.c	2008-04-08 00:15:33.000000000 -0400
 @@ -14,6 +14,7 @@
  #include <linux/io.h>
  #include <linux/ssb/ssb.h>
@@ -93992,7 +93989,7 @@
  err_pci_exit:
  	ssb_pci_exit(bus);
  err_unmap:
-@@ -1153,7 +1210,14 @@ static int __init ssb_modinit(void)
+@@ -1159,7 +1216,14 @@ static int __init ssb_modinit(void)
  	err = b43_pci_ssb_bridge_init();
  	if (err) {
  		ssb_printk(KERN_ERR "Broadcom 43xx PCI-SSB-bridge "
@@ -94008,7 +94005,7 @@
  		/* don't fail SSB init because of this */
  		err = 0;
  	}
-@@ -1167,6 +1231,7 @@ fs_initcall(ssb_modinit);
+@@ -1173,6 +1237,7 @@ fs_initcall(ssb_modinit);
  
  static void __exit ssb_modexit(void)
  {
@@ -94017,8 +94014,8 @@
  	bus_unregister(&ssb_bustype);
  }
 diff -up linux-2.6.24.noarch/drivers/ssb/driver_mipscore.c.orig linux-2.6.24.noarch/drivers/ssb/driver_mipscore.c
---- linux-2.6.24.noarch/drivers/ssb/driver_mipscore.c.orig	2008-01-24 17:58:37.000000000 -0500
-+++ linux-2.6.24.noarch/drivers/ssb/driver_mipscore.c	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/drivers/ssb/driver_mipscore.c.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/drivers/ssb/driver_mipscore.c	2008-04-08 00:15:33.000000000 -0400
 @@ -209,6 +209,7 @@ void ssb_mipscore_init(struct ssb_mipsco
  			/* fallthrough */
  		case SSB_DEV_PCI:
@@ -94028,8 +94025,8 @@
  		case SSB_DEV_USB20_HOST:
  			/* These devices get their own IRQ line if available, the rest goes on IRQ0 */
 diff -up linux-2.6.24.noarch/drivers/ssb/ssb_private.h.orig linux-2.6.24.noarch/drivers/ssb/ssb_private.h
---- linux-2.6.24.noarch/drivers/ssb/ssb_private.h.orig	2008-04-01 20:38:33.000000000 -0400
-+++ linux-2.6.24.noarch/drivers/ssb/ssb_private.h	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/drivers/ssb/ssb_private.h.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/drivers/ssb/ssb_private.h	2008-04-08 00:15:33.000000000 -0400
 @@ -81,6 +81,7 @@ extern int ssb_pcmcia_switch_segment(str
  				     u8 seg);
  extern int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
@@ -94076,8 +94073,8 @@
  /* b43_pci_bridge.c */
  #ifdef CONFIG_SSB_B43_PCI_BRIDGE
 diff -up /dev/null linux-2.6.24.noarch/drivers/ssb/driver_gige.c
---- /dev/null	2008-04-01 10:36:34.721293558 -0400
-+++ linux-2.6.24.noarch/drivers/ssb/driver_gige.c	2008-04-01 20:48:59.000000000 -0400
+--- /dev/null	2008-04-08 00:00:49.269005103 -0400
++++ linux-2.6.24.noarch/drivers/ssb/driver_gige.c	2008-04-08 00:15:33.000000000 -0400
 @@ -0,0 +1,294 @@
 +/*
 + * Sonics Silicon Backplane
@@ -94374,8 +94371,8 @@
 +	return ssb_driver_register(&ssb_gige_driver);
 +}
 diff -up linux-2.6.24.noarch/drivers/ssb/pci.c.orig linux-2.6.24.noarch/drivers/ssb/pci.c
---- linux-2.6.24.noarch/drivers/ssb/pci.c.orig	2008-04-01 20:38:33.000000000 -0400
-+++ linux-2.6.24.noarch/drivers/ssb/pci.c	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/drivers/ssb/pci.c.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/drivers/ssb/pci.c	2008-04-08 00:15:33.000000000 -0400
 @@ -227,7 +227,7 @@ static u8 ssb_sprom_crc(const u16 *sprom
  	return crc;
  }
@@ -94592,8 +94589,8 @@
  	if (err)
  		goto out;
 diff -up linux-2.6.24.noarch/drivers/ssb/driver_chipcommon.c.orig linux-2.6.24.noarch/drivers/ssb/driver_chipcommon.c
---- linux-2.6.24.noarch/drivers/ssb/driver_chipcommon.c.orig	2008-04-01 20:38:33.000000000 -0400
-+++ linux-2.6.24.noarch/drivers/ssb/driver_chipcommon.c	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/drivers/ssb/driver_chipcommon.c.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/drivers/ssb/driver_chipcommon.c	2008-04-08 00:15:33.000000000 -0400
 @@ -353,6 +353,16 @@ void ssb_chipco_watchdog_timer_set(struc
  	chipco_write32(cc, SSB_CHIPCO_WATCHDOG, ticks);
  }
@@ -94612,8 +94609,8 @@
  {
  	return chipco_read32(cc, SSB_CHIPCO_GPIOIN) & mask;
 diff -up linux-2.6.24.noarch/drivers/ssb/Kconfig.orig linux-2.6.24.noarch/drivers/ssb/Kconfig
---- linux-2.6.24.noarch/drivers/ssb/Kconfig.orig	2008-04-01 20:38:33.000000000 -0400
-+++ linux-2.6.24.noarch/drivers/ssb/Kconfig	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/drivers/ssb/Kconfig.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/drivers/ssb/Kconfig	2008-04-08 00:15:33.000000000 -0400
 @@ -20,6 +20,10 @@ config SSB
  
  	  If unsure, say N.
@@ -94656,8 +94653,8 @@
 +
  endmenu
 diff -up linux-2.6.24.noarch/drivers/ssb/embedded.c.orig linux-2.6.24.noarch/drivers/ssb/embedded.c
---- linux-2.6.24.noarch/drivers/ssb/embedded.c.orig	2008-04-01 20:38:33.000000000 -0400
-+++ linux-2.6.24.noarch/drivers/ssb/embedded.c	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/drivers/ssb/embedded.c.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/drivers/ssb/embedded.c	2008-04-08 00:15:33.000000000 -0400
 @@ -10,6 +10,9 @@
  
  #include <linux/ssb/ssb.h>
@@ -94760,8 +94757,8 @@
 +	return -ENODEV;
 +}
 diff -up linux-2.6.24.noarch/drivers/ssb/driver_pcicore.c.orig linux-2.6.24.noarch/drivers/ssb/driver_pcicore.c
---- linux-2.6.24.noarch/drivers/ssb/driver_pcicore.c.orig	2008-04-01 20:38:33.000000000 -0400
-+++ linux-2.6.24.noarch/drivers/ssb/driver_pcicore.c	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/drivers/ssb/driver_pcicore.c.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/drivers/ssb/driver_pcicore.c	2008-04-08 00:15:33.000000000 -0400
 @@ -60,77 +60,6 @@ static DEFINE_SPINLOCK(cfgspace_lock);
  /* Core to access the external PCI config space. Can only have one. */
  static struct ssb_pcicore *extpci_core;
@@ -94937,8 +94934,8 @@
  {
  	u32 val;
 diff -up /dev/null linux-2.6.24.noarch/drivers/ssb/sprom.c
---- /dev/null	2008-04-01 10:36:34.721293558 -0400
-+++ linux-2.6.24.noarch/drivers/ssb/sprom.c	2008-04-01 20:48:59.000000000 -0400
+--- /dev/null	2008-04-08 00:00:49.269005103 -0400
++++ linux-2.6.24.noarch/drivers/ssb/sprom.c	2008-04-08 00:15:33.000000000 -0400
 @@ -0,0 +1,133 @@
 +/*
 + * Sonics Silicon Backplane
@@ -95074,8 +95071,8 @@
 +	return err ? err : count;
 +}
 diff -up linux-2.6.24.noarch/Documentation/laptops/acer-wmi.txt.orig linux-2.6.24.noarch/Documentation/laptops/acer-wmi.txt
---- linux-2.6.24.noarch/Documentation/laptops/acer-wmi.txt.orig	2008-04-01 20:38:03.000000000 -0400
-+++ linux-2.6.24.noarch/Documentation/laptops/acer-wmi.txt	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/Documentation/laptops/acer-wmi.txt.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/Documentation/laptops/acer-wmi.txt	2008-04-08 00:15:33.000000000 -0400
 @@ -80,7 +80,7 @@ once you enable the radio, will depend o
  e.g. With the BCM4318 on the Acer Aspire 5020 series:
  
@@ -95086,8 +95083,8 @@
  Wireless radio control is unconditionally enabled - all Acer laptops that support
  acer-wmi come with built-in wireless. However, should you feel so inclined to
 diff -up linux-2.6.24.noarch/Documentation/networking/bcm43xx.txt.orig linux-2.6.24.noarch/Documentation/networking/bcm43xx.txt
---- linux-2.6.24.noarch/Documentation/networking/bcm43xx.txt.orig	2008-01-24 17:58:37.000000000 -0500
-+++ linux-2.6.24.noarch/Documentation/networking/bcm43xx.txt	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/Documentation/networking/bcm43xx.txt.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/Documentation/networking/bcm43xx.txt	2008-04-08 00:15:33.000000000 -0400
 @@ -1,89 +0,0 @@
 -
 -			BCM43xx Linux Driver Project
@@ -95179,8 +95176,8 @@
 -and CONFIG_IEEE80211_SOFTMAC_DEBUG. The log information provided is
 -essential for solving any problems.
 diff -up /dev/null linux-2.6.24.noarch/Documentation/DocBook/mac80211.tmpl
---- /dev/null	2008-04-01 10:36:34.721293558 -0400
-+++ linux-2.6.24.noarch/Documentation/DocBook/mac80211.tmpl	2008-04-01 20:48:59.000000000 -0400
+--- /dev/null	2008-04-08 00:00:49.269005103 -0400
++++ linux-2.6.24.noarch/Documentation/DocBook/mac80211.tmpl	2008-04-08 00:15:33.000000000 -0400
 @@ -0,0 +1,335 @@
 +<?xml version="1.0" encoding="UTF-8"?>
 +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
@@ -95518,8 +95515,8 @@
 +  </part>
 +</book>
 diff -up linux-2.6.24.noarch/Documentation/DocBook/Makefile.orig linux-2.6.24.noarch/Documentation/DocBook/Makefile
---- linux-2.6.24.noarch/Documentation/DocBook/Makefile.orig	2008-04-01 20:48:01.000000000 -0400
-+++ linux-2.6.24.noarch/Documentation/DocBook/Makefile	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/Documentation/DocBook/Makefile.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/Documentation/DocBook/Makefile	2008-04-08 00:15:33.000000000 -0400
 @@ -11,7 +11,8 @@ DOCBOOKS := wanbook.xml z8530book.xml mc
  	    procfs-guide.xml writing_usb_driver.xml networking.xml \
  	    kernel-api.xml filesystems.xml lsm.xml usb.xml \
@@ -95531,8 +95528,8 @@
  ###
  # The build process is as follows (targets):
 diff -up linux-2.6.24.noarch/Documentation/feature-removal-schedule.txt.orig linux-2.6.24.noarch/Documentation/feature-removal-schedule.txt
---- linux-2.6.24.noarch/Documentation/feature-removal-schedule.txt.orig	2008-04-01 20:38:03.000000000 -0400
-+++ linux-2.6.24.noarch/Documentation/feature-removal-schedule.txt	2008-04-01 20:48:59.000000000 -0400
+--- linux-2.6.24.noarch/Documentation/feature-removal-schedule.txt.orig	2008-04-08 00:15:26.000000000 -0400
++++ linux-2.6.24.noarch/Documentation/feature-removal-schedule.txt	2008-04-08 00:15:33.000000000 -0400
 @@ -230,33 +230,6 @@ Who:	Jean Delvare <khali at linux-fr.org>
  
  ---------------------------

linux-2.6-wireless.patch:

Index: linux-2.6-wireless.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/linux-2.6-wireless.patch,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- linux-2.6-wireless.patch	2 Apr 2008 08:55:25 -0000	1.5
+++ linux-2.6-wireless.patch	14 Apr 2008 16:06:53 -0000	1.6
@@ -1,279 +1,130 @@
-commit d43c7b37ad787173d08683f05eadeea0398fefdf
-Author: Vladimir Koutny <vlado at work.ksp.sk>
-Date:   Mon Mar 31 17:05:03 2008 +0200
+commit 16f2e85d3151efa643879fa5aa87c9d77d60f57e
+Author: Johannes Berg <johannes at sipsolutions.net>
+Date:   Mon Apr 7 14:35:46 2008 +0200
 
-    mac80211: correct use_short_preamble handling
+    nl80211: fix STA AID bug
     
-    ERP IE bit for preamble mode is 0 for short and 1 for long, not the other
-    way around. This fixes the value reported to the driver via
-    bss_conf->use_short_preamble field.
+    This fixes the STA AID setting and actually makes hostapd/mac80211
+    work properly in presence of power-saving stations.
     
-    Signed-off-by: Vladimir Koutny <vlado at ksp.sk>
+    Signed-off-by: Johannes Berg <johannes at sipsolutions.net>
     Signed-off-by: John W. Linville <linville at tuxdriver.com>
 
-commit e645890115004fa6c4dd1f9541bb834970c8bcae
-Author: Michael Buesch <mb at bu3sch.de>
-Date:   Fri Mar 28 11:48:53 2008 +0100
+commit 881400a20c3551e90eed1062cf0387fa686a2fd0
+Author: Stefano Brivio <stefano.brivio at polimi.it>
+Date:   Sun Apr 6 17:05:07 2008 +0200
 
-    b43: Fix PCMCIA IRQ routing
+    b43legacy: fix bcm4303 crash
     
-    This fixes the IRQ routing on PCMCIA devices.
-    With this patch the card will finally be able to receive IRQs.
+    This fixes an hard crash which happened upon driver loading on bcm4303 rev.
+    2 devices.
     
-    Signed-off-by: Michael Buesch <mb at bu3sch.de>
+    Signed-off-by: Stefano Brivio <stefano.brivio at polimi.it>
     Signed-off-by: John W. Linville <linville at tuxdriver.com>
 
-commit 539e6f8cffe9299fbf813ad574535b90ac370031
-Author: Michael Buesch <mb at bu3sch.de>
-Date:   Fri Mar 28 11:46:58 2008 +0100
+commit 7981a35ed0f64ca49b1a0c0acecbc9b644a8a2e3
+Author: Abhijeet Kolekar <abhijeet.kolekar at intel.com>
+Date:   Fri Apr 4 14:32:01 2008 -0700
 
-    b43: Add DMA mapping failure messages
+    iwlwifi: fix n-band association problem
     
-    This adds messages for some DMA mapping failures.
-    These are useful for debugging DMA address problems, as they appear
-    on x86_64 machines with IOMMU enabled.
+    This patch enables the IWL4965_HT flag (n-band) in Kconfig.
+    Removed the "depends on n" from Kconfig for config IWL4965_HT
     
-    Signed-off-by: Michael Buesch <mb at bu3sch.de>
+    Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar at intel.com>
+    Signed-off-by: Reinette Chatre <reinette.chatre at intel.com>
     Signed-off-by: John W. Linville <linville at tuxdriver.com>
 
-commit 64f851e410ae37a0990212ae34f0c96b641478f7
-Author: Jan Niehusmann <jan at gondor.com>
-Date:   Sun Mar 23 20:23:56 2008 +0100
+commit 3f2eeac97952b262f2b904c6150a9879777995eb
+Author: Daniel Drake <dsd at gentoo.org>
+Date:   Wed Apr 2 20:33:54 2008 +0100
 
-    mac80211: trigger ieee80211_sta_work after opening interface
+    ipw2200: set MAC address on radiotap interface
     
-    ieee80211_sta_work is disabled while network interface
-    is down. Therefore, if you configure wireless parameters
-    before bringing the interface up, these configurations are
-    not yet effective and association fails.
+    Commit bada339ba24dee9e143bfb42e1dc61f146619846 enforces that all
+    interfaces have a valid MAC address before they are brought up.
     
-    A workaround from userspace is calling a command like
-    'iwconfig wlan0 ap any' after the interface is brought up.
+    ipw2200 does not assign a MAC address to it's radiotap interface, meaning
+    that the radiotap interface cannot be brought up in 2.6.24.
+    https://bugs.gentoo.org/show_bug.cgi?id=215714
     
-    To fix this behaviour, trigger execution of ieee80211_sta_work from
-    ieee80211_open when in STA or IBSS mode.
+    Fix this by copying the MAC address from the real interface.
     
-    Signed-off-by: Jan Niehusmann <jan at gondor.com>
+    Signed-off-by: Daniel Drake <dsd at gentoo.org>
     Signed-off-by: John W. Linville <linville at tuxdriver.com>
 
-commit 3e05e6703fb663fb8a394615d16c3a93cbef001e
-Author: Ivo van Doorn <ivdoorn at gmail.com>
-Date:   Thu Mar 27 17:15:24 2008 +0100
-
-    rt2x00: Ignore set_state(STATE_SLEEP) failure
-    
-    Some hardware never seem to accept the "goto sleep" command, since the legacy
-    drivers don't have suspend and resume handlers the entire code for it was
-    basically a educated guess (based on the "enable radio" code).
-    This patch will only print a warning when the "goto sleep" command fails, and
-    just continues as usual. Perhaps that means the device will not reach a sleep
-    state and consumes more power then it should, but it is equally possible it
-    simply needs some seconds longer to sleep. Anyway, by making the command
-    non-fatal it will not block the rest of the suspend procedure.
-    
-    Signed-off-by: Ivo van Doorn <IvDoorn at gmail.com>
-    Signed-off-by: John W. Linville <linville at tuxdriver.com>
-
-commit 8def53bc1ff4686bd24b3c274a4871c9ae33c27c
-Author: Julia Lawall <julia at diku.dk>
-Date:   Tue Mar 4 14:58:59 2008 -0800
-
-    drivers/net/wireless/iwlwifi/iwl-4965.c: correct use of ! and &
-    
-    In commit e6bafba5b4765a5a252f1b8d31cbf6d2459da337, a bug was fixed that
-    involved converting !x & y to !(x & y).  The code below shows the same
-    pattern, and thus should perhaps be fixed in the same way.
-    
-    This is not tested and clearly changes the semantics, so it is only
-    something to consider.
-    
-    The semantic patch that makes this change is as follows:
-    (http://www.emn.fr/x-info/coccinelle/)
-    
-    // <smpl>
-    @@ expression E1,E2; @@
-    (
-      !E1 & !E2
-    |
-    - !E1 & E2
-    + !(E1 & E2)
-    )
-    // </smpl>
-    
-    Signed-off-by: Julia Lawall <julia at diku.dk>
-    Cc: Tomas Winkler <tomas.winkler at intel.com>
-    Cc: Guy Cohen <guy.cohen at intel.com>
-    Cc: Reinette Chatre <reinette.chatre at intel.com>
-    Cc: Zhu Yi <yi.zhu at intel.com>
-    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
-    Signed-off-by: John W. Linville <linville at tuxdriver.com>
-
-commit 9cef555bcc6a5a7c1a5bb7728fd96bc59fa1b96a
+commit 877cb0d4af2658beb5f89d38ae51968782f62fad
 Author: Holger Schurig <hs4233 at mail.mn-solutions.de>
-Date:   Wed Mar 19 15:24:21 2008 +0100
+Date:   Wed Apr 2 16:34:51 2008 +0200
 
-    libertas: fix spinlock recursion bug
-    
-    This fixes a bug detected by CONFIG_DEBUG_SPINLOCK:
+    libertas: fix mode initialization problem
     
-    if_cs_get_int_status() is only called from lbs_thread(), via
-    priv->hw_get_int_status. However, lbs_thread() has already taken the
-    priv->driver_lock. So it's a fault to take the same lock again here.
+    After moving lbs_find_best_network_ssid() from scan.c to assoc.c gcc was
+    able to deduce that new_mode might stay uninitialized.
     
     Signed-off-by: Holger Schurig <hs4233 at mail.mn-solutions.de>
     Acked-by: Dan Williams <dcbw at redhat.com>
     Signed-off-by: John W. Linville <linville at tuxdriver.com>
 
-diff -up linux-2.6.24.noarch/net/mac80211/ieee80211.c.orig linux-2.6.24.noarch/net/mac80211/ieee80211.c
---- linux-2.6.24.noarch/net/mac80211/ieee80211.c.orig	2008-04-01 20:39:01.000000000 -0400
-+++ linux-2.6.24.noarch/net/mac80211/ieee80211.c	2008-04-01 20:41:26.000000000 -0400
-@@ -375,6 +375,18 @@ static int ieee80211_open(struct net_dev
- 	if (need_hw_reconfig)
- 		ieee80211_hw_config(local);
+diff -up linux-2.6.24.noarch/net/wireless/nl80211.c.orig linux-2.6.24.noarch/net/wireless/nl80211.c
+--- linux-2.6.24.noarch/net/wireless/nl80211.c.orig	2008-04-07 23:22:10.000000000 -0400
++++ linux-2.6.24.noarch/net/wireless/nl80211.c	2008-04-07 23:27:24.000000000 -0400
+@@ -945,7 +945,7 @@ static int nl80211_new_station(struct sk
+ 		nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
+ 	params.listen_interval =
+ 		nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
+-	params.listen_interval = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
++	params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
+ 
+ 	if (parse_station_flags(info->attrs[NL80211_ATTR_STA_FLAGS],
+ 				&params.station_flags))
+diff -up linux-2.6.24.noarch/drivers/net/wireless/libertas/assoc.c.orig linux-2.6.24.noarch/drivers/net/wireless/libertas/assoc.c
+--- linux-2.6.24.noarch/drivers/net/wireless/libertas/assoc.c.orig	2008-04-07 23:21:35.000000000 -0400
++++ linux-2.6.24.noarch/drivers/net/wireless/libertas/assoc.c	2008-04-07 23:27:24.000000000 -0400
+@@ -541,7 +541,7 @@ void lbs_association_worker(struct work_
+ 	}
+ 
+ 	if (find_any_ssid) {
+-		u8 new_mode;
++		u8 new_mode = assoc_req->mode;
+ 
+ 		ret = lbs_find_best_network_ssid(priv, assoc_req->ssid,
+ 				&assoc_req->ssid_len, assoc_req->mode, &new_mode);
+diff -up linux-2.6.24.noarch/drivers/net/wireless/ipw2200.c.orig linux-2.6.24.noarch/drivers/net/wireless/ipw2200.c
+--- linux-2.6.24.noarch/drivers/net/wireless/ipw2200.c.orig	2008-04-07 23:21:34.000000000 -0400
++++ linux-2.6.24.noarch/drivers/net/wireless/ipw2200.c	2008-04-07 23:27:24.000000000 -0400
+@@ -11576,6 +11576,7 @@ static int ipw_prom_alloc(struct ipw_pri
+ 	priv->prom_priv->priv = priv;
+ 
+ 	strcpy(priv->prom_net_dev->name, "rtap%d");
++	memcpy(priv->prom_net_dev->dev_addr, priv->mac_addr, ETH_ALEN);
+ 
+ 	priv->prom_net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
+ 	priv->prom_net_dev->open = ipw_prom_open;
+diff -up linux-2.6.24.noarch/drivers/net/wireless/iwlwifi/Kconfig.orig linux-2.6.24.noarch/drivers/net/wireless/iwlwifi/Kconfig
+--- linux-2.6.24.noarch/drivers/net/wireless/iwlwifi/Kconfig.orig	2008-04-07 23:21:34.000000000 -0400
++++ linux-2.6.24.noarch/drivers/net/wireless/iwlwifi/Kconfig	2008-04-07 23:27:24.000000000 -0400
+@@ -35,7 +35,6 @@ config IWL4965_HT
+ 	bool "Enable 802.11n HT features in iwl4965 driver"
+ 	depends on EXPERIMENTAL
+ 	depends on IWL4965 && IWL4965_QOS
+-	depends on n
+ 	---help---
+ 	  This option enables IEEE 802.11n High Throughput features
+ 	  for the iwl4965 driver.
+diff -up linux-2.6.24.noarch/drivers/ssb/main.c.orig linux-2.6.24.noarch/drivers/ssb/main.c
+--- linux-2.6.24.noarch/drivers/ssb/main.c.orig	2008-04-07 23:21:44.000000000 -0400
++++ linux-2.6.24.noarch/drivers/ssb/main.c	2008-04-07 23:27:24.000000000 -0400
+@@ -1044,6 +1044,12 @@ int ssb_bus_may_powerdown(struct ssb_bus
+ 		goto out;
  
-+	/*
-+	 * ieee80211_sta_work is disabled while network interface
-+	 * is down. Therefore, some configuration changes may not
-+	 * yet be effective. Trigger execution of ieee80211_sta_work
-+	 * to fix this.
-+	 */
-+	if(sdata->vif.type == IEEE80211_IF_TYPE_STA ||
-+	   sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
-+		struct ieee80211_if_sta *ifsta = &sdata->u.sta;
-+		queue_work(local->hw.workqueue, &ifsta->work);
-+	}
+ 	cc = &bus->chipco;
 +
- 	netif_start_queue(dev);
- 
- 	return 0;
-diff -up linux-2.6.24.noarch/net/mac80211/ieee80211_sta.c.orig linux-2.6.24.noarch/net/mac80211/ieee80211_sta.c
---- linux-2.6.24.noarch/net/mac80211/ieee80211_sta.c.orig	2008-04-01 20:39:01.000000000 -0400
-+++ linux-2.6.24.noarch/net/mac80211/ieee80211_sta.c	2008-04-01 20:41:26.000000000 -0400
-@@ -360,7 +360,7 @@ static u32 ieee80211_handle_erp_ie(struc
- 	struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf;
- 	struct ieee80211_if_sta *ifsta = &sdata->u.sta;
- 	bool use_protection = (erp_value & WLAN_ERP_USE_PROTECTION) != 0;
--	bool preamble_mode = (erp_value & WLAN_ERP_BARKER_PREAMBLE) != 0;
-+	bool use_short_preamble = (erp_value & WLAN_ERP_BARKER_PREAMBLE) == 0;
- 	DECLARE_MAC_BUF(mac);
- 	u32 changed = 0;
- 
-@@ -376,16 +376,15 @@ static u32 ieee80211_handle_erp_ie(struc
- 		changed |= BSS_CHANGED_ERP_CTS_PROT;
- 	}
- 
--	if (preamble_mode != bss_conf->use_short_preamble) {
-+	if (use_short_preamble != bss_conf->use_short_preamble) {
- 		if (net_ratelimit()) {
- 			printk(KERN_DEBUG "%s: switched to %s barker preamble"
- 			       " (BSSID=%s)\n",
- 			       sdata->dev->name,
--			       (preamble_mode == WLAN_ERP_PREAMBLE_SHORT) ?
--					"short" : "long",
-+			       use_short_preamble ? "short" : "long",
- 			       print_mac(mac, ifsta->bssid));
- 		}
--		bss_conf->use_short_preamble = preamble_mode;
-+		bss_conf->use_short_preamble = use_short_preamble;
- 		changed |= BSS_CHANGED_ERP_PREAMBLE;
- 	}
- 
-diff -up linux-2.6.24.noarch/drivers/net/wireless/b43/pcmcia.c.orig linux-2.6.24.noarch/drivers/net/wireless/b43/pcmcia.c
---- linux-2.6.24.noarch/drivers/net/wireless/b43/pcmcia.c.orig	2008-01-24 17:58:37.000000000 -0500
-+++ linux-2.6.24.noarch/drivers/net/wireless/b43/pcmcia.c	2008-04-01 20:41:26.000000000 -0400
-@@ -91,6 +91,8 @@ static int __devinit b43_pcmcia_probe(st
- 
- 	dev->conf.ConfigBase = parse.config.base;
- 	dev->conf.Present = parse.config.rmask[0];
-+	dev->conf.Attributes = CONF_ENABLE_IRQ;
-+	dev->conf.IntType = INT_MEMORY_AND_IO;
- 
- 	dev->io.BasePort2 = 0;
- 	dev->io.NumPorts2 = 0;
-@@ -112,8 +114,8 @@ static int __devinit b43_pcmcia_probe(st
- 	if (res != CS_SUCCESS)
- 		goto err_disable;
- 
--	dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_FIRST_SHARED;
--	dev->irq.IRQInfo1 = IRQ_LEVEL_ID | IRQ_SHARE_ID;
-+	dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-+	dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
- 	dev->irq.Handler = NULL; /* The handler is registered later. */
- 	dev->irq.Instance = NULL;
- 	res = pcmcia_request_irq(dev, &dev->irq);
-diff -up linux-2.6.24.noarch/drivers/net/wireless/b43/dma.c.orig linux-2.6.24.noarch/drivers/net/wireless/b43/dma.c
---- linux-2.6.24.noarch/drivers/net/wireless/b43/dma.c.orig	2008-04-01 20:39:01.000000000 -0400
-+++ linux-2.6.24.noarch/drivers/net/wireless/b43/dma.c	2008-04-01 20:41:26.000000000 -0400
-@@ -574,6 +574,7 @@ static int setup_rx_descbuffer(struct b4
- 	}
- 
- 	if (b43_dma_mapping_error(ring, dmaaddr, ring->rx_buffersize, 0)) {
-+		b43err(ring->dev->wl, "RX DMA buffer allocation failed\n");
- 		dev_kfree_skb_any(skb);
- 		return -EIO;
- 	}
-@@ -829,8 +830,12 @@ struct b43_dmaring *b43_setup_dmaring(st
- 						  DMA_TO_DEVICE);
- 
- 			if (b43_dma_mapping_error(ring, dma_test,
--						  b43_txhdr_size(dev), 1))
-+						  b43_txhdr_size(dev), 1)) {
++	if (!cc->dev)
++		goto out;
++	if (cc->dev->id.revision < 5)
++		goto out;
 +
-+				b43err(dev->wl,
-+				       "TXHDR DMA allocation failed\n");
- 				goto err_kfree_txhdr_cache;
-+			}
- 		}
- 
- 		dma_unmap_single(dev->dev->dev,
-diff -up linux-2.6.24.noarch/drivers/net/wireless/libertas/if_cs.c.orig linux-2.6.24.noarch/drivers/net/wireless/libertas/if_cs.c
---- linux-2.6.24.noarch/drivers/net/wireless/libertas/if_cs.c.orig	2008-04-01 20:40:36.000000000 -0400
-+++ linux-2.6.24.noarch/drivers/net/wireless/libertas/if_cs.c	2008-04-01 20:40:41.000000000 -0400
-@@ -677,9 +677,7 @@ sbi_get_int_status_exit:
- 
- 	/* Card has a command result for us */
- 	if (*ireg & IF_CS_C_S_CMD_UPLD_RDY) {
--		spin_lock(&priv->driver_lock);
- 		ret = if_cs_receive_cmdres(priv, priv->upld_buf, &priv->upld_len);
--		spin_unlock(&priv->driver_lock);
- 		if (ret < 0)
- 			lbs_pr_err("could not receive cmd from card\n");
- 	}
-diff -up linux-2.6.24.noarch/drivers/net/wireless/iwlwifi/iwl-4965.c.orig linux-2.6.24.noarch/drivers/net/wireless/iwlwifi/iwl-4965.c
---- linux-2.6.24.noarch/drivers/net/wireless/iwlwifi/iwl-4965.c.orig	2008-04-01 20:40:36.000000000 -0400
-+++ linux-2.6.24.noarch/drivers/net/wireless/iwlwifi/iwl-4965.c	2008-04-01 20:40:41.000000000 -0400
-@@ -4602,7 +4602,7 @@ static u8 iwl4965_is_fat_tx_allowed(stru
- 
- 	if (sta_ht_inf) {
- 		if ((!sta_ht_inf->ht_supported) ||
--		   (!sta_ht_inf->cap & IEEE80211_HT_CAP_SUP_WIDTH))
-+		   (!(sta_ht_inf->cap & IEEE80211_HT_CAP_SUP_WIDTH)))
- 			return 0;
- 	}
- 
-diff -up linux-2.6.24.noarch/drivers/net/wireless/rt2x00/rt2x00dev.c.orig linux-2.6.24.noarch/drivers/net/wireless/rt2x00/rt2x00dev.c
---- linux-2.6.24.noarch/drivers/net/wireless/rt2x00/rt2x00dev.c.orig	2008-04-01 20:40:36.000000000 -0400
-+++ linux-2.6.24.noarch/drivers/net/wireless/rt2x00/rt2x00dev.c	2008-04-01 20:40:41.000000000 -0400
-@@ -1246,11 +1246,20 @@ int rt2x00lib_suspend(struct rt2x00_dev 
- 
- exit:
- 	/*
--	 * Set device mode to sleep for power management.
-+	 * Set device mode to sleep for power management,
-+	 * on some hardware this call seems to consistently fail.
-+	 * From the specifications it is hard to tell why it fails,
-+	 * and if this is a "bad thing".
-+	 * Overall it is safe to just ignore the failure and
-+	 * continue suspending. The only downside is that the
-+	 * device will not be in optimal power save mode, but with
-+	 * the radio and the other components already disabled the
-+	 * device is as good as disabled.
- 	 */
- 	retval = rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_SLEEP);
- 	if (retval)
--		return retval;
-+		WARNING(rt2x00dev, "Device failed to enter sleep state, "
-+			"continue suspending.\n");
- 
- 	return 0;
- }
+ 	ssb_chipco_set_clockmode(cc, SSB_CLKMODE_SLOW);
+ 	err = ssb_pci_xtal(bus, SSB_GPIO_XTAL | SSB_GPIO_PLL, 0);
+ 	if (err)

linux-2.6-xen-0001-squashfs-Fix-build-without-CONFIG_SMP.patch:

Index: linux-2.6-xen-0001-squashfs-Fix-build-without-CONFIG_SMP.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/linux-2.6-xen-0001-squashfs-Fix-build-without-CONFIG_SMP.patch,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- linux-2.6-xen-0001-squashfs-Fix-build-without-CONFIG_SMP.patch	3 Apr 2008 09:48:58 -0000	1.4
+++ linux-2.6-xen-0001-squashfs-Fix-build-without-CONFIG_SMP.patch	14 Apr 2008 16:06:53 -0000	1.5
@@ -1,4 +1,4 @@
-From 1b166290057a8c0d66917da0023351c322487806 Mon Sep 17 00:00:00 2001
+From f75baa2f60e344b5cfe70336bcee349e1576e987 Mon Sep 17 00:00:00 2001
 From: Mark McLoughlin <markmc at redhat.com>
 Date: Wed, 5 Mar 2008 12:50:50 +0000
 Subject: [PATCH] squashfs: Fix build without CONFIG_SMP

linux-2.6-xen-0002-xen-execshield-Add-xen-specific-load_user_cs_desc.patch:

Index: linux-2.6-xen-0002-xen-execshield-Add-xen-specific-load_user_cs_desc.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/linux-2.6-xen-0002-xen-execshield-Add-xen-specific-load_user_cs_desc.patch,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- linux-2.6-xen-0002-xen-execshield-Add-xen-specific-load_user_cs_desc.patch	3 Apr 2008 09:48:58 -0000	1.4
+++ linux-2.6-xen-0002-xen-execshield-Add-xen-specific-load_user_cs_desc.patch	14 Apr 2008 16:06:53 -0000	1.5
@@ -1,4 +1,4 @@
-From 5de016b6e9392c72f90a8fcce66930dbfa7dc56f Mon Sep 17 00:00:00 2001
+From 36630ad09c177fd24eb2c3cb10cfe681c4fbe096 Mon Sep 17 00:00:00 2001
 From: Stephen Tweedie <sct at redhat.com>
 Date: Tue, 11 Mar 2008 18:05:30 +0000
 Subject: [PATCH] xen execshield: Add xen-specific load_user_cs_desc()
@@ -30,7 +30,7 @@
  	.load_idt = native_load_idt,
  	.store_gdt = native_store_gdt,
 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
-index de4e6f0..f32795f 100644
+index 27ee26a..66ffdb2 100644
 --- a/arch/x86/xen/enlighten.c
 +++ b/arch/x86/xen/enlighten.c
 @@ -290,6 +290,22 @@ static void xen_set_ldt(const void *addr, unsigned entries)
@@ -56,7 +56,7 @@
  static void xen_load_gdt(const struct desc_ptr *dtr)
  {
  	unsigned long *frames;
-@@ -985,6 +1001,7 @@ static const struct pv_cpu_ops xen_cpu_ops __initdata = {
+@@ -998,6 +1014,7 @@ static const struct pv_cpu_ops xen_cpu_ops __initdata = {
  
  	.load_tr_desc = paravirt_nop,
  	.set_ldt = xen_set_ldt,

linux-2.6-xen-0003-xen-execshield-fix-endless-GPF-fault-loop.patch:

Index: linux-2.6-xen-0003-xen-execshield-fix-endless-GPF-fault-loop.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/linux-2.6-xen-0003-xen-execshield-fix-endless-GPF-fault-loop.patch,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- linux-2.6-xen-0003-xen-execshield-fix-endless-GPF-fault-loop.patch	3 Apr 2008 09:48:58 -0000	1.4
+++ linux-2.6-xen-0003-xen-execshield-fix-endless-GPF-fault-loop.patch	14 Apr 2008 16:06:53 -0000	1.5
@@ -1,4 +1,4 @@
-From 800ccaf3f4fbe02b3c23ce3f9220b401e4867551 Mon Sep 17 00:00:00 2001
+From 6115da66a037e21c67a5a003b6278e55d92367fc Mon Sep 17 00:00:00 2001
 From: Stephen Tweedie <sct at redhat.com>
 Date: Tue, 11 Mar 2008 18:07:31 +0000
 Subject: [PATCH] xen execshield: fix endless GPF fault loop

nouveau-drm.patch:

Index: nouveau-drm.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/nouveau-drm.patch,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- nouveau-drm.patch	1 Apr 2008 10:38:07 -0000	1.4
+++ nouveau-drm.patch	14 Apr 2008 16:06:53 -0000	1.5
@@ -6242,7 +6242,7 @@
 +		DRM_ERROR("Unable to initialize the mmio mapping (%d). "
 +			  "Please report your setup to " DRIVER_EMAIL "\n",
 +			  ret);
-+		return 1;
++		return -EINVAL;
 +	}
 +	DRM_DEBUG("regs mapped ok at 0x%lx\n", dev_priv->mmio->offset);
 +


Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/sources,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- sources	2 Apr 2008 08:55:25 -0000	1.14
+++ sources	14 Apr 2008 16:06:54 -0000	1.15
@@ -1,3 +1,3 @@
 3f23ad4b69d0a552042d1ed0f4399857  linux-2.6.24.tar.bz2
-ef38a1bf38d8ddb2629d9b8c2a0fa662  patch-2.6.25-rc8.bz2
+bd9c3782deccd234b2c8df8c223347e9  patch-2.6.25-rc9.bz2
 4aa57328d0802a063fa67dfc063da30e  xen-3.2.0.tar.gz


Index: upstream
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/upstream,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- upstream	2 Apr 2008 08:55:25 -0000	1.4
+++ upstream	14 Apr 2008 16:06:54 -0000	1.5
@@ -1,2 +1,2 @@
 linux-2.6.24.tar.bz2
-patch-2.6.25-rc8.bz2
+patch-2.6.25-rc9.bz2


--- linux-2.6-input-macbook-appletouch.patch DELETED ---


--- linux-2.6-libata-ali-atapi-dma.patch DELETED ---


--- linux-2.6-xen-0004-xen-Do-not-pin-unpin-PMD-pages.patch DELETED ---


--- linux-2.6-xen-0005-xen-Make-xen-blkfront-write-its-protocol-ABI-to-xen.patch DELETED ---


--- linux-2.6-xen-0006-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch DELETED ---


--- linux-2.6-xen-0007-xen-Enable-Xen-console-by-default-in-domU.patch DELETED ---


--- linux-2.6-xen-0008-xen-Module-autoprobing-support-for-frontend-drivers.patch DELETED ---


--- linux-2.6-xen-0009-xen-Add-compatibility-aliases-for-frontend-drivers.patch DELETED ---


--- linux-2.6-xen-0010-xen-blkfront-Delay-wait-for-block-devices-until-aft.patch DELETED ---


--- linux-2.6-xen-0011-xen-Add-a-vmlinuz-target.patch DELETED ---


--- linux-2.6-xen-0012-xen-Add-empty-xenctrl-module.patch DELETED ---


--- linux-2.6-xen-0013-xen-Add-proc-xen-capabilities.patch DELETED ---


--- linux-2.6-xen-0014-xen-Add-proc-xen-privcmd.patch DELETED ---


--- linux-2.6-xen-0015-xen-Add-proc-xen-xenbus.patch DELETED ---


--- linux-2.6-xen-0016-xen-Add-Xen-s-sys-hypervisor-interface.patch DELETED ---


--- linux-2.6-xen-0017-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch DELETED ---


--- linux-2.6-xen-0018-xen-x86_64-Add-64-bit-version-of-privcmd_hypercall.patch DELETED ---


--- linux-2.6-xen-0019-xen-x86_64-Only-define-load_user_cs_desc-on-32-bi.patch DELETED ---


--- linux-2.6-xen-0020-xen-x86_64-Initial-x86_64-support-for-Xen-paravirt_.patch DELETED ---


--- patch-2.6.25-rc8.bz2.sign DELETED ---




More information about the scm-commits mailing list