From patchwork Fri Aug 7 16:08:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 6970971 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 73E509F373 for ; Fri, 7 Aug 2015 16:12:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A920C2061B for ; Fri, 7 Aug 2015 16:12:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4242B2039C for ; Fri, 7 Aug 2015 16:12:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZNkDs-00033B-7m; Fri, 07 Aug 2015 16:10:20 +0000 Received: from mail-wi0-f172.google.com ([209.85.212.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZNkDK-0001p7-TO for linux-arm-kernel@lists.infradead.org; Fri, 07 Aug 2015 16:09:48 +0000 Received: by wicne3 with SMTP id ne3so65803017wic.1 for ; Fri, 07 Aug 2015 09:09:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eAF3gW3yzsu/MJ3KwbNHUl0irZBdezSmW0xn7aFsr9M=; b=BiQk2q4chyfvtZwhaClWPdQGi0zuOPbegnjIoPFjDg+0SThd9jTqULyNaDPmidnTyh 3qf78DhSH38PERFDawPb1SMZm7xOGjS779SR+5FNhiAJXRQoZ/zcu9gnasIVfuRVJK/8 /Hx2NUhHe7avzXRTZfOol0ofEjoeQ/4ffrZa85mzif90Q7tYH2oWlV9QFANbrz/d1jkv CF0i2DefFU6Grpcpf9N6Owzp1K+zkIZu+NWT9cMLCbZhrEmlTpRSgUFI4n8Vg0bx2CDd CvVtHXbuLG67rtZ+UkUnc9qu15T+3pKCAW54XNUQEc0vwqp+z0NJRmrG/aI44iX1w1Tb YVvA== X-Gm-Message-State: ALoCoQlSIQcxA7XgQUjxhpSoGjKlJE25OJPITkw9kttUYfA3q+r/GfTwGBtLrdiMxGPj1uk9I27x X-Received: by 10.180.215.101 with SMTP id oh5mr8526071wic.6.1438963765222; Fri, 07 Aug 2015 09:09:25 -0700 (PDT) Received: from gnx2579.home (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id by17sm9127438wib.18.2015.08.07.09.09.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Aug 2015 09:09:24 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, drjones@redhat.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH v2 3/4] KVM: arm/arm64: check power_off in critical section before VCPU run Date: Fri, 7 Aug 2015 18:08:32 +0200 Message-Id: <1438963713-10460-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438963713-10460-1-git-send-email-eric.auger@linaro.org> References: <1438963713-10460-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150807_090947_243592_BBB97FAE X-CRM114-Status: GOOD ( 12.50 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, linux-kernel@vger.kernel.org, patches@linaro.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-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case KVM_SET_MP_STATE ioctl is called just after we executed the vcpu_sleep check, we can enter the guest although KVM_MP_STATE_STOPPED is set. Let's check the power_off state in the critical section, just before entering the guest. Signed-off-by: Eric Auger Reported-by: Christoffer Dall --- arch/arm/kvm/arm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 4f50be3..cc404a8 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -555,7 +555,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) run->exit_reason = KVM_EXIT_INTR; } - if (ret <= 0 || need_new_vmid_gen(vcpu->kvm)) { + if (ret <= 0 || need_new_vmid_gen(vcpu->kvm) || + vcpu->arch.power_off) { local_irq_enable(); kvm_vgic_sync_hwstate(vcpu); preempt_enable();