arm/arm64: KVM: Reset the HCR on each vcpu when resetting the vcpu
authorChristoffer Dall <christoffer.dall@linaro.org>
Thu, 16 Oct 2014 15:21:16 +0000 (17:21 +0200)
committerChristoffer Dall <christoffer.dall@linaro.org>
Sat, 13 Dec 2014 13:15:26 +0000 (14:15 +0100)
When userspace resets the vcpu using KVM_ARM_VCPU_INIT, we should also
reset the HCR, because we now modify the HCR dynamically to
enable/disable trapping of guest accesses to the VM registers.

This is crucial for reboot of VMs working since otherwise we will not be
doing the necessary cache maintenance operations when faulting in pages
with the guest MMU off.

Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
arch/arm/include/asm/kvm_emulate.h
arch/arm/kvm/arm.c
arch/arm/kvm/guest.c
arch/arm64/include/asm/kvm_emulate.h
arch/arm64/kvm/guest.c

index b9db269c6e6155bbd1e60f2d7f8bad077b503913..66ce17655bb9e29a73f58ebd9a4716735fcf9739 100644 (file)
@@ -33,6 +33,11 @@ void kvm_inject_undefined(struct kvm_vcpu *vcpu);
 void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr);
 void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr);
 
+static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu)
+{
+       vcpu->arch.hcr = HCR_GUEST_MASK;
+}
+
 static inline bool vcpu_mode_is_32bit(struct kvm_vcpu *vcpu)
 {
        return 1;
index edc196412abed854f5e55f8a44d4a29405dea44e..24c9ca4076b242ffe01447e8e153307b793da96a 100644 (file)
@@ -658,6 +658,8 @@ static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu,
        if (ret)
                return ret;
 
+       vcpu_reset_hcr(vcpu);
+
        /*
         * Handle the "start in power-off" case by marking the VCPU as paused.
         */
index cc0b78769bd8ab40e5237b88aaedb14068f767e0..8c97208b9b970c4d799e76ee7096d58dfb8c33ae 100644 (file)
@@ -38,7 +38,6 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
 
 int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
 {
-       vcpu->arch.hcr = HCR_GUEST_MASK;
        return 0;
 }
 
index 5674a55b551824bcdb4dfd7f26ae45cb3b6c8836..8127e45e263752821c833d1c354a8033372b2a47 100644 (file)
@@ -38,6 +38,11 @@ void kvm_inject_undefined(struct kvm_vcpu *vcpu);
 void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr);
 void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr);
 
+static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu)
+{
+       vcpu->arch.hcr_el2 = HCR_GUEST_FLAGS;
+}
+
 static inline unsigned long *vcpu_pc(const struct kvm_vcpu *vcpu)
 {
        return (unsigned long *)&vcpu_gp_regs(vcpu)->regs.pc;
index 76794692c20b9463717430f01b66b2e73f36bc23..84d5959ff8742b64d37af40046a1c4fc8bd6e641 100644 (file)
@@ -38,7 +38,6 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
 
 int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
 {
-       vcpu->arch.hcr_el2 = HCR_GUEST_FLAGS;
        return 0;
 }
 
This page took 0.027924 seconds and 5 git commands to generate.