Received: by 10.192.165.156 with SMTP id m28csp1075921imm; Wed, 11 Apr 2018 11:59:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx49V7GUNhpFxe4CgaXY0QHD28NWCcX1IwGlow7sNJVulD/93CHh0EFCgENX9O9rHeSos9/kb X-Received: by 10.101.101.206 with SMTP id y14mr4391270pgv.220.1523473166451; Wed, 11 Apr 2018 11:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523473166; cv=none; d=google.com; s=arc-20160816; b=hNgbyekZ3YBjZTb0i46UcfngizVtfCFJ9zqrOCPiZtw8Lup6shEy5dHbFyIYmlDEfe VOmYI6dAk2UBJe6LF0ROn+wthTDYC79Hf7ep9QIssxSBKCEFbSAM4nWHfDkXlKG/6pj3 ytbJ7GPlNOvUFAsxjGKxt8/5jPvNti1nN+bIFnoBq9lGqit7NFrZqUeodw/dpPgJAaXr J67+bVlH9m7YBzcB8pIojvYcvrYAlNgL883WsDbs+tQNu5bz5Q+A0H1S9d/rCRVx+rEz f13EnOVdqTcI+OUiKZDK/O8LrZIiiGeV5gFwjKVPErxTKqDPLvxJQ5dOzrSrB6jEmqOL r2bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=H3hav84K5rZggnLpYuDHS7WgZjvrSEq0VHEceV7ikwg=; b=fK67i1EYukKQWlcPFY/eWDG71k3zhu4wykgmguMv0mC/fEzp2uIHCfXl6KmLadb4WI lYHsdFC/nQh5UEHMYWFQEGfDn6RkYQ1gz2HJAhOfPQZ9HYpLo40DEOL04ZMQmaJTL+do EIIDpHtjjAiBrFqZUPMeyW5uGRD4Gqoy4mruMQYkWYMVewvhDoHkOKuwuf5VGQTWHPrN KzpIzQ28nJhe8RTwkWbLThxJHZ/awEsClBYJVh6gkn6Zlu/fcVW9x6UYm34NkmZVrKZm W3DDfzWLTtk8mXMm19HaxWGD1lePJM++TsQOh50ioroVjXQ71gD6NIDtB+O87i8KUXjD sRJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15si1128030pgf.358.2018.04.11.11.58.49; Wed, 11 Apr 2018 11:59:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933618AbeDKSy6 (ORCPT + 99 others); Wed, 11 Apr 2018 14:54:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34776 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933556AbeDKSyz (ORCPT ); Wed, 11 Apr 2018 14:54:55 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 831C099F; Wed, 11 Apr 2018 18:54:54 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Morse , Marc Zyngier , Christoffer Dall , Sasha Levin Subject: [PATCH 4.9 055/310] KVM: arm: Restore banked registers and physical timer access on hyp_panic() Date: Wed, 11 Apr 2018 20:33:14 +0200 Message-Id: <20180411183624.614135856@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: James Morse [ Upstream commit d2e19368848ce6065daa785efca26faed54732b6 ] When KVM panics, it hurridly restores the host context and parachutes into the host's panic() code. This looks like it was copied from arm64, the 32bit KVM panic code needs to restore the host's banked registers too. At some point panic() touches the physical timer/counter, this will trap back to HYP. If we're lucky, we panic again. Add a __timer_save_state() call to KVMs hyp_panic() path, this saves the guest registers and disables the traps for the host. Fixes: c36b6db5f3e4 ("ARM: KVM: Add panic handling code") Signed-off-by: James Morse Reviewed-by: Marc Zyngier Reviewed-by: Christoffer Dall Signed-off-by: Christoffer Dall Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/arm/kvm/hyp/switch.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/arm/kvm/hyp/switch.c +++ b/arch/arm/kvm/hyp/switch.c @@ -237,8 +237,10 @@ void __hyp_text __noreturn __hyp_panic(i vcpu = (struct kvm_vcpu *)read_sysreg(HTPIDR); host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context); + __timer_save_state(vcpu); __deactivate_traps(vcpu); __deactivate_vm(vcpu); + __banked_restore_state(host_ctxt); __sysreg_restore_state(host_ctxt); }