return rc;
}
+static int pv_create_gdt_ldt_l1tab(struct vcpu *v)
+{
+ return create_perdomain_mapping(v->domain, GDT_VIRT_START(v),
+ 1U << GDT_LDT_VCPU_SHIFT,
+ v->domain->arch.pv_domain.gdt_ldt_l1tab,
+ NULL);
+}
+
+static void pv_destroy_gdt_ldt_l1tab(struct vcpu *v)
+{
+ destroy_perdomain_mapping(v->domain, GDT_VIRT_START(v),
+ 1U << GDT_LDT_VCPU_SHIFT);
+}
+
int vcpu_initialise(struct vcpu *v)
{
struct domain *d = v->domain;
if ( !is_idle_domain(d) )
{
- rc = create_perdomain_mapping(d, GDT_VIRT_START(v),
- 1 << GDT_LDT_VCPU_SHIFT,
- d->arch.pv_domain.gdt_ldt_l1tab, NULL);
+ rc = pv_create_gdt_ldt_l1tab(v);
if ( rc )
goto done;
NR_VECTORS);
if ( !v->arch.pv_vcpu.trap_ctxt )
{
+ pv_destroy_gdt_ldt_l1tab(v);
rc = -ENOMEM;
goto done;
}
vcpu_destroy_fpu(v);
if ( is_pv_domain(d) )
+ {
+ pv_destroy_gdt_ldt_l1tab(v);
xfree(v->arch.pv_vcpu.trap_ctxt);
+ }
}
else if ( !is_idle_domain(v->domain) )
vpmu_initialise(v);
if ( is_hvm_vcpu(v) )
hvm_vcpu_destroy(v);
else
+ {
+ pv_destroy_gdt_ldt_l1tab(v);
xfree(v->arch.pv_vcpu.trap_ctxt);
+ }
}
static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)