Access Xen's vcpu info structure per-CPU.

Tested on i386 and amd64 (both dom0 and domU) by me.
Xen2 tested (both dom0 and domU) by bouyer.
OK bouyer
This commit is contained in:
cegger 2008-04-21 15:15:33 +00:00
parent a7315e0fc1
commit 20161b7289
19 changed files with 104 additions and 88 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.26 2008/03/26 12:36:33 ad Exp $
# $NetBSD: genassym.cf,v 1.27 2008/04/21 15:15:33 cegger Exp $
#
# Copyright (c) 1998, 2006, 2007 The NetBSD Foundation, Inc.
@ -391,6 +391,7 @@ define OPTERON_MSR_PASSCODE OPTERON_MSR_PASSCODE
define X86_BUS_SPACE_IO X86_BUS_SPACE_IO
ifdef XEN
define CPU_INFO_VCPU offsetof(struct cpu_info, ci_vcpu)
define EVTCHN_UPCALL_MASK offsetof(struct vcpu_info, evtchn_upcall_mask)
define XEN_PT_BASE offsetof(struct start_info, pt_base)
define XEN_NR_PT_FRAMES offsetof(struct start_info, nr_pt_frames)

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.86 2008/04/16 21:51:03 cegger Exp $ */
/* $NetBSD: machdep.c,v 1.87 2008/04/21 15:15:33 cegger Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007
@ -120,7 +120,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.86 2008/04/16 21:51:03 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.87 2008/04/21 15:15:33 cegger Exp $");
/* #define XENDEBUG_LOW */
@ -1229,6 +1229,9 @@ init_x86_64(paddr_t first_avail)
uint64_t addr, size, io_end, new_physmem;
#endif
#else /* XEN */
KASSERT(HYPERVISOR_shared_info != NULL);
cpu_info_primary.ci_vcpu = &HYPERVISOR_shared_info->vcpu_info[0];
__PRINTK(("init_x86_64(0x%lx)\n", first_avail));
first_bt_vaddr = (vaddr_t) (first_avail + KERNBASE + PAGE_SIZE * 2);
__PRINTK(("first_bt_vaddr 0x%lx\n", first_bt_vaddr));

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.46 2008/04/16 21:51:03 cegger Exp $ */
/* $NetBSD: cpu.h,v 1.47 2008/04/21 15:15:33 cegger Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -64,6 +64,10 @@ struct cpu_info {
struct device *ci_dev;
struct cpu_info *ci_self;
#ifdef XEN
volatile struct vcpu_info *ci_vcpu;
#endif
/*
* Will be accessed by other CPUs.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: frameasm.h,v 1.11 2008/02/29 12:34:23 yamt Exp $ */
/* $NetBSD: frameasm.h,v 1.12 2008/04/21 15:15:33 cegger Exp $ */
#ifndef _AMD64_MACHINE_FRAMEASM_H
#define _AMD64_MACHINE_FRAMEASM_H
@ -134,12 +134,12 @@
#define CLI(temp_reg) \
movl CPUVAR(CPUID),%e/**/temp_reg ; \
shlq $6,%r/**/temp_reg ; \
addq _C_LABEL(HYPERVISOR_shared_info),%r/**/temp_reg ; \
addq CPUVAR(VCPU),%r/**/temp_reg ; \
movb $1,EVTCHN_UPCALL_MASK(%r/**/temp_reg)
#define STI(temp_reg) \
movl CPUVAR(CPUID),%e/**/temp_reg ; \
shlq $6,%r/**/temp_reg ; \
addq _C_LABEL(HYPERVISOR_shared_info),%r/**/temp_reg ; \
addq CPUVAR(VCPU),%r/**/temp_reg ; \
movb $0,EVTCHN_UPCALL_MASK(%r/**/temp_reg)
#else /* XEN */
#define CLI(temp_reg) cli

View File

@ -1,4 +1,4 @@
/* $NetBSD: profile.h,v 1.12 2007/12/20 23:46:12 ad Exp $ */
/* $NetBSD: profile.h,v 1.13 2008/04/21 15:15:33 cegger Exp $ */
/*
* Copyright (c) 1992, 1993
@ -114,13 +114,13 @@ mcount_disable_intr(void)
static inline u_long
mcount_read_psl(void)
{
return (HYPERVISOR_shared_info->vcpu_info[0].evtchn_upcall_mask);
return (curcpu()->ci_vcpu->evtchn_upcall_mask);
}
static inline void
mcount_write_psl(u_long psl)
{
HYPERVISOR_shared_info->vcpu_info[0].evtchn_upcall_mask = psl;
curcpu()->ci_vcpu->evtchn_upcall_mask = psl;
x86_lfence();
/* XXX can't call hypervisor_force_callback() because we're in mcount*/
}

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.64 2008/03/26 12:36:33 ad Exp $
# $NetBSD: genassym.cf,v 1.65 2008/04/21 15:15:33 cegger Exp $
#
# Copyright (c) 1998, 2006, 2007 The NetBSD Foundation, Inc.
@ -471,6 +471,7 @@ define PGOFSET PGOFSET
define PGSHIFT PGSHIFT
ifdef XEN
define CPU_INFO_VCPU offsetof(struct cpu_info, ci_vcpu)
ifdef XEN3
define START_INFO_SHARED_INFO offsetof(struct start_info, shared_info)
define START_INFO_FLAGS offsetof(struct start_info, flags)
@ -480,13 +481,8 @@ else
define START_INFO_SHARED_INFO offsetof(start_info_t, shared_info)
endif
define SIF_INITDOMAIN SIF_INITDOMAIN
ifdef XEN3
define EVTCHN_UPCALL_PENDING offsetof(struct shared_info, vcpu_info[0].evtchn_upcall_pending)
define EVTCHN_UPCALL_MASK offsetof(struct shared_info, vcpu_info[0].evtchn_upcall_mask)
else
define EVTCHN_UPCALL_PENDING offsetof(struct shared_info_st, vcpu_info[0].evtchn_upcall_pending)
define EVTCHN_UPCALL_MASK offsetof(struct shared_info_st, vcpu_info[0].evtchn_upcall_mask)
endif
define EVTCHN_UPCALL_PENDING offsetof(struct vcpu_info, evtchn_upcall_pending)
define EVTCHN_UPCALL_MASK offsetof(struct vcpu_info, evtchn_upcall_mask)
define HYPERVISOR_sched_op __HYPERVISOR_sched_op
define SCHEDOP_yield SCHEDOP_yield

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.627 2008/02/26 18:24:28 xtraeme Exp $ */
/* $NetBSD: machdep.c,v 1.628 2008/04/21 15:15:33 cegger Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008 The NetBSD Foundation, Inc.
@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.627 2008/02/26 18:24:28 xtraeme Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.628 2008/04/21 15:15:33 cegger Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@ -1378,6 +1378,8 @@ init386(paddr_t first_avail)
#ifdef XEN
XENPRINTK(("HYPERVISOR_shared_info %p (%x)\n", HYPERVISOR_shared_info,
xen_start_info.shared_info));
KASSERT(HYPERVISOR_shared_info != NULL);
cpu_info_primary.ci_vcpu = &HYPERVISOR_shared_info->vcpu_info[0];
#endif
cpu_probe_features(&cpu_info_primary);
cpu_feature = cpu_info_primary.ci_feature_flags;

View File

@ -1,4 +1,4 @@
/* $NetBSD: spl.S,v 1.26 2008/01/11 20:00:14 bouyer Exp $ */
/* $NetBSD: spl.S,v 1.27 2008/04/21 15:15:34 cegger Exp $ */
/*
* Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <machine/asm.h>
__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.26 2008/01/11 20:00:14 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.27 2008/04/21 15:15:34 cegger Exp $");
#include "opt_vm86.h"
#include "opt_ddb.h"
@ -181,7 +181,7 @@ IDTVEC(spllower)
testl $PSL_I,%eax
jnz .Lspllower_panic
#else
movl _C_LABEL(HYPERVISOR_shared_info),%eax
movl CPUVAR(VCPU),%eax
movb EVTCHN_UPCALL_MASK(%eax), %al
andb %al, %al
jz .Lspllower_panic
@ -247,7 +247,7 @@ IDTVEC(doreti)
testl $PSL_I,%eax
jnz .Ldoreti_panic
#else
movl _C_LABEL(HYPERVISOR_shared_info),%eax
movl CPUVAR(VCPU),%eax
movb EVTCHN_UPCALL_MASK(%eax), %al
andb %al, %al
jz .Ldoreti_panic

View File

@ -1,4 +1,4 @@
/* $NetBSD: vector.S,v 1.34 2008/01/11 20:00:14 bouyer Exp $ */
/* $NetBSD: vector.S,v 1.35 2008/04/21 15:15:34 cegger Exp $ */
/*
* Copyright 2002 (c) Wasabi Systems, Inc.
@ -72,7 +72,7 @@
*/
#include <machine/asm.h>
__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.34 2008/01/11 20:00:14 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.35 2008/04/21 15:15:34 cegger Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -1293,7 +1293,7 @@ NENTRY(hypervisor_callback)
movl CPUVAR(ILEVEL),%ebx
jmp doreti_checkast
safesti:
movl HYPERVISOR_shared_info,%esi
movl CPUVAR(VCPU),%esi
XEN_UNBLOCK_EVENTS(%esi) # reenable event callbacks
scrit: /**** START OF CRITICAL REGION ****/
XEN_TEST_PENDING(%esi)

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.165 2008/02/27 20:18:56 xtraeme Exp $ */
/* $NetBSD: cpu.h,v 1.166 2008/04/21 15:15:34 cegger Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -74,6 +74,11 @@ struct pmap;
struct cpu_info {
struct device *ci_dev; /* pointer to our device */
struct cpu_info *ci_self; /* self-pointer */
#ifdef XEN
volatile struct vcpu_info *ci_vcpu;
#endif
void *ci_tlog_base; /* Trap log base */
int32_t ci_tlog_offset; /* Trap log current offset */

View File

@ -1,4 +1,4 @@
/* $NetBSD: frameasm.h,v 1.12 2008/02/29 12:34:23 yamt Exp $ */
/* $NetBSD: frameasm.h,v 1.13 2008/04/21 15:15:34 cegger Exp $ */
#ifndef _I386_FRAMEASM_H_
#define _I386_FRAMEASM_H_
@ -18,11 +18,11 @@
#define XEN_UNBLOCK_EVENTS(reg) movb $0,EVTCHN_UPCALL_MASK(reg)
#define XEN_TEST_PENDING(reg) testb $0xFF,EVTCHN_UPCALL_PENDING(reg)
#define CLI(reg) movl _C_LABEL(HYPERVISOR_shared_info),reg ; \
#define CLI(reg) movl CPUVAR(VCPU),reg ; \
XEN_BLOCK_EVENTS(reg)
#define STI(reg) movl _C_LABEL(HYPERVISOR_shared_info),reg ; \
#define STI(reg) movl CPUVAR(VCPU),reg ; \
XEN_UNBLOCK_EVENTS(reg)
#define STIC(reg) movl _C_LABEL(HYPERVISOR_shared_info),reg ; \
#define STIC(reg) movl CPUVAR(VCPU),reg ; \
XEN_UNBLOCK_EVENTS(reg) ; \
testb $0xff,EVTCHN_UPCALL_PENDING(reg)
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: xen.h,v 1.6 2007/10/17 19:58:29 garbled Exp $ */
/* $NetBSD: xen.h,v 1.7 2008/04/21 15:15:34 cegger Exp $ */
/*
* Copyright (c) 2004, K A Fraser
@ -286,7 +286,7 @@ typedef struct shared_info_st
* Per-VCPU information goes here. This will be cleaned up more when Xen
* actually supports multi-VCPU guests.
*/
volatile struct {
volatile struct vcpu_info {
/*
* 'evtchn_upcall_pending' is written non-zero by Xen to indicate
* a pending notification for a particular VCPU. It is then cleared

View File

@ -1,4 +1,4 @@
/* $NetBSD: xen.h,v 1.28 2008/02/19 19:50:53 bouyer Exp $ */
/* $NetBSD: xen.h,v 1.29 2008/04/21 15:15:34 cegger Exp $ */
/*
*
@ -139,33 +139,33 @@ void xpq_flush_cache(void);
#define __save_flags(x) \
do { \
(x) = HYPERVISOR_shared_info->vcpu_info[0].evtchn_upcall_mask; \
(x) = curcpu()->ci_vcpu->evtchn_upcall_mask; \
} while (0)
#define __restore_flags(x) \
do { \
volatile shared_info_t *_shared = HYPERVISOR_shared_info; \
volatile struct vcpu_info *_vci = curcpu()->ci_vcpu; \
__insn_barrier(); \
if ((_shared->vcpu_info[0].evtchn_upcall_mask = (x)) == 0) { \
x86_lfence(); \
if (__predict_false(_shared->vcpu_info[0].evtchn_upcall_pending)) \
if ((_vci->evtchn_upcall_mask = (x)) == 0) { \
x86_lfence(); \
if (__predict_false(_vci->evtchn_upcall_pending)) \
hypervisor_force_callback(); \
} \
} while (0)
#define __cli() \
do { \
HYPERVISOR_shared_info->vcpu_info[0].evtchn_upcall_mask = 1; \
x86_lfence(); \
curcpu()->ci_vcpu->evtchn_upcall_mask = 1; \
x86_lfence(); \
} while (0)
#define __sti() \
do { \
volatile shared_info_t *_shared = HYPERVISOR_shared_info; \
volatile struct vcpu_info *_vci = curcpu()->ci_vcpu; \
__insn_barrier(); \
_shared->vcpu_info[0].evtchn_upcall_mask = 0; \
_vci->evtchn_upcall_mask = 0; \
x86_lfence(); /* unmask then check (avoid races) */ \
if (__predict_false(_shared->vcpu_info[0].evtchn_upcall_pending)) \
if (__predict_false(_vci->evtchn_upcall_pending)) \
hypervisor_force_callback(); \
} while (0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.c,v 1.15 2008/04/18 15:32:46 cegger Exp $ */
/* $NetBSD: cpu.c,v 1.16 2008/04/21 15:15:34 cegger Exp $ */
/* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp */
/*-
@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.15 2008/04/18 15:32:46 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.16 2008/04/21 15:15:34 cegger Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -254,6 +254,7 @@ cpu_attach(device_t parent, device_t self, void *aux)
ci->ci_dev = self;
ci->ci_apicid = caa->cpu_number;
ci->ci_cpuid = ci->ci_apicid;
ci->ci_vcpu = NULL;
printf(": ");
switch (caa->cpu_role) {
@ -345,9 +346,7 @@ cpu_attach_common(device_t parent, device_t self, void *aux)
struct cpu_attach_args *caa = aux;
struct cpu_info *ci;
uintptr_t ptr;
#if defined(MULTIPROCESSOR)
int cpunum = caa->cpu_number;
#endif
sc->sc_dev = self;
@ -388,7 +387,11 @@ cpu_attach_common(device_t parent, device_t self, void *aux)
sc->sc_info = ci;
ci->ci_dev = self;
ci->ci_apicid = caa->cpu_number;
ci->ci_apicid = cpunum;
KASSERT(HYPERVISOR_shared_info != NULL);
ci->ci_vcpu = &HYPERVISOR_shared_info->vcpu_info[cpunum];
#ifdef MULTIPROCESSOR
ci->ci_cpuid = ci->ci_apicid;
#else
@ -1054,8 +1057,7 @@ void
cpu_get_tsc_freq(struct cpu_info *ci)
{
#ifdef XEN3
const volatile vcpu_time_info_t *tinfo =
&HYPERVISOR_shared_info->vcpu_info[0].time;
const volatile vcpu_time_info_t *tinfo = &ci->ci_vcpu->time;
delay(1000000);
uint64_t freq = 1000000000ULL << 32;
freq = freq / (uint64_t)tinfo->tsc_to_system_mul;
@ -1065,6 +1067,7 @@ cpu_get_tsc_freq(struct cpu_info *ci)
freq = freq >> tinfo->tsc_shift;
ci->ci_tsc_freq = freq;
#else
/* Xen2 */
/* XXX this needs to read the shared_info of the CPU being probed.. */
ci->ci_tsc_freq = HYPERVISOR_shared_info->cpu_freq;
#endif /* XEN3 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: hypervisor_machdep.c,v 1.7 2008/04/14 13:38:03 cegger Exp $ */
/* $NetBSD: hypervisor_machdep.c,v 1.8 2008/04/21 15:15:34 cegger Exp $ */
/*
*
@ -59,7 +59,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.7 2008/04/14 13:38:03 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.8 2008/04/21 15:15:34 cegger Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -82,10 +82,12 @@ stipending(void)
unsigned int l1i, l2i, port;
volatile shared_info_t *s = HYPERVISOR_shared_info;
struct cpu_info *ci;
volatile struct vcpu_info *vci;
int ret;
ret = 0;
ci = curcpu();
vci = ci->ci_vcpu;
#if 0
if (HYPERVISOR_shared_info->events)
@ -105,13 +107,13 @@ stipending(void)
* we're only called after STIC, so we know that we'll have to
* STI at the end
*/
while (s->vcpu_info[0].evtchn_upcall_pending) {
while (vci->evtchn_upcall_pending) {
cli();
s->vcpu_info[0].evtchn_upcall_pending = 0;
vci->evtchn_upcall_pending = 0;
/* NB. No need for a barrier here -- XCHG is a barrier
* on x86. */
#ifdef XEN3
l1 = xen_atomic_xchg(&s->vcpu_info[0].evtchn_pending_sel, 0);
l1 = xen_atomic_xchg(&vci->evtchn_pending_sel, 0);
#else
l1 = xen_atomic_xchg(&s->evtchn_pending_sel, 0);
#endif
@ -170,9 +172,11 @@ do_hypervisor_callback(struct intrframe *regs)
unsigned int l1i, l2i, port;
volatile shared_info_t *s = HYPERVISOR_shared_info;
struct cpu_info *ci;
volatile struct vcpu_info *vci;
int level;
ci = curcpu();
vci = ci->ci_vcpu;
level = ci->ci_ilevel;
// DDD printf("do_hypervisor_callback\n");
@ -184,12 +188,12 @@ do_hypervisor_callback(struct intrframe *regs)
}
#endif
while (s->vcpu_info[0].evtchn_upcall_pending) {
s->vcpu_info[0].evtchn_upcall_pending = 0;
while (vci->evtchn_upcall_pending) {
vci->evtchn_upcall_pending = 0;
/* NB. No need for a barrier here -- XCHG is a barrier
* on x86. */
#ifdef XEN3
l1 = xen_atomic_xchg(&s->vcpu_info[0].evtchn_pending_sel, 0);
l1 = xen_atomic_xchg(&vci->evtchn_pending_sel, 0);
#else
l1 = xen_atomic_xchg(&s->evtchn_pending_sel, 0);
#endif
@ -202,8 +206,8 @@ do_hypervisor_callback(struct intrframe *regs)
* mask and clear the pending events.
* Doing it here for all event that will be processed
* avoids a race with stipending (which can be called
* though evtchn_do_event->splx) that could cause an event to
* be both processed and marked pending.
* though evtchn_do_event->splx) that could cause an
* event to be both processed and marked pending.
*/
xen_atomic_setbits_l(&s->evtchn_mask[l1i], l2);
xen_atomic_clearbits_l(&s->evtchn_pending[l1i], l2);
@ -241,7 +245,7 @@ do_hypervisor_callback(struct intrframe *regs)
if (level != ci->ci_ilevel)
printf("hypervisor done %08x level %d/%d ipending %08x\n",
#ifdef XEN3
(uint)HYPERVISOR_shared_info->vcpu_info[0].evtchn_pending_sel,
(uint)vci->evtchn_pending_sel,
#else
(uint)HYPERVISOR_shared_info->evtchn_pending_sel,
#endif
@ -253,6 +257,8 @@ void
hypervisor_unmask_event(unsigned int ev)
{
volatile shared_info_t *s = HYPERVISOR_shared_info;
volatile struct vcpu_info *vci = curcpu()->ci_vcpu;
#ifdef PORT_DEBUG
if (ev == PORT_DEBUG)
printf("hypervisor_unmask_event %d\n", ev);
@ -266,12 +272,12 @@ hypervisor_unmask_event(unsigned int ev)
*/
if (xen_atomic_test_bit(&s->evtchn_pending[0], ev) &&
#ifdef XEN3
!xen_atomic_test_and_set_bit(&s->vcpu_info[0].evtchn_pending_sel, ev>>LONG_SHIFT)) {
!xen_atomic_test_and_set_bit(&vci->evtchn_pending_sel, ev>>LONG_SHIFT)) {
#else
!xen_atomic_test_and_set_bit(&s->evtchn_pending_sel, ev>>LONG_SHIFT)) {
#endif
xen_atomic_set_bit(&s->vcpu_info[0].evtchn_upcall_pending, 0);
if (!s->vcpu_info[0].evtchn_upcall_mask)
xen_atomic_set_bit(&vci->evtchn_upcall_pending, 0);
if (!vci->evtchn_upcall_mask)
hypervisor_force_callback();
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: xen_intr.c,v 1.3 2008/04/14 13:38:03 cegger Exp $ */
/* $NetBSD: xen_intr.c,v 1.4 2008/04/21 15:15:34 cegger Exp $ */
/*-
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.3 2008/04/14 13:38:03 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.4 2008/04/21 15:15:34 cegger Exp $");
#include <sys/param.h>
@ -119,17 +119,17 @@ u_long
x86_read_psl(void)
{
return (HYPERVISOR_shared_info->vcpu_info[0].evtchn_upcall_mask);
return (curcpu()->ci_vcpu->evtchn_upcall_mask);
}
void
x86_write_psl(u_long psl)
{
struct cpu_info *ci = curcpu();
HYPERVISOR_shared_info->vcpu_info[0].evtchn_upcall_mask = psl;
ci->ci_vcpu->evtchn_upcall_mask = psl;
x86_lfence();
if (HYPERVISOR_shared_info->vcpu_info[0].evtchn_upcall_pending &&
psl == 0) {
if (ci->ci_vcpu->evtchn_upcall_pending && psl == 0) {
hypervisor_force_callback();
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: xenfunc.c,v 1.4 2008/02/17 14:03:16 bouyer Exp $ */
/* $NetBSD: xenfunc.c,v 1.5 2008/04/21 15:15:34 cegger Exp $ */
/*
*
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.4 2008/02/17 14:03:16 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.5 2008/04/21 15:15:34 cegger Exp $");
#include <sys/param.h>
@ -150,7 +150,7 @@ vaddr_t
rcr2(void)
{
#ifdef XEN3
return HYPERVISOR_shared_info->vcpu_info[0].arch.cr2; /* XXX curcpu */
return curcpu()->ci_vcpu->arch.cr2;
#else
return 0;
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: clock.c,v 1.45 2008/04/14 13:38:03 cegger Exp $ */
/* $NetBSD: clock.c,v 1.46 2008/04/21 15:15:34 cegger Exp $ */
/*
*
@ -34,7 +34,7 @@
#include "opt_xen.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.45 2008/04/14 13:38:03 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.46 2008/04/21 15:15:34 cegger Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -103,8 +103,7 @@ static void
get_time_values_from_xen(void)
{
#ifdef XEN3
volatile struct vcpu_time_info *t =
&HYPERVISOR_shared_info->vcpu_info[0].time;
volatile struct vcpu_time_info *t = &curcpu()->ci_vcpu->time;
uint32_t tversion;
do {
@ -150,8 +149,7 @@ time_values_up_to_date(void)
#ifndef XEN3
rv = shadow_time_version == HYPERVISOR_shared_info->time_version1;
#else
rv = shadow_time_version ==
HYPERVISOR_shared_info->vcpu_info[0].time.version; /* XXXSMP */
rv = shadow_time_version == curcpu()->ci_vcpu->time.version;
#endif
x86_lfence();

View File

@ -1,4 +1,4 @@
/* $NetBSD: evtchn.c,v 1.36 2008/04/19 13:46:12 cegger Exp $ */
/* $NetBSD: evtchn.c,v 1.37 2008/04/21 15:15:34 cegger Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@ -64,7 +64,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.36 2008/04/19 13:46:12 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.37 2008/04/21 15:15:34 cegger Exp $");
#include "opt_xen.h"
#include "isa.h"
@ -671,12 +671,10 @@ xen_debug_handler(void *arg)
int xci_ilevel = ci->ci_ilevel;
int xci_ipending = ci->ci_ipending;
int xci_idepth = ci->ci_idepth;
u_long upcall_pending =
HYPERVISOR_shared_info->vcpu_info[0].evtchn_upcall_pending;
u_long upcall_mask =
HYPERVISOR_shared_info->vcpu_info[0].evtchn_upcall_mask;
u_long upcall_pending = ci->ci_vcpu->evtchn_upcall_pending;
u_long upcall_mask = ci->ci_vcpu->evtchn_upcall_mask;
#ifdef XEN3
u_long pending_sel = HYPERVISOR_shared_info->vcpu_info[0].evtchn_pending_sel;
u_long pending_sel = ci->ci_vcpu->evtchn_pending_sel;
#else
u_long pending_sel = HYPERVISOR_shared_info->evtchn_pending_sel;
#endif