diff --git a/sys/conf/options.i386 b/sys/conf/options.i386 index 333ec6a8dfbf..dd888b1be1ab 100644 --- a/sys/conf/options.i386 +++ b/sys/conf/options.i386 @@ -118,3 +118,4 @@ BPF_JITTER opt_bpf.h NATIVE opt_global.h XEN opt_global.h +XENHVM opt_global.h diff --git a/sys/dev/xen/balloon/balloon.c b/sys/dev/xen/balloon/balloon.c index eb55dfc7b4cd..dff80ba3e8f1 100644 --- a/sys/dev/xen/balloon/balloon.c +++ b/sys/dev/xen/balloon/balloon.c @@ -41,8 +41,8 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include +#include #include #include diff --git a/sys/dev/xen/blkfront/blkfront.c b/sys/dev/xen/blkfront/blkfront.c index 2e08bb1d2108..81c0e8b8b8c7 100644 --- a/sys/dev/xen/blkfront/blkfront.c +++ b/sys/dev/xen/blkfront/blkfront.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include diff --git a/sys/dev/xen/netfront/netfront.c b/sys/dev/xen/netfront/netfront.c index 423df9761546..61b14af32712 100644 --- a/sys/dev/xen/netfront/netfront.c +++ b/sys/dev/xen/netfront/netfront.c @@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include diff --git a/sys/dev/xen/xenpci/evtchn.c b/sys/dev/xen/xenpci/evtchn.c index ea53a7e371c0..96c83f0a62b0 100644 --- a/sys/dev/xen/xenpci/evtchn.c +++ b/sys/dev/xen/xenpci/evtchn.c @@ -51,13 +51,19 @@ __FBSDID("$FreeBSD$"); #include +#if defined(__i386__) +#define __ffs(word) ffs(word) +#elif defined(__amd64__) static inline unsigned long __ffs(unsigned long word) { __asm__("bsfq %1,%0" :"=r" (word) - :"rm" (word)); + :"rm" (word)); /* XXXRW: why no "cc"? */ return word; } +#else +#error "evtchn: unsupported architecture" +#endif #define is_valid_evtchn(x) ((x) != 0) #define evtchn_from_irq(x) (irq_evtchn[irq].evtchn) diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h index 8906eda38cda..aaba41362eaa 100644 --- a/sys/i386/include/pcpu.h +++ b/sys/i386/include/pcpu.h @@ -44,13 +44,16 @@ * other processors" */ -#ifdef XEN +#if defined(XEN) || defined(XENHVM) #ifndef NR_VIRQS #define NR_VIRQS 24 #endif #ifndef NR_IPIS #define NR_IPIS 2 #endif +#endif + +#if defined(XEN) /* These are peridically updated in shared_info, and then copied here. */ struct shadow_time_info { @@ -72,8 +75,18 @@ struct shadow_time_info { int pc_callfunc_irq; \ int pc_virq_to_irq[NR_VIRQS]; \ int pc_ipi_to_irq[NR_IPIS] -#else + +#elif defined(XENHVM) + +#define PCPU_XEN_FIELDS \ + ; \ + unsigned int pc_last_processed_l1i; \ + unsigned int pc_last_processed_l2i + +#else /* !XEN && !XENHVM */ + #define PCPU_XEN_FIELDS + #endif #define PCPU_MD_FIELDS \ diff --git a/sys/i386/include/pmap.h b/sys/i386/include/pmap.h index a710f4b3e29e..3d09588ce93a 100644 --- a/sys/i386/include/pmap.h +++ b/sys/i386/include/pmap.h @@ -208,7 +208,7 @@ extern pd_entry_t *IdlePTD; /* physical address of "Idle" state directory */ */ #define vtophys(va) pmap_kextract((vm_offset_t)(va)) -#ifdef XEN +#if defined(XEN) #include #include #include @@ -315,7 +315,9 @@ pmap_kextract(vm_offset_t va) } return (pa); } +#endif +#if !defined(XEN) #define PT_UPDATES_FLUSH() #endif diff --git a/sys/i386/include/xen/hypercall.h b/sys/i386/include/xen/hypercall.h index 2631a9b58e6f..edc13f4e6f51 100644 --- a/sys/i386/include/xen/hypercall.h +++ b/sys/i386/include/xen/hypercall.h @@ -234,9 +234,14 @@ HYPERVISOR_memory_op( return _hypercall2(int, memory_op, cmd, arg); } +#if defined(XEN) int HYPERVISOR_multicall(multicall_entry_t *, int); static inline int _HYPERVISOR_multicall( +#else /* XENHVM */ +static inline int +HYPERVISOR_multicall( +#endif void *call_list, int nr_calls) { return _hypercall2(int, multicall, call_list, nr_calls); diff --git a/sys/i386/include/xen/xen-os.h b/sys/i386/include/xen/xen-os.h index 4aaeb58e9bbe..e6518a40fcfe 100644 --- a/sys/i386/include/xen/xen-os.h +++ b/sys/i386/include/xen/xen-os.h @@ -12,7 +12,7 @@ #define CONFIG_X86_PAE #endif -#if defined(XEN) && !defined(__XEN_INTERFACE_VERSION__) +#if !defined(__XEN_INTERFACE_VERSION__) /* * Can update to a more recent version when we implement * the hypercall page @@ -95,6 +95,8 @@ void printk(const char *fmt, ...); /* some function prototypes */ void trap_init(void); +#ifndef XENHVM + /* * STI/CLI equivalents. These basically set and clear the virtual * event_enable flag in teh shared_info structure. Note that when @@ -164,6 +166,7 @@ do { \ #define spin_lock_irqsave mtx_lock_irqsave #define spin_unlock_irqrestore mtx_unlock_irqrestore +#endif #ifdef SMP #define smp_mb() mb() diff --git a/sys/i386/include/xen/xenpmap.h b/sys/i386/include/xen/xenpmap.h index b8a545e55d3b..169e40884453 100644 --- a/sys/i386/include/xen/xenpmap.h +++ b/sys/i386/include/xen/xenpmap.h @@ -35,6 +35,8 @@ #ifndef _XEN_XENPMAP_H_ #define _XEN_XENPMAP_H_ + +#if defined(XEN) void _xen_queue_pt_update(vm_paddr_t, vm_paddr_t, char *, int); void xen_pt_switch(vm_paddr_t); void xen_set_ldt(vm_paddr_t, unsigned long); @@ -230,5 +232,15 @@ phys_to_machine_mapping_valid(unsigned long pfn) return xen_phys_machine[pfn] != INVALID_P2M_ENTRY; } +#elif defined(XENHVM) + +#define set_phys_to_machine(pfn, mfn) ((void)0) +#define phys_to_machine_mapping_valid(pfn) (TRUE) + +#if !defined(PAE) +#define vtomach(va) pmap_kextract((vm_offset_t) (va)) +#endif + +#endif /* !XEN && !XENHVM */ #endif /* _XEN_XENPMAP_H_ */ diff --git a/sys/i386/include/xen/xenvar.h b/sys/i386/include/xen/xenvar.h index 1110f8506ae0..4f8c857fb36d 100644 --- a/sys/i386/include/xen/xenvar.h +++ b/sys/i386/include/xen/xenvar.h @@ -28,6 +28,11 @@ #ifndef XENVAR_H_ #define XENVAR_H_ + +#include + +#if defined(XEN) + #define XBOOTUP 0x1 #define XPMAP 0x2 extern int xendebug_flags; @@ -36,7 +41,6 @@ extern int xendebug_flags; #else #define XENPRINTF printf #endif -#include extern xen_pfn_t *xen_phys_machine; extern xen_pfn_t *xen_pfn_to_mfn_frame_list[16]; @@ -101,4 +105,11 @@ int xen_create_contiguous_region(vm_page_t pages, int npages); void xen_destroy_contiguous_region(void * addr, int npages); +#elif defined(XENHVM) + +#define PFNTOMFN(pa) (pa) +#define MFNTOPFN(ma) (ma) + +#endif /* !XEN && !XENHVM */ + #endif