rpms/kernel-xen-2.6/devel linux-2.6-xen-0005-xen-Module-autoprobing-support-for-frontend-drivers.patch, NONE, 1.1.2.1 linux-2.6-xen-0006-xen-Add-compatibility-aliases-for-frontend-drivers.patch, NONE, 1.1.2.1 linux-2.6-xen-0007-xen-dom0-Make-hvc_xen-console-work-for-dom0.patch, NONE, 1.1.2.1 linux-2.6-xen-0008-xen-dom0-Initialize-xenbus-for-dom0.patch, NONE, 1.1.2.1 linux-2.6-xen-0009-xen-dom0-Set-up-basic-IO-permissions-for-dom0.patch, NONE, 1.1.2.1 linux-2.6-xen-0010-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch, NONE, 1.1.2.1 linux-2.6-xen-0011-xen-dom0-Add-support-for-the-platform_ops-hypercall.patch, NONE, 1.1.2.1 linux-2.6-xen-0012-xen-acpi-Enable-early-access-to-ACPI-tables.patch, NONE, 1.1.2.1 linux-2.6-xen-0013-xen-dom0-Add-paravirt_ops-ioremap_page_range-for.patch, NONE, 1.1.2.1 linux-2.6-xen-0014-MTRR-use-cpu_callout_map-instead-of-cpu_online_map.patch, NONE, 1.1.2.1 linux-2.6-xen-0015-xen-mtrr-Add-mtrr_ops-support-for-Xen-mtrr.patch, NONE, 1.1.2.1 linux-2.6-xen-0016-xen-mtrr-Don-t-enable-xen-mtrr-on-bare-metal.patch, NONE, 1.1.2.1 linux-2.6-xen-0017-xen-mtrr-set-cpu-in-cpu_callout_map.patch, NONE, 1.1.2.1 linux-2.6-xen-0018-xen-mtrr-Clean-up-the-num_var_ranges-CPU_UNKOWN-hac.patch, NONE, 1.1.2.1 linux-2.6-xen-0019-xen-mtrr-Use-specific-cpu_has_foo-macros-instead-of.patch, NONE, 1.1.2.1 linux-2.6-xen-0020-xen-mtrr-Kill-some-unneccessary-includes.patch, NONE, 1.1.2.1 linux-2.6-xen-0021-xen-mtrr-No-need-to-explicitly-set-use_intel_if-0.patch, NONE, 1.1.2.1 linux-2.6-xen-0022-xen-mtrr-Use-generic_validate_add_page.patch, NONE, 1.1.2.1 linux-2.6-xen-0023-xen-mtrr-Implement-xen_get_free_region.patch, NONE, 1.1.2.1 linux-2.6-xen-0024-xen-mtrr-Add-xen_-get-set-_mtrr-implementations.patch, NONE, 1.1.2.1 linux-2.6-xen-0025-irq2.diff-from-Juan-Quintela.patch, NONE, 1.1.2.1 linux-2.6-xen-0026-xen-dom0-Obvious-cpuid-fix-to-domU-handling.patch, NONE, 1.1.2.1 linux-2.6-xen-0027-xen-debug-Diagnose-bind_virq_to_irq-errors.patch, NONE, 1.1.2.1 linux-2.6-xen-0028-xen-traps-Revert-Juan-s-traps_32.c-changes-to-debug.patch, NONE, 1.1.2.1 linux-2.6-xen-0029-xen-debug-Move-init_apic_mappings-after-trap-init.patch, NONE, 1.1.2.1 linux-2.6-xen-0030-xen-debug-Trace-progress-in-trap_init-around-init.patch, NONE, 1.1.2.1 linux-2.6-xen-0031-xen-apic-Disable-init_apic_mappings-when-under-CO.patch, NONE, 1.1.2.1 linux-2.6-xen-0032-xen-debug-Log-entry-into-virtual-console-s-xen_init.patch, NONE, 1.1.2.1 linux-2.6-xen-0033-xen-debug-Log-bind_virq_to_irq-events.patch, NONE, 1.1.2.1 linux-2.6-xen-0034-xen-debug-Work-around-USB-issue-triggered-by-Xen-de.patch, NONE, 1.1.2.1 linux-2.6-xen-0035-Remove-duplicated-dma_alloc-free_noncoherent-define.patch, NONE, 1.1.2.1 linux-2.6-xen-0036-xem-dom0-Add-hypervisor-memory_exchange-descriptor.patch, NONE, 1.1.2.1 linux-2.6-xen-0037-xen-dom0-add-virt_to_pfn-macro.patch, NONE, 1.1.2.1 linux-2.6-xen-0038-xen-dom0-use-virt_to_pfn-where-appropriate.patch, NONE, 1.1.2.1 linux-2.6-xen-0039-xen-dom0-Add-contiguous-region-support.patch, NONE, 1.1.2.1 linux-2.6-xen-0040-xen-dom0-Don-t-mask-off-PCD-bits-from-pte-entries.patch, NONE, 1.1.2.1 linux-2.6-xen-0041-xen-dom0-Remove-duplicate-xen_store_interface-assig.patch, NONE, 1.1.2.1 linux-2.6-xen-0042-xen-dom0-Slightly-re-arrange-xenbus_probe_init-er.patch, NONE, 1.1.2.1 linux-2.6-xen-0043-xen-dom0-Use-max_low_pfn-declaration-from-linux-boo.patch, NONE, 1.1.2.1 linux-2.6-xen-0044-xen-dma-Add-dma_mapping_ops-indirection-for-32-bit.patch, NONE, 1.1.2.1 linux-2.6-xen-0045-xen-dma-Remove-unused-32-bit-dma_ops-map_simple-me.patch, NONE, 1.1.2.1 linux-2.6-xen-0046-xen-dma-Initial-commit-of-pci-xen.c-dma-mapping-fun.patch, NONE, 1.1.2.1 linux-2.6-xen-0047-xen-dma-Add-calls-to-dma_ops-alloc-free_coherent-ho.patch, NONE, 1.1.2.1 linux-2.6-xen-0048-xen-dma-Add-xen_alloc-free_coherent.patch, NONE, 1.1.2.1 linux-2.6-xen-0049-xen-dma-Don-t-merge-bios-on-xen-pvops.patch, NONE, 1.1.2.1 linux-2.6-xen-0050-xen-dom0-Minor-coding-style-issue-in-ISA-mapping-co.patch, NONE, 1.1.2.1 linux-2.6-xen-0051-xen-dom0-Use-i-PAGE_SHIFT-instead-of-PAGE_DOWN-i.patch, NONE, 1.1.2.1 linux-2.6-xen-0052-xen-dom0-Match-up-set_pte_mfn-prototype-with-the.patch, NONE, 1.1.2.1 linux-2.6-xen-0053-xen-dom0-Reserve-ISA-address-space-earlier.patch, NONE, 1.1.2.1 linux-2.6-xen-0054-xen-Add-empty-xenctrl-module.patch, NONE, 1.1.2.1 linux-2.6-xen-0055-xen-dom0-Add-proc-xen-capabilities.patch, NONE, 1.1.2.1 linux-2.6-xen-0056-xen-Add-proc-xen-privcmd.patch, NONE, 1.1.2.1 linux-2.6-xen-0057-xen-dom0-Add-proc-xen-xsd_-port-kva.patch, NONE, 1.1.2.1 linux-2.6-xen-0058-xen-Add-proc-xen-xenbus.patch, NONE, 1.1.2.1 linux-2.6-xen-0059-xen-Add-dev-xen-evtchn.patch, NONE, 1.1.2.1 linux-2.6-xen-0060-xen-Add-__init-__exit-notations-to-xenctrl-function.patch, NONE, 1.1.2.1 linux-2.6-xen-0061-xen-Add-Xen-s-sys-hypervisor-interface.patch, NONE, 1.1.2.1 linux-2.6-xen-0062-xen-dom0-Add-basic-proc-xen-balloon.patch, NONE, 1.1.2.1 linux-2.6-xen-0063-xen-dom0-Re-work-privcmd_ioctl-a-little.patch, NONE, 1.1.2.1 linux-2.6-xen-0064-xen-dom0-Add-IOCTL_PRIVCMD_MMAP.patch, NONE, 1.1.2.1 linux-2.6-xen-0065-xen-dom0-Add-a-vmlinuz-target.patch, NONE, 1.1.2.1 kernel.spec, 1.11.2.7, 1.11.2.8 linux-2.6-xen-0001-Revert-linux-2.6-execshield.patch-from-kernel-2_6_24.patch, 1.1.2.1, 1.1.2.2 linux-2.6-xen-0002-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch, 1.1.2.1, 1.1.2.2 linux-2.6-xen-0003-fbdev-Make-deferred-I-O-work-as-advertized.patch, 1.1.2.1, 1.1.2.2 linux-2.6-xen-0004-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch, 1.1.2.1, 1.1.2.2 linux-2.6-xen-0005-Add-compatibility-aliases-for-Xen-block-network-fron.patch, 1.1.2.1, NONE linux-2.6-xen-0006-xen-dom0-Make-hvc_xen-console-work-for-dom0.patch, 1.1.2.1, NONE linux-2.6-xen-0007-xen-dom0-Initialize-xenbus-for-dom0.patch, 1.1.2.1, NONE linux-2.6-xen-0008-xen-dom0-Set-up-basic-IO-permissions-for-dom0.patch, 1.1.2.1, NONE linux-2.6-xen-0009-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch, 1.1.2.1, NONE linux-2.6-xen-0010-xen-dom0-Add-support-for-the-platform_ops-hypercall.patch, 1.1.2.1, NONE linux-2.6-xen-0011-xen-acpi-Enable-early-access-to-ACPI-tables.patch, 1.1.2.1, NONE linux-2.6-xen-0012-xen-dom0-Add-paravirt_ops-ioremap_page_range-for.patch, 1.1.2.1, NONE linux-2.6-xen-0013-MTRR-use-cpu_callout_map-instead-of-cpu_online_map.patch, 1.1.2.1, NONE linux-2.6-xen-0014-xen-mtrr-Add-mtrr_ops-support-for-Xen-mtrr.patch, 1.1.2.1, NONE linux-2.6-xen-0015-xen-mtrr-Don-t-enable-xen-mtrr-on-bare-metal.patch, 1.1.2.1, NONE linux-2.6-xen-0016-xen-mtrr-set-cpu-in-cpu_callout_map.patch, 1.1.2.1, NONE linux-2.6-xen-0017-xen-mtrr-Clean-up-the-num_var_ranges-CPU_UNKOWN-hac.patch, 1.1.2.1, NONE linux-2.6-xen-0018-xen-mtrr-Use-specific-cpu_has_foo-macros-instead-of.patch, 1.1.2.1, NONE linux-2.6-xen-0019-xen-mtrr-Kill-some-unneccessary-includes.patch, 1.1.2.1, NONE linux-2.6-xen-0020-xen-mtrr-No-need-to-explicitly-set-use_intel_if-0.patch, 1.1.2.1, NONE linux-2.6-xen-0021-xen-mtrr-Use-generic_validate_add_page.patch, 1.1.2.1, NONE linux-2.6-xen-0022-xen-mtrr-Implement-xen_get_free_region.patch, 1.1.2.1, NONE linux-2.6-xen-0023-xen-mtrr-Add-xen_-get-set-_mtrr-implementations.patch, 1.1.2.1, NONE linux-2.6-xen-0024-irq2.diff-from-Juan-Quintela.patch, 1.1.2.1, NONE linux-2.6-xen-0025-xen-dom0-Obvious-cpuid-fix-to-domU-handling.patch, 1.1.2.1, NONE linux-2.6-xen-0026-xen-debug-Diagnose-bind_virq_to_irq-errors.patch, 1.1.2.1, NONE linux-2.6-xen-0027-xen-traps-Revert-Juan-s-traps_32.c-changes-to-debug.patch, 1.1.2.1, NONE linux-2.6-xen-0028-xen-debug-Move-init_apic_mappings-after-trap-init.patch, 1.1.2.1, NONE linux-2.6-xen-0029-xen-debug-Trace-progress-in-trap_init-around-init.patch, 1.1.2.1, NONE linux-2.6-xen-0030-xen-apic-Disable-init_apic_mappings-when-under-CO.patch, 1.1.2.1, NONE linux-2.6-xen-0031-xen-debug-Log-entry-into-virtual-console-s-xen_init.patch, 1.1.2.1, NONE linux-2.6-xen-0032-xen-debug-Log-bind_virq_to_irq-events.patch, 1.1.2.1, NONE linux-2.6-xen-0033-xen-debug-Work-around-USB-issue-triggered-by-Xen-de.patch, 1.1.2.1, NONE linux-2.6-xen-0034-Remove-duplicated-dma_alloc-free_noncoherent-define.patch, 1.1.2.1, NONE linux-2.6-xen-0035-xem-dom0-Add-hypervisor-memory_exchange-descriptor.patch, 1.1.2.1, NONE linux-2.6-xen-0036-xen-dom0-add-virt_to_pfn-macro.patch, 1.1.2.1, NONE linux-2.6-xen-0037-xen-dom0-use-virt_to_pfn-where-appropriate.patch, 1.1.2.1, NONE linux-2.6-xen-0038-xen-dom0-Add-contiguous-region-support.patch, 1.1.2.1, NONE linux-2.6-xen-0039-xen-dom0-Don-t-mask-off-PCD-bits-from-pte-entries.patch, 1.1.2.1, NONE linux-2.6-xen-0040-xen-dom0-Remove-duplicate-xen_store_interface-assig.patch, 1.1.2.1, NONE linux-2.6-xen-0041-xen-dom0-Slightly-re-arrange-xenbus_probe_init-er.patch, 1.1.2.1, NONE linux-2.6-xen-0042-xen-dom0-Use-max_low_pfn-declaration-from-linux-boo.patch, 1.1.2.1, NONE linux-2.6-xen-0043-xen-dma-Add-dma_mapping_ops-indirection-for-32-bit.patch, 1.1.2.1, NONE linux-2.6-xen-0044-xen-dma-Remove-unused-32-bit-dma_ops-map_simple-me.patch, 1.1.2.1, NONE linux-2.6-xen-0045-xen-dma-Initial-commit-of-pci-xen.c-dma-mapping-fun.patch, 1.1.2.1, NONE linux-2.6-xen-0046-xen-dma-Add-calls-to-dma_ops-alloc-free_coherent-ho.patch, 1.1.2.1, NONE linux-2.6-xen-0047-xen-dma-Add-xen_alloc-free_coherent.patch, 1.1.2.1, NONE linux-2.6-xen-0048-xen-dma-Don-t-merge-bios-on-xen-pvops.patch, 1.1.2.1, NONE linux-2.6-xen-0049-xen-dom0-Minor-coding-style-issue-in-ISA-mapping-co.patch, 1.1.2.1, NONE linux-2.6-xen-0050-xen-dom0-Use-i-PAGE_SHIFT-instead-of-PAGE_DOWN-i.patch, 1.1.2.1, NONE linux-2.6-xen-0051-xen-dom0-Match-up-set_pte_mfn-prototype-with-the.patch, 1.1.2.1, NONE linux-2.6-xen-0052-xen-dom0-Reserve-ISA-address-space-earlier.patch, 1.1.2.1, NONE linux-2.6-xen-0053-xen-Add-empty-xenctrl-module.patch, 1.1.2.1, NONE linux-2.6-xen-0054-xen-dom0-Add-proc-xen-capabilities.patch, 1.1.2.1, NONE linux-2.6-xen-0055-xen-Add-proc-xen-privcmd.patch, 1.1.2.1, NONE linux-2.6-xen-0056-xen-dom0-Add-proc-xen-xsd_-port-kva.patch, 1.1.2.1, NONE linux-2.6-xen-0057-xen-Add-proc-xen-xenbus.patch, 1.1.2.1, NONE linux-2.6-xen-0058-xen-Add-dev-xen-evtchn.patch, 1.1.2.1, NONE linux-2.6-xen-0059-xen-Add-__init-__exit-notations-to-xenctrl-function.patch, 1.1.2.1, NONE linux-2.6-xen-0060-xen-Add-Xen-s-sys-hypervisor-interface.patch, 1.1.2.1, NONE linux-2.6-xen-0061-xen-dom0-Add-basic-proc-xen-balloon.patch, 1.1.2.1, NONE linux-2.6-xen-0062-xen-dom0-Re-work-privcmd_ioctl-a-little.patch, 1.1.2.1, NONE linux-2.6-xen-0063-xen-dom0-Add-IOCTL_PRIVCMD_MMAP.patch, 1.1.2.1, NONE linux-2.6-xen-0064-xen-dom0-Add-a-vmlinuz-target.patch, 1.1.2.1, NONE

Mark McLoughlin (markmc) fedora-extras-commits at redhat.com
Fri Feb 22 13:36:08 UTC 2008


Author: markmc

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

Modified Files:
      Tag: private-markmc-pv-ops-branch
	kernel.spec 
	linux-2.6-xen-0001-Revert-linux-2.6-execshield.patch-from-kernel-2_6_24.patch 
	linux-2.6-xen-0002-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch 
	linux-2.6-xen-0003-fbdev-Make-deferred-I-O-work-as-advertized.patch 
	linux-2.6-xen-0004-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch 
Added Files:
      Tag: private-markmc-pv-ops-branch
	linux-2.6-xen-0005-xen-Module-autoprobing-support-for-frontend-drivers.patch 
	linux-2.6-xen-0006-xen-Add-compatibility-aliases-for-frontend-drivers.patch 
	linux-2.6-xen-0007-xen-dom0-Make-hvc_xen-console-work-for-dom0.patch 
	linux-2.6-xen-0008-xen-dom0-Initialize-xenbus-for-dom0.patch 
	linux-2.6-xen-0009-xen-dom0-Set-up-basic-IO-permissions-for-dom0.patch 
	linux-2.6-xen-0010-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch 
	linux-2.6-xen-0011-xen-dom0-Add-support-for-the-platform_ops-hypercall.patch 
	linux-2.6-xen-0012-xen-acpi-Enable-early-access-to-ACPI-tables.patch 
	linux-2.6-xen-0013-xen-dom0-Add-paravirt_ops-ioremap_page_range-for.patch 
	linux-2.6-xen-0014-MTRR-use-cpu_callout_map-instead-of-cpu_online_map.patch 
	linux-2.6-xen-0015-xen-mtrr-Add-mtrr_ops-support-for-Xen-mtrr.patch 
	linux-2.6-xen-0016-xen-mtrr-Don-t-enable-xen-mtrr-on-bare-metal.patch 
	linux-2.6-xen-0017-xen-mtrr-set-cpu-in-cpu_callout_map.patch 
	linux-2.6-xen-0018-xen-mtrr-Clean-up-the-num_var_ranges-CPU_UNKOWN-hac.patch 
	linux-2.6-xen-0019-xen-mtrr-Use-specific-cpu_has_foo-macros-instead-of.patch 
	linux-2.6-xen-0020-xen-mtrr-Kill-some-unneccessary-includes.patch 
	linux-2.6-xen-0021-xen-mtrr-No-need-to-explicitly-set-use_intel_if-0.patch 
	linux-2.6-xen-0022-xen-mtrr-Use-generic_validate_add_page.patch 
	linux-2.6-xen-0023-xen-mtrr-Implement-xen_get_free_region.patch 
	linux-2.6-xen-0024-xen-mtrr-Add-xen_-get-set-_mtrr-implementations.patch 
	linux-2.6-xen-0025-irq2.diff-from-Juan-Quintela.patch 
	linux-2.6-xen-0026-xen-dom0-Obvious-cpuid-fix-to-domU-handling.patch 
	linux-2.6-xen-0027-xen-debug-Diagnose-bind_virq_to_irq-errors.patch 
	linux-2.6-xen-0028-xen-traps-Revert-Juan-s-traps_32.c-changes-to-debug.patch 
	linux-2.6-xen-0029-xen-debug-Move-init_apic_mappings-after-trap-init.patch 
	linux-2.6-xen-0030-xen-debug-Trace-progress-in-trap_init-around-init.patch 
	linux-2.6-xen-0031-xen-apic-Disable-init_apic_mappings-when-under-CO.patch 
	linux-2.6-xen-0032-xen-debug-Log-entry-into-virtual-console-s-xen_init.patch 
	linux-2.6-xen-0033-xen-debug-Log-bind_virq_to_irq-events.patch 
	linux-2.6-xen-0034-xen-debug-Work-around-USB-issue-triggered-by-Xen-de.patch 
	linux-2.6-xen-0035-Remove-duplicated-dma_alloc-free_noncoherent-define.patch 
	linux-2.6-xen-0036-xem-dom0-Add-hypervisor-memory_exchange-descriptor.patch 
	linux-2.6-xen-0037-xen-dom0-add-virt_to_pfn-macro.patch 
	linux-2.6-xen-0038-xen-dom0-use-virt_to_pfn-where-appropriate.patch 
	linux-2.6-xen-0039-xen-dom0-Add-contiguous-region-support.patch 
	linux-2.6-xen-0040-xen-dom0-Don-t-mask-off-PCD-bits-from-pte-entries.patch 
	linux-2.6-xen-0041-xen-dom0-Remove-duplicate-xen_store_interface-assig.patch 
	linux-2.6-xen-0042-xen-dom0-Slightly-re-arrange-xenbus_probe_init-er.patch 
	linux-2.6-xen-0043-xen-dom0-Use-max_low_pfn-declaration-from-linux-boo.patch 
	linux-2.6-xen-0044-xen-dma-Add-dma_mapping_ops-indirection-for-32-bit.patch 
	linux-2.6-xen-0045-xen-dma-Remove-unused-32-bit-dma_ops-map_simple-me.patch 
	linux-2.6-xen-0046-xen-dma-Initial-commit-of-pci-xen.c-dma-mapping-fun.patch 
	linux-2.6-xen-0047-xen-dma-Add-calls-to-dma_ops-alloc-free_coherent-ho.patch 
	linux-2.6-xen-0048-xen-dma-Add-xen_alloc-free_coherent.patch 
	linux-2.6-xen-0049-xen-dma-Don-t-merge-bios-on-xen-pvops.patch 
	linux-2.6-xen-0050-xen-dom0-Minor-coding-style-issue-in-ISA-mapping-co.patch 
	linux-2.6-xen-0051-xen-dom0-Use-i-PAGE_SHIFT-instead-of-PAGE_DOWN-i.patch 
	linux-2.6-xen-0052-xen-dom0-Match-up-set_pte_mfn-prototype-with-the.patch 
	linux-2.6-xen-0053-xen-dom0-Reserve-ISA-address-space-earlier.patch 
	linux-2.6-xen-0054-xen-Add-empty-xenctrl-module.patch 
	linux-2.6-xen-0055-xen-dom0-Add-proc-xen-capabilities.patch 
	linux-2.6-xen-0056-xen-Add-proc-xen-privcmd.patch 
	linux-2.6-xen-0057-xen-dom0-Add-proc-xen-xsd_-port-kva.patch 
	linux-2.6-xen-0058-xen-Add-proc-xen-xenbus.patch 
	linux-2.6-xen-0059-xen-Add-dev-xen-evtchn.patch 
	linux-2.6-xen-0060-xen-Add-__init-__exit-notations-to-xenctrl-function.patch 
	linux-2.6-xen-0061-xen-Add-Xen-s-sys-hypervisor-interface.patch 
	linux-2.6-xen-0062-xen-dom0-Add-basic-proc-xen-balloon.patch 
	linux-2.6-xen-0063-xen-dom0-Re-work-privcmd_ioctl-a-little.patch 
	linux-2.6-xen-0064-xen-dom0-Add-IOCTL_PRIVCMD_MMAP.patch 
	linux-2.6-xen-0065-xen-dom0-Add-a-vmlinuz-target.patch 
Removed Files:
      Tag: private-markmc-pv-ops-branch
	linux-2.6-xen-0005-Add-compatibility-aliases-for-Xen-block-network-fron.patch 
	linux-2.6-xen-0006-xen-dom0-Make-hvc_xen-console-work-for-dom0.patch 
	linux-2.6-xen-0007-xen-dom0-Initialize-xenbus-for-dom0.patch 
	linux-2.6-xen-0008-xen-dom0-Set-up-basic-IO-permissions-for-dom0.patch 
	linux-2.6-xen-0009-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch 
	linux-2.6-xen-0010-xen-dom0-Add-support-for-the-platform_ops-hypercall.patch 
	linux-2.6-xen-0011-xen-acpi-Enable-early-access-to-ACPI-tables.patch 
	linux-2.6-xen-0012-xen-dom0-Add-paravirt_ops-ioremap_page_range-for.patch 
	linux-2.6-xen-0013-MTRR-use-cpu_callout_map-instead-of-cpu_online_map.patch 
	linux-2.6-xen-0014-xen-mtrr-Add-mtrr_ops-support-for-Xen-mtrr.patch 
	linux-2.6-xen-0015-xen-mtrr-Don-t-enable-xen-mtrr-on-bare-metal.patch 
	linux-2.6-xen-0016-xen-mtrr-set-cpu-in-cpu_callout_map.patch 
	linux-2.6-xen-0017-xen-mtrr-Clean-up-the-num_var_ranges-CPU_UNKOWN-hac.patch 
	linux-2.6-xen-0018-xen-mtrr-Use-specific-cpu_has_foo-macros-instead-of.patch 
	linux-2.6-xen-0019-xen-mtrr-Kill-some-unneccessary-includes.patch 
	linux-2.6-xen-0020-xen-mtrr-No-need-to-explicitly-set-use_intel_if-0.patch 
	linux-2.6-xen-0021-xen-mtrr-Use-generic_validate_add_page.patch 
	linux-2.6-xen-0022-xen-mtrr-Implement-xen_get_free_region.patch 
	linux-2.6-xen-0023-xen-mtrr-Add-xen_-get-set-_mtrr-implementations.patch 
	linux-2.6-xen-0024-irq2.diff-from-Juan-Quintela.patch 
	linux-2.6-xen-0025-xen-dom0-Obvious-cpuid-fix-to-domU-handling.patch 
	linux-2.6-xen-0026-xen-debug-Diagnose-bind_virq_to_irq-errors.patch 
	linux-2.6-xen-0027-xen-traps-Revert-Juan-s-traps_32.c-changes-to-debug.patch 
	linux-2.6-xen-0028-xen-debug-Move-init_apic_mappings-after-trap-init.patch 
	linux-2.6-xen-0029-xen-debug-Trace-progress-in-trap_init-around-init.patch 
	linux-2.6-xen-0030-xen-apic-Disable-init_apic_mappings-when-under-CO.patch 
	linux-2.6-xen-0031-xen-debug-Log-entry-into-virtual-console-s-xen_init.patch 
	linux-2.6-xen-0032-xen-debug-Log-bind_virq_to_irq-events.patch 
	linux-2.6-xen-0033-xen-debug-Work-around-USB-issue-triggered-by-Xen-de.patch 
	linux-2.6-xen-0034-Remove-duplicated-dma_alloc-free_noncoherent-define.patch 
	linux-2.6-xen-0035-xem-dom0-Add-hypervisor-memory_exchange-descriptor.patch 
	linux-2.6-xen-0036-xen-dom0-add-virt_to_pfn-macro.patch 
	linux-2.6-xen-0037-xen-dom0-use-virt_to_pfn-where-appropriate.patch 
	linux-2.6-xen-0038-xen-dom0-Add-contiguous-region-support.patch 
	linux-2.6-xen-0039-xen-dom0-Don-t-mask-off-PCD-bits-from-pte-entries.patch 
	linux-2.6-xen-0040-xen-dom0-Remove-duplicate-xen_store_interface-assig.patch 
	linux-2.6-xen-0041-xen-dom0-Slightly-re-arrange-xenbus_probe_init-er.patch 
	linux-2.6-xen-0042-xen-dom0-Use-max_low_pfn-declaration-from-linux-boo.patch 
	linux-2.6-xen-0043-xen-dma-Add-dma_mapping_ops-indirection-for-32-bit.patch 
	linux-2.6-xen-0044-xen-dma-Remove-unused-32-bit-dma_ops-map_simple-me.patch 
	linux-2.6-xen-0045-xen-dma-Initial-commit-of-pci-xen.c-dma-mapping-fun.patch 
	linux-2.6-xen-0046-xen-dma-Add-calls-to-dma_ops-alloc-free_coherent-ho.patch 
	linux-2.6-xen-0047-xen-dma-Add-xen_alloc-free_coherent.patch 
	linux-2.6-xen-0048-xen-dma-Don-t-merge-bios-on-xen-pvops.patch 
	linux-2.6-xen-0049-xen-dom0-Minor-coding-style-issue-in-ISA-mapping-co.patch 
	linux-2.6-xen-0050-xen-dom0-Use-i-PAGE_SHIFT-instead-of-PAGE_DOWN-i.patch 
	linux-2.6-xen-0051-xen-dom0-Match-up-set_pte_mfn-prototype-with-the.patch 
	linux-2.6-xen-0052-xen-dom0-Reserve-ISA-address-space-earlier.patch 
	linux-2.6-xen-0053-xen-Add-empty-xenctrl-module.patch 
	linux-2.6-xen-0054-xen-dom0-Add-proc-xen-capabilities.patch 
	linux-2.6-xen-0055-xen-Add-proc-xen-privcmd.patch 
	linux-2.6-xen-0056-xen-dom0-Add-proc-xen-xsd_-port-kva.patch 
	linux-2.6-xen-0057-xen-Add-proc-xen-xenbus.patch 
	linux-2.6-xen-0058-xen-Add-dev-xen-evtchn.patch 
	linux-2.6-xen-0059-xen-Add-__init-__exit-notations-to-xenctrl-function.patch 
	linux-2.6-xen-0060-xen-Add-Xen-s-sys-hypervisor-interface.patch 
	linux-2.6-xen-0061-xen-dom0-Add-basic-proc-xen-balloon.patch 
	linux-2.6-xen-0062-xen-dom0-Re-work-privcmd_ioctl-a-little.patch 
	linux-2.6-xen-0063-xen-dom0-Add-IOCTL_PRIVCMD_MMAP.patch 
	linux-2.6-xen-0064-xen-dom0-Add-a-vmlinuz-target.patch 
Log Message:
* Fri Feb 22 2008 Mark McLoughlin <markmc at redhat.com>
- Add support for auto-probing frontend drivers


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

--- NEW FILE linux-2.6-xen-0005-xen-Module-autoprobing-support-for-frontend-drivers.patch ---
>From f82ab30c0065b7a10246bce6358c970e7a944247 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 2bdebcb..25aa472 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -982,3 +982,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 bca37bf..67fe705 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.2


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

--- NEW FILE linux-2.6-xen-0006-xen-Add-compatibility-aliases-for-frontend-drivers.patch ---
>From 6f51d03cf70e1f654334ceab5103d60727d76b0b 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 25aa472..009451f 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -983,3 +983,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 67fe705..78e7452 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.2


linux-2.6-xen-0007-xen-dom0-Make-hvc_xen-console-work-for-dom0.patch:

--- NEW FILE linux-2.6-xen-0007-xen-dom0-Make-hvc_xen-console-work-for-dom0.patch ---
>From 0142b1f6b091dd7b50e845eba2560996833b9e57 Mon Sep 17 00:00:00 2001
From: Juan Quintela <quintela at redhat.com>
Date: Mon, 26 Nov 2007 07:38:29 +0100
Subject: [PATCH] xen dom0: Make hvc_xen console work for dom0.

Signed-off-by: Jeremy Fitzhardinge <jeremy at xensource.com>
Signed-off-by: Juan Quintela <quintela at redhat.com>
Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/xen/events.c  |    2 +-
 drivers/char/hvc_xen.c |   61 +++++++++++++++++++++++++++++++++++++++++------
 include/xen/events.h   |    2 +
 3 files changed, 56 insertions(+), 9 deletions(-)

diff --git a/arch/x86/xen/events.c b/arch/x86/xen/events.c
index 6d1da58..2bf9731 100644
--- a/arch/x86/xen/events.c
+++ b/arch/x86/xen/events.c
@@ -311,7 +311,7 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
 }
 
 
-static int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
+int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
 {
 	struct evtchn_bind_virq bind_virq;
 	int evtchn, irq;
diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c
index dd68f85..6e85664 100644
--- a/drivers/char/hvc_xen.c
+++ b/drivers/char/hvc_xen.c
@@ -50,7 +50,7 @@ static inline void notify_daemon(void)
 	notify_remote_via_evtchn(xen_start_info->console.domU.evtchn);
 }
 
-static int write_console(uint32_t vtermno, const char *data, int len)
+static int domU_write_console(uint32_t vtermno, const char *data, int len)
 {
 	struct xencons_interface *intf = xencons_interface();
 	XENCONS_RING_IDX cons, prod;
@@ -71,7 +71,28 @@ static int write_console(uint32_t vtermno, const char *data, int len)
 	return sent;
 }
 
-static int read_console(uint32_t vtermno, char *buf, int len)
+static int dom0_write_console(uint32_t vtermno, const char *data, int len)
+{
+	int ret;
+
+	ret = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)data);
+
+	return ret < 0 ? 0 : len;
+}
+
+static int write_console(uint32_t vtermno, const char *data, int len)
+{
+	int ret;
+
+	if (is_initial_xendomain())
+		ret = dom0_write_console(vtermno, data, len);
+	else
+		ret = domU_write_console(vtermno, data, len);
+
+	return ret;
+}
+
+static int domU_read_console(uint32_t vtermno, char *buf, int len)
 {
 	struct xencons_interface *intf = xencons_interface();
 	XENCONS_RING_IDX cons, prod;
@@ -92,22 +113,40 @@ static int read_console(uint32_t vtermno, char *buf, int len)
 	return recv;
 }
 
-static struct hv_ops hvc_ops = {
-	.get_chars = read_console,
-	.put_chars = write_console,
+static int dom0_read_console(uint32_t vtermno, char *buf, int len)
+{
+	return HYPERVISOR_console_io(CONSOLEIO_read, len, buf);
+}
+
+static struct hv_ops domU_hvc_ops = {
+	.get_chars = domU_read_console,
+	.put_chars = domU_write_console,
+};
+
+static struct hv_ops dom0_hvc_ops = {
+	.get_chars = dom0_read_console,
+	.put_chars = dom0_write_console,
 };
 
 static int __init xen_init(void)
 {
 	struct hvc_struct *hp;
+	struct hv_ops *ops;
 
 	if (!is_running_on_xen())
 		return 0;
 
-	xencons_irq = bind_evtchn_to_irq(xen_start_info->console.domU.evtchn);
+	if (is_initial_xendomain()) {
+		ops = &dom0_hvc_ops;
+		xencons_irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
+	} else {
+		ops = &domU_hvc_ops;
+		xencons_irq = bind_evtchn_to_irq(xen_start_info->console.domU.evtchn);
+	}
+
 	if (xencons_irq < 0)
 		xencons_irq = 0 /* NO_IRQ */;
-	hp = hvc_alloc(HVC_COOKIE, xencons_irq, &hvc_ops, 256);
+	hp = hvc_alloc(HVC_COOKIE, xencons_irq, ops, 256);
 	if (IS_ERR(hp))
 		return PTR_ERR(hp);
 
@@ -123,10 +162,16 @@ static void __exit xen_fini(void)
 
 static int xen_cons_init(void)
 {
+	struct hv_ops *ops;
+
 	if (!is_running_on_xen())
 		return 0;
 
-	hvc_instantiate(HVC_COOKIE, 0, &hvc_ops);
+	ops = &domU_hvc_ops;
+	if (is_initial_xendomain())
+		ops = &dom0_hvc_ops;
+
+	hvc_instantiate(HVC_COOKIE, 0, ops);
 	return 0;
 }
 
diff --git a/include/xen/events.h b/include/xen/events.h
index 2bde54d..0436486 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -18,6 +18,8 @@ int bind_evtchn_to_irqhandler(unsigned int evtchn,
 			      irq_handler_t handler,
 			      unsigned long irqflags, const char *devname,
 			      void *dev_id);
+int bind_virq_to_irq(unsigned int virq, unsigned int cpu);
+
 int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu,
 			    irq_handler_t handler,
 			    unsigned long irqflags, const char *devname,
-- 
1.5.4.2


linux-2.6-xen-0008-xen-dom0-Initialize-xenbus-for-dom0.patch:

--- NEW FILE linux-2.6-xen-0008-xen-dom0-Initialize-xenbus-for-dom0.patch ---
>From ae56854ed82e9c8181edd89bffc6a5e7a602c5ca Mon Sep 17 00:00:00 2001
From: Juan Quintela <quintela at redhat.com>
Date: Mon, 26 Nov 2007 08:35:10 +0100
Subject: [PATCH] xen dom0: Initialize xenbus for dom0.

Signed-off-by: Jeremy Fitzhardinge <jeremy at xensource.com>
Signed-off-by: Juan Quintela <quintela at redhat.com>
---
 drivers/xen/xenbus/xenbus_probe.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index 336363c..7263b3d 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -810,6 +810,7 @@ void xenbus_probe(struct work_struct *unused)
 static int __init xenbus_probe_init(void)
 {
 	int err = 0;
+	unsigned long page = 0;
 
 	DPRINTK("");
 
@@ -830,7 +831,31 @@ static int __init xenbus_probe_init(void)
 	 * Domain0 doesn't have a store_evtchn or store_mfn yet.
 	 */
 	if (is_initial_xendomain()) {
-		/* dom0 not yet supported */
+		struct evtchn_alloc_unbound alloc_unbound;
+
+		/* Allocate page. */
+		page = get_zeroed_page(GFP_KERNEL);
+		if (!page)
+			return -ENOMEM;
+
+		xen_store_mfn = xen_start_info->store_mfn =
+			pfn_to_mfn(virt_to_phys((void *)page) >>
+				   PAGE_SHIFT);
+
+		/* Next allocate a local port which xenstored can bind to */
+		alloc_unbound.dom        = DOMID_SELF;
+		alloc_unbound.remote_dom = 0;
+
+		err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
+						  &alloc_unbound);
+		if (err == -ENOSYS)
+			goto out_unreg_front;
+
+		BUG_ON(err);
+		xen_store_evtchn = xen_start_info->store_evtchn =
+			alloc_unbound.port;
+
+		xen_store_interface = mfn_to_virt(xen_store_mfn);
 	} else {
 		xenstored_ready = 1;
 		xen_store_evtchn = xen_start_info->store_evtchn;
@@ -858,6 +883,9 @@ static int __init xenbus_probe_init(void)
 	bus_unregister(&xenbus_frontend.bus);
 
   out_error:
+	if (page != 0)
+		free_page(page);
+
 	return err;
 }
 
-- 
1.5.4.2


linux-2.6-xen-0009-xen-dom0-Set-up-basic-IO-permissions-for-dom0.patch:

--- NEW FILE linux-2.6-xen-0009-xen-dom0-Set-up-basic-IO-permissions-for-dom0.patch ---
>From 449196ff01f34bd88c80ac26fb2f0fa2cb27e51e Mon Sep 17 00:00:00 2001
From: Juan Quintela <quintela at redhat.com>
Date: Mon, 26 Nov 2007 08:53:42 +0100
Subject: [PATCH] xen dom0: Set up basic IO permissions for dom0.

Add the direct mapping area for ISA bus access, and enable IO space
access for the guest when running as dom0.

Signed-off-by: Jeremy Fitzhardinge <jeremy at xensource.com>
Signed-off-by: Juan Quintela <quintela at redhat.com>
---
 arch/x86/mm/ioremap_32.c |    3 ---
 arch/x86/xen/enlighten.c |   21 +++++++++++++++++++++
 arch/x86/xen/setup.c     |    3 ++-
 include/asm-x86/io_32.h  |    4 ++++
 4 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/arch/x86/mm/ioremap_32.c b/arch/x86/mm/ioremap_32.c
index 0b27831..63a301a 100644
--- a/arch/x86/mm/ioremap_32.c
+++ b/arch/x86/mm/ioremap_32.c
@@ -18,9 +18,6 @@
 #include <asm/tlbflush.h>
 #include <asm/pgtable.h>
 
-#define ISA_START_ADDRESS	0xa0000
-#define ISA_END_ADDRESS		0x100000
-
 /*
  * Generic mapping function (not visible outside):
  */
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 84f46e2..69a73f0 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -45,6 +45,7 @@
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/reboot.h>
+#include <asm/io.h>
 
 #include "xen-ops.h"
 #include "mmu.h"
@@ -860,6 +861,20 @@ static __init void xen_pagetable_setup_done(pgd_t *base)
 
 		pin_pagetable_pfn(level, PFN_DOWN(__pa(base)));
 	}
+
+	/*
+	 * If we're dom0, then 1:1 map the ISA machine addresses into
+	 * the kernel's address space.
+	 */
+	if (is_initial_xendomain()) {
+		unsigned i;
+
+		for(i = ISA_START_ADDRESS; i < ISA_END_ADDRESS; i += PAGE_SIZE)
+			set_pte_mfn(PAGE_OFFSET + i, PFN_DOWN(i), PAGE_KERNEL);
+
+		reserve_bootmem(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS);
+		printk(KERN_INFO "Xen: setup ISA identity maps\n");
+	}
 }
 
 /* This is called once we have the cpu_possible_map */
@@ -1211,6 +1226,12 @@ asmlinkage void __init xen_start_kernel(void)
 	if (xen_feature(XENFEAT_supervisor_mode_kernel))
 		pv_info.kernel_rpl = 0;
 
+	if (is_initial_xendomain()) {
+		struct physdev_set_iopl set_iopl;
+		set_iopl.iopl = 1;
+		HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
+	}
+
 	/* set the limit of our address space */
 	xen_reserve_top();
 
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index f84e772..3c84287 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -105,7 +105,8 @@ void __init xen_arch_setup(void)
 	xen_fill_possible_map();
 #endif
 
-	paravirt_disable_iospace();
+	if (!is_initial_xendomain())
+		paravirt_disable_iospace();
 
 	fiddle_vdso();
 }
diff --git a/include/asm-x86/io_32.h b/include/asm-x86/io_32.h
index fe881cd..e2b916e 100644
--- a/include/asm-x86/io_32.h
+++ b/include/asm-x86/io_32.h
@@ -139,6 +139,10 @@ extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys);
 #define dmi_iounmap bt_iounmap
 #define dmi_alloc alloc_bootmem
 
+
+#define ISA_START_ADDRESS	0xa0000
+#define ISA_END_ADDRESS		0x100000
+
 /*
  * ISA I/O bus memory addresses are 1:1 with the physical address.
  */
-- 
1.5.4.2


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

--- NEW FILE linux-2.6-xen-0010-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch ---
>From 14514c95709eb64732bac56021edc81c0cde46c0 Mon Sep 17 00:00:00 2001
From: Juan Quintela <quintela at redhat.com>
Date: Tue, 27 Nov 2007 06:44:53 +0100
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>
---
 arch/x86/kernel/paravirt_32.c |    2 ++
 arch/x86/mm/pgtable_32.c      |   15 ++++++++++-----
 arch/x86/xen/enlighten.c      |   38 ++++++++++++++++++++++++++++++++++----
 arch/x86/xen/mmu.c            |   30 +-----------------------------
 include/asm-x86/fixmap_32.h   |   13 +++++++++++--
 include/asm-x86/paravirt.h    |   13 +++++++++++++
 include/asm-x86/pgtable_32.h  |    3 +++
 7 files changed, 74 insertions(+), 40 deletions(-)

diff --git a/arch/x86/kernel/paravirt_32.c b/arch/x86/kernel/paravirt_32.c
index f500079..9fc62c2 100644
--- a/arch/x86/kernel/paravirt_32.c
+++ b/arch/x86/kernel/paravirt_32.c
@@ -462,6 +462,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 be61a1d..8892aad 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);
 
@@ -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_pfn(address, 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 69a73f0..7240969 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -183,10 +183,12 @@ static void xen_cpuid(unsigned int *eax, unsigned int *ebx,
 	 * Mask out inconvenient features, to try and disable as many
 	 * unsupported kernel subsystems as possible.
 	 */
-	if (*eax == 1)
-		maskedx = ~((1 << X86_FEATURE_APIC) |  /* disable APIC */
-			    (1 << X86_FEATURE_ACPI) |  /* disable ACPI */
-			    (1 << X86_FEATURE_ACC));   /* thermal monitoring */
+	if (*eax == 1) {
+		maskedx = ~(1 << X86_FEATURE_APIC);  /* disable local APIC */
+		if (!is_initial_xendomain())
+			maskedx &= ~((1 << X86_FEATURE_ACPI) |  /* disable ACPI */
+				     (1 << X86_FEATURE_ACC));   /* thermal monitoring */
+	}
 
 	asm(XEN_EMULATE_PREFIX "cpuid"
 		: "=a" (*eax),
@@ -952,6 +954,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,
@@ -1104,6 +1132,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/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 0ac6c5d..2e28104 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -119,35 +119,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/fixmap_32.h b/include/asm-x86/fixmap_32.h
index 249e753..9ed0e25 100644
--- a/include/asm-x86/fixmap_32.h
+++ b/include/asm-x86/fixmap_32.h
@@ -98,8 +98,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 f59d370..3b9d5b7 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -240,6 +240,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
@@ -1000,6 +1007,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)
 
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h
index ed3e70d..6d3687d 100644
--- a/include/asm-x86/pgtable_32.h
+++ b/include/asm-x86/pgtable_32.h
@@ -483,6 +483,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.2


linux-2.6-xen-0011-xen-dom0-Add-support-for-the-platform_ops-hypercall.patch:

--- NEW FILE linux-2.6-xen-0011-xen-dom0-Add-support-for-the-platform_ops-hypercall.patch ---
>From ae90146bef18cca6ecab5bc31cc8bba3dde0451f Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Fri, 30 Nov 2007 15:06:30 +0000
Subject: [PATCH] xen dom0: Add support for the platform_ops hypercall

Minimal changes to get platform ops (renamed dom0_ops on pv_ops) working
on pv_ops builds.  Pulls in upstream linux-2.6.18-xen.hg's platform.h

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 include/asm-x86/xen/hypercall.h  |    9 ++
 include/xen/interface/platform.h |  232 ++++++++++++++++++++++++++++++++++++++
 include/xen/interface/xen.h      |    2 +
 3 files changed, 243 insertions(+), 0 deletions(-)
 create mode 100644 include/xen/interface/platform.h

diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
index bc0ee7d..0802755 100644
--- a/include/asm-x86/xen/hypercall.h
+++ b/include/asm-x86/xen/hypercall.h
@@ -39,6 +39,7 @@
 #include <xen/interface/xen.h>
 #include <xen/interface/sched.h>
 #include <xen/interface/physdev.h>
+#include <xen/interface/platform.h>
 
 extern struct { char _entry[32]; } hypercall_page[];
 
@@ -184,6 +185,14 @@ HYPERVISOR_set_timer_op(u64 timeout)
 }
 
 static inline int
+HYPERVISOR_dom0_op(
+	struct xen_platform_op *platform_op)
+{
+	platform_op->interface_version = XENPF_INTERFACE_VERSION;
+	return _hypercall1(int, dom0_op, platform_op);
+}
+
+static inline int
 HYPERVISOR_set_debugreg(int reg, unsigned long value)
 {
 	return _hypercall2(int, set_debugreg, reg, value);
diff --git a/include/xen/interface/platform.h b/include/xen/interface/platform.h
new file mode 100644
index 0000000..0e80c53
--- /dev/null
+++ b/include/xen/interface/platform.h
@@ -0,0 +1,232 @@
+/******************************************************************************
+ * platform.h
+ * 
+ * Hardware platform operations. Intended for use by domain-0 kernel.
+ * 
+ * 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) 2002-2006, K Fraser
+ */
+
+#ifndef __XEN_PUBLIC_PLATFORM_H__
+#define __XEN_PUBLIC_PLATFORM_H__
+
+#include "xen.h"
+
+#define XENPF_INTERFACE_VERSION 0x03000001
+
+/*
+ * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
+ * 1 January, 1970 if the current system time was <system_time>.
+ */
+#define XENPF_settime             17
+struct xenpf_settime {
+    /* IN variables. */
+    uint32_t secs;
+    uint32_t nsecs;
+    uint64_t system_time;
+};
+typedef struct xenpf_settime xenpf_settime_t;
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_settime_t);
+
+/*
+ * Request memory range (@mfn, @mfn+ at nr_mfns-1) to have type @type.
+ * On x86, @type is an architecture-defined MTRR memory type.
+ * On success, returns the MTRR that was used (@reg) and a handle that can
+ * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting.
+ * (x86-specific).
+ */
+#define XENPF_add_memtype         31
+struct xenpf_add_memtype {
+    /* IN variables. */
+    unsigned long mfn;
+    uint64_t nr_mfns;
+    uint32_t type;
+    /* OUT variables. */
+    uint32_t handle;
+    uint32_t reg;
+};
+typedef struct xenpf_add_memtype xenpf_add_memtype_t;
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_add_memtype_t);
+
+/*
+ * Tear down an existing memory-range type. If @handle is remembered then it
+ * should be passed in to accurately tear down the correct setting (in case
+ * of overlapping memory regions with differing types). If it is not known
+ * then @handle should be set to zero. In all cases @reg must be set.
+ * (x86-specific).
+ */
+#define XENPF_del_memtype         32
+struct xenpf_del_memtype {
+    /* IN variables. */
+    uint32_t handle;
+    uint32_t reg;
+};
+typedef struct xenpf_del_memtype xenpf_del_memtype_t;
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_del_memtype_t);
+
+/* Read current type of an MTRR (x86-specific). */
+#define XENPF_read_memtype        33
+struct xenpf_read_memtype {
+    /* IN variables. */
+    uint32_t reg;
+    /* OUT variables. */
+    unsigned long mfn;
+    uint64_t nr_mfns;
+    uint32_t type;
+};
+typedef struct xenpf_read_memtype xenpf_read_memtype_t;
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_read_memtype_t);
+
+#define XENPF_microcode_update    35
+struct xenpf_microcode_update {
+    /* IN variables. */
+    GUEST_HANDLE(void) data;          /* Pointer to microcode data */
+    uint32_t length;                  /* Length of microcode data. */
+};
+typedef struct xenpf_microcode_update xenpf_microcode_update_t;
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_microcode_update_t);
+
+#define XENPF_platform_quirk      39
+#define QUIRK_NOIRQBALANCING      1 /* Do not restrict IO-APIC RTE targets */
+#define QUIRK_IOAPIC_BAD_REGSEL   2 /* IO-APIC REGSEL forgets its value    */
+#define QUIRK_IOAPIC_GOOD_REGSEL  3 /* IO-APIC REGSEL behaves properly     */
+struct xenpf_platform_quirk {
+    /* IN variables. */
+    uint32_t quirk_id;
+};
+typedef struct xenpf_platform_quirk xenpf_platform_quirk_t;
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_platform_quirk_t);
+
+#define XENPF_firmware_info       50
+#define XEN_FW_DISK_INFO          1 /* from int 13 AH=08/41/48 */
+#define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
+#define XEN_FW_VBEDDC_INFO        3 /* from int 10 AX=4f15 */
+struct xenpf_firmware_info {
+    /* IN variables. */
+    uint32_t type;
+    uint32_t index;
+    /* OUT variables. */
+    union {
+        struct {
+            /* Int13, Fn48: Check Extensions Present. */
+            uint8_t device;                   /* %dl: bios device number */
+            uint8_t version;                  /* %ah: major version      */
+            uint16_t interface_support;       /* %cx: support bitmap     */
+            /* Int13, Fn08: Legacy Get Device Parameters. */
+            uint16_t legacy_max_cylinder;     /* %cl[7:6]:%ch: max cyl # */
+            uint8_t legacy_max_head;          /* %dh: max head #         */
+            uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector #  */
+            /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */
+            /* NB. First uint16_t of buffer must be set to buffer size.      */
+            GUEST_HANDLE(void) edd_params;
+        } disk_info; /* XEN_FW_DISK_INFO */
+        struct {
+            uint8_t device;                   /* bios device number  */
+            uint32_t mbr_signature;           /* offset 0x1b8 in mbr */
+        } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */
+        struct {
+            /* Int10, AX=4F15: Get EDID info. */
+            uint8_t capabilities;
+            uint8_t edid_transfer_time;
+            /* must refer to 128-byte buffer */
+            GUEST_HANDLE(uchar) edid;
+        } vbeddc_info; /* XEN_FW_VBEDDC_INFO */
+    } u;
+};
+typedef struct xenpf_firmware_info xenpf_firmware_info_t;
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t);
+
+#define XENPF_enter_acpi_sleep    51
+struct xenpf_enter_acpi_sleep {
+    /* IN variables */
+    uint16_t pm1a_cnt_val;      /* PM1a control value. */
+    uint16_t pm1b_cnt_val;      /* PM1b control value. */
+    uint32_t sleep_state;       /* Which state to enter (Sn). */
+    uint32_t flags;             /* Must be zero. */
+};
+typedef struct xenpf_enter_acpi_sleep xenpf_enter_acpi_sleep_t;
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t);
+
+#define XENPF_change_freq         52
+struct xenpf_change_freq {
+    /* IN variables */
+    uint32_t flags; /* Must be zero. */
+    uint32_t cpu;   /* Physical cpu. */
+    uint64_t freq;  /* New frequency (Hz). */
+};
+typedef struct xenpf_change_freq xenpf_change_freq_t;
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_change_freq_t);
+
+/*
+ * Get idle times (nanoseconds since boot) for physical CPUs specified in the
+ * @cpumap_bitmap with range [0.. at cpumap_nr_cpus-1]. The @idletime array is
+ * indexed by CPU number; only entries with the corresponding @cpumap_bitmap
+ * bit set are written to. On return, @cpumap_bitmap is modified so that any
+ * non-existent CPUs are cleared. Such CPUs have their @idletime array entry
+ * cleared.
+ */
+#define XENPF_getidletime         53
+struct xenpf_getidletime {
+    /* IN/OUT variables */
+    /* IN: CPUs to interrogate; OUT: subset of IN which are present */
+    GUEST_HANDLE(uchar) cpumap_bitmap;
+    /* IN variables */
+    /* Size of cpumap bitmap. */
+    uint32_t cpumap_nr_cpus;
+    /* Must be indexable for every cpu in cpumap_bitmap. */
+    GUEST_HANDLE(uint64_t) idletime;
+    /* OUT variables */
+    /* System time when the idletime snapshots were taken. */
+    uint64_t now;
+};
+typedef struct xenpf_getidletime xenpf_getidletime_t;
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_getidletime_t);
+
+struct xen_platform_op {
+    uint32_t cmd;
+    uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
+    union {
+        struct xenpf_settime           settime;
+        struct xenpf_add_memtype       add_memtype;
+        struct xenpf_del_memtype       del_memtype;
+        struct xenpf_read_memtype      read_memtype;
+        struct xenpf_microcode_update  microcode;
+        struct xenpf_platform_quirk    platform_quirk;
+        struct xenpf_firmware_info     firmware_info;
+        struct xenpf_enter_acpi_sleep  enter_acpi_sleep;
+        struct xenpf_change_freq       change_freq;
+        struct xenpf_getidletime       getidletime;
+        uint8_t                        pad[128];
+    } u;
+};
+typedef struct xen_platform_op xen_platform_op_t;
+DEFINE_GUEST_HANDLE_STRUCT(xen_platform_op_t);
+
+#endif /* __XEN_PUBLIC_PLATFORM_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h
index 518a5bf..5f12e21 100644
--- a/include/xen/interface/xen.h
+++ b/include/xen/interface/xen.h
@@ -437,6 +437,8 @@ typedef uint8_t xen_domain_handle_t[16];
 #define __mk_unsigned_long(x) x ## UL
 #define mk_unsigned_long(x) __mk_unsigned_long(x)
 
+DEFINE_GUEST_HANDLE(uint64_t);
+
 #else /* __ASSEMBLY__ */
 
 /* In assembly code we cannot use C numeric constant suffixes. */
-- 
1.5.4.2


linux-2.6-xen-0012-xen-acpi-Enable-early-access-to-ACPI-tables.patch:

--- NEW FILE linux-2.6-xen-0012-xen-acpi-Enable-early-access-to-ACPI-tables.patch ---
>From ae2c3d78c8da89040a410d57279426734508a8ae Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Fri, 7 Dec 2007 11:39:27 +0000
Subject: [PATCH] xen acpi: Enable early access to ACPI tables.

Always use the fixmap remapping to remap ACPI tables during boot in
__acpi_map_table.  Tables which are identity-mapped on baremetal may
not be on Xen.

Add xen-specific logic to detect when ioremap is being called on local
RAM.

Use isa_bus_to_virt on ISA regions for consistency with the fixmap code
Use is_local_lowmem() to test for local non-highmem pages in a Xen-
compatible way.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/kernel/acpi/boot.c |   34 +++++++++++++++-------------------
 arch/x86/mm/ioremap_32.c    |   34 ++++++++++++++++++++++++++--------
 2 files changed, 41 insertions(+), 27 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 0ca27c7..e59bda5 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -40,6 +40,8 @@
 #include <asm/io.h>
 #include <asm/mpspec.h>
 
+#include <asm/xen/hypervisor.h>
+
 static int __initdata acpi_force = 0;
 
 #ifdef	CONFIG_ACPI
@@ -103,22 +105,6 @@ static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  */
 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
 
-#ifdef	CONFIG_X86_64
-
-/* rely on all ACPI tables being in the direct mapping */
-char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
-{
-	if (!phys_addr || !size)
-		return NULL;
-
-	if (phys_addr+size <= (end_pfn_map << PAGE_SHIFT) + PAGE_SIZE)
-		return __va(phys_addr);
-
-	return NULL;
-}
-
-#else
-
 /*
  * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
  * to map the target physical address. The problem is that set_fixmap()
@@ -136,8 +122,19 @@ char *__acpi_map_table(unsigned long phys, unsigned long size)
 	unsigned long base, offset, mapped_size;
 	int idx;
 
-	if (phys + size < 8 * 1024 * 1024)
-		return __va(phys);
+	if (!phys || !size)
+		return NULL;
+
+	if (!is_running_on_xen()) {
+#ifdef	CONFIG_X86_64
+		/* rely on all ACPI tables being in the direct mapping */
+		if (phys+size <= (end_pfn_map << PAGE_SHIFT) + PAGE_SIZE)
+			return __va(phys);
+#else
+		if (phys + size < 8 * 1024 * 1024)
+			return __va(phys);
+#endif
+	}
 
 	offset = phys & (PAGE_SIZE - 1);
 	mapped_size = PAGE_SIZE - offset;
@@ -158,7 +155,6 @@ char *__acpi_map_table(unsigned long phys, unsigned long size)
 
 	return ((unsigned char *)base + offset);
 }
-#endif
 
 #ifdef CONFIG_PCI_MMCONFIG
 /* The physical address of the MMCONFIG aperture.  Set from ACPI tables. */
diff --git a/arch/x86/mm/ioremap_32.c b/arch/x86/mm/ioremap_32.c
index 63a301a..b4e71f4 100644
--- a/arch/x86/mm/ioremap_32.c
+++ b/arch/x86/mm/ioremap_32.c
@@ -18,6 +18,9 @@
 #include <asm/tlbflush.h>
 #include <asm/pgtable.h>
 
+#include <asm/xen/hypervisor.h>
+#include <xen/page.h>
+
 /*
  * Generic mapping function (not visible outside):
  */
@@ -31,6 +34,21 @@
  * have to convert them into an offset in a page-aligned mapping, but the
  * caller shouldn't need to know that small detail.
  */
+/*
+ * Does @address reside within a non-highmem page that is local to this virtual
+ * machine (i.e., not an I/O page, nor a memory page belonging to another VM).
+ * See the comment that accompanies mfn_to_local_pfn() in page.h to understand
+ * why this works.
+ */
+static inline int is_local_lowmem(unsigned long address)
+{
+	extern unsigned long max_low_pfn;
+	if (is_running_on_xen())
+		return (mfn_to_local_pfn(address >> PAGE_SHIFT) < max_low_pfn);
+	else
+		return (address <= virt_to_phys(high_memory - 1));
+}
+
 void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
 {
 	void __iomem * addr;
@@ -47,12 +65,12 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
 	 * Don't remap the low PCI/ISA area, it's always mapped..
 	 */
 	if (phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS)
-		return (void __iomem *) phys_to_virt(phys_addr);
+		return (void __iomem *) isa_bus_to_virt(phys_addr);
 
 	/*
 	 * Don't allow anybody to remap normal RAM that we're using..
 	 */
-	if (phys_addr <= virt_to_phys(high_memory - 1)) {
+	if (is_local_lowmem(phys_addr)) {
 		char *t_addr, *t_end;
 		struct page *page;
 
@@ -123,8 +141,8 @@ void __iomem *ioremap_nocache (unsigned long phys_addr, unsigned long size)
 	/* Guaranteed to be > phys_addr, as per __ioremap() */
 	last_addr = phys_addr + size - 1;
 
-	if (last_addr < virt_to_phys(high_memory) - 1) {
-		struct page *ppage = virt_to_page(__va(phys_addr));		
+	if (is_local_lowmem(last_addr)) {
+		struct page *ppage = virt_to_page(bus_to_virt(phys_addr));
 		unsigned long npages;
 
 		phys_addr &= PAGE_MASK;
@@ -166,8 +184,8 @@ void iounmap(volatile void __iomem *addr)
 	 * vm_area and by simply returning an address into the kernel mapping
 	 * of ISA space.   So handle that here.
 	 */
-	if (addr >= phys_to_virt(ISA_START_ADDRESS) &&
-			addr < phys_to_virt(ISA_END_ADDRESS))
+	if (addr >= isa_bus_to_virt(ISA_START_ADDRESS) &&
+			addr < isa_bus_to_virt(ISA_END_ADDRESS))
 		return;
 
 	addr = (volatile void __iomem *)(PAGE_MASK & (unsigned long __force)addr);
@@ -191,8 +209,8 @@ void iounmap(volatile void __iomem *addr)
 	}
 
 	/* Reset the direct mapping. Can block */
-	if ((p->flags >> 20) && p->phys_addr < virt_to_phys(high_memory) - 1) {
-		change_page_attr(virt_to_page(__va(p->phys_addr)),
+	if ((p->flags >> 20) && is_local_lowmem(p->phys_addr)) {
+		change_page_attr(virt_to_page(bus_to_virt(p->phys_addr)),
 				 get_vm_area_size(p) >> PAGE_SHIFT,
 				 PAGE_KERNEL);
 		global_flush_tlb();
-- 
1.5.4.2


linux-2.6-xen-0013-xen-dom0-Add-paravirt_ops-ioremap_page_range-for.patch:

--- NEW FILE linux-2.6-xen-0013-xen-dom0-Add-paravirt_ops-ioremap_page_range-for.patch ---
>From 3a3f635bcb87484ce929d02472e7c7557a914b2e Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Fri, 7 Dec 2007 15:27:21 +0000
Subject: [PATCH] xen dom0: Add paravirt_ops ioremap_page_range() for Xen.

Adds a new pv_mmu_ops field for ioremap_page_range, and the necessary
pv-ops plumbing to connect to lib/ioremap.c's default implementation on
baremetal while still getting xen's hypercall-based implementation when
necessary.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/kernel/paravirt_32.c |    1 +
 arch/x86/mm/pgtable_32.c      |    7 ++
 arch/x86/xen/Makefile         |    2 +-
 arch/x86/xen/enlighten.c      |    1 +
 arch/x86/xen/ioremap.c        |  147 +++++++++++++++++++++++++++++++++++++++++
 arch/x86/xen/mmu.h            |    3 +
 include/asm-x86/fixmap_32.h   |    2 +
 include/asm-x86/paravirt.h    |   10 +++
 include/linux/io.h            |   12 ++-
 lib/ioremap.c                 |    4 +-
 10 files changed, 182 insertions(+), 7 deletions(-)
 create mode 100644 arch/x86/xen/ioremap.c

diff --git a/arch/x86/kernel/paravirt_32.c b/arch/x86/kernel/paravirt_32.c
index 9fc62c2..e578f14 100644
--- a/arch/x86/kernel/paravirt_32.c
+++ b/arch/x86/kernel/paravirt_32.c
@@ -464,6 +464,7 @@ struct pv_mmu_ops pv_mmu_ops = {
 	},
 
 	.set_fixmap = native_set_fixmap,
+	.ioremap_page_range = native_ioremap_page_range,
 };
 
 EXPORT_SYMBOL_GPL(pv_time_ops);
diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
index 8892aad..d1ca199 100644
--- a/arch/x86/mm/pgtable_32.c
+++ b/arch/x86/mm/pgtable_32.c
@@ -15,6 +15,7 @@
 #include <linux/spinlock.h>
 #include <linux/module.h>
 #include <linux/quicklist.h>
+#include <linux/io.h>
 
 #include <asm/system.h>
 #include <asm/pgtable.h>
@@ -167,6 +168,12 @@ void native_set_fixmap(enum fixed_addresses idx, unsigned long phys, pgprot_t fl
 	__native_set_fixmap(idx, pfn_pte(phys >> PAGE_SHIFT, flags));
 }
 
+int native_ioremap_page_range(unsigned long addr, unsigned long end,
+			       unsigned long phys_addr, pgprot_t prot)
+{
+	return __ioremap_page_range(addr, end, phys_addr, prot);
+}
+
 /**
  * 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/Makefile b/arch/x86/xen/Makefile
index 343df24..7ef9e01 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -1,4 +1,4 @@
 obj-y		:= enlighten.o setup.o features.o multicalls.o mmu.o \
-			events.o time.o manage.o xen-asm.o
+			events.o time.o manage.o xen-asm.o ioremap.o
 
 obj-$(CONFIG_SMP)	+= smp.o
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 7240969..b84f57b 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1134,6 +1134,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = {
 	},
 
 	.set_fixmap = xen_set_fixmap,
+	.ioremap_page_range = xen_ioremap_page_range,
 };
 
 #ifdef CONFIG_SMP
diff --git a/arch/x86/xen/ioremap.c b/arch/x86/xen/ioremap.c
new file mode 100644
index 0000000..4cbbca2
--- /dev/null
+++ b/arch/x86/xen/ioremap.c
@@ -0,0 +1,147 @@
+/*
+ * arch/x86/xen/ioremap.c
+ *
+ * Xen-specific paravirt-ops routines to support re-mapping IO memory
+ * to kernel address space so that we can access it within a Xen privileged
+ * domain.
+ *
+ * (C) Copyright 1995 1996 Linus Torvalds
+ */
+
+#include <linux/vmalloc.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/io.h>
+
+#include <asm/fixmap.h>
+#include <asm/cacheflush.h>
+#include <asm/tlbflush.h>
+#include <asm/pgtable.h>
+#include <asm/pgalloc.h>
+
+#include <asm/xen/hypercall.h>
+#include <xen/page.h>
+
+static int direct_remap_area_pte_fn(pte_t *pte, 
+				    struct page *pmd_page,
+				    unsigned long address, 
+				    void *data)
+{
+	struct mmu_update **v = (struct mmu_update **)data;
+
+	BUG_ON(!pte_none(*pte));
+
+	(*v)->ptr = ((u64)pfn_to_mfn(page_to_pfn(pmd_page)) <<
+		     PAGE_SHIFT) | ((unsigned long)pte & ~PAGE_MASK);
+	(*v)++;
+
+	return 0;
+}
+
+static int __direct_remap_pfn_range(struct mm_struct *mm,
+				    unsigned long address, 
+				    unsigned long mfn,
+				    unsigned long size, 
+				    pgprot_t prot,
+				    domid_t  domid)
+{
+	int rc;
+	unsigned long i, start_address;
+	struct mmu_update *u, *v, *w;
+
+	u = v = w = (struct mmu_update *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	if (u == NULL)
+		return -ENOMEM;
+
+	start_address = address;
+
+	flush_cache_all();
+
+	for (i = 0; i < size; i += PAGE_SIZE) {
+		if ((v - u) == (PAGE_SIZE / sizeof(struct mmu_update))) {
+			/* Flush a full batch after filling in the PTE ptrs. */
+			rc = apply_to_page_range(mm, start_address, 
+						 address - start_address,
+						 direct_remap_area_pte_fn, &w);
+			if (rc)
+				goto out;
+			rc = -EFAULT;
+			if (HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0)
+				goto out;
+			v = w = u;
+			start_address = address;
+		}
+
+		/*
+		 * Fill in the machine address: PTE ptr is done later by
+		 * apply_to_page_range(). 
+		 */
+		v->val = pte_val_ma(mfn_pte(mfn, prot));
+
+		mfn++;
+		address += PAGE_SIZE; 
+		v++;
+	}
+
+	if (v != u) {
+		/* Final batch. */
+		rc = apply_to_page_range(mm, start_address,
+					 address - start_address,
+					 direct_remap_area_pte_fn, &w);
+		if (rc)
+			goto out;
+		rc = -EFAULT;
+		if (unlikely(HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0))
+			goto out;
+	}
+
+	rc = 0;
+
+ out:
+	flush_tlb_all();
+
+	free_page((unsigned long)u);
+
+	return rc;
+}
+
+/*
+ * Does @address reside within a non-highmem page that is local to this virtual
+ * machine (i.e., not an I/O page, nor a memory page belonging to another VM).
+ * See the comment that accompanies mfn_to_local_pfn() in page.h to understand
+ * why this works.
+ */
+static inline int is_local_lowmem(unsigned long address)
+{
+	extern unsigned long max_low_pfn;
+	return (mfn_to_local_pfn(address >> PAGE_SHIFT) < max_low_pfn);
+}
+
+/*
+ * Remap an arbitrary physical address space into the kernel virtual
+ * address space. Needed when the kernel wants to access high addresses
+ * directly.
+ *
+ * NOTE! We need to allow non-page-aligned mappings too: we will obviously
+ * have to convert them into an offset in a page-aligned mapping, but the
+ * caller shouldn't need to know that small detail.
+ */
+int xen_ioremap_page_range(unsigned long addr, unsigned long end,
+			   unsigned long phys_addr, pgprot_t prot)
+{
+	domid_t domid = DOMID_IO;
+	int rc;
+
+	if (is_local_lowmem(phys_addr))
+		domid = DOMID_SELF;
+
+	rc = __direct_remap_pfn_range(&init_mm, (unsigned long)addr,
+				      phys_addr>>PAGE_SHIFT,
+				      end-addr, prot, domid);
+	
+	if (rc)
+		vunmap((void __force *) addr);
+	return rc;
+}
+
diff --git a/arch/x86/xen/mmu.h b/arch/x86/xen/mmu.h
index c9ff27f..8594c92 100644
--- a/arch/x86/xen/mmu.h
+++ b/arch/x86/xen/mmu.h
@@ -57,4 +57,7 @@ pmd_t xen_make_pmd(unsigned long);
 pgd_t xen_make_pgd(unsigned long);
 #endif
 
+extern int xen_ioremap_page_range(unsigned long addr, unsigned long end,
+				  unsigned long phys_addr, pgprot_t prot);
+
 #endif	/* _XEN_MMU_H */
diff --git a/include/asm-x86/fixmap_32.h b/include/asm-x86/fixmap_32.h
index 9ed0e25..4517c72 100644
--- a/include/asm-x86/fixmap_32.h
+++ b/include/asm-x86/fixmap_32.h
@@ -101,6 +101,8 @@ enum fixed_addresses {
 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);
+int native_ioremap_page_range(unsigned long addr, unsigned long end,
+			      unsigned long phys_addr, pgprot_t prot);
 
 #ifndef CONFIG_PARAVIRT
 static inline void __set_fixmap(enum fixed_addresses idx,
diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
index 3b9d5b7..fd17cf4 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -247,6 +247,9 @@ struct pv_mmu_ops {
 	   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);
+	int (*ioremap_page_range)(unsigned long addr, unsigned long end, 
+				  unsigned long phys_addr, pgprot_t prot);
+	
 };
 
 /* This contains all the paravirt structures: we get a convenient
@@ -1013,6 +1016,13 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
 	pv_mmu_ops.set_fixmap(idx, phys, flags);
 }
 
+#define  __HAVE_ARCH_IOREMAP_PAGE_RANGE
+static inline int ioremap_page_range(unsigned long addr, unsigned long end, 
+				     unsigned long phys_addr, pgprot_t prot)
+{
+	return pv_mmu_ops.ioremap_page_range(addr, end, phys_addr, prot);
+}
+
 void _paravirt_nop(void);
 #define paravirt_nop	((void *)_paravirt_nop)
 
diff --git a/include/linux/io.h b/include/linux/io.h
index e3b2dda..b8abe3d 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -28,16 +28,20 @@ void __iowrite32_copy(void __iomem *to, const void *from, size_t count);
 void __iowrite64_copy(void __iomem *to, const void *from, size_t count);
 
 #ifdef CONFIG_MMU
-int ioremap_page_range(unsigned long addr, unsigned long end,
-		       unsigned long phys_addr, pgprot_t prot);
+int __ioremap_page_range(unsigned long addr, unsigned long end,
+			 unsigned long phys_addr, pgprot_t prot);
 #else
-static inline int ioremap_page_range(unsigned long addr, unsigned long end,
-				     unsigned long phys_addr, pgprot_t prot)
+static inline int __ioremap_page_range(unsigned long addr, unsigned long end,
+				       unsigned long phys_addr, pgprot_t prot)
 {
 	return 0;
 }
 #endif
 
+#ifndef __HAVE_ARCH_IOREMAP_PAGE_RANGE
+#define ioremap_page_range __ioremap_page_range
+#endif
+
 /*
  * Managed iomap interface
  */
diff --git a/lib/ioremap.c b/lib/ioremap.c
index 14c6078..4106cb0 100644
--- a/lib/ioremap.c
+++ b/lib/ioremap.c
@@ -66,8 +66,8 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
 	return 0;
 }
 
-int ioremap_page_range(unsigned long addr,
-		       unsigned long end, unsigned long phys_addr, pgprot_t prot)
+int __ioremap_page_range(unsigned long addr, unsigned long end, 
+			 unsigned long phys_addr, pgprot_t prot)
 {
 	pgd_t *pgd;
 	unsigned long start;
-- 
1.5.4.2


linux-2.6-xen-0014-MTRR-use-cpu_callout_map-instead-of-cpu_online_map.patch:

--- NEW FILE linux-2.6-xen-0014-MTRR-use-cpu_callout_map-instead-of-cpu_online_map.patch ---
>From 1862be1d5fa1aab96e50d13cb19faa258b7caf4d Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Wed, 30 Jan 2008 13:25:36 +0000
Subject: [PATCH] MTRR: use cpu_callout_map instead of cpu_online_map

During mtrr_restore() only the BP is set in cpu_online_map,
so we need to use cpu_callout_map as a map of CPUs on which
to restore the MTRRs.

The code already uses num_booting_cpus() for this reason, but
it then sends IPIs to the CPUs in cpu_online_map rather than
cpu_callout_map.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/kernel/cpu/mtrr/main.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index 3b20613..4662ba3 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -232,7 +232,7 @@ static void set_mtrr(unsigned int reg, unsigned long base,
 	atomic_set(&data.gate,0);
 
 	/*  Start the ball rolling on other CPUs  */
-	if (smp_call_function(ipi_handler, &data, 1, 0) != 0)
+	if (smp_call_function_mask(cpu_callout_map, ipi_handler, &data, 0) != 0)
 		panic("mtrr: timed out waiting for other CPUs\n");
 
 	local_irq_save(flags);
-- 
1.5.4.2


linux-2.6-xen-0015-xen-mtrr-Add-mtrr_ops-support-for-Xen-mtrr.patch:

--- NEW FILE linux-2.6-xen-0015-xen-mtrr-Add-mtrr_ops-support-for-Xen-mtrr.patch ---
>From 66f3430a28d0ebc543bf9b0c97319e9461e3a8bf Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Mon, 10 Dec 2007 11:32:15 +0000
Subject: [PATCH] xen mtrr: Add mtrr_ops support for Xen mtrr

Add a Xen mtrr type, and reorganise mtrr initialisation slightly to allow the
mtrr driver to set up num_var_ranges (Xen needs to do this by querying the
hypervisor itself.)

Only the boot path is handled for now: we set up a xen-specific mtrr_if
and set up the mtrr tables based on hypervisor information, but we don't
yet handle mtrr entry add/delete.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/kernel/cpu/mtrr/Makefile |    1 +
 arch/x86/kernel/cpu/mtrr/main.c   |   30 ++++++++++++++++---
 arch/x86/kernel/cpu/mtrr/xen.c    |   57 +++++++++++++++++++++++++++++++++++++
 3 files changed, 83 insertions(+), 5 deletions(-)
 create mode 100644 arch/x86/kernel/cpu/mtrr/xen.c

diff --git a/arch/x86/kernel/cpu/mtrr/Makefile b/arch/x86/kernel/cpu/mtrr/Makefile
index 191fc05..81db513 100644
--- a/arch/x86/kernel/cpu/mtrr/Makefile
+++ b/arch/x86/kernel/cpu/mtrr/Makefile
@@ -1,3 +1,4 @@
 obj-y		:= main.o if.o generic.o state.o
 obj-$(CONFIG_X86_32) += amd.o cyrix.o centaur.o
+obj-$(CONFIG_XEN) += xen.o
 
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index 4662ba3..c5e0578 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -572,6 +572,7 @@ EXPORT_SYMBOL(mtrr_del);
 extern void amd_init_mtrr(void);
 extern void cyrix_init_mtrr(void);
 extern void centaur_init_mtrr(void);
+extern void xen_init_mtrr(void);
 
 static void __init init_ifs(void)
 {
@@ -580,6 +581,9 @@ static void __init init_ifs(void)
 	cyrix_init_mtrr();
 	centaur_init_mtrr();
 #endif
+#ifdef CONFIG_XEN
+	xen_init_mtrr();
+#endif
 }
 
 /* The suspend/resume methods are only for CPU without MTRR. CPU using generic
@@ -635,16 +639,14 @@ static struct sysdev_driver mtrr_sysdev_driver = {
 
 
 /**
- * mtrr_bp_init - initialize mtrrs on the boot CPU
+ * mtrr_bp_detect - detect mtrr hardware on the boot CPU
  *
  * This needs to be called early; before any of the other CPUs are 
  * initialized (i.e. before smp_init()).
  * 
  */
-void __init mtrr_bp_init(void)
+static void __init mtrr_bp_detect(void)
 {
-	init_ifs();
-
 	if (cpu_has_mtrr) {
 		mtrr_if = &generic_mtrr_ops;
 		size_or_mask = 0xff000000;	/* 36 bits */
@@ -701,9 +703,27 @@ void __init mtrr_bp_init(void)
 			break;
 		}
 	}
+}
+
+/**
+ * mtrr_bp_init - initialize mtrrs on the boot CPU
+ *
+ * This needs to be called early; before any of the other CPUs are 
+ * initialized (i.e. before smp_init()).
+ * 
+ */
+void __init mtrr_bp_init(void)
+{
+	init_ifs();
+
+	if (!mtrr_if)
+		mtrr_bp_detect();
 
 	if (mtrr_if) {
-		set_num_var_ranges();
+		/* Xen pv_ops will set the mtrr CPU to unknown, but will
+		 * also initialise the num_var_ranges for us */
+		if (!is_cpu(UNKNOWN))
+			set_num_var_ranges();
 		init_table();
 		if (use_intel())
 			get_mtrr_state();
diff --git a/arch/x86/kernel/cpu/mtrr/xen.c b/arch/x86/kernel/cpu/mtrr/xen.c
new file mode 100644
index 0000000..7011195
--- /dev/null
+++ b/arch/x86/kernel/cpu/mtrr/xen.c
@@ -0,0 +1,57 @@
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/ctype.h>
+#include <linux/module.h>
+#include <linux/seq_file.h>
+#include <asm/uaccess.h>
+#include <linux/mutex.h>
+
+#include <asm/mtrr.h>
+#include "mtrr.h"
+
+#include <xen/interface/platform.h>
+#include <asm/xen/hypervisor.h>
+#include <asm/xen/hypercall.h>
+
+/* DOM0 TODO: Need to fill in the remaining mtrr methods to have full
+ * working userland mtrr support. */
+static struct mtrr_ops xen_mtrr_ops = {
+	.vendor            = X86_VENDOR_UNKNOWN,
+//	.set               = xen_set_mtrr,
+//	.get               = xen_get_mtrr,
+	.get_free_region   = generic_get_free_region,
+//	.validate_add_page = xen_validate_add_page,
+	.have_wrcomb       = positive_have_wrcomb,
+	.use_intel_if	   = 0
+};
+
+static int __init xen_num_var_ranges(void)
+{
+	int ranges;
+	struct xen_platform_op op;
+
+	for (ranges = 0; ; ranges++) {
+		op.cmd = XENPF_read_memtype;
+		op.u.read_memtype.reg = ranges;
+		if (HYPERVISOR_dom0_op(&op) != 0)
+			break;
+	}
+	return ranges;
+}
+
+void __init xen_init_mtrr(void)
+{
+	struct cpuinfo_x86 *c = &boot_cpu_data;
+
+	if (!is_initial_xendomain())
+		return;
+
+	if ((!cpu_has(c, X86_FEATURE_MTRR)) &&
+	    (!cpu_has(c, X86_FEATURE_K6_MTRR)) &&
+	    (!cpu_has(c, X86_FEATURE_CYRIX_ARR)) &&
+	    (!cpu_has(c, X86_FEATURE_CENTAUR_MCR)))
+		return;
+
+	mtrr_if = &xen_mtrr_ops;
+	num_var_ranges = xen_num_var_ranges();
+}
-- 
1.5.4.2


linux-2.6-xen-0016-xen-mtrr-Don-t-enable-xen-mtrr-on-bare-metal.patch:

--- NEW FILE linux-2.6-xen-0016-xen-mtrr-Don-t-enable-xen-mtrr-on-bare-metal.patch ---
>From c112a887edda8e8190302d05050443cfb46b15cc Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Wed, 12 Dec 2007 14:31:16 +0000
Subject: [PATCH] xen mtrr: Don't enable xen mtrr on bare metal

is_initial_xendomain() doesn't return valid results unless we're running
on Xen, so it's not a sufficient test for a Xen dom0 on its own: we need
to test separately for is_running_on_xen() first.  Without that, we end
up setting xen mtrr behaviour on baremetal systems.

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

diff --git a/arch/x86/kernel/cpu/mtrr/xen.c b/arch/x86/kernel/cpu/mtrr/xen.c
index 7011195..4ee9a0f 100644
--- a/arch/x86/kernel/cpu/mtrr/xen.c
+++ b/arch/x86/kernel/cpu/mtrr/xen.c
@@ -43,7 +43,7 @@ void __init xen_init_mtrr(void)
 {
 	struct cpuinfo_x86 *c = &boot_cpu_data;
 
-	if (!is_initial_xendomain())
+	if (!is_running_on_xen() || !is_initial_xendomain())
 		return;
 
 	if ((!cpu_has(c, X86_FEATURE_MTRR)) &&
-- 
1.5.4.2


linux-2.6-xen-0017-xen-mtrr-set-cpu-in-cpu_callout_map.patch:

--- NEW FILE linux-2.6-xen-0017-xen-mtrr-set-cpu-in-cpu_callout_map.patch ---
>From 01fa979ab63094f04b82d333bc977cc7a2ab7022 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Wed, 30 Jan 2008 13:18:23 +0000
Subject: [PATCH] xen mtrr: set cpu in cpu_callout_map

The MTRR code uses num_booting_cpus() so make Xen
update cpu_callout_map as it brings cpus up.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/xen/smp.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index c1b131b..e731309 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -198,6 +198,7 @@ void __init xen_smp_prepare_cpus(unsigned int max_cpus)
 		if (IS_ERR(idle))
 			panic("failed fork for CPU %d", cpu);
 
+		cpu_set(cpu, cpu_callout_map);
 		cpu_set(cpu, cpu_present_map);
 	}
 
-- 
1.5.4.2


linux-2.6-xen-0018-xen-mtrr-Clean-up-the-num_var_ranges-CPU_UNKOWN-hac.patch:

--- NEW FILE linux-2.6-xen-0018-xen-mtrr-Clean-up-the-num_var_ranges-CPU_UNKOWN-hac.patch ---
>From 2250cf3b5f805a44e95469dd8802b16a583208ee Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Mon, 28 Jan 2008 18:55:06 +0000
Subject: [PATCH] xen mtrr: Clean up the num_var_ranges/CPU_UNKOWN hack

Move the CPU_UNKNOWN hack into set_var_num_ranges()
and only enable it with CONFIG_XEN

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/kernel/cpu/mtrr/main.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index c5e0578..3ac6ed8 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -107,6 +107,14 @@ static void __init set_num_var_ranges(void)
 {
 	unsigned long config = 0, dummy;
 
+#ifdef CONFIG_XEN
+	/* Xen pv_ops will set the mtrr CPU to unknown, but will
+	 * also initialise the num_var_ranges for us
+	 */
+	if (is_cpu(UNKNOWN))
+		return;
+#endif
+
 	if (use_intel()) {
 		rdmsr(MTRRcap_MSR, config, dummy);
 	} else if (is_cpu(AMD))
@@ -720,10 +728,7 @@ void __init mtrr_bp_init(void)
 		mtrr_bp_detect();
 
 	if (mtrr_if) {
-		/* Xen pv_ops will set the mtrr CPU to unknown, but will
-		 * also initialise the num_var_ranges for us */
-		if (!is_cpu(UNKNOWN))
-			set_num_var_ranges();
+		set_num_var_ranges();
 		init_table();
 		if (use_intel())
 			get_mtrr_state();
-- 
1.5.4.2


linux-2.6-xen-0019-xen-mtrr-Use-specific-cpu_has_foo-macros-instead-of.patch:

--- NEW FILE linux-2.6-xen-0019-xen-mtrr-Use-specific-cpu_has_foo-macros-instead-of.patch ---
>From 62a87502a6784dd68425f5e3a0873b37f7ac0cb0 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Mon, 28 Jan 2008 18:40:06 +0000
Subject: [PATCH] xen mtrr: Use specific cpu_has_foo macros instead of generic cpu_has()

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/kernel/cpu/mtrr/xen.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/xen.c b/arch/x86/kernel/cpu/mtrr/xen.c
index 4ee9a0f..a693a63 100644
--- a/arch/x86/kernel/cpu/mtrr/xen.c
+++ b/arch/x86/kernel/cpu/mtrr/xen.c
@@ -41,15 +41,13 @@ static int __init xen_num_var_ranges(void)
 
 void __init xen_init_mtrr(void)
 {
-	struct cpuinfo_x86 *c = &boot_cpu_data;
-
 	if (!is_running_on_xen() || !is_initial_xendomain())
 		return;
 
-	if ((!cpu_has(c, X86_FEATURE_MTRR)) &&
-	    (!cpu_has(c, X86_FEATURE_K6_MTRR)) &&
-	    (!cpu_has(c, X86_FEATURE_CYRIX_ARR)) &&
-	    (!cpu_has(c, X86_FEATURE_CENTAUR_MCR)))
+	if (!cpu_has_mtrr &&
+	    !cpu_has_k6_mtrr &&
+	    !cpu_has_cyrix_arr &&
+	    !cpu_has_centaur_mcr)
 		return;
 
 	mtrr_if = &xen_mtrr_ops;
-- 
1.5.4.2


linux-2.6-xen-0020-xen-mtrr-Kill-some-unneccessary-includes.patch:

--- NEW FILE linux-2.6-xen-0020-xen-mtrr-Kill-some-unneccessary-includes.patch ---
>From e530c1ce0084725fda50252edcb2358f95768403 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Mon, 28 Jan 2008 19:05:11 +0000
Subject: [PATCH] xen mtrr: Kill some unneccessary includes

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/kernel/cpu/mtrr/xen.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/xen.c b/arch/x86/kernel/cpu/mtrr/xen.c
index a693a63..d1197ff 100644
--- a/arch/x86/kernel/cpu/mtrr/xen.c
+++ b/arch/x86/kernel/cpu/mtrr/xen.c
@@ -1,12 +1,6 @@
 #include <linux/init.h>
-#include <linux/proc_fs.h>
-#include <linux/ctype.h>
-#include <linux/module.h>
-#include <linux/seq_file.h>
-#include <asm/uaccess.h>
-#include <linux/mutex.h>
-
-#include <asm/mtrr.h>
+#include <linux/mm.h>
+
 #include "mtrr.h"
 
 #include <xen/interface/platform.h>
-- 
1.5.4.2


linux-2.6-xen-0021-xen-mtrr-No-need-to-explicitly-set-use_intel_if-0.patch:

--- NEW FILE linux-2.6-xen-0021-xen-mtrr-No-need-to-explicitly-set-use_intel_if-0.patch ---
>From 45ade8f3ee1cdf58b45335be7c168ee810b441b8 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Mon, 28 Jan 2008 18:39:29 +0000
Subject: [PATCH] xen mtrr: No need to explicitly set use_intel_if = 0

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/kernel/cpu/mtrr/xen.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/xen.c b/arch/x86/kernel/cpu/mtrr/xen.c
index d1197ff..726d6ac 100644
--- a/arch/x86/kernel/cpu/mtrr/xen.c
+++ b/arch/x86/kernel/cpu/mtrr/xen.c
@@ -16,7 +16,6 @@ static struct mtrr_ops xen_mtrr_ops = {
 	.get_free_region   = generic_get_free_region,
 //	.validate_add_page = xen_validate_add_page,
 	.have_wrcomb       = positive_have_wrcomb,
-	.use_intel_if	   = 0
 };
 
 static int __init xen_num_var_ranges(void)
-- 
1.5.4.2


linux-2.6-xen-0022-xen-mtrr-Use-generic_validate_add_page.patch:

--- NEW FILE linux-2.6-xen-0022-xen-mtrr-Use-generic_validate_add_page.patch ---
>From a8ebf296d79664c934a16c2e6b8eadcd3899f74c Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Tue, 29 Jan 2008 17:43:25 +0000
Subject: [PATCH] xen mtrr: Use generic_validate_add_page()

The hypervisor already performs the same validation, but
better to do it early before getting to the range combining
code.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/kernel/cpu/mtrr/xen.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/xen.c b/arch/x86/kernel/cpu/mtrr/xen.c
index 726d6ac..eff6fd7 100644
--- a/arch/x86/kernel/cpu/mtrr/xen.c
+++ b/arch/x86/kernel/cpu/mtrr/xen.c
@@ -14,7 +14,7 @@ static struct mtrr_ops xen_mtrr_ops = {
 //	.set               = xen_set_mtrr,
 //	.get               = xen_get_mtrr,
 	.get_free_region   = generic_get_free_region,
-//	.validate_add_page = xen_validate_add_page,
+	.validate_add_page = generic_validate_add_page,
 	.have_wrcomb       = positive_have_wrcomb,
 };
 
-- 
1.5.4.2


linux-2.6-xen-0023-xen-mtrr-Implement-xen_get_free_region.patch:

--- NEW FILE linux-2.6-xen-0023-xen-mtrr-Implement-xen_get_free_region.patch ---
>From 9b830c53d79480544cd83cff3120cac8370e7d9f Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Wed, 30 Jan 2008 09:40:33 +0000
Subject: [PATCH] xen mtrr: Implement xen_get_free_region()

When an already set MTRR is being changed, we need to
first unset, since Xen also maintains a usage count.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/kernel/cpu/mtrr/xen.c |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/xen.c b/arch/x86/kernel/cpu/mtrr/xen.c
index eff6fd7..6998e00 100644
--- a/arch/x86/kernel/cpu/mtrr/xen.c
+++ b/arch/x86/kernel/cpu/mtrr/xen.c
@@ -7,13 +7,38 @@
 #include <asm/xen/hypervisor.h>
 #include <asm/xen/hypercall.h>
 
+static int xen_get_free_region(unsigned long base, unsigned long size, int replace_reg)
+{
+	struct xen_platform_op op;
+	int error;
+
+	if (replace_reg < 0)
+		return generic_get_free_region(base, size, -1);
+
+	/* If we're replacing the contents of a register,
+	 * we need to first unset it since Xen also keeps
+	 * a usage count.
+	 */
+	op.cmd = XENPF_del_memtype;
+	op.u.del_memtype.handle = 0;
+	op.u.del_memtype.reg    = replace_reg;
+
+	error = HYPERVISOR_dom0_op(&op);
+	if (error) {
+		BUG_ON(error > 0);
+		return error;
+	}
+
+	return replace_reg;
+}
+
 /* DOM0 TODO: Need to fill in the remaining mtrr methods to have full
  * working userland mtrr support. */
 static struct mtrr_ops xen_mtrr_ops = {
 	.vendor            = X86_VENDOR_UNKNOWN,
 //	.set               = xen_set_mtrr,
 //	.get               = xen_get_mtrr,
-	.get_free_region   = generic_get_free_region,
+	.get_free_region   = xen_get_free_region,
 	.validate_add_page = generic_validate_add_page,
 	.have_wrcomb       = positive_have_wrcomb,
 };
-- 
1.5.4.2


linux-2.6-xen-0024-xen-mtrr-Add-xen_-get-set-_mtrr-implementations.patch:

--- NEW FILE linux-2.6-xen-0024-xen-mtrr-Add-xen_-get-set-_mtrr-implementations.patch ---
>From f1365546a79b0225b4dc855bb767281fff4e891e Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Tue, 29 Jan 2008 18:29:46 +0000
Subject: [PATCH] xen mtrr: Add xen_{get,set}_mtrr() implementations

Straightforward apart from the hack to turn mtrr_ops->set()
into a no-op on all but one CPU.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/kernel/cpu/mtrr/xen.c |   52 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/xen.c b/arch/x86/kernel/cpu/mtrr/xen.c
index 6998e00..35b1246 100644
--- a/arch/x86/kernel/cpu/mtrr/xen.c
+++ b/arch/x86/kernel/cpu/mtrr/xen.c
@@ -7,6 +7,52 @@
 #include <asm/xen/hypervisor.h>
 #include <asm/xen/hypercall.h>
 
+static void xen_set_mtrr(unsigned int reg, unsigned long base,
+			 unsigned long size, mtrr_type type)
+{
+	struct xen_platform_op op;
+	int error;
+
+	/* mtrr_ops->set() is called once per CPU,
+	 * but Xen's ops apply to all CPUs.
+	 */
+	if (smp_processor_id())
+		return;
+
+	if (size == 0) {
+		op.cmd = XENPF_del_memtype;
+		op.u.del_memtype.handle = 0;
+		op.u.del_memtype.reg    = reg;
+	} else {
+		op.cmd = XENPF_add_memtype;
+		op.u.add_memtype.mfn     = base;
+		op.u.add_memtype.nr_mfns = size;
+		op.u.add_memtype.type    = type;
+	}
+
+	error = HYPERVISOR_dom0_op(&op);
+	BUG_ON(error != 0);
+}
+
+static void xen_get_mtrr(unsigned int reg, unsigned long *base,
+			 unsigned long *size, mtrr_type *type)
+{
+	struct xen_platform_op op;
+
+	op.cmd = XENPF_read_memtype;
+	op.u.read_memtype.reg = reg;
+	if (HYPERVISOR_dom0_op(&op) != 0) {
+		*base = 0;
+		*size = 0;
+		*type = 0;
+		return;
+	}
+
+	*size = op.u.read_memtype.nr_mfns;
+	*base = op.u.read_memtype.mfn;
+	*type = op.u.read_memtype.type;
+}
+
 static int xen_get_free_region(unsigned long base, unsigned long size, int replace_reg)
 {
 	struct xen_platform_op op;
@@ -32,12 +78,10 @@ static int xen_get_free_region(unsigned long base, unsigned long size, int repla
 	return replace_reg;
 }
 
-/* DOM0 TODO: Need to fill in the remaining mtrr methods to have full
- * working userland mtrr support. */
 static struct mtrr_ops xen_mtrr_ops = {
 	.vendor            = X86_VENDOR_UNKNOWN,
-//	.set               = xen_set_mtrr,
-//	.get               = xen_get_mtrr,
+	.set               = xen_set_mtrr,
+	.get               = xen_get_mtrr,
 	.get_free_region   = xen_get_free_region,
 	.validate_add_page = generic_validate_add_page,
 	.have_wrcomb       = positive_have_wrcomb,
-- 
1.5.4.2


linux-2.6-xen-0025-irq2.diff-from-Juan-Quintela.patch:

--- NEW FILE linux-2.6-xen-0025-irq2.diff-from-Juan-Quintela.patch ---
>From 145c492db1ce3ac680efffd8ae8c2071f03a809c Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Thu, 13 Dec 2007 17:55:34 +0000
Subject: [PATCH] irq2.diff from Juan Quintela.

Some verbose tracing removed.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/kernel/acpi/boot.c                       |   77 ++++++++---
 arch/x86/kernel/apic_32.c                         |   11 ++
 arch/x86/kernel/io_apic_32.c                      |  100 +++++++++++---
 arch/x86/kernel/mpparse_32.c                      |   15 ++-
 arch/x86/kernel/setup_32.c                        |   17 ++-
 arch/x86/kernel/traps_32.c                        |   41 +++++-
 arch/x86/xen/enlighten.c                          |    2 +-
 arch/x86/xen/events.c                             |  157 ++++++++++++++++++++-
 drivers/acpi/tables.c                             |   14 ++-
 include/asm-x86/mach-default/irq_vectors_limits.h |   13 ++
 init/main.c                                       |   30 ++++-
 11 files changed, 426 insertions(+), 51 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index e59bda5..6fdda10 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -41,6 +41,7 @@
 #include <asm/mpspec.h>
 
 #include <asm/xen/hypervisor.h>
+#include <xen/hvc-console.h>
 
 static int __initdata acpi_force = 0;
 
@@ -301,16 +302,17 @@ acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
 {
 	struct acpi_madt_io_apic *ioapic = NULL;
 
+	xprintk("ap_ioapic 1\n");
 	ioapic = (struct acpi_madt_io_apic *)header;
-
+	xprintk("ap_ioapic 2\n");
 	if (BAD_MADT_ENTRY(ioapic, end))
 		return -EINVAL;
-
+	xprintk("ap_ioapic 3\n");
 	acpi_table_print_madt_entry(header);
-
+	xprintk("ap_ioapic 4\n");
 	mp_register_ioapic(ioapic->id,
 			   ioapic->address, ioapic->global_irq_base);
-
+	xprintk("ap_ioapic 5\n");
 	return 0;
 }
 
@@ -588,7 +590,13 @@ acpi_scan_rsdp(unsigned long start, unsigned long length)
 	 * RSDP signature.
 	 */
 	for (offset = 0; offset < length; offset += 16) {
+#ifdef CONFIG_XEN
+		unsigned long vstart = (unsigned long)isa_bus_to_virt(start);
+
+		if (strncmp((char *)(vstart + offset), "RSD PTR ", sig_len))
+#else
 		if (strncmp((char *)(phys_to_virt(start) + offset), "RSD PTR ", sig_len))
+#endif
 			continue;
 		return (start + offset);
 	}
@@ -711,7 +719,7 @@ late_initcall(hpet_insert_resource);
 static int __init acpi_parse_fadt(struct acpi_table_header *table)
 {
 
-#ifdef CONFIG_X86_PM_TIMER
+#if 0
 	/* detect the location of the ACPI PM Timer */
 	if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
 		/* FADT rev. 2 */
@@ -819,6 +827,7 @@ static int __init acpi_parse_madt_ioapic_entries(void)
 {
 	int count;
 
+	xprintk("apm_ioapic_entries 1\n");
 	/*
 	 * ACPI interpreter is required to complete interrupt setup,
 	 * so if it is off, don't enumerate the io-apics with ACPI.
@@ -828,59 +837,67 @@ static int __init acpi_parse_madt_ioapic_entries(void)
 	if (acpi_disabled || acpi_noirq) {
 		return -ENODEV;
 	}
-
+	xprintk("apm_ioapic_entries 2\n");
 	if (!cpu_has_apic)
 		return -ENODEV;
-
+	xprintk("apm_ioapic_entries 3\n");
 	/*
 	 * if "noapic" boot option, don't look for IO-APICs
 	 */
 	if (skip_ioapic_setup) {
+		xprintk("apm_ioapic_entries 4\n");
 		printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
 		       "due to 'noapic' option.\n");
 		return -ENODEV;
 	}
-
+	xprintk("apm_ioapic_entries 5\n");
 	count =
 	    acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
 				  MAX_IO_APICS);
+	xprintk("apm_ioapic_entries 6\n");
 	if (!count) {
+		xprintk("apm_ioapic_entries 7\n");
 		printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
 		return -ENODEV;
 	} else if (count < 0) {
+		xprintk("apm_ioapic_entries 8\n");
 		printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
 		return count;
 	}
-
+	xprintk("apm_ioapic_entries 9\n");
 	count =
 	    acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
 				  NR_IRQ_VECTORS);
+	xprintk("apm_ioapic_entries 10\n");
 	if (count < 0) {
+		xprintk("apm_ioapic_entries 11\n");
 		printk(KERN_ERR PREFIX
 		       "Error parsing interrupt source overrides entry\n");
 		/* TBD: Cleanup to allow fallback to MPS */
 		return count;
 	}
-
+	xprintk("apm_ioapic_entries 12\n");
 	/*
 	 * If BIOS did not supply an INT_SRC_OVR for the SCI
 	 * pretend we got one so we can set the SCI flags.
 	 */
 	if (!acpi_sci_override_gsi)
 		acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0);
-
+	xprintk("apm_ioapic_entries 13\n");
 	/* Fill in identity legacy mapings where no override */
 	mp_config_acpi_legacy_irqs();
-
+	xprintk("apm_ioapic_entries 14\n");
 	count =
 	    acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
 				  NR_IRQ_VECTORS);
+	xprintk("apm_ioapic_entries 15\n");
 	if (count < 0) {
+		xprintk("apm_ioapic_entries 16\n");
 		printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
 		/* TBD: Cleanup to allow fallback to MPS */
 		return count;
 	}
-
+	xprintk("apm_ioapic_entries 17\n");
 	return 0;
 }
 #else
@@ -895,38 +912,50 @@ static void __init acpi_process_madt(void)
 #ifdef CONFIG_X86_LOCAL_APIC
 	int error;
 
+	xprintk("acpi_process_madt 1\n");
 	if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
-
+		xprintk("acpi_process_madt 2\n");
 		/*
 		 * Parse MADT LAPIC entries
 		 */
 		error = acpi_parse_madt_lapic_entries();
+		xprintk("acpi_process_madt 3\n");
 		if (!error) {
+			xprintk("acpi_process_madt 4\n");
 			acpi_lapic = 1;
 
 #ifdef CONFIG_X86_GENERICARCH
 			generic_bigsmp_probe();
+			xprintk("acpi_process_madt 5\n");
 #endif
 			/*
 			 * Parse MADT IO-APIC entries
 			 */
 			error = acpi_parse_madt_ioapic_entries();
+			xprintk("acpi_process_madt 6\n");
 			if (!error) {
+				xprintk("acpi_process_madt 7\n");
 				acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
 				acpi_irq_balance_set(NULL);
+				xprintk("acpi_process_madt 8\n");
 				acpi_ioapic = 1;
 
 				smp_found_config = 1;
 				setup_apic_routing();
+				xprintk("acpi_process_madt 9\n");
 			}
+			xprintk("acpi_process_madt 10\n");
 		}
+		xprintk("acpi_process_madt 11\n");
 		if (error == -EINVAL) {
+				xprintk("acpi_process_madt 12\n");
 			/*
 			 * Dell Precision Workstation 410, 610 come here.
 			 */
 			printk(KERN_ERR PREFIX
 			       "Invalid BIOS MADT, disabling ACPI\n");
 			disable_acpi();
+			xprintk("acpi_process_madt 13\n");
 		}
 	}
 #endif
@@ -1183,6 +1212,7 @@ int __init acpi_boot_table_init(void)
 {
 	int error;
 
+	xprintk("acpi_boot_table_init 1\n");
 #ifdef __i386__
 	dmi_check_system(acpi_dmi_table);
 #endif
@@ -1193,23 +1223,32 @@ int __init acpi_boot_table_init(void)
 	 */
 	if (acpi_disabled && !acpi_ht)
 		return 1;
+	xprintk("acpi_boot_table_init 2\n");
 
 	/*
 	 * Initialize the ACPI boot-time table parser.
 	 */
 	error = acpi_table_init();
+	xprintk("acpi_boot_table_init 3\n");
 	if (error) {
+	xprintk("acpi_boot_table_init 4\n");
 		disable_acpi();
 		return error;
 	}
 
 	acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
+	xprintk("acpi_boot_table_init 5\n");
 
 	/*
 	 * blacklist may disable ACPI entirely
 	 */
+	xprintk("acpi_boot_table_init 6\n");
 	error = acpi_blacklisted();
+	xprintk("acpi_boot_table_init 7\n");
+
 	if (error) {
+		xprintk("acpi_boot_table_init 8\n");
+
 		if (acpi_force) {
 			printk(KERN_WARNING PREFIX "acpi=force override\n");
 		} else {
@@ -1218,6 +1257,7 @@ int __init acpi_boot_table_init(void)
 			return error;
 		}
 	}
+	xprintk("acpi_boot_table_init 9\n");
 
 	return 0;
 }
@@ -1228,22 +1268,25 @@ int __init acpi_boot_init(void)
 	 * If acpi_disabled, bail out
 	 * One exception: acpi=ht continues far enough to enumerate LAPICs
 	 */
+	xprintk("acpi_boot_init 1\n");
 	if (acpi_disabled && !acpi_ht)
 		return 1;
-
+	xprintk("acpi_boot_init 2\n");
 	acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
 
 	/*
 	 * set sci_int and PM timer address
 	 */
+	xprintk("acpi_boot_init 3\n");
 	acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
-
 	/*
 	 * Process the Multiple APIC Description Table (MADT), if present
 	 */
+	xprintk("acpi_boot_init 4\n");
 	acpi_process_madt();
-
+	xprintk("acpi_boot_init 5\n");
 	acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
+	xprintk("acpi_boot_init 6\n");
 
 	return 0;
 }
diff --git a/arch/x86/kernel/apic_32.c b/arch/x86/kernel/apic_32.c
index edb5108..06b8860 100644
--- a/arch/x86/kernel/apic_32.c
+++ b/arch/x86/kernel/apic_32.c
@@ -45,6 +45,8 @@
 
 #include "io_ports.h"
 
+#include <asm/xen/hypervisor.h>
+
 /*
  * Sanity check
  */
@@ -122,11 +124,15 @@ static inline int lapic_is_integrated(void)
  */
 static int modern_apic(void)
 {
+#ifndef CONFIG_XEN
 	/* AMD systems use old APIC versions, so check the CPU */
 	if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
 	    boot_cpu_data.x86 >= 0xf)
 		return 1;
 	return lapic_get_version() >= 0x14;
+#else
+	return 1;
+#endif
 }
 
 void apic_wait_icr_idle(void)
@@ -1166,6 +1172,7 @@ fake_ioapic_page:
  */
 int __init APIC_init_uniprocessor (void)
 {
+#ifndef CONFIG_XEN
 	if (enable_local_apic < 0)
 		clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
 
@@ -1198,13 +1205,16 @@ int __init APIC_init_uniprocessor (void)
 	phys_cpu_present_map = physid_mask_of_physid(boot_cpu_physical_apicid);
 
 	setup_local_APIC();
+#endif
 
 #ifdef CONFIG_X86_IO_APIC
 	if (smp_found_config)
 		if (!skip_ioapic_setup && nr_ioapics)
 			setup_IO_APIC();
 #endif
+#ifndef CONFIG_XEN
 	setup_boot_clock();
+#endif
 
 	return 0;
 }
@@ -1565,3 +1575,4 @@ device_initcall(init_lapic_sysfs);
 static void apic_pm_activate(void) { }
 
 #endif	/* CONFIG_PM */
+
diff --git a/arch/x86/kernel/io_apic_32.c b/arch/x86/kernel/io_apic_32.c
index a6b1490..fc24cdf 100644
--- a/arch/x86/kernel/io_apic_32.c
+++ b/arch/x86/kernel/io_apic_32.c
@@ -50,6 +50,43 @@
 
 #include "io_ports.h"
 
+#include <xen/interface/xen.h>
+#include <xen/interface/physdev.h>
+#include <asm/xen/hypercall.h>
+#include <asm/xen/hypervisor.h>
+
+/* Fake i8259 */
+#define make_8259A_irq(_irq)     (io_apic_irqs &= ~(1UL<<(_irq)))
+#define disable_8259A_irq(_irq)  ((void)0)
+#define i8259A_irq_pending(_irq) (0)
+
+static inline unsigned int xen_io_apic_read(unsigned int apic, unsigned int reg)
+{
+	struct physdev_apic apic_op;
+	int ret;
+
+	apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr;
+	apic_op.reg = reg;
+	ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op);
+	if (ret)
+		return ret;
+	return apic_op.value;
+}
+
+static inline void xen_io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
+{
+	struct physdev_apic apic_op;
+
+	apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr;
+	apic_op.reg = reg;
+	apic_op.value = value;
+	HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op);
+}
+
+#define io_apic_read(a,r)    xen_io_apic_read(a,r)
+#define io_apic_write(a,r,v) xen_io_apic_write(a,r,v)
+#define io_apic_modify(a,r,v) xen_io_apic_write(a,r,v)
+
 int (*ioapic_renumber_irq)(int ioapic, int irq);
 atomic_t irq_mis_count;
 
@@ -92,6 +129,7 @@ static struct irq_pin_list {
 	int apic, pin, next;
 } irq_2_pin[PIN_MAP_SIZE];
 
+#ifndef CONFIG_XEN 
 struct io_apic {
 	unsigned int index;
 	unsigned int unused[3];
@@ -131,6 +169,7 @@ static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned
 		writel(reg, &io_apic->index);
 	writel(value, &io_apic->data);
 }
+#endif /* CONFIG_XEN */
 
 union entry_union {
 	struct { u32 w1, w2; };
@@ -306,6 +345,9 @@ static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin)
 	ioapic_mask_entry(apic, pin);
 }
 
+#ifdef CONFIG_XEN
+#define clear_IO_APIC() ((void)0)
+#else
 static void clear_IO_APIC (void)
 {
 	int apic, pin;
@@ -314,6 +356,7 @@ static void clear_IO_APIC (void)
 		for (pin = 0; pin < nr_ioapic_registers[apic]; pin++)
 			clear_IO_APIC_pin(apic, pin);
 }
+#endif
 
 #ifdef CONFIG_SMP
 static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t cpumask)
@@ -729,6 +772,7 @@ late_initcall(balanced_irq_init);
 #ifndef CONFIG_SMP
 void fastcall send_IPI_self(int vector)
 {
+#ifndef CONFIG_XEN
 	unsigned int cfg;
 
 	/*
@@ -740,6 +784,7 @@ void fastcall send_IPI_self(int vector)
 	 * Send the IPI. The write to APIC_ICR fires this off.
 	 */
 	apic_write_around(APIC_ICR, cfg);
+#endif
 }
 #endif /* !CONFIG_SMP */
 
@@ -1197,29 +1242,19 @@ static u8 irq_vector[NR_IRQ_VECTORS] __read_mostly = { FIRST_DEVICE_VECTOR , 0 }
 
 static int __assign_irq_vector(int irq)
 {
-	static int current_vector = FIRST_DEVICE_VECTOR, current_offset = 0;
-	int vector, offset;
+	int vector;
+	struct physdev_irq irq_op;
 
 	BUG_ON((unsigned)irq >= NR_IRQ_VECTORS);
 
 	if (irq_vector[irq] > 0)
 		return irq_vector[irq];
 
-	vector = current_vector;
-	offset = current_offset;
-next:
-	vector += 8;
-	if (vector >= FIRST_SYSTEM_VECTOR) {
-		offset = (offset + 1) % 8;
-		vector = FIRST_DEVICE_VECTOR + offset;
-	}
-	if (vector == current_vector)
+	irq_op.irq = irq;
+	if (HYPERVISOR_physdev_op(PHYSDEVOP_alloc_irq_vector, &irq_op))
 		return -ENOSPC;
-	if (test_and_set_bit(vector, used_vectors))
-		goto next;
 
-	current_vector = vector;
-	current_offset = offset;
+	vector = irq_op.vector;
 	irq_vector[irq] = vector;
 
 	return vector;
@@ -1236,12 +1271,17 @@ static int assign_irq_vector(int irq)
 
 	return vector;
 }
+
+
 static struct irq_chip ioapic_chip;
 
 #define IOAPIC_AUTO	-1
 #define IOAPIC_EDGE	0
 #define IOAPIC_LEVEL	1
 
+#ifdef CONFIG_XEN
+#define ioapic_register_intr(_irq,_vector,_trigger) ((void)0)
+#else
 static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
 {
 	if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
@@ -1256,6 +1296,7 @@ static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
 	}
 	set_intr_gate(vector, interrupt[irq]);
 }
+#endif
 
 static void __init setup_IO_APIC_irqs(void)
 {
@@ -1316,7 +1357,7 @@ static void __init setup_IO_APIC_irqs(void)
 		else
 			add_pin_to_irq(irq, apic, pin);
 
-		if (!apic && !IO_APIC_IRQ(irq))
+		if (/* !apic &&*/ !IO_APIC_IRQ(irq))
 			continue;
 
 		if (IO_APIC_IRQ(irq)) {
@@ -1378,6 +1419,9 @@ static void __init setup_ExtINT_IRQ0_pin(unsigned int apic, unsigned int pin, in
 	enable_8259A_irq(0);
 }
 
+#ifdef CONFIG_XEN
+void __init print_IO_APIC(void) { }
+#else
 void __init print_IO_APIC(void)
 {
 	int apic, i;
@@ -1492,6 +1536,7 @@ void __init print_IO_APIC(void)
 
 	return;
 }
+#endif /* !CONFIG_XEN */
 
 #if 0
 
@@ -1717,6 +1762,7 @@ void disable_IO_APIC(void)
 	 */
 	clear_IO_APIC();
 
+#ifndef CONFIG_XEN
 	/*
 	 * If the i8259 is routed through an IOAPIC
 	 * Put that IOAPIC in virtual wire mode
@@ -1743,6 +1789,7 @@ void disable_IO_APIC(void)
 		ioapic_write_entry(ioapic_i8259.apic, ioapic_i8259.pin, entry);
 	}
 	disconnect_bsp_APIC(ioapic_i8259.pin != -1);
+#endif
 }
 
 /*
@@ -1752,7 +1799,7 @@ void disable_IO_APIC(void)
  * by Matt Domsch <Matt_Domsch at dell.com>  Tue Dec 21 12:25:05 CST 1999
  */
 
-#ifndef CONFIG_X86_NUMAQ
+#if !defined(CONFIG_XEN) && !defined(CONFIG_X86_NUMAQ)
 static void __init setup_ioapic_ids_from_mpc(void)
 {
 	union IO_APIC_reg_00 reg_00;
@@ -2015,7 +2062,6 @@ static struct irq_chip ioapic_chip __read_mostly = {
 	.retrigger	= ioapic_retrigger_irq,
 };
 
-
 static inline void init_IO_APIC_traps(void)
 {
 	int irq;
@@ -2041,9 +2087,11 @@ static inline void init_IO_APIC_traps(void)
 			 */
 			if (irq < 16)
 				make_8259A_irq(irq);
+#ifndef CONFIG_XEN
 			else
 				/* Strange. Oh, well.. */
 				irq_desc[irq].chip = &no_irq_chip;
+#endif
 		}
 	}
 }
@@ -2159,6 +2207,7 @@ static inline void unlock_ExtINT_logic(void)
 
 int timer_uses_ioapic_pin_0;
 
+#ifndef CONFIG_XEN
 /*
  * This code may look a bit paranoid, but it's supposed to cooperate with
  * a wide range of boards and BIOS bugs.  Fortunately only the timer IRQ
@@ -2288,6 +2337,9 @@ static inline void __init check_timer(void)
 out:
 	local_irq_restore(flags);
 }
+#else
+#define check_timer() ((void)0)
+#endif /* CONFIG_XEN */
 
 /*
  *
@@ -2320,7 +2372,9 @@ void __init setup_IO_APIC(void)
 	 */
 	if (!acpi_ioapic)
 		setup_ioapic_ids_from_mpc();
+#ifndef CONFIG_XEN
 	sync_Arb_IDs();
+#endif
 	setup_IO_APIC_irqs();
 	init_IO_APIC_traps();
 	check_timer();
@@ -2351,6 +2405,12 @@ static int __init io_apic_bug_finalize(void)
 {
 	if(sis_apic_bug == -1)
 		sis_apic_bug = 0;
+	if (is_initial_xendomain()) {
+		struct xen_platform_op op = { .cmd = XENPF_platform_quirk };
+		op.u.platform_quirk.quirk_id = sis_apic_bug ?
+			QUIRK_IOAPIC_BAD_REGSEL : QUIRK_IOAPIC_GOOD_REGSEL;
+		HYPERVISOR_dom0_op(&op);
+	}
 	return 0;
 }
 
@@ -2465,7 +2525,9 @@ int create_irq(void)
 	spin_unlock_irqrestore(&vector_lock, flags);
 
 	if (irq >= 0) {
+#ifndef CONFIG_XEN
 		set_intr_gate(vector, interrupt[irq]);
+#endif
 		dynamic_irq_init(irq);
 	}
 	return irq;
@@ -2688,6 +2750,7 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
 
 int __init io_apic_get_unique_id (int ioapic, int apic_id)
 {
+#ifndef CONFIG_XEN
 	union IO_APIC_reg_00 reg_00;
 	static physid_mask_t apic_id_map = PHYSID_MASK_NONE;
 	physid_mask_t tmp;
@@ -2756,6 +2819,7 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id)
 
 	apic_printk(APIC_VERBOSE, KERN_INFO
 			"IOAPIC[%d]: Assigned apic_id %d\n", ioapic, apic_id);
+#endif
 
 	return apic_id;
 }
diff --git a/arch/x86/kernel/mpparse_32.c b/arch/x86/kernel/mpparse_32.c
index 7a05a7f..289041d 100644
--- a/arch/x86/kernel/mpparse_32.c
+++ b/arch/x86/kernel/mpparse_32.c
@@ -105,6 +105,7 @@ static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __cpuinit
 
 static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
 {
+#ifndef CONFIG_XEN
  	int ver, apicid;
 	physid_mask_t phys_cpu;
  	
@@ -195,6 +196,7 @@ static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
 	}
 
 	cpu_set(num_processors, cpu_possible_map);
+#endif
 	num_processors++;
 
 	/*
@@ -204,6 +206,7 @@ static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
 	 * if (CPU_HOTPLUG_ENABLED || num_processors > 8)
 	 *       - Ashok Raj <ashok.raj at intel.com>
 	 */
+#ifndef CONFIG_XEN
 	if (num_processors > 8) {
 		switch (boot_cpu_data.x86_vendor) {
 		case X86_VENDOR_INTEL:
@@ -217,6 +220,7 @@ static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
 		}
 	}
 	bios_cpu_apicid[num_processors - 1] = m->mpc_apicid;
+#endif
 }
 
 static void __init MP_bus_info (struct mpc_config_bus *m)
@@ -683,7 +687,11 @@ void __init get_smp_config (void)
 		 * Read the physical hardware table.  Anything here will
 		 * override the defaults.
 		 */
+#ifdef CONFIG_XEN
+		if (!smp_read_mpc(isa_bus_to_virt(mpf->mpf_physptr))) {
+#else
 		if (!smp_read_mpc(phys_to_virt(mpf->mpf_physptr))) {
+#endif
 			smp_found_config = 0;
 			printk(KERN_ERR "BIOS bug, MP table errors detected!...\n");
 			printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n");
@@ -811,6 +819,7 @@ int es7000_plat;
 
 void __init mp_register_lapic_address(u64 address)
 {
+#ifndef CONFIG_XEN
 	mp_lapic_addr = (unsigned long) address;
 
 	set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
@@ -819,6 +828,7 @@ void __init mp_register_lapic_address(u64 address)
 		boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
 
 	Dprintk("Boot CPU = %d\n", boot_cpu_physical_apicid);
+#endif
 }
 
 void __cpuinit mp_register_lapic (u8 id, u8 enabled)
@@ -835,6 +845,7 @@ void __cpuinit mp_register_lapic (u8 id, u8 enabled)
 	if (id == boot_cpu_physical_apicid)
 		boot_cpu = 1;
 
+#ifndef CONFIG_XEN
 	processor.mpc_type = MP_PROCESSOR;
 	processor.mpc_apicid = id;
 	processor.mpc_apicver = GET_APIC_VERSION(apic_read(APIC_LVR));
@@ -845,7 +856,7 @@ void __cpuinit mp_register_lapic (u8 id, u8 enabled)
 	processor.mpc_featureflag = boot_cpu_data.x86_capability[0];
 	processor.mpc_reserved[0] = 0;
 	processor.mpc_reserved[1] = 0;
-
+#endif
 	MP_processor_info(&processor);
 }
 
@@ -899,7 +910,9 @@ void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
 	mp_ioapics[idx].mpc_flags = MPC_APIC_USABLE;
 	mp_ioapics[idx].mpc_apicaddr = address;
 
+#ifndef CONFIG_XEN
 	set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
+#endif
 	if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
 		&& !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
 		tmpid = io_apic_get_unique_id(idx, id);
diff --git a/arch/x86/kernel/setup_32.c b/arch/x86/kernel/setup_32.c
index a441deb..5d9edab 100644
--- a/arch/x86/kernel/setup_32.c
+++ b/arch/x86/kernel/setup_32.c
@@ -62,6 +62,8 @@
 #include <bios_ebda.h>
 #include <asm/cacheflush.h>
 
+#include <xen/hvc-console.h>
+
 /* This value is set up by the early boot code to point to the value
    immediately after the boot time page tables.  It contains a *physical*
    address, and must not be in the .bss segment! */
@@ -546,10 +548,13 @@ void __init setup_arch(char **cmdline_p)
 {
 	unsigned long max_low_pfn;
 
+	xprintk("setup_arch 1\n");
 	memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
+	xprintk("setup_arch 2\n");
 	pre_setup_arch_hook();
+	xprintk("setup_arch 3\n");
 	early_cpu_init();
-
+	xprintk("setup_arch 4\n");
 	/*
 	 * FIXME: This isn't an official loader_type right
 	 * now but does currently work with elilo.
@@ -564,6 +569,7 @@ void __init setup_arch(char **cmdline_p)
 #endif
 
 	ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
+	xprintk("setup_arch 5\n");
 	screen_info = boot_params.screen_info;
 	edid_info = boot_params.edid_info;
 	apm_info.bios = boot_params.apm_bios_info;
@@ -671,7 +677,7 @@ void __init setup_arch(char **cmdline_p)
 
 #ifdef CONFIG_ACPI
 	acpi_boot_init();
-
+	xprintk("setup_arch 10\n");
 #if defined(CONFIG_SMP) && defined(CONFIG_X86_PC)
 	if (def_to_bigsmp)
 		printk(KERN_WARNING "More than 8 CPUs detected and "
@@ -679,14 +685,16 @@ void __init setup_arch(char **cmdline_p)
 			"CONFIG_X86_GENERICARCH or CONFIG_X86_BIGSMP.\n");
 #endif
 #endif
+	xprintk("setup_arch 11\n");
 #ifdef CONFIG_X86_LOCAL_APIC
 	if (smp_found_config)
 		get_smp_config();
 #endif
-
+	xprintk("setup_arch 12\n");
 	e820_register_memory();
+	xprintk("setup_arch 13\n");
 	e820_mark_nosave_regions();
-
+	xprintk("setup_arch 14\n");
 #ifdef CONFIG_VT
 #if defined(CONFIG_VGA_CONSOLE)
 	if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
@@ -695,4 +703,5 @@ void __init setup_arch(char **cmdline_p)
 	conswitchp = &dummy_con;
 #endif
 #endif
+	xprintk("setup_arch 15\n");
 }
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 02d1e1e..912cbc8 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -59,6 +59,8 @@
 
 #include <linux/module.h>
 
+#include <asm/xen/hypercall.h>
+
 #include "mach_traps.h"
 
 int panic_on_unrecovered_nmi;
@@ -1130,10 +1132,42 @@ static void __init set_task_gate(unsigned int n, unsigned int gdt_entry)
 }
 
 
+/*
+ * NB. All these are "trap gates" (i.e. events_mask isn't set) except
+ * for those that specify <dpl>|4 in the second field.
+ */
+static struct trap_info trap_table[] = {
+	{  0, 0, __KERNEL_CS, (unsigned long)divide_error		},
+	{  1, 0|4, __KERNEL_CS, (unsigned long)debug			},
+	{  3, 3|4, __KERNEL_CS, (unsigned long)int3			},
+	{  4, 3, __KERNEL_CS, (unsigned long)overflow			},
+	{  5, 0, __KERNEL_CS, (unsigned long)bounds			},
+	{  6, 0, __KERNEL_CS, (unsigned long)invalid_op			},
+	{  7, 0|4, __KERNEL_CS, (unsigned long)device_not_available	},
+	{  9, 0, __KERNEL_CS, (unsigned long)coprocessor_segment_overrun },
+	{ 10, 0, __KERNEL_CS, (unsigned long)invalid_TSS		},
+	{ 11, 0, __KERNEL_CS, (unsigned long)segment_not_present	},
+	{ 12, 0, __KERNEL_CS, (unsigned long)stack_segment		},
+	{ 13, 0, __KERNEL_CS, (unsigned long)general_protection		},
+	{ 14, 0|4, __KERNEL_CS, (unsigned long)page_fault		},
+	{ 15, 0, __KERNEL_CS, (unsigned long)invalid_TSS		},
+	{ 16, 0, __KERNEL_CS, (unsigned long)coprocessor_error		},
+	{ 17, 0, __KERNEL_CS, (unsigned long)alignment_check		},
+#ifdef CONFIG_X86_MCE
+	{ 18, 0, __KERNEL_CS, (unsigned long)machine_check		},
+#endif
+	{ 19, 0, __KERNEL_CS, (unsigned long)simd_coprocessor_error	},
+	{ SYSCALL_VECTOR,  3, __KERNEL_CS, (unsigned long)system_call	},
+	{  0, 0,	   0, 0						}
+};
+
 void __init trap_init(void)
 {
 	int i;
 
+#ifdef CONFIG_XEN
+	HYPERVISOR_set_trap_table(trap_table);
+#else
 #ifdef CONFIG_EISA
 	void __iomem *p = ioremap(0x0FFFD9, 4);
 	if (readl(p) == 'E'+('I'<<8)+('S'<<16)+('A'<<24)) {
@@ -1168,6 +1202,7 @@ void __init trap_init(void)
 	set_trap_gate(18,&machine_check);
 #endif
 	set_trap_gate(19,&simd_coprocessor_error);
+#endif /* !CONFIG_XEN */
 
 	if (cpu_has_fxsr) {
 		/*
@@ -1191,8 +1226,9 @@ void __init trap_init(void)
 		printk("done.\n");
 	}
 
+#ifndef CONFIG_XEN
 	set_system_gate(SYSCALL_VECTOR,&system_call);
-
+#endif
 	/* Reserve all the builtin and the syscall vector. */
 	for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++)
 		set_bit(i, used_vectors);
@@ -1202,8 +1238,9 @@ void __init trap_init(void)
 	 * Should be a barrier for any external CPU state.
 	 */
 	cpu_init();
-
+#ifndef CONFIG_XEN
 	trap_init_hook();
+#endif
 }
 
 static int __init kstack_setup(char *s)
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index b84f57b..2d438bb 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -184,8 +184,8 @@ static void xen_cpuid(unsigned int *eax, unsigned int *ebx,
 	 * unsupported kernel subsystems as possible.
 	 */
 	if (*eax == 1) {
-		maskedx = ~(1 << X86_FEATURE_APIC);  /* disable local APIC */
 		if (!is_initial_xendomain())
+			maskedx = ~(1 << X86_FEATURE_APIC);  /* disable local APIC */
 			maskedx &= ~((1 << X86_FEATURE_ACPI) |  /* disable ACPI */
 				     (1 << X86_FEATURE_ACC));   /* thermal monitoring */
 	}
diff --git a/arch/x86/xen/events.c b/arch/x86/xen/events.c
index 2bf9731..88edd7c 100644
--- a/arch/x86/xen/events.c
+++ b/arch/x86/xen/events.c
@@ -82,6 +82,9 @@ static u8 cpu_evtchn[NR_EVENT_CHANNELS];
 /* Reference counts for bindings to IRQs. */
 static int irq_bindcount[NR_IRQS];
 
+/* Bitmap indicating which PIRQs require Xen to be notified on unmask. */
+static DECLARE_BITMAP(pirq_needs_eoi, NR_PIRQS);
+
 /* Xen will never allocate port zero for any purpose. */
 #define VALID_EVTCHN(chn)	((chn) != 0)
 
@@ -96,6 +99,8 @@ void force_evtchn_callback(void)
 }
 EXPORT_SYMBOL_GPL(force_evtchn_callback);
 
+static DEFINE_PER_CPU(unsigned int, upcall_count) = { 0 };
+
 static struct irq_chip xen_dynamic_chip;
 
 /* Constructor for packed IRQ information. */
@@ -235,7 +240,7 @@ static int find_unbound_irq(void)
 	int irq;
 
 	/* Only allocate from dynirq range */
-	for (irq = 0; irq < NR_IRQS; irq++)
+	for (irq = DYNIRQ_BASE; irq < NR_IRQS; irq++)
 		if (irq_bindcount[irq] == 0)
 			break;
 
@@ -471,9 +476,15 @@ fastcall void xen_evtchn_do_upcall(struct pt_regs *regs)
 	struct shared_info *s = HYPERVISOR_shared_info;
 	struct vcpu_info *vcpu_info = __get_cpu_var(xen_vcpu);
 	unsigned long pending_words;
+	unsigned int count;
+
+	do {
 
 	vcpu_info->evtchn_upcall_pending = 0;
 
+	if (unlikely(per_cpu(upcall_count, cpu)++))
+		return;
+
 	/* NB. No need for a barrier here -- XCHG is a barrier on x86. */
 	pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0);
 	while (pending_words != 0) {
@@ -492,6 +503,10 @@ fastcall void xen_evtchn_do_upcall(struct pt_regs *regs)
 			}
 		}
 	}
+	/* If there were nested callbacks then we have more to do. */
+	count = per_cpu(upcall_count, cpu);
+	per_cpu(upcall_count, cpu) = 0;
+	} while (unlikely(count != 1));
 
 	put_cpu();
 }
@@ -573,6 +588,132 @@ static struct irq_chip xen_dynamic_chip __read_mostly = {
 	.retrigger	= retrigger_dynirq,
 };
 
+static inline void pirq_unmask_notify(int irq)
+{
+	struct physdev_eoi eoi = { .irq = irq };
+
+	if (unlikely(test_bit(irq, pirq_needs_eoi)))
+		(void)HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi);
+}
+
+static inline void pirq_query_unmask(int irq)
+{
+	struct physdev_irq_status_query irq_status;
+
+	irq_status.irq = irq;
+	(void)HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status);
+	clear_bit(irq, pirq_needs_eoi);
+	if (irq_status.flags & XENIRQSTAT_needs_eoi)
+		set_bit(irq, pirq_needs_eoi);
+}
+
+/*
+ * On startup, if there is no action associated with the IRQ then we are
+ * probing. In this case we should not share with others as it will confuse us.
+ */
+#define probing_irq(_irq) (irq_desc[(_irq)].action == NULL)
+
+static unsigned int startup_pirq(unsigned int irq)
+{
+	struct evtchn_bind_pirq bind_pirq;
+	int evtchn = evtchn_from_irq(irq);
+
+	if (VALID_EVTCHN(evtchn))
+		goto out;
+	
+	bind_pirq.pirq  = irq;
+	/* NB. We are happy to share unless we are probing. */
+	bind_pirq.flags = probing_irq(irq) ? 0 : BIND_PIRQ__WILL_SHARE;
+	if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_pirq, &bind_pirq) != 0) {
+		if (!probing_irq(irq))
+			printk(KERN_INFO "Failed to obtain physical IRQ %d\n",
+			       irq);
+		return 0;
+	}
+	evtchn = bind_pirq.port;
+
+	pirq_query_unmask(irq);
+
+	evtchn_to_irq[evtchn] = irq;
+	bind_evtchn_to_cpu(evtchn, 0);
+	irq_info[irq] = mk_irq_info(IRQT_PIRQ, irq, evtchn);
+
+ out:
+	unmask_evtchn(evtchn);
+	pirq_unmask_notify(irq);
+
+	return 0;
+}
+
+static void unmask_pirq(unsigned int irq)
+{
+	int evtchn = evtchn_from_irq(irq);
+
+	if (VALID_EVTCHN(evtchn)) {
+		unmask_evtchn(evtchn);
+		pirq_unmask_notify(irq);
+	}
+}
+
+static void mask_pirq(unsigned int irq)
+{
+	int evtchn = evtchn_from_irq(irq);
+
+	if (VALID_EVTCHN(evtchn))
+		mask_evtchn(evtchn);
+}
+
+static void ack_pirq(unsigned int irq)
+{
+	int evtchn = evtchn_from_irq(irq);
+
+	move_native_irq(irq);
+
+	if (VALID_EVTCHN(evtchn)) {
+		mask_evtchn(evtchn);
+		clear_evtchn(evtchn);
+	}
+}
+
+static void eoi_pirq(unsigned int irq)
+{
+	int evtchn = evtchn_from_irq(irq);
+
+	if (VALID_EVTCHN(evtchn) && !(irq_desc[irq].status & IRQ_DISABLED)) {
+		unmask_evtchn(evtchn);
+		pirq_unmask_notify(irq);
+	}
+}
+
+static int retrigger_pirq(unsigned int irq)
+{
+	int evtchn = evtchn_from_irq(irq);
+	int ret = 0;
+
+	if (VALID_EVTCHN(evtchn)) {
+		struct shared_info *s = HYPERVISOR_shared_info;
+		int masked = sync_test_and_set_bit(evtchn, s->evtchn_mask);
+		set_evtchn(evtchn);
+
+		if (!masked)
+			unmask_evtchn(evtchn);
+		ret = 1;
+	}
+
+	return ret;
+}
+
+static struct irq_chip xen_physical_chip __read_mostly = {
+	.name		= "xen-phys",
+	.startup	= startup_pirq,
+	.mask		= mask_pirq,
+	.unmask		= unmask_pirq,
+	.ack		= ack_pirq,
+	.eoi		= eoi_pirq,
+	.set_affinity	= set_affinity_irq,
+	.retrigger	= retrigger_pirq,
+};
+
 void __init xen_init_IRQ(void)
 {
 	int i;
@@ -584,8 +725,20 @@ void __init xen_init_IRQ(void)
 		mask_evtchn(i);
 
 	/* Dynamic IRQ space is currently unbound. Zero the refcnts. */
-	for (i = 0; i < NR_IRQS; i++)
+	for (i = 0; i < NR_IRQS; i++) {
 		irq_bindcount[i] = 0;
+		irq_info[i] = IRQ_UNBOUND;
+	}
+
+	for (i = 0; i < NR_PIRQS; i++) {
+		irq_bindcount[i] = 1;
+		irq_desc[i].status = IRQ_DISABLED;
+		irq_desc[i].action = NULL;
+		irq_desc[i].depth = 1;
+		set_irq_chip_and_handler_name(i, &xen_physical_chip,
+					      handle_level_irq, "pirq");
+	}
+
 
 	irq_ctx_init(smp_processor_id());
 }
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index c341918..df800bf 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -33,6 +33,8 @@
 #include <linux/acpi.h>
 #include <linux/bootmem.h>
 
+#include <xen/hvc-console.h>
+
 #define PREFIX			"ACPI: "
 
 #define ACPI_MAX_TABLES		128
@@ -182,19 +184,21 @@ acpi_table_parse_entries(char *id,
 	unsigned int count = 0;
 	unsigned long table_end;
 
+	xprintk("atp_entries 1\n");
+
 	if (!handler)
 		return -EINVAL;
-
+	xprintk("atp_entries 2\n");
 	if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
 		acpi_get_table(id, acpi_apic_instance, &table_header);
 	else
 		acpi_get_table(id, 0, &table_header);
-
+	xprintk("atp_entries 3\n");
 	if (!table_header) {
 		printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
 		return -ENODEV;
 	}
-
+	xprintk("atp_entries 4\n");
 	table_end = (unsigned long)table_header + table_header->length;
 
 	/* Parse all entries looking for a match. */
@@ -204,6 +208,7 @@ acpi_table_parse_entries(char *id,
 
 	while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
 	       table_end) {
+		xprintk("atp_entries 5\n");
 		if (entry->type == entry_id
 		    && (!max_entries || count++ < max_entries))
 			if (handler(entry, table_end))
@@ -212,11 +217,12 @@ acpi_table_parse_entries(char *id,
 		entry = (struct acpi_subtable_header *)
 		    ((unsigned long)entry + entry->length);
 	}
+	xprintk("atp_entries 6\n");
 	if (max_entries && count > max_entries) {
 		printk(KERN_WARNING PREFIX "[%4.4s:0x%02x] ignored %i entries of "
 		       "%i found\n", id, entry_id, count - max_entries, count);
 	}
-
+	xprintk("atp_entries 7\n");
 	return count;
 }
 
diff --git a/include/asm-x86/mach-default/irq_vectors_limits.h b/include/asm-x86/mach-default/irq_vectors_limits.h
index a90c7a6..eb5e8a0 100644
--- a/include/asm-x86/mach-default/irq_vectors_limits.h
+++ b/include/asm-x86/mach-default/irq_vectors_limits.h
@@ -1,6 +1,18 @@
 #ifndef _ASM_IRQ_VECTORS_LIMITS_H
 #define _ASM_IRQ_VECTORS_LIMITS_H
 
+
+#ifdef CONFIG_XEN
+#define PIRQ_BASE		0
+#define NR_PIRQS		256
+
+#define DYNIRQ_BASE		(PIRQ_BASE + NR_PIRQS)
+#define NR_DYNIRQS		256
+
+#define NR_IRQS			(NR_PIRQS + NR_DYNIRQS)
+#define NR_IRQ_VECTORS		NR_IRQS
+
+#else
 #if defined(CONFIG_X86_IO_APIC) || defined(CONFIG_PARAVIRT)
 #define NR_IRQS 224
 # if (224 >= 32 * NR_CPUS)
@@ -12,5 +24,6 @@
 #define NR_IRQS 16
 #define NR_IRQ_VECTORS NR_IRQS
 #endif
+#endif /* CONFIG_XEN */
 
 #endif /* _ASM_IRQ_VECTORS_LIMITS_H */
diff --git a/init/main.c b/init/main.c
index eee7888..24ac4cd 100644
--- a/init/main.c
+++ b/init/main.c
@@ -68,6 +68,8 @@
 #include <asm/smp.h>
 #endif
 
+#include <xen/hvc-console.h>
+
 /*
  * This is one of the first .c files built. Error out early if we have compiler
  * trouble.
@@ -551,56 +553,80 @@ asmlinkage void __init start_kernel(void)
 	printk(KERN_NOTICE);
 	printk(linux_banner);
 	setup_arch(&command_line);
+	xprintk("start_kernel 9\n");
 	setup_command_line(command_line);
+	xprintk("start_kernel 10\n");
 	unwind_setup();
+	xprintk("start_kernel 11\n");
 	setup_per_cpu_areas();
+	xprintk("start_kernel 12\n");
 	smp_prepare_boot_cpu();	/* arch-specific boot-cpu hooks */
-
+	xprintk("start_kernel 13\n");
 	/*
 	 * Set up the scheduler prior starting any interrupts (such as the
 	 * timer interrupt). Full topology setup happens at smp_init()
 	 * time - but meanwhile we still have a functioning scheduler.
 	 */
+	xprintk("start_kernel 14\n");
 	sched_init();
 	/*
 	 * Disable preemption - early bootup scheduling is extremely
 	 * fragile until we cpu_idle() for the first time.
 	 */
+	xprintk("start_kernel 15\n");
 	preempt_disable();
+	xprintk("start_kernel 16\n");
 	build_all_zonelists();
+	xprintk("start_kernel 17\n");
 	page_alloc_init();
+	xprintk("start_kernel 18\n");
 	printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line);
 	parse_early_param();
+	xprintk("start_kernel 19\n");
 	parse_args("Booting kernel", static_command_line, __start___param,
 		   __stop___param - __start___param,
 		   &unknown_bootoption);
+	xprintk("start_kernel 20\n");
 	if (!irqs_disabled()) {
 		printk(KERN_WARNING "start_kernel(): bug: interrupts were "
 				"enabled *very* early, fixing it\n");
 		local_irq_disable();
 	}
+	xprintk("start_kernel 21\n");
 	sort_main_extable();
+	xprintk("start_kernel 22\n");
 	trap_init();
+	xprintk("start_kernel 23\n");
 	rcu_init();
+	xprintk("start_kernel 24\n");
 	init_IRQ();
+	xprintk("start_kernel 25\n");
 	pidhash_init();
+	xprintk("start_kernel 26\n");
 	init_timers();
+	xprintk("start_kernel 27\n");
 	hrtimers_init();
+	xprintk("start_kernel 28\n");
 	softirq_init();
+	xprintk("start_kernel 29\n");
 	timekeeping_init();
+	xprintk("start_kernel 30\n");
 	time_init();
 	profile_init();
+	xprintk("start_kernel 31\n");
 	if (!irqs_disabled())
 		printk("start_kernel(): bug: interrupts were enabled early\n");
 	early_boot_irqs_on();
+	xprintk("start_kernel 32\n");
 	local_irq_enable();
-
+	xprintk("start_kernel 33\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
 	 * this. But we do want output early, in case something goes wrong.
 	 */
 	console_init();
+	xprintk("start_kernel 34\n");
 	if (panic_later)
 		panic(panic_later, panic_param);
 
-- 
1.5.4.2


linux-2.6-xen-0026-xen-dom0-Obvious-cpuid-fix-to-domU-handling.patch:

--- NEW FILE linux-2.6-xen-0026-xen-dom0-Obvious-cpuid-fix-to-domU-handling.patch ---
>From e15de921d99be19d32be489f5a210d6568d54ebf Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Thu, 13 Dec 2007 18:00:17 +0000
Subject: [PATCH] xen dom0: Obvious cpuid fix to domU handling.

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

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 2d438bb..806d739 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -184,10 +184,11 @@ static void xen_cpuid(unsigned int *eax, unsigned int *ebx,
 	 * unsupported kernel subsystems as possible.
 	 */
 	if (*eax == 1) {
-		if (!is_initial_xendomain())
+		if (!is_initial_xendomain()) {
 			maskedx = ~(1 << X86_FEATURE_APIC);  /* disable local APIC */
 			maskedx &= ~((1 << X86_FEATURE_ACPI) |  /* disable ACPI */
 				     (1 << X86_FEATURE_ACC));   /* thermal monitoring */
+		}
 	}
 
 	asm(XEN_EMULATE_PREFIX "cpuid"
-- 
1.5.4.2


linux-2.6-xen-0027-xen-debug-Diagnose-bind_virq_to_irq-errors.patch:

--- NEW FILE linux-2.6-xen-0027-xen-debug-Diagnose-bind_virq_to_irq-errors.patch ---
>From 71f4fd1ac9a9657a91cb4b6702c7615fc9cc7709 Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Mon, 7 Jan 2008 20:39:20 +0000
Subject: [PATCH] xen debug: Diagnose bind_virq_to_irq errors

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

diff --git a/arch/x86/xen/events.c b/arch/x86/xen/events.c
index 88edd7c..1014809 100644
--- a/arch/x86/xen/events.c
+++ b/arch/x86/xen/events.c
@@ -329,8 +329,11 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
 		bind_virq.virq = virq;
 		bind_virq.vcpu = cpu;
 		if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
-						&bind_virq) != 0)
+						&bind_virq) != 0) {
+			printk(KERN_ERR "%s: failed on virq %u, vcpu %u\n",
+			       __FUNCTION__, virq, cpu);
 			BUG();
+		}
 		evtchn = bind_virq.port;
 
 		irq = find_unbound_irq();
-- 
1.5.4.2


linux-2.6-xen-0028-xen-traps-Revert-Juan-s-traps_32.c-changes-to-debug.patch:

--- NEW FILE linux-2.6-xen-0028-xen-traps-Revert-Juan-s-traps_32.c-changes-to-debug.patch ---
>From b3df330c365062bcf5c6c36067075870fa627c11 Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Mon, 7 Jan 2008 20:39:51 +0000
Subject: [PATCH] xen traps: Revert Juan's traps_32.c changes to debug why they are needed.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/kernel/traps_32.c |   41 ++---------------------------------------
 1 files changed, 2 insertions(+), 39 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 912cbc8..02d1e1e 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -59,8 +59,6 @@
 
 #include <linux/module.h>
 
-#include <asm/xen/hypercall.h>
-
 #include "mach_traps.h"
 
 int panic_on_unrecovered_nmi;
@@ -1132,42 +1130,10 @@ static void __init set_task_gate(unsigned int n, unsigned int gdt_entry)
 }
 
 
-/*
- * NB. All these are "trap gates" (i.e. events_mask isn't set) except
- * for those that specify <dpl>|4 in the second field.
- */
-static struct trap_info trap_table[] = {
-	{  0, 0, __KERNEL_CS, (unsigned long)divide_error		},
-	{  1, 0|4, __KERNEL_CS, (unsigned long)debug			},
-	{  3, 3|4, __KERNEL_CS, (unsigned long)int3			},
-	{  4, 3, __KERNEL_CS, (unsigned long)overflow			},
-	{  5, 0, __KERNEL_CS, (unsigned long)bounds			},
-	{  6, 0, __KERNEL_CS, (unsigned long)invalid_op			},
-	{  7, 0|4, __KERNEL_CS, (unsigned long)device_not_available	},
-	{  9, 0, __KERNEL_CS, (unsigned long)coprocessor_segment_overrun },
-	{ 10, 0, __KERNEL_CS, (unsigned long)invalid_TSS		},
-	{ 11, 0, __KERNEL_CS, (unsigned long)segment_not_present	},
-	{ 12, 0, __KERNEL_CS, (unsigned long)stack_segment		},
-	{ 13, 0, __KERNEL_CS, (unsigned long)general_protection		},
-	{ 14, 0|4, __KERNEL_CS, (unsigned long)page_fault		},
-	{ 15, 0, __KERNEL_CS, (unsigned long)invalid_TSS		},
-	{ 16, 0, __KERNEL_CS, (unsigned long)coprocessor_error		},
-	{ 17, 0, __KERNEL_CS, (unsigned long)alignment_check		},
-#ifdef CONFIG_X86_MCE
-	{ 18, 0, __KERNEL_CS, (unsigned long)machine_check		},
-#endif
-	{ 19, 0, __KERNEL_CS, (unsigned long)simd_coprocessor_error	},
-	{ SYSCALL_VECTOR,  3, __KERNEL_CS, (unsigned long)system_call	},
-	{  0, 0,	   0, 0						}
-};
-
 void __init trap_init(void)
 {
 	int i;
 
-#ifdef CONFIG_XEN
-	HYPERVISOR_set_trap_table(trap_table);
-#else
 #ifdef CONFIG_EISA
 	void __iomem *p = ioremap(0x0FFFD9, 4);
 	if (readl(p) == 'E'+('I'<<8)+('S'<<16)+('A'<<24)) {
@@ -1202,7 +1168,6 @@ void __init trap_init(void)
 	set_trap_gate(18,&machine_check);
 #endif
 	set_trap_gate(19,&simd_coprocessor_error);
-#endif /* !CONFIG_XEN */
 
 	if (cpu_has_fxsr) {
 		/*
@@ -1226,9 +1191,8 @@ void __init trap_init(void)
 		printk("done.\n");
 	}
 
-#ifndef CONFIG_XEN
 	set_system_gate(SYSCALL_VECTOR,&system_call);
-#endif
+
 	/* Reserve all the builtin and the syscall vector. */
 	for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++)
 		set_bit(i, used_vectors);
@@ -1238,9 +1202,8 @@ void __init trap_init(void)
 	 * Should be a barrier for any external CPU state.
 	 */
 	cpu_init();
-#ifndef CONFIG_XEN
+
 	trap_init_hook();
-#endif
 }
 
 static int __init kstack_setup(char *s)
-- 
1.5.4.2


linux-2.6-xen-0029-xen-debug-Move-init_apic_mappings-after-trap-init.patch:

--- NEW FILE linux-2.6-xen-0029-xen-debug-Move-init_apic_mappings-after-trap-init.patch ---
>From 719698e7940cc4122500970d1824db276076a963 Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Tue, 8 Jan 2008 15:33:44 +0000
Subject: [PATCH] xen debug: Move init_apic_mappings() after trap initialisation.

Improves the chance of meaningful debug output if the apic init goes wrong.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/kernel/traps_32.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 02d1e1e..065ef05 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -1142,10 +1142,6 @@ void __init trap_init(void)
 	iounmap(p);
 #endif
 
-#ifdef CONFIG_X86_LOCAL_APIC
-	init_apic_mappings();
-#endif
-
 	set_trap_gate(0,&divide_error);
 	set_intr_gate(1,&debug);
 	set_intr_gate(2,&nmi);
@@ -1169,6 +1165,10 @@ void __init trap_init(void)
 #endif
 	set_trap_gate(19,&simd_coprocessor_error);
 
+#ifdef CONFIG_X86_LOCAL_APIC
+	init_apic_mappings();
+#endif
+
 	if (cpu_has_fxsr) {
 		/*
 		 * Verify that the FXSAVE/FXRSTOR data will be 16-byte aligned.
-- 
1.5.4.2


linux-2.6-xen-0030-xen-debug-Trace-progress-in-trap_init-around-init.patch:

--- NEW FILE linux-2.6-xen-0030-xen-debug-Trace-progress-in-trap_init-around-init.patch ---
>From 52ab2f65548fafadb3a80b1c6da0dd096f06992d Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Tue, 8 Jan 2008 15:54:05 +0000
Subject: [PATCH] xen debug: Trace progress in trap_init() around init_apic_mappings()

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

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 065ef05..5def73a 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -61,6 +61,8 @@
 
 #include "mach_traps.h"
 
+#include <xen/hvc-console.h>
+
 int panic_on_unrecovered_nmi;
 
 DECLARE_BITMAP(used_vectors, NR_VECTORS);
@@ -1142,6 +1144,7 @@ void __init trap_init(void)
 	iounmap(p);
 #endif
 
+	xprintk("trap_init 0\n");
 	set_trap_gate(0,&divide_error);
 	set_intr_gate(1,&debug);
 	set_intr_gate(2,&nmi);
@@ -1166,7 +1169,9 @@ void __init trap_init(void)
 	set_trap_gate(19,&simd_coprocessor_error);
 
 #ifdef CONFIG_X86_LOCAL_APIC
+	xprintk("trap_init 1\n");
 	init_apic_mappings();
+	xprintk("trap_init 2\n");
 #endif
 
 	if (cpu_has_fxsr) {
-- 
1.5.4.2


linux-2.6-xen-0031-xen-apic-Disable-init_apic_mappings-when-under-CO.patch:

--- NEW FILE linux-2.6-xen-0031-xen-apic-Disable-init_apic_mappings-when-under-CO.patch ---
>From bc199c8d1802ae500e3a99c6b2dcfd574cc54d70 Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Tue, 8 Jan 2008 15:54:38 +0000
Subject: [PATCH] xen apic: Disable init_apic_mappings() when under CONFIG_XEN

Hack, needs to be a runtime switch.

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

diff --git a/arch/x86/kernel/apic_32.c b/arch/x86/kernel/apic_32.c
index 06b8860..637a735 100644
--- a/arch/x86/kernel/apic_32.c
+++ b/arch/x86/kernel/apic_32.c
@@ -1110,6 +1110,7 @@ no_apic:
  */
 void __init init_apic_mappings(void)
 {
+#ifndef CONFIG_XEN
 	unsigned long apic_phys;
 
 	/*
@@ -1164,6 +1165,7 @@ fake_ioapic_page:
 		}
 	}
 #endif
+#endif
 }
 
 /*
-- 
1.5.4.2


linux-2.6-xen-0032-xen-debug-Log-entry-into-virtual-console-s-xen_init.patch:

--- NEW FILE linux-2.6-xen-0032-xen-debug-Log-entry-into-virtual-console-s-xen_init.patch ---
>From 850979a035b77d66ae191d4117f5ef49157148c4 Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Tue, 8 Jan 2008 18:42:32 +0000
Subject: [PATCH] xen debug: Log entry into virtual console's xen_init() function

Signed-off-by: Stephen Tweedie <sct 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 6e85664..db5bff3 100644
--- a/drivers/char/hvc_xen.c
+++ b/drivers/char/hvc_xen.c
@@ -136,6 +136,9 @@ static int __init xen_init(void)
 	if (!is_running_on_xen())
 		return 0;
 
+	printk(KERN_INFO "%s: entered on cpu %d\n",
+	       __FUNCTION__, smp_processor_id());
+	
 	if (is_initial_xendomain()) {
 		ops = &dom0_hvc_ops;
 		xencons_irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
-- 
1.5.4.2


linux-2.6-xen-0033-xen-debug-Log-bind_virq_to_irq-events.patch:

--- NEW FILE linux-2.6-xen-0033-xen-debug-Log-bind_virq_to_irq-events.patch ---
>From 54b20ea9ea5aeb9e516009271f010a2f1ef761e5 Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Tue, 8 Jan 2008 18:43:03 +0000
Subject: [PATCH] xen debug: Log bind_virq_to_irq events

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

diff --git a/arch/x86/xen/events.c b/arch/x86/xen/events.c
index 1014809..ca4912e 100644
--- a/arch/x86/xen/events.c
+++ b/arch/x86/xen/events.c
@@ -319,7 +319,7 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
 int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
 {
 	struct evtchn_bind_virq bind_virq;
-	int evtchn, irq;
+	int evtchn, irq, rc;
 
 	spin_lock(&irq_mapping_update_lock);
 
@@ -328,10 +328,10 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
 	if (irq == -1) {
 		bind_virq.virq = virq;
 		bind_virq.vcpu = cpu;
-		if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
-						&bind_virq) != 0) {
-			printk(KERN_ERR "%s: failed on virq %u, vcpu %u\n",
-			       __FUNCTION__, virq, cpu);
+		if ((rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
+						      &bind_virq)) != 0) {
+			printk(KERN_ERR "%s: failed on virq %u, vcpu %u, err %d\n",
+			       __FUNCTION__, virq, cpu, rc);
 			BUG();
 		}
 		evtchn = bind_virq.port;
-- 
1.5.4.2


linux-2.6-xen-0034-xen-debug-Work-around-USB-issue-triggered-by-Xen-de.patch:

--- NEW FILE linux-2.6-xen-0034-xen-debug-Work-around-USB-issue-triggered-by-Xen-de.patch ---
>From 60777009391f106a1cedc1c92ee1e5d91fa69aaa Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Mon, 4 Feb 2008 22:10:55 +0000
Subject: [PATCH] xen debug: Work around USB issue triggered by Xen debugging.

It appears that having too much serial console output from Xen's
startup_pirq() is tripping up a race in the usb stack when usb
initialisation fails.  By the time usb_kick_khubd gets around to
poking the khubd, the driver has already been torn down, and we
get a null pointer deref.

Checking for that in usb_kick_khubd lets us get past that, but
we still need to work out why the usb init is failing in the
first place.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 drivers/usb/core/hub.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b04d232..5a335ee 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -345,7 +345,8 @@ static void kick_khubd(struct usb_hub *hub)
 void usb_kick_khubd(struct usb_device *hdev)
 {
 	/* FIXME: What if hdev isn't bound to the hub driver? */
-	kick_khubd(hdev_to_hub(hdev));
+	if (hdev && hdev->actconfig && hdev_to_hub(hdev))
+		kick_khubd(hdev_to_hub(hdev));
 }
 
 
-- 
1.5.4.2


linux-2.6-xen-0035-Remove-duplicated-dma_alloc-free_noncoherent-define.patch:

--- NEW FILE linux-2.6-xen-0035-Remove-duplicated-dma_alloc-free_noncoherent-define.patch ---
>From 54858ead14d7f7d127d7322fe98c14721a989344 Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Mon, 21 Jan 2008 16:18:57 +0000
Subject: [PATCH] Remove duplicated dma_alloc/free_noncoherent #defines.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 include/asm-x86/dma-mapping_64.h |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index ecd0f61..d0e10b3 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -65,9 +65,6 @@ static inline int dma_mapping_error(dma_addr_t dma_addr)
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
 
-#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
-#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
-
 extern void *dma_alloc_coherent(struct device *dev, size_t size,
 				dma_addr_t *dma_handle, gfp_t gfp);
 extern void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
-- 
1.5.4.2


linux-2.6-xen-0036-xem-dom0-Add-hypervisor-memory_exchange-descriptor.patch:

--- NEW FILE linux-2.6-xen-0036-xem-dom0-Add-hypervisor-memory_exchange-descriptor.patch ---
>From 64c33eb742c80d4ec64d6f100fea3ed10b7f34fd Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Thu, 31 Jan 2008 19:26:06 +0000
Subject: [PATCH] xem dom0: Add hypervisor memory_exchange descriptor

Adds the memory_exchange descriptors needed to allow dom0 to ask
the hypervisor to force regions of its memory to be machine-
contiguous.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 include/xen/interface/memory.h |   42 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h
index af36ead..1ad1d74 100644
--- a/include/xen/interface/memory.h
+++ b/include/xen/interface/memory.h
@@ -142,4 +142,46 @@ struct xen_translate_gpfn_list {
 };
 DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list);
 
+/*
+ * An atomic exchange of memory pages. If return code is zero then
+ * @out.extent_list provides GMFNs of the newly-allocated memory.
+ * Returns zero on complete success, otherwise a negative error code.
+ * On complete success then always @nr_exchanged == @in.nr_extents.
+ * On partial success @nr_exchanged indicates how much work was done.
+ */
+#define XENMEM_exchange             11
+struct xen_memory_exchange {
+    /*
+     * [IN] Details of memory extents to be exchanged (GMFN bases).
+     * Note that @in.address_bits is ignored and unused.
+     */
+    struct xen_memory_reservation in;
+
+    /*
+     * [IN/OUT] Details of new memory extents.
+     * We require that:
+     *  1. @in.domid == @out.domid
+     *  2. @in.nr_extents  << @in.extent_order == 
+     *     @out.nr_extents << @out.extent_order
+     *  3. @in.extent_start and @out.extent_start lists must not overlap
+     *  4. @out.extent_start lists GPFN bases to be populated
+     *  5. @out.extent_start is overwritten with allocated GMFN bases
+     */
+    struct xen_memory_reservation out;
+
+    /*
+     * [OUT] Number of input extents that were successfully exchanged:
+     *  1. The first @nr_exchanged input extents were successfully
+     *     deallocated.
+     *  2. The corresponding first entries in the output extent list correctly
+     *     indicate the GMFNs that were successfully exchanged.
+     *  3. All other input and output extents are untouched.
+     *  4. If not all input exents are exchanged then the return code of this
+     *     command will be non-zero.
+     *  5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER!
+     */
+    unsigned int nr_exchanged;
+};
+DEFINE_GUEST_HANDLE_STRUCT(xen_memory_exchange);
+
 #endif /* __XEN_PUBLIC_MEMORY_H__ */
-- 
1.5.4.2


linux-2.6-xen-0037-xen-dom0-add-virt_to_pfn-macro.patch:

--- NEW FILE linux-2.6-xen-0037-xen-dom0-add-virt_to_pfn-macro.patch ---
>From 0df6aed5f602875138fe28038bfc720ceee406d6 Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Mon, 4 Feb 2008 16:40:57 +0000
Subject: [PATCH] xen dom0: add virt_to_pfn() macro

The xen/mmu.c code is computing pfns manually via PFN_DOWN(__pa(v))
in various places.  Add a new virt_to_pfn macro to do that more
cleanly, complementing the existing virt_to_mfn in include/xen/page.h.

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

diff --git a/include/xen/page.h b/include/xen/page.h
index c0c8fcb..ce45a6b 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -134,7 +134,8 @@ static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
 
 /* VIRT <-> MACHINE conversion */
 #define virt_to_machine(v)	(phys_to_machine(XPADDR(__pa(v))))
-#define virt_to_mfn(v)		(pfn_to_mfn(PFN_DOWN(__pa(v))))
+#define virt_to_pfn(v)		(PFN_DOWN(__pa(v)))
+#define virt_to_mfn(v)		(pfn_to_mfn(virt_to_pfn(v)))
 #define mfn_to_virt(m)		(__va(mfn_to_pfn(m) << PAGE_SHIFT))
 
 #ifdef CONFIG_X86_PAE
-- 
1.5.4.2


linux-2.6-xen-0038-xen-dom0-use-virt_to_pfn-where-appropriate.patch:

--- NEW FILE linux-2.6-xen-0038-xen-dom0-use-virt_to_pfn-where-appropriate.patch ---
>From 7a95e548ccb7d2fee76004d4d3f7a1f02bb70f7a Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Mon, 4 Feb 2008 16:42:35 +0000
Subject: [PATCH] xen dom0: use virt_to_pfn() where appropriate

Simply cleans up the code to use avoid manually coding the virt-to-pfn
conversion all over the place.

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

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 2e28104..5bbdbb7 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -454,7 +454,7 @@ void xen_pgd_pin(pgd_t *pgd)
 	level = MMUEXT_PIN_L2_TABLE;
 #endif
 
-	xen_do_pin(level, PFN_DOWN(__pa(pgd)));
+	xen_do_pin(level, virt_to_pfn(pgd));
 
 	xen_mc_issue(0);
 }
@@ -509,7 +509,7 @@ static void xen_pgd_unpin(pgd_t *pgd)
 {
 	xen_mc_batch();
 
-	xen_do_pin(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(pgd)));
+	xen_do_pin(MMUEXT_UNPIN_TABLE, virt_to_pfn(pgd));
 
 	pgd_walk(pgd, unpin_page, TASK_SIZE);
 
-- 
1.5.4.2


linux-2.6-xen-0039-xen-dom0-Add-contiguous-region-support.patch:

--- NEW FILE linux-2.6-xen-0039-xen-dom0-Add-contiguous-region-support.patch ---
>From b21537dd3c85a716b1301374faf725c00598b0ac Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Thu, 31 Jan 2008 11:47:28 +0000
Subject: [PATCH] xen dom0: Add contiguous region support.

Adds xen_(create|destroy)_contiguous_region, to force ranges of pfns
to be physically contiguous in machine ram, so that DMA can be
performed correctly from it.

Based on the code from linux-2.6.18-xen.hg, but updated to use
multicall batching for contig region pte updating, and refactored to
split out the common code for zapping/remapping ptes and performing
the memory exchange hypercall.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/xen/enlighten.c |   21 +++-
 arch/x86/xen/mmu.c       |  247 +++++++++++++++++++++++++++++++++++++++++++++-
 include/xen/page.h       |   17 +++
 3 files changed, 280 insertions(+), 5 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 806d739..a11607a 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -865,18 +865,31 @@ static __init void xen_pagetable_setup_done(pgd_t *base)
 		pin_pagetable_pfn(level, PFN_DOWN(__pa(base)));
 	}
 
-	/*
-	 * If we're dom0, then 1:1 map the ISA machine addresses into
-	 * the kernel's address space.
-	 */
 	if (is_initial_xendomain()) {
 		unsigned i;
+		extern unsigned long *contiguous_bitmap;
 
+		/*
+		 * If we're dom0, then 1:1 map the ISA machine addresses
+		 * into the kernel's address space.
+		 */
 		for(i = ISA_START_ADDRESS; i < ISA_END_ADDRESS; i += PAGE_SIZE)
 			set_pte_mfn(PAGE_OFFSET + i, PFN_DOWN(i), PAGE_KERNEL);
 
 		reserve_bootmem(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS);
 		printk(KERN_INFO "Xen: setup ISA identity maps\n");
+
+		/*
+		 * Allocate a contiguous page bitmap, to mark dma
+		 * coherent regions.  This may eventually be needed for
+		 * domU too, if PCI front/back support is added, but for
+		 * now it is only required for dom0.
+		 */
+		contiguous_bitmap = alloc_bootmem_low_pages
+			((max_low_pfn + 2*BITS_PER_LONG) >> 3);
+		BUG_ON(!contiguous_bitmap);
+		memset(contiguous_bitmap, 0, (max_low_pfn + 2*BITS_PER_LONG) >> 3);
+
 	}
 }
 
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 5bbdbb7..7d5111b 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -47,15 +47,17 @@
 #include <asm/mmu_context.h>
 #include <asm/paravirt.h>
 
-#include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
 
 #include <xen/page.h>
 #include <xen/interface/xen.h>
+#include <xen/interface/memory.h>
 
 #include "multicalls.h"
 #include "mmu.h"
 
+DEFINE_SPINLOCK(reservation_lock);
+
 xmaddr_t arbitrary_virt_to_machine(unsigned long address)
 {
 	pte_t *pte = lookup_address(address);
@@ -614,3 +616,246 @@ void xen_exit_mmap(struct mm_struct *mm)
 
 	spin_unlock(&mm->page_table_lock);
 }
+
+
+/*
+ * Bitmap is indexed by page number. If bit is set, the page is part of a
+ * xen_create_contiguous_region() area of memory.
+ */
+unsigned long *contiguous_bitmap;
+
+static void contiguous_bitmap_set(
+	unsigned long first_page, unsigned long nr_pages)
+{
+	unsigned long start_off, end_off, curr_idx, end_idx;
+
+	curr_idx  = first_page / BITS_PER_LONG;
+	start_off = first_page & (BITS_PER_LONG-1);
+	end_idx   = (first_page + nr_pages) / BITS_PER_LONG;
+	end_off   = (first_page + nr_pages) & (BITS_PER_LONG-1);
+
+	if (curr_idx == end_idx) {
+		contiguous_bitmap[curr_idx] |=
+			((1UL<<end_off)-1) & -(1UL<<start_off);
+	} else {
+		contiguous_bitmap[curr_idx] |= -(1UL<<start_off);
+		while ( ++curr_idx < end_idx )
+			contiguous_bitmap[curr_idx] = ~0UL;
+		contiguous_bitmap[curr_idx] |= (1UL<<end_off)-1;
+	}
+}
+
+static void contiguous_bitmap_clear(
+	unsigned long first_page, unsigned long nr_pages)
+{
+	unsigned long start_off, end_off, curr_idx, end_idx;
+
+	curr_idx  = first_page / BITS_PER_LONG;
+	start_off = first_page & (BITS_PER_LONG-1);
+	end_idx   = (first_page + nr_pages) / BITS_PER_LONG;
+	end_off   = (first_page + nr_pages) & (BITS_PER_LONG-1);
+
+	if (curr_idx == end_idx) {
+		contiguous_bitmap[curr_idx] &=
+			-(1UL<<end_off) | ((1UL<<start_off)-1);
+	} else {
+		contiguous_bitmap[curr_idx] &= (1UL<<start_off)-1;
+		while ( ++curr_idx != end_idx )
+			contiguous_bitmap[curr_idx] = 0;
+		contiguous_bitmap[curr_idx] &= -(1UL<<end_off);
+	}
+}
+
+/* Protected by balloon_lock. */
+#define MAX_CONTIG_ORDER 9 /* 2MB */
+static unsigned long discontig_frames[1<<MAX_CONTIG_ORDER];
+
+/*
+ * Zap a range of ptes, recording the pfn and mfn numbers as required as
+ * we go
+ */
+#define VOID_PTE (mfn_pte(0, __pgprot(0)))
+static void xen_zap_pfn_range(unsigned long vaddr, int order,
+			      unsigned long *in_frames,
+			      unsigned long *out_frames)
+{
+	int i;
+	struct multicall_space mcs;
+
+	xen_mc_batch();
+	for (i = 0; i < (1UL<<order); i++, vaddr += PAGE_SIZE) {
+		mcs = __xen_mc_entry(0);
+
+		if (in_frames)
+			in_frames[i] = virt_to_mfn(vaddr);
+
+		MULTI_update_va_mapping(mcs.mc, vaddr, VOID_PTE, 0);
+		set_phys_to_machine(virt_to_pfn(vaddr), INVALID_P2M_ENTRY);
+
+		if (out_frames)
+			out_frames[i] = virt_to_pfn(vaddr);
+	}
+	xen_mc_issue(0);
+}
+
+/*
+ * Update the pfn-to-mfn mappings for a virtual address range, either to
+ * point to an array of mfns, or contiguously from a single starting
+ * mfn.
+ */
+static void xen_remap_exchanged_ptes(unsigned long vaddr, int order,
+				     unsigned long *mfns,
+				     unsigned long first_mfn)
+{
+	int i;
+	unsigned long mfn;
+	struct multicall_space mcs;
+
+	xen_mc_batch();
+	for (i = 0; i < (1UL<<order); i++, vaddr += PAGE_SIZE) {
+		mcs = __xen_mc_entry(0);
+
+		if (mfns) 
+			mfn = mfns[i];
+		else
+			mfn = first_mfn + i;
+		MULTI_update_va_mapping(mcs.mc, vaddr, 
+					mfn_pte(mfn, PAGE_KERNEL), 0);
+		set_phys_to_machine(virt_to_pfn(vaddr), mfn);
+	}
+
+	mcs.mc->args[MULTI_UVMFLAGS_INDEX] = order ? UVMF_TLB_FLUSH|UVMF_ALL
+						   : UVMF_INVLPG|UVMF_ALL;
+
+	xen_mc_issue(0);
+}
+
+/*
+ * Perform the hypercall to exchange a region of our pfns to point to
+ * memory with the required contiguous alignment.  Takes the pfns as
+ * input, and populates mfns as output.  
+ *
+ * Returns a success code indicating whether the hypervisor was able to
+ * satisfy the request or not.
+ */
+int xen_exchange_memory(unsigned long extents_in, unsigned int order_in,
+			unsigned long *pfns_in,
+			unsigned long extents_out, unsigned int order_out,
+			unsigned long *mfns_out,
+			unsigned int address_bits)
+{
+	long rc;
+	int success;
+	
+	struct xen_memory_exchange exchange = {
+		.in = {
+			.nr_extents   = extents_in,
+			.extent_order = order_in,
+			.extent_start = pfns_in,
+			.domid        = DOMID_SELF
+		},
+		.out = {
+			.nr_extents   = extents_out,
+			.extent_order = order_out,
+			.extent_start = mfns_out,
+			.address_bits = address_bits,
+			.domid        = DOMID_SELF
+		}
+	};
+	
+	BUG_ON (extents_in << order_in != extents_out << order_out);
+	
+	rc = HYPERVISOR_memory_op(XENMEM_exchange, &exchange);
+	success = (exchange.nr_exchanged == extents_in);
+
+	BUG_ON(!success && ((exchange.nr_exchanged != 0) || (rc == 0)));
+	BUG_ON(success && (rc != 0));
+
+	return success;
+}
+
+
+int xen_create_contiguous_region(
+	unsigned long vstart, unsigned int order, unsigned int address_bits)
+{
+	unsigned long *in_frames = discontig_frames, out_frame;
+	unsigned long  flags;
+	int            success;
+	/*
+	 * Currently an auto-translated guest will not perform I/O, nor will
+	 * it require PAE page directories below 4GB. Therefore any calls to
+	 * this function are redundant and can be ignored.
+	 */
+	if (xen_feature(XENFEAT_auto_translated_physmap))
+		return 0;
+
+	if (unlikely(order > MAX_CONTIG_ORDER))
+		return -ENOMEM;
+
+	memset((void *) vstart, 0, PAGE_SIZE << order);
+
+	reservation_lock(flags);
+
+	/* 1. Zap current PTEs, remembering MFNs. */
+	xen_zap_pfn_range(vstart, order, in_frames, NULL);
+
+	/* 2. Get a new contiguous memory extent. */
+	out_frame = virt_to_pfn(vstart);
+	success = xen_exchange_memory(1UL << order, 0, in_frames,
+				      1, order, &out_frame,
+				      address_bits);
+
+	/* 3. Map the new extent in place of old pages. */
+	if (success)
+		xen_remap_exchanged_ptes(vstart, order, NULL, out_frame);
+	else
+		xen_remap_exchanged_ptes(vstart, order, in_frames, 0);
+
+	if (success)
+		contiguous_bitmap_set(virt_to_pfn(vstart), 1UL << order);
+
+	reservation_unlock(flags);
+
+	return success ? 0 : -ENOMEM;
+}
+EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
+
+void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
+{
+	unsigned long *out_frames = discontig_frames, in_frame;
+	unsigned long  flags;
+	int            success;
+
+	if (xen_feature(XENFEAT_auto_translated_physmap) ||
+	    !test_bit(virt_to_pfn(vstart), contiguous_bitmap))
+		return;
+
+	if (unlikely(order > MAX_CONTIG_ORDER))
+		return;
+
+	memset((void *) vstart, 0, PAGE_SIZE << order);
+
+	reservation_lock(flags);
+
+	contiguous_bitmap_clear(virt_to_pfn(vstart), 1UL << order);
+
+	/* 1. Find start MFN of contiguous extent. */
+	in_frame = virt_to_mfn(vstart);
+
+	/* 2. Zap current PTEs. */
+	xen_zap_pfn_range(vstart, order, NULL, out_frames);
+
+	/* 3. Do the exchange for non-contiguous MFNs. */
+	success = xen_exchange_memory(1, order, &in_frame,
+				      1UL << order, 0, out_frames,
+				      0);
+
+	/* 4. Map new pages in place of old pages. */
+	if (success)
+		xen_remap_exchanged_ptes(vstart, order, out_frames, 0);
+	else
+		xen_remap_exchanged_ptes(vstart, order, NULL, in_frame);
+
+	reservation_unlock(flags);
+}
+EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region);
diff --git a/include/xen/page.h b/include/xen/page.h
index ce45a6b..b453913 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -178,4 +178,21 @@ xmaddr_t arbitrary_virt_to_machine(unsigned long address);
 void make_lowmem_page_readonly(void *vaddr);
 void make_lowmem_page_readwrite(void *vaddr);
 
+int xen_create_contiguous_region(unsigned long vstart, unsigned int order, 
+				 unsigned int address_bits);
+void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order);
+
+/*
+ * Lock the memory reservations of the domain.  Can be used to (for
+ * example) prevent a balloon driver from changing the memory
+ * reservation during a driver critical region, but is also used to lock
+ * memory exchanges when changing the page reservations, for example
+ * when creating or destroying contiguous regions.
+ */
+extern spinlock_t reservation_lock;
+#define reservation_lock(__flags)   \
+	spin_lock_irqsave(&reservation_lock, (__flags))
+#define reservation_unlock(__flags) \
+	spin_unlock_irqrestore(&reservation_lock, (__flags))
+
 #endif /* __XEN_PAGE_H */
-- 
1.5.4.2


linux-2.6-xen-0040-xen-dom0-Don-t-mask-off-PCD-bits-from-pte-entries.patch:

--- NEW FILE linux-2.6-xen-0040-xen-dom0-Don-t-mask-off-PCD-bits-from-pte-entries.patch ---
>From 064de8caaca6b36cf2defdec078561b537d5f809 Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Tue, 29 Jan 2008 16:53:30 +0000
Subject: [PATCH] xen dom0: Don't mask off PCD bits from pte entries.

With pv_ops, Xen is preventing the PAGE_PCD don't-cache pte flag
from being set in any pte.  That might be reasonable for domU, but
is certainly not for dom0 --- device drivers genuinely need this
for ioremap_nocache().

If this exposes problems in domU, we'll need to address those
separately.

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

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 7d5111b..cb78a87 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -218,8 +218,6 @@ pte_t xen_make_pte(unsigned long long pte)
 	if (pte & 1)
 		pte = phys_to_machine(XPADDR(pte)).maddr;
 
-	pte &= ~_PAGE_PCD;
-
 	return (pte_t){ pte, pte >> 32 };
 }
 
@@ -267,8 +265,6 @@ pte_t xen_make_pte(unsigned long pte)
 	if (pte & _PAGE_PRESENT)
 		pte = phys_to_machine(XPADDR(pte)).maddr;
 
-	pte &= ~_PAGE_PCD;
-
 	return (pte_t){ pte };
 }
 
-- 
1.5.4.2


linux-2.6-xen-0041-xen-dom0-Remove-duplicate-xen_store_interface-assig.patch:

--- NEW FILE linux-2.6-xen-0041-xen-dom0-Remove-duplicate-xen_store_interface-assig.patch ---
>From 723cc17a9945c6cf1274004474a959360091c0fa Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Mon, 28 Jan 2008 09:32:31 +0000
Subject: [PATCH] xen dom0: Remove duplicate xen_store_interface assignment

Remove a duplicate line that assigns to xen_store_interface
the same way twice.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 drivers/xen/xenbus/xenbus_probe.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index 7263b3d..059b158 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -854,8 +854,6 @@ static int __init xenbus_probe_init(void)
 		BUG_ON(err);
 		xen_store_evtchn = xen_start_info->store_evtchn =
 			alloc_unbound.port;
-
-		xen_store_interface = mfn_to_virt(xen_store_mfn);
 	} else {
 		xenstored_ready = 1;
 		xen_store_evtchn = xen_start_info->store_evtchn;
-- 
1.5.4.2


linux-2.6-xen-0042-xen-dom0-Slightly-re-arrange-xenbus_probe_init-er.patch:

--- NEW FILE linux-2.6-xen-0042-xen-dom0-Slightly-re-arrange-xenbus_probe_init-er.patch ---
>From bc212ad648e0eeca1cfa3b913e519d79122e71bc Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Mon, 28 Jan 2008 09:44:46 +0000
Subject: [PATCH] xen dom0: Slightly re-arrange xenbus_probe_init() error handling

The dom0 xenstore page should never be allocated at
the out_error label, so only try and free it at
out_unreg_front.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 drivers/xen/xenbus/xenbus_probe.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index 059b158..c096f69 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -880,10 +880,10 @@ static int __init xenbus_probe_init(void)
   out_unreg_front:
 	bus_unregister(&xenbus_frontend.bus);
 
-  out_error:
 	if (page != 0)
 		free_page(page);
 
+  out_error:
 	return err;
 }
 
-- 
1.5.4.2


linux-2.6-xen-0043-xen-dom0-Use-max_low_pfn-declaration-from-linux-boo.patch:

--- NEW FILE linux-2.6-xen-0043-xen-dom0-Use-max_low_pfn-declaration-from-linux-boo.patch ---
>From dd070b952c603ac29d42e6a212c8005d951467ea Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Mon, 28 Jan 2008 16:42:05 +0000
Subject: [PATCH] xen dom0: Use max_low_pfn declaration from linux/bootmem.h

is_local_lowmem() currently declares max_low_pfn itself,
rather than using the declaration in linux/bootmem.h.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/mm/ioremap_32.c |    2 +-
 arch/x86/xen/ioremap.c   |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/ioremap_32.c b/arch/x86/mm/ioremap_32.c
index b4e71f4..3d3810f 100644
--- a/arch/x86/mm/ioremap_32.c
+++ b/arch/x86/mm/ioremap_32.c
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/io.h>
+#include <linux/bootmem.h>
 #include <asm/fixmap.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
@@ -42,7 +43,6 @@
  */
 static inline int is_local_lowmem(unsigned long address)
 {
-	extern unsigned long max_low_pfn;
 	if (is_running_on_xen())
 		return (mfn_to_local_pfn(address >> PAGE_SHIFT) < max_low_pfn);
 	else
diff --git a/arch/x86/xen/ioremap.c b/arch/x86/xen/ioremap.c
index 4cbbca2..70f77bd 100644
--- a/arch/x86/xen/ioremap.c
+++ b/arch/x86/xen/ioremap.c
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/io.h>
+#include <linux/bootmem.h>
 
 #include <asm/fixmap.h>
 #include <asm/cacheflush.h>
@@ -114,7 +115,6 @@ static int __direct_remap_pfn_range(struct mm_struct *mm,
  */
 static inline int is_local_lowmem(unsigned long address)
 {
-	extern unsigned long max_low_pfn;
 	return (mfn_to_local_pfn(address >> PAGE_SHIFT) < max_low_pfn);
 }
 
-- 
1.5.4.2


linux-2.6-xen-0044-xen-dma-Add-dma_mapping_ops-indirection-for-32-bit.patch:

--- NEW FILE linux-2.6-xen-0044-xen-dma-Add-dma_mapping_ops-indirection-for-32-bit.patch ---
>From 27e1441102cfd1057f625664da4813cce4ccef68 Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Mon, 21 Jan 2008 19:03:54 +0000
Subject: [PATCH] xen dma: Add dma_mapping_ops indirection for 32-bit dma mappings

Uses the same dma_mapping_ops indirections as 64-bit x86, but using
the existing 32-bit implementation underneath.  This will provide a
framework into which the Xen swiotlb operations can more cleanly be
hooked at run-time.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/kernel/Makefile_32      |    3 +-
 arch/x86/kernel/pci-dma_32.c     |   32 +++++++++
 arch/x86/kernel/pci-nommu_32.c   |   72 ++++++++++++++++++++
 arch/x86/mm/init_32.c            |    4 +
 include/asm-x86/dma-mapping_32.h |  136 ++++++++++++++++++++++----------------
 include/asm-x86/pci_32.h         |   23 ++++---
 6 files changed, 202 insertions(+), 68 deletions(-)
 create mode 100644 arch/x86/kernel/pci-nommu_32.c

diff --git a/arch/x86/kernel/Makefile_32 b/arch/x86/kernel/Makefile_32
index 879ed77..e545b89 100644
--- a/arch/x86/kernel/Makefile_32
+++ b/arch/x86/kernel/Makefile_32
@@ -8,7 +8,8 @@ CPPFLAGS_vmlinux.lds += -Ui386
 obj-y	:= process_32.o signal_32.o entry_32.o traps_32.o irq_32.o \
 		ptrace_32.o time_32.o ioport_32.o ldt_32.o setup_32.o i8259_32.o sys_i386_32.o \
 		pci-dma_32.o i386_ksyms_32.o i387_32.o bootflag.o e820_32.o\
-		quirks.o i8237.o topology.o alternative.o i8253.o tsc_32.o
+		quirks.o i8237.o topology.o alternative.o i8253.o tsc_32.o \
+		pci-nommu_32.o
 
 obj-$(CONFIG_STACKTRACE)	+= stacktrace.o
 obj-y				+= cpu/
diff --git a/arch/x86/kernel/pci-dma_32.c b/arch/x86/kernel/pci-dma_32.c
index 5133032..04a95c9 100644
--- a/arch/x86/kernel/pci-dma_32.c
+++ b/arch/x86/kernel/pci-dma_32.c
@@ -156,6 +156,38 @@ EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
 int forbid_dac;
 EXPORT_SYMBOL(forbid_dac);
 
+int dma_supported(struct device *dev, u64 mask)
+{
+        /*
+         * we fall back to GFP_DMA when the mask isn't all 1s,
+         * so we can't guarantee allocations that must be
+         * within a tighter range than GFP_DMA..
+         */
+        if(mask < 0x00ffffff)
+                return 0;
+
+	/* Work around chipset bugs */
+	if (forbid_dac > 0 && mask > 0xffffffffULL)
+		return 0;
+
+	if (dma_ops->dma_supported)
+		return dma_ops->dma_supported(dev, mask);
+
+	return 1;
+}
+EXPORT_SYMBOL(dma_supported);
+
+int dma_set_mask(struct device *dev, u64 mask)
+{
+	if(!dev->dma_mask || !dma_supported(dev, mask))
+		return -EIO;
+
+	*dev->dma_mask = mask;
+
+	return 0;
+}
+EXPORT_SYMBOL(dma_set_mask);
+
 static __devinit void via_no_dac(struct pci_dev *dev)
 {
 	if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI && forbid_dac == 0) {
diff --git a/arch/x86/kernel/pci-nommu_32.c b/arch/x86/kernel/pci-nommu_32.c
new file mode 100644
index 0000000..6a8e3ba
--- /dev/null
+++ b/arch/x86/kernel/pci-nommu_32.c
@@ -0,0 +1,72 @@
+/* Fallback functions when the main IOMMU code is not compiled in. This
+   code is roughly equivalent to i386. */
+#include <linux/mm.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/string.h>
+#include <linux/dma-mapping.h>
+#include <linux/scatterlist.h>
+
+#include <asm/processor.h>
+#include <asm/dma.h>
+
+static dma_addr_t
+nommu_map_single(struct device *dev, void *ptr, size_t size,
+	       enum dma_data_direction direction)
+{
+	WARN_ON(size == 0);
+	flush_write_buffers();
+	return virt_to_phys(ptr);
+}
+
+static void nommu_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
+			enum dma_data_direction direction)
+{
+}
+
+static int nommu_map_sg(struct device *dev, struct scatterlist *sg,
+	       int nents, enum dma_data_direction direction)
+{
+	struct scatterlist *s;
+	int i;
+
+	for_each_sg(sg, s, nents, i) {
+		BUG_ON(!sg_page(s));
+
+		s->dma_address = sg_phys(s);
+	}
+
+	flush_write_buffers();
+	return nents;
+}
+
+/* Unmap a set of streaming mode DMA translations.
+ * Again, cpu read rules concerning calls here are the same as for
+ * pci_unmap_single() above.
+ */
+static void nommu_unmap_sg(struct device *dev, struct scatterlist *sg,
+		  int nents, enum dma_data_direction direction)
+{
+}
+
+
+const struct dma_mapping_ops nommu_dma_ops = {
+	.map_single = nommu_map_single,
+	.unmap_single = nommu_unmap_single,
+	.map_sg = nommu_map_sg,
+	.unmap_sg = nommu_unmap_sg,
+	.is_phys = 1,
+};
+
+int __init no_iommu_init(void)
+{
+	if (dma_ops)
+		return 0;
+
+	dma_ops = &nommu_dma_ops;
+	return 0;
+}
+
+
+/* Must execute after PCI subsystem */
+fs_initcall(no_iommu_init);
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 4e8851a..daaeca4 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -31,6 +31,7 @@
 #include <linux/memory_hotplug.h>
 #include <linux/initrd.h>
 #include <linux/cpumask.h>
+#include <linux/dma-mapping.h>
 
 #include <asm/processor.h>
 #include <asm/system.h>
@@ -45,6 +46,9 @@
 #include <asm/sections.h>
 #include <asm/paravirt.h>
 
+const struct dma_mapping_ops* dma_ops;
+EXPORT_SYMBOL(dma_ops);
+
 unsigned int __VMALLOC_RESERVE = 128 << 20;
 
 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index 55f01bd..b14e296 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -8,6 +8,48 @@
 #include <asm/io.h>
 #include <asm/bug.h>
 
+struct dma_mapping_ops {
+	int             (*mapping_error)(dma_addr_t dma_addr);
+	void*           (*alloc_coherent)(struct device *dev, size_t size,
+                                dma_addr_t *dma_handle, gfp_t gfp);
+	void            (*free_coherent)(struct device *dev, size_t size,
+                                void *vaddr, dma_addr_t dma_handle);
+	dma_addr_t      (*map_single)(struct device *hwdev, void *ptr,
+                                size_t size, enum dma_data_direction);
+	/* like map_single, but doesn't check the device mask */
+	dma_addr_t      (*map_simple)(struct device *hwdev, char *ptr,
+                                size_t size, enum dma_data_direction);
+	void            (*unmap_single)(struct device *dev, dma_addr_t addr,
+		                size_t size, enum dma_data_direction);
+	void            (*sync_single_for_cpu)(struct device *hwdev,
+		                dma_addr_t dma_handle, size_t size,
+				enum dma_data_direction);
+	void            (*sync_single_for_device)(struct device *hwdev,
+                                dma_addr_t dma_handle, size_t size,
+				enum dma_data_direction);
+	void            (*sync_single_range_for_cpu)(struct device *hwdev,
+                                dma_addr_t dma_handle, unsigned long offset,
+		                size_t size, enum dma_data_direction);
+	void            (*sync_single_range_for_device)(struct device *hwdev,
+				dma_addr_t dma_handle, unsigned long offset,
+		                size_t size, enum dma_data_direction);
+	void            (*sync_sg_for_cpu)(struct device *hwdev,
+                                struct scatterlist *sg, int nelems,
+				enum dma_data_direction);
+	void            (*sync_sg_for_device)(struct device *hwdev,
+				struct scatterlist *sg, int nelems,
+				enum dma_data_direction);
+	int             (*map_sg)(struct device *hwdev, struct scatterlist *sg,
+		                int nents, enum dma_data_direction);
+	void            (*unmap_sg)(struct device *hwdev,
+				struct scatterlist *sg, int nents,
+				enum dma_data_direction);
+	int             (*dma_supported)(struct device *hwdev, u64 mask);
+	int		is_phys;
+};
+
+extern const struct dma_mapping_ops* dma_ops;
+
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
 
@@ -24,7 +66,7 @@ dma_map_single(struct device *dev, void *ptr, size_t size,
 	BUG_ON(!valid_dma_direction(direction));
 	WARN_ON(size == 0);
 	flush_write_buffers();
-	return virt_to_phys(ptr);
+	return dma_ops->map_single(dev, ptr, size, direction);
 }
 
 static inline void
@@ -32,61 +74,49 @@ dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
 		 enum dma_data_direction direction)
 {
 	BUG_ON(!valid_dma_direction(direction));
+	dma_ops->unmap_single(dev, dma_addr, size, direction);
 }
 
+#define dma_map_page(dev,page,offset,size,dir) \
+	dma_map_single((dev), page_address(page)+(offset), (size), (dir))
+
+#define dma_unmap_page dma_unmap_single
+
 static inline int
 dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
 	   enum dma_data_direction direction)
 {
-	struct scatterlist *sg;
-	int i;
-
 	BUG_ON(!valid_dma_direction(direction));
 	WARN_ON(nents == 0 || sglist[0].length == 0);
-
-	for_each_sg(sglist, sg, nents, i) {
-		BUG_ON(!sg_page(sg));
-
-		sg->dma_address = sg_phys(sg);
-	}
-
-	flush_write_buffers();
-	return nents;
-}
-
-static inline dma_addr_t
-dma_map_page(struct device *dev, struct page *page, unsigned long offset,
-	     size_t size, enum dma_data_direction direction)
-{
-	BUG_ON(!valid_dma_direction(direction));
-	return page_to_phys(page) + offset;
+	return dma_ops->map_sg(dev, sglist, nents, direction);
 }
 
 static inline void
-dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
-	       enum dma_data_direction direction)
-{
-	BUG_ON(!valid_dma_direction(direction));
-}
-
-
-static inline void
 dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
 	     enum dma_data_direction direction)
 {
 	BUG_ON(!valid_dma_direction(direction));
+	dma_ops->unmap_sg(dev, sg, nhwentries, direction);
 }
 
 static inline void
 dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
 			enum dma_data_direction direction)
 {
+	BUG_ON(!valid_dma_direction(direction));
+	if (dma_ops->sync_single_for_cpu)
+		dma_ops->sync_single_for_cpu(dev, dma_handle, size,
+					     direction);
 }
 
 static inline void
 dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
 			enum dma_data_direction direction)
 {
+	BUG_ON(!valid_dma_direction(direction));
+	if (dma_ops->sync_single_for_device)
+		dma_ops->sync_single_for_device(dev, dma_handle, size,
+						direction);
 	flush_write_buffers();
 }
 
@@ -95,6 +125,10 @@ dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
 			      unsigned long offset, size_t size,
 			      enum dma_data_direction direction)
 {
+	BUG_ON(!valid_dma_direction(direction));
+	if (dma_ops->sync_single_range_for_cpu)
+		dma_ops->sync_single_range_for_cpu(dev, dma_handle,
+						   offset, size, direction);
 }
 
 static inline void
@@ -102,6 +136,10 @@ dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
 				 unsigned long offset, size_t size,
 				 enum dma_data_direction direction)
 {
+	BUG_ON(!valid_dma_direction(direction));
+	if (dma_ops->sync_single_range_for_device)
+		dma_ops->sync_single_range_for_device(dev, dma_handle,
+						      offset, size, direction);
 	flush_write_buffers();
 }
 
@@ -109,51 +147,33 @@ static inline void
 dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
 		    enum dma_data_direction direction)
 {
+	BUG_ON(!valid_dma_direction(direction));
+	if (dma_ops->sync_sg_for_cpu)
+		dma_ops->sync_sg_for_cpu(dev, sg, nelems, direction);
 }
 
 static inline void
 dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
 		    enum dma_data_direction direction)
 {
+	BUG_ON(!valid_dma_direction(direction));
+	if (dma_ops->sync_sg_for_cpu)
+		dma_ops->sync_sg_for_cpu(dev, sg, nelems, direction);
 	flush_write_buffers();
 }
 
 static inline int
 dma_mapping_error(dma_addr_t dma_addr)
 {
-	return 0;
-}
+	if (dma_ops->mapping_error)
+		return dma_ops->mapping_error(dma_addr);
 
-extern int forbid_dac;
-
-static inline int
-dma_supported(struct device *dev, u64 mask)
-{
-        /*
-         * we fall back to GFP_DMA when the mask isn't all 1s,
-         * so we can't guarantee allocations that must be
-         * within a tighter range than GFP_DMA..
-         */
-        if(mask < 0x00ffffff)
-                return 0;
-
-	/* Work around chipset bugs */
-	if (forbid_dac > 0 && mask > 0xffffffffULL)
-		return 0;
-
-	return 1;
+	return 0;
 }
 
-static inline int
-dma_set_mask(struct device *dev, u64 mask)
-{
-	if(!dev->dma_mask || !dma_supported(dev, mask))
-		return -EIO;
-
-	*dev->dma_mask = mask;
+extern int dma_supported(struct device *hwdev, u64 mask);
 
-	return 0;
-}
+extern int dma_set_mask(struct device *dev, u64 mask);
 
 static inline int
 dma_get_cache_alignment(void)
diff --git a/include/asm-x86/pci_32.h b/include/asm-x86/pci_32.h
index 8c4c3a0..612f63e 100644
--- a/include/asm-x86/pci_32.h
+++ b/include/asm-x86/pci_32.h
@@ -15,15 +15,20 @@ struct pci_dev;
  * address space.  The networking and block device layers use
  * this boolean for bounce buffer decisions.
  */
-#define PCI_DMA_BUS_IS_PHYS	(1)
-
-/* pci_unmap_{page,single} is a nop so... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
-#define pci_unmap_addr(PTR, ADDR_NAME)		(0)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)	do { } while (0)
-#define pci_unmap_len(PTR, LEN_NAME)		(0)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)	do { } while (0)
+#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
+
+#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)	\
+	dma_addr_t ADDR_NAME;
+#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)		\
+	__u32 LEN_NAME;
+#define pci_unmap_addr(PTR, ADDR_NAME)			\
+	((PTR)->ADDR_NAME)
+#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)		\
+	(((PTR)->ADDR_NAME) = (VAL))
+#define pci_unmap_len(PTR, LEN_NAME)			\
+	((PTR)->LEN_NAME)
+#define pci_unmap_len_set(PTR, LEN_NAME, VAL)		\
+	(((PTR)->LEN_NAME) = (VAL))
 
 
 #endif /* __KERNEL__ */
-- 
1.5.4.2


linux-2.6-xen-0045-xen-dma-Remove-unused-32-bit-dma_ops-map_simple-me.patch:

--- NEW FILE linux-2.6-xen-0045-xen-dma-Remove-unused-32-bit-dma_ops-map_simple-me.patch ---
>From 54f268ac1f492d8c1c9532a233823676daee1fbe Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Mon, 21 Jan 2008 22:51:56 +0000
Subject: [PATCH] xen dma: Remove unused 32-bit dma_ops->map_simple method

On 64-bit, dma_ops->map_simple is only used in the gart iommu handling.
It's not needed by the 32-bit pci code, so remove it.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 include/asm-x86/dma-mapping_32.h |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index b14e296..db5f2e0 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -16,9 +16,6 @@ struct dma_mapping_ops {
                                 void *vaddr, dma_addr_t dma_handle);
 	dma_addr_t      (*map_single)(struct device *hwdev, void *ptr,
                                 size_t size, enum dma_data_direction);
-	/* like map_single, but doesn't check the device mask */
-	dma_addr_t      (*map_simple)(struct device *hwdev, char *ptr,
-                                size_t size, enum dma_data_direction);
 	void            (*unmap_single)(struct device *dev, dma_addr_t addr,
 		                size_t size, enum dma_data_direction);
 	void            (*sync_single_for_cpu)(struct device *hwdev,
-- 
1.5.4.2


linux-2.6-xen-0046-xen-dma-Initial-commit-of-pci-xen.c-dma-mapping-fun.patch:

--- NEW FILE linux-2.6-xen-0046-xen-dma-Initial-commit-of-pci-xen.c-dma-mapping-fun.patch ---
>From 77f912855d0fff7949cfb8a3975899192e521c25 Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Tue, 22 Jan 2008 17:01:48 +0000
Subject: [PATCH] xen dma: Initial commit of pci-xen.c dma mapping functions.

Adds pci-xen.c, detectable at runtime, for the Xen DMA mapping
functions.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/kernel/Makefile_32    |    2 +
 arch/x86/kernel/pci-dma_32.c   |   13 +++
 arch/x86/kernel/pci-nommu_32.c |    4 -
 arch/x86/kernel/pci-xen.c      |  162 ++++++++++++++++++++++++++++++++++++++++
 include/asm-x86/iommu.h        |   30 +-------
 include/asm-x86/iommu_32.h     |    9 ++
 include/asm-x86/iommu_64.h     |   29 +++++++
 7 files changed, 218 insertions(+), 31 deletions(-)
 create mode 100644 arch/x86/kernel/pci-xen.c
 create mode 100644 include/asm-x86/iommu_32.h
 create mode 100644 include/asm-x86/iommu_64.h

diff --git a/arch/x86/kernel/Makefile_32 b/arch/x86/kernel/Makefile_32
index e545b89..ab491bb 100644
--- a/arch/x86/kernel/Makefile_32
+++ b/arch/x86/kernel/Makefile_32
@@ -50,6 +50,8 @@ obj-y				+= pcspeaker.o
 
 obj-$(CONFIG_SCx200)		+= scx200_32.o
 
+obj-$(CONFIG_XEN)		+= pci-xen.o
+
 # vsyscall_32.o contains the vsyscall DSO images as __initdata.
 # We must build both images before we can assemble it.
 # Note: kbuild does not track this dependency due to usage of .incbin
diff --git a/arch/x86/kernel/pci-dma_32.c b/arch/x86/kernel/pci-dma_32.c
index 04a95c9..6df2e1a 100644
--- a/arch/x86/kernel/pci-dma_32.c
+++ b/arch/x86/kernel/pci-dma_32.c
@@ -13,6 +13,7 @@
 #include <linux/pci.h>
 #include <linux/module.h>
 #include <asm/io.h>
+#include <asm/iommu.h>
 
 struct dma_coherent_mem {
 	void		*virt_base;
@@ -150,6 +151,16 @@ void *dma_mark_declared_memory_occupied(struct device *dev,
 }
 EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
 
+static int __init pci_iommu_init(void)
+{
+#ifdef CONFIG_XEN
+	xen_iommu_init();
+#endif
+
+	no_iommu_init();
+	return 0;
+}
+
 #ifdef CONFIG_PCI
 /* Many VIA bridges seem to corrupt data for DAC. Disable it here */
 
@@ -207,3 +218,5 @@ static int check_iommu(char *s)
 }
 __setup("iommu=", check_iommu);
 #endif
+/* Must execute after PCI subsystem */
+fs_initcall(pci_iommu_init);
diff --git a/arch/x86/kernel/pci-nommu_32.c b/arch/x86/kernel/pci-nommu_32.c
index 6a8e3ba..ed7f5af 100644
--- a/arch/x86/kernel/pci-nommu_32.c
+++ b/arch/x86/kernel/pci-nommu_32.c
@@ -66,7 +66,3 @@ int __init no_iommu_init(void)
 	dma_ops = &nommu_dma_ops;
 	return 0;
 }
-
-
-/* Must execute after PCI subsystem */
-fs_initcall(no_iommu_init);
diff --git a/arch/x86/kernel/pci-xen.c b/arch/x86/kernel/pci-xen.c
new file mode 100644
index 0000000..6967a33
--- /dev/null
+++ b/arch/x86/kernel/pci-xen.c
@@ -0,0 +1,162 @@
+#include <linux/mm.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/string.h>
+#include <linux/dma-mapping.h>
+#include <linux/scatterlist.h>
+
+#include <asm/processor.h>
+#include <asm/dma.h>
+#include <asm/xen/hypervisor.h>
+
+#include <xen/page.h>
+
+#define IOMMU_BUG_ON(test)				\
+do {							\
+	if (unlikely(test)) {				\
+		printk(KERN_ALERT "Fatal DMA error! "	\
+		       "Please use 'swiotlb=force' "	\
+		       "once we implement it.\n");	\
+		BUG();					\
+	}						\
+} while (0)
+
+static inline int
+address_needs_mapping(struct device *hwdev, dma_addr_t addr)
+{
+	dma_addr_t mask = 0xffffffff;
+	/* If the device has a mask, use it, otherwise default to 32 bits */
+	if (hwdev && hwdev->dma_mask)
+		mask = *hwdev->dma_mask;
+	return (addr & ~mask) != 0;
+}
+
+static int
+range_straddles_page_boundary(struct page *page, unsigned int offset, 
+			      size_t size)
+{
+	unsigned long pfn;
+	xpaddr_t phys;
+	extern unsigned long *contiguous_bitmap;
+	extern unsigned long max_low_pfn;
+	
+	phys = XPADDR(page_to_phys(page));
+	if (((phys.paddr & ~PAGE_MASK) + size) <= PAGE_SIZE)
+		return 0;
+
+	pfn = page_to_pfn(page);
+	if (pfn < max_low_pfn && test_bit(pfn, contiguous_bitmap))
+		return 0;
+
+	printk(KERN_WARNING "DMA range crosses page boundary: "
+	       "0x%016Lx+0x%04x\n", phys.paddr, size);
+	return 1;
+}
+
+static inline dma_addr_t xen_dma_map_page(struct page *page)
+{
+	/* Xen TODO: 2.6.18 xen calls __gnttab_dma_map_page here to deal
+	 * with foreign pages.  We'll need similar logic here at some
+	 * point. */
+	return ((dma_addr_t)pfn_to_mfn(page_to_pfn(page))) << PAGE_SHIFT;
+}
+
+static inline void xen_dma_unmap_page(dma_addr_t p)
+{
+	/* Xen TODO: 2.6.18 xen calls __gnttab_dma_unmap_page_page here
+	 * to deal with foreign pages.  We'll need similar logic here at
+	 * some point. */
+}
+
+static dma_addr_t
+xen_map_single(struct device *dev, void *ptr, size_t size,
+	       enum dma_data_direction direction)
+{
+	dma_addr_t dma;
+	struct page *page = virt_to_page(ptr);
+	xpaddr_t phys = XPADDR(virt_to_phys(ptr));
+	
+	BUG_ON(ptr == NULL);
+	WARN_ON(size == 0);
+
+	flush_write_buffers();
+
+	dma = xen_dma_map_page(page) + offset_in_page(ptr);
+	IOMMU_BUG_ON(range_straddles_page_boundary(
+		     page, phys.paddr & ~PAGE_MASK, size));
+	IOMMU_BUG_ON(address_needs_mapping(dev, dma));
+
+	return dma;
+}
+
+static void xen_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
+			enum dma_data_direction direction)
+{
+	xen_dma_unmap_page(addr);
+}
+
+static int xen_map_sg(struct device *dev, struct scatterlist *sg,
+	       int nents, enum dma_data_direction direction)
+{
+	struct scatterlist *s;
+	int i;
+
+	if (direction == DMA_NONE)
+		BUG();
+
+	for_each_sg(sg, s, nents, i) {
+		struct page *page = sg_page(s);
+		
+		BUG_ON(!page);
+
+		/* Xen TODO: Why does 2.6.18 xen also set s->dma_length
+		 * here?  And do we still need to? */
+		
+		s->dma_address = xen_dma_map_page(page) + s->offset;
+
+		IOMMU_BUG_ON(address_needs_mapping(
+			     dev, s->dma_address));
+		IOMMU_BUG_ON(range_straddles_page_boundary(
+			     page, s->offset, s->length));
+	}
+
+	flush_write_buffers();
+	return nents;
+}
+
+static void xen_unmap_sg(struct device *dev, struct scatterlist *sg,
+		  int nents, enum dma_data_direction direction)
+{
+	struct scatterlist *s;
+	int i;
+
+	if (direction == DMA_NONE)
+		BUG();
+
+	for_each_sg(sg, s, nents, i)
+		xen_dma_unmap_page(s->dma_address);
+}
+
+
+const struct dma_mapping_ops xen_dma_ops = {
+	.map_single = xen_map_single,
+	.unmap_single = xen_unmap_single,
+	.map_sg = xen_map_sg,
+	.unmap_sg = xen_unmap_sg,
+	/* Xen TODO: Is this right even if we have no swiotlb
+	 * installed? */
+	.is_phys = 0,
+};
+
+int __init xen_iommu_init(void)
+{
+	if (!is_running_on_xen())
+		return 0;
+	if (!is_initial_xendomain())
+		return 0;
+	
+	BUG_ON(dma_ops);
+	dma_ops = &xen_dma_ops;
+	printk(KERN_INFO "Installed Xen dma mapping ops (no swiotlb)\n");
+	return 0;
+}
diff --git a/include/asm-x86/iommu.h b/include/asm-x86/iommu.h
index 07862fd..9f8a9ef 100644
--- a/include/asm-x86/iommu.h
+++ b/include/asm-x86/iommu.h
@@ -1,29 +1,5 @@
-#ifndef _ASM_X8664_GART_H
-#define _ASM_X8664_GART_H 1
-
-extern void pci_iommu_shutdown(void);
-extern void no_iommu_init(void);
-extern int force_iommu, no_iommu;
-extern int iommu_detected;
-#ifdef CONFIG_IOMMU
-extern void gart_iommu_init(void);
-extern void gart_iommu_shutdown(void);
-extern void __init gart_parse_options(char *);
-extern void iommu_hole_init(void);
-extern int fallback_aper_order;
-extern int fallback_aper_force;
-extern int iommu_aperture;
-extern int iommu_aperture_allowed;
-extern int iommu_aperture_disabled;
-extern int fix_aperture;
+#ifdef CONFIG_X86_32
+# include "iommu_32.h"
 #else
-#define iommu_aperture 0
-#define iommu_aperture_allowed 0
-
-static inline void gart_iommu_shutdown(void)
-{
-}
-
-#endif
-
+# include "iommu_64.h"
 #endif
diff --git a/include/asm-x86/iommu_32.h b/include/asm-x86/iommu_32.h
new file mode 100644
index 0000000..4bc3e8a
--- /dev/null
+++ b/include/asm-x86/iommu_32.h
@@ -0,0 +1,9 @@
+#ifndef _ASM_X86_IOMMU_H
+#define _ASM_X86_IOMMU_H 1
+
+extern void no_iommu_init(void);
+#ifdef CONFIG_XEN
+extern void xen_iommu_init(void);
+#endif
+
+#endif
diff --git a/include/asm-x86/iommu_64.h b/include/asm-x86/iommu_64.h
new file mode 100644
index 0000000..07862fd
--- /dev/null
+++ b/include/asm-x86/iommu_64.h
@@ -0,0 +1,29 @@
+#ifndef _ASM_X8664_GART_H
+#define _ASM_X8664_GART_H 1
+
+extern void pci_iommu_shutdown(void);
+extern void no_iommu_init(void);
+extern int force_iommu, no_iommu;
+extern int iommu_detected;
+#ifdef CONFIG_IOMMU
+extern void gart_iommu_init(void);
+extern void gart_iommu_shutdown(void);
+extern void __init gart_parse_options(char *);
+extern void iommu_hole_init(void);
+extern int fallback_aper_order;
+extern int fallback_aper_force;
+extern int iommu_aperture;
+extern int iommu_aperture_allowed;
+extern int iommu_aperture_disabled;
+extern int fix_aperture;
+#else
+#define iommu_aperture 0
+#define iommu_aperture_allowed 0
+
+static inline void gart_iommu_shutdown(void)
+{
+}
+
+#endif
+
+#endif
-- 
1.5.4.2


linux-2.6-xen-0047-xen-dma-Add-calls-to-dma_ops-alloc-free_coherent-ho.patch:

--- NEW FILE linux-2.6-xen-0047-xen-dma-Add-calls-to-dma_ops-alloc-free_coherent-ho.patch ---
>From c378d6774fcc1fe1cb4a641dead8b98061df224f Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Wed, 30 Jan 2008 21:53:48 +0000
Subject: [PATCH] xen dma: Add calls to dma_ops alloc/free_coherent hooks.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/kernel/pci-dma_32.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/pci-dma_32.c b/arch/x86/kernel/pci-dma_32.c
index 6df2e1a..b983dc0 100644
--- a/arch/x86/kernel/pci-dma_32.c
+++ b/arch/x86/kernel/pci-dma_32.c
@@ -48,6 +48,9 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
 	if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
 		gfp |= GFP_DMA;
 
+	if (dma_ops->alloc_coherent)
+		return dma_ops->alloc_coherent(dev, size, dma_handle, gfp);
+
 	ret = (void *)__get_free_pages(gfp, order);
 
 	if (ret != NULL) {
@@ -69,8 +72,12 @@ void dma_free_coherent(struct device *dev, size_t size,
 		int page = (vaddr - mem->virt_base) >> PAGE_SHIFT;
 
 		bitmap_release_region(mem->bitmap, page, order);
-	} else
-		free_pages((unsigned long)vaddr, order);
+	} else {
+		if (dma_ops->free_coherent)
+			dma_ops->free_coherent(dev, size, vaddr, dma_handle);
+		else
+			free_pages((unsigned long)vaddr, order);
+	}
 }
 EXPORT_SYMBOL(dma_free_coherent);
 
-- 
1.5.4.2


linux-2.6-xen-0048-xen-dma-Add-xen_alloc-free_coherent.patch:

--- NEW FILE linux-2.6-xen-0048-xen-dma-Add-xen_alloc-free_coherent.patch ---
>From 399c5c21b453a7d17752bdae0329c9d68e362a4e Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Thu, 31 Jan 2008 11:49:04 +0000
Subject: [PATCH] xen dma: Add xen_alloc/free_coherent

Add dma_ops-based xen-specific dma_alloc/free_coherent functions,
using the xen contiguous region calls to obtain DMA-capable
memory.

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

diff --git a/arch/x86/kernel/pci-xen.c b/arch/x86/kernel/pci-xen.c
index 6967a33..2f92422 100644
--- a/arch/x86/kernel/pci-xen.c
+++ b/arch/x86/kernel/pci-xen.c
@@ -137,8 +137,50 @@ static void xen_unmap_sg(struct device *dev, struct scatterlist *sg,
 		xen_dma_unmap_page(s->dma_address);
 }
 
+static void *xen_alloc_coherent(struct device *dev, size_t size,
+				dma_addr_t *dma_handle, gfp_t gfp)
+{
+	unsigned int order = get_order(size);
+	unsigned long vstart;
+	dma_addr_t mask;
+	void *ret;
+	
+	vstart = __get_free_pages(gfp, order);
+	ret = (void *)vstart;
+
+	if (ret == NULL)
+		return NULL;
+	
+	if (dev != NULL && dev->coherent_dma_mask)
+		mask = dev->coherent_dma_mask;
+	else
+		mask = 0xffffffff;
+
+	if (xen_create_contiguous_region(vstart, order,
+					 fls64(mask)) != 0) {
+		free_pages(vstart, order);
+		return NULL;
+	}
+
+	memset(ret, 0, size);
+	*dma_handle = virt_to_machine(ret).maddr;
+
+	return ret;
+}
+
+static void xen_free_coherent(struct device *dev, size_t size,
+			      void *vaddr, dma_addr_t dma_handle)
+{
+	int order = get_order(size);
+
+	xen_destroy_contiguous_region((unsigned long)vaddr, order);
+	free_pages((unsigned long)vaddr, order);
+}
+
 
 const struct dma_mapping_ops xen_dma_ops = {
+	.alloc_coherent = xen_alloc_coherent,
+	.free_coherent = xen_free_coherent,
 	.map_single = xen_map_single,
 	.unmap_single = xen_unmap_single,
 	.map_sg = xen_map_sg,
-- 
1.5.4.2


linux-2.6-xen-0049-xen-dma-Don-t-merge-bios-on-xen-pvops.patch:

--- NEW FILE linux-2.6-xen-0049-xen-dma-Don-t-merge-bios-on-xen-pvops.patch ---
>From ea0f29bbc707c69e693aa3a9166da036d14dfb2c Mon Sep 17 00:00:00 2001
From: Stephen Tweedie <sct at redhat.com>
Date: Fri, 1 Feb 2008 18:04:53 +0000
Subject: [PATCH] xen dma: Don't merge bios on xen pvops.

On Xen, pages which are pseudophysically contiguous may not be
machine-contiguous.  So the normal bio rules for merging adjacent
bios do not apply.  And if Xen is running with no swiotlb, then
it has no mechanism for unpicking such merged bio segments.

Add a switch to turn of such merging, so that pvops xen can prevent
it.

We add the switch in the form of a simple extern variable, in
order to prevent the whole paravirt-ops infrastructure from being
pulled into io.h.

We might consider changing this to have an arch-supplied bio merge
function, so that xen can determine whether any two bios are in
fact machine-contiguous.

Signed-off-by: Stephen Tweedie <sct at redhat.com>
---
 arch/x86/kernel/pci-dma_32.c |    9 +++++++++
 arch/x86/kernel/pci-xen.c    |    1 +
 include/asm-x86/io_32.h      |   12 ++++++++++++
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/pci-dma_32.c b/arch/x86/kernel/pci-dma_32.c
index b983dc0..ce05946 100644
--- a/arch/x86/kernel/pci-dma_32.c
+++ b/arch/x86/kernel/pci-dma_32.c
@@ -15,6 +15,15 @@
 #include <asm/io.h>
 #include <asm/iommu.h>
 
+/*
+ * Determine whether the bio layer is permitted to merge sg entries 
+ * across physically-contiguous pages.
+ *
+ * True unless a specific dma driver tells us otherwise.
+ */
+int __biovec_phys_mergeable = 1;
+EXPORT_SYMBOL(__biovec_phys_mergeable);
+
 struct dma_coherent_mem {
 	void		*virt_base;
 	u32		device_base;
diff --git a/arch/x86/kernel/pci-xen.c b/arch/x86/kernel/pci-xen.c
index 2f92422..73f27d4 100644
--- a/arch/x86/kernel/pci-xen.c
+++ b/arch/x86/kernel/pci-xen.c
@@ -199,6 +199,7 @@ int __init xen_iommu_init(void)
 	
 	BUG_ON(dma_ops);
 	dma_ops = &xen_dma_ops;
+	__biovec_phys_mergeable = 0;
 	printk(KERN_INFO "Installed Xen dma mapping ops (no swiotlb)\n");
 	return 0;
 }
diff --git a/include/asm-x86/io_32.h b/include/asm-x86/io_32.h
index e2b916e..6344856 100644
--- a/include/asm-x86/io_32.h
+++ b/include/asm-x86/io_32.h
@@ -95,6 +95,18 @@ static inline void * phys_to_virt(unsigned long address)
 	return __va(address);
 }
 
+struct bio_vec;
+
+/*
+ * Allow for paravirt drivers to determine physical bio mergeability for
+ * themselves, as virtualised environments may not necessary allow for
+ * dma across contiguous pfns.
+ */
+extern int __biovec_phys_mergeable;
+#define BIOVEC_PHYS_MERGEABLE(vec1, vec2)	\
+	(((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2))) && \
+	 (__biovec_phys_mergeable != 0))
+
 /*
  * Change "struct page" to physical address.
  */
-- 
1.5.4.2


linux-2.6-xen-0050-xen-dom0-Minor-coding-style-issue-in-ISA-mapping-co.patch:

--- NEW FILE linux-2.6-xen-0050-xen-dom0-Minor-coding-style-issue-in-ISA-mapping-co.patch ---
>From 27b850f951af2eb4aa97e8db8b3f3f8e4175441c Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Fri, 1 Feb 2008 10:15:18 +0000
Subject: [PATCH] xen dom0: Minor coding style issue in ISA mapping code

Signed-off-by: Mark McLoughlin <markmc 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 a11607a..5719b8f 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -873,7 +873,7 @@ static __init void xen_pagetable_setup_done(pgd_t *base)
 		 * If we're dom0, then 1:1 map the ISA machine addresses
 		 * into the kernel's address space.
 		 */
-		for(i = ISA_START_ADDRESS; i < ISA_END_ADDRESS; i += PAGE_SIZE)
+		for (i = ISA_START_ADDRESS; i < ISA_END_ADDRESS; i += PAGE_SIZE)
 			set_pte_mfn(PAGE_OFFSET + i, PFN_DOWN(i), PAGE_KERNEL);
 
 		reserve_bootmem(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS);
-- 
1.5.4.2


linux-2.6-xen-0051-xen-dom0-Use-i-PAGE_SHIFT-instead-of-PAGE_DOWN-i.patch:

--- NEW FILE linux-2.6-xen-0051-xen-dom0-Use-i-PAGE_SHIFT-instead-of-PAGE_DOWN-i.patch ---
>From db439542c5ff9f912e61e7420f2c072ae80bd8ee Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Fri, 1 Feb 2008 10:17:05 +0000
Subject: [PATCH] xen dom0: Use i >> PAGE_SHIFT instead of PAGE_DOWN(i)

It's the same thing, but when dealing with page aligned
addresses, it looks like it's more usual to not use
the macro. Also, it's a tiny bit more obvious what's
going on.

Signed-off-by: Mark McLoughlin <markmc 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 5719b8f..363a4f5 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -874,7 +874,7 @@ static __init void xen_pagetable_setup_done(pgd_t *base)
 		 * into the kernel's address space.
 		 */
 		for (i = ISA_START_ADDRESS; i < ISA_END_ADDRESS; i += PAGE_SIZE)
-			set_pte_mfn(PAGE_OFFSET + i, PFN_DOWN(i), PAGE_KERNEL);
+			set_pte_mfn(PAGE_OFFSET + i, i >> PAGE_SHIFT, PAGE_KERNEL);
 
 		reserve_bootmem(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS);
 		printk(KERN_INFO "Xen: setup ISA identity maps\n");
-- 
1.5.4.2


linux-2.6-xen-0052-xen-dom0-Match-up-set_pte_mfn-prototype-with-the.patch:

--- NEW FILE linux-2.6-xen-0052-xen-dom0-Match-up-set_pte_mfn-prototype-with-the.patch ---
>From 9a2e987c49c2907fd32aa49b6c3ef02abef3e189 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Fri, 1 Feb 2008 10:19:02 +0000
Subject: [PATCH] xen dom0: Match up set_pte_mfn() prototype with the impl

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/xen/mmu.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/mmu.h b/arch/x86/xen/mmu.h
index 8594c92..34b1757 100644
--- a/arch/x86/xen/mmu.h
+++ b/arch/x86/xen/mmu.h
@@ -16,7 +16,7 @@
 #define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
 
 
-void set_pte_mfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags);
+void set_pte_mfn(unsigned long vaddr, unsigned long mfn, 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,
-- 
1.5.4.2


linux-2.6-xen-0053-xen-dom0-Reserve-ISA-address-space-earlier.patch:

--- NEW FILE linux-2.6-xen-0053-xen-dom0-Reserve-ISA-address-space-earlier.patch ---
>From b5ccee984ae104a390623e1b7caf0502c488316d Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Fri, 1 Feb 2008 15:08:26 +0000
Subject: [PATCH] xen dom0: Reserve ISA address space earlier

Reserve the ISA address space earlier so as to prevent
pmd/pte pages from being allocated there. Otherwise
we run the risk of some page tables being blown away
later when we remap that region.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/xen/enlighten.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 363a4f5..0866c20 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -794,6 +794,13 @@ static __init void xen_pagetable_setup_start(pgd_t *base)
 	 */
 	memcpy(base, xen_pgd, PTRS_PER_PGD * sizeof(pgd_t));
 
+	/*
+	 * If we're dom0, then reserve the ISA address space
+	 * so that pmd/pte pages don't get allocated there.
+	 */
+	if (is_initial_xendomain())
+		reserve_bootmem(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS);
+
 	if (PTRS_PER_PMD > 1) {
 		int i;
 		/*
@@ -876,7 +883,6 @@ static __init void xen_pagetable_setup_done(pgd_t *base)
 		for (i = ISA_START_ADDRESS; i < ISA_END_ADDRESS; i += PAGE_SIZE)
 			set_pte_mfn(PAGE_OFFSET + i, i >> PAGE_SHIFT, PAGE_KERNEL);
 
-		reserve_bootmem(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS);
 		printk(KERN_INFO "Xen: setup ISA identity maps\n");
 
 		/*
-- 
1.5.4.2


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

--- NEW FILE linux-2.6-xen-0054-xen-Add-empty-xenctrl-module.patch ---
>From db5a74a12204baa30dde29449d21e6b39b7923ce 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         |   11 +++++++
 drivers/xen/Makefile         |    2 +
 drivers/xen/xenctrl/Makefile |    4 +++
 drivers/xen/xenctrl/main.c   |   62 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 79 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 fbfa55c..7f01d14 100644
--- a/arch/x86/xen/Kconfig
+++ b/arch/x86/xen/Kconfig
@@ -10,3 +10,14 @@ 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 m if XEN
+	help
+	  This is the /proc/xen and /dev/evtchn interfaces used by
+	  Xen's libxc and xenstored.
+
+	  Enable this if you wish to use this kernel to boot a
+	  privileged (i.e. Dom0) Xen guest.
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.2


linux-2.6-xen-0055-xen-dom0-Add-proc-xen-capabilities.patch:

--- NEW FILE linux-2.6-xen-0055-xen-dom0-Add-proc-xen-capabilities.patch ---
>From f1a5bf7d4214dc41d73923d6611e6a4c02069668 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 dom0: 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      |   37 +++++++++++++++++++
 4 files changed, 117 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..66443fb
--- /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 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 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..e90e588
--- /dev/null
+++ b/drivers/xen/xenctrl/xenctrl.h
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * 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.
+ */
+
+/*
+ * capabilities.c
+ */
+int capabilities_create_proc_entry(void);
+void capabilities_remove_proc_entry(void);
-- 
1.5.4.2


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

--- NEW FILE linux-2.6-xen-0056-xen-Add-proc-xen-privcmd.patch ---
>From 40595817e26b1683c52a7ce32741c234628e5d42 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   |   88 +++++++++++++++++++++++++++++++++++++++
 drivers/xen/xenctrl/xenctrl.h   |    6 +++
 include/asm-x86/xen/hypercall.h |   28 ++++++++++++
 include/xen/sys/privcmd.h       |   79 +++++++++++++++++++++++++++++++++++
 6 files changed, 208 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..1746a17
--- /dev/null
+++ b/drivers/xen/xenctrl/privcmd.c
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * 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)
+{
+	int ret = -ENOSYS;
+
+	switch (cmd) {
+	case IOCTL_PRIVCMD_HYPERCALL: {
+		privcmd_hypercall_t hypercall;
+  
+		if (copy_from_user(&hypercall, (void __user *)arg,
+				   sizeof(hypercall)))
+			return -EFAULT;
+
+		ret = privcmd_hypercall(&hypercall);
+		break;
+	}
+
+	case IOCTL_PRIVCMD_MMAP:
+	case IOCTL_PRIVCMD_MMAPBATCH:
+		printk(KERN_WARNING "IOCTL_PRIVCMD_MMAP ioctl not yet implemented\n");
+	default:
+		ret = -EINVAL;
+		break;
+	}
+
+	return ret;
+}
+
+static const struct file_operations privcmd_file_ops = {
+	.unlocked_ioctl = privcmd_ioctl,
+};
+
+int 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 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 e90e588..e88ada5 100644
--- a/drivers/xen/xenctrl/xenctrl.h
+++ b/drivers/xen/xenctrl/xenctrl.h
@@ -35,3 +35,9 @@
  */
 int capabilities_create_proc_entry(void);
 void capabilities_remove_proc_entry(void);
+
+/*
+ * privcmd.c
+ */
+int privcmd_create_proc_entry(void);
+void privcmd_remove_proc_entry(void);
diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
index 0802755..47b61f8 100644
--- a/include/asm-x86/xen/hypercall.h
+++ b/include/asm-x86/xen/hypercall.h
@@ -419,4 +419,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.2


linux-2.6-xen-0057-xen-dom0-Add-proc-xen-xsd_-port-kva.patch:

--- NEW FILE linux-2.6-xen-0057-xen-dom0-Add-proc-xen-xsd_-port-kva.patch ---
>From 438d932b47881bc861926c22988d1fa0e4ba58f6 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Mon, 4 Feb 2008 10:29:28 +0000
Subject: [PATCH] xen dom0: Add /proc/xen/xsd_{port,kva}

These two /proc interfaces allows xenstored to make
itself available to the Dom0 kernel by mapping the
"interface" page, and connecting to the event
channel, allocated by the kernel.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 drivers/xen/xenbus/xenbus_comms.h |    2 -
 drivers/xen/xenbus/xenbus_probe.c |    5 +-
 drivers/xen/xenctrl/Makefile      |    1 +
 drivers/xen/xenctrl/main.c        |    6 ++
 drivers/xen/xenctrl/xenctrl.h     |    6 ++
 drivers/xen/xenctrl/xenstore.c    |  118 +++++++++++++++++++++++++++++++++++++
 include/xen/xenbus.h              |    4 +
 7 files changed, 139 insertions(+), 3 deletions(-)
 create mode 100644 drivers/xen/xenctrl/xenstore.c

diff --git a/drivers/xen/xenbus/xenbus_comms.h b/drivers/xen/xenbus/xenbus_comms.h
index c21db75..cb5324f 100644
--- a/drivers/xen/xenbus/xenbus_comms.h
+++ b/drivers/xen/xenbus/xenbus_comms.h
@@ -40,7 +40,5 @@ int xb_read(void *data, unsigned len);
 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 c096f69..94e36f3 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -56,8 +56,11 @@
 #include "xenbus_probe.h"
 
 int xen_store_evtchn;
+EXPORT_SYMBOL_GPL(xen_store_evtchn);
+unsigned long xen_store_mfn;
+EXPORT_SYMBOL_GPL(xen_store_mfn);
 struct xenstore_domain_interface *xen_store_interface;
-static unsigned long xen_store_mfn;
+EXPORT_SYMBOL_GPL(xen_store_interface);
 
 static BLOCKING_NOTIFIER_HEAD(xenstore_chain);
 
diff --git a/drivers/xen/xenctrl/Makefile b/drivers/xen/xenctrl/Makefile
index 8a706cb..4416174 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 += xenstore.o
diff --git a/drivers/xen/xenctrl/main.c b/drivers/xen/xenctrl/main.c
index d1fe6ef..2ebf85a 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 = xsd_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)
 {
+	xsd_remove_proc_entry();
 	privcmd_remove_proc_entry();
 	capabilities_remove_proc_entry();
 	remove_proc_entry("xen", NULL);
diff --git a/drivers/xen/xenctrl/xenctrl.h b/drivers/xen/xenctrl/xenctrl.h
index e88ada5..0e8f8cf 100644
--- a/drivers/xen/xenctrl/xenctrl.h
+++ b/drivers/xen/xenctrl/xenctrl.h
@@ -41,3 +41,9 @@ void capabilities_remove_proc_entry(void);
  */
 int privcmd_create_proc_entry(void);
 void privcmd_remove_proc_entry(void);
+
+/*
+ * xenstore.c
+ */
+int xsd_create_proc_entry(void);
+void xsd_remove_proc_entry(void);
diff --git a/drivers/xen/xenctrl/xenstore.c b/drivers/xen/xenctrl/xenstore.c
new file mode 100644
index 0000000..4b38ff5
--- /dev/null
+++ b/drivers/xen/xenctrl/xenstore.c
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * xenstore.c
+ *
+ * /proc/xen/xsd_{port,kva}
+ *
+ * Copyright (C) 2005 Rusty Russell, IBM Corporation
+ * Copyright (C) 2005 Mike Wray, Hewlett-Packard
+ * Copyright (C) 2005, 2006 XenSource Ltd
+ * Copyright (C) 2007 Solarflare Communications, Inc.
+ * 
+ * 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/seq_file.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <asm/xen/hypervisor.h>
+#include <xen/page.h>
+#include <xen/xenbus.h>
+
+static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	size_t size = vma->vm_end - vma->vm_start;
+
+	if ((size > PAGE_SIZE) || (vma->vm_pgoff != 0))
+		return -EINVAL;
+
+	if (remap_pfn_range(vma, vma->vm_start, mfn_to_pfn(xen_store_mfn),
+			    size, vma->vm_page_prot))
+		return -EAGAIN;
+
+	return 0;
+}
+
+static int xsd_kva_show(struct seq_file *m, void *v)
+{
+	seq_printf(m, "0x%p\n", xen_store_interface);
+	return 0;
+}
+
+static int xsd_kva_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, xsd_kva_show, NULL);
+}
+
+static const struct file_operations xsd_kva_fops = {
+	.open		= xsd_kva_open,
+	.mmap		= xsd_kva_mmap,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static int xsd_port_read(char *page, char **start, off_t off,
+			 int count, int *eof, void *data)
+{
+	int len;
+
+	len  = sprintf(page, "%d\n", xen_store_evtchn);
+	*eof = 1;
+	return len;
+}
+
+int xsd_create_proc_entry(void)
+{
+	struct proc_dir_entry *entry;
+
+	if (!is_initial_xendomain())
+		return 0;
+
+	entry = create_proc_entry("xen/xsd_kva", 0600, NULL);
+	if (!entry)
+		return -ENOMEM;
+
+	entry->owner = THIS_MODULE;
+	entry->proc_fops = &xsd_kva_fops;
+
+	entry = create_proc_entry("xen/xsd_port", 0400, NULL);
+	if (!entry)
+		goto fail;
+
+	entry->owner = THIS_MODULE;
+	entry->read_proc = xsd_port_read;
+
+	return 0;
+
+ fail:  remove_proc_entry("xen/xsd_kva", NULL);
+	return - ENOMEM;
+}
+
+void xsd_remove_proc_entry(void)
+{
+	remove_proc_entry("xen/xsd_port", NULL);
+	remove_proc_entry("xen/xsd_kva", NULL);
+}
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h
index 6f7c290..40e0083 100644
--- a/include/xen/xenbus.h
+++ b/include/xen/xenbus.h
@@ -231,4 +231,8 @@ 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;
+extern unsigned long xen_store_mfn;
+extern struct xenstore_domain_interface *xen_store_interface;
+
 #endif /* _XEN_XENBUS_H */
-- 
1.5.4.2


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

--- NEW FILE linux-2.6-xen-0058-xen-Add-proc-xen-xenbus.patch ---
>From 1fb0cf23ef60c29951fd1387781a7cc09b8789cd 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_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 +
 5 files changed, 412 insertions(+), 0 deletions(-)
 create mode 100644 drivers/xen/xenctrl/xenbus.c

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 4416174..959b0eb 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 += xenstore.o
+xenctrl-objs += xenbus.o
diff --git a/drivers/xen/xenctrl/main.c b/drivers/xen/xenctrl/main.c
index 2ebf85a..95e1b3b 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 = xenbus_create_proc_entry();
+	if (ret)
+		goto fail4;
+
 	return 0;
 
+ fail4: xsd_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)
 {
+	xenbus_remove_proc_entry();
 	xsd_remove_proc_entry();
 	privcmd_remove_proc_entry();
 	capabilities_remove_proc_entry();
diff --git a/drivers/xen/xenctrl/xenbus.c b/drivers/xen/xenctrl/xenbus.c
new file mode 100644
index 0000000..8127dc8
--- /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 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 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 0e8f8cf..5990be5 100644
--- a/drivers/xen/xenctrl/xenctrl.h
+++ b/drivers/xen/xenctrl/xenctrl.h
@@ -47,3 +47,9 @@ void privcmd_remove_proc_entry(void);
  */
 int xsd_create_proc_entry(void);
 void xsd_remove_proc_entry(void);
+
+/*
+ * xenbus.c
+ */
+int xenbus_create_proc_entry(void);
+void xenbus_remove_proc_entry(void);
-- 
1.5.4.2


linux-2.6-xen-0059-xen-Add-dev-xen-evtchn.patch:

--- NEW FILE linux-2.6-xen-0059-xen-Add-dev-xen-evtchn.patch ---
>From a45207a87b146129944fa96605c00458a0bb2b6d Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Mon, 4 Feb 2008 08:25:31 +0000
Subject: [PATCH] xen: Add /dev/xen/evtchn

This device driver allows userspace programs to allocate
event channels, bind to existing channels, poll for
pending events etc.

An additional kernel interface is provided to allow the
driver to register a handler for event upcalls.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/xen/events.c         |   31 ++-
 drivers/xen/xenctrl/Makefile  |    1 +
 drivers/xen/xenctrl/evtchn.c  |  552 +++++++++++++++++++++++++++++++++++++++++
 drivers/xen/xenctrl/main.c    |    6 +
 drivers/xen/xenctrl/xenctrl.h |    6 +
 include/xen/events.h          |   11 +
 include/xen/sys/evtchn.h      |   88 +++++++
 7 files changed, 691 insertions(+), 4 deletions(-)
 create mode 100644 drivers/xen/xenctrl/evtchn.c
 create mode 100644 include/xen/sys/evtchn.h

diff --git a/arch/x86/xen/events.c b/arch/x86/xen/events.c
index ca4912e..abce636 100644
--- a/arch/x86/xen/events.c
+++ b/arch/x86/xen/events.c
@@ -169,11 +169,12 @@ static inline unsigned int cpu_from_evtchn(unsigned int evtchn)
 	return cpu_evtchn[evtchn];
 }
 
-static inline void clear_evtchn(int port)
+void clear_evtchn(int port)
 {
 	struct shared_info *s = HYPERVISOR_shared_info;
 	sync_clear_bit(port, &s->evtchn_pending[0]);
 }
+EXPORT_SYMBOL_GPL(clear_evtchn);
 
 static inline void set_evtchn(int port)
 {
@@ -199,13 +200,14 @@ void notify_remote_via_irq(int irq)
 }
 EXPORT_SYMBOL_GPL(notify_remote_via_irq);
 
-static void mask_evtchn(int port)
+void mask_evtchn(int port)
 {
 	struct shared_info *s = HYPERVISOR_shared_info;
 	sync_set_bit(port, &s->evtchn_mask[0]);
 }
+EXPORT_SYMBOL_GPL(mask_evtchn);
 
-static void unmask_evtchn(int port)
+void unmask_evtchn(int port)
 {
 	struct shared_info *s = HYPERVISOR_shared_info;
 	unsigned int cpu = get_cpu();
@@ -234,6 +236,7 @@ static void unmask_evtchn(int port)
 
 	put_cpu();
 }
+EXPORT_SYMBOL_GPL(unmask_evtchn);
 
 static int find_unbound_irq(void)
 {
@@ -463,6 +466,22 @@ void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector)
 	notify_remote_via_irq(irq);
 }
 
+/*
+ * Notifier list for event channels not bound to an irq
+ */
+static ATOMIC_NOTIFIER_HEAD(evtchn_upcall_notifier);
+
+int register_evtchn_upcall_notifier(struct notifier_block *n)
+{
+	return atomic_notifier_chain_register(&evtchn_upcall_notifier, n);
+}
+EXPORT_SYMBOL(register_evtchn_upcall_notifier);
+
+int unregister_evtchn_upcall_notifier(struct notifier_block *n)
+{
+	return atomic_notifier_chain_unregister(&evtchn_upcall_notifier, n);
+}
+EXPORT_SYMBOL(unregister_evtchn_upcall_notifier);
 
 /*
  * Search the CPUs pending events bitmasks.  For each one found, map
@@ -503,6 +522,9 @@ fastcall void xen_evtchn_do_upcall(struct pt_regs *regs)
 			if (irq != -1) {
 				regs->orig_eax = ~irq;
 				do_IRQ(regs);
+			} else {
+				atomic_notifier_call_chain(&evtchn_upcall_notifier,
+							   port, NULL);
 			}
 		}
 	}
@@ -515,7 +537,7 @@ fastcall void xen_evtchn_do_upcall(struct pt_regs *regs)
 }
 
 /* Rebind an evtchn so that it gets delivered to a specific cpu */
-static void rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
+void rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
 {
 	struct evtchn_bind_vcpu bind_vcpu;
 	int evtchn = evtchn_from_irq(irq);
@@ -535,6 +557,7 @@ static void rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
 	if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0)
 		bind_evtchn_to_cpu(evtchn, tcpu);
 }
+EXPORT_SYMBOL_GPL(rebind_irq_to_cpu);
 
 
 static void set_affinity_irq(unsigned irq, cpumask_t dest)
diff --git a/drivers/xen/xenctrl/Makefile b/drivers/xen/xenctrl/Makefile
index 959b0eb..efc12c2 100644
--- a/drivers/xen/xenctrl/Makefile
+++ b/drivers/xen/xenctrl/Makefile
@@ -6,3 +6,4 @@ xenctrl-objs += capabilities.o
 xenctrl-objs += privcmd.o
 xenctrl-objs += xenstore.o
 xenctrl-objs += xenbus.o
+xenctrl-objs += evtchn.o
diff --git a/drivers/xen/xenctrl/evtchn.c b/drivers/xen/xenctrl/evtchn.c
new file mode 100644
index 0000000..22fabe2
--- /dev/null
+++ b/drivers/xen/xenctrl/evtchn.c
@@ -0,0 +1,552 @@
+/******************************************************************************
+ * evtchn.c
+ * 
+ * Driver for receiving and demuxing event-channel signals.
+ * 
+ * Copyright (c) 2004-2005, K A Fraser
+ * Multi-process extensions Copyright (c) 2004, Steven Smith
+ * 
+ * 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/fs.h>
+#include <linux/uaccess.h>
+#include <linux/poll.h>
+#include <linux/module.h>
+#include <linux/miscdevice.h>
+#include <linux/cpu.h>
+#include <asm/xen/hypervisor.h>
+#include <xen/events.h>
+#include <xen/sys/evtchn.h>
+
+struct per_user_data {
+	/* Notification ring, accessed via /dev/xen/evtchn. */
+#define EVTCHN_RING_SIZE     (PAGE_SIZE / sizeof(evtchn_port_t))
+#define EVTCHN_RING_MASK(_i) ((_i)&(EVTCHN_RING_SIZE-1))
+	evtchn_port_t *ring;
+	unsigned int ring_cons, ring_prod, ring_overflow;
+	struct mutex ring_cons_mutex; /* protect against concurrent readers */
+
+	/* Processes wait on this queue when ring is empty. */
+	wait_queue_head_t evtchn_wait;
+	struct fasync_struct *evtchn_async_queue;
+
+	int bind_cpu;
+	int nr_event_wrong_delivery;
+};
+
+/* Who's bound to each port? */
+static struct per_user_data *port_user[NR_EVENT_CHANNELS];
+static spinlock_t port_user_lock;
+
+static int evtchn_upcall_callback(struct notifier_block *nb,
+				  unsigned long port, void *v)
+{
+	struct per_user_data *u;
+	int ret = NOTIFY_OK;
+
+	spin_lock(&port_user_lock);
+
+	if (!(u = port_user[port]))
+		goto out;
+
+	ret = NOTIFY_STOP;
+
+	mask_evtchn(port);
+	clear_evtchn(port);
+
+	if ((u->ring_prod - u->ring_cons) >= EVTCHN_RING_SIZE) {
+		u->ring_overflow = 1;
+		goto out;
+	}
+
+	u->ring[EVTCHN_RING_MASK(u->ring_prod)] = port;
+	if (u->ring_cons != u->ring_prod++)
+		goto out;
+
+	wake_up_interruptible(&u->evtchn_wait);
+	kill_fasync(&u->evtchn_async_queue, SIGIO, POLL_IN);
+ out:
+	spin_unlock(&port_user_lock);
+	return ret;
+}
+
+static struct notifier_block evtchn_upcall_nfb = {
+        .notifier_call = evtchn_upcall_callback
+};
+
+static void evtchn_check_wrong_delivery(struct per_user_data *u)
+{
+	evtchn_port_t port;
+	unsigned int current_cpu = smp_processor_id();
+
+	/* Delivered to correct CPU? All is good. */
+	if (u->bind_cpu == current_cpu) {
+		u->nr_event_wrong_delivery = 0;
+		return;
+	}
+
+	/* Tolerate up to 100 consecutive misdeliveries. */
+	if (++u->nr_event_wrong_delivery < 100)
+		return;
+
+	spin_lock_irq(&port_user_lock);
+
+	for (port = 0; port < NR_EVENT_CHANNELS; port++)
+		if (port_user[port] == u)
+			rebind_irq_to_cpu(port, current_cpu);
+
+	u->bind_cpu = current_cpu;
+	u->nr_event_wrong_delivery = 0;
+
+	spin_unlock_irq(&port_user_lock);
+}
+
+static ssize_t evtchn_read(struct file *file, char __user *buf,
+			   size_t count, loff_t *ppos)
+{
+	int rc;
+	unsigned int c, p, bytes1 = 0, bytes2 = 0;
+	struct per_user_data *u = file->private_data;
+
+	/* Whole number of ports. */
+	count &= ~(sizeof(evtchn_port_t)-1);
+
+	if (count == 0)
+		return 0;
+
+	if (count > PAGE_SIZE)
+		count = PAGE_SIZE;
+
+	for (;;) {
+		mutex_lock(&u->ring_cons_mutex);
+
+		rc = -EFBIG;
+		if (u->ring_overflow)
+			goto unlock_out;
+
+		if ((c = u->ring_cons) != (p = u->ring_prod))
+			break;
+
+		mutex_unlock(&u->ring_cons_mutex);
+
+		if (file->f_flags & O_NONBLOCK)
+			return -EAGAIN;
+
+		rc = wait_event_interruptible(
+			u->evtchn_wait, u->ring_cons != u->ring_prod);
+		if (rc)
+			return rc;
+	}
+
+	/* Byte lengths of two chunks. Chunk split (if any) is at ring wrap. */
+	if (((c ^ p) & EVTCHN_RING_SIZE) != 0) {
+		bytes1 = (EVTCHN_RING_SIZE - EVTCHN_RING_MASK(c)) *
+			sizeof(evtchn_port_t);
+		bytes2 = EVTCHN_RING_MASK(p) * sizeof(evtchn_port_t);
+	} else {
+		bytes1 = (p - c) * sizeof(evtchn_port_t);
+		bytes2 = 0;
+	}
+
+	/* Truncate chunks according to caller's maximum byte count. */
+	if (bytes1 > count) {
+		bytes1 = count;
+		bytes2 = 0;
+	} else if ((bytes1 + bytes2) > count) {
+		bytes2 = count - bytes1;
+	}
+
+	rc = -EFAULT;
+	if (copy_to_user(buf, &u->ring[EVTCHN_RING_MASK(c)], bytes1) ||
+	    ((bytes2 != 0) &&
+	     copy_to_user(&buf[bytes1], &u->ring[0], bytes2)))
+		goto unlock_out;
+	
+	evtchn_check_wrong_delivery(u);
+
+	u->ring_cons += (bytes1 + bytes2) / sizeof(evtchn_port_t);
+	rc = bytes1 + bytes2;
+
+ unlock_out:
+	mutex_unlock(&u->ring_cons_mutex);
+	return rc;
+}
+
+static ssize_t evtchn_write(struct file *file, const char __user *buf,
+			    size_t count, loff_t *ppos)
+{
+	int rc, i;
+	evtchn_port_t *kbuf = (evtchn_port_t *)__get_free_page(GFP_KERNEL);
+	struct per_user_data *u = file->private_data;
+
+	if (kbuf == NULL)
+		return -ENOMEM;
+
+	/* Whole number of ports. */
+	count &= ~(sizeof(evtchn_port_t)-1);
+
+	rc = 0;
+	if (count == 0)
+		goto out;
+
+	if (count > PAGE_SIZE)
+		count = PAGE_SIZE;
+
+	rc = -EFAULT;
+	if (copy_from_user(kbuf, buf, count) != 0)
+		goto out;
+
+	spin_lock_irq(&port_user_lock);
+	for (i = 0; i < (count/sizeof(evtchn_port_t)); i++)
+		if ((kbuf[i] < NR_EVENT_CHANNELS) && (port_user[kbuf[i]] == u))
+			unmask_evtchn(kbuf[i]);
+	spin_unlock_irq(&port_user_lock);
+
+	rc = count;
+
+ out:
+	free_page((unsigned long)kbuf);
+	return rc;
+}
+
+static unsigned int next_bind_cpu(cpumask_t map)
+{
+	static unsigned int bind_cpu;
+	bind_cpu = next_cpu(bind_cpu, map);
+	if (bind_cpu >= NR_CPUS)
+		bind_cpu = first_cpu(map);
+	return bind_cpu;
+}
+
+static void evtchn_bind_to_user(struct per_user_data *u, int port)
+{
+	spin_lock_irq(&port_user_lock);
+
+	BUG_ON(port_user[port] != NULL);
+	port_user[port] = u;
+
+	if (u->bind_cpu == -1)
+		u->bind_cpu = next_bind_cpu(cpu_online_map);
+
+	rebind_irq_to_cpu(port, u->bind_cpu);
+
+	unmask_evtchn(port);
+
+	spin_unlock_irq(&port_user_lock);
+}
+
+static long evtchn_ioctl(struct file *file,
+			 unsigned int cmd, unsigned long arg)
+{
+	int rc;
+	struct per_user_data *u = file->private_data;
+	void __user *uarg = (void __user *) arg;
+
+	switch (cmd) {
+	case IOCTL_EVTCHN_BIND_VIRQ: {
+		struct ioctl_evtchn_bind_virq bind;
+		struct evtchn_bind_virq bind_virq;
+
+		rc = -EFAULT;
+		if (copy_from_user(&bind, uarg, sizeof(bind)))
+			break;
+
+		bind_virq.virq = bind.virq;
+		bind_virq.vcpu = 0;
+		rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
+						 &bind_virq);
+		if (rc != 0)
+			break;
+
+		rc = bind_virq.port;
+		evtchn_bind_to_user(u, rc);
+		break;
+	}
+
+	case IOCTL_EVTCHN_BIND_INTERDOMAIN: {
+		struct ioctl_evtchn_bind_interdomain bind;
+		struct evtchn_bind_interdomain bind_interdomain;
+
+		rc = -EFAULT;
+		if (copy_from_user(&bind, uarg, sizeof(bind)))
+			break;
+
+		bind_interdomain.remote_dom  = bind.remote_domain;
+		bind_interdomain.remote_port = bind.remote_port;
+		rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
+						 &bind_interdomain);
+		if (rc != 0)
+			break;
+
+		rc = bind_interdomain.local_port;
+		evtchn_bind_to_user(u, rc);
+		break;
+	}
+
+	case IOCTL_EVTCHN_BIND_UNBOUND_PORT: {
+		struct ioctl_evtchn_bind_unbound_port bind;
+		struct evtchn_alloc_unbound alloc_unbound;
+
+		rc = -EFAULT;
+		if (copy_from_user(&bind, uarg, sizeof(bind)))
+			break;
+
+		alloc_unbound.dom        = DOMID_SELF;
+		alloc_unbound.remote_dom = bind.remote_domain;
+		rc = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
+						 &alloc_unbound);
+		if (rc != 0)
+			break;
+
+		rc = alloc_unbound.port;
+		evtchn_bind_to_user(u, rc);
+		break;
+	}
+
+	case IOCTL_EVTCHN_UNBIND: {
+		struct ioctl_evtchn_unbind unbind;
+		struct evtchn_close close;
+		int ret;
+
+		rc = -EFAULT;
+		if (copy_from_user(&unbind, uarg, sizeof(unbind)))
+			break;
+
+		rc = -EINVAL;
+		if (unbind.port >= NR_EVENT_CHANNELS)
+			break;
+
+		spin_lock_irq(&port_user_lock);
+    
+		rc = -ENOTCONN;
+		if (port_user[unbind.port] != u) {
+			spin_unlock_irq(&port_user_lock);
+			break;
+		}
+
+		port_user[unbind.port] = NULL;
+		mask_evtchn(unbind.port);
+
+		spin_unlock_irq(&port_user_lock);
+
+		close.port = unbind.port;
+		ret = HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
+		BUG_ON(ret);
+
+		rc = 0;
+		break;
+	}
+
+	case IOCTL_EVTCHN_NOTIFY: {
+		struct ioctl_evtchn_notify notify;
+
+		rc = -EFAULT;
+		if (copy_from_user(&notify, uarg, sizeof(notify)))
+			break;
+
+		if (notify.port >= NR_EVENT_CHANNELS) {
+			rc = -EINVAL;
+		} else if (port_user[notify.port] != u) {
+			rc = -ENOTCONN;
+		} else {
+			notify_remote_via_evtchn(notify.port);
+			rc = 0;
+		}
+		break;
+	}
+
+	case IOCTL_EVTCHN_RESET: {
+		/* Initialise the ring to empty. Clear errors. */
+		mutex_lock(&u->ring_cons_mutex);
+		spin_lock_irq(&port_user_lock);
+		u->ring_cons = u->ring_prod = u->ring_overflow = 0;
+		spin_unlock_irq(&port_user_lock);
+		mutex_unlock(&u->ring_cons_mutex);
+		rc = 0;
+		break;
+	}
+
+	default:
+		rc = -ENOSYS;
+		break;
+	}
+
+	return rc;
+}
+
+static unsigned int evtchn_poll(struct file *file, poll_table *wait)
+{
+	unsigned int mask = POLLOUT | POLLWRNORM;
+	struct per_user_data *u = file->private_data;
+
+	poll_wait(file, &u->evtchn_wait, wait);
+	if (u->ring_cons != u->ring_prod)
+		mask |= POLLIN | POLLRDNORM;
+	if (u->ring_overflow)
+		mask = POLLERR;
+	return mask;
+}
+
+static int evtchn_fasync(int fd, struct file *filp, int on)
+{
+	struct per_user_data *u = filp->private_data;
+	return fasync_helper(fd, filp, on, &u->evtchn_async_queue);
+}
+
+static int evtchn_open(struct inode *inode, struct file *filp)
+{
+	struct per_user_data *u;
+
+	if ((u = kmalloc(sizeof(*u), GFP_KERNEL)) == NULL)
+		return -ENOMEM;
+
+	memset(u, 0, sizeof(*u));
+	init_waitqueue_head(&u->evtchn_wait);
+
+	u->ring = (evtchn_port_t *)__get_free_page(GFP_KERNEL);
+	if (u->ring == NULL) {
+		kfree(u);
+		return -ENOMEM;
+	}
+
+	mutex_init(&u->ring_cons_mutex);
+
+	filp->private_data = u;
+
+	u->bind_cpu = -1;
+
+	return 0;
+}
+
+static int evtchn_release(struct inode *inode, struct file *filp)
+{
+	int i;
+	struct per_user_data *u = filp->private_data;
+	struct evtchn_close close;
+
+	spin_lock_irq(&port_user_lock);
+
+	free_page((unsigned long)u->ring);
+
+	for (i = 0; i < NR_EVENT_CHANNELS; i++) {
+		int ret;
+		if (port_user[i] != u)
+			continue;
+
+		port_user[i] = NULL;
+		mask_evtchn(i);
+
+		close.port = i;
+		ret = HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
+		BUG_ON(ret);
+	}
+
+	spin_unlock_irq(&port_user_lock);
+
+	kfree(u);
+
+	return 0;
+}
+
+static const struct file_operations evtchn_fops = {
+	.owner   = THIS_MODULE,
+	.read    = evtchn_read,
+	.write   = evtchn_write,
+	.unlocked_ioctl = evtchn_ioctl,
+	.poll    = evtchn_poll,
+	.fasync  = evtchn_fasync,
+	.open    = evtchn_open,
+	.release = evtchn_release,
+};
+
+static struct miscdevice evtchn_miscdev = {
+	.minor        = MISC_DYNAMIC_MINOR,
+	.name         = "evtchn",
+	.fops         = &evtchn_fops,
+};
+
+static int __cpuinit evtchn_cpu_notify(struct notifier_block *nfb,
+			unsigned long action, void *hcpu)
+{
+	int hotcpu = (unsigned long)hcpu;
+	cpumask_t map = cpu_online_map;
+	int port, newcpu;
+	struct per_user_data *u;
+
+	switch (action) {
+	case CPU_DOWN_PREPARE:
+		cpu_clear(hotcpu, map);
+		spin_lock_irq(&port_user_lock);
+		for (port = 0; port < NR_EVENT_CHANNELS; port++) {
+			if ((u = port_user[port]) != NULL && 
+			    u->bind_cpu == hotcpu &&
+			    (newcpu = next_bind_cpu(map)) < NR_CPUS) {
+				rebind_irq_to_cpu(port, newcpu);
+				u->bind_cpu = newcpu;
+			}
+		}
+		spin_unlock_irq(&port_user_lock);
+		break;
+	default:
+		return NOTIFY_DONE;
+	}
+	return NOTIFY_OK;
+}
+
+static struct notifier_block __cpuinitdata evtchn_cpu_nfb = {
+	.notifier_call = evtchn_cpu_notify
+};
+
+int evtchn_init(void)
+{
+	int err;
+
+	spin_lock_init(&port_user_lock);
+	memset(port_user, 0, sizeof(port_user));
+
+	register_evtchn_upcall_notifier(&evtchn_upcall_nfb);
+	register_cpu_notifier(&evtchn_cpu_nfb);
+
+	err = misc_register(&evtchn_miscdev);
+	if (err != 0) {
+		printk(KERN_ALERT "Could not register /dev/xen/evtchn\n");
+		goto fail;
+	}
+
+	return 0;
+
+ fail:
+	unregister_cpu_notifier(&evtchn_cpu_nfb);
+	unregister_evtchn_upcall_notifier(&evtchn_upcall_nfb);
+	return err;
+}
+
+void evtchn_exit(void)
+{
+	misc_deregister(&evtchn_miscdev);
+	unregister_cpu_notifier(&evtchn_cpu_nfb);
+	unregister_evtchn_upcall_notifier(&evtchn_upcall_nfb);
+}
diff --git a/drivers/xen/xenctrl/main.c b/drivers/xen/xenctrl/main.c
index 95e1b3b..a2d5ca3 100644
--- a/drivers/xen/xenctrl/main.c
+++ b/drivers/xen/xenctrl/main.c
@@ -67,8 +67,13 @@ static int __init xenctrl_init(void)
 	if (ret)
 		goto fail4;
 
+	ret = evtchn_init();
+	if (ret)
+		goto fail5;
+
 	return 0;
 
+ fail5: xenbus_remove_proc_entry();
  fail4: xsd_remove_proc_entry();
  fail3: privcmd_remove_proc_entry();
  fail2: capabilities_remove_proc_entry();
@@ -78,6 +83,7 @@ static int __init xenctrl_init(void)
 
 static void __exit xenctrl_exit(void)
 {
+	evtchn_exit();
 	xenbus_remove_proc_entry();
 	xsd_remove_proc_entry();
 	privcmd_remove_proc_entry();
diff --git a/drivers/xen/xenctrl/xenctrl.h b/drivers/xen/xenctrl/xenctrl.h
index 5990be5..63117bd 100644
--- a/drivers/xen/xenctrl/xenctrl.h
+++ b/drivers/xen/xenctrl/xenctrl.h
@@ -53,3 +53,9 @@ void xsd_remove_proc_entry(void);
  */
 int xenbus_create_proc_entry(void);
 void xenbus_remove_proc_entry(void);
+
+/*
+ * evtchn.c
+ */
+int evtchn_init(void);
+void evtchn_exit(void);
diff --git a/include/xen/events.h b/include/xen/events.h
index 0436486..7b3ee9e 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -2,6 +2,7 @@
 #define _XEN_EVENTS_H
 
 #include <linux/interrupt.h>
+#include <linux/notifier.h>
 
 #include <xen/interface/event_channel.h>
 #include <asm/xen/hypercall.h>
@@ -38,6 +39,12 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
  */
 void unbind_from_irqhandler(unsigned int irq, void *dev_id);
 
+void mask_evtchn(int port);
+void unmask_evtchn(int port);
+void clear_evtchn(int port);
+
+void rebind_irq_to_cpu(unsigned irq, unsigned tcpu);
+
 void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector);
 
 static inline void notify_remote_via_evtchn(int port)
@@ -47,4 +54,8 @@ static inline void notify_remote_via_evtchn(int port)
 }
 
 extern void notify_remote_via_irq(int irq);
+
+int register_evtchn_upcall_notifier(struct notifier_block *n);
+int unregister_evtchn_upcall_notifier(struct notifier_block *n);
+
 #endif	/* _XEN_EVENTS_H */
diff --git a/include/xen/sys/evtchn.h b/include/xen/sys/evtchn.h
new file mode 100644
index 0000000..938d4da
--- /dev/null
+++ b/include/xen/sys/evtchn.h
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * evtchn.h
+ * 
+ * Interface to /dev/xen/evtchn.
+ * 
+ * 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_EVTCHN_H__
+#define __LINUX_PUBLIC_EVTCHN_H__
+
+/*
+ * Bind a fresh port to VIRQ @virq.
+ * Return allocated port.
+ */
+#define IOCTL_EVTCHN_BIND_VIRQ				\
+	_IOC(_IOC_NONE, 'E', 0, sizeof(struct ioctl_evtchn_bind_virq))
+struct ioctl_evtchn_bind_virq {
+	unsigned int virq;
+};
+
+/*
+ * Bind a fresh port to remote <@remote_domain, @remote_port>.
+ * Return allocated port.
+ */
+#define IOCTL_EVTCHN_BIND_INTERDOMAIN			\
+	_IOC(_IOC_NONE, 'E', 1, sizeof(struct ioctl_evtchn_bind_interdomain))
+struct ioctl_evtchn_bind_interdomain {
+	unsigned int remote_domain, remote_port;
+};
+
+/*
+ * Allocate a fresh port for binding to @remote_domain.
+ * Return allocated port.
+ */
+#define IOCTL_EVTCHN_BIND_UNBOUND_PORT			\
+	_IOC(_IOC_NONE, 'E', 2, sizeof(struct ioctl_evtchn_bind_unbound_port))
+struct ioctl_evtchn_bind_unbound_port {
+	unsigned int remote_domain;
+};
+
+/*
+ * Unbind previously allocated @port.
+ */
+#define IOCTL_EVTCHN_UNBIND				\
+	_IOC(_IOC_NONE, 'E', 3, sizeof(struct ioctl_evtchn_unbind))
+struct ioctl_evtchn_unbind {
+	unsigned int port;
+};
+
+/*
+ * Unbind previously allocated @port.
+ */
+#define IOCTL_EVTCHN_NOTIFY				\
+	_IOC(_IOC_NONE, 'E', 4, sizeof(struct ioctl_evtchn_notify))
+struct ioctl_evtchn_notify {
+	unsigned int port;
+};
+
+/* Clear and reinitialise the event buffer. Clear error condition. */
+#define IOCTL_EVTCHN_RESET				\
+	_IOC(_IOC_NONE, 'E', 5, 0)
+
+#endif /* __LINUX_PUBLIC_EVTCHN_H__ */
-- 
1.5.4.2


linux-2.6-xen-0060-xen-Add-__init-__exit-notations-to-xenctrl-function.patch:

--- NEW FILE linux-2.6-xen-0060-xen-Add-__init-__exit-notations-to-xenctrl-function.patch ---
>From c4d55e6c69c13f2e6d94763019d24ea02f7ce1ea Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Thu, 7 Feb 2008 15:37:30 +0000
Subject: [PATCH] xen: Add __init/__exit notations to xenctrl function

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 drivers/xen/xenctrl/capabilities.c |    4 ++--
 drivers/xen/xenctrl/evtchn.c       |    4 ++--
 drivers/xen/xenctrl/privcmd.c      |    4 ++--
 drivers/xen/xenctrl/xenbus.c       |    4 ++--
 drivers/xen/xenctrl/xenctrl.h      |   22 ++++++++++++----------
 drivers/xen/xenctrl/xenstore.c     |    4 ++--
 6 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/xen/xenctrl/capabilities.c b/drivers/xen/xenctrl/capabilities.c
index 66443fb..1ff078a 100644
--- a/drivers/xen/xenctrl/capabilities.c
+++ b/drivers/xen/xenctrl/capabilities.c
@@ -48,7 +48,7 @@ static int capabilities_read(char *page, char **start, off_t off,
 	return len;
 }
 
-int capabilities_create_proc_entry(void)
+int __init capabilities_create_proc_entry(void)
 {
 	struct proc_dir_entry *entry;
 
@@ -62,7 +62,7 @@ int capabilities_create_proc_entry(void)
 	return 0;
 }
 
-void capabilities_remove_proc_entry(void)
+void __exit capabilities_remove_proc_entry(void)
 {
 	remove_proc_entry("xen/capabilities", NULL);
 }
diff --git a/drivers/xen/xenctrl/evtchn.c b/drivers/xen/xenctrl/evtchn.c
index 22fabe2..d894632 100644
--- a/drivers/xen/xenctrl/evtchn.c
+++ b/drivers/xen/xenctrl/evtchn.c
@@ -520,7 +520,7 @@ static struct notifier_block __cpuinitdata evtchn_cpu_nfb = {
 	.notifier_call = evtchn_cpu_notify
 };
 
-int evtchn_init(void)
+int __init evtchn_init(void)
 {
 	int err;
 
@@ -544,7 +544,7 @@ int evtchn_init(void)
 	return err;
 }
 
-void evtchn_exit(void)
+void __exit evtchn_exit(void)
 {
 	misc_deregister(&evtchn_miscdev);
 	unregister_cpu_notifier(&evtchn_cpu_nfb);
diff --git a/drivers/xen/xenctrl/privcmd.c b/drivers/xen/xenctrl/privcmd.c
index 1746a17..cf74948 100644
--- a/drivers/xen/xenctrl/privcmd.c
+++ b/drivers/xen/xenctrl/privcmd.c
@@ -68,7 +68,7 @@ static const struct file_operations privcmd_file_ops = {
 	.unlocked_ioctl = privcmd_ioctl,
 };
 
-int privcmd_create_proc_entry(void)
+int __init privcmd_create_proc_entry(void)
 {
 	static struct proc_dir_entry *entry;
 
@@ -82,7 +82,7 @@ int privcmd_create_proc_entry(void)
 	return 0;
 }
 
-void privcmd_remove_proc_entry(void)
+void __exit privcmd_remove_proc_entry(void)
 {
 	remove_proc_entry("xen/privcmd", NULL);
 }
diff --git a/drivers/xen/xenctrl/xenbus.c b/drivers/xen/xenctrl/xenbus.c
index 8127dc8..57d5501 100644
--- a/drivers/xen/xenctrl/xenbus.c
+++ b/drivers/xen/xenctrl/xenbus.c
@@ -378,7 +378,7 @@ static const struct file_operations xenbus_dev_file_ops = {
 	.poll = xenbus_dev_poll,
 };
 
-int xenbus_create_proc_entry(void)
+int __init xenbus_create_proc_entry(void)
 {
 	struct proc_dir_entry *entry;
 
@@ -392,7 +392,7 @@ int xenbus_create_proc_entry(void)
 	return 0;
 }
 
-void xenbus_remove_proc_entry(void)
+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 63117bd..9ca6b1f 100644
--- a/drivers/xen/xenctrl/xenctrl.h
+++ b/drivers/xen/xenctrl/xenctrl.h
@@ -30,32 +30,34 @@
  * IN THE SOFTWARE.
  */
 
+#include <linux/init.h>
+
 /*
  * capabilities.c
  */
-int capabilities_create_proc_entry(void);
-void capabilities_remove_proc_entry(void);
+int capabilities_create_proc_entry(void) __init;
+void capabilities_remove_proc_entry(void) __exit;
 
 /*
  * privcmd.c
  */
-int privcmd_create_proc_entry(void);
-void privcmd_remove_proc_entry(void);
+int privcmd_create_proc_entry(void) __init;
+void privcmd_remove_proc_entry(void) __exit;
 
 /*
  * xenstore.c
  */
-int xsd_create_proc_entry(void);
-void xsd_remove_proc_entry(void);
+int xsd_create_proc_entry(void) __init;
+void xsd_remove_proc_entry(void) __exit;
 
 /*
  * xenbus.c
  */
-int xenbus_create_proc_entry(void);
-void xenbus_remove_proc_entry(void);
+int xenbus_create_proc_entry(void) __init;
+void xenbus_remove_proc_entry(void) __exit;
 
 /*
  * evtchn.c
  */
-int evtchn_init(void);
-void evtchn_exit(void);
+int evtchn_init(void) __init;
+void evtchn_exit(void) __exit;
diff --git a/drivers/xen/xenctrl/xenstore.c b/drivers/xen/xenctrl/xenstore.c
index 4b38ff5..9b16e82 100644
--- a/drivers/xen/xenctrl/xenstore.c
+++ b/drivers/xen/xenctrl/xenstore.c
@@ -84,7 +84,7 @@ static int xsd_port_read(char *page, char **start, off_t off,
 	return len;
 }
 
-int xsd_create_proc_entry(void)
+int __init xsd_create_proc_entry(void)
 {
 	struct proc_dir_entry *entry;
 
@@ -111,7 +111,7 @@ int xsd_create_proc_entry(void)
 	return - ENOMEM;
 }
 
-void xsd_remove_proc_entry(void)
+void __exit xsd_remove_proc_entry(void)
 {
 	remove_proc_entry("xen/xsd_port", NULL);
 	remove_proc_entry("xen/xsd_kva", NULL);
-- 
1.5.4.2


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

--- NEW FILE linux-2.6-xen-0061-xen-Add-Xen-s-sys-hypervisor-interface.patch ---
>From 85917e55d3c4020d09ea4adfc0f310932e703637 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 7f01d14..f2974af 100644
--- a/arch/x86/xen/Kconfig
+++ b/arch/x86/xen/Kconfig
@@ -13,8 +13,9 @@ config XEN
 
 config XENCTRL
 	tristate "Xen's user space control interfaces"
-	depends on XEN && PROC_FS
+	depends on XEN && PROC_FS && SYSFS
 	default m if XEN
+	select SYS_HYPERVISOR
 	help
 	  This is the /proc/xen and /dev/evtchn interfaces used by
 	  Xen's libxc and xenstored.
diff --git a/drivers/xen/xenctrl/Makefile b/drivers/xen/xenctrl/Makefile
index efc12c2..b14836e 100644
--- a/drivers/xen/xenctrl/Makefile
+++ b/drivers/xen/xenctrl/Makefile
@@ -7,3 +7,4 @@ xenctrl-objs += privcmd.o
 xenctrl-objs += xenstore.o
 xenctrl-objs += xenbus.o
 xenctrl-objs += evtchn.o
+xenctrl-objs += sysfs.o
diff --git a/drivers/xen/xenctrl/main.c b/drivers/xen/xenctrl/main.c
index a2d5ca3..f6c715d 100644
--- a/drivers/xen/xenctrl/main.c
+++ b/drivers/xen/xenctrl/main.c
@@ -71,8 +71,13 @@ static int __init xenctrl_init(void)
 	if (ret)
 		goto fail5;
 
+	ret = sys_hypervisor_init();
+	if (ret)
+		goto fail6;
+
 	return 0;
 
+ fail6: sys_hypervisor_exit();
  fail5: xenbus_remove_proc_entry();
  fail4: xsd_remove_proc_entry();
  fail3: privcmd_remove_proc_entry();
@@ -83,6 +88,7 @@ static int __init xenctrl_init(void)
 
 static void __exit xenctrl_exit(void)
 {
+	sys_hypervisor_exit();
 	evtchn_exit();
 	xenbus_remove_proc_entry();
 	xsd_remove_proc_entry();
diff --git a/drivers/xen/xenctrl/sysfs.c b/drivers/xen/xenctrl/sysfs.c
new file mode 100644
index 0000000..3b38aaf
--- /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 subsys_attribute _name##_attr = __ATTR_RO(_name)
+
+#define HYPERVISOR_ATTR_RW(_name) \
+static struct subsys_attribute _name##_attr = \
+	__ATTR(_name, 0644, _name##_show, _name##_store)
+
+static ssize_t type_show(struct kset *kset, char *buffer)
+{
+	return sprintf(buffer, "xen\n");
+}
+
+HYPERVISOR_ATTR_RO(type);
+
+static int __init xen_sysfs_type_init(void)
+{
+	return sysfs_create_file(&hypervisor_subsys.kobj, &type_attr.attr);
+}
+
+static void xen_sysfs_type_destroy(void)
+{
+	sysfs_remove_file(&hypervisor_subsys.kobj, &type_attr.attr);
+}
+
+static ssize_t major_show(struct kset *kset, 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 kset *kset, 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 kset *kset, 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_subsys.kobj, &version_group);
+}
+
+static void xen_sysfs_version_destroy(void)
+{
+	sysfs_remove_group(&hypervisor_subsys.kobj, &version_group);
+}
+
+static ssize_t uuid_show(struct kset *kset, 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_subsys.kobj, &uuid_attr.attr);
+}
+
+static void xen_sysfs_uuid_destroy(void)
+{
+	sysfs_remove_file(&hypervisor_subsys.kobj, &uuid_attr.attr);
+}
+
+static ssize_t compiler_show(struct kset *kset, 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 kset *kset, 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 kset *kset, 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_subsys.kobj,
+				  &xen_compilation_group);
+}
+
+static void xen_compilation_destroy(void)
+{
+	sysfs_remove_group(&hypervisor_subsys.kobj,
+			   &xen_compilation_group);
+}
+
+static ssize_t capabilities_show(struct kset *kset, 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 kset *kset, 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 kset *kset, 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 kset *kset, 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 kset *kset, 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_subsys.kobj,
+				  &xen_properties_group);
+}
+
+static void xen_properties_destroy(void)
+{
+	sysfs_remove_group(&hypervisor_subsys.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 9ca6b1f..5c6d899 100644
--- a/drivers/xen/xenctrl/xenctrl.h
+++ b/drivers/xen/xenctrl/xenctrl.h
@@ -61,3 +61,9 @@ void xenbus_remove_proc_entry(void) __exit;
  */
 int evtchn_init(void) __init;
 void evtchn_exit(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.2


linux-2.6-xen-0062-xen-dom0-Add-basic-proc-xen-balloon.patch:

--- NEW FILE linux-2.6-xen-0062-xen-dom0-Add-basic-proc-xen-balloon.patch ---
>From 088f8ea70761142657d817dbe99eda0a9c7cb4c7 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Thu, 7 Feb 2008 19:11:54 +0000
Subject: [PATCH] xen dom0: Add basic /proc/xen/balloon

Userspace querys Dom0's current memory allocation using
/proc/xen/balloon. This implements that basic functionality,
leaving out the rest of the fields usually reported by
this interface.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 drivers/xen/xenctrl/Makefile  |    1 +
 drivers/xen/xenctrl/balloon.c |   68 +++++++++++++++++++++++++++++++++++++++++
 drivers/xen/xenctrl/main.c    |   12 +++++--
 drivers/xen/xenctrl/xenctrl.h |    6 +++
 4 files changed, 84 insertions(+), 3 deletions(-)
 create mode 100644 drivers/xen/xenctrl/balloon.c

diff --git a/drivers/xen/xenctrl/Makefile b/drivers/xen/xenctrl/Makefile
index b14836e..823bb16 100644
--- a/drivers/xen/xenctrl/Makefile
+++ b/drivers/xen/xenctrl/Makefile
@@ -6,5 +6,6 @@ xenctrl-objs += capabilities.o
 xenctrl-objs += privcmd.o
 xenctrl-objs += xenstore.o
 xenctrl-objs += xenbus.o
+xenctrl-objs += balloon.o
 xenctrl-objs += evtchn.o
 xenctrl-objs += sysfs.o
diff --git a/drivers/xen/xenctrl/balloon.c b/drivers/xen/xenctrl/balloon.c
new file mode 100644
index 0000000..c8c1c13
--- /dev/null
+++ b/drivers/xen/xenctrl/balloon.c
@@ -0,0 +1,68 @@
+/******************************************************************************
+ *
+ * balloon.c
+ *
+ * /proc/xen/balloon
+ *
+ * Copyright (c) 2003, B Dragovic
+ * Copyright (c) 2003-2004, M Williamson, K Fraser
+ * Copyright (c) 2005 Dan M. Smith, 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/bootmem.h>
+#include <asm/xen/hypervisor.h>
+
+#define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10))
+
+static int balloon_read(char *page, char **start, off_t off,
+			int count, int *eof, void *data)
+{
+	*eof = 1;
+	return sprintf(page, "Current allocation: %8lu kB\n",
+		       PAGES2KB(xen_start_info->nr_pages));
+}
+
+int __init balloon_create_proc_entry(void)
+{
+	struct proc_dir_entry *entry;
+
+	entry = create_proc_entry("xen/balloon", 0644, NULL);
+	if (!entry)
+		return -ENOMEM;
+
+	entry->owner = THIS_MODULE;
+	entry->read_proc = balloon_read;
+
+	return 0;
+}
+
+void __exit balloon_remove_proc_entry(void)
+{
+	remove_proc_entry("xen/balloon", NULL);
+}
diff --git a/drivers/xen/xenctrl/main.c b/drivers/xen/xenctrl/main.c
index f6c715d..fe3e793 100644
--- a/drivers/xen/xenctrl/main.c
+++ b/drivers/xen/xenctrl/main.c
@@ -67,17 +67,22 @@ static int __init xenctrl_init(void)
 	if (ret)
 		goto fail4;
 
-	ret = evtchn_init();
+	ret = balloon_create_proc_entry();
 	if (ret)
 		goto fail5;
 
-	ret = sys_hypervisor_init();
+	ret = evtchn_init();
 	if (ret)
 		goto fail6;
 
+	ret = sys_hypervisor_init();
+	if (ret)
+		goto fail7;
+
 	return 0;
 
- fail6: sys_hypervisor_exit();
+ fail7: sys_hypervisor_exit();
+ fail6: balloon_remove_proc_entry();
  fail5: xenbus_remove_proc_entry();
  fail4: xsd_remove_proc_entry();
  fail3: privcmd_remove_proc_entry();
@@ -90,6 +95,7 @@ static void __exit xenctrl_exit(void)
 {
 	sys_hypervisor_exit();
 	evtchn_exit();
+	balloon_remove_proc_entry();
 	xenbus_remove_proc_entry();
 	xsd_remove_proc_entry();
 	privcmd_remove_proc_entry();
diff --git a/drivers/xen/xenctrl/xenctrl.h b/drivers/xen/xenctrl/xenctrl.h
index 5c6d899..105343f 100644
--- a/drivers/xen/xenctrl/xenctrl.h
+++ b/drivers/xen/xenctrl/xenctrl.h
@@ -57,6 +57,12 @@ int xenbus_create_proc_entry(void) __init;
 void xenbus_remove_proc_entry(void) __exit;
 
 /*
+ * balloon.c
+ */
+int balloon_create_proc_entry(void) __init;
+void balloon_remove_proc_entry(void) __exit;
+
+/*
  * evtchn.c
  */
 int evtchn_init(void) __init;
-- 
1.5.4.2


linux-2.6-xen-0063-xen-dom0-Re-work-privcmd_ioctl-a-little.patch:

--- NEW FILE linux-2.6-xen-0063-xen-dom0-Re-work-privcmd_ioctl-a-little.patch ---
>From 0cd0bb4891ba5e4dba8229752d9dd53119a45fd7 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Mon, 11 Feb 2008 11:23:54 +0000
Subject: [PATCH] xen dom0: Re-work privcmd_ioctl() a little

Re-organise the code in privcmd_ioctl() a little in
preparation for adding support for IOCTL_PRIVCMD_MMAP.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 drivers/xen/xenctrl/privcmd.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/xen/xenctrl/privcmd.c b/drivers/xen/xenctrl/privcmd.c
index cf74948..58c4b83 100644
--- a/drivers/xen/xenctrl/privcmd.c
+++ b/drivers/xen/xenctrl/privcmd.c
@@ -39,29 +39,22 @@
 static long privcmd_ioctl(struct file *file, unsigned int cmd,
 			  unsigned long arg)
 {
-	int ret = -ENOSYS;
-
 	switch (cmd) {
 	case IOCTL_PRIVCMD_HYPERCALL: {
-		privcmd_hypercall_t hypercall;
+		privcmd_hypercall_t cmd;
   
-		if (copy_from_user(&hypercall, (void __user *)arg,
-				   sizeof(hypercall)))
+		if (copy_from_user(&cmd, (void __user *)arg, sizeof(cmd)))
 			return -EFAULT;
 
-		ret = privcmd_hypercall(&hypercall);
-		break;
+		return privcmd_hypercall(&cmd);
 	}
 
 	case IOCTL_PRIVCMD_MMAP:
 	case IOCTL_PRIVCMD_MMAPBATCH:
 		printk(KERN_WARNING "IOCTL_PRIVCMD_MMAP ioctl not yet implemented\n");
 	default:
-		ret = -EINVAL;
-		break;
+		return -EINVAL;
 	}
-
-	return ret;
 }
 
 static const struct file_operations privcmd_file_ops = {
-- 
1.5.4.2


linux-2.6-xen-0064-xen-dom0-Add-IOCTL_PRIVCMD_MMAP.patch:

--- NEW FILE linux-2.6-xen-0064-xen-dom0-Add-IOCTL_PRIVCMD_MMAP.patch ---
>From a8c47f2dc1818de8fcb7f9add8446678456c9d56 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Thu, 7 Feb 2008 19:05:10 +0000
Subject: [PATCH] xen dom0: Add IOCTL_PRIVCMD_MMAP

IOCTL_PRIVCMD_MMAP is used by Dom0 userspace (via
libxc's xc_map_foreign_range() function) to map
pages from a foreign domain without requiring a
grant and without adding the page to Dom0's
p2m map.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/xen/ioremap.c           |   30 +++++++
 drivers/xen/xenctrl/privcmd.c    |  176 +++++++++++++++++++++++++++++++++++++-
 include/asm-x86/xen/hypervisor.h |    4 +
 3 files changed, 207 insertions(+), 3 deletions(-)

diff --git a/arch/x86/xen/ioremap.c b/arch/x86/xen/ioremap.c
index 70f77bd..e963ff9 100644
--- a/arch/x86/xen/ioremap.c
+++ b/arch/x86/xen/ioremap.c
@@ -145,3 +145,33 @@ int xen_ioremap_page_range(unsigned long addr, unsigned long end,
 	return rc;
 }
 
+int xen_map_foreign_range(struct vm_area_struct *vma, unsigned long addr,
+			  unsigned long mfn, unsigned long size,
+			  pgprot_t prot, domid_t domid)
+{
+	if (xen_feature(XENFEAT_auto_translated_physmap))
+		return remap_pfn_range(vma, addr, mfn, size, prot);
+
+	if (domid == DOMID_SELF)
+		return -EINVAL;
+
+	vma->vm_flags |= VM_IO | VM_RESERVED;
+
+#if 0
+	/* FIXME:
+	 * has_foreign_mappings is needed to avoid a race
+	 * condition whereby pages are freed by the unpin
+	 * in arch_exit_mmap() and then allocated to the
+	 * domain before the PTE is destroyed, leading to
+	 * an erroneous reference count update. See:
+	 * 
+	 * http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00014.html
+	 * http://xenbits.xensource.com/xen-unstable.hg?rev/e351aace191e
+	 */
+	vma->vm_mm->context.has_foreign_mappings = 1;
+#endif
+
+	return __direct_remap_pfn_range(vma->vm_mm, addr, mfn,
+					size, prot, domid);
+}
+EXPORT_SYMBOL(xen_map_foreign_range);
diff --git a/drivers/xen/xenctrl/privcmd.c b/drivers/xen/xenctrl/privcmd.c
index 58c4b83..5622e87 100644
--- a/drivers/xen/xenctrl/privcmd.c
+++ b/drivers/xen/xenctrl/privcmd.c
@@ -33,8 +33,156 @@
 #include <linux/proc_fs.h>
 #include <linux/module.h>
 #include <linux/uaccess.h>
+#include <linux/mm.h>
 #include <asm/xen/hypervisor.h>
 #include <xen/sys/privcmd.h>
+#include <xen/features.h>
+
+static struct page *privcmd_nopage(struct vm_area_struct *vma,
+				   unsigned long address, int *type)
+{
+	return NOPAGE_SIGBUS;
+}
+
+static struct vm_operations_struct privcmd_vm_ops = {
+	.nopage = privcmd_nopage
+};
+
+static int privcmd_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	/* Unsupported for auto-translate guests. */
+	if (xen_feature(XENFEAT_auto_translated_physmap))
+		return -ENOSYS;
+
+	/* FIXME:
+	 * the VM_PFNMAP here may be dubious. See:
+	 *
+	 *   http://lists.xensource.com/archives/html/xen-devel/2007-12/msg00207.html
+	 *
+	 * Note, in recent kernels it is also needed to
+	 * avoid the mapping being dropped to VM_PRIVATE
+	 * by vma_wants_writenotify()
+	 */
+
+	/* DONTCOPY is essential for Xen as copy_page_range is broken. */
+	vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY | VM_PFNMAP;
+	vma->vm_ops = &privcmd_vm_ops;
+	vma->vm_private_data = NULL;
+
+	return 0;
+}
+
+static struct vm_area_struct *
+privcmd_verify_mapping(struct mm_struct *mm, unsigned long addr)
+{
+	struct vm_area_struct *vma;
+
+	vma = find_vma(mm, addr);
+	if (!vma || vma->vm_start != addr)
+		return NULL;
+
+	/* Disallow multiple mappings */
+	return xchg(&vma->vm_private_data, (void *)1) ? NULL : vma;
+}
+
+static int privcmd_mmap_cmd(privcmd_mmap_t *cmd)
+{
+	struct mm_struct *mm = current->mm;
+	struct vm_area_struct *vma;
+	privcmd_mmap_entry_t __user *p;
+	unsigned long va;
+	int i, ret = 0;
+
+	down_write(&mm->mmap_sem);
+
+	for (i = 0, p = cmd->entry, vma = NULL; i < cmd->num; i++, p++) {
+		privcmd_mmap_entry_t entry;
+		unsigned long end;
+
+		if (copy_from_user(&entry, p, sizeof(entry))) {
+			ret = -EFAULT;
+			break;
+		}
+
+		ret = -EINVAL;
+
+		if (!vma) {
+			vma = privcmd_verify_mapping(mm, entry.va);
+			if (!vma)
+				break;
+			va = vma->vm_start;
+		}
+
+		/* Do not allow range to wrap the address space. */
+		if (entry.npages > (LONG_MAX >> PAGE_SHIFT) ||
+		    (unsigned long)(entry.npages << PAGE_SHIFT) >= -va)
+			break;
+
+		end = entry.va + (entry.npages << PAGE_SHIFT);
+
+		/* Range chunks must be contiguous in va space. */
+		if (entry.va != va || end > vma->vm_end)
+			break;
+
+		ret = xen_map_foreign_range(vma,
+					    entry.va & PAGE_MASK,
+					    entry.mfn,
+					    entry.npages << PAGE_SHIFT,
+					    vma->vm_page_prot,
+					    cmd->dom);
+		if (ret < 0)
+			break;
+
+		va = end;
+	}
+
+	up_write(&mm->mmap_sem);
+
+	return ret;
+}
+
+static int privcmd_mmap_batch_cmd(privcmd_mmapbatch_t *cmd)
+{
+	struct mm_struct *mm = current->mm;
+	struct vm_area_struct *vma;
+	int i;
+
+	if (cmd->num <= 0 || cmd->num > (LONG_MAX >> PAGE_SHIFT))
+		return -EINVAL;
+
+	down_write(&mm->mmap_sem);
+
+	vma = privcmd_verify_mapping(mm, cmd->addr);
+	if (!vma ||
+	    cmd->addr + (cmd->num << PAGE_SHIFT) != vma->vm_end) {
+		up_write(&mm->mmap_sem);
+		return -EINVAL;
+	}
+
+	for (i = 0; i < cmd->num; i++) {
+		unsigned long __user *p;
+		unsigned long addr, mfn;
+		int ret;
+
+		p = cmd->arr + i;
+
+		if (get_user(mfn, p)) {
+			up_write(&mm->mmap_sem);
+			return -EFAULT;
+		}
+
+		addr = (cmd->addr & PAGE_MASK) + (i << PAGE_SHIFT);
+
+		ret = xen_map_foreign_range(vma, addr, mfn, PAGE_SIZE,
+					    vma->vm_page_prot, cmd->dom);
+		if (ret < 0)
+			put_user(0xF0000000 | mfn, p);
+	}
+
+	up_write(&mm->mmap_sem);
+
+	return 0;
+}
 
 static long privcmd_ioctl(struct file *file, unsigned int cmd,
 			  unsigned long arg)
@@ -49,9 +197,30 @@ static long privcmd_ioctl(struct file *file, unsigned int cmd,
 		return privcmd_hypercall(&cmd);
 	}
 
-	case IOCTL_PRIVCMD_MMAP:
-	case IOCTL_PRIVCMD_MMAPBATCH:
-		printk(KERN_WARNING "IOCTL_PRIVCMD_MMAP ioctl not yet implemented\n");
+	case IOCTL_PRIVCMD_MMAP: {
+		privcmd_mmap_t cmd;
+
+		if (!is_initial_xendomain())
+			return -EPERM;
+
+		if (copy_from_user(&cmd, (void __user *)arg, sizeof(cmd)))
+			return -EFAULT;
+
+		return privcmd_mmap_cmd(&cmd);
+	}
+
+	case IOCTL_PRIVCMD_MMAPBATCH: {
+		privcmd_mmapbatch_t cmd;
+
+		if (!is_initial_xendomain())
+			return -EPERM;
+
+		if (copy_from_user(&cmd, (void __user *)arg, sizeof(cmd)))
+			return -EFAULT;
+
+		return privcmd_mmap_batch_cmd(&cmd);
+	}
+
 	default:
 		return -EINVAL;
 	}
@@ -59,6 +228,7 @@ static long privcmd_ioctl(struct file *file, unsigned int cmd,
 
 static const struct file_operations privcmd_file_ops = {
 	.unlocked_ioctl = privcmd_ioctl,
+	.mmap = privcmd_mmap,
 };
 
 int __init privcmd_create_proc_entry(void)
diff --git a/include/asm-x86/xen/hypervisor.h b/include/asm-x86/xen/hypervisor.h
index 8e15dd2..a266f4f 100644
--- a/include/asm-x86/xen/hypervisor.h
+++ b/include/asm-x86/xen/hypervisor.h
@@ -70,4 +70,8 @@ u64 jiffies_to_st(unsigned long jiffies);
 
 #define is_running_on_xen()	(xen_start_info ? 1 : 0)
 
+int xen_map_foreign_range(struct vm_area_struct *vma, unsigned long addr,
+			  unsigned long mfn, unsigned long size,
+			  pgprot_t prot, domid_t domid);
+
 #endif /* __HYPERVISOR_H__ */
-- 
1.5.4.2


linux-2.6-xen-0065-xen-dom0-Add-a-vmlinuz-target.patch:

--- NEW FILE linux-2.6-xen-0065-xen-dom0-Add-a-vmlinuz-target.patch ---
>From 578e490d7760993e9a20633e1770b04d7a10ab61 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 dom0: 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 Dom0.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 arch/x86/Makefile_32   |    9 +++++++++
 arch/x86/boot/Makefile |    9 +++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Makefile_32 b/arch/x86/Makefile_32
index 625090d..0865b07 100644
--- a/arch/x86/Makefile_32
+++ b/arch/x86/Makefile_32
@@ -130,6 +130,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
+
 all: bzImage
 
 # KBUILD_IMAGE specify target image being built
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index 7a3116c..6f1b455 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 apm.o cmdline.o copy.o cpu.o cpucheck.o edd.o
@@ -97,6 +98,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.2



Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/kernel.spec,v
retrieving revision 1.11.2.7
retrieving revision 1.11.2.8
diff -u -r1.11.2.7 -r1.11.2.8
--- kernel.spec	21 Feb 2008 13:20:14 -0000	1.11.2.7
+++ kernel.spec	22 Feb 2008 13:35:30 -0000	1.11.2.8
@@ -694,66 +694,68 @@
 Patch5001: linux-2.6-xen-0002-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch
 Patch5002: linux-2.6-xen-0003-fbdev-Make-deferred-I-O-work-as-advertized.patch
 Patch5003: linux-2.6-xen-0004-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch
-Patch5004: linux-2.6-xen-0005-Add-compatibility-aliases-for-Xen-block-network-fron.patch
-Patch5005: linux-2.6-xen-0006-xen-dom0-Make-hvc_xen-console-work-for-dom0.patch
-Patch5006: linux-2.6-xen-0007-xen-dom0-Initialize-xenbus-for-dom0.patch
-Patch5007: linux-2.6-xen-0008-xen-dom0-Set-up-basic-IO-permissions-for-dom0.patch
-Patch5008: linux-2.6-xen-0009-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch
-Patch5009: linux-2.6-xen-0010-xen-dom0-Add-support-for-the-platform_ops-hypercall.patch
-Patch5010: linux-2.6-xen-0011-xen-acpi-Enable-early-access-to-ACPI-tables.patch
-Patch5011: linux-2.6-xen-0012-xen-dom0-Add-paravirt_ops-ioremap_page_range-for.patch
-Patch5012: linux-2.6-xen-0013-MTRR-use-cpu_callout_map-instead-of-cpu_online_map.patch
-Patch5013: linux-2.6-xen-0014-xen-mtrr-Add-mtrr_ops-support-for-Xen-mtrr.patch
-Patch5014: linux-2.6-xen-0015-xen-mtrr-Don-t-enable-xen-mtrr-on-bare-metal.patch
-Patch5015: linux-2.6-xen-0016-xen-mtrr-set-cpu-in-cpu_callout_map.patch
-Patch5016: linux-2.6-xen-0017-xen-mtrr-Clean-up-the-num_var_ranges-CPU_UNKOWN-hac.patch
-Patch5017: linux-2.6-xen-0018-xen-mtrr-Use-specific-cpu_has_foo-macros-instead-of.patch
-Patch5018: linux-2.6-xen-0019-xen-mtrr-Kill-some-unneccessary-includes.patch
-Patch5019: linux-2.6-xen-0020-xen-mtrr-No-need-to-explicitly-set-use_intel_if-0.patch
-Patch5020: linux-2.6-xen-0021-xen-mtrr-Use-generic_validate_add_page.patch
-Patch5021: linux-2.6-xen-0022-xen-mtrr-Implement-xen_get_free_region.patch
-Patch5022: linux-2.6-xen-0023-xen-mtrr-Add-xen_-get-set-_mtrr-implementations.patch
-Patch5023: linux-2.6-xen-0024-irq2.diff-from-Juan-Quintela.patch
-Patch5024: linux-2.6-xen-0025-xen-dom0-Obvious-cpuid-fix-to-domU-handling.patch
-Patch5025: linux-2.6-xen-0026-xen-debug-Diagnose-bind_virq_to_irq-errors.patch
-Patch5026: linux-2.6-xen-0027-xen-traps-Revert-Juan-s-traps_32.c-changes-to-debug.patch
-Patch5027: linux-2.6-xen-0028-xen-debug-Move-init_apic_mappings-after-trap-init.patch
-Patch5028: linux-2.6-xen-0029-xen-debug-Trace-progress-in-trap_init-around-init.patch
-Patch5029: linux-2.6-xen-0030-xen-apic-Disable-init_apic_mappings-when-under-CO.patch
-Patch5030: linux-2.6-xen-0031-xen-debug-Log-entry-into-virtual-console-s-xen_init.patch
-Patch5031: linux-2.6-xen-0032-xen-debug-Log-bind_virq_to_irq-events.patch
-Patch5032: linux-2.6-xen-0033-xen-debug-Work-around-USB-issue-triggered-by-Xen-de.patch
-Patch5033: linux-2.6-xen-0034-Remove-duplicated-dma_alloc-free_noncoherent-define.patch
-Patch5034: linux-2.6-xen-0035-xem-dom0-Add-hypervisor-memory_exchange-descriptor.patch
-Patch5035: linux-2.6-xen-0036-xen-dom0-add-virt_to_pfn-macro.patch
-Patch5036: linux-2.6-xen-0037-xen-dom0-use-virt_to_pfn-where-appropriate.patch
-Patch5037: linux-2.6-xen-0038-xen-dom0-Add-contiguous-region-support.patch
-Patch5038: linux-2.6-xen-0039-xen-dom0-Don-t-mask-off-PCD-bits-from-pte-entries.patch
-Patch5039: linux-2.6-xen-0040-xen-dom0-Remove-duplicate-xen_store_interface-assig.patch
-Patch5040: linux-2.6-xen-0041-xen-dom0-Slightly-re-arrange-xenbus_probe_init-er.patch
-Patch5041: linux-2.6-xen-0042-xen-dom0-Use-max_low_pfn-declaration-from-linux-boo.patch
-Patch5042: linux-2.6-xen-0043-xen-dma-Add-dma_mapping_ops-indirection-for-32-bit.patch
-Patch5043: linux-2.6-xen-0044-xen-dma-Remove-unused-32-bit-dma_ops-map_simple-me.patch
-Patch5044: linux-2.6-xen-0045-xen-dma-Initial-commit-of-pci-xen.c-dma-mapping-fun.patch
-Patch5045: linux-2.6-xen-0046-xen-dma-Add-calls-to-dma_ops-alloc-free_coherent-ho.patch
-Patch5046: linux-2.6-xen-0047-xen-dma-Add-xen_alloc-free_coherent.patch
-Patch5047: linux-2.6-xen-0048-xen-dma-Don-t-merge-bios-on-xen-pvops.patch
-Patch5048: linux-2.6-xen-0049-xen-dom0-Minor-coding-style-issue-in-ISA-mapping-co.patch
-Patch5049: linux-2.6-xen-0050-xen-dom0-Use-i-PAGE_SHIFT-instead-of-PAGE_DOWN-i.patch
-Patch5050: linux-2.6-xen-0051-xen-dom0-Match-up-set_pte_mfn-prototype-with-the.patch
-Patch5051: linux-2.6-xen-0052-xen-dom0-Reserve-ISA-address-space-earlier.patch
-Patch5052: linux-2.6-xen-0053-xen-Add-empty-xenctrl-module.patch
-Patch5053: linux-2.6-xen-0054-xen-dom0-Add-proc-xen-capabilities.patch
-Patch5054: linux-2.6-xen-0055-xen-Add-proc-xen-privcmd.patch
-Patch5055: linux-2.6-xen-0056-xen-dom0-Add-proc-xen-xsd_-port-kva.patch
-Patch5056: linux-2.6-xen-0057-xen-Add-proc-xen-xenbus.patch
-Patch5057: linux-2.6-xen-0058-xen-Add-dev-xen-evtchn.patch
-Patch5058: linux-2.6-xen-0059-xen-Add-__init-__exit-notations-to-xenctrl-function.patch
-Patch5059: linux-2.6-xen-0060-xen-Add-Xen-s-sys-hypervisor-interface.patch
-Patch5060: linux-2.6-xen-0061-xen-dom0-Add-basic-proc-xen-balloon.patch
-Patch5061: linux-2.6-xen-0062-xen-dom0-Re-work-privcmd_ioctl-a-little.patch
-Patch5062: linux-2.6-xen-0063-xen-dom0-Add-IOCTL_PRIVCMD_MMAP.patch
-Patch5063: linux-2.6-xen-0064-xen-dom0-Add-a-vmlinuz-target.patch
+Patch5004: linux-2.6-xen-0005-xen-Module-autoprobing-support-for-frontend-drivers.patch
+Patch5005: linux-2.6-xen-0006-xen-Add-compatibility-aliases-for-frontend-drivers.patch
+Patch5006: linux-2.6-xen-0007-xen-dom0-Make-hvc_xen-console-work-for-dom0.patch
+Patch5007: linux-2.6-xen-0008-xen-dom0-Initialize-xenbus-for-dom0.patch
+Patch5008: linux-2.6-xen-0009-xen-dom0-Set-up-basic-IO-permissions-for-dom0.patch
+Patch5009: linux-2.6-xen-0010-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch
+Patch5010: linux-2.6-xen-0011-xen-dom0-Add-support-for-the-platform_ops-hypercall.patch
+Patch5011: linux-2.6-xen-0012-xen-acpi-Enable-early-access-to-ACPI-tables.patch
+Patch5012: linux-2.6-xen-0013-xen-dom0-Add-paravirt_ops-ioremap_page_range-for.patch
+Patch5013: linux-2.6-xen-0014-MTRR-use-cpu_callout_map-instead-of-cpu_online_map.patch
+Patch5014: linux-2.6-xen-0015-xen-mtrr-Add-mtrr_ops-support-for-Xen-mtrr.patch
+Patch5015: linux-2.6-xen-0016-xen-mtrr-Don-t-enable-xen-mtrr-on-bare-metal.patch
+Patch5016: linux-2.6-xen-0017-xen-mtrr-set-cpu-in-cpu_callout_map.patch
+Patch5017: linux-2.6-xen-0018-xen-mtrr-Clean-up-the-num_var_ranges-CPU_UNKOWN-hac.patch
+Patch5018: linux-2.6-xen-0019-xen-mtrr-Use-specific-cpu_has_foo-macros-instead-of.patch
+Patch5019: linux-2.6-xen-0020-xen-mtrr-Kill-some-unneccessary-includes.patch
+Patch5020: linux-2.6-xen-0021-xen-mtrr-No-need-to-explicitly-set-use_intel_if-0.patch
+Patch5021: linux-2.6-xen-0022-xen-mtrr-Use-generic_validate_add_page.patch
+Patch5022: linux-2.6-xen-0023-xen-mtrr-Implement-xen_get_free_region.patch
+Patch5023: linux-2.6-xen-0024-xen-mtrr-Add-xen_-get-set-_mtrr-implementations.patch
+Patch5024: linux-2.6-xen-0025-irq2.diff-from-Juan-Quintela.patch
+Patch5025: linux-2.6-xen-0026-xen-dom0-Obvious-cpuid-fix-to-domU-handling.patch
+Patch5026: linux-2.6-xen-0027-xen-debug-Diagnose-bind_virq_to_irq-errors.patch
+Patch5027: linux-2.6-xen-0028-xen-traps-Revert-Juan-s-traps_32.c-changes-to-debug.patch
+Patch5028: linux-2.6-xen-0029-xen-debug-Move-init_apic_mappings-after-trap-init.patch
+Patch5029: linux-2.6-xen-0030-xen-debug-Trace-progress-in-trap_init-around-init.patch
+Patch5030: linux-2.6-xen-0031-xen-apic-Disable-init_apic_mappings-when-under-CO.patch
+Patch5031: linux-2.6-xen-0032-xen-debug-Log-entry-into-virtual-console-s-xen_init.patch
+Patch5032: linux-2.6-xen-0033-xen-debug-Log-bind_virq_to_irq-events.patch
+Patch5033: linux-2.6-xen-0034-xen-debug-Work-around-USB-issue-triggered-by-Xen-de.patch
+Patch5034: linux-2.6-xen-0035-Remove-duplicated-dma_alloc-free_noncoherent-define.patch
+Patch5035: linux-2.6-xen-0036-xem-dom0-Add-hypervisor-memory_exchange-descriptor.patch
+Patch5036: linux-2.6-xen-0037-xen-dom0-add-virt_to_pfn-macro.patch
+Patch5037: linux-2.6-xen-0038-xen-dom0-use-virt_to_pfn-where-appropriate.patch
+Patch5038: linux-2.6-xen-0039-xen-dom0-Add-contiguous-region-support.patch
+Patch5039: linux-2.6-xen-0040-xen-dom0-Don-t-mask-off-PCD-bits-from-pte-entries.patch
+Patch5040: linux-2.6-xen-0041-xen-dom0-Remove-duplicate-xen_store_interface-assig.patch
+Patch5041: linux-2.6-xen-0042-xen-dom0-Slightly-re-arrange-xenbus_probe_init-er.patch
+Patch5042: linux-2.6-xen-0043-xen-dom0-Use-max_low_pfn-declaration-from-linux-boo.patch
+Patch5043: linux-2.6-xen-0044-xen-dma-Add-dma_mapping_ops-indirection-for-32-bit.patch
+Patch5044: linux-2.6-xen-0045-xen-dma-Remove-unused-32-bit-dma_ops-map_simple-me.patch
+Patch5045: linux-2.6-xen-0046-xen-dma-Initial-commit-of-pci-xen.c-dma-mapping-fun.patch
+Patch5046: linux-2.6-xen-0047-xen-dma-Add-calls-to-dma_ops-alloc-free_coherent-ho.patch
+Patch5047: linux-2.6-xen-0048-xen-dma-Add-xen_alloc-free_coherent.patch
+Patch5048: linux-2.6-xen-0049-xen-dma-Don-t-merge-bios-on-xen-pvops.patch
+Patch5049: linux-2.6-xen-0050-xen-dom0-Minor-coding-style-issue-in-ISA-mapping-co.patch
+Patch5050: linux-2.6-xen-0051-xen-dom0-Use-i-PAGE_SHIFT-instead-of-PAGE_DOWN-i.patch
+Patch5051: linux-2.6-xen-0052-xen-dom0-Match-up-set_pte_mfn-prototype-with-the.patch
+Patch5052: linux-2.6-xen-0053-xen-dom0-Reserve-ISA-address-space-earlier.patch
+Patch5053: linux-2.6-xen-0054-xen-Add-empty-xenctrl-module.patch
+Patch5054: linux-2.6-xen-0055-xen-dom0-Add-proc-xen-capabilities.patch
+Patch5055: linux-2.6-xen-0056-xen-Add-proc-xen-privcmd.patch
+Patch5056: linux-2.6-xen-0057-xen-dom0-Add-proc-xen-xsd_-port-kva.patch
+Patch5057: linux-2.6-xen-0058-xen-Add-proc-xen-xenbus.patch
+Patch5058: linux-2.6-xen-0059-xen-Add-dev-xen-evtchn.patch
+Patch5059: linux-2.6-xen-0060-xen-Add-__init-__exit-notations-to-xenctrl-function.patch
+Patch5060: linux-2.6-xen-0061-xen-Add-Xen-s-sys-hypervisor-interface.patch
+Patch5061: linux-2.6-xen-0062-xen-dom0-Add-basic-proc-xen-balloon.patch
+Patch5062: linux-2.6-xen-0063-xen-dom0-Re-work-privcmd_ioctl-a-little.patch
+Patch5063: linux-2.6-xen-0064-xen-dom0-Add-IOCTL_PRIVCMD_MMAP.patch
+Patch5064: linux-2.6-xen-0065-xen-dom0-Add-a-vmlinuz-target.patch
+
 # kernel-xen patches end
 
 # Xen hypervisor patches (20000+)
@@ -1337,66 +1339,68 @@
 ApplyPatch linux-2.6-xen-0002-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch
 ApplyPatch linux-2.6-xen-0003-fbdev-Make-deferred-I-O-work-as-advertized.patch
 ApplyPatch linux-2.6-xen-0004-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch
-ApplyPatch linux-2.6-xen-0005-Add-compatibility-aliases-for-Xen-block-network-fron.patch
-ApplyPatch linux-2.6-xen-0006-xen-dom0-Make-hvc_xen-console-work-for-dom0.patch
-ApplyPatch linux-2.6-xen-0007-xen-dom0-Initialize-xenbus-for-dom0.patch
-ApplyPatch linux-2.6-xen-0008-xen-dom0-Set-up-basic-IO-permissions-for-dom0.patch
-ApplyPatch linux-2.6-xen-0009-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch
-ApplyPatch linux-2.6-xen-0010-xen-dom0-Add-support-for-the-platform_ops-hypercall.patch
-ApplyPatch linux-2.6-xen-0011-xen-acpi-Enable-early-access-to-ACPI-tables.patch
-ApplyPatch linux-2.6-xen-0012-xen-dom0-Add-paravirt_ops-ioremap_page_range-for.patch
-ApplyPatch linux-2.6-xen-0013-MTRR-use-cpu_callout_map-instead-of-cpu_online_map.patch
-ApplyPatch linux-2.6-xen-0014-xen-mtrr-Add-mtrr_ops-support-for-Xen-mtrr.patch
-ApplyPatch linux-2.6-xen-0015-xen-mtrr-Don-t-enable-xen-mtrr-on-bare-metal.patch
-ApplyPatch linux-2.6-xen-0016-xen-mtrr-set-cpu-in-cpu_callout_map.patch
-ApplyPatch linux-2.6-xen-0017-xen-mtrr-Clean-up-the-num_var_ranges-CPU_UNKOWN-hac.patch
-ApplyPatch linux-2.6-xen-0018-xen-mtrr-Use-specific-cpu_has_foo-macros-instead-of.patch
-ApplyPatch linux-2.6-xen-0019-xen-mtrr-Kill-some-unneccessary-includes.patch
-ApplyPatch linux-2.6-xen-0020-xen-mtrr-No-need-to-explicitly-set-use_intel_if-0.patch
-ApplyPatch linux-2.6-xen-0021-xen-mtrr-Use-generic_validate_add_page.patch
-ApplyPatch linux-2.6-xen-0022-xen-mtrr-Implement-xen_get_free_region.patch
-ApplyPatch linux-2.6-xen-0023-xen-mtrr-Add-xen_-get-set-_mtrr-implementations.patch
-ApplyPatch linux-2.6-xen-0024-irq2.diff-from-Juan-Quintela.patch
-ApplyPatch linux-2.6-xen-0025-xen-dom0-Obvious-cpuid-fix-to-domU-handling.patch
-ApplyPatch linux-2.6-xen-0026-xen-debug-Diagnose-bind_virq_to_irq-errors.patch
-ApplyPatch linux-2.6-xen-0027-xen-traps-Revert-Juan-s-traps_32.c-changes-to-debug.patch
-ApplyPatch linux-2.6-xen-0028-xen-debug-Move-init_apic_mappings-after-trap-init.patch
-ApplyPatch linux-2.6-xen-0029-xen-debug-Trace-progress-in-trap_init-around-init.patch
-ApplyPatch linux-2.6-xen-0030-xen-apic-Disable-init_apic_mappings-when-under-CO.patch
-ApplyPatch linux-2.6-xen-0031-xen-debug-Log-entry-into-virtual-console-s-xen_init.patch
-ApplyPatch linux-2.6-xen-0032-xen-debug-Log-bind_virq_to_irq-events.patch
-ApplyPatch linux-2.6-xen-0033-xen-debug-Work-around-USB-issue-triggered-by-Xen-de.patch
-ApplyPatch linux-2.6-xen-0034-Remove-duplicated-dma_alloc-free_noncoherent-define.patch
-ApplyPatch linux-2.6-xen-0035-xem-dom0-Add-hypervisor-memory_exchange-descriptor.patch
-ApplyPatch linux-2.6-xen-0036-xen-dom0-add-virt_to_pfn-macro.patch
-ApplyPatch linux-2.6-xen-0037-xen-dom0-use-virt_to_pfn-where-appropriate.patch
-ApplyPatch linux-2.6-xen-0038-xen-dom0-Add-contiguous-region-support.patch
-ApplyPatch linux-2.6-xen-0039-xen-dom0-Don-t-mask-off-PCD-bits-from-pte-entries.patch
-ApplyPatch linux-2.6-xen-0040-xen-dom0-Remove-duplicate-xen_store_interface-assig.patch
-ApplyPatch linux-2.6-xen-0041-xen-dom0-Slightly-re-arrange-xenbus_probe_init-er.patch
-ApplyPatch linux-2.6-xen-0042-xen-dom0-Use-max_low_pfn-declaration-from-linux-boo.patch
-ApplyPatch linux-2.6-xen-0043-xen-dma-Add-dma_mapping_ops-indirection-for-32-bit.patch
-ApplyPatch linux-2.6-xen-0044-xen-dma-Remove-unused-32-bit-dma_ops-map_simple-me.patch
-ApplyPatch linux-2.6-xen-0045-xen-dma-Initial-commit-of-pci-xen.c-dma-mapping-fun.patch
-ApplyPatch linux-2.6-xen-0046-xen-dma-Add-calls-to-dma_ops-alloc-free_coherent-ho.patch
-ApplyPatch linux-2.6-xen-0047-xen-dma-Add-xen_alloc-free_coherent.patch
-ApplyPatch linux-2.6-xen-0048-xen-dma-Don-t-merge-bios-on-xen-pvops.patch
-ApplyPatch linux-2.6-xen-0049-xen-dom0-Minor-coding-style-issue-in-ISA-mapping-co.patch
-ApplyPatch linux-2.6-xen-0050-xen-dom0-Use-i-PAGE_SHIFT-instead-of-PAGE_DOWN-i.patch
-ApplyPatch linux-2.6-xen-0051-xen-dom0-Match-up-set_pte_mfn-prototype-with-the.patch
-ApplyPatch linux-2.6-xen-0052-xen-dom0-Reserve-ISA-address-space-earlier.patch
-ApplyPatch linux-2.6-xen-0053-xen-Add-empty-xenctrl-module.patch
-ApplyPatch linux-2.6-xen-0054-xen-dom0-Add-proc-xen-capabilities.patch
-ApplyPatch linux-2.6-xen-0055-xen-Add-proc-xen-privcmd.patch
-ApplyPatch linux-2.6-xen-0056-xen-dom0-Add-proc-xen-xsd_-port-kva.patch
-ApplyPatch linux-2.6-xen-0057-xen-Add-proc-xen-xenbus.patch
-ApplyPatch linux-2.6-xen-0058-xen-Add-dev-xen-evtchn.patch
-ApplyPatch linux-2.6-xen-0059-xen-Add-__init-__exit-notations-to-xenctrl-function.patch
-ApplyPatch linux-2.6-xen-0060-xen-Add-Xen-s-sys-hypervisor-interface.patch
-ApplyPatch linux-2.6-xen-0061-xen-dom0-Add-basic-proc-xen-balloon.patch
-ApplyPatch linux-2.6-xen-0062-xen-dom0-Re-work-privcmd_ioctl-a-little.patch
-ApplyPatch linux-2.6-xen-0063-xen-dom0-Add-IOCTL_PRIVCMD_MMAP.patch
-ApplyPatch linux-2.6-xen-0064-xen-dom0-Add-a-vmlinuz-target.patch
+ApplyPatch linux-2.6-xen-0005-xen-Module-autoprobing-support-for-frontend-drivers.patch
+ApplyPatch linux-2.6-xen-0006-xen-Add-compatibility-aliases-for-frontend-drivers.patch
+ApplyPatch linux-2.6-xen-0007-xen-dom0-Make-hvc_xen-console-work-for-dom0.patch
+ApplyPatch linux-2.6-xen-0008-xen-dom0-Initialize-xenbus-for-dom0.patch
+ApplyPatch linux-2.6-xen-0009-xen-dom0-Set-up-basic-IO-permissions-for-dom0.patch
+ApplyPatch linux-2.6-xen-0010-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch
+ApplyPatch linux-2.6-xen-0011-xen-dom0-Add-support-for-the-platform_ops-hypercall.patch
+ApplyPatch linux-2.6-xen-0012-xen-acpi-Enable-early-access-to-ACPI-tables.patch
+ApplyPatch linux-2.6-xen-0013-xen-dom0-Add-paravirt_ops-ioremap_page_range-for.patch
+ApplyPatch linux-2.6-xen-0014-MTRR-use-cpu_callout_map-instead-of-cpu_online_map.patch
+ApplyPatch linux-2.6-xen-0015-xen-mtrr-Add-mtrr_ops-support-for-Xen-mtrr.patch
+ApplyPatch linux-2.6-xen-0016-xen-mtrr-Don-t-enable-xen-mtrr-on-bare-metal.patch
+ApplyPatch linux-2.6-xen-0017-xen-mtrr-set-cpu-in-cpu_callout_map.patch
+ApplyPatch linux-2.6-xen-0018-xen-mtrr-Clean-up-the-num_var_ranges-CPU_UNKOWN-hac.patch
+ApplyPatch linux-2.6-xen-0019-xen-mtrr-Use-specific-cpu_has_foo-macros-instead-of.patch
+ApplyPatch linux-2.6-xen-0020-xen-mtrr-Kill-some-unneccessary-includes.patch
+ApplyPatch linux-2.6-xen-0021-xen-mtrr-No-need-to-explicitly-set-use_intel_if-0.patch
+ApplyPatch linux-2.6-xen-0022-xen-mtrr-Use-generic_validate_add_page.patch
+ApplyPatch linux-2.6-xen-0023-xen-mtrr-Implement-xen_get_free_region.patch
+ApplyPatch linux-2.6-xen-0024-xen-mtrr-Add-xen_-get-set-_mtrr-implementations.patch
+ApplyPatch linux-2.6-xen-0025-irq2.diff-from-Juan-Quintela.patch
+ApplyPatch linux-2.6-xen-0026-xen-dom0-Obvious-cpuid-fix-to-domU-handling.patch
+ApplyPatch linux-2.6-xen-0027-xen-debug-Diagnose-bind_virq_to_irq-errors.patch
+ApplyPatch linux-2.6-xen-0028-xen-traps-Revert-Juan-s-traps_32.c-changes-to-debug.patch
+ApplyPatch linux-2.6-xen-0029-xen-debug-Move-init_apic_mappings-after-trap-init.patch
+ApplyPatch linux-2.6-xen-0030-xen-debug-Trace-progress-in-trap_init-around-init.patch
+ApplyPatch linux-2.6-xen-0031-xen-apic-Disable-init_apic_mappings-when-under-CO.patch
+ApplyPatch linux-2.6-xen-0032-xen-debug-Log-entry-into-virtual-console-s-xen_init.patch
+ApplyPatch linux-2.6-xen-0033-xen-debug-Log-bind_virq_to_irq-events.patch
+ApplyPatch linux-2.6-xen-0034-xen-debug-Work-around-USB-issue-triggered-by-Xen-de.patch
+ApplyPatch linux-2.6-xen-0035-Remove-duplicated-dma_alloc-free_noncoherent-define.patch
+ApplyPatch linux-2.6-xen-0036-xem-dom0-Add-hypervisor-memory_exchange-descriptor.patch
+ApplyPatch linux-2.6-xen-0037-xen-dom0-add-virt_to_pfn-macro.patch
+ApplyPatch linux-2.6-xen-0038-xen-dom0-use-virt_to_pfn-where-appropriate.patch
+ApplyPatch linux-2.6-xen-0039-xen-dom0-Add-contiguous-region-support.patch
+ApplyPatch linux-2.6-xen-0040-xen-dom0-Don-t-mask-off-PCD-bits-from-pte-entries.patch
+ApplyPatch linux-2.6-xen-0041-xen-dom0-Remove-duplicate-xen_store_interface-assig.patch
+ApplyPatch linux-2.6-xen-0042-xen-dom0-Slightly-re-arrange-xenbus_probe_init-er.patch
+ApplyPatch linux-2.6-xen-0043-xen-dom0-Use-max_low_pfn-declaration-from-linux-boo.patch
+ApplyPatch linux-2.6-xen-0044-xen-dma-Add-dma_mapping_ops-indirection-for-32-bit.patch
+ApplyPatch linux-2.6-xen-0045-xen-dma-Remove-unused-32-bit-dma_ops-map_simple-me.patch
+ApplyPatch linux-2.6-xen-0046-xen-dma-Initial-commit-of-pci-xen.c-dma-mapping-fun.patch
+ApplyPatch linux-2.6-xen-0047-xen-dma-Add-calls-to-dma_ops-alloc-free_coherent-ho.patch
+ApplyPatch linux-2.6-xen-0048-xen-dma-Add-xen_alloc-free_coherent.patch
+ApplyPatch linux-2.6-xen-0049-xen-dma-Don-t-merge-bios-on-xen-pvops.patch
+ApplyPatch linux-2.6-xen-0050-xen-dom0-Minor-coding-style-issue-in-ISA-mapping-co.patch
+ApplyPatch linux-2.6-xen-0051-xen-dom0-Use-i-PAGE_SHIFT-instead-of-PAGE_DOWN-i.patch
+ApplyPatch linux-2.6-xen-0052-xen-dom0-Match-up-set_pte_mfn-prototype-with-the.patch
+ApplyPatch linux-2.6-xen-0053-xen-dom0-Reserve-ISA-address-space-earlier.patch
+ApplyPatch linux-2.6-xen-0054-xen-Add-empty-xenctrl-module.patch
+ApplyPatch linux-2.6-xen-0055-xen-dom0-Add-proc-xen-capabilities.patch
+ApplyPatch linux-2.6-xen-0056-xen-Add-proc-xen-privcmd.patch
+ApplyPatch linux-2.6-xen-0057-xen-dom0-Add-proc-xen-xsd_-port-kva.patch
+ApplyPatch linux-2.6-xen-0058-xen-Add-proc-xen-xenbus.patch
+ApplyPatch linux-2.6-xen-0059-xen-Add-dev-xen-evtchn.patch
+ApplyPatch linux-2.6-xen-0060-xen-Add-__init-__exit-notations-to-xenctrl-function.patch
+ApplyPatch linux-2.6-xen-0061-xen-Add-Xen-s-sys-hypervisor-interface.patch
+ApplyPatch linux-2.6-xen-0062-xen-dom0-Add-basic-proc-xen-balloon.patch
+ApplyPatch linux-2.6-xen-0063-xen-dom0-Re-work-privcmd_ioctl-a-little.patch
+ApplyPatch linux-2.6-xen-0064-xen-dom0-Add-IOCTL_PRIVCMD_MMAP.patch
+ApplyPatch linux-2.6-xen-0065-xen-dom0-Add-a-vmlinuz-target.patch
+
 # kernel-xen apply end
 
 # END OF PATCH APPLICATIONS
@@ -1980,6 +1984,9 @@
 %kernel_variant_files -a /%{image_install_path}/xen*-%{KVERREL} -e /etc/ld.so.conf.d/kernelcap-%{KVERREL}.conf %{with_xen} xen
 
 %changelog
+* Fri Feb 22 2008 Mark McLoughlin <markmc at redhat.com>
+- Add support for auto-probing frontend drivers
+
 * Thu Feb 21 2008 Mark McLoughlin <markmc at redhat.com>
 - Include xen pv fb and kbd drivers
 - Add module aliases for xennet and xenblk

linux-2.6-xen-0001-Revert-linux-2.6-execshield.patch-from-kernel-2_6_24.patch:

Index: linux-2.6-xen-0001-Revert-linux-2.6-execshield.patch-from-kernel-2_6_24.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/Attic/linux-2.6-xen-0001-Revert-linux-2.6-execshield.patch-from-kernel-2_6_24.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- linux-2.6-xen-0001-Revert-linux-2.6-execshield.patch-from-kernel-2_6_24.patch	21 Feb 2008 13:20:14 -0000	1.1.2.1
+++ linux-2.6-xen-0001-Revert-linux-2.6-execshield.patch-from-kernel-2_6_24.patch	22 Feb 2008 13:35:30 -0000	1.1.2.2
@@ -1676,5 +1676,5 @@
  				ret = new_addr;
  				goto out;
 -- 
-1.5.4.1
+1.5.4.2
 

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

Index: linux-2.6-xen-0002-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/Attic/linux-2.6-xen-0002-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- linux-2.6-xen-0002-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch	21 Feb 2008 13:20:14 -0000	1.1.2.1
+++ linux-2.6-xen-0002-xen-debug-Add-xprintk-to-log-directly-via-hypercall.patch	22 Feb 2008 13:35:30 -0000	1.1.2.2
@@ -1,4 +1,4 @@
-From 7770eb4599aea667372a82659e0bc9fd3708f668 Mon Sep 17 00:00:00 2001
+From d5f22b8612a899f6a99bb35ae85ddbb06d910f1a 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
@@ -75,5 +75,5 @@
  
  #endif	/* XEN_HVC_CONSOLE_H */
 -- 
-1.5.4.1
+1.5.4.2
 

linux-2.6-xen-0003-fbdev-Make-deferred-I-O-work-as-advertized.patch:

Index: linux-2.6-xen-0003-fbdev-Make-deferred-I-O-work-as-advertized.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/Attic/linux-2.6-xen-0003-fbdev-Make-deferred-I-O-work-as-advertized.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- linux-2.6-xen-0003-fbdev-Make-deferred-I-O-work-as-advertized.patch	21 Feb 2008 13:20:14 -0000	1.1.2.1
+++ linux-2.6-xen-0003-fbdev-Make-deferred-I-O-work-as-advertized.patch	22 Feb 2008 13:35:30 -0000	1.1.2.2
@@ -1,4 +1,4 @@
-From 84a7dfdc8860f79d1a7c79faa0d2dff3c081ed20 Mon Sep 17 00:00:00 2001
+From 70b9c3791f137756d78ab99d5041778626395fe9 Mon Sep 17 00:00:00 2001
 From: Markus Armbruster <armbru at redhat.com>
 Date: Thu, 21 Feb 2008 10:43:04 +0100
 Subject: [PATCH] fbdev: Make deferred I/O work as advertized
@@ -85,5 +85,5 @@
  EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
  
 -- 
-1.5.4.1
+1.5.4.2
 

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

Index: linux-2.6-xen-0004-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/Attic/linux-2.6-xen-0004-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- linux-2.6-xen-0004-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch	21 Feb 2008 13:20:14 -0000	1.1.2.1
+++ linux-2.6-xen-0004-xen-pvfb-Para-virtual-framebuffer-keyboard-and-poi.patch	22 Feb 2008 13:35:30 -0000	1.1.2.2
@@ -1,4 +1,4 @@
-From 6005d660517a2ce9939ad8c78fef60c3aca774f1 Mon Sep 17 00:00:00 2001
+From 9b2b9531a809c0101a783b8b6d82070b9e65cef1 Mon Sep 17 00:00:00 2001
 From: Markus Armbruster <armbru at redhat.com>
 Date: Thu, 21 Feb 2008 10:43:39 +0100
 Subject: [PATCH] xen pvfb: Para-virtual framebuffer, keyboard and pointer driver
@@ -1272,5 +1272,5 @@
 +
 +#endif
 -- 
-1.5.4.1
+1.5.4.2
 


--- linux-2.6-xen-0005-Add-compatibility-aliases-for-Xen-block-network-fron.patch DELETED ---


--- linux-2.6-xen-0006-xen-dom0-Make-hvc_xen-console-work-for-dom0.patch DELETED ---


--- linux-2.6-xen-0007-xen-dom0-Initialize-xenbus-for-dom0.patch DELETED ---


--- linux-2.6-xen-0008-xen-dom0-Set-up-basic-IO-permissions-for-dom0.patch DELETED ---


--- linux-2.6-xen-0009-xen-dom0-Add-set_fixmap-pv_mmu_ops.patch DELETED ---


--- linux-2.6-xen-0010-xen-dom0-Add-support-for-the-platform_ops-hypercall.patch DELETED ---


--- linux-2.6-xen-0011-xen-acpi-Enable-early-access-to-ACPI-tables.patch DELETED ---


--- linux-2.6-xen-0012-xen-dom0-Add-paravirt_ops-ioremap_page_range-for.patch DELETED ---


--- linux-2.6-xen-0013-MTRR-use-cpu_callout_map-instead-of-cpu_online_map.patch DELETED ---


--- linux-2.6-xen-0014-xen-mtrr-Add-mtrr_ops-support-for-Xen-mtrr.patch DELETED ---


--- linux-2.6-xen-0015-xen-mtrr-Don-t-enable-xen-mtrr-on-bare-metal.patch DELETED ---


--- linux-2.6-xen-0016-xen-mtrr-set-cpu-in-cpu_callout_map.patch DELETED ---


--- linux-2.6-xen-0017-xen-mtrr-Clean-up-the-num_var_ranges-CPU_UNKOWN-hac.patch DELETED ---


--- linux-2.6-xen-0018-xen-mtrr-Use-specific-cpu_has_foo-macros-instead-of.patch DELETED ---


--- linux-2.6-xen-0019-xen-mtrr-Kill-some-unneccessary-includes.patch DELETED ---


--- linux-2.6-xen-0020-xen-mtrr-No-need-to-explicitly-set-use_intel_if-0.patch DELETED ---


--- linux-2.6-xen-0021-xen-mtrr-Use-generic_validate_add_page.patch DELETED ---


--- linux-2.6-xen-0022-xen-mtrr-Implement-xen_get_free_region.patch DELETED ---


--- linux-2.6-xen-0023-xen-mtrr-Add-xen_-get-set-_mtrr-implementations.patch DELETED ---


--- linux-2.6-xen-0024-irq2.diff-from-Juan-Quintela.patch DELETED ---


--- linux-2.6-xen-0025-xen-dom0-Obvious-cpuid-fix-to-domU-handling.patch DELETED ---


--- linux-2.6-xen-0026-xen-debug-Diagnose-bind_virq_to_irq-errors.patch DELETED ---


--- linux-2.6-xen-0027-xen-traps-Revert-Juan-s-traps_32.c-changes-to-debug.patch DELETED ---


--- linux-2.6-xen-0028-xen-debug-Move-init_apic_mappings-after-trap-init.patch DELETED ---


--- linux-2.6-xen-0029-xen-debug-Trace-progress-in-trap_init-around-init.patch DELETED ---


--- linux-2.6-xen-0030-xen-apic-Disable-init_apic_mappings-when-under-CO.patch DELETED ---


--- linux-2.6-xen-0031-xen-debug-Log-entry-into-virtual-console-s-xen_init.patch DELETED ---


--- linux-2.6-xen-0032-xen-debug-Log-bind_virq_to_irq-events.patch DELETED ---


--- linux-2.6-xen-0033-xen-debug-Work-around-USB-issue-triggered-by-Xen-de.patch DELETED ---


--- linux-2.6-xen-0034-Remove-duplicated-dma_alloc-free_noncoherent-define.patch DELETED ---


--- linux-2.6-xen-0035-xem-dom0-Add-hypervisor-memory_exchange-descriptor.patch DELETED ---


--- linux-2.6-xen-0036-xen-dom0-add-virt_to_pfn-macro.patch DELETED ---


--- linux-2.6-xen-0037-xen-dom0-use-virt_to_pfn-where-appropriate.patch DELETED ---


--- linux-2.6-xen-0038-xen-dom0-Add-contiguous-region-support.patch DELETED ---


--- linux-2.6-xen-0039-xen-dom0-Don-t-mask-off-PCD-bits-from-pte-entries.patch DELETED ---


--- linux-2.6-xen-0040-xen-dom0-Remove-duplicate-xen_store_interface-assig.patch DELETED ---


--- linux-2.6-xen-0041-xen-dom0-Slightly-re-arrange-xenbus_probe_init-er.patch DELETED ---


--- linux-2.6-xen-0042-xen-dom0-Use-max_low_pfn-declaration-from-linux-boo.patch DELETED ---


--- linux-2.6-xen-0043-xen-dma-Add-dma_mapping_ops-indirection-for-32-bit.patch DELETED ---


--- linux-2.6-xen-0044-xen-dma-Remove-unused-32-bit-dma_ops-map_simple-me.patch DELETED ---


--- linux-2.6-xen-0045-xen-dma-Initial-commit-of-pci-xen.c-dma-mapping-fun.patch DELETED ---


--- linux-2.6-xen-0046-xen-dma-Add-calls-to-dma_ops-alloc-free_coherent-ho.patch DELETED ---


--- linux-2.6-xen-0047-xen-dma-Add-xen_alloc-free_coherent.patch DELETED ---


--- linux-2.6-xen-0048-xen-dma-Don-t-merge-bios-on-xen-pvops.patch DELETED ---


--- linux-2.6-xen-0049-xen-dom0-Minor-coding-style-issue-in-ISA-mapping-co.patch DELETED ---


--- linux-2.6-xen-0050-xen-dom0-Use-i-PAGE_SHIFT-instead-of-PAGE_DOWN-i.patch DELETED ---


--- linux-2.6-xen-0051-xen-dom0-Match-up-set_pte_mfn-prototype-with-the.patch DELETED ---


--- linux-2.6-xen-0052-xen-dom0-Reserve-ISA-address-space-earlier.patch DELETED ---


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


--- linux-2.6-xen-0054-xen-dom0-Add-proc-xen-capabilities.patch DELETED ---


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


--- linux-2.6-xen-0056-xen-dom0-Add-proc-xen-xsd_-port-kva.patch DELETED ---


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


--- linux-2.6-xen-0058-xen-Add-dev-xen-evtchn.patch DELETED ---


--- linux-2.6-xen-0059-xen-Add-__init-__exit-notations-to-xenctrl-function.patch DELETED ---


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


--- linux-2.6-xen-0061-xen-dom0-Add-basic-proc-xen-balloon.patch DELETED ---


--- linux-2.6-xen-0062-xen-dom0-Re-work-privcmd_ioctl-a-little.patch DELETED ---


--- linux-2.6-xen-0063-xen-dom0-Add-IOCTL_PRIVCMD_MMAP.patch DELETED ---


--- linux-2.6-xen-0064-xen-dom0-Add-a-vmlinuz-target.patch DELETED ---




More information about the fedora-extras-commits mailing list