Subject: xen3 arch-x86 From: http://xenbits.xensource.com/linux-2.6.18-xen.hg (tip 728:832aac894efd) Patch-mainline: obsolete Acked-by: jbeulich@novell.com Index: head-2008-12-01/arch/x86/Makefile =================================================================== --- head-2008-12-01.orig/arch/x86/Makefile 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/arch/x86/Makefile 2008-12-01 11:11:08.000000000 +0100 @@ -115,6 +115,10 @@ mcore-y := arch/x86/mach-default/ mflags-$(CONFIG_X86_VOYAGER) := -Iinclude/asm-x86/mach-voyager mcore-$(CONFIG_X86_VOYAGER) := arch/x86/mach-voyager/ +# 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/ @@ -183,9 +187,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 @@ -208,6 +229,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-12-01/arch/x86/boot/Makefile =================================================================== --- head-2008-12-01.orig/arch/x86/boot/Makefile 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/arch/x86/boot/Makefile 2008-12-01 11:11:08.000000000 +0100 @@ -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 @@ -190,5 +190,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-12-01/arch/x86/kernel/Makefile =================================================================== --- head-2008-12-01.orig/arch/x86/kernel/Makefile 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/arch/x86/kernel/Makefile 2008-12-01 11:14:33.000000000 +0100 @@ -99,10 +99,13 @@ scx200-y += scx200_32.o obj-$(CONFIG_OLPC) += olpc.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 genx2apic_uv_x.o tlb_uv.o + obj-$(CONFIG_X86_XEN_GENAPIC) += genapic_xen_64.o obj-y += bios_uv.o obj-$(CONFIG_X86_PM_TIMER) += pmtimer_64.o obj-$(CONFIG_AUDIT) += audit_64.o @@ -116,4 +119,10 @@ ifeq ($(CONFIG_X86_64),y) obj-$(CONFIG_SWIOTLB) += pci-swiotlb_64.o obj-$(CONFIG_PCI_MMCONFIG) += mmconf-fam10h_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-12-01/arch/x86/kernel/acpi/Makefile =================================================================== --- head-2008-12-01.orig/arch/x86/kernel/acpi/Makefile 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/arch/x86/kernel/acpi/Makefile 2008-12-01 11:11:08.000000000 +0100 @@ -5,6 +5,9 @@ obj-$(CONFIG_ACPI_SLEEP) += sleep.o wake ifneq ($(CONFIG_ACPI_PROCESSOR),) obj-y += cstate.o processor.o +ifneq ($(CONFIG_PROCESSOR_EXTERNAL_CONTROL),) +obj-$(CONFIG_XEN) += processor_extcntl_xen.o +endif endif $(obj)/wakeup_rm.o: $(obj)/realmode/wakeup.bin @@ -12,3 +15,4 @@ $(obj)/wakeup_rm.o: $(obj)/realmode/w $(obj)/realmode/wakeup.bin: FORCE $(Q)$(MAKE) $(build)=$(obj)/realmode +disabled-obj-$(CONFIG_XEN) := cstate.o wakeup_$(BITS).o Index: head-2008-12-01/arch/x86/kernel/acpi/boot.c =================================================================== --- head-2008-12-01.orig/arch/x86/kernel/acpi/boot.c 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/arch/x86/kernel/acpi/boot.c 2008-12-01 11:11:08.000000000 +0100 @@ -130,8 +130,10 @@ char *__init __acpi_map_table(unsigned l if (!phys || !size) return NULL; +#ifndef CONFIG_XEN if (phys+size <= (max_low_pfn_mapped << PAGE_SHIFT)) return __va(phys); +#endif offset = phys & (PAGE_SIZE - 1); mapped_size = PAGE_SIZE - offset; Index: head-2008-12-01/arch/x86/kernel/acpi/processor.c =================================================================== --- head-2008-12-01.orig/arch/x86/kernel/acpi/processor.c 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/arch/x86/kernel/acpi/processor.c 2008-12-01 11:11:08.000000000 +0100 @@ -75,7 +75,18 @@ static void init_intel_pdc(struct acpi_p /* Initialize _PDC data based on the CPU vendor */ void arch_acpi_processor_init_pdc(struct acpi_processor *pr) { +#ifdef CONFIG_XEN + /* + * As a work-around, just use cpu0's cpuinfo for all processors. + * Further work is required to expose xen hypervisor interface of + * getting physical cpuinfo to dom0 kernel and then + * arch_acpi_processor_init_pdc can set _PDC parameters according + * to Xen's phys information. + */ + struct cpuinfo_x86 *c = &boot_cpu_data; +#else struct cpuinfo_x86 *c = &cpu_data(pr->id); +#endif pr->pdc = NULL; if (c->x86_vendor == X86_VENDOR_INTEL) Index: head-2008-12-01/arch/x86/kernel/cpu/mtrr/Makefile =================================================================== --- head-2008-12-01.orig/arch/x86/kernel/cpu/mtrr/Makefile 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/arch/x86/kernel/cpu/mtrr/Makefile 2008-12-01 11:11:08.000000000 +0100 @@ -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-12-01/arch/x86/kernel/crash.c =================================================================== --- head-2008-12-01.orig/arch/x86/kernel/crash.c 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/arch/x86/kernel/crash.c 2008-12-01 11:11:08.000000000 +0100 @@ -32,6 +32,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; @@ -190,6 +191,7 @@ static void halt_current_cpu(struct pt_r /* There are no cpus to shootdown */ } #endif +#endif /* CONFIG_XEN */ void native_machine_crash_shutdown(struct pt_regs *regs) { @@ -206,11 +208,13 @@ void native_machine_crash_shutdown(struc /* 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-12-01/arch/x86/lib/Makefile =================================================================== --- head-2008-12-01.orig/arch/x86/lib/Makefile 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/arch/x86/lib/Makefile 2008-12-01 11:11:08.000000000 +0100 @@ -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-12-01/arch/x86/mm/Makefile =================================================================== --- head-2008-12-01.orig/arch/x86/mm/Makefile 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/arch/x86/mm/Makefile 2008-12-01 11:11:08.000000000 +0100 @@ -21,4 +21,6 @@ obj-$(CONFIG_K8_NUMA) += k8topology_64. endif obj-$(CONFIG_ACPI_NUMA) += srat_$(BITS).o +obj-$(CONFIG_XEN) += hypervisor.o + obj-$(CONFIG_MEMTEST) += memtest.o Index: head-2008-12-01/arch/x86/oprofile/Makefile =================================================================== --- head-2008-12-01.orig/arch/x86/oprofile/Makefile 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/arch/x86/oprofile/Makefile 2008-12-01 11:11:08.000000000 +0100 @@ -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-12-01/arch/x86/pci/Makefile =================================================================== --- head-2008-12-01.orig/arch/x86/pci/Makefile 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/arch/x86/pci/Makefile 2008-12-01 11:11:08.000000000 +0100 @@ -4,6 +4,9 @@ obj-$(CONFIG_PCI_BIOS) += pcbios.o obj-$(CONFIG_PCI_MMCONFIG) += mmconfig_$(BITS).o direct.o mmconfig-shared.o obj-$(CONFIG_PCI_DIRECT) += direct.o obj-$(CONFIG_PCI_OLPC) += olpc.o +# pcifront should be after mmconfig.o and direct.o as it should only +# take over if direct access to the PCI bus is unavailable +obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += pcifront.o obj-y += fixup.o obj-$(CONFIG_ACPI) += acpi.o Index: head-2008-12-01/include/asm-x86/acpi.h =================================================================== --- head-2008-12-01.orig/include/asm-x86/acpi.h 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/include/asm-x86/acpi.h 2008-12-01 11:11:08.000000000 +0100 @@ -30,6 +30,10 @@ #include #include +#ifdef CONFIG_XEN +#include +#endif + #define COMPILER_DEPENDENT_INT64 long long #define COMPILER_DEPENDENT_UINT64 unsigned long long @@ -124,6 +128,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 */ @@ -156,7 +181,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-12-01/include/asm-x86/apic.h =================================================================== --- head-2008-12-01.orig/include/asm-x86/apic.h 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/include/asm-x86/apic.h 2008-12-01 11:11:08.000000000 +0100 @@ -12,7 +12,9 @@ #include #include +#ifndef CONFIG_XEN #define ARCH_APICTIMER_STOPS_ON_C3 1 +#endif /* * Debugging macros Index: head-2008-12-01/include/asm-x86/kexec.h =================================================================== --- head-2008-12-01.orig/include/asm-x86/kexec.h 2008-12-01 10:53:14.000000000 +0100 +++ head-2008-12-01/include/asm-x86/kexec.h 2008-12-01 11:11:08.000000000 +0100 @@ -170,6 +170,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 */