@@ -14,6 +14,8 @@
static long switch_mode(struct domain *d, enum domain_type type)
{
+ struct vcpu *v;
+
if ( d == NULL )
return -EINVAL;
if ( d->tot_pages != 0 )
@@ -23,6 +25,10 @@ static long switch_mode(struct domain *d, enum domain_type type)
d->arch.type = type;
+ if ( is_64bit_domain(d) )
+ for_each_vcpu(d, v)
+ vcpu_switch_to_aarch64_mode(v);
+
return 0;
}
@@ -537,6 +537,11 @@ void vcpu_destroy(struct vcpu *v)
free_xenheap_pages(v->arch.stack, STACK_ORDER);
}
+void vcpu_switch_to_aarch64_mode(struct vcpu *v)
+{
+ v->arch.hcr_el2 |= HCR_RW;
+}
+
int arch_domain_create(struct domain *d, unsigned int domcr_flags,
struct xen_arch_domainconfig *config)
{
@@ -2148,6 +2148,10 @@ int construct_dom0(struct domain *d)
return -EINVAL;
}
d->arch.type = kinfo.type;
+
+ if ( is_64bit_domain(d) )
+ vcpu_switch_to_aarch64_mode(v);
+
#endif
allocate_memory(d, &kinfo);
@@ -2240,6 +2244,9 @@ int construct_dom0(struct domain *d)
printk("Failed to allocate dom0 vcpu %d on pcpu %d\n", i, cpu);
break;
}
+
+ if ( is_64bit_domain(d) )
+ vcpu_switch_to_aarch64_mode(d->vcpu[i]);
}
return 0;
@@ -137,11 +137,6 @@ void p2m_restore_state(struct vcpu *n)
WRITE_SYSREG64(p2m->vttbr, VTTBR_EL2);
isb();
- if ( is_32bit_domain(n->domain) )
- n->arch.hcr_el2 &= ~HCR_RW;
- else
- n->arch.hcr_el2 |= HCR_RW;
-
WRITE_SYSREG(n->arch.sctlr, SCTLR_EL1);
isb();
@@ -268,6 +268,7 @@ struct arch_vcpu
void vcpu_show_execution_state(struct vcpu *);
void vcpu_show_registers(const struct vcpu *);
+void vcpu_switch_to_aarch64_mode(struct vcpu *);
unsigned int domain_max_vcpus(const struct domain *);