]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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)
committerJiri Slaby <jslaby@suse.cz>
Thu, 30 Apr 2015 09:15:12 +0000 (11:15 +0200)
commit b856a59141b1066d3c896a0d0231f84dabd040af upstream.

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>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
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 708e4d8a647f226b4dbdf9722527edd33177912b..4adba055cfeabf02d17696cfda317351fab42a42 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 137cee9f3fd21eecc90c00409d8a7e2f49f97df7..8f4761b5af85f061f87723387d90e05f9f87182f 100644 (file)
@@ -673,6 +673,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 df0076b820a91cca5f335e37bf5b6f9e1293193c..152d03612181d16d5fef5e1e84da8d2c178fbf58 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 6df93cdc652bccdf4bd6287f30bc3eb70779ff4d..45d8633d746e327f9ede638a9c0a2fb229950ecc 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 2c3ff67a8ecbef4625769f53811bfb9958083d1a..6ee53bb29fa817d66602f45fb47e7e2ddd8df574 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;
 }