Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm: initial Xen support

- Basic hypervisor.h and interface.h definitions.
- Skeleton enlighten.c, set xen_start_info to an empty struct.
- Make xen_initial_domain dependent on the SIF_PRIVILIGED_BIT.

The new code only compiles when CONFIG_XEN is set, that is going to be
added to arch/arm/Kconfig in patch #11 "xen/arm: introduce CONFIG_XEN on
ARM".

Changes in v3:

- improve comments.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

+132 -1
+1
arch/arm/Makefile
··· 251 251 core-$(CONFIG_FPE_NWFPE) += arch/arm/nwfpe/ 252 252 core-$(CONFIG_FPE_FASTFPE) += $(FASTFPE_OBJ) 253 253 core-$(CONFIG_VFP) += arch/arm/vfp/ 254 + core-$(CONFIG_XEN) += arch/arm/xen/ 254 255 255 256 # If we have a machine-specific directory, then include it in the build. 256 257 core-y += arch/arm/kernel/ arch/arm/mm/ arch/arm/common/
+6
arch/arm/include/asm/hypervisor.h
··· 1 + #ifndef _ASM_ARM_HYPERVISOR_H 2 + #define _ASM_ARM_HYPERVISOR_H 3 + 4 + #include <asm/xen/hypervisor.h> 5 + 6 + #endif
+19
arch/arm/include/asm/xen/hypervisor.h
··· 1 + #ifndef _ASM_ARM_XEN_HYPERVISOR_H 2 + #define _ASM_ARM_XEN_HYPERVISOR_H 3 + 4 + extern struct shared_info *HYPERVISOR_shared_info; 5 + extern struct start_info *xen_start_info; 6 + 7 + /* Lazy mode for batching updates / context switch */ 8 + enum paravirt_lazy_mode { 9 + PARAVIRT_LAZY_NONE, 10 + PARAVIRT_LAZY_MMU, 11 + PARAVIRT_LAZY_CPU, 12 + }; 13 + 14 + static inline enum paravirt_lazy_mode paravirt_get_lazy_mode(void) 15 + { 16 + return PARAVIRT_LAZY_NONE; 17 + } 18 + 19 + #endif /* _ASM_ARM_XEN_HYPERVISOR_H */
+69
arch/arm/include/asm/xen/interface.h
··· 1 + /****************************************************************************** 2 + * Guest OS interface to ARM Xen. 3 + * 4 + * Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Citrix, 2012 5 + */ 6 + 7 + #ifndef _ASM_ARM_XEN_INTERFACE_H 8 + #define _ASM_ARM_XEN_INTERFACE_H 9 + 10 + #include <linux/types.h> 11 + 12 + #define __DEFINE_GUEST_HANDLE(name, type) \ 13 + typedef type * __guest_handle_ ## name 14 + 15 + #define DEFINE_GUEST_HANDLE_STRUCT(name) \ 16 + __DEFINE_GUEST_HANDLE(name, struct name) 17 + #define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name) 18 + #define GUEST_HANDLE(name) __guest_handle_ ## name 19 + 20 + #define set_xen_guest_handle(hnd, val) \ 21 + do { \ 22 + if (sizeof(hnd) == 8) \ 23 + *(uint64_t *)&(hnd) = 0; \ 24 + (hnd) = val; \ 25 + } while (0) 26 + 27 + #ifndef __ASSEMBLY__ 28 + /* Explicitly size integers that represent pfns in the interface with 29 + * Xen so that we can have one ABI that works for 32 and 64 bit guests. */ 30 + typedef uint64_t xen_pfn_t; 31 + /* Guest handles for primitive C types. */ 32 + __DEFINE_GUEST_HANDLE(uchar, unsigned char); 33 + __DEFINE_GUEST_HANDLE(uint, unsigned int); 34 + __DEFINE_GUEST_HANDLE(ulong, unsigned long); 35 + DEFINE_GUEST_HANDLE(char); 36 + DEFINE_GUEST_HANDLE(int); 37 + DEFINE_GUEST_HANDLE(long); 38 + DEFINE_GUEST_HANDLE(void); 39 + DEFINE_GUEST_HANDLE(uint64_t); 40 + DEFINE_GUEST_HANDLE(uint32_t); 41 + DEFINE_GUEST_HANDLE(xen_pfn_t); 42 + 43 + /* Maximum number of virtual CPUs in multi-processor guests. */ 44 + #define MAX_VIRT_CPUS 1 45 + 46 + struct arch_vcpu_info { }; 47 + struct arch_shared_info { }; 48 + 49 + /* TODO: Move pvclock definitions some place arch independent */ 50 + struct pvclock_vcpu_time_info { 51 + u32 version; 52 + u32 pad0; 53 + u64 tsc_timestamp; 54 + u64 system_time; 55 + u32 tsc_to_system_mul; 56 + s8 tsc_shift; 57 + u8 flags; 58 + u8 pad[2]; 59 + } __attribute__((__packed__)); /* 32 bytes */ 60 + 61 + /* It is OK to have a 12 bytes struct with no padding because it is packed */ 62 + struct pvclock_wall_clock { 63 + u32 version; 64 + u32 sec; 65 + u32 nsec; 66 + } __attribute__((__packed__)); 67 + #endif 68 + 69 + #endif /* _ASM_ARM_XEN_INTERFACE_H */
+1
arch/arm/xen/Makefile
··· 1 + obj-y := enlighten.o
+35
arch/arm/xen/enlighten.c
··· 1 + #include <xen/xen.h> 2 + #include <xen/interface/xen.h> 3 + #include <xen/interface/memory.h> 4 + #include <xen/platform_pci.h> 5 + #include <asm/xen/hypervisor.h> 6 + #include <asm/xen/hypercall.h> 7 + #include <linux/module.h> 8 + 9 + struct start_info _xen_start_info; 10 + struct start_info *xen_start_info = &_xen_start_info; 11 + EXPORT_SYMBOL_GPL(xen_start_info); 12 + 13 + enum xen_domain_type xen_domain_type = XEN_NATIVE; 14 + EXPORT_SYMBOL_GPL(xen_domain_type); 15 + 16 + struct shared_info xen_dummy_shared_info; 17 + struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info; 18 + 19 + DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu); 20 + 21 + /* TODO: to be removed */ 22 + __read_mostly int xen_have_vector_callback; 23 + EXPORT_SYMBOL_GPL(xen_have_vector_callback); 24 + 25 + int xen_platform_pci_unplug = XEN_UNPLUG_ALL; 26 + EXPORT_SYMBOL_GPL(xen_platform_pci_unplug); 27 + 28 + int xen_remap_domain_mfn_range(struct vm_area_struct *vma, 29 + unsigned long addr, 30 + unsigned long mfn, int nr, 31 + pgprot_t prot, unsigned domid) 32 + { 33 + return -ENOSYS; 34 + } 35 + EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
+1 -1
include/xen/xen.h
··· 23 23 #include <xen/interface/xen.h> 24 24 #include <asm/xen/hypervisor.h> 25 25 26 - #define xen_initial_domain() (xen_pv_domain() && \ 26 + #define xen_initial_domain() (xen_domain() && \ 27 27 xen_start_info->flags & SIF_INITDOMAIN) 28 28 #else /* !CONFIG_XEN_DOM0 */ 29 29 #define xen_initial_domain() (0)