Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3545195imu; Mon, 7 Jan 2019 05:24:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN4FyjdocC06uM1YRNHyvGAP0NVtf06w4M3Ime/KDcEwZJx62Z8t0pnFY2Ze4MAltBMMqraP X-Received: by 2002:a17:902:a9c4:: with SMTP id b4mr61218729plr.298.1546867475572; Mon, 07 Jan 2019 05:24:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546867475; cv=none; d=google.com; s=arc-20160816; b=mHsVZKJzRUi7GbmzyeDcGQr3Zr/+NOmqJMu3wDur2H/P3YCdp0h/T//H0y2cgsIfwW 6/UqZooOnFzm+2X7qaH3wDweBxViRUhaP3ijDtuyJP5r1bDoahiKXKjlpn6P9CcPiHf0 p+SV+hKKwdDQusnG6gbNGDFvhKDq0OYAzbToomllnCgRnmprxYvXeappGRodUHOq2XrU S2/xsM9uAvhzAkteUi8mxlI9ejdmfxICONeXS9NOjttxRv6yrL2+ZzsPFRtWiwTiTzbS mRfWnbJvFedSLLbMC9GqdPt7md2tcz7MthK8u5UMqG1k5qcQfoSFR+lB46pndCRyx2WE dOTg== 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=8nlyfoVAw3Qh6uyb6NhzrPo2abi1QLCyWigwSsA2ylA=; b=MhM6CdPZ3RXFST7HBXT3IoJEt9Sxfr4AhWMjmk9oG4OT5namvnZQsTaK02OtlIaP3c MTDJ6Z8l9ypmDlr4zevNCv/RhNLUOeVrKG1GieLTVW6ecKeEKVCwmImfOv2P+qi3f3z2 e5RAGlHzCWIoQMmJMwGvKFzGI0bLZoWaVn4/BGneh0HdCLgVA7zXKC5NuNZkzXGzr0s9 CTpNEsSr5yEZvOEzt8KAaIsT4wnSrqJsr7RUIaYfBPHuaQF/olFF1kxQTl5ObQrmnh7p fKPmPiaROX3MTyIYa7LKEEYHmdNm9C/bOfA+SJhuNKvNCXL8TQVA/9T3UeWj4eXezdp5 wQJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ThiH/T6f"; 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 o68si6177721pfo.140.2019.01.07.05.24.20; Mon, 07 Jan 2019 05:24:35 -0800 (PST) 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="ThiH/T6f"; 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 S1729848AbfAGNV1 (ORCPT + 99 others); Mon, 7 Jan 2019 08:21:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:34108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728801AbfAGMpF (ORCPT ); Mon, 7 Jan 2019 07:45:05 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 CFAFE2183E; Mon, 7 Jan 2019 12:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546865105; bh=10Dcalrs+Qt4Txyv0of0WKE8I0S+q9W7GelN7WZhdL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ThiH/T6f/+eLNNZCei4ELtNPa++3L+DUj2cVncRUQqkCxQJ07kr4r2YU7SAp+n9iG yqoAluSWlsB9bFsfetgaumCPUInQLboK55JXytu0c2O/bzq4FE5BigF6yJTACA+1i2 zob+IxGCgpomCS1byvFOlmm8ka6VJjw5HtEI7y/M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoffer Dall , Marc Zyngier Subject: [PATCH 4.20 137/145] KVM: arm/arm64: vgic-v2: Set active_source to 0 when restoring state Date: Mon, 7 Jan 2019 13:32:54 +0100 Message-Id: <20190107104455.122701207@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107104437.308206189@linuxfoundation.org> References: <20190107104437.308206189@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christoffer Dall commit 60c3ab30d8c2ff3a52606df03f05af2aae07dc6b upstream. When restoring the active state from userspace, we don't know which CPU was the source for the active state, and this is not architecturally exposed in any of the register state. Set the active_source to 0 in this case. In the future, we can expand on this and exposse the information as additional information to userspace for GICv2 if anyone cares. Cc: stable@vger.kernel.org Signed-off-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Greg Kroah-Hartman --- virt/kvm/arm/vgic/vgic-mmio.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) --- a/virt/kvm/arm/vgic/vgic-mmio.c +++ b/virt/kvm/arm/vgic/vgic-mmio.c @@ -317,11 +317,26 @@ static void vgic_mmio_change_active(stru vgic_hw_irq_change_active(vcpu, irq, active, !requester_vcpu); } else { u32 model = vcpu->kvm->arch.vgic.vgic_model; + u8 active_source; irq->active = active; + + /* + * The GICv2 architecture indicates that the source CPUID for + * an SGI should be provided during an EOI which implies that + * the active state is stored somewhere, but at the same time + * this state is not architecturally exposed anywhere and we + * have no way of knowing the right source. + * + * This may lead to a VCPU not being able to receive + * additional instances of a particular SGI after migration + * for a GICv2 VM on some GIC implementations. Oh well. + */ + active_source = (requester_vcpu) ? requester_vcpu->vcpu_id : 0; + if (model == KVM_DEV_TYPE_ARM_VGIC_V2 && active && vgic_irq_is_sgi(irq->intid)) - irq->active_source = requester_vcpu->vcpu_id; + irq->active_source = active_source; } if (irq->active)