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: 6970871 Return-Path: X-Original-To: patchwork-kvm@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 6EE809F46B for ; Fri, 7 Aug 2015 16:09:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91F8E2039C for ; Fri, 7 Aug 2015 16:09:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8A9A2061E for ; Fri, 7 Aug 2015 16:09:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1945910AbbHGQJ2 (ORCPT ); Fri, 7 Aug 2015 12:09:28 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:34965 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1945897AbbHGQJ0 (ORCPT ); Fri, 7 Aug 2015 12:09:26 -0400 Received: by wibxm9 with SMTP id xm9so67296963wib.0 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=mm8yUvqgCPdhyrlw/jBVtkq1x0SCTM9w7YMnxzVqnxOGDRjXgKoIEW1u5vr+WvnvyH HUOO8ouueP3lKlr1NxUAeuOZ5CzJw2TytV01HRQoxv3UmWDMv1nVYbRD2RTSR0ajYtU3 00jWHWfB6EtzvG+bHOm085myr7uyTyvQtQt0KJkFPIVTphRLjwpQyFOmifepLBqTfxBq D1EDddQQmxPxjhCfabSTVdkn91LB7kgO6Tdrf25RaQS3sKmjz2vRt03MizkEjtlcMaiq Gbst/d8E4J3A+eFrHk4E1SSUvgFVEErFTRTcAvLR0gDhSQ/paJqfFV6cUqvx+rAqjSC+ HQtw== X-Gm-Message-State: ALoCoQm4vgHFhT8X3f+uVCEiI6k6y00UVUt+s0jHtAt+t/NZVwof6Ka0MySIvjexZjmR89cC1JqQ 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 Cc: linux-kernel@vger.kernel.org, patches@linaro.org, pbonzini@redhat.com 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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();