Subject: xen3 arch-x86 From: http://xenbits.xensource.com/linux-2.6.18-xen.hg (tip 517:d71965a78c20) Patch-mainline: obsolete Acked-by: jbeulich@novell.com Index: head-2008-04-15/arch/x86/Makefile =================================================================== --- head-2008-04-15.orig/arch/x86/Makefile 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/arch/x86/Makefile 2008-04-15 09:59:26.000000000 +0200 @@ -131,6 +131,10 @@ mcore-$(CONFIG_X86_BIGSMP) := arch/x86/m mflags-$(CONFIG_X86_SUMMIT) := -Iinclude/asm-x86/mach-summit mcore-$(CONFIG_X86_SUMMIT) := arch/x86/mach-default/ +# Xen subarch support +mflags-$(CONFIG_X86_XEN) := -Iinclude/asm-x86/mach-xen +mcore-$(CONFIG_X86_XEN) := arch/x86/mach-xen/ + # generic subarchitecture mflags-$(CONFIG_X86_GENERICARCH):= -Iinclude/asm-x86/mach-generic fcore-$(CONFIG_X86_GENERICARCH) += arch/x86/mach-generic/ @@ -208,9 +212,26 @@ drivers-$(CONFIG_KDB) += arch/x86/kdb/ boot := arch/x86/boot -PHONY += zImage bzImage compressed zlilo bzlilo \ +PHONY += zImage bzImage vmlinuz compressed zlilo bzlilo \ zdisk bzdisk fdimage fdimage144 fdimage288 isoimage install +ifdef CONFIG_XEN +CPPFLAGS := -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION) \ + -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(CPPFLAGS) + +ifdef CONFIG_X86_64 +LDFLAGS_vmlinux := -e startup_64 +endif + +# Default kernel to build +all: vmlinuz + +# KBUILD_IMAGE specifies the target image being built +KBUILD_IMAGE := $(boot)/vmlinuz + +vmlinuz: vmlinux + $(Q)$(MAKE) $(build)=$(boot) $(KBUILD_IMAGE) +else # Default kernel to build all: bzImage @@ -233,6 +254,7 @@ zdisk bzdisk: vmlinux fdimage fdimage144 fdimage288 isoimage: vmlinux $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@ +endif install: $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install Index: head-2008-04-15/arch/x86/boot/Makefile =================================================================== --- head-2008-04-15.orig/arch/x86/boot/Makefile 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/arch/x86/boot/Makefile 2008-04-15 09:59:26.000000000 +0200 @@ -25,7 +25,7 @@ SVGA_MODE := -DSVGA_MODE=NORMAL_VGA #RAMDISK := -DRAMDISK=512 -targets := vmlinux.bin setup.bin setup.elf zImage bzImage +targets := vmlinux.bin setup.bin setup.elf zImage bzImage vmlinuz vmlinux-stripped subdir- := compressed setup-y += a20.o cmdline.o copy.o cpu.o cpucheck.o edd.o @@ -176,5 +176,13 @@ zlilo: $(BOOTIMAGE) cp System.map $(INSTALL_PATH)/ if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi +$(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) + install: sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)" Index: head-2008-04-15/arch/x86/kernel/acpi/boot.c =================================================================== --- head-2008-04-15.orig/arch/x86/kernel/acpi/boot.c 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/arch/x86/kernel/acpi/boot.c 2008-04-15 09:59:26.000000000 +0200 @@ -103,7 +103,7 @@ static u64 acpi_lapic_addr __initdata = */ enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC; -#ifdef CONFIG_X86_64 +#if defined(CONFIG_X86_64) && !defined(CONFIG_XEN) /* rely on all ACPI tables being in the direct mapping */ char *__init __acpi_map_table(unsigned long phys_addr, unsigned long size) @@ -136,8 +136,10 @@ char *__init __acpi_map_table(unsigned l unsigned long base, offset, mapped_size; int idx; +#ifndef CONFIG_XEN if (phys + size < 8 * 1024 * 1024) return __va(phys); +#endif offset = phys & (PAGE_SIZE - 1); mapped_size = PAGE_SIZE - offset; Index: head-2008-04-15/arch/x86/kernel/Makefile =================================================================== --- head-2008-04-15.orig/arch/x86/kernel/Makefile 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/arch/x86/kernel/Makefile 2008-04-15 09:59:26.000000000 +0200 @@ -86,14 +86,23 @@ endif obj-$(CONFIG_SCx200) += scx200.o scx200-y += scx200_32.o +obj-$(CONFIG_X86_XEN) += fixup.o + ### # 64 bit specific files ifeq ($(CONFIG_X86_64),y) obj-y += genapic_64.o genapic_flat_64.o + obj-$(CONFIG_X86_XEN_GENAPIC) += genapic_64.o genapic_xen_64.o obj-$(CONFIG_X86_PM_TIMER) += pmtimer_64.o obj-$(CONFIG_AUDIT) += audit_64.o obj-$(CONFIG_GART_IOMMU) += pci-gart_64.o aperture_64.o obj-$(CONFIG_CALGARY_IOMMU) += pci-calgary_64.o tce_64.o obj-$(CONFIG_SWIOTLB) += pci-swiotlb_64.o + + time_64-$(CONFIG_XEN) += time_32.o + pci-dma_64-$(CONFIG_XEN) += pci-dma_32.o endif + +disabled-obj-$(CONFIG_XEN) := i8259_$(BITS).o reboot.o smpboot_$(BITS).o +%/head_$(BITS).o %/head_$(BITS).s: $(if $(CONFIG_XEN),EXTRA_AFLAGS,dummy) := Index: head-2008-04-15/arch/x86/kernel/acpi/Makefile =================================================================== --- head-2008-04-15.orig/arch/x86/kernel/acpi/Makefile 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/arch/x86/kernel/acpi/Makefile 2008-04-15 09:59:26.000000000 +0200 @@ -5,3 +5,4 @@ ifneq ($(CONFIG_ACPI_PROCESSOR),) obj-y += cstate.o processor.o endif +disabled-obj-$(CONFIG_XEN) := cstate.o wakeup_$(BITS).o Index: head-2008-04-15/arch/x86/kernel/cpu/mtrr/Makefile =================================================================== --- head-2008-04-15.orig/arch/x86/kernel/cpu/mtrr/Makefile 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/arch/x86/kernel/cpu/mtrr/Makefile 2008-04-15 09:59:26.000000000 +0200 @@ -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) := main.o if.o Index: head-2008-04-15/arch/x86/kernel/crash.c =================================================================== --- head-2008-04-15.orig/arch/x86/kernel/crash.c 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/arch/x86/kernel/crash.c 2008-04-15 09:59:26.000000000 +0200 @@ -35,6 +35,7 @@ /* This keeps a track of which one is crashing cpu. */ static int crashing_cpu; +#ifndef CONFIG_XEN #if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC) static atomic_t waiting_for_crash_ipi; @@ -120,6 +121,7 @@ static void nmi_shootdown_cpus(void) /* There are no cpus to shootdown */ } #endif +#endif /* CONFIG_XEN */ void machine_crash_shutdown(struct pt_regs *regs) { @@ -136,11 +138,13 @@ void machine_crash_shutdown(struct pt_re /* Make a note of crashing cpu. Will be used in NMI callback.*/ crashing_cpu = safe_smp_processor_id(); +#ifndef CONFIG_XEN nmi_shootdown_cpus(); lapic_shutdown(); #if defined(CONFIG_X86_IO_APIC) disable_IO_APIC(); #endif +#endif /* CONFIG_XEN */ #ifdef CONFIG_HPET_TIMER hpet_disable(); #endif Index: head-2008-04-15/arch/x86/lib/Makefile =================================================================== --- head-2008-04-15.orig/arch/x86/lib/Makefile 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/arch/x86/lib/Makefile 2008-04-15 09:59:26.000000000 +0200 @@ -25,3 +25,5 @@ else lib-y += memmove_64.o memset_64.o lib-y += copy_user_64.o rwlock_64.o copy_user_nocache_64.o endif + +lib-$(CONFIG_XEN_SCRUB_PAGES) += scrub.o Index: head-2008-04-15/arch/x86/mm/Makefile =================================================================== --- head-2008-04-15.orig/arch/x86/mm/Makefile 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/arch/x86/mm/Makefile 2008-04-15 09:59:26.000000000 +0200 @@ -3,3 +3,5 @@ include ${srctree}/arch/x86/mm/Makefile_ else include ${srctree}/arch/x86/mm/Makefile_64 endif + +obj-$(CONFIG_XEN) += hypervisor.o Index: head-2008-04-15/arch/x86/oprofile/Makefile =================================================================== --- head-2008-04-15.orig/arch/x86/oprofile/Makefile 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/arch/x86/oprofile/Makefile 2008-04-15 09:59:26.000000000 +0200 @@ -6,7 +6,14 @@ DRIVER_OBJS = $(addprefix ../../../drive oprofilefs.o oprofile_stats.o \ timer_int.o ) +ifdef CONFIG_XEN +XENOPROF_COMMON_OBJS = $(addprefix ../../../drivers/xen/xenoprof/, \ + xenoprofile.o) +oprofile-y := $(DRIVER_OBJS) \ + $(XENOPROF_COMMON_OBJS) xenoprof.o +else oprofile-y := $(DRIVER_OBJS) init.o backtrace.o oprofile-$(CONFIG_X86_LOCAL_APIC) += nmi_int.o op_model_athlon.o \ op_model_ppro.o op_model_p4.o oprofile-$(CONFIG_X86_IO_APIC) += nmi_timer_int.o +endif Index: head-2008-04-15/include/asm-x86/acpi.h =================================================================== --- head-2008-04-15.orig/include/asm-x86/acpi.h 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/include/asm-x86/acpi.h 2008-04-15 10:24:13.000000000 +0200 @@ -29,6 +29,10 @@ #include #include +#ifdef CONFIG_XEN +#include +#endif + #define COMPILER_DEPENDENT_INT64 long long #define COMPILER_DEPENDENT_UINT64 unsigned long long @@ -123,6 +127,27 @@ extern unsigned long acpi_wakeup_address /* early initialization routine */ extern void acpi_reserve_bootmem(void); +#ifdef CONFIG_XEN +static inline int acpi_notify_hypervisor_state(u8 sleep_state, + u32 pm1a_cnt_val, + u32 pm1b_cnt_val) +{ + struct xen_platform_op op = { + .cmd = XENPF_enter_acpi_sleep, + .interface_version = XENPF_INTERFACE_VERSION, + .u = { + .enter_acpi_sleep = { + .pm1a_cnt_val = pm1a_cnt_val, + .pm1b_cnt_val = pm1b_cnt_val, + .sleep_state = sleep_state, + }, + }, + }; + + return HYPERVISOR_platform_op(&op); +} +#endif /* CONFIG_XEN */ + /* * Check if the CPU can handle C2 and deeper */ @@ -153,7 +178,9 @@ static inline void disable_acpi(void) { #endif /* !CONFIG_ACPI */ +#ifndef CONFIG_XEN #define ARCH_HAS_POWER_INIT 1 +#endif struct bootnode; Index: head-2008-04-15/include/asm-x86/apic.h =================================================================== --- head-2008-04-15.orig/include/asm-x86/apic.h 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/include/asm-x86/apic.h 2008-04-15 09:59:26.000000000 +0200 @@ -8,7 +8,9 @@ #include #include +#ifndef CONFIG_XEN #define ARCH_APICTIMER_STOPS_ON_C3 1 +#endif #define Dprintk(x...) Index: head-2008-04-15/include/asm-x86/kexec.h =================================================================== --- head-2008-04-15.orig/include/asm-x86/kexec.h 2008-04-15 09:41:09.000000000 +0200 +++ head-2008-04-15/include/asm-x86/kexec.h 2008-04-15 09:59:26.000000000 +0200 @@ -165,6 +165,19 @@ relocate_kernel(unsigned long indirectio unsigned long start_address) ATTRIB_NORET; #endif +/* Under Xen we need to work with machine addresses. These macros give the + * machine address of a certain page to the generic kexec code instead of + * the pseudo physical address which would be given by the default macros. + */ + +#ifdef CONFIG_XEN +#define KEXEC_ARCH_HAS_PAGE_MACROS +#define kexec_page_to_pfn(page) pfn_to_mfn(page_to_pfn(page)) +#define kexec_pfn_to_page(pfn) pfn_to_page(mfn_to_pfn(pfn)) +#define kexec_virt_to_phys(addr) virt_to_machine(addr) +#define kexec_phys_to_virt(addr) phys_to_virt(machine_to_phys(addr)) +#endif + #endif /* __ASSEMBLY__ */ #endif /* _KEXEC_H */