From patchwork Sun Apr 23 17:09:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9695063 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D8BD660245 for ; Sun, 23 Apr 2017 17:13:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3BCD26538 for ; Sun, 23 Apr 2017 17:13:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B89FF267EC; Sun, 23 Apr 2017 17:13:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 623C126538 for ; Sun, 23 Apr 2017 17:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163160AbdDWRNz (ORCPT ); Sun, 23 Apr 2017 13:13:55 -0400 Received: from mail-wr0-f172.google.com ([209.85.128.172]:35928 "EHLO mail-wr0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162948AbdDWRKg (ORCPT ); Sun, 23 Apr 2017 13:10:36 -0400 Received: by mail-wr0-f172.google.com with SMTP id l50so5312415wrc.3 for ; Sun, 23 Apr 2017 10:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LCZWzRQNT4atSy644C/EqlriROg72PvzjMY77IQZg58=; b=FvR91/SPKwuIwJeFXQRZqDGrZSktzeMFpDy85+zne96OFKyqOUPRs8H0sDe+CtCiHn JEWTgtVbjetMkO7ze/jImGPSUXwmq1YElGKgsbauavMJlekzPEr8pkc8ZjmIXt5nfMFl HN5jn1TLlbsywLVo9xEc/0VBXShFVQmMlG7QY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LCZWzRQNT4atSy644C/EqlriROg72PvzjMY77IQZg58=; b=Md5x3zEPFRY9jgTLd5cXrmiMfi4C39SqfIuC6bcqntebjGp2KQpgPhYGqC+8MjmXC3 /G8fTB4ftPIqPLMZJ9KkH6EL8I/KqFjNRwzqhD8zx46jLft7Nd05EpHrF2njZ5wwmjJE RQla5TJtJbLZB7sKba/kL4+VSvtNiRV1/6kYTHyut6GW0K3jUf+Hi3JoxTLkSYeaxEAL O24oNFwtM5IVrTz64AGiZHID8uNpIPBH2wEOCW59oIeMs3BTA7SeZcHnpSkXeUIc+Tns 32SbbWvItWl+cPdF1PwhjF2b4IH7yrhdJd0OvJY24NswQV1AMuRJ+VTQUl/Y2rV78okw nMsg== X-Gm-Message-State: AN3rC/5YsKSEw2EaRLT0IHjxCTvYnEZKr5OftHlKvWZn3/VFku0lfX2N QmjWnNX2zLe9gCNt X-Received: by 10.223.131.67 with SMTP id 61mr2670916wrd.57.1492967435197; Sun, 23 Apr 2017 10:10:35 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id 58sm2803521edz.2.2017.04.23.10.10.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Apr 2017 10:10:34 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christoffer Dall Subject: [PULL 60/79] ARM: KVM: Gracefully handle hyp-stubs being restored from under our feet Date: Sun, 23 Apr 2017 19:09:10 +0200 Message-Id: <20170423170929.27334-61-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170423170929.27334-1-cdall@linaro.org> References: <20170423170929.27334-1-cdall@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier Should kvm_reboot() be invoked while guest is running, an IPI wil be issued, forcing the guest to exit and HYP being reset to the stubs. We will then try to reenter the guest, only to get an error (HVC_STUB_ERR). This patch allows this case to be gracefully handled by exiting the run loop. Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm/include/asm/kvm_asm.h | 2 +- arch/arm/kvm/handle_exit.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/kvm_asm.h b/arch/arm/include/asm/kvm_asm.h index eae11b3..14d68a4 100644 --- a/arch/arm/include/asm/kvm_asm.h +++ b/arch/arm/include/asm/kvm_asm.h @@ -33,7 +33,7 @@ #define ARM_EXCEPTION_IRQ 5 #define ARM_EXCEPTION_FIQ 6 #define ARM_EXCEPTION_HVC 7 - +#define ARM_EXCEPTION_HYP_GONE HVC_STUB_ERR /* * The rr_lo_hi macro swaps a pair of registers depending on * current endianness. It is used in conjunction with ldrd and strd diff --git a/arch/arm/kvm/handle_exit.c b/arch/arm/kvm/handle_exit.c index 96af65a..5fd7968 100644 --- a/arch/arm/kvm/handle_exit.c +++ b/arch/arm/kvm/handle_exit.c @@ -160,6 +160,14 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, case ARM_EXCEPTION_DATA_ABORT: kvm_inject_vabt(vcpu); return 1; + case ARM_EXCEPTION_HYP_GONE: + /* + * HYP has been reset to the hyp-stub. This happens + * when a guest is pre-empted by kvm_reboot()'s + * shutdown call. + */ + run->exit_reason = KVM_EXIT_FAIL_ENTRY; + return 0; default: kvm_pr_unimpl("Unsupported exception type: %d", exception_index);