summaryrefslogtreecommitdiffstats
path: root/sys/i386/xen
diff options
context:
space:
mode:
authorgibbs <gibbs@FreeBSD.org>2013-08-29 19:52:18 +0000
committergibbs <gibbs@FreeBSD.org>2013-08-29 19:52:18 +0000
commitfcdbf70fd9ffe66a2cd744ca6626d7f87b39e593 (patch)
tree645c89eddfbfb23b9b30e45b882f5beb39a4a267 /sys/i386/xen
parentd60bb760ec3e7d8592b384e51bf1e6402f0e8700 (diff)
downloadFreeBSD-src-fcdbf70fd9ffe66a2cd744ca6626d7f87b39e593.zip
FreeBSD-src-fcdbf70fd9ffe66a2cd744ca6626d7f87b39e593.tar.gz
Implement vector callback for PVHVM and unify event channel implementations
Re-structure Xen HVM support so that: - Xen is detected and hypercalls can be performed very early in system startup. - Xen interrupt services are implemented using FreeBSD's native interrupt delivery infrastructure. - the Xen interrupt service implementation is shared between PV and HVM guests. - Xen interrupt handlers can optionally use a filter handler in order to avoid the overhead of dispatch to an interrupt thread. - interrupt load can be distributed among all available CPUs. - the overhead of accessing the emulated local and I/O apics on HVM is removed for event channel port events. - a similar optimization can eventually, and fairly easily, be used to optimize MSI. Early Xen detection, HVM refactoring, PVHVM interrupt infrastructure, and misc Xen cleanups: Sponsored by: Spectra Logic Corporation Unification of PV & HVM interrupt infrastructure, bug fixes, and misc Xen cleanups: Submitted by: Roger Pau Monné Sponsored by: Citrix Systems R&D sys/x86/x86/local_apic.c: sys/amd64/include/apicvar.h: sys/i386/include/apicvar.h: sys/amd64/amd64/apic_vector.S: sys/i386/i386/apic_vector.s: sys/amd64/amd64/machdep.c: sys/i386/i386/machdep.c: sys/i386/xen/exception.s: sys/x86/include/segments.h: Reserve IDT vector 0x93 for the Xen event channel upcall interrupt handler. On Hypervisors that support the direct vector callback feature, we can request that this vector be called directly by an injected HVM interrupt event, instead of a simulated PCI interrupt on the Xen platform PCI device. This avoids all of the overhead of dealing with the emulated I/O APIC and local APIC. It also means that the Hypervisor can inject these events on any CPU, allowing upcalls for different ports to be handled in parallel. sys/amd64/amd64/mp_machdep.c: sys/i386/i386/mp_machdep.c: Map Xen per-vcpu area during AP startup. sys/amd64/include/intr_machdep.h: sys/i386/include/intr_machdep.h: Increase the FreeBSD IRQ vector table to include space for event channel interrupt sources. sys/amd64/include/pcpu.h: sys/i386/include/pcpu.h: Remove Xen HVM per-cpu variable data. These fields are now allocated via the dynamic per-cpu scheme. See xen_intr.c for details. sys/amd64/include/xen/hypercall.h: sys/dev/xen/blkback/blkback.c: sys/i386/include/xen/xenvar.h: sys/i386/xen/clock.c: sys/i386/xen/xen_machdep.c: sys/xen/gnttab.c: Prefer FreeBSD primatives to Linux ones in Xen support code. sys/amd64/include/xen/xen-os.h: sys/i386/include/xen/xen-os.h: sys/xen/xen-os.h: sys/dev/xen/balloon/balloon.c: sys/dev/xen/blkback/blkback.c: sys/dev/xen/blkfront/blkfront.c: sys/dev/xen/console/xencons_ring.c: sys/dev/xen/control/control.c: sys/dev/xen/netback/netback.c: sys/dev/xen/netfront/netfront.c: sys/dev/xen/xenpci/xenpci.c: sys/i386/i386/machdep.c: sys/i386/include/pmap.h: sys/i386/include/xen/xenfunc.h: sys/i386/isa/npx.c: sys/i386/xen/clock.c: sys/i386/xen/mp_machdep.c: sys/i386/xen/mptable.c: sys/i386/xen/xen_clock_util.c: sys/i386/xen/xen_machdep.c: sys/i386/xen/xen_rtc.c: sys/xen/evtchn/evtchn_dev.c: sys/xen/features.c: sys/xen/gnttab.c: sys/xen/gnttab.h: sys/xen/hvm.h: sys/xen/xenbus/xenbus.c: sys/xen/xenbus/xenbus_if.m: sys/xen/xenbus/xenbusb_front.c: sys/xen/xenbus/xenbusvar.h: sys/xen/xenstore/xenstore.c: sys/xen/xenstore/xenstore_dev.c: sys/xen/xenstore/xenstorevar.h: Pull common Xen OS support functions/settings into xen/xen-os.h. sys/amd64/include/xen/xen-os.h: sys/i386/include/xen/xen-os.h: sys/xen/xen-os.h: Remove constants, macros, and functions unused in FreeBSD's Xen support. sys/xen/xen-os.h: sys/i386/xen/xen_machdep.c: sys/x86/xen/hvm.c: Introduce new functions xen_domain(), xen_pv_domain(), and xen_hvm_domain(). These are used in favor of #ifdefs so that FreeBSD can dynamically detect and adapt to the presence of a hypervisor. The goal is to have an HVM optimized GENERIC, but more is necessary before this is possible. sys/amd64/amd64/machdep.c: sys/dev/xen/xenpci/xenpcivar.h: sys/dev/xen/xenpci/xenpci.c: sys/x86/xen/hvm.c: sys/sys/kernel.h: Refactor magic ioport, Hypercall table and Hypervisor shared information page setup, and move it to a dedicated HVM support module. HVM mode initialization is now triggered during the SI_SUB_HYPERVISOR phase of system startup. This currently occurs just after the kernel VM is fully setup which is just enough infrastructure to allow the hypercall table and shared info page to be properly mapped. sys/xen/hvm.h: sys/x86/xen/hvm.c: Add definitions and a method for configuring Hypervisor event delievery via a direct vector callback. sys/amd64/include/xen/xen-os.h: sys/x86/xen/hvm.c: sys/conf/files: sys/conf/files.amd64: sys/conf/files.i386: Adjust kernel build to reflect the refactoring of early Xen startup code and Xen interrupt services. sys/dev/xen/blkback/blkback.c: sys/dev/xen/blkfront/blkfront.c: sys/dev/xen/blkfront/block.h: sys/dev/xen/control/control.c: sys/dev/xen/evtchn/evtchn_dev.c: sys/dev/xen/netback/netback.c: sys/dev/xen/netfront/netfront.c: sys/xen/xenstore/xenstore.c: sys/xen/evtchn/evtchn_dev.c: sys/dev/xen/console/console.c: sys/dev/xen/console/xencons_ring.c Adjust drivers to use new xen_intr_*() API. sys/dev/xen/blkback/blkback.c: Since blkback defers all event handling to a taskqueue, convert this task queue to a "fast" taskqueue, and schedule it via an interrupt filter. This avoids an unnecessary ithread context switch. sys/xen/xenstore/xenstore.c: The xenstore driver is MPSAFE. Indicate as much when registering its interrupt handler. sys/xen/xenbus/xenbus.c: sys/xen/xenbus/xenbusvar.h: Remove unused event channel APIs. sys/xen/evtchn.h: Remove all kernel Xen interrupt service API definitions from this file. It is now only used for structure and ioctl definitions related to the event channel userland device driver. Update the definitions in this file to match those from NetBSD. Implementing this interface will be necessary for Dom0 support. sys/xen/evtchn/evtchnvar.h: Add a header file for implemenation internal APIs related to managing event channels event delivery. This is used to allow, for example, the event channel userland device driver to access low-level routines that typical kernel consumers of event channel services should never access. sys/xen/interface/event_channel.h: sys/xen/xen_intr.h: Standardize on the evtchn_port_t type for referring to an event channel port id. In order to prevent low-level event channel APIs from leaking to kernel consumers who should not have access to this data, the type is defined twice: Once in the Xen provided event_channel.h, and again in xen/xen_intr.h. The double declaration is protected by __XEN_EVTCHN_PORT_DEFINED__ to ensure it is never declared twice within a given compilation unit. sys/xen/xen_intr.h: sys/xen/evtchn/evtchn.c: sys/x86/xen/xen_intr.c: sys/dev/xen/xenpci/evtchn.c: sys/dev/xen/xenpci/xenpcivar.h: New implementation of Xen interrupt services. This is similar in many respects to the i386 PV implementation with the exception that events for bound to event channel ports (i.e. not IPI, virtual IRQ, or physical IRQ) are further optimized to avoid mask/unmask operations that aren't necessary for these edge triggered events. Stubs exist for supporting physical IRQ binding, but will need additional work before this implementation can be fully shared between PV and HVM. sys/amd64/amd64/mp_machdep.c: sys/i386/i386/mp_machdep.c: sys/i386/xen/mp_machdep.c sys/x86/xen/hvm.c: Add support for placing vcpu_info into an arbritary memory page instead of using HYPERVISOR_shared_info->vcpu_info. This allows the creation of domains with more than 32 vcpus. sys/i386/i386/machdep.c: sys/i386/xen/clock.c: sys/i386/xen/xen_machdep.c: sys/i386/xen/exception.s: Add support for new event channle implementation.
Diffstat (limited to 'sys/i386/xen')
-rw-r--r--sys/i386/xen/clock.c58
-rw-r--r--sys/i386/xen/exception.s2
-rw-r--r--sys/i386/xen/mp_machdep.c89
-rw-r--r--sys/i386/xen/mptable.c2
-rw-r--r--sys/i386/xen/xen_clock_util.c3
-rw-r--r--sys/i386/xen/xen_machdep.c48
-rw-r--r--sys/i386/xen/xen_rtc.c10
7 files changed, 128 insertions, 84 deletions
diff --git a/sys/i386/xen/clock.c b/sys/i386/xen/clock.c
index a10b546..524fa14 100644
--- a/sys/i386/xen/clock.c
+++ b/sys/i386/xen/clock.c
@@ -84,7 +84,7 @@ __FBSDID("$FreeBSD$");
#include <vm/pmap.h>
#include <machine/pmap.h>
#include <xen/hypervisor.h>
-#include <machine/xen/xen-os.h>
+#include <xen/xen-os.h>
#include <machine/xen/xenfunc.h>
#include <xen/interface/vcpu.h>
#include <machine/cpu.h>
@@ -133,6 +133,8 @@ static uint64_t processed_system_time; /* stime (ns) at last processing. */
static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};
+int ap_cpu_initclocks(int cpu);
+
SYSCTL_INT(_machdep, OID_AUTO, independent_wallclock,
CTLFLAG_RW, &independent_wallclock, 0, "");
SYSCTL_INT(_machdep, OID_AUTO, xen_disable_rtc_set,
@@ -257,9 +259,11 @@ static void __get_time_values_from_xen(void)
struct vcpu_time_info *src;
struct shadow_time_info *dst;
uint32_t pre_version, post_version;
+ struct pcpu *pc;
+ pc = pcpu_find(smp_processor_id());
src = &s->vcpu_info[smp_processor_id()].time;
- dst = &per_cpu(shadow_time, smp_processor_id());
+ dst = &pc->pc_shadow_time;
spinlock_enter();
do {
@@ -283,9 +287,11 @@ static inline int time_values_up_to_date(int cpu)
{
struct vcpu_time_info *src;
struct shadow_time_info *dst;
+ struct pcpu *pc;
src = &HYPERVISOR_shared_info->vcpu_info[cpu].time;
- dst = &per_cpu(shadow_time, cpu);
+ pc = pcpu_find(cpu);
+ dst = &pc->pc_shadow_time;
rmb();
return (dst->version == src->version);
@@ -320,7 +326,8 @@ clkintr(void *arg)
{
int64_t now;
int cpu = smp_processor_id();
- struct shadow_time_info *shadow = &per_cpu(shadow_time, cpu);
+ struct pcpu *pc = pcpu_find(cpu);
+ struct shadow_time_info *shadow = &pc->pc_shadow_time;
struct xen_et_state *state = DPCPU_PTR(et_state);
do {
@@ -364,8 +371,10 @@ getit(void)
struct shadow_time_info *shadow;
uint64_t time;
uint32_t local_time_version;
+ struct pcpu *pc;
- shadow = &per_cpu(shadow_time, smp_processor_id());
+ pc = pcpu_find(smp_processor_id());
+ shadow = &pc->pc_shadow_time;
do {
local_time_version = shadow->version;
@@ -492,12 +501,14 @@ void
timer_restore(void)
{
struct xen_et_state *state = DPCPU_PTR(et_state);
+ struct pcpu *pc;
/* Get timebases for new environment. */
__get_time_values_from_xen();
/* Reset our own concept of passage of system time. */
- processed_system_time = per_cpu(shadow_time, 0).system_timestamp;
+ pc = pcpu_find(0);
+ processed_system_time = pc->pc_shadow_time.system_timestamp;
state->next = processed_system_time;
}
@@ -508,10 +519,13 @@ startrtclock()
uint64_t __cpu_khz;
uint32_t cpu_khz;
struct vcpu_time_info *info;
+ struct pcpu *pc;
+
+ pc = pcpu_find(0);
/* initialize xen values */
__get_time_values_from_xen();
- processed_system_time = per_cpu(shadow_time, 0).system_timestamp;
+ processed_system_time = pc->pc_shadow_time.system_timestamp;
__cpu_khz = 1000000ULL << 32;
info = &HYPERVISOR_shared_info->vcpu_info[0].time;
@@ -594,8 +608,10 @@ domu_resettodr(void)
int s;
dom0_op_t op;
struct shadow_time_info *shadow;
+ struct pcpu *pc;
- shadow = &per_cpu(shadow_time, smp_processor_id());
+ pc = pcpu_find(smp_processor_id());
+ shadow = &pc->pc_shadow_time;
if (xen_disable_rtc_set)
return;
@@ -773,6 +789,7 @@ xen_et_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
struct xen_et_state *state = DPCPU_PTR(et_state);
struct shadow_time_info *shadow;
int64_t fperiod;
+ struct pcpu *pc;
__get_time_values_from_xen();
@@ -788,7 +805,8 @@ xen_et_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
else
fperiod = state->period;
- shadow = &per_cpu(shadow_time, smp_processor_id());
+ pc = pcpu_find(smp_processor_id());
+ shadow = &pc->pc_shadow_time;
state->next = shadow->system_timestamp + get_nsec_offset(shadow);
state->next += fperiod;
HYPERVISOR_set_timer_op(state->next + 50000);
@@ -811,11 +829,11 @@ xen_et_stop(struct eventtimer *et)
void
cpu_initclocks(void)
{
- unsigned int time_irq;
+ xen_intr_handle_t time_irq;
int error;
HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, 0, NULL);
- error = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "cpu0:timer",
+ error = xen_intr_bind_virq(root_bus, VIRQ_TIMER, 0,
clkintr, NULL, NULL, INTR_TYPE_CLK, &time_irq);
if (error)
panic("failed to register clock interrupt\n");
@@ -840,13 +858,11 @@ cpu_initclocks(void)
int
ap_cpu_initclocks(int cpu)
{
- char buf[MAXCOMLEN + 1];
- unsigned int time_irq;
+ xen_intr_handle_t time_irq;
int error;
HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL);
- snprintf(buf, sizeof(buf), "cpu%d:timer", cpu);
- error = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, buf,
+ error = xen_intr_bind_virq(root_bus, VIRQ_TIMER, cpu,
clkintr, NULL, NULL, INTR_TYPE_CLK, &time_irq);
if (error)
panic("failed to register clock interrupt\n");
@@ -859,7 +875,10 @@ xen_get_timecount(struct timecounter *tc)
{
uint64_t clk;
struct shadow_time_info *shadow;
- shadow = &per_cpu(shadow_time, smp_processor_id());
+ struct pcpu *pc;
+
+ pc = pcpu_find(smp_processor_id());
+ shadow = &pc->pc_shadow_time;
__get_time_values_from_xen();
@@ -876,13 +895,6 @@ get_system_time(int ticks)
return processed_system_time + (ticks * NS_PER_TICK);
}
-void
-idle_block(void)
-{
-
- HYPERVISOR_sched_op(SCHEDOP_block, 0);
-}
-
int
timer_spkr_acquire(void)
{
diff --git a/sys/i386/xen/exception.s b/sys/i386/xen/exception.s
index e965ffd..95f1c0e 100644
--- a/sys/i386/xen/exception.s
+++ b/sys/i386/xen/exception.s
@@ -168,7 +168,7 @@ call_evtchn_upcall:
jb critical_region_fixup
10: pushl %esp
- call evtchn_do_upcall
+ call xen_intr_handle_upcall
addl $4,%esp
/*
diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c
index 05531cb..407731a 100644
--- a/sys/i386/xen/mp_machdep.c
+++ b/sys/i386/xen/mp_machdep.c
@@ -87,7 +87,7 @@ __FBSDID("$FreeBSD$");
-#include <machine/xen/xen-os.h>
+#include <xen/xen-os.h>
#include <xen/evtchn.h>
#include <xen/xen_intr.h>
#include <xen/hypervisor.h>
@@ -102,9 +102,6 @@ extern struct pcpu __pcpu[];
static int bootAP;
static union descriptor *bootAPgdt;
-static char resched_name[NR_CPUS][15];
-static char callfunc_name[NR_CPUS][15];
-
/* Free these after use */
void *bootstacks[MAXCPU];
@@ -156,6 +153,10 @@ static cpuset_t hyperthreading_cpus_mask;
extern void Xhypervisor_callback(void);
extern void failsafe_callback(void);
extern void pmap_lazyfix_action(void);
+extern int ap_cpu_initclocks(int cpu);
+
+DPCPU_DEFINE(xen_intr_handle_t, ipi_port[NR_IPIS]);
+DPCPU_DEFINE(struct vcpu_info *, vcpu_info);
struct cpu_group *
cpu_topo(void)
@@ -461,49 +462,49 @@ cpu_mp_announce(void)
}
static int
-xen_smp_intr_init(unsigned int cpu)
+xen_smp_cpu_init(unsigned int cpu)
{
int rc;
- unsigned int irq;
-
- per_cpu(resched_irq, cpu) = per_cpu(callfunc_irq, cpu) = -1;
+ xen_intr_handle_t irq_handle;
- sprintf(resched_name[cpu], "resched%u", cpu);
- rc = bind_ipi_to_irqhandler(RESCHEDULE_VECTOR,
- cpu,
- resched_name[cpu],
- smp_reschedule_interrupt,
- INTR_TYPE_TTY, &irq);
+ DPCPU_ID_SET(cpu, ipi_port[RESCHEDULE_VECTOR], NULL);
+ DPCPU_ID_SET(cpu, ipi_port[CALL_FUNCTION_VECTOR], NULL);
- printf("[XEN] IPI cpu=%d irq=%d vector=RESCHEDULE_VECTOR (%d)\n",
- cpu, irq, RESCHEDULE_VECTOR);
-
- per_cpu(resched_irq, cpu) = irq;
-
- sprintf(callfunc_name[cpu], "callfunc%u", cpu);
- rc = bind_ipi_to_irqhandler(CALL_FUNCTION_VECTOR,
- cpu,
- callfunc_name[cpu],
- smp_call_function_interrupt,
- INTR_TYPE_TTY, &irq);
+ /*
+ * The PCPU variable pc_device is not initialized on i386 PV,
+ * so we have to use the root_bus device in order to setup
+ * the IPIs.
+ */
+ rc = xen_intr_bind_ipi(root_bus, RESCHEDULE_VECTOR,
+ cpu, smp_reschedule_interrupt, INTR_TYPE_TTY, &irq_handle);
if (rc < 0)
goto fail;
- per_cpu(callfunc_irq, cpu) = irq;
+ xen_intr_describe(irq_handle, "resched%u", cpu);
+ DPCPU_ID_SET(cpu, ipi_port[RESCHEDULE_VECTOR], irq_handle);
- printf("[XEN] IPI cpu=%d irq=%d vector=CALL_FUNCTION_VECTOR (%d)\n",
- cpu, irq, CALL_FUNCTION_VECTOR);
+ printf("[XEN] IPI cpu=%d port=%d vector=RESCHEDULE_VECTOR (%d)\n",
+ cpu, xen_intr_port(irq_handle), RESCHEDULE_VECTOR);
+
+ rc = xen_intr_bind_ipi(root_bus, CALL_FUNCTION_VECTOR,
+ cpu, smp_call_function_interrupt, INTR_TYPE_TTY, &irq_handle);
+ if (rc < 0)
+ goto fail;
+ xen_intr_describe(irq_handle, "callfunc%u", cpu);
+ DPCPU_ID_SET(cpu, ipi_port[CALL_FUNCTION_VECTOR], irq_handle);
+
+ printf("[XEN] IPI cpu=%d port=%d vector=CALL_FUNCTION_VECTOR (%d)\n",
+ cpu, xen_intr_port(irq_handle), CALL_FUNCTION_VECTOR);
-
if ((cpu != 0) && ((rc = ap_cpu_initclocks(cpu)) != 0))
goto fail;
return 0;
fail:
- if (per_cpu(resched_irq, cpu) >= 0)
- unbind_from_irqhandler(per_cpu(resched_irq, cpu));
- if (per_cpu(callfunc_irq, cpu) >= 0)
- unbind_from_irqhandler(per_cpu(callfunc_irq, cpu));
+ xen_intr_unbind(DPCPU_ID_GET(cpu, ipi_port[RESCHEDULE_VECTOR]));
+ DPCPU_ID_SET(cpu, ipi_port[RESCHEDULE_VECTOR], NULL);
+ xen_intr_unbind(DPCPU_ID_GET(cpu, ipi_port[CALL_FUNCTION_VECTOR]));
+ DPCPU_ID_SET(cpu, ipi_port[CALL_FUNCTION_VECTOR], NULL);
return rc;
}
@@ -513,7 +514,17 @@ xen_smp_intr_init_cpus(void *unused)
int i;
for (i = 0; i < mp_ncpus; i++)
- xen_smp_intr_init(i);
+ xen_smp_cpu_init(i);
+}
+
+static void
+xen_smp_intr_setup_cpus(void *unused)
+{
+ int i;
+
+ for (i = 0; i < mp_ncpus; i++)
+ DPCPU_ID_SET(i, vcpu_info,
+ &HYPERVISOR_shared_info->vcpu_info[i]);
}
#define MTOPSIZE (1<<(14 + PAGE_SHIFT))
@@ -959,6 +970,13 @@ start_ap(int apic_id)
return 0; /* return FAILURE */
}
+static void
+ipi_pcpu(int cpu, u_int ipi)
+{
+ KASSERT((ipi <= NR_IPIS), ("invalid IPI"));
+ xen_intr_signal(DPCPU_ID_GET(cpu, ipi_port[ipi]));
+}
+
/*
* send an IPI to a specific CPU.
*/
@@ -1246,5 +1264,6 @@ release_aps(void *dummy __unused)
ia32_pause();
}
SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL);
-SYSINIT(start_ipis, SI_SUB_INTR, SI_ORDER_ANY, xen_smp_intr_init_cpus, NULL);
+SYSINIT(start_ipis, SI_SUB_SMP, SI_ORDER_ANY, xen_smp_intr_init_cpus, NULL);
+SYSINIT(start_cpu, SI_SUB_INTR, SI_ORDER_ANY, xen_smp_intr_setup_cpus, NULL);
diff --git a/sys/i386/xen/mptable.c b/sys/i386/xen/mptable.c
index 0c1efe8..74cb9ab 100644
--- a/sys/i386/xen/mptable.c
+++ b/sys/i386/xen/mptable.c
@@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
#include <machine/apicvar.h>
#include <xen/hypervisor.h>
-#include <machine/xen/xen-os.h>
+#include <xen/xen-os.h>
#include <machine/smp.h>
#include <xen/interface/vcpu.h>
diff --git a/sys/i386/xen/xen_clock_util.c b/sys/i386/xen/xen_clock_util.c
index c14a627..c124515 100644
--- a/sys/i386/xen/xen_clock_util.c
+++ b/sys/i386/xen/xen_clock_util.c
@@ -39,12 +39,13 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/time.h>
+#include <xen/xen-os.h>
#include <xen/xen_intr.h>
+
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/pmap.h>
#include <xen/hypervisor.h>
-#include <machine/xen/xen-os.h>
#include <machine/xen/xenfunc.h>
#include <xen/interface/io/xenbus.h>
#include <xen/interface/vcpu.h>
diff --git a/sys/i386/xen/xen_machdep.c b/sys/i386/xen/xen_machdep.c
index 9b5edd3..7049be6 100644
--- a/sys/i386/xen/xen_machdep.c
+++ b/sys/i386/xen/xen_machdep.c
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/rwlock.h>
#include <sys/sysproto.h>
-#include <machine/xen/xen-os.h>
+#include <xen/xen-os.h>
#include <vm/vm.h>
#include <vm/pmap.h>
@@ -96,6 +96,8 @@ xen_pfn_t *xen_pfn_to_mfn_frame_list[16];
xen_pfn_t *xen_pfn_to_mfn_frame_list_list;
int preemptable, init_first;
extern unsigned int avail_space;
+int xen_vector_callback_enabled = 0;
+enum xen_domain_type xen_domain_type = XEN_PV_DOMAIN;
void ni_cli(void);
void ni_sti(void);
@@ -129,6 +131,12 @@ ni_sti(void)
);
}
+void
+force_evtchn_callback(void)
+{
+ (void)HYPERVISOR_xen_version(0, NULL);
+}
+
/*
* Modify the cmd_line by converting ',' to NULLs so that it is in a format
* suitable for the static env vars.
@@ -141,7 +149,7 @@ xen_setbootenv(char *cmd_line)
/* Skip leading spaces */
for (; *cmd_line == ' '; cmd_line++);
- printk("xen_setbootenv(): cmd_line='%s'\n", cmd_line);
+ xc_printf("xen_setbootenv(): cmd_line='%s'\n", cmd_line);
for (cmd_line_next = cmd_line; strsep(&cmd_line_next, ",") != NULL;);
return cmd_line;
@@ -177,16 +185,16 @@ xen_boothowto(char *envp)
return howto;
}
-#define PRINTK_BUFSIZE 1024
+#define XC_PRINTF_BUFSIZE 1024
void
-printk(const char *fmt, ...)
+xc_printf(const char *fmt, ...)
{
__va_list ap;
int retval;
- static char buf[PRINTK_BUFSIZE];
+ static char buf[XC_PRINTF_BUFSIZE];
va_start(ap, fmt);
- retval = vsnprintf(buf, PRINTK_BUFSIZE - 1, fmt, ap);
+ retval = vsnprintf(buf, XC_PRINTF_BUFSIZE - 1, fmt, ap);
va_end(ap);
buf[retval] = 0;
(void)HYPERVISOR_console_write(buf, retval);
@@ -239,9 +247,10 @@ xen_dump_queue(void)
if (_xpq_idx <= 1)
return;
- printk("xen_dump_queue(): %u entries\n", _xpq_idx);
+ xc_printf("xen_dump_queue(): %u entries\n", _xpq_idx);
for (i = 0; i < _xpq_idx; i++) {
- printk(" val: %llx ptr: %llx\n", XPQ_QUEUE[i].val, XPQ_QUEUE[i].ptr);
+ xc_printf(" val: %llx ptr: %llx\n", XPQ_QUEUE[i].val,
+ XPQ_QUEUE[i].ptr);
}
}
#endif
@@ -955,9 +964,10 @@ initvalues(start_info_t *startinfo)
cur_space = xen_start_info->pt_base +
(l3_pages + l2_pages + l1_pages + 1)*PAGE_SIZE;
- printk("initvalues(): wooh - availmem=%x,%x\n", avail_space, cur_space);
+ xc_printf("initvalues(): wooh - availmem=%x,%x\n", avail_space,
+ cur_space);
- printk("KERNBASE=%x,pt_base=%x, VTOPFN(base)=%x, nr_pt_frames=%x\n",
+ xc_printf("KERNBASE=%x,pt_base=%x, VTOPFN(base)=%x, nr_pt_frames=%x\n",
KERNBASE,xen_start_info->pt_base, VTOPFN(xen_start_info->pt_base),
xen_start_info->nr_pt_frames);
xendebug_flags = 0; /* 0xffffffff; */
@@ -1007,7 +1017,7 @@ initvalues(start_info_t *startinfo)
/* Map proc0's KSTACK */
proc0kstack = cur_space; cur_space += (KSTACK_PAGES * PAGE_SIZE);
- printk("proc0kstack=%u\n", proc0kstack);
+ xc_printf("proc0kstack=%u\n", proc0kstack);
/* vm86/bios stack */
cur_space += PAGE_SIZE;
@@ -1106,18 +1116,18 @@ initvalues(start_info_t *startinfo)
shinfo = xen_start_info->shared_info;
PT_SET_MA(HYPERVISOR_shared_info, shinfo | PG_KERNEL);
- printk("#4\n");
+ xc_printf("#4\n");
xen_store_ma = (((vm_paddr_t)xen_start_info->store_mfn) << PAGE_SHIFT);
PT_SET_MA(xen_store, xen_store_ma | PG_KERNEL);
console_page_ma = (((vm_paddr_t)xen_start_info->console.domU.mfn) << PAGE_SHIFT);
PT_SET_MA(console_page, console_page_ma | PG_KERNEL);
- printk("#5\n");
+ xc_printf("#5\n");
set_iopl.iopl = 1;
PANIC_IF(HYPERVISOR_physdev_op(PHYSDEVOP_SET_IOPL, &set_iopl));
- printk("#6\n");
+ xc_printf("#6\n");
#if 0
/* add page table for KERNBASE */
xen_queue_pt_update(IdlePTDma + KPTDI*sizeof(vm_paddr_t),
@@ -1132,7 +1142,7 @@ initvalues(start_info_t *startinfo)
#endif
xen_flush_queue();
cur_space += PAGE_SIZE;
- printk("#6\n");
+ xc_printf("#6\n");
#endif /* 0 */
#ifdef notyet
if (xen_start_info->flags & SIF_INITDOMAIN) {
@@ -1150,13 +1160,13 @@ initvalues(start_info_t *startinfo)
i < (((vm_offset_t)&etext) & ~PAGE_MASK); i += PAGE_SIZE)
PT_SET_MA(i, VTOM(i) | PG_V | PG_A);
- printk("#7\n");
+ xc_printf("#7\n");
physfree = VTOP(cur_space);
init_first = physfree >> PAGE_SHIFT;
IdlePTD = (pd_entry_t *)VTOP(IdlePTD);
IdlePDPT = (pd_entry_t *)VTOP(IdlePDPT);
setup_xen_features();
- printk("#8, proc0kstack=%u\n", proc0kstack);
+ xc_printf("#8, proc0kstack=%u\n", proc0kstack);
}
@@ -1200,9 +1210,9 @@ HYPERVISOR_multicall(struct multicall_entry * call_list, int nr_calls)
/* Check the results of individual hypercalls. */
for (i = 0; i < nr_calls; i++)
- if (unlikely(call_list[i].result < 0))
+ if (__predict_false(call_list[i].result < 0))
ret++;
- if (unlikely(ret > 0))
+ if (__predict_false(ret > 0))
panic("%d multicall(s) failed: cpu %d\n",
ret, smp_processor_id());
diff --git a/sys/i386/xen/xen_rtc.c b/sys/i386/xen/xen_rtc.c
index 8e1e017..8dc3ecb 100644
--- a/sys/i386/xen/xen_rtc.c
+++ b/sys/i386/xen/xen_rtc.c
@@ -39,15 +39,17 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/time.h>
+#include <xen/xen-os.h>
#include <xen/xen_intr.h>
+#include <xen/hypervisor.h>
+#include <xen/interface/io/xenbus.h>
+#include <xen/interface/vcpu.h>
+
#include <vm/vm.h>
#include <vm/pmap.h>
+
#include <machine/pmap.h>
-#include <xen/hypervisor.h>
-#include <machine/xen/xen-os.h>
#include <machine/xen/xenfunc.h>
-#include <xen/interface/io/xenbus.h>
-#include <xen/interface/vcpu.h>
#include <machine/cpu.h>
#include <machine/xen/xen_clock_util.h>
OpenPOWER on IntegriCloud