Xen/ia64 modified files
RFC 1/2 Xen/ia64 modified files
This patch includes only the modifications to existing Linux/ia64
files to support both privileged and un-privileged guests on Xen/ia64.
arch/ia64/Kconfig | 16 +++ arch/ia64/Makefile | 18 +++ arch/ia64/hp/sim/Makefile | 2 arch/ia64/kernel/entry.S | 32 +++--- arch/ia64/kernel/head.S | 6 + arch/ia64/kernel/iosapic.c | 68 +++++++++++++ arch/ia64/kernel/irq_ia64.c | 200 ++++++++++++++++++++++++++++++++++++++++ arch/ia64/kernel/pal.S | 5 - arch/ia64/kernel/setup.c | 54 ++++++++++ arch/ia64/mm/ioremap.c | 3 include/asm-ia64/agp.h | 31 ++++++ include/asm-ia64/dma-mapping.h | 69 +++++++++++++ include/asm-ia64/gcc_intrin.h | 68 +++++++------ include/asm-ia64/hw_irq.h | 8 + include/asm-ia64/intel_intrin.h | 68 +++++++------ include/asm-ia64/io.h | 34 ++++++ include/asm-ia64/iosapic.h | 2 include/asm-ia64/irq.h | 31 ++++++ include/asm-ia64/machvec.h | 15 +++ include/asm-ia64/meminit.h | 5 + include/asm-ia64/page.h | 102 ++++++++++++++++++++ include/asm-ia64/pal.h | 1 include/asm-ia64/pgalloc.h | 2 include/asm-ia64/processor.h | 1 include/asm-ia64/system.h | 4 25 files changed, 758 insertions(+), 87 deletions(-)
Signature · 1 line
Alex Williamson HP Open Source & Linux Org.
arch/ia64/Kconfig +16 -0
@@ -57,6 +57,20 @@ config GENERIC_IOMAP config GENERIC_IOMAP bool default y + +config XEN + bool "Xen hypervisor support" + default y + help + Enable Xen hypervisor support. Resulting kernel runs + both as a guest OS on Xen and natively on hardware. + +config ARCH_XEN + bool + default y + depends on XEN + help + TEMP ONLY. Needs to be on for drivers/xen to build. config SCHED_NO_NO_OMIT_FRAME_POINTER bool
@@ -506,3 +520,5 @@ source "security/Kconfig" source "security/Kconfig" source "crypto/Kconfig" + +source "drivers/xen/Kconfig"
arch/ia64/Makefile +16 -2
@@ -45,6 +45,12 @@ endif endif CFLAGS += $(cflags-y) + +cppflags-$(CONFIG_XEN) += \ + -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION) + +CPPFLAGS += $(cppflags-y) + head-y := arch/ia64/kernel/head.o arch/ia64/kernel/init_task.o libs-y += arch/ia64/lib/
@@ -55,9 +61,15 @@ core-$(CONFIG_IA64_HP_ZX1) += arch/ia64/ core-$(CONFIG_IA64_HP_ZX1) += arch/ia64/dig/ core-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += arch/ia64/dig/ core-$(CONFIG_IA64_SGI_SN2) += arch/ia64/sn/ +core-$(CONFIG_XEN) += arch/ia64/xen/ drivers-$(CONFIG_PCI) += arch/ia64/pci/ +ifneq ($(CONFIG_XEN),y) drivers-$(CONFIG_IA64_HP_SIM) += arch/ia64/hp/sim/ +endif +ifneq ($(CONFIG_IA64_GENERIC),y) +drivers-$(CONFIG_XEN) += arch/ia64/hp/sim/ +endif drivers-$(CONFIG_IA64_HP_ZX1) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ drivers-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ drivers-$(CONFIG_IA64_GENERIC) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ arch/ia64/hp/sim/ arch/ia64/sn/
@@ -70,6 +82,8 @@ all: compressed unwcheck all: compressed unwcheck compressed: vmlinux.gz + +vmlinuz: vmlinux.gz vmlinux.gz: vmlinux $(Q)$(MAKE) $(build)=$(boot) $@
@@ -85,8 +99,8 @@ boot: lib/lib.a vmlinux boot: lib/lib.a vmlinux $(Q)$(MAKE) $(build)=$(boot) $@ -install: vmlinux.gz - sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)" +install: + -yes | sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)" define archhelp echo '* compressed - Build compressed kernel image'
arch/ia64/hp/sim/Makefile +2 -0
@@ -14,3 +14,5 @@ obj-$(CONFIG_HP_SIMSERIAL) += simserial. obj-$(CONFIG_HP_SIMSERIAL) += simserial.o obj-$(CONFIG_HP_SIMSERIAL_CONSOLE) += hpsim_console.o obj-$(CONFIG_HP_SIMSCSI) += simscsi.o +obj-$(CONFIG_XEN) += simserial.o +obj-$(CONFIG_XEN) += hpsim_console.o
arch/ia64/kernel/entry.S +19 -13
@@ -181,7 +181,7 @@ END(sys_clone) * called. The code starting at .map relies on this. The rest of the code * doesn't care about the interrupt masking status. */ -GLOBAL_ENTRY(ia64_switch_to) +GLOBAL_ENTRY(__ia64_switch_to) .prologue alloc r16=ar.pfs,1,0,0,0 DO_SAVE_SWITCH_STACK
@@ -235,7 +235,7 @@ GLOBAL_ENTRY(ia64_switch_to) ;; srlz.d br.cond.sptk .done -END(ia64_switch_to) +END(__ia64_switch_to) /* * Note that interrupts are enabled during save_switch_stack and load_switch_stack. This
@@ -376,7 +376,7 @@ END(save_switch_stack) * - b7 holds address to return to * - must not touch r8-r11 */ -ENTRY(load_switch_stack) +GLOBAL_ENTRY(load_switch_stack) .prologue .altrp b7
@@ -511,7 +511,7 @@ END(clone) * because some system calls (such as ia64_execve) directly * manipulate ar.pfs. */ -GLOBAL_ENTRY(ia64_trace_syscall) +GLOBAL_ENTRY(__ia64_trace_syscall) PT_REGS_UNWIND_INFO(0) /* * We need to preserve the scratch registers f6-f11 in case the system
@@ -583,7 +583,7 @@ strace_error: (p6) mov r10=-1 (p6) mov r8=r9 br.cond.sptk .strace_save_retval -END(ia64_trace_syscall) +END(__ia64_trace_syscall) /* * When traced and returning from sigreturn, we invoke syscall_trace but then
@@ -636,8 +636,11 @@ GLOBAL_ENTRY(ia64_ret_from_syscall) adds r2=PT(R8)+16,sp // r2 = &pt_regs.r8 mov r10=r0 // clear error indication in r10 (p7) br.cond.spnt handle_syscall_error // handle potential syscall failure + ;; + // don't fall through, ia64_leave_syscall may be #define'd + br.cond.sptk.few ia64_leave_syscall + ;; END(ia64_ret_from_syscall) - // fall through /* * ia64_leave_syscall(): Same as ia64_leave_kernel, except that it doesn't * need to switch to bank 0 and doesn't restore the scratch registers.
@@ -682,7 +685,7 @@ END(ia64_ret_from_syscall) * ar.csd: cleared * ar.ssd: cleared */ -ENTRY(ia64_leave_syscall) +GLOBAL_ENTRY(__ia64_leave_syscall) PT_REGS_UNWIND_INFO(0) /* * work.need_resched etc. mustn't get changed by this CPU before it returns to
@@ -790,7 +793,7 @@ ENTRY(ia64_leave_syscall) mov.m ar.ssd=r0 // M2 clear ar.ssd mov f11=f0 // F clear f11 br.cond.sptk.many rbs_switch // B -END(ia64_leave_syscall) +END(__ia64_leave_syscall) #ifdef CONFIG_IA32_SUPPORT GLOBAL_ENTRY(ia64_ret_from_ia32_execve)
@@ -802,10 +805,13 @@ GLOBAL_ENTRY(ia64_ret_from_ia32_execve) st8.spill [r2]=r8 // store return value in slot for r8 and set unat bit .mem.offset 8,0 st8.spill [r3]=r0 // clear error indication in slot for r10 and set unat bit + ;; + // don't fall through, ia64_leave_kernel may be #define'd + br.cond.sptk.few ia64_leave_kernel + ;; END(ia64_ret_from_ia32_execve) - // fall through #endif /* CONFIG_IA32_SUPPORT */ -GLOBAL_ENTRY(ia64_leave_kernel) +GLOBAL_ENTRY(__ia64_leave_kernel) PT_REGS_UNWIND_INFO(0) /* * work.need_resched etc. mustn't get changed by this CPU before it returns to
@@ -1136,7 +1142,7 @@ skip_rbs_switch: ld8 r10=[r3] br.cond.sptk.many .work_processed_syscall // re-check -END(ia64_leave_kernel) +END(__ia64_leave_kernel) ENTRY(handle_syscall_error) /*
@@ -1176,7 +1182,7 @@ END(ia64_invoke_schedule_tail) * be set up by the caller. We declare 8 input registers so the system call * args get preserved, in case we need to restart a system call. */ -ENTRY(notify_resume_user) +GLOBAL_ENTRY(notify_resume_user) .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(8) alloc loc1=ar.pfs,8,2,3,0 // preserve all eight input regs in case of syscall restart! mov r9=ar.unat
@@ -1264,7 +1270,7 @@ ENTRY(sys_rt_sigreturn) adds sp=16,sp ;; ld8 r9=[sp] // load new ar.unat - mov.sptk b7=r8,ia64_leave_kernel + mov.sptk b7=r8,__ia64_leave_kernel ;; mov ar.unat=r9 br.many b7
arch/ia64/kernel/head.S +6 -0
@@ -362,6 +362,12 @@ 1: // now we are in virtual mode (isBP) movl r2=ia64_boot_param ;; (isBP) st8 [r2]=r28 // save the address of the boot param area passed by the bootloader + +#ifdef CONFIG_XEN + // Note: isBP is used by the subprogram. + br.call.sptk.many rp=early_xen_setup + ;; +#endif #ifdef CONFIG_SMP (isAP) br.call.sptk.many rp=start_secondary
arch/ia64/kernel/iosapic.c +68 -0
86 lines not on this page · raw message
arch/ia64/kernel/irq_ia64.c +200 -0
230 lines not on this page · raw message
arch/ia64/kernel/pal.S +3 -2
@@ -16,6 +16,7 @@ #include <asm/processor.h> .data + .globl pal_entry_point pal_entry_point: data8 ia64_pal_default_handler .text
@@ -53,7 +54,7 @@ END(ia64_pal_default_handler) * in4 1 ==> clear psr.ic, 0 ==> don't clear psr.ic * */ -GLOBAL_ENTRY(ia64_pal_call_static) +GLOBAL_ENTRY(__ia64_pal_call_static) .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(5) alloc loc1 = ar.pfs,5,5,0,0 movl loc2 = pal_entry_point
@@ -90,7 +91,7 @@ 1: mov psr.l = loc3 ;; srlz.d // seralize restoration of psr.l br.ret.sptk.many b0 -END(ia64_pal_call_static) +END(__ia64_pal_call_static) /* * Make a PAL call using the stacked registers calling convention.
arch/ia64/kernel/setup.c +54 -0
102 lines not on this page · raw message
arch/ia64/mm/ioremap.c +3 -0
@@ -15,6 +15,9 @@ static inline void __iomem *static inline void __iomem *__ioremap (unsigned long offset,unsigned long size) { +#ifdef CONFIG_XEN + offset =HYPERVISOR_ioremap (offset, size); +#endif return (void __iomem *) (__IA64_UNCACHED_OFFSET | offset); }
include/asm-ia64/agp.h +31 -0
@@ -19,13 +19,44 @@#define flush_agp_cache () mb()/* Convert a physical address to an address suitable for the GART. */ +#ifndef CONFIG_XEN #define phys_to_gart (x) (x)#define gart_to_phys (x) (x) +#else +#define phys_to_gart (x) phys_to_machine_for_dma(x) +#define gart_to_phys (x) machine_to_phys_for_dma(x) +#endif /* GATT allocation. Returns/accepts GATT kernel virtual address. */ +#ifndef CONFIG_XEN #define alloc_gatt_pages (order) \ ((char *)__get_free_pages(GFP_KERNEL, (order)))#define free_gatt_pages (table, order) \ free_pages((unsigned long)(table), (order)) +#else +#include <asm/hypervisor.h> +static inline char * +alloc_gatt_pages (unsigned int order) +{ +unsigned long error; +unsigned long ret =__get_free_pages (GFP_KERNEL , (order)); +if (ret ==0 ) { + goto out; + } + error =xen_create_contiguous_region (ret, order,0 ); +if (error) { +free_pages (ret, order); + ret =0 ; + } +out: +return (char *)ret; +} +static inline void +free_gatt_pages (void * table,unsigned int order) +{ +xen_destroy_contiguous_region ((unsigned long )table, order); +free_pages ((unsigned long )table, order); +} +#endif /* CONFIG_XEN */ #endif /* _ASM_IA64_AGP_H */
include/asm-ia64/dma-mapping.h +69 -0
86 lines not on this page · raw message
include/asm-ia64/gcc_intrin.h +35 -33
183 lines not on this page · raw message
include/asm-ia64/hw_irq.h +8 -0
@@ -15,7 +15,11 @@#include <asm/ptrace.h> #include <asm/smp.h> +#ifndef CONFIG_XEN typedef u8 ia64_vector ; +#else +typedef u16 ia64_vector ; +#endif /* * 0 special
@@ -86,11 +90,15 @@ extern void ia64_send_ipi (int cpu, intextern void ia64_send_ipi (int cpu,int vector,int delivery_mode,int redirect);extern void register_percpu_irq (ia64_vector vec,struct irqaction *action); +#ifndef CONFIG_XEN static inline void hw_resend_irq (struct hw_interrupt_type *h,unsigned int vector) {platform_send_ipi (smp_processor_id (), vector,IA64_IPI_DM_INT ,0 ); } +#else +extern void hw_resend_irq (struct hw_interrupt_type *h,unsigned int i); +#endif /* CONFIG_XEN */ /* * Default implementations for the irq-descriptor API:
include/asm-ia64/intel_intrin.h +35 -33
118 lines not on this page · raw message
include/asm-ia64/io.h +34 -0
@@ -71,6 +71,10 @@ extern unsigned int num_io_spaces;#include <asm/page.h> #include <asm/system.h> #include <asm-generic/iomap.h> +#ifdef CONFIG_XEN +#include <asm/privop.h> +#include <asm/hypervisor.h> +#endif /* * Change virtual addresses to physical addresses and vv.
@@ -95,9 +99,39 @@ extern int valid_mmap_phys_addr_range (u* The following two macros are deprecated and scheduled for removal. * Please use the PCI-DMA interface defined in <asm/pci.h> instead. */ +#ifndef CONFIG_XEN #define bus_to_virt phys_to_virt#define virt_to_bus virt_to_phys#define page_to_bus page_to_phys +#define page_to_phys (page) (page_to_pfn(page) << PAGE_SHIFT) +#define page_to_pseudophys (page) page_to_phys(page) +#else +#define bus_to_virt (bus) \ + phys_to_virt(machine_to_phys_for_dma(bus)) +#define virt_to_bus (virt) \ + phys_to_machine_for_dma(virt_to_phys(virt)) +#define page_to_bus (page) \ + phys_to_machine_for_dma(page_to_pseudophys(page)) + +#define page_to_pseudophys (page) \ + ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) +// XXX +// the following drivers are broken because they use page_to_phys() to +// get bus address. fix them. +// drivers/ide/cris/ide-cris.c +// drivers/scsi/dec_esp.c +#define page_to_phys (page) (page_to_pseudophys(page)) +#define bvec_to_bus (bv) (page_to_bus((bv)->bv_page) + \ + (unsigned long) (bv)->bv_offset) +#define bio_to_pseudophys (bio) (page_to_pseudophys(bio_page((bio))) + \ + (unsigned long) bio_offset((bio))) +#define bvec_to_pseudophys (bv) (page_to_pseudophys((bv)->bv_page) + \ + (unsigned long) (bv)->bv_offset) +#define BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ + (((bvec_to_bus((vec1)) + (vec1)->bv_len) == bvec_to_bus((vec2))) && \ + ((bvec_to_pseudophys((vec1)) + (vec1)->bv_len) == \ + bvec_to_pseudophys((vec2)))) +#endif # endif /* KERNEL */
include/asm-ia64/iosapic.h +2 -0
@@ -53,6 +53,7 @@#define NR_IOSAPICS 256 +#ifndef CONFIG_XEN static inline unsigned int iosapic_read (char __iomem *iosapic,unsigned int reg) {writel (reg, iosapic +IOSAPIC_REG_SELECT );
@@ -64,6 +65,7 @@ static inline void iosapic_write(char __writel (reg, iosapic +IOSAPIC_REG_SELECT ); writel(val, iosapic + IOSAPIC_WINDOW); } +#endif static inline void iosapic_eoi (char __iomem *iosapic,u32 vector) {
include/asm-ia64/irq.h +31 -0
@@ -11,8 +11,39 @@* 02/29/00 D.Mosberger moved most things into hw_irq.h */ +#ifndef CONFIG_XEN #define NR_IRQS 256#define NR_IRQ_VECTORS NR_IRQS +#else +/* +* The flat IRQ space is divided into two regions: +* 1. A one-to-one mapping of real physical IRQs. This space is only used +* if we have physical device-access privilege. This region is at the +* start of the IRQ space so that existing device drivers do not need +* to be modified to translate physical IRQ numbers into our IRQ space. +* 3. A dynamic mapping of inter-domain and Xen-sourced virtual IRQs. These +* are bound using the provided bind/unbind functions. +*/ + +#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 + +#define pirq_to_irq (_x) ((_x) + PIRQ_BASE) +#define irq_to_pirq (_x) ((_x) - PIRQ_BASE) + +#define dynirq_to_irq (_x) ((_x) + DYNIRQ_BASE) +#define irq_to_dynirq (_x) ((_x) - DYNIRQ_BASE) + +#define RESCHEDULE_VECTOR 0 +#define IPI_VECTOR 1 +#define NR_IPIS 2 +#endif /* CONFIG_XEN */ /* * IRQ line status macro IRQ_PER_CPU is used
include/asm-ia64/machvec.h +15 -0
@@ -257,6 +257,21 @@ extern void machvec_init (const char *na# error Unknown configuration. Update asm-ia64/machvec.h.# endif /* CONFIG_IA64_GENERIC */ +#ifdef CONFIG_XEN +# define platform_dma_map_sg dma_map_sg +# define platform_dma_unmap_sg dma_unmap_sg +# define platform_dma_mapping_error dma_mapping_error +# define platform_dma_supported dma_supported +# define platform_dma_alloc_coherent dma_alloc_coherent +# define platform_dma_free_coherent dma_free_coherent +# define platform_dma_map_single dma_map_single +# define platform_dma_unmap_single dma_unmap_single +# define platform_dma_sync_single_for_cpu \ + dma_sync_single_for_cpu +# define platform_dma_sync_single_for_device \ + dma_sync_single_for_device +#endif +/* * Declare default routines which aren't declared anywhere else: */
include/asm-ia64/meminit.h +5 -0
@@ -17,10 +17,15 @@* - command line string * - kernel code & data * - Kernel memory map built from EFI memory map +* - xen start info * * More could be added if necessary */ +#ifndef CONFIG_XEN #define IA64_MAX_RSVD_REGIONS 6 +#else +#define IA64_MAX_RSVD_REGIONS 7 +#endif struct rsvd_region {unsigned long start;/* virtual address of beginning of element */
include/asm-ia64/page.h +101 -1
112 lines not on this page · raw message
include/asm-ia64/pal.h +1 -0
@@ -82,6 +82,7 @@#ifndef __ASSEMBLY__#include <linux/types.h> +#include <asm/processor.h> #include <asm/fpu.h> /*
include/asm-ia64/pgalloc.h +1 -1
@@ -126,7 +126,7 @@ static inline voidstatic inline void pmd_populate (struct mm_struct *mm,pmd_t * pmd_entry,struct page *pte) { -pmd_val (*pmd_entry) =page_to_phys (pte); +pmd_val (*pmd_entry) =page_to_pseudophys (pte); } static inline void
include/asm-ia64/processor.h +1 -0
@@ -19,6 +19,7 @@#include <asm/kregs.h> #include <asm/ptrace.h> #include <asm/ustack.h> +#include <asm/privop.h> #define IA64_NUM_DBG_REGS 8/*
include/asm-ia64/system.h +2 -2
@@ -125,7 +125,7 @@ extern struct ia64_boot_param {#define __local_irq_save (x) \ do { \ ia64_stop(); \ - (x) = ia64_getreg(_IA64_REG_PSR); \ + (x) = ia64_get_psr_i(); \ ia64_stop(); \ ia64_rsm(IA64_PSR_I); \ } while (0)
@@ -173,7 +173,7 @@ do { \#endif /* !CONFIG_IA64_DEBUG_IRQ */ #define local_irq_enable () ({ ia64_stop(); ia64_ssm(IA64_PSR_I); ia64_srlz_d(); }) -#define local_save_flags (flags) ({ ia64_stop(); (flags) = ia64_getreg(_IA64_REG_PSR); }) +#define local_save_flags (flags) ({ ia64_stop(); (flags) = ia64_get_psr_i(); })#define irqs_disabled () \ ({ \
arch/ia64/Kconfig source "security/Kconfig" · line 524
Quoted 9 lines · Alex Williamson
diff -r
016512c08f6b-r4489a633a5dearch/ia64/Kconfigarch/ia64/Kconfig +2
-0@@ -506,3 +520,5 @@ source "security/Kconfig" source "security/Kconfig" source "crypto/Kconfig" + +source "drivers/xen/Kconfig"
This should really be in drivers/Kconfig, though I suspect that's something for the xensource people.
arch/ia64/Makefile endif · line 53
Quoted 13 lines
diff -r
016512c08f6b-r4489a633a5dearch/ia64/Makefilearch/ia64/Makefile +6
-0@@ -45,6 +45,12 @@ endif endif CFLAGS += $(cflags-y) + +cppflags-$(CONFIG_XEN) += \ + -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION) + +CPPFLAGS += $(cppflags-y) +
That seems a little weird; again something for the xensource people to fix.
arch/ia64/Makefile core-$(CONFIG_IA64_HP_ZX1) += arch/ia64/ · line 72
Quoted 7 lines
arch/ia64/Makefile +5
-0drivers-$(CONFIG_PCI) += arch/ia64/pci/ +ifneq ($(CONFIG_XEN),y) drivers-$(CONFIG_IA64_HP_SIM) += arch/ia64/hp/sim/ +endif +ifneq ($(CONFIG_IA64_GENERIC),y) +drivers-$(CONFIG_XEN) += arch/ia64/hp/sim/ +endif
What're you trying to achieve here? Why isn't it sufficient to add:
drivers-$(CONFIG_XEN) += arch/ia64/hp/sim/
and leave all the ifneqs out?
arch/ia64/Makefile all: compressed unwcheck · line 86
Quoted 6 lines
arch/ia64/Makefile +2
-0@@ -70,6 +82,8 @@ all: compressed unwcheck all: compressed unwcheck compressed: vmlinux.gz + +vmlinuz: vmlinux.gz
This could be added independently
arch/ia64/Makefile boot: lib/lib.a vmlinux · line 103
Quoted 10 lines
arch/ia64/Makefile +2
-2vmlinux.gz: vmlinux $(Q)$(MAKE) $(build)=$(boot) $@@@ -85,8 +99,8 @@ boot: lib/lib.a vmlinux boot: lib/lib.a vmlinux $(Q)$(MAKE) $(build)=$(boot) $@ -install: vmlinux.gz - sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)" +install: + -yes | sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)"
Huh?
arch/ia64/Makefile register_intr (unsigned int gsi, int vec · line 719
Quoted 9 lines
arch/ia64/Makefile +5
-0@@ -653,6 +712,11 @@ register_intr (unsigned int gsi, int vec iosapic_intr_info[vector].polarity = polarity; iosapic_intr_info[vector].dmode = delivery; iosapic_intr_info[vector].trigger = trigger; + +#ifdef CONFIG_XEN + if (is_running_on_xen()) + return 0; +#endif
I would suggest defining this in a header with the standard
#ifdef CONFIG_XEN
#define is_running_on_xen() ...
#else
#define is_running_on_xen() 0
#endif
trick. This applies to just about every use of is_running_on_xen(), so I shan't comment on that further.
arch/ia64/kernel/irq_ia64.c assign_irq_vector (int irq) · line 72
Quoted 11 lines
diff -r
016512c08f6b-r4489a633a5dearch/ia64/kernel/irq_ia64.carch/ia64/kernel/irq_ia64.c +4
-0@@ -66,6 +66,11 @@ assign_irq_vector (int irq) assign_irq_vector (int irq) {int pos, vector; +#ifdef CONFIG_XEN +extern int xen_assign_irq_vector (int ); +if (is_running_on_xen ()) +return xen_assign_irq_vector (irq);
The extern should certainly be in a header file.
I'll review the rest of the irq stuff in a later mail.
arch/ia64/kernel/irq_ia64.c reserve_memory (void) · line 275
Quoted 5 lines
arch/ia64/kernel/irq_ia64.c +1
-0@@ -260,6 +272,7 @@ reserve_memory (void) n++; num_rsvd_regions = n; +BUG_ON (IA64_MAX_RSVD_REGIONS +1 < n);
Could be included now?
Quoted 4 lines
arch/ia64/kernel/irq_ia64.c +0
-0@@ -333,6 +346,16 @@ early_console_setup (char *cmdline) {int earlycons =0 ;
arch/ia64/kernel/irq_ia64.c early_console_setup (char *cmdline) · line 358
Quoted 10 lines
arch/ia64/kernel/irq_ia64.c +10
-0+#ifdef CONFIG_XEN +#ifndef CONFIG_IA64_HP_SIM +if (is_running_on_xen ()) { +extern struct console hpsim_cons; + hpsim_cons.flags |=CON_BOOT ; +register_console (&hpsim_cons); + earlycons++; + } +#endif +#endif
I'm not sure why you need the ifndef CONFIG_IA64_HP_SIM here?
arch/ia64/mm/ioremap.c static inline void __iomem * · line 22
Quoted 12 lines
diff -r
016512c08f6b-r4489a633a5dearch/ia64/mm/ioremap.carch/ia64/mm/ioremap.c +3
-0@@ -15,6 +15,9 @@ static inline void __iomem *static inline void __iomem *__ioremap (unsigned long offset,unsigned long size) { +#ifdef CONFIG_XEN + offset =HYPERVISOR_ioremap (offset, size); +#endif return (void __iomem *) (__IA64_UNCACHED_OFFSET | offset); }
I think this would be another great candidate for a dummy function.
arch/ia64/mm/ioremap.c static inline void __iomem * · line 23
Quoted 2 lines
arch/ia64/mm/ioremap.c +1
-1-#define ia64_intrin_local_irq_restore (x) \ +#define __ia64_intrin_local_irq_restore (x) \
I presume with all these changes, the Xen header file does something like:
#ifdef CONFIG_XEN
#define ia64_intrin_local_irq_restore(x) xen_ia64_intrin_local_irq_restore(x) #else
#define ia64_intrin_local_irq_restore(x) __ia64_intrin_local_irq_restore(x) #endif
arch/ia64/mm/ioremap.c
Quoted 5 lines
arch/ia64/mm/ioremap.c +5
-0+// XXX +// the following drivers are broken because they use page_to_phys() to +// get bus address. fix them. +// drivers/ide/cris/ide-cris.c +// drivers/scsi/dec_esp.c
Um, well, I don't see Xen running on DECstations or CRIS cameras any time soon ;-) We can probably let those drivers rust in pieces.
arch/ia64/mm/ioremap.c
Quoted 5 lines
#define
__local_irq_save(x)\
do { \arch/ia64/mm/ioremap.c +1
-1ia64_stop (); \ - (x) =ia64_getreg (_IA64_REG_PSR); \ + (x) =ia64_get_psr_i (); \
Looks like a good cleanup to submit ahead of time.
arch/ia64/mm/ioremap.c
Quoted 6 lines
#endif /* !CONFIG_IA64_DEBUG_IRQ */
#define
local_irq_enable()({ia64_stop();ia64_ssm(IA64_PSR_I);ia64_srlz_d(); })arch/ia64/mm/ioremap.c +1
-1-#define local_save_flags (flags) ({ ia64_stop(); (flags) = ia64_getreg(_IA64_REG_PSR); }) +#define local_save_flags (flags) ({ ia64_stop(); (flags) = ia64_get_psr_i(); })
Ditto.
Overall, looks good. I'll sit down at some point and really review the IRQ stuff, but this seems pretty clean to me.
Hi Willy,
Quoted 7 lines · Matthew Wilcox
Quoted 6 lines · Alex Williamson
diff -r
016512c08f6b-r4489a633a5dearch/ia64/Kconfigarch/ia64/Kconfig +0
-0@@ -506,3 +520,5 @@ source "security/Kconfig" source "security/Kconfig"
Quoted 6 lines
arch/ia64/Kconfig source "security/Kconfig" · line 524
Quoted 3 lines
arch/ia64/Kconfig +2
-0source "crypto/Kconfig" + +source "drivers/xen/Kconfig"This should really be in
drivers/Kconfig, though I suspect that's something for the xensource people.
I agree, things like this should flow a little better when the xen
infrastructure is integrated upstream.
Quoted 10 lines
arch/ia64/Kconfig
Quoted 7 lines
drivers-$(CONFIG_PCI) +=
arch/ia64/pci/arch/ia64/Kconfig +5
-0+ifneq ($(CONFIG_XEN),y) drivers-$(CONFIG_IA64_HP_SIM) += arch/ia64/hp/sim/ +endif +ifneq ($(CONFIG_IA64_GENERIC),y) +drivers-$(CONFIG_XEN) += arch/ia64/hp/sim/ +endifWhat're you trying to achieve here? Why isn't it sufficient to add:
Quoted 3 lines
drivers-$(CONFIG_XEN) +=
arch/ia64/hp/sim/and leave all the ifneqs out?
Good question. Some of this is probably kruft and I think we need to
look at whether all of the hpsim changes can simply be removed. I'll also mention that we're currently using only CONFIG_IA64_DIG for dom0 and domU kernels. The zx1 and sn machvecs will need some porting to understand the virtual physical memory idea (at least for their iommus).
Quoted 8 lines
arch/ia64/Kconfig all: compressed unwcheck · line 86
Quoted 6 lines
arch/ia64/Kconfig +2
-0@@ -70,6 +82,8 @@ all: compressed unwcheck all: compressed unwcheck compressed: vmlinux.gz + +vmlinuz: vmlinux.gzThis could be added independently
Good idea, we should start cherry picking some of these for early
upstream inclusion.
Quoted 6 lines
Quoted 6 lines
arch/ia64/Kconfig +0
-0vmlinux.gz: vmlinux $(Q)$(MAKE) $(build)=$(boot) $@@@ -85,8 +99,8 @@ boot: lib/lib.a vmlinux boot: lib/lib.a vmlinux $(Q)$(MAKE) $(build)=$(boot) $@
Quoted 6 lines
arch/ia64/Kconfig boot: lib/lib.a vmlinux · line 103
Quoted 4 lines
arch/ia64/Kconfig +2
-2-install: vmlinux.gz - sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)" +install: + -yes | sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)"Huh?
This is just to get around some build strangeness in the Xen tree,
probably not something that makes sense for the linux-ia64 tree.
Quoted 11 lines
I would suggest defining this in a header with the standard
#ifdef
CONFIG_XEN
#defineis_running_on_xen()...
#else
#defineis_running_on_xen()0
#endiftrick. This applies to just about every use of
is_running_on_xen(), so I shan't comment on that further.
Excellent cleanup idea.
Quoted 13 lines
arch/ia64/Kconfig boot: lib/lib.a vmlinux
Quoted 11 lines
arch/ia64/Kconfig +10
-0+#ifdef CONFIG_XEN +#ifndef CONFIG_IA64_HP_SIM + if (is_running_on_xen()) { + extern struct console hpsim_cons; + hpsim_cons.flags |= CON_BOOT; + register_console(&hpsim_cons); + earlycons++; + } +#endif +#endifI'm not sure why you need the ifndef
CONFIG_IA64_HP_SIMhere?
IMHO, this whole chunk is dated and probably needs to go. This
provides something like an early_printk() through the hypervisor when running on Xen.
Quoted 6 lines
Quoted 6 lines
diff -r
016512c08f6b-r4489a633a5dearch/ia64/mm/ioremap.carch/ia64/mm/ioremap.c +0
-0@@ -15,6 +15,9 @@ static inline void __iomem *static inline void __iomem *__ioremap (unsigned long offset,unsigned long size)
Quoted 8 lines
arch/ia64/mm/ioremap.c static inline void __iomem * · line 22
Quoted 6 lines
arch/ia64/mm/ioremap.c +3
-0{ +#ifdef CONFIG_XEN + offset =HYPERVISOR_ioremap (offset, size); +#endif return (void __iomem *) (__IA64_UNCACHED_OFFSET | offset); }I think this would be another great candidate for a dummy function.
Yep, good idea.
Quoted 11 lines
arch/ia64/mm/ioremap.c static inline void __iomem * · line 23
Quoted 2 lines
arch/ia64/mm/ioremap.c +1
-1-#define ia64_intrin_local_irq_restore (x) \ +#define __ia64_intrin_local_irq_restore (x) \I presume with all these changes, the Xen header file does something like:
#ifdef
CONFIG_XEN
#defineia64_intrin_local_irq_restore(x)xen_ia64_intrin_local_irq_restore(x)#else
#defineia64_intrin_local_irq_restore(x)__ia64_intrin_local_irq_restore(x)#endif
Yes, where xen_ia64_intrin_local_irq_restore() supports native and
paravirtualized to allow a kernel with CONFIG_XEN to run on either.
Quoted 2 lines
Overall, looks good. I'll sit down at some point and really review the IRQ stuff, but this seems pretty clean to me.
Great, thanks for jumping on this! I'll see about incorporating your
suggestions into our tree. Thanks,
Alex
Signature · 1 line
Alex Williamson HP Open Source & Linux Org.
arch/ia64/Kconfig config GENERIC_IOMAP · line 63
Quoted 3 lines · Alex Williamson
arch/ia64/Kconfig +3
-0+config XEN + bool "Xen hypervisor support" + default y
select ARCH_XEN
?
arch/ia64/Kconfig config GENERIC_IOMAP · line 70
Quoted 7 lines
arch/ia64/Kconfig +7
-0+ help + Enable Xen hypervisor support. Resulting kernel runs + both as a guest OS on Xen and natively on hardware. + +config ARCH_XEN + bool + default y
would suffice surely?
that would mean you don't have to see/select this option
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Alex" = Alex Williamson <[email protected]> writes:
Alex> This patch includes only the modifications to existing
Alex> Linux/ia64 files to support both privileged and un-privileged Alex> guests on Xen/ia64.
Hi Alex,
A few comments:
- There's a lot of function prototypes scattered over the code which should be in headers
- Several // commented out cases
- is_running_on_xen() should be done like IS_RUNNING_ON_SIMULATOR() in the sn2 tree
- In general I don't like this CONFIG_XEN being added everywhere. It would be much nicer if we could seperate the majority of the Xen code into a seperate file that is only compiled in when enabled.
- In many cases expanding and using the machvec table would reduce the ugliness of the patches. For instance in the dma mapping code, simply define a set of Xen specific functions that do all the magic stuff nobody else cares about.
- I do not like the fact that the changes to the generic code as so Xen specific. It would be much nicer to call into hypervisor_init_foo() so if someone wanted to write their own hypervisor they could interface to it without us getting another round of patches to core code. After all it seems that 2006 is the year of hypervisor-du-jour :)
I know the comments seem fairly harsh, but please don't take them personal. I find a lot of the changes really ugly, but I suspect thats because it's ported over.
Anyway, hope it's helpful.
Cheers,
Jes
arch/ia64/kernel/entry.S +4 -1
@@ -636,8 +636,11 @@ GLOBAL_ENTRY(ia64_ret_from_syscall) adds r2=PT(R8)+16,sp // r2 = &pt_regs.r8 mov r10=r0 // clear error indication in r10 (p7) br.cond.spnt handle_syscall_error // handle potential syscall failure + ;; + // don't fall through, ia64_leave_syscall may be #define'd + br.cond.sptk.few ia64_leave_syscall + ;; END(ia64_ret_from_syscall) - // fall through
Aren't we taking a performance hit here for the general case just to be able to support Xen. IMHO that should be conditional.
arch/ia64/kernel/iosapic.c +17 -0
@@ -160,6 +160,65 @@ static int iosapic_kmalloc_ok;static int iosapic_kmalloc_ok;static LIST_HEAD (free_rte_list); +#ifdef CONFIG_XEN +#include <xen/interface/xen.h> +#include <xen/interface/physdev.h> +#include <asm/hypervisor.h> +static inline unsigned int xen_iosapic_read (char __iomem *iosapic,unsigned int reg) +{ +struct physdev_apic apic_op; +int ret; + + apic_op.apic_physbase = (unsigned long )iosapic - + __IA64_UNCACHED_OFFSET; + apic_op.reg = reg; + ret =HYPERVISOR_physdev_op (PHYSDEVOP_apic_read, &apic_op); +if (ret) +return ret; +return apic_op.value; +}
[snip]
+static inline unsigned int iosapic_read(char __iomem *iosapic, unsigned int reg) +{
+ if (!is_running_on_xen()) {
+ writel(reg, iosapic + IOSAPIC_REG_SELECT);
+ return readl(iosapic + IOSAPIC_WINDOW);
+ } else
+ return xen_iosapic_read(iosapic, reg);
+}
This is where I'd write 'shiver ... barf!' and a couple of other things unsuitable for email. Magically overloading macros from a header file. It would be much nicer to put this into the machvec table or a similar place and stick the Xen specific stuff in a seperate file.
+/* 16 should be far optimistic value, since only several percpu irqs
+ * are registered early.
+ */
+#define MAX_LATE_IRQ 16
+static struct saved_irq saved_percpu_irqs[MAX_LATE_IRQ]; +static unsigned short late_irq_cnt = 0;
+static unsigned short saved_irq_cnt = 0;
+static int xen_slab_ready = 0;
No need to init with zero, just wastes space in the text segment.
+/*
+ * This is xen version percpu irq registration, which needs bind
+ * to xen specific evtchn sub-system. One trick here is that xen
+ * evtchn binding interface depends on kmalloc because related
+ * port needs to be freed at device/cpu down. So we cache the
+ * registration on BSP before slab is ready and then deal them
+ * at later point. For rest instances happening after slab ready,
+ * we hook them to xen evtchn immediately.
+ *
+ * FIXME: MCA is not supported by far, and thus "nomca" boot param is
+ * required.
+ */
+void
+xen_register_percpu_irq (unsigned int irq, struct irqaction *action, int save) +{
More stuff for a sepete xen specific file.
+ char name[15];
+ unsigned int cpu = smp_processor_id();
+ int ret = 0;
+
+ if (xen_slab_ready) {
+ switch (irq) {
+ case IA64_TIMER_VECTOR:
+ sprintf(timer_name[cpu], "%s%d", action->name, cpu);
+ ret = bind_virq_to_irqhandler(VIRQ_ITC, cpu,
+ action->handler, action->flags,
+ timer_name[cpu], action->dev_id);
+ printk(KERN_INFO "register VIRQ_ITC (%s) to xen irq (%d)\n", name, ret);
The kernel is 80 columns.
+/* FIXME: There's no obvious point to check whether slab is ready. So
+ * a hack is used here by utilizing a late time hook.
+ */
+extern void (*late_time_init)(void);
+extern char xen_event_callback;
+extern void xen_init_IRQ(void);
postcore initcall perhaps? Oh and of course in a header file.
+DECLARE_PER_CPU(int, ipi_to_irq[NR_IPIS]);
+void xen_smp_intr_init(void)
+{
More for a seperate xen file.
@@ -232,6 +382,10 @@ register_percpu_irq (ia64_vector vec, st
for (irq = 0; irq < NR_IRQS; ++irq)
if (irq_to_vector(irq) = vec) {
+#ifdef CONFIG_XEN
+ if (is_running_on_xen())
+ return xen_register_percpu_irq(vec, action, 1);
+#endif
Maybe one could do some sort of xen_init_core() that included this instead adding the xen specific callout?
@@ -243,6 +397,21 @@ void __init
void __init
init_IRQ (void)
{
+#ifdef CONFIG_XEN
+ /* Maybe put into platform_irq_init later */
+ if (is_running_on_xen()) {
+ struct callback_register event = {
Ditto
@@ -260,6 +429,37 @@ ia64_send_ipi (int cpu, int vector, int
unsigned long ipi_data;
unsigned long phys_cpu_id;
+#ifdef CONFIG_XEN
+ if (is_running_on_xen()) {
+ int irq = -1;
+
+ /* TODO: we need to call vcpu_up here */
+ if (unlikely(vector = ap_wakeup_vector)) {
+ extern void xen_send_ipi (int cpu, int vec);
Header file please.
+ xen_send_ipi (cpu, vector);
+ //vcpu_prepare_and_up(cpu);
+ return;
+ }
+
+ switch(vector) {
+ case IA64_IPI_VECTOR:
+ irq = per_cpu(ipi_to_irq, cpu)[IPI_VECTOR];
+ break;
+ case IA64_IPI_RESCHEDULE:
+ irq = per_cpu(ipi_to_irq, cpu)[RESCHEDULE_VECTOR];
+ break;
+ default:
+ printk(KERN_WARNING"Unsupported IPI type 0x%x\n", vector);
+ irq = 0;
+ break;
+ }
+
+ BUG_ON(irq < 0);
+ notify_remote_via_irq(irq);
+ return;
+ }
+#endif /* CONFIG_XEN */
Looks like another machvec style candidate.
arch/ia64/kernel/setup.c +3 -0
@@ -61,6 +61,10 @@#include <asm/system.h> #include <asm/unistd.h> #include <asm/system.h> +#ifdef CONFIG_XEN +#include <asm/hypervisor.h> +#endif
Why make the include conditional?
@@ -478,6 +505,25 @@ setup_arch (char **cmdline_p)
conswitchp = &vga_con;
# endif
}
+#ifdef CONFIG_XEN
+ if (is_running_on_xen()) {
+ extern shared_info_t *HYPERVISOR_shared_info;
+ extern int xen_init (void);
+
+ xen_init ();Again make it external? Some sort of hypervisor_init_console() call?
@@ -486,6 +532,7 @@ setup_arch (char **cmdline_p)
platform_setup(cmdline_p);
paging_init();
+ contiguous_bitmap_init(max_pfn);
????? huh?
arch/ia64/mm/ioremap.c +3 -0
@@ -15,6 +15,9 @@ static inline void __iomem *static inline void __iomem *__ioremap (unsigned long offset,unsigned long size) { +#ifdef CONFIG_XEN + offset =HYPERVISOR_ioremap (offset, size); +#endif
Why not defined it as "HYPERVISOR_IOREMAP_ADJUST(foo) foo" for the
non hypervisor case?
No studly caps please.
/* GATT allocation. Returns/accepts GATT kernel virtual address. */
+#ifndef CONFIG_XEN
#define alloc_gatt_pages(order) \
((char *)__get_free_pages(GFP_KERNEL, (order)))
#define free_gatt_pages(table, order) \
free_pages((unsigned long)(table), (order))
+#else
+#include <asm/hypervisor.h>
+static inline char*
+alloc_gatt_pages(unsigned int order)
+{
+ unsigned long error;
+ unsigned long ret = __get_free_pages(GFP_KERNEL, (order));
+ if (ret = 0) {
+ goto out;
+ }
+ error = xen_create_contiguous_region(ret, order, 0);
An example of this being too xen specific.
include/asm-ia64/dma-mapping.h +5 -0
@@ -7,7 +7,13 @@*/ #include <linux/config.h> #include <asm/machvec.h> +#ifdef CONFIG_XEN +#include <asm/hypervisor.h> //XXX to compile arch/i386/kernel/swiotlb.c +// and arch/i386/kernel/pci-dma-xen.c +#include <asm-i386/mach-xen/asm/swiotlb.h> //XXX to compile arch/i386/kernel/swiotlb.c +#endif
Pass the barf bucket please!
+#ifndef CONFIG_XEN
#define dma_alloc_coherent platform_dma_alloc_coherent
#define dma_alloc_noncoherent platform_dma_alloc_coherent /* coherent mem. is cheap */
#define dma_free_coherent platform_dma_free_coherent
@@ -21,6 +27,46 @@
#define dma_sync_single_for_device platform_dma_sync_single_for_device
#define dma_sync_sg_for_device platform_dma_sync_sg_for_device
#define dma_mapping_error platform_dma_mapping_error
+#else
+int dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
+ enum dma_data_direction direction);
+void dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
+ enum dma_data_direction direction);
+int dma_supported(struct device *dev, u64 mask);
Please use the machvec table appropriately here.
@@ -62,4 +108,27 @@ dma_cache_sync (void *vaddr, size_t size
#define dma_is_consistent(dma_handle) (1) /* all we do is coherent memory... */
+#ifdef CONFIG_XEN
+// arch/i386/kernel/swiotlb.o requires
+void contiguous_bitmap_init(unsigned long end_pfn); +
+static inline int
+address_needs_mapping(struct device *hwdev, dma_addr_t addr) +{
+ dma_addr_t mask = DMA_64BIT_MASK;
+ /* If the device has a mask, use it, otherwise default to 64 bits */
+ if (hwdev && hwdev->dma_mask)
+ mask = *hwdev->dma_mask;
+ return (addr & ~mask) != 0;
+}
+
+static inline int +range_straddles_page_boundary(void *p, size_t size) +{
+ extern unsigned long *contiguous_bitmap;
+ return (((((unsigned long)p & ~PAGE_MASK) + size) > PAGE_SIZE) &&
+ !test_bit(__pa(p) >> PAGE_SHIFT, contiguous_bitmap));
+}
+#endif
These are used by what?
#endif /* _ASM_IA64_DMA_MAPPING_H */
include/asm-ia64/gcc_intrin.h +1 -1
@@ -26,7 +26,7 @@ extern void ia64_bad_param_for_getreg (v register unsigned long ia64_r13 asm ("r13") __attribute_used__; -#define ia64_setreg (regnum, val) \ +#define __ia64_setreg (regnum, val) \
Mmmm, in general I think going the intrinsics way was a big mistake which was a path we should never have taken just to support a broken compiler :( This just makes it even uglier :(
include/asm-ia64/hw_irq.h +4 -0
@@ -15,7 +15,11 @@#include <asm/ptrace.h> #include <asm/smp.h> +#ifndef CONFIG_XEN typedef u8 ia64_vector ; +#else +typedef u16 ia64_vector ; +#endif
Whats the justification for this? If it's needed, couldn't we just make it a u16 table for all cases or is the performance impact severe?
+#ifndef CONFIG_XEN
static inline void
hw_resend_irq (struct hw_interrupt_type *h, unsigned int vector) {
platform_send_ipi(smp_processor_id(), vector, IA64_IPI_DM_INT, 0);
}
+#else
+extern void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i); +#endif /* CONFIG_XEN */
If Xen used the machvec table this would be unnecessary.
include/asm-ia64/io.h +12 -0
@@ -71,6 +71,10 @@ extern unsigned int num_io_spaces;#include <asm/page.h> #include <asm/system.h> #include <asm-generic/iomap.h> +#ifdef CONFIG_XEN +#include <asm/privop.h> +#include <asm/hypervisor.h> +#endif /* * Change virtual addresses to physical addresses and vv.
@@ -95,9 +99,39 @@ extern int valid_mmap_phys_addr_range (u* The following two macros are deprecated and scheduled for removal. * Please use the PCI-DMA interface defined in <asm/pci.h> instead. */ +#ifndef CONFIG_XEN #define bus_to_virt phys_to_virt#define virt_to_bus virt_to_phys#define page_to_bus page_to_phys +#define page_to_phys (page) (page_to_pfn(page) << PAGE_SHIFT) +#define page_to_pseudophys (page) page_to_phys(page) +#else +#define bus_to_virt (bus) \ + phys_to_virt(machine_to_phys_for_dma(bus)) +#define virt_to_bus (virt) \ + phys_to_machine_for_dma(virt_to_phys(virt))
No thanks! Could we please have this split into two seperate files if it's needed?
include/asm-ia64/irq.h +2 -0
@@ -11,8 +11,39 @@* 02/29/00 D.Mosberger moved most things into hw_irq.h */ +#ifndef CONFIG_XEN #define NR_IRQS 256#define NR_IRQ_VECTORS NR_IRQS +#else
You define the same values for Xen below. Why not just create a xen_irq.h for the rest and include it where needed.
include/asm-ia64/machvec.h +15 -0
@@ -257,6 +257,21 @@ extern void machvec_init (const char *na# error Unknown configuration. Update asm-ia64/machvec.h.# endif /* CONFIG_IA64_GENERIC */ +#ifdef CONFIG_XEN +# define platform_dma_map_sg dma_map_sg +# define platform_dma_unmap_sg dma_unmap_sg +# define platform_dma_mapping_error dma_mapping_error +# define platform_dma_supported dma_supported +# define platform_dma_alloc_coherent dma_alloc_coherent +# define platform_dma_free_coherent dma_free_coherent +# define platform_dma_map_single dma_map_single +# define platform_dma_unmap_single dma_unmap_single +# define platform_dma_sync_single_for_cpu \ + dma_sync_single_for_cpu +# define platform_dma_sync_single_for_device \ + dma_sync_single_for_device +#endif +
Uh oh! - think I covered this above :)
include/asm-ia64/page.h +9 -1
@@ -127,7 +127,6 @@ extern unsigned long max_low_pfn;# define pfn_valid (pfn) (((pfn) >= min_low_pfn) && ((pfn) < max_low_pfn) && ia64_pfn_valid(pfn))#endif -#define page_to_phys (page) (page_to_pfn(page) << PAGE_SHIFT)#define virt_to_page (kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)#define pfn_to_kaddr (pfn) __va((pfn) << PAGE_SHIFT)
@@ -229,4 +228,105 @@ get_order (unsigned long size) (((current->personality & READ_IMPLIES_EXEC) != 0) \ ? VM_EXEC : 0)) +#ifndef __ASSEMBLY__ +#ifdef CONFIG_XEN + +#define INVALID_P2M_ENTRY (~0UL) + +#include <linux/kernel.h> +#include <asm/hypervisor.h> +#include <xen/features.h> // to compile netback, netfront +typedef unsigned long maddr_t ;// to compile netback, netfront
There is no such thing as a maddr_t in the kernel and there never should be! typedefs were invented by the evil empire which is just out to get us! Please teach the Xen community to write code instead :)
+// XXX hack!
+// Linux/IA64 uses PG_arch_1.
+// This hack will be removed once PG_foreign bit is taken.
+//#include <xen/foreign_page.h>
+#ifdef __ASM_XEN_FOREIGN_PAGE_H__
+# error "don't include include/xen/foreign_page.h!" +#endif
I am somewhat concerned about the excessive number of #include's added to core header files like page.h
+extern struct address_space xen_ia64_foreign_dummy_mapping;
+#define PageForeign(page) \
+ ((page)->mapping = &xen_ia64_foreign_dummy_mapping)
Barf!
+#define HAVE_ARCH_FREE_PAGE
+
+//XXX xen page size != page size
Why?
+static inline unsigned long
+mfn_to_pfn_for_dma(unsigned long mfn)
+{
+ unsigned long pfn;
+ pfn = HYPERVISOR_machtophys(mfn);
StUdLyCaPsMeHaRdEr!
Quoted 9 lines
From: Jes Sorensen
Sent: 2006Äê6ÔÂ6ÈÕ 17:15Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Alex" = Alex Williamson <[email protected]> writes:
Alex> This patch includes only the modifications to existing
Alex> Linux/ia64 files to support both privileged and un-privileged Alex> guests on Xen/ia64.
Quoted 8 lines
- In general I don't like this
CONFIG_XENbeing added everywhere. It would be much nicer if we could seperate the majority of the Xen code into a seperate file that is only compiled in when enabled.
- In many cases expanding and using the machvec table would reduce the
ugliness of the patches. For instance in the dma mapping code, simply define a set of Xen specific functions that do all the magic stuff nobody else cares about.
Hi, Jes,
Thanks for careful review. I agree that xen should be introduced
as some type of new 'box' as others, like current sn/hp/dig under arch/ia64. That does save many ugly checks for is_running_on_xen scattered in common code. Future it would be even worse. Actually that's the way how xen/x86 has already done currently, where mach-xen is introduced under arch/i386 and thus the hierarchy is much cleaner. IMO, that's one of the outstanding gaps between xen/x86 and xen/ia64, and time for change now. :-)
Thanks,
Kevin
Quoted 3 lines · Jes Sorensen
Hi Alex,
A few comments:
Hi Jes,
Thanks for the thorough review. There is definitely still much to be
cleaned up before we think about including this. Incorporating changes into a Xen machvec is certainly on my wish list. Some of the CONFIG_XEN demarcations in the code are to make it easier for us to rebase the code as we track upstream. I hope to get rid of a lot of those as we incorporate things like a better is_running_on_xen() check. Thanks again for you comments, we'll start incorporating them.
Alex
Signature · 1 line
Alex Williamson HP Open Source & Linux Org.