Skip to contentSkip to conversation

KVM: arm64: Fixes ARM VM hangs at boot

PATCH In review Thomas Tai 2 participants 3 messages Sep 30, 2020 – Oct 1, 2020

Subsystems (2)
lore
Share & tools
lore

Thomas Tai

author
#0 lore raw

PATCH 1/1 KVM: arm64: Fixes ARM VM hangs at boot

When using the latest kernel v5.9-rc7 on an ARM server, VMs could hang at boot with no output. The commit a0e50aa3f4a8 removed asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT)), it looks like isb is still needed for non ARM64_WORKAROUND_SPECULATIVE_AT host when switching to guest.

The code fragment for the original patch:

-       /* __load_guest_stage2() includes an ISB for the workaround. */
-       __load_guest_stage2(kvm);
-       asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT));
+       __load_guest_stage2(mmu);

The code should have been:

-       /* __load_guest_stage2() includes an ISB for the workaround. */
-       __load_guest_stage2(kvm);
-       asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT));
+       __load_guest_stage2(mmu);
+       asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT));

ie, the workaround is still needed.

Fixes a0e50aa3f4a8 ("KVM: arm64: Factor out stage 2 page table data from

struct kvm")

---
 arch/arm64/kvm/hyp/nvhe/tlb.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kvm/hyp/nvhe/tlb.c +1 -0
index 69eae60..536496e 100644
@@ -32,6 +32,7 @@ static void __tlb_switch_to_guest(struct kvm_s2_mmu *mmu,
 	}
 
 	__load_guest_stage2(mmu);
+	asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT));
 }
 
 static void __tlb_switch_to_host(struct tlb_inv_context *cxt)
Signature · 7 lines
1.8.3.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#1 lore raw

Hi Thomas,

Quoted 5 lines · Thomas Tai

When using the latest kernel v5.9-rc7 on an ARM server, VMs could hang at boot with no output. The commit a0e50aa3f4a8 removed asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT)), it looks like isb is still needed for non ARM64_WORKAROUND_SPECULATIVE_AT host when switching to guest.

Is that on an eMAG system, by any chance?

Quoted 38 lines

The code fragment for the original patch:

(quoted diff) +0 -3
-       /* __load_guest_stage2() includes an ISB for the workaround. */
-       __load_guest_stage2(kvm);
-       asm(ALTERNATIVE("isb", "nop", 

ARM64_WORKAROUND_SPECULATIVE_AT));
+ __load_guest_stage2(mmu);

The code should have been:

(quoted diff) +0 -3
-       /* __load_guest_stage2() includes an ISB for the workaround. */
-       __load_guest_stage2(kvm);
-       asm(ALTERNATIVE("isb", "nop", 

ARM64_WORKAROUND_SPECULATIVE_AT));

(quoted diff) +2 -0
+       __load_guest_stage2(mmu);
+       asm(ALTERNATIVE("isb", "nop", 

ARM64_WORKAROUND_SPECULATIVE_AT));
ie, the workaround is still needed.

Fixes a0e50aa3f4a8 ("KVM: arm64: Factor out stage 2 page table data from

struct kvm")

---
 arch/arm64/kvm/hyp/nvhe/tlb.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kvm/hyp/nvhe/tlb.c +1 -0
index 69eae60..536496e 100644
@@ -32,6 +32,7 @@ static void __tlb_switch_to_guest(struct kvm_s2_mmu 
 *mmu,
 	}
 
 	__load_guest_stage2(mmu);
+	asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT));
 }
 
Quoted 1 line

static void __tlb_switch_to_host(struct tlb_inv_context *cxt)

Ouch. I remember fixing this a while ago, but somehow dropped it after applying it and *not* merging it...

Thanks a lot for the heads up!

        M.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/commit/?h=kvm-arm64/pre-nv-5.9

Signature · 5 lines
Jazz is not dead. It just smells funny...
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
author
#2 lore raw
Quoted 10 lines · Marc Zyngier

Hi Thomas,

Quoted 5 lines · Thomas Tai

When using the latest kernel v5.9-rc7 on an ARM server, VMs could hang at boot with no output. The commit a0e50aa3f4a8 removed asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT)), it looks like isb is still needed for non ARM64_WORKAROUND_SPECULATIVE_AT host when switching to guest.

Is that on an eMAG system, by any chance?

Hi Marc,
Yes, it is indeed an eMAG system.

Quoted 41 lines
Quoted 36 lines

The code fragment for the original patch:
-       /* __load_guest_stage2() includes an ISB for the workaround. */ -       __load_guest_stage2(kvm);
-       asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT)); +       __load_guest_stage2(mmu);

The code should have been:
-       /* __load_guest_stage2() includes an ISB for the workaround. */ -       __load_guest_stage2(kvm);
-       asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT)); +       __load_guest_stage2(mmu);
+       asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT)); ie, the workaround is still needed.

Fixes a0e50aa3f4a8 ("KVM: arm64: Factor out stage 2 page table data from

struct kvm")

---
 arch/arm64/kvm/hyp/nvhe/tlb.c | 1 +

 1 file changed, 1 insertion(+)
arch/arm64/kvm/hyp/nvhe/tlb.c +1 -0
index 69eae60..536496e 100644
@@ -32,6 +32,7 @@ static void __tlb_switch_to_guest(struct kvm_s2_mmu 
 *mmu,
      }
 
      __load_guest_stage2(mmu);
+    asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT));
  }
 
Quoted 1 line

 static void __tlb_switch_to_host(struct tlb_inv_context *cxt)

Ouch. I remember fixing this a while ago, but somehow dropped it after applying it and *not* merging it...

Quoted 5 lines

Thanks a lot for the heads up!

        M.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/commit/?h=kvm-arm64/pre-nv-5.9

Good to know you have the fix.

Thank you,
Thomas

Quoted 1 line

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel