static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
{
- int vcpuid;
+ unsigned int vcpuid = hvm_load_instance(h);
struct vcpu *v;
struct hvm_hw_cpu ctxt;
struct segment_register seg;
const char *errstr;
/* Which vcpu is this? */
- vcpuid = hvm_load_instance(h);
if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%u has no vcpu%u\n",
static int hvm_load_mtrr_msr(struct domain *d, hvm_domain_context_t *h)
{
- int vcpuid, i;
+ unsigned int vcpuid, i;
struct vcpu *v;
struct mtrr_state *mtrr_state;
struct hvm_hw_mtrr hw_mtrr;
static int viridian_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t *h)
{
- int vcpuid;
+ unsigned int vcpuid = hvm_load_instance(h);
struct vcpu *v;
struct hvm_viridian_vcpu_context ctxt;
- vcpuid = hvm_load_instance(h);
if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
static int lapic_load_hidden(struct domain *d, hvm_domain_context_t *h)
{
- uint16_t vcpuid;
+ unsigned int vcpuid = hvm_load_instance(h);
struct vcpu *v;
struct vlapic *s;
return -ENODEV;
/* Which vlapic to load? */
- vcpuid = hvm_load_instance(h);
if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no apic%u\n",
static int lapic_load_regs(struct domain *d, hvm_domain_context_t *h)
{
- uint16_t vcpuid;
+ unsigned int vcpuid = hvm_load_instance(h);
struct vcpu *v;
struct vlapic *s;
return -ENODEV;
/* Which vlapic to load? */
- vcpuid = hvm_load_instance(h);
if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no apic%u\n",
static int vpic_load(struct domain *d, hvm_domain_context_t *h)
{
struct hvm_hw_vpic *s;
- uint16_t inst;
+ unsigned int inst = hvm_load_instance(h);
if ( !has_vpic(d) )
return -ENODEV;
/* Which PIC is this? */
- inst = hvm_load_instance(h);
if ( inst > 1 )
return -EINVAL;
s = &d->arch.hvm_domain.vpic[inst];
_hvm_load_entry(_x, _h, _dst, 0)
/* Unmarshalling: what is the instance ID of the next entry? */
-static inline uint16_t hvm_load_instance(struct hvm_domain_context *h)
+static inline unsigned int hvm_load_instance(const struct hvm_domain_context *h)
{
- struct hvm_save_descriptor *d
- = (struct hvm_save_descriptor *)&h->data[h->cur];
+ const struct hvm_save_descriptor *d = (const void *)&h->data[h->cur];
+
return d->instance;
}