From: Greg Kroah-Hartman Date: Mon, 15 Mar 2021 12:38:35 +0000 (+0100) Subject: 5.10-stable patches X-Git-Tag: v4.4.262~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a4bf8ee5f8c965a2bd594fd9a804b0dcb11a8186;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: kvm-arm64-fix-nvhe-hyp-panic-host-context-restore.patch --- diff --git a/queue-5.10/kvm-arm64-fix-nvhe-hyp-panic-host-context-restore.patch b/queue-5.10/kvm-arm64-fix-nvhe-hyp-panic-host-context-restore.patch new file mode 100644 index 00000000000..a9051dd9ca6 --- /dev/null +++ b/queue-5.10/kvm-arm64-fix-nvhe-hyp-panic-host-context-restore.patch @@ -0,0 +1,109 @@ +From foo@baz Mon Mar 15 01:38:17 PM CET 2021 +From: Andrew Scull +Date: Mon, 15 Mar 2021 12:22:10 +0000 +Subject: KVM: arm64: Fix nVHE hyp panic host context restore +To: kvmarm@lists.cs.columbia.edu +Cc: maz@kernel.org, kernel-team@android.com, Andrew Scull , stable@vger.kernel.org +Message-ID: <20210315122210.1688894-1-ascull@google.com> + +From: Andrew Scull + +Commit c4b000c3928d4f20acef79dccf3a65ae3795e0b0 upstream. + +When panicking from the nVHE hyp and restoring the host context, x29 is +expected to hold a pointer to the host context. This wasn't being done +so fix it to make sure there's a valid pointer the host context being +used. + +Rather than passing a boolean indicating whether or not the host context +should be restored, instead pass the pointer to the host context. NULL +is passed to indicate that no context should be restored. + +Fixes: a2e102e20fd6 ("KVM: arm64: nVHE: Handle hyp panics") +Cc: stable@vger.kernel.org # 5.10.y only +Signed-off-by: Andrew Scull +Signed-off-by: Marc Zyngier +Link: https://lore.kernel.org/r/20210219122406.1337626-1-ascull@google.com +Signed-off-by: Greg Kroah-Hartman +--- + arch/arm64/include/asm/kvm_hyp.h | 3 ++- + arch/arm64/kvm/hyp/nvhe/host.S | 20 ++++++++++---------- + arch/arm64/kvm/hyp/nvhe/switch.c | 3 +-- + 3 files changed, 13 insertions(+), 13 deletions(-) + +--- a/arch/arm64/include/asm/kvm_hyp.h ++++ b/arch/arm64/include/asm/kvm_hyp.h +@@ -99,7 +99,8 @@ u64 __guest_enter(struct kvm_vcpu *vcpu) + + void __noreturn hyp_panic(void); + #ifdef __KVM_NVHE_HYPERVISOR__ +-void __noreturn __hyp_do_panic(bool restore_host, u64 spsr, u64 elr, u64 par); ++void __noreturn __hyp_do_panic(struct kvm_cpu_context *host_ctxt, u64 spsr, ++ u64 elr, u64 par); + #endif + + #endif /* __ARM64_KVM_HYP_H__ */ +--- a/arch/arm64/kvm/hyp/nvhe/host.S ++++ b/arch/arm64/kvm/hyp/nvhe/host.S +@@ -64,10 +64,15 @@ __host_enter_without_restoring: + SYM_FUNC_END(__host_exit) + + /* +- * void __noreturn __hyp_do_panic(bool restore_host, u64 spsr, u64 elr, u64 par); ++ * void __noreturn __hyp_do_panic(struct kvm_cpu_context *host_ctxt, u64 spsr, ++ * u64 elr, u64 par); + */ + SYM_FUNC_START(__hyp_do_panic) +- /* Load the format arguments into x1-7 */ ++ mov x29, x0 ++ ++ /* Load the format string into x0 and arguments into x1-7 */ ++ ldr x0, =__hyp_panic_string ++ + mov x6, x3 + get_vcpu_ptr x7, x3 + +@@ -82,13 +87,8 @@ SYM_FUNC_START(__hyp_do_panic) + ldr lr, =panic + msr elr_el2, lr + +- /* +- * Set the panic format string and enter the host, conditionally +- * restoring the host context. +- */ +- cmp x0, xzr +- ldr x0, =__hyp_panic_string +- b.eq __host_enter_without_restoring ++ /* Enter the host, conditionally restoring the host context. */ ++ cbz x29, __host_enter_without_restoring + b __host_enter_for_panic + SYM_FUNC_END(__hyp_do_panic) + +@@ -144,7 +144,7 @@ SYM_FUNC_END(__hyp_do_panic) + + .macro invalid_host_el1_vect + .align 7 +- mov x0, xzr /* restore_host = false */ ++ mov x0, xzr /* host_ctxt = NULL */ + mrs x1, spsr_el2 + mrs x2, elr_el2 + mrs x3, par_el1 +--- a/arch/arm64/kvm/hyp/nvhe/switch.c ++++ b/arch/arm64/kvm/hyp/nvhe/switch.c +@@ -260,7 +260,6 @@ void __noreturn hyp_panic(void) + u64 spsr = read_sysreg_el2(SYS_SPSR); + u64 elr = read_sysreg_el2(SYS_ELR); + u64 par = read_sysreg_par(); +- bool restore_host = true; + struct kvm_cpu_context *host_ctxt; + struct kvm_vcpu *vcpu; + +@@ -274,7 +273,7 @@ void __noreturn hyp_panic(void) + __sysreg_restore_state_nvhe(host_ctxt); + } + +- __hyp_do_panic(restore_host, spsr, elr, par); ++ __hyp_do_panic(host_ctxt, spsr, elr, par); + unreachable(); + } + diff --git a/queue-5.10/series b/queue-5.10/series index 1e258cd44af..9df24b958c6 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -286,3 +286,4 @@ kvm-arm64-ensure-i-cache-isolation-between-vcpus-of-a-same-vm.patch mm-page_alloc.c-refactor-initialization-of-struct-page-for-holes-in-memory-layout.patch xen-events-don-t-unmask-an-event-channel-when-an-eoi-is-pending.patch xen-events-avoid-handling-the-same-event-on-two-cpus-at-the-same-time.patch +kvm-arm64-fix-nvhe-hyp-panic-host-context-restore.patch