aboutsummaryrefslogtreecommitdiffstats
path: root/xen
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-10-29 11:14:54 +0000
committerKeir Fraser <keir.fraser@citrix.com>2009-10-29 11:14:54 +0000
commitbde7d0c41aaf5d38d0697feb2750df61685960f7 (patch)
tree054effc61576f6f5bffb089305dbc9fc68ef47fc /xen
parent4e69eb152ebb1f81b539eb4c1decb372ad29242b (diff)
downloadxen-bde7d0c41aaf5d38d0697feb2750df61685960f7.tar.gz
xen-bde7d0c41aaf5d38d0697feb2750df61685960f7.tar.bz2
xen-bde7d0c41aaf5d38d0697feb2750df61685960f7.zip
Point per-vcpu vcpu_info at a dummy structure by default, avoiding
need for scattered NULL-pointer checks. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'xen')
-rw-r--r--xen/arch/x86/domain.c11
-rw-r--r--xen/common/domain.c10
-rw-r--r--xen/common/event_channel.c12
-rw-r--r--xen/common/keyhandler.c6
-rw-r--r--xen/include/asm-x86/shared.h4
-rw-r--r--xen/include/xen/shared.h2
6 files changed, 12 insertions, 33 deletions
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 49662661df..7c22d131b8 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -832,7 +832,6 @@ void arch_vcpu_reset(struct vcpu *v)
static void
unmap_vcpu_info(struct vcpu *v)
{
- struct domain *d = v->domain;
unsigned long mfn;
if ( v->arch.vcpu_info_mfn == INVALID_MFN )
@@ -841,7 +840,7 @@ unmap_vcpu_info(struct vcpu *v)
mfn = v->arch.vcpu_info_mfn;
unmap_domain_page_global(v->vcpu_info);
- v->vcpu_info = (void *)&shared_info(d, vcpu_info[v->vcpu_id]);
+ v->vcpu_info = &dummy_vcpu_info;
v->arch.vcpu_info_mfn = INVALID_MFN;
put_page_and_type(mfn_to_page(mfn));
@@ -885,13 +884,7 @@ map_vcpu_info(struct vcpu *v, unsigned long mfn, unsigned offset)
new_info = (vcpu_info_t *)(mapping + offset);
- if ( v->vcpu_info )
- memcpy(new_info, v->vcpu_info, sizeof(*new_info));
- else
- {
- memset(new_info, 0, sizeof(*new_info));
- __vcpu_info(v, new_info, evtchn_upcall_mask) = 1;
- }
+ memcpy(new_info, v->vcpu_info, sizeof(*new_info));
v->vcpu_info = new_info;
v->arch.vcpu_info_mfn = mfn;
diff --git a/xen/common/domain.c b/xen/common/domain.c
index f07d800cfc..468f3476ae 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -87,6 +87,8 @@ struct domain *dom0;
struct vcpu *idle_vcpu[NR_CPUS] __read_mostly;
+vcpu_info_t dummy_vcpu_info;
+
int current_domain_id(void)
{
return current->domain->domain_id;
@@ -154,8 +156,9 @@ struct vcpu *alloc_vcpu(
v->runstate.state = RUNSTATE_offline;
v->runstate.state_entry_time = NOW();
set_bit(_VPF_down, &v->pause_flags);
- if ( vcpu_id < XEN_LEGACY_MAX_VCPUS )
- v->vcpu_info = (void *)&shared_info(d, vcpu_info[vcpu_id]);
+ v->vcpu_info = ((vcpu_id < XEN_LEGACY_MAX_VCPUS)
+ ? (vcpu_info_t *)&shared_info(d, vcpu_info[vcpu_id])
+ : &dummy_vcpu_info);
}
if ( sched_init_vcpu(v, cpu_id) != 0 )
@@ -754,9 +757,6 @@ long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
switch ( cmd )
{
case VCPUOP_initialise:
- if ( !v->vcpu_info )
- return -EINVAL;
-
if ( (ctxt = xmalloc(struct vcpu_guest_context)) == NULL )
return -ENOMEM;
diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index 58be1729b0..d052f15980 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -244,9 +244,6 @@ static long evtchn_bind_virq(evtchn_bind_virq_t *bind)
((v = d->vcpu[vcpu]) == NULL) )
return -ENOENT;
- if ( unlikely(!v->vcpu_info) )
- return -EAGAIN;
-
spin_lock(&d->event_lock);
if ( v->virq_to_evtchn[virq] != 0 )
@@ -280,9 +277,6 @@ static long evtchn_bind_ipi(evtchn_bind_ipi_t *bind)
(d->vcpu[vcpu] == NULL) )
return -ENOENT;
- if ( unlikely(!d->vcpu[vcpu]->vcpu_info) )
- return -EAGAIN;
-
spin_lock(&d->event_lock);
if ( (port = get_free_port(d)) < 0 )
@@ -726,9 +720,6 @@ long evtchn_bind_vcpu(unsigned int port, unsigned int vcpu_id)
if ( (vcpu_id >= d->max_vcpus) || (d->vcpu[vcpu_id] == NULL) )
return -ENOENT;
- if ( unlikely(!d->vcpu[vcpu_id]->vcpu_info) )
- return -EAGAIN;
-
spin_lock(&d->event_lock);
if ( !port_is_valid(d, port) )
@@ -952,9 +943,6 @@ int alloc_unbound_xen_event_channel(
struct domain *d = local_vcpu->domain;
int port;
- if ( unlikely(!local_vcpu->vcpu_info) )
- return -EAGAIN;
-
spin_lock(&d->event_lock);
if ( (port = get_free_port(d)) < 0 )
diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index 844d890df7..8ddfa95db9 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -209,8 +209,8 @@ static void dump_domains(unsigned char key)
v->vcpu_id, v->processor,
v->is_running ? 'T':'F',
v->pause_flags, v->poll_evtchn,
- v->vcpu_info ? vcpu_info(v, evtchn_upcall_pending) : 0,
- v->vcpu_info ? vcpu_info(v, evtchn_upcall_mask) : 1);
+ vcpu_info(v, evtchn_upcall_pending),
+ vcpu_info(v, evtchn_upcall_mask));
cpuset_print(tmpstr, sizeof(tmpstr), v->vcpu_dirty_cpumask);
printk("dirty_cpus=%s ", tmpstr);
cpuset_print(tmpstr, sizeof(tmpstr), v->cpu_affinity);
@@ -218,8 +218,6 @@ static void dump_domains(unsigned char key)
arch_dump_vcpu_info(v);
periodic_timer_print(tmpstr, sizeof(tmpstr), v->periodic_period);
printk(" %s\n", tmpstr);
- if ( !v->vcpu_info )
- continue;
printk(" Notifying guest (virq %d, port %d, stat %d/%d/%d)\n",
VIRQ_DEBUG, v->virq_to_evtchn[VIRQ_DEBUG],
test_bit(v->virq_to_evtchn[VIRQ_DEBUG],
diff --git a/xen/include/asm-x86/shared.h b/xen/include/asm-x86/shared.h
index d3584c0ac3..ceca564d62 100644
--- a/xen/include/asm-x86/shared.h
+++ b/xen/include/asm-x86/shared.h
@@ -26,8 +26,6 @@ static inline void arch_set_##field(struct domain *d, \
#define GET_SET_VCPU(type, field) \
static inline type arch_get_##field(const struct vcpu *v) \
{ \
- if ( unlikely(!v->vcpu_info) ) \
- return 0; \
return !has_32bit_shinfo(v->domain) ? \
v->vcpu_info->native.arch.field : \
v->vcpu_info->compat.arch.field; \
@@ -59,7 +57,7 @@ static inline void arch_set_##field(struct domain *d, \
#define GET_SET_VCPU(type, field) \
static inline type arch_get_##field(const struct vcpu *v) \
{ \
- return v->vcpu_info ? v->vcpu_info->arch.field : 0; \
+ return v->vcpu_info->arch.field; \
} \
static inline void arch_set_##field(struct vcpu *v, \
type val) \
diff --git a/xen/include/xen/shared.h b/xen/include/xen/shared.h
index 3bbf133294..528c8b77c5 100644
--- a/xen/include/xen/shared.h
+++ b/xen/include/xen/shared.h
@@ -43,6 +43,8 @@ typedef struct vcpu_info vcpu_info_t;
#endif
+extern vcpu_info_t dummy_vcpu_info;
+
#define shared_info(d, field) __shared_info(d, (d)->shared_info, field)
#define vcpu_info(v, field) __vcpu_info(v, (v)->vcpu_info, field)