diff options
author | kmacy <kmacy@FreeBSD.org> | 2008-12-29 06:31:03 +0000 |
---|---|---|
committer | kmacy <kmacy@FreeBSD.org> | 2008-12-29 06:31:03 +0000 |
commit | 9198d09682e0ff9e4b99c1a500c60ec311f33516 (patch) | |
tree | 78f4ff4cfc0d598fd6e8ccc01fa628fc8ded089f /sys/i386 | |
parent | e46dfc4a1843e8da9da2fceed45ebc43d45d62b1 (diff) | |
download | FreeBSD-src-9198d09682e0ff9e4b99c1a500c60ec311f33516.zip FreeBSD-src-9198d09682e0ff9e4b99c1a500c60ec311f33516.tar.gz |
merge 186535, 186537, and 186538 from releng_7_xen
Log:
- merge in latest xenbus from dfr's xenhvm
- fix race condition in xs_read_reply by converting tsleep to mtx_sleep
Log:
unmask evtchn in bind_{virq, ipi}_to_irq
Log:
- remove code for handling case of not being able to sleep
- eliminate tsleep - make sleeps atomic
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/conf/XEN | 6 | ||||
-rw-r--r-- | sys/i386/i386/genassym.c | 2 | ||||
-rw-r--r-- | sys/i386/i386/machdep.c | 4 | ||||
-rw-r--r-- | sys/i386/i386/vm_machdep.c | 2 | ||||
-rw-r--r-- | sys/i386/include/xen/evtchn.h | 94 | ||||
-rw-r--r-- | sys/i386/include/xen/hypervisor.h | 143 | ||||
-rw-r--r-- | sys/i386/include/xen/xen_intr.h | 74 | ||||
-rw-r--r-- | sys/i386/include/xen/xenfunc.h | 2 | ||||
-rw-r--r-- | sys/i386/isa/npx.c | 2 | ||||
-rw-r--r-- | sys/i386/xen/clock.c | 33 | ||||
-rw-r--r-- | sys/i386/xen/mp_machdep.c | 21 | ||||
-rw-r--r-- | sys/i386/xen/mptable.c | 2 | ||||
-rw-r--r-- | sys/i386/xen/pmap.c | 2 | ||||
-rw-r--r-- | sys/i386/xen/xen_machdep.c | 2 |
14 files changed, 41 insertions, 348 deletions
diff --git a/sys/i386/conf/XEN b/sys/i386/conf/XEN index 9295844..7ddc776 100644 --- a/sys/i386/conf/XEN +++ b/sys/i386/conf/XEN @@ -9,9 +9,9 @@ ident XEN makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols makeoptions MODULES_OVERRIDE="" -#options SCHED_ULE # ULE scheduler -#options PREEMPTION # Enable kernel thread preemption -options SCHED_4BSD +options SCHED_ULE # ULE scheduler +options PREEMPTION # Enable kernel thread preemption +#options SCHED_4BSD options INET # InterNETworking options INET6 # IPv6 communications protocols diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index 059e2ab..7c6acf0 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -234,7 +234,7 @@ ASSYM(BUS_SPACE_HANDLE_IAT, offsetof(struct bus_space_handle, bsh_iat)); #endif #ifdef XEN -#include <machine/xen/hypervisor.h> +#include <xen/hypervisor.h> ASSYM(PC_CR3, offsetof(struct pcpu, pc_cr3)); ASSYM(HYPERVISOR_VIRT_START, __HYPERVISOR_VIRT_START); #endif diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index d824b26..803d8d1 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -144,11 +144,11 @@ uint32_t arch_i386_xbox_memsize = 0; #ifdef XEN /* XEN includes */ #include <machine/xen/xen-os.h> -#include <machine/xen/hypervisor.h> +#include <xen/hypervisor.h> #include <machine/xen/xen-os.h> #include <machine/xen/xenvar.h> #include <machine/xen/xenfunc.h> -#include <machine/xen/xen_intr.h> +#include <xen/xen_intr.h> void Xhypervisor_callback(void); void failsafe_callback(void); diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index 502be4d..15233c5 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -89,7 +89,7 @@ __FBSDID("$FreeBSD$"); #include <vm/vm_param.h> #ifdef XEN -#include <machine/xen/hypervisor.h> +#include <xen/hypervisor.h> #endif #ifdef PC98 #include <pc98/cbus/cbus.h> diff --git a/sys/i386/include/xen/evtchn.h b/sys/i386/include/xen/evtchn.h deleted file mode 100644 index f86a8ab..0000000 --- a/sys/i386/include/xen/evtchn.h +++ /dev/null @@ -1,94 +0,0 @@ -/****************************************************************************** - * evtchn.h - * - * Communication via Xen event channels. - * Also definitions for the device that demuxes notifications to userspace. - * - * Copyright (c) 2004, K A Fraser - * - * $FreeBSD$ - */ - -#ifndef __ASM_EVTCHN_H__ -#define __ASM_EVTCHN_H__ -#include <machine/pcpu.h> -#include <machine/xen/hypervisor.h> -#include <machine/xen/synch_bitops.h> -#include <machine/frame.h> - -/* - * LOW-LEVEL DEFINITIONS - */ - -/* - * Unlike notify_remote_via_evtchn(), this is safe to use across - * save/restore. Notifications on a broken connection are silently dropped. - */ -void notify_remote_via_irq(int irq); - - -/* Entry point for notifications into Linux subsystems. */ -void evtchn_do_upcall(struct trapframe *frame); - -/* Entry point for notifications into the userland character device. */ -void evtchn_device_upcall(int port); - -void mask_evtchn(int port); - -void unmask_evtchn(int port); - -#ifdef SMP -void rebind_evtchn_to_cpu(int port, unsigned int cpu); -#else -#define rebind_evtchn_to_cpu(port, cpu) ((void)0) -#endif - -static inline -int test_and_set_evtchn_mask(int port) -{ - shared_info_t *s = HYPERVISOR_shared_info; - return synch_test_and_set_bit(port, s->evtchn_mask); -} - -static inline void -clear_evtchn(int port) -{ - shared_info_t *s = HYPERVISOR_shared_info; - synch_clear_bit(port, &s->evtchn_pending[0]); -} - -static inline void -notify_remote_via_evtchn(int port) -{ - struct evtchn_send send = { .port = port }; - (void)HYPERVISOR_event_channel_op(EVTCHNOP_send, &send); -} - -/* - * Use these to access the event channel underlying the IRQ handle returned - * by bind_*_to_irqhandler(). - */ -int irq_to_evtchn_port(int irq); - -void ipi_pcpu(unsigned int cpu, int vector); - -/* - * CHARACTER-DEVICE DEFINITIONS - */ - -#define PORT_NORMAL 0x0000 -#define PORT_EXCEPTION 0x8000 -#define PORTIDX_MASK 0x7fff - -/* /dev/xen/evtchn resides at device number major=10, minor=200 */ -#define EVTCHN_MINOR 200 - -/* /dev/xen/evtchn ioctls: */ -/* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */ -#define EVTCHN_RESET _IO('E', 1) -/* EVTCHN_BIND: Bind to the specified event-channel port. */ -#define EVTCHN_BIND _IO('E', 2) -/* EVTCHN_UNBIND: Unbind from the specified event-channel port. */ -#define EVTCHN_UNBIND _IO('E', 3) - -#endif /* __ASM_EVTCHN_H__ */ diff --git a/sys/i386/include/xen/hypervisor.h b/sys/i386/include/xen/hypervisor.h deleted file mode 100644 index 7f7ca20..0000000 --- a/sys/i386/include/xen/hypervisor.h +++ /dev/null @@ -1,143 +0,0 @@ -/****************************************************************************** - * hypervisor.h - * - * Linux-specific hypervisor handling. - * - * Copyright (c) 2002, K A Fraser - */ - -#ifndef __HYPERVISOR_H__ -#define __HYPERVISOR_H__ - -#define is_running_on_xen() 1 - -#ifdef PAE -#ifndef CONFIG_X86_PAE -#define CONFIG_X86_PAE -#endif -#endif - -#include <sys/cdefs.h> -#include <sys/systm.h> -#include <xen/interface/xen.h> -#include <xen/interface/platform.h> -#include <xen/interface/event_channel.h> -#include <xen/interface/physdev.h> -#include <xen/interface/sched.h> -#include <xen/interface/callback.h> -#include <machine/xen/hypercall.h> - -#if defined(__amd64__) -#define MULTI_UVMFLAGS_INDEX 2 -#define MULTI_UVMDOMID_INDEX 3 -#else -#define MULTI_UVMFLAGS_INDEX 3 -#define MULTI_UVMDOMID_INDEX 4 -#endif - -#ifdef CONFIG_XEN_PRIVILEGED_GUEST -#define is_initial_xendomain() (xen_start_info->flags & SIF_INITDOMAIN) -#else -#define is_initial_xendomain() 0 -#endif - -extern start_info_t *xen_start_info; - -extern uint64_t get_system_time(int ticks); - -static inline int -HYPERVISOR_console_write(char *str, int count) -{ - return HYPERVISOR_console_io(CONSOLEIO_write, count, str); -} - -static inline void HYPERVISOR_crash(void) __dead2; - -static inline int -HYPERVISOR_yield(void) -{ - int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL); - -#if CONFIG_XEN_COMPAT <= 0x030002 - if (rc == -ENOXENSYS) - rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0); -#endif - return (rc); -} - -static inline int -HYPERVISOR_block( - void) -{ - int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL); - -#if CONFIG_XEN_COMPAT <= 0x030002 - if (rc == -ENOXENSYS) - rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0); -#endif - return (rc); -} - - -static inline void -HYPERVISOR_shutdown(unsigned int reason) -{ - struct sched_shutdown sched_shutdown = { - .reason = reason - }; - - HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown); -#if CONFIG_XEN_COMPAT <= 0x030002 - HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason); -#endif -} - -static inline void -HYPERVISOR_crash(void) -{ - HYPERVISOR_shutdown(SHUTDOWN_crash); - /* NEVER REACHED */ - for (;;) ; /* eliminate noreturn error */ -} - -/* Transfer control to hypervisor until an event is detected on one */ -/* of the specified ports or the specified number of ticks elapse */ -static inline int -HYPERVISOR_poll( - evtchn_port_t *ports, unsigned int nr_ports, int ticks) -{ - int rc; - struct sched_poll sched_poll = { - .nr_ports = nr_ports, - .timeout = get_system_time(ticks) - }; - set_xen_guest_handle(sched_poll.ports, ports); - - rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll); -#if CONFIG_XEN_COMPAT <= 0x030002 - if (rc == -ENOXENSYS) - rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0); -#endif - return (rc); -} - -static inline void -MULTI_update_va_mapping( - multicall_entry_t *mcl, unsigned long va, - uint64_t new_val, unsigned long flags) -{ - mcl->op = __HYPERVISOR_update_va_mapping; - mcl->args[0] = va; -#if defined(__amd64__) - mcl->args[1] = new_val.pte; -#elif defined(PAE) - mcl->args[1] = (uint32_t)(new_val & 0xffffffff) ; - mcl->args[2] = (uint32_t)(new_val >> 32); -#else - mcl->args[1] = new_val; - mcl->args[2] = 0; -#endif - mcl->args[MULTI_UVMFLAGS_INDEX] = flags; -} - -#endif /* __HYPERVISOR_H__ */ diff --git a/sys/i386/include/xen/xen_intr.h b/sys/i386/include/xen/xen_intr.h deleted file mode 100644 index a0e6c88..0000000 --- a/sys/i386/include/xen/xen_intr.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- */ -#ifndef _XEN_INTR_H_ -#define _XEN_INTR_H_ - -/* -* The flat IRQ space is divided into two regions: -* 1. A one-to-one mapping of real physical IRQs. This space is only used -* if we have physical device-access privilege. This region is at the -* start of the IRQ space so that existing device drivers do not need -* to be modified to translate physical IRQ numbers into our IRQ space. -* 3. A dynamic mapping of inter-domain and Xen-sourced virtual IRQs. These -* are bound using the provided bind/unbind functions. -* -* -* $FreeBSD$ -*/ - -#define PIRQ_BASE 0 -#define NR_PIRQS 128 - -#define DYNIRQ_BASE (PIRQ_BASE + NR_PIRQS) -#define NR_DYNIRQS 128 - -#define NR_IRQS (NR_PIRQS + NR_DYNIRQS) - -#define pirq_to_irq(_x) ((_x) + PIRQ_BASE) -#define irq_to_pirq(_x) ((_x) - PIRQ_BASE) - -#define dynirq_to_irq(_x) ((_x) + DYNIRQ_BASE) -#define irq_to_dynirq(_x) ((_x) - DYNIRQ_BASE) - -/* Dynamic binding of event channels and VIRQ sources to Linux IRQ space. */ -extern void unbind_from_irq(int irq); - -extern int bind_caller_port_to_irqhandler(unsigned int caller_port, - const char *devname, driver_intr_t handler, void *arg, - unsigned long irqflags, void **cookiep); -extern int bind_listening_port_to_irqhandler(unsigned int remote_domain, - const char *devname, driver_intr_t handler, void *arg, unsigned long irqflags, - void **cookiep); -extern int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, const char *devname, - driver_filter_t filter, driver_intr_t handler, unsigned long irqflags); -extern int bind_ipi_to_irqhandler(unsigned int ipi, - unsigned int cpu, - const char *devname, - driver_filter_t handler, - unsigned long irqflags); - -extern int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, - unsigned int remote_port, - const char *devname, - driver_filter_t filter, - driver_intr_t handler, - unsigned long irqflags); - - - -extern void unbind_from_irqhandler(unsigned int evtchn, void *dev_id); -static __inline__ int irq_cannonicalize(int irq) -{ - return (irq == 2) ? 9 : irq; -} - -extern void disable_irq(unsigned int); -extern void disable_irq_nosync(unsigned int); -extern void enable_irq(unsigned int); - -extern void irq_suspend(void); -extern void irq_resume(void); - -extern void idle_block(void); -extern int ap_cpu_initclocks(int cpu); - -#endif /* _XEN_INTR_H_ */ diff --git a/sys/i386/include/xen/xenfunc.h b/sys/i386/include/xen/xenfunc.h index e1a707d..2851709 100644 --- a/sys/i386/include/xen/xenfunc.h +++ b/sys/i386/include/xen/xenfunc.h @@ -33,7 +33,7 @@ #define _XEN_XENFUNC_H_ #include <machine/xen/xen-os.h> -#include <machine/xen/hypervisor.h> +#include <xen/hypervisor.h> #include <machine/xen/xenpmap.h> #include <machine/segments.h> #include <sys/pcpu.h> diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c index 6be3da9..29dc2ca 100644 --- a/sys/i386/isa/npx.c +++ b/sys/i386/isa/npx.c @@ -70,7 +70,7 @@ __FBSDID("$FreeBSD$"); #include <machine/intr_machdep.h> #ifdef XEN #include <machine/xen/xen-os.h> -#include <machine/xen/hypervisor.h> +#include <xen/hypervisor.h> #endif #ifdef DEV_ISA diff --git a/sys/i386/xen/clock.c b/sys/i386/xen/clock.c index 3b4b6f3..db5b09c 100644 --- a/sys/i386/xen/clock.c +++ b/sys/i386/xen/clock.c @@ -78,11 +78,11 @@ __FBSDID("$FreeBSD$"); #include <i386/isa/isa.h> #include <isa/rtc.h> -#include <machine/xen/xen_intr.h> +#include <xen/xen_intr.h> #include <vm/vm.h> #include <vm/pmap.h> #include <machine/pmap.h> -#include <machine/xen/hypervisor.h> +#include <xen/hypervisor.h> #include <machine/xen/xen-os.h> #include <machine/xen/xenfunc.h> #include <xen/interface/vcpu.h> @@ -791,18 +791,20 @@ static struct vcpu_set_periodic_timer xen_set_periodic_tick; void cpu_initclocks(void) { - int time_irq; - + unsigned int time_irq; + int error; + xen_set_periodic_tick.period_ns = NS_PER_TICK; HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, 0, &xen_set_periodic_tick); - - if ((time_irq = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", - clkintr, NULL, - INTR_TYPE_CLK | INTR_FAST)) < 0) { + + error = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", + clkintr, NULL, NULL, + INTR_TYPE_CLK | INTR_FAST, &time_irq); + if (error) panic("failed to register clock interrupt\n"); - } + /* should fast clock be enabled ? */ @@ -811,18 +813,19 @@ cpu_initclocks(void) int ap_cpu_initclocks(int cpu) { - int time_irq; + unsigned int time_irq; + int error; xen_set_periodic_tick.period_ns = NS_PER_TICK; HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu, &xen_set_periodic_tick); - - if ((time_irq = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, "clk", - clkintr2, NULL, - INTR_TYPE_CLK | INTR_FAST)) < 0) { + error = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", + clkintr, NULL, NULL, + INTR_TYPE_CLK | INTR_FAST, &time_irq); + if (error) panic("failed to register clock interrupt\n"); - } + return (0); } diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c index 4b6c77c..874cde8 100644 --- a/sys/i386/xen/mp_machdep.c +++ b/sys/i386/xen/mp_machdep.c @@ -85,9 +85,9 @@ __FBSDID("$FreeBSD$"); #include <machine/xen/xen-os.h> -#include <machine/xen/evtchn.h> -#include <machine/xen/xen_intr.h> -#include <machine/xen/hypervisor.h> +#include <xen/evtchn.h> +#include <xen/xen_intr.h> +#include <xen/hypervisor.h> #include <xen/interface/vcpu.h> #define stop_cpus_with_nmi 0 @@ -464,7 +464,8 @@ static int xen_smp_intr_init(unsigned int cpu) { int rc; - + unsigned int irq; + per_cpu(resched_irq, cpu) = per_cpu(callfunc_irq, cpu) = -1; sprintf(resched_name[cpu], "resched%u", cpu); @@ -472,22 +473,22 @@ xen_smp_intr_init(unsigned int cpu) cpu, resched_name[cpu], smp_reschedule_interrupt, - INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE); + INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE, &irq); printf("cpu=%d irq=%d vector=%d\n", cpu, rc, RESCHEDULE_VECTOR); - per_cpu(resched_irq, cpu) = rc; + 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_FAST|INTR_TYPE_TTY|INTR_MPSAFE); + INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE, &irq); if (rc < 0) goto fail; - per_cpu(callfunc_irq, cpu) = rc; + per_cpu(callfunc_irq, cpu) = irq; printf("cpu=%d irq=%d vector=%d\n", cpu, rc, CALL_FUNCTION_VECTOR); @@ -500,9 +501,9 @@ xen_smp_intr_init(unsigned int cpu) fail: if (per_cpu(resched_irq, cpu) >= 0) - unbind_from_irqhandler(per_cpu(resched_irq, cpu), NULL); + unbind_from_irqhandler(per_cpu(resched_irq, cpu)); if (per_cpu(callfunc_irq, cpu) >= 0) - unbind_from_irqhandler(per_cpu(callfunc_irq, cpu), NULL); + unbind_from_irqhandler(per_cpu(callfunc_irq, cpu)); return rc; } diff --git a/sys/i386/xen/mptable.c b/sys/i386/xen/mptable.c index 99edc50..c6c7d53 100644 --- a/sys/i386/xen/mptable.c +++ b/sys/i386/xen/mptable.c @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); #include <machine/mptable.h> #include <machine/specialreg.h> -#include <machine/xen/hypervisor.h> +#include <xen/hypervisor.h> #include <machine/xen/xen-os.h> #include <machine/smp.h> #include <xen/interface/vcpu.h> diff --git a/sys/i386/xen/pmap.c b/sys/i386/xen/pmap.c index d646458..6ad67ff 100644 --- a/sys/i386/xen/pmap.c +++ b/sys/i386/xen/pmap.c @@ -154,7 +154,7 @@ __FBSDID("$FreeBSD$"); #endif #include <xen/interface/xen.h> -#include <machine/xen/hypervisor.h> +#include <xen/hypervisor.h> #include <machine/xen/hypercall.h> #include <machine/xen/xenvar.h> #include <machine/xen/xenfunc.h> diff --git a/sys/i386/xen/xen_machdep.c b/sys/i386/xen/xen_machdep.c index 9f48702..0c86c62 100644 --- a/sys/i386/xen/xen_machdep.c +++ b/sys/i386/xen/xen_machdep.c @@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$"); -#include <machine/xen/hypervisor.h> +#include <xen/hypervisor.h> #include <machine/xen/xenvar.h> #include <machine/xen/xenfunc.h> #include <machine/xen/xenpmap.h> |