From nobody Fri Dec 19 18:59:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494400129428923.9492316580554; Wed, 10 May 2017 00:08:49 -0700 (PDT) Received: from localhost ([::1]:40741 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8Ljs-0008VL-4b for importer@patchew.org; Wed, 10 May 2017 03:08:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42522) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8Lco-0002Qo-FX for qemu-devel@nongnu.org; Wed, 10 May 2017 03:01:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8Lcm-0007mz-2Y for qemu-devel@nongnu.org; Wed, 10 May 2017 03:01:30 -0400 Received: from ozlabs.org ([103.22.144.67]:59811) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8Lcl-0007ly-OI; Wed, 10 May 2017 03:01:28 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wN6bQ2Ys1z9s7q; Wed, 10 May 2017 17:01:22 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1494399682; bh=JUvLE93jB80kcnTHUs6DyQ9aoQDa7W1xHN4e4W9oTvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cBFZUmqxKS1xyji4ajhFfRJozyDdBYP+J32HonNNRWClPcs1thhjXTbQtPcxz/JgL Kcc0paO2EIaXy/m9rLtuguEvTEebux3dT3Eoz2AN3CXcLBBh9o9xNaYoeW0BZ4Rp75 QmKVm9ybKUk8T4aGnzEfYFHdKdDEbQIbs6GiOa08= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 10 May 2017 17:01:02 +1000 Message-Id: <20170510070115.13063-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170510070115.13063-1-david@gibson.dropbear.id.au> References: <20170510070115.13063-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 09/22] ppc/xics: preserve P and Q bits for KVM IRQs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com, nikunj@linux.vnet.ibm.com, aik@ozlabs.ru, mark.cave-ayland@ilande.co.uk, agraf@suse.de, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, clg@kaod.org, sjitindarsingh@gmail.com, bharata@linux.vnet.ibm.com, sam.bobroff@au1.ibm.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sam Bobroff Kernel commit 17d48610ae0f ("KVM: PPC: Book 3S: XICS: Implement ICS P/Q states") added new bits to the state used by KVM IRQs. Currently, QEMU does not preserve these bits, so migrating (or otherwise saving and restoring) the guest state causes the P and Q bits to be cleared. Clearing the P bit has no effect, because the kernel will set it based on other data, but the loss of a set Q bit will cause a lost interrupt. This patch preserves the P and Q bits, correcting the problem. Signed-off-by: Sam Bobroff Signed-off-by: David Gibson --- hw/intc/xics_kvm.c | 12 ++++++++++++ include/hw/ppc/xics.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 03c1fc7..dd93531 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -229,6 +229,12 @@ static void ics_get_kvm_state(ICSState *ics) | XICS_STATUS_REJECTED; } } + if (state & KVM_XICS_PRESENTED) { + irq->status |=3D XICS_STATUS_PRESENTED; + } + if (state & KVM_XICS_QUEUED) { + irq->status |=3D XICS_STATUS_QUEUED; + } } } =20 @@ -266,6 +272,12 @@ static int ics_set_kvm_state(ICSState *ics, int versio= n_id) state |=3D KVM_XICS_PENDING; } } + if (irq->status & XICS_STATUS_PRESENTED) { + state |=3D KVM_XICS_PRESENTED; + } + if (irq->status & XICS_STATUS_QUEUED) { + state |=3D KVM_XICS_QUEUED; + } =20 ret =3D ioctl(kernel_xics_fd, KVM_SET_DEVICE_ATTR, &attr); if (ret !=3D 0) { diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index c215dc7..68525c8 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -144,6 +144,8 @@ struct ICSIRQState { #define XICS_STATUS_SENT 0x2 #define XICS_STATUS_REJECTED 0x4 #define XICS_STATUS_MASKED_PENDING 0x8 +#define XICS_STATUS_PRESENTED 0x10 +#define XICS_STATUS_QUEUED 0x20 uint8_t status; /* (flags & XICS_FLAGS_IRQ_MASK) =3D=3D 0 means the interrupt is not alloc= ated */ #define XICS_FLAGS_IRQ_LSI 0x1 --=20 2.9.3