From patchwork Mon Jan 7 18:39:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 1021496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43YPWc23Ffz9s7T for ; Tue, 8 Jan 2019 05:47:08 +1100 (AEDT) Received: from localhost ([127.0.0.1]:47866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggZvW-00089H-4q for incoming@patchwork.ozlabs.org; Mon, 07 Jan 2019 13:47:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggZq8-0003Xu-TE for qemu-devel@nongnu.org; Mon, 07 Jan 2019 13:41:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggZq7-0004Ic-KT for qemu-devel@nongnu.org; Mon, 07 Jan 2019 13:41:32 -0500 Received: from 9.mo173.mail-out.ovh.net ([46.105.72.44]:60154) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ggZq5-00044A-25 for qemu-devel@nongnu.org; Mon, 07 Jan 2019 13:41:30 -0500 Received: from player687.ha.ovh.net (unknown [10.109.146.5]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id 8BD66E4E2D for ; Mon, 7 Jan 2019 19:41:25 +0100 (CET) Received: from kaod.org (lfbn-1-10605-110.w90-89.abo.wanadoo.fr [90.89.196.110]) (Authenticated sender: clg@kaod.org) by player687.ha.ovh.net (Postfix) with ESMTPSA id 7C56A1604F91; Mon, 7 Jan 2019 18:41:17 +0000 (UTC) From: =?utf-8?q?C=C3=A9dric_Le_Goater?= To: David Gibson Date: Mon, 7 Jan 2019 19:39:45 +0100 Message-Id: <20190107183946.7230-13-clg@kaod.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107183946.7230-1-clg@kaod.org> References: <20190107183946.7230-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 11336967637229931494 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrvdejgdduudegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.105.72.44 Subject: [Qemu-devel] [PATCH 12/13] spapr/xics: ignore the lower 4K in the IRQ number space 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: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The IRQ number space of the XIVE and XICS interrupt mode are aligned when using the dual interrupt mode for the machine. This means that the ICS offset is set to zero in QEMU and that the KVM XICS device should be informed of this new value. Unfortunately, there is now way to do so and KVM still maintains the XICS_IRQ_BASE (0x1000) offset. Ignore the lower 4K which are not used under the XICS interrupt mode. These IRQ numbers are only claimed by XIVE for the CPU IPIs. Signed-off-by: Cédric Le Goater --- hw/intc/xics_kvm.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 651bbfdf6966..1d21ff217b82 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -238,6 +238,15 @@ static void ics_get_kvm_state(ICSState *ics) for (i = 0; i < ics->nr_irqs; i++) { ICSIRQState *irq = &ics->irqs[i]; + /* + * The KVM XICS device considers that the IRQ numbers should + * start at XICS_IRQ_BASE (0x1000). Ignore the lower 4K + * numbers (only claimed by XIVE for the CPU IPIs). + */ + if (i + ics->offset < XICS_IRQ_BASE) { + continue; + } + kvm_device_access(kernel_xics_fd, KVM_DEV_XICS_GRP_SOURCES, i + ics->offset, &state, false, &error_fatal); @@ -303,6 +312,15 @@ static int ics_set_kvm_state(ICSState *ics, int version_id) ICSIRQState *irq = &ics->irqs[i]; int ret; + /* + * The KVM XICS device considers that the IRQ numbers should + * start at XICS_IRQ_BASE (0x1000). Ignore the lower 4K + * numbers (only claimed by XIVE for the CPU IPIs). + */ + if (i + ics->offset < XICS_IRQ_BASE) { + continue; + } + state = irq->server; state |= (uint64_t)(irq->saved_priority & KVM_XICS_PRIORITY_MASK) << KVM_XICS_PRIORITY_SHIFT;