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: 9695149 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 4698C601E9 for ; Sun, 23 Apr 2017 17:31:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43550203B9 for ; Sun, 23 Apr 2017 17:31:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37BA5262F2; Sun, 23 Apr 2017 17:31:14 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B7DE9203B9 for ; Sun, 23 Apr 2017 17:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7CMqp1qeQDXSwK5u1WdCZDBBCVONvU/LGW7wptThhls=; b=lgArVAIk3bD34WW64qZv/KG37W HPKOZmD94qGm1Oc8WtZFSdsqyz2SnFUuBcL5ypLP+yQ1Cf/2JvS6iyYJAEubjsUGbZS2o5welQMuX aNFAEgtII9ma3qlT5H4FZJK8uYmbWuBkqyu5xoi/XMoswPN9aWZvbIs9TIBNizEWrIMXsw6A4VG9h K+9Yyep+Is04Ent5n5RsyFmv+98ELUjH4GfNVu4rV+UDQ6bfFrxd6te7681zfmuao4/gEsxwGZidj zgWlwxI4wZAuWY3oG9p4Lbf6mZb9q4E1/uYpou6JR2Hn8nfKeYuD6g+eRw50WNWRJqR3dQ9CLnDwx rOtweFKw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d2LLt-0002yV-6w; Sun, 23 Apr 2017 17:31:13 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2LLb-0002ZO-2Y for linux-arm-kernel@bombadil.infradead.org; Sun, 23 Apr 2017 17:30:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LCZWzRQNT4atSy644C/EqlriROg72PvzjMY77IQZg58=; b=U09WyWyR/RNviU6+3YZ7hkWT/ QAIMKIN7JEd68Kd3+/nIOIKFYrzjhCgUPCOY90prWkTV9MljJobm7DqTUONSHupi/E4WIRvdpYDzV 0G8+3L3TnmoGIJrbupxbLfm7+HxVORTGuBZxErOY5HX1jfe7aXW5TeGdjKTk8o0Eu73idGxilFVuS gj0rKQJX8N+hrRe92tt4nJDHgc2Q/f+eNV4e/3ayHixVtdIe1BAaU876fRlXsWbz+TLzaTwHYqWT7 mm/fskVyX5VcJ+/6m4tIH/lfQpKP0MoUPuWGTJtPhsvdFgUn7YFWwwggu/2dbv2dlDgFEGare2GUF Mqo+tHCKQ==; Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2LAu-0005s9-I3 for linux-arm-kernel@lists.infradead.org; Sun, 23 Apr 2017 17:19:59 +0000 Received: by mail-wr0-x233.google.com with SMTP id w50so55906906wrc.0 for ; Sun, 23 Apr 2017 10:19:32 -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=Ax9RY8IMLagr2tkh4i1ggulS71Z6EfX9QA6hmRouNzsYlEH5nG2/M8F4wXwutV8WZ6 gyHauKPayDZuc1vVZexlnjkDpBpZQQknNfzNyREE3qpzYY1mn466Uw4LdP/fXj+5+nPt oVLrEgXIl1RJMZRF5zqmtzm92BfrC5Hn8OyAC7Rng/A6LpaMwUytkglapfA2p6Ky9n2x MAZyPoJ7NMG/JJMRPUQsAc/m364YjfNfWD3bxeQGZ0lb1lEz90e6i5R6Cg++3mIKgfZp VmTnfRDblTm/tKQC7t+YMq1FfDZ1462Kk8RolqUsMxwOiYf/3hMltiY9D17jTTgpAFet rt3A== X-Gm-Message-State: AN3rC/6oI7HLe/PJi7bXvgFfAGKSSWQoKjYPTqpo9cIX8D3EDSf40iv8 +gYBvdW5suMox66R 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?= 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170423_131952_832544_BE3D0CFB X-CRM114-Status: GOOD ( 12.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Christoffer Dall , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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);