Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2155442ybm; Thu, 23 May 2019 12:16:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzI/LJTrNvaH6hIsvUnwUGT/WPc0Ym3IyfiXgr11AGEJjba7GSMowIFsJfBfBKeLaKL97XI X-Received: by 2002:a17:902:3a3:: with SMTP id d32mr2797123pld.14.1558638970537; Thu, 23 May 2019 12:16:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558638970; cv=none; d=google.com; s=arc-20160816; b=prJ2WnwQG4jkKk6ijmT/BA9qqRvx6PkG7Io8u/PGieYq1dF1slcKsvBP81wY0GE1/i hTjLl5s81N3DVAKZfmY+HsVMt+M3yumdJPlNBxvD3tXNVH5qNXx/eoSDDswolTIR8mr2 hEfEW9TKOwlk2DDZFX1EbtibFAE8bgAmQAtUSc+P0cLT1sCuRWP0YEiu4ofZwmw3f+n2 nT85Ln6hdk5kmzPpqZKWrejTx3BwNlF9ERlpOhepKU4d8wWo8T09BYgLYgvWGGb+KoSW R4KPZ65YaN/A6Kmq3TJTTSrb093AdUnQp8eirX6eNcH686rXm/4Qrjlr0qq3p4GZOpoD iSRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=L3RV+wIZ/YIndZeWP0qcX3LhNpUPE6BHhD204yIZJFs=; b=f7SmpZJ39dRQblh6tH8oEUu6VFi10m/gdoNop6pcnfIgk535Ugw4lrBvlb0mTrPa/B vbrAlkSyX3jj0X31ViuJG6HAduTh+gFixuWoLpyTI8CUVHMb2YoSaF+ptbzXQg/ZtT7L t9B4fpqWlIhdM+C1p3Vn7GSfLut/wgYpXyat1VkIv9XD+UTloEeUfBbLV5KyxS4yJ2JL F0KkGh9ETsh/xcuvjdJUPQlYOzvvjZeYab5LXF3x/IB4ksyjKpl+ddaD71a8et2e7XRM xOgGRTGkWJH2dLpPWe+p6f6B6K/qvO+qQOEP7IHNpcfsmqgb2cFVM73bC1XGOKCHOm7v 7ypQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=atfqW5YD; 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 n6si524576plk.237.2019.05.23.12.15.55; Thu, 23 May 2019 12:16:10 -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; dkim=pass header.i=@kernel.org header.s=default header.b=atfqW5YD; 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 S2388520AbfEWTNL (ORCPT + 99 others); Thu, 23 May 2019 15:13:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:47000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388510AbfEWTNJ (ORCPT ); Thu, 23 May 2019 15:13:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CA32E217D9; Thu, 23 May 2019 19:13:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558638788; bh=UY8SQeHd7FCBBneJtTyKQp5Ic9+zcQhEBd8HXBbyPCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=atfqW5YD0D2Hn7lgl1kEIi7Ne9S5O5pW8uDSTyf21ah68r3nzSQqB8G6sB7TYB4I4 lqtTp6FvjYmDyhPwAoJLVfSVyvtF3rJkXjiuHfrpH4cv3yXKx2/gTW83fGqILolPsM ksQyGVNojG28h1Hp5rk6yV29weU1meAg0Afj6Zck= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Jones , Marc Zyngier , Sasha Levin Subject: [PATCH 4.14 65/77] KVM: arm/arm64: Ensure vcpu target is unset on reset failure Date: Thu, 23 May 2019 21:06:23 +0200 Message-Id: <20190523181728.972641334@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181719.982121681@linuxfoundation.org> References: <20190523181719.982121681@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 811328fc3222f7b55846de0cd0404339e2e1e6d7 ] A failed KVM_ARM_VCPU_INIT should not set the vcpu target, as the vcpu target is used by kvm_vcpu_initialized() to determine if other vcpu ioctls may proceed. We need to set the target before calling kvm_reset_vcpu(), but if that call fails, we should then unset it and clear the feature bitmap while we're at it. Signed-off-by: Andrew Jones [maz: Simplified patch, completed commit message] Signed-off-by: Marc Zyngier Signed-off-by: Sasha Levin --- virt/kvm/arm/arm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 32aa88c19b8d5..4154f98b337c5 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -856,7 +856,7 @@ int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level, static int kvm_vcpu_set_target(struct kvm_vcpu *vcpu, const struct kvm_vcpu_init *init) { - unsigned int i; + unsigned int i, ret; int phys_target = kvm_target_cpu(); if (init->target != phys_target) @@ -891,9 +891,14 @@ static int kvm_vcpu_set_target(struct kvm_vcpu *vcpu, vcpu->arch.target = phys_target; /* Now we know what it is, we can reset it. */ - return kvm_reset_vcpu(vcpu); -} + ret = kvm_reset_vcpu(vcpu); + if (ret) { + vcpu->arch.target = -1; + bitmap_zero(vcpu->arch.features, KVM_VCPU_MAX_FEATURES); + } + return ret; +} static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu, struct kvm_vcpu_init *init) -- 2.20.1