Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm: KVM: Allow hyp teardown

So far, KVM was getting in the way of kexec on 32bit (and the arm64
kexec hackers couldn't be bothered to fix it on 32bit...).

With simpler page tables, tearing KVM down becomes very easy, so
let's just do it.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>

authored by

Marc Zyngier and committed by
Christoffer Dall
e537ecd7 cd602a37

+24 -7
+2
arch/arm/include/asm/kvm_asm.h
··· 66 66 extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu); 67 67 68 68 extern void __init_stage2_translation(void); 69 + 70 + extern void __kvm_hyp_reset(unsigned long); 69 71 #endif 70 72 71 73 #endif /* __ARM_KVM_ASM_H__ */
+3 -5
arch/arm/include/asm/kvm_host.h
··· 266 266 kvm_call_hyp(__init_stage2_translation); 267 267 } 268 268 269 - static inline void __cpu_reset_hyp_mode(phys_addr_t phys_idmap_start) 269 + static inline void __cpu_reset_hyp_mode(unsigned long vector_ptr, 270 + phys_addr_t phys_idmap_start) 270 271 { 271 - /* 272 - * TODO 273 - * kvm_call_reset(phys_idmap_start); 274 - */ 272 + kvm_call_hyp((void *)virt_to_idmap(__kvm_hyp_reset), vector_ptr); 275 273 } 276 274 277 275 static inline int kvm_arch_dev_ioctl_check_extension(long ext)
+2 -1
arch/arm/kvm/arm.c
··· 1074 1074 static void cpu_hyp_reset(void) 1075 1075 { 1076 1076 if (!is_kernel_in_hyp_mode()) 1077 - __cpu_reset_hyp_mode(kvm_get_idmap_start()); 1077 + __cpu_reset_hyp_mode(hyp_default_vectors, 1078 + kvm_get_idmap_start()); 1078 1079 } 1079 1080 1080 1081 static void _kvm_arch_hardware_enable(void *discard)
+15
arch/arm/kvm/init.S
··· 112 112 113 113 eret 114 114 115 + @ r0 : stub vectors address 116 + ENTRY(__kvm_hyp_reset) 117 + /* We're now in idmap, disable MMU */ 118 + mrc p15, 4, r1, c1, c0, 0 @ HSCTLR 119 + ldr r2, =(HSCTLR_M | HSCTLR_A | HSCTLR_C | HSCTLR_I) 120 + bic r1, r1, r2 121 + mcr p15, 4, r1, c1, c0, 0 @ HSCTLR 122 + 123 + /* Install stub vectors */ 124 + mcr p15, 4, r0, c12, c0, 0 @ HVBAR 125 + isb 126 + 127 + eret 128 + ENDPROC(__kvm_hyp_reset) 129 + 115 130 .ltorg 116 131 117 132 .globl __kvm_hyp_init_end
+2 -1
arch/arm64/include/asm/kvm_host.h
··· 359 359 } 360 360 361 361 void __kvm_hyp_teardown(void); 362 - static inline void __cpu_reset_hyp_mode(phys_addr_t phys_idmap_start) 362 + static inline void __cpu_reset_hyp_mode(unsigned long vector_ptr, 363 + phys_addr_t phys_idmap_start) 363 364 { 364 365 kvm_call_hyp(__kvm_hyp_teardown, phys_idmap_start); 365 366 }