Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2072482ybp; Thu, 10 Oct 2019 01:40:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9iBYnGZ2uIFlAlPk8C94ukiJ7yofMkaBm2Qypo4Ru7wknU/d9Ad09qmG4kjiEYEN8vHk5 X-Received: by 2002:a17:906:31d4:: with SMTP id f20mr6974713ejf.265.1570696847435; Thu, 10 Oct 2019 01:40:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570696847; cv=none; d=google.com; s=arc-20160816; b=lhvg5c/iUpNfGCUEUsn9YOudn/JUaRsnw4TtDBU1p4EL7dr+f/nQ7DPcjvUm0zOlKV S+keMjqoW7jokC2NT3Ujq7M+WxvH5xg/Tydj51mAWhIoHJ9sSYgjnaEKWt9Q8dxwXUR5 EGQHguK/uuBPdUJv97auZz79r55m8jTbZLos7oVuGYgATbtYMqZVgpS8/lcgpMJrdhVU tBxrOII+FwpQLefOc05IqC3sGdn9IbXeX6kUKBnVKEh0iVyrg8OAcuKEc68DU8/gG3sJ cMJlWjK7CX0JPFjGyU9eF4KMNS/KrY7QxX7wdZnN64NB1SmSXZQwlJhal7337qB6F6rs T2og== 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=fVY+ZMVq8TpJOuCNkLk9i6N41ikPK+ynC/TGtKQNX60=; b=x3la4TPi6PQOfTzIbj0qouN7jxUGnkxIublK4K4f+nGAR3iWoWzKR+Tyz2qcl2cfXl 6YXults03q6Xmv2nf/YRVLba3luxQHbtT/pra+PxEQZmD1memtwGn7rNgsZ21x+/P00D Z1EDncbwLfpcT9Hsw8Yjvc8W+nKl6p61EqP3VDmRenyoUpQ1T+gUw7MPvxZ03sZ5s97i ZPpdOSqFt7sTdZIxBnZWAfcRCT3lVyvKz8oKGSsyZ3sV5MEKcpwPCqfBMS1TkBVBcurY 52wuf6LkFan0JPlTQ5zuy/N9DGplsi78pLz8nd1pgMMPESeUvUikThxms/XFcE2muQSi rysw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cUJEdXv3; 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 w1si2712028edt.288.2019.10.10.01.40.24; Thu, 10 Oct 2019 01:40:47 -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=cUJEdXv3; 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 S2387503AbfJJIiD (ORCPT + 99 others); Thu, 10 Oct 2019 04:38:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:40754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733242AbfJJIiC (ORCPT ); Thu, 10 Oct 2019 04:38:02 -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 DC8B9218AC; Thu, 10 Oct 2019 08:37:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696680; bh=KVIefgYKWyqtPqq32prcAvLAwdmrycoJNpUEJNBBK+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cUJEdXv3qNU0IQSv9cY6MN9iLvTisBRz/XdneU3IEyT7VFGQJMIK5W97r8/c9Zn5/ 0dlmRBF9MPjwx7g+VPJGV63OBVsf1fJkqgm5yII378IpJRZRnYVbYwuoVZSrZE0t6v P0/rSsIhT00K8F5c9qj8QsSZXL+J5iiBMT62eQgQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Mackerras Subject: [PATCH 5.3 014/148] KVM: PPC: Book3S HV: Check for MMU ready on piggybacked virtual cores Date: Thu, 10 Oct 2019 10:34:35 +0200 Message-Id: <20191010083611.971557085@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@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 From: Paul Mackerras commit d28eafc5a64045c78136162af9d4ba42f8230080 upstream. When we are running multiple vcores on the same physical core, they could be from different VMs and so it is possible that one of the VMs could have its arch.mmu_ready flag cleared (for example by a concurrent HPT resize) when we go to run it on a physical core. We currently check the arch.mmu_ready flag for the primary vcore but not the flags for the other vcores that will be run alongside it. This adds that check, and also a check when we select the secondary vcores from the preempted vcores list. Cc: stable@vger.kernel.org # v4.14+ Fixes: 38c53af85306 ("KVM: PPC: Book3S HV: Fix exclusion between HPT resizing and other HPT updates") Signed-off-by: Paul Mackerras Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kvm/book3s_hv.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -2860,7 +2860,7 @@ static void collect_piggybacks(struct co if (!spin_trylock(&pvc->lock)) continue; prepare_threads(pvc); - if (!pvc->n_runnable) { + if (!pvc->n_runnable || !pvc->kvm->arch.mmu_ready) { list_del_init(&pvc->preempt_list); if (pvc->runner == NULL) { pvc->vcore_state = VCORE_INACTIVE; @@ -2881,15 +2881,20 @@ static void collect_piggybacks(struct co spin_unlock(&lp->lock); } -static bool recheck_signals(struct core_info *cip) +static bool recheck_signals_and_mmu(struct core_info *cip) { int sub, i; struct kvm_vcpu *vcpu; + struct kvmppc_vcore *vc; - for (sub = 0; sub < cip->n_subcores; ++sub) - for_each_runnable_thread(i, vcpu, cip->vc[sub]) + for (sub = 0; sub < cip->n_subcores; ++sub) { + vc = cip->vc[sub]; + if (!vc->kvm->arch.mmu_ready) + return true; + for_each_runnable_thread(i, vcpu, vc) if (signal_pending(vcpu->arch.run_task)) return true; + } return false; } @@ -3119,7 +3124,7 @@ static noinline void kvmppc_run_core(str local_irq_disable(); hard_irq_disable(); if (lazy_irq_pending() || need_resched() || - recheck_signals(&core_info) || !vc->kvm->arch.mmu_ready) { + recheck_signals_and_mmu(&core_info)) { local_irq_enable(); vc->vcore_state = VCORE_INACTIVE; /* Unlock all except the primary vcore */