aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common
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/common
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/common')
-rw-r--r--xen/common/domain.c10
-rw-r--r--xen/common/event_channel.c12
-rw-r--r--xen/common/keyhandler.c6
3 files changed, 7 insertions, 21 deletions
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],