svn commit: r216956 - in head/sys: conf dev/xen/balloon dev/xen/blkfront dev/xen/netfront dev/xen/xenpci i386/include i386/include/xen

Robert Watson rwatson at FreeBSD.org
Tue Jan 4 14:49:55 UTC 2011


Author: rwatson
Date: Tue Jan  4 14:49:54 2011
New Revision: 216956
URL: http://svn.freebsd.org/changeset/base/216956

Log:
  Make "options XENHVM" compile for i386, not just amd64 -- a largely
  mechanical change.  This opens the door for using PV device drivers
  under Xen HVM on i386, as well as more general harmonisation of i386
  and amd64 Xen support in FreeBSD.
  
  Reviewed by:    cperciva
  MFC after:      3 weeks

Modified:
  head/sys/conf/options.i386
  head/sys/dev/xen/balloon/balloon.c
  head/sys/dev/xen/blkfront/blkfront.c
  head/sys/dev/xen/netfront/netfront.c
  head/sys/dev/xen/xenpci/evtchn.c
  head/sys/i386/include/pcpu.h
  head/sys/i386/include/pmap.h
  head/sys/i386/include/xen/hypercall.h
  head/sys/i386/include/xen/xen-os.h
  head/sys/i386/include/xen/xenpmap.h
  head/sys/i386/include/xen/xenvar.h

Modified: head/sys/conf/options.i386
==============================================================================
--- head/sys/conf/options.i386	Tue Jan  4 14:13:09 2011	(r216955)
+++ head/sys/conf/options.i386	Tue Jan  4 14:49:54 2011	(r216956)
@@ -118,3 +118,4 @@ BPF_JITTER		opt_bpf.h
 
 NATIVE			opt_global.h
 XEN			opt_global.h
+XENHVM			opt_global.h

Modified: head/sys/dev/xen/balloon/balloon.c
==============================================================================
--- head/sys/dev/xen/balloon/balloon.c	Tue Jan  4 14:13:09 2011	(r216955)
+++ head/sys/dev/xen/balloon/balloon.c	Tue Jan  4 14:49:54 2011	(r216956)
@@ -41,8 +41,8 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>
 
 #include <machine/xen/xen-os.h>
-#include <machine/xen/xenfunc.h>
 #include <machine/xen/xenvar.h>
+#include <machine/xen/xenfunc.h>
 #include <xen/hypervisor.h>
 #include <xen/xenstore/xenstorevar.h>
 

Modified: head/sys/dev/xen/blkfront/blkfront.c
==============================================================================
--- head/sys/dev/xen/blkfront/blkfront.c	Tue Jan  4 14:13:09 2011	(r216955)
+++ head/sys/dev/xen/blkfront/blkfront.c	Tue Jan  4 14:49:54 2011	(r216956)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 
 #include <machine/_inttypes.h>
 #include <machine/xen/xen-os.h>
+#include <machine/xen/xenvar.h>
 #include <machine/xen/xenfunc.h>
 
 #include <xen/hypervisor.h>

Modified: head/sys/dev/xen/netfront/netfront.c
==============================================================================
--- head/sys/dev/xen/netfront/netfront.c	Tue Jan  4 14:13:09 2011	(r216955)
+++ head/sys/dev/xen/netfront/netfront.c	Tue Jan  4 14:49:54 2011	(r216956)
@@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$");
 
 #include <machine/xen/xen-os.h>
 #include <machine/xen/xenfunc.h>
+#include <machine/xen/xenvar.h>
 #include <xen/hypervisor.h>
 #include <xen/xen_intr.h>
 #include <xen/evtchn.h>

Modified: head/sys/dev/xen/xenpci/evtchn.c
==============================================================================
--- head/sys/dev/xen/xenpci/evtchn.c	Tue Jan  4 14:13:09 2011	(r216955)
+++ head/sys/dev/xen/xenpci/evtchn.c	Tue Jan  4 14:49:54 2011	(r216956)
@@ -51,13 +51,19 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/xen/xenpci/xenpcivar.h>
 
+#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)

Modified: head/sys/i386/include/pcpu.h
==============================================================================
--- head/sys/i386/include/pcpu.h	Tue Jan  4 14:13:09 2011	(r216955)
+++ head/sys/i386/include/pcpu.h	Tue Jan  4 14:49:54 2011	(r216956)
@@ -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							\

Modified: head/sys/i386/include/pmap.h
==============================================================================
--- head/sys/i386/include/pmap.h	Tue Jan  4 14:13:09 2011	(r216955)
+++ head/sys/i386/include/pmap.h	Tue Jan  4 14:49:54 2011	(r216956)
@@ -208,7 +208,7 @@ extern pd_entry_t *IdlePTD;	/* physical 
  */
 #define	vtophys(va)	pmap_kextract((vm_offset_t)(va))
 
-#ifdef XEN
+#if defined(XEN)
 #include <sys/param.h>
 #include <machine/xen/xen-os.h>
 #include <machine/xen/xenvar.h>
@@ -315,7 +315,9 @@ pmap_kextract(vm_offset_t va)
 	}
 	return (pa);
 }
+#endif
 
+#if !defined(XEN)
 #define PT_UPDATES_FLUSH()
 #endif
 

Modified: head/sys/i386/include/xen/hypercall.h
==============================================================================
--- head/sys/i386/include/xen/hypercall.h	Tue Jan  4 14:13:09 2011	(r216955)
+++ head/sys/i386/include/xen/hypercall.h	Tue Jan  4 14:49:54 2011	(r216956)
@@ -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);

Modified: head/sys/i386/include/xen/xen-os.h
==============================================================================
--- head/sys/i386/include/xen/xen-os.h	Tue Jan  4 14:13:09 2011	(r216955)
+++ head/sys/i386/include/xen/xen-os.h	Tue Jan  4 14:49:54 2011	(r216956)
@@ -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() 

Modified: head/sys/i386/include/xen/xenpmap.h
==============================================================================
--- head/sys/i386/include/xen/xenpmap.h	Tue Jan  4 14:13:09 2011	(r216955)
+++ head/sys/i386/include/xen/xenpmap.h	Tue Jan  4 14:49:54 2011	(r216956)
@@ -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 l
 	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_ */

Modified: head/sys/i386/include/xen/xenvar.h
==============================================================================
--- head/sys/i386/include/xen/xenvar.h	Tue Jan  4 14:13:09 2011	(r216955)
+++ head/sys/i386/include/xen/xenvar.h	Tue Jan  4 14:49:54 2011	(r216956)
@@ -28,6 +28,11 @@
 
 #ifndef XENVAR_H_
 #define XENVAR_H_
+
+#include <machine/xen/features.h>
+
+#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 <machine/xen/features.h>
 
 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_pag
 
 void  xen_destroy_contiguous_region(void * addr, int npages);
 
+#elif defined(XENHVM)
+
+#define	PFNTOMFN(pa)	(pa)
+#define	MFNTOPFN(ma)	(ma)
+
+#endif /* !XEN && !XENHVM */
+
 #endif


More information about the svn-src-all mailing list