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
This commit is contained in:
Robert Watson 2011-01-04 14:49:54 +00:00
parent 641c6c5c1a
commit 2913e88c91
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=216956
11 changed files with 62 additions and 7 deletions

View File

@ -118,3 +118,4 @@ BPF_JITTER opt_bpf.h
NATIVE opt_global.h
XEN opt_global.h
XENHVM opt_global.h

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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)

View File

@ -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 \

View File

@ -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 <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

View File

@ -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);

View File

@ -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()

View File

@ -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_ */

View File

@ -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_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