From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665549; cv=none; d=zohomail.com; s=zohoarc; b=JjRtfbKFt/ihU4bkdxioEY3LhmGVgTUdy+h3F0Vh6o4O1r2nC/nGiOrW+em1rXM80FEauMaoANmLU9c0apZq+JoH9TD5YkpUg2KeEWcEMgaVDUYG4AK+EHVtM0/KwDCkU4VKvUU1dZRubIdWEu3t3WHK9wp0m+6V4fn9vvmt2N0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665549; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DWCGiwNo7MKcuIWaZkIrERjSqG8LFgJEpi3mQlx/TDE=; b=CRtFP8n5FZkstwIV3wuQKNxZ+Pei2p4ow1EaRPpPyoyWfFJ3ssNT147dF8Kbc7RjPvfX4t5Zoh5bBMYp11esehidPGzRPgX0bZqIH67Q96WOG4m0VgGmpe3j6E1HuXzAT2A9tl3DrYms4F5ZkJjo7jdLkJcbQXWHKwa4xk+FWd4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665549247114.48270102562935; Sun, 24 Nov 2019 23:05:49 -0800 (PST) Received: from localhost ([::1]:40802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8RP-000851-PO for importer@patchew.org; Mon, 25 Nov 2019 02:05:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41479) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Kg-0001xg-1r for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:58:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8Ke-0001Bo-JB for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:58:49 -0500 Received: from 17.mo3.mail-out.ovh.net ([87.98.178.58]:49855) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8Ke-00015y-CH for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:58:48 -0500 Received: from player697.ha.ovh.net (unknown [10.108.54.141]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id C8CBA233534 for ; Mon, 25 Nov 2019 07:58:38 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id D84C6C809409; Mon, 25 Nov 2019 06:58:31 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 01/20] ppc/xive: Introduce a XivePresenter interface Date: Mon, 25 Nov 2019 07:58:01 +0100 Message-Id: <20191125065820.927-2-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8907557115116489702 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.178.58 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When the XIVE IVRE sub-engine (XiveRouter) looks for a Notification Virtual Target (NVT) to notify, it broadcasts a message on the PowerBUS to find an XIVE IVPE sub-engine (Presenter) with the NVT dispatched on one of its HW threads, and then forwards the notification if any response was received. The current XIVE presenter model is sufficient for the pseries machine because it has a single interrupt controller device, but the PowerNV machine can have multiple chips each having its own interrupt controller. In this case, the XIVE presenter model is too simple and the CAM line matching should scan all chips of the system. To start fixing this issue, we first extend the XIVE Router model with a new XivePresenter QOM interface representing the XIVE IVPE sub-engine. This interface exposes a 'match_nvt' handler which the sPAPR and PowerNV XIVE Router models will need to implement to perform the CAM line matching. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/xive.h | 32 ++++++++++++++++++++++++++++++++ hw/intc/xive.c | 26 +++++++++++++++++--------- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index fa7adf87feb2..f9aa0fa0dac3 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -367,6 +367,38 @@ int xive_router_write_nvt(XiveRouter *xrtr, uint8_t nv= t_blk, uint32_t nvt_idx, XiveTCTX *xive_router_get_tctx(XiveRouter *xrtr, CPUState *cs); void xive_router_notify(XiveNotifier *xn, uint32_t lisn); =20 +/* + * XIVE Presenter + */ + +typedef struct XiveTCTXMatch { + XiveTCTX *tctx; + uint8_t ring; +} XiveTCTXMatch; + +typedef struct XivePresenter XivePresenter; + +#define TYPE_XIVE_PRESENTER "xive-presenter" +#define XIVE_PRESENTER(obj) \ + INTERFACE_CHECK(XivePresenter, (obj), TYPE_XIVE_PRESENTER) +#define XIVE_PRESENTER_CLASS(klass) \ + OBJECT_CLASS_CHECK(XivePresenterClass, (klass), TYPE_XIVE_PRESENTER) +#define XIVE_PRESENTER_GET_CLASS(obj) \ + OBJECT_GET_CLASS(XivePresenterClass, (obj), TYPE_XIVE_PRESENTER) + +typedef struct XivePresenterClass { + InterfaceClass parent; + int (*match_nvt)(XivePresenter *xptr, uint8_t format, + uint8_t nvt_blk, uint32_t nvt_idx, + bool cam_ignore, uint8_t priority, + uint32_t logic_serv, XiveTCTXMatch *match); +} XivePresenterClass; + +int xive_presenter_tctx_match(XivePresenter *xptr, XiveTCTX *tctx, + uint8_t format, + uint8_t nvt_blk, uint32_t nvt_idx, + bool cam_ignore, uint32_t logic_serv); + /* * XIVE END ESBs */ diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 511e1a936347..344bb3f3bc4b 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -1363,9 +1363,10 @@ static uint32_t xive_tctx_hw_cam_line(XiveTCTX *tctx) /* * The thread context register words are in big-endian format. */ -static int xive_presenter_tctx_match(XiveTCTX *tctx, uint8_t format, - uint8_t nvt_blk, uint32_t nvt_idx, - bool cam_ignore, uint32_t logic_serv) +int xive_presenter_tctx_match(XivePresenter *xptr, XiveTCTX *tctx, + uint8_t format, + uint8_t nvt_blk, uint32_t nvt_idx, + bool cam_ignore, uint32_t logic_serv) { uint32_t cam =3D xive_nvt_cam_line(nvt_blk, nvt_idx); uint32_t qw3w2 =3D xive_tctx_word2(&tctx->regs[TM_QW3_HV_PHYS]); @@ -1422,11 +1423,6 @@ static int xive_presenter_tctx_match(XiveTCTX *tctx,= uint8_t format, return -1; } =20 -typedef struct XiveTCTXMatch { - XiveTCTX *tctx; - uint8_t ring; -} XiveTCTXMatch; - static bool xive_presenter_match(XiveRouter *xrtr, uint8_t format, uint8_t nvt_blk, uint32_t nvt_idx, bool cam_ignore, uint8_t priority, @@ -1460,7 +1456,8 @@ static bool xive_presenter_match(XiveRouter *xrtr, ui= nt8_t format, * Check the thread context CAM lines and record matches. We * will handle CPU exception delivery later */ - ring =3D xive_presenter_tctx_match(tctx, format, nvt_blk, nvt_idx, + ring =3D xive_presenter_tctx_match(XIVE_PRESENTER(xrtr), tctx, for= mat, + nvt_blk, nvt_idx, cam_ignore, logic_serv); /* * Save the context and follow on to catch duplicates, that we @@ -1754,6 +1751,7 @@ static const TypeInfo xive_router_info =3D { .class_init =3D xive_router_class_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_XIVE_NOTIFIER }, + { TYPE_XIVE_PRESENTER }, { } } }; @@ -1923,10 +1921,20 @@ static const TypeInfo xive_notifier_info =3D { .class_size =3D sizeof(XiveNotifierClass), }; =20 +/* + * XIVE Presenter + */ +static const TypeInfo xive_presenter_info =3D { + .name =3D TYPE_XIVE_PRESENTER, + .parent =3D TYPE_INTERFACE, + .class_size =3D sizeof(XivePresenterClass), +}; + static void xive_register_types(void) { type_register_static(&xive_source_info); type_register_static(&xive_notifier_info); + type_register_static(&xive_presenter_info); type_register_static(&xive_router_info); type_register_static(&xive_end_source_info); type_register_static(&xive_tctx_info); --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665366; cv=none; d=zohomail.com; s=zohoarc; b=QU8lubbxnB61akW4QbDJrAE5yvusvp3x5213prPfkeZNd8uP4FcTRpGCiuaepP9jN+n9fzyTFMzk1E/2G8HgKaTPfipmgeIyRiMSDAlgJNabiW41yq3BgTntTt1GSmkMaUy+YDid05Ilnrn9mdevAOiGzU/1772ETG5OYJ+bc28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665366; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l/agrnZQuvtIruTosAqUl9197qF5kMw5U/2PpSDK53s=; b=E5fm9+sR54cE1X8eMfccWfEpnbgqXyRrg6vRNVfTjfdujSzTIBnUynrRF1OBsBP0DapXZJbJzR2fRoGdd1e1R3p4zIK9c+MkC4rCm1D4m2sEJLYPlUPyzp3D+2klecixuRlCORwBcaPoAd0p6PIc7a1pU7Kp2bikBSKvoyrm564= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665366792145.10674522058196; Sun, 24 Nov 2019 23:02:46 -0800 (PST) Received: from localhost ([::1]:40754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8OS-0004LM-Qv for importer@patchew.org; Mon, 25 Nov 2019 02:02:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41455) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Ke-0001uj-F2 for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:58:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8Kb-00019m-S7 for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:58:48 -0500 Received: from 18.mo3.mail-out.ovh.net ([87.98.172.162]:52996) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8Kb-00018i-Ge for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:58:45 -0500 Received: from player697.ha.ovh.net (unknown [10.109.146.137]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id 05080233542 for ; Mon, 25 Nov 2019 07:58:44 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 89C62C809435; Mon, 25 Nov 2019 06:58:38 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 02/20] ppc/xive: Implement the XivePresenter interface Date: Mon, 25 Nov 2019 07:58:02 +0100 Message-Id: <20191125065820.927-3-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8908964491588832230 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedu Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.172.162 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Each XIVE Router model, sPAPR and PowerNV, now implements the 'match_nvt' handler of the XivePresenter QOM interface. This is simply moving code and taking into account the new API. To be noted that the xive_router_get_tctx() helper is not used anymore when doing CAM matching and will be removed later on after other changes. The XIVE presenter model is still too simple for the PowerNV machine and the CAM matching algo is not correct on multichip system. Subsequent patches will introduce more changes to scan all chips of the system. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz Signed-off-by: C=C3=A9dric Le Goater --- hw/intc/pnv_xive.c | 41 +++++++++++++++++++++++++++++++++++ hw/intc/spapr_xive.c | 49 ++++++++++++++++++++++++++++++++++++++++++ hw/intc/xive.c | 51 ++++++-------------------------------------- 3 files changed, 97 insertions(+), 44 deletions(-) diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index 9a771f640763..8055de89cf63 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -372,6 +372,45 @@ static int pnv_xive_get_eas(XiveRouter *xrtr, uint8_t = blk, uint32_t idx, return pnv_xive_vst_read(xive, VST_TSEL_IVT, blk, idx, eas); } =20 +static int pnv_xive_match_nvt(XivePresenter *xptr, uint8_t format, + uint8_t nvt_blk, uint32_t nvt_idx, + bool cam_ignore, uint8_t priority, + uint32_t logic_serv, XiveTCTXMatch *match) +{ + CPUState *cs; + int count =3D 0; + + CPU_FOREACH(cs) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + XiveTCTX *tctx =3D XIVE_TCTX(pnv_cpu_state(cpu)->intc); + int ring; + + /* + * Check the thread context CAM lines and record matches. + */ + ring =3D xive_presenter_tctx_match(xptr, tctx, format, nvt_blk, nv= t_idx, + cam_ignore, logic_serv); + /* + * Save the context and follow on to catch duplicates, that we + * don't support yet. + */ + if (ring !=3D -1) { + if (match->tctx) { + qemu_log_mask(LOG_GUEST_ERROR, "XIVE: already found a " + "thread context NVT %x/%x\n", + nvt_blk, nvt_idx); + return -1; + } + + match->ring =3D ring; + match->tctx =3D tctx; + count++; + } + } + + return count; +} + static XiveTCTX *pnv_xive_get_tctx(XiveRouter *xrtr, CPUState *cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); @@ -1780,6 +1819,7 @@ static void pnv_xive_class_init(ObjectClass *klass, v= oid *data) PnvXScomInterfaceClass *xdc =3D PNV_XSCOM_INTERFACE_CLASS(klass); XiveRouterClass *xrc =3D XIVE_ROUTER_CLASS(klass); XiveNotifierClass *xnc =3D XIVE_NOTIFIER_CLASS(klass); + XivePresenterClass *xpc =3D XIVE_PRESENTER_CLASS(klass); =20 xdc->dt_xscom =3D pnv_xive_dt_xscom; =20 @@ -1795,6 +1835,7 @@ static void pnv_xive_class_init(ObjectClass *klass, v= oid *data) xrc->get_tctx =3D pnv_xive_get_tctx; =20 xnc->notify =3D pnv_xive_notify; + xpc->match_nvt =3D pnv_xive_match_nvt; }; =20 static const TypeInfo pnv_xive_info =3D { diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index 729246e906c9..bb3b2dfdb77f 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -405,6 +405,52 @@ static XiveTCTX *spapr_xive_get_tctx(XiveRouter *xrtr,= CPUState *cs) return spapr_cpu_state(cpu)->tctx; } =20 +static int spapr_xive_match_nvt(XivePresenter *xptr, uint8_t format, + uint8_t nvt_blk, uint32_t nvt_idx, + bool cam_ignore, uint8_t priority, + uint32_t logic_serv, XiveTCTXMatch *match) +{ + CPUState *cs; + int count =3D 0; + + CPU_FOREACH(cs) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + XiveTCTX *tctx =3D spapr_cpu_state(cpu)->tctx; + int ring; + + /* + * Skip partially initialized vCPUs. This can happen when + * vCPUs are hotplugged. + */ + if (!tctx) { + continue; + } + + /* + * Check the thread context CAM lines and record matches. + */ + ring =3D xive_presenter_tctx_match(xptr, tctx, format, nvt_blk, nv= t_idx, + cam_ignore, logic_serv); + /* + * Save the matching thread interrupt context and follow on to + * check for duplicates which are invalid. + */ + if (ring !=3D -1) { + if (match->tctx) { + qemu_log_mask(LOG_GUEST_ERROR, "XIVE: already found a thre= ad " + "context NVT %x/%x\n", nvt_blk, nvt_idx); + return -1; + } + + match->ring =3D ring; + match->tctx =3D tctx; + count++; + } + } + + return count; +} + static const VMStateDescription vmstate_spapr_xive_end =3D { .name =3D TYPE_SPAPR_XIVE "/end", .version_id =3D 1, @@ -684,6 +730,7 @@ static void spapr_xive_class_init(ObjectClass *klass, v= oid *data) DeviceClass *dc =3D DEVICE_CLASS(klass); XiveRouterClass *xrc =3D XIVE_ROUTER_CLASS(klass); SpaprInterruptControllerClass *sicc =3D SPAPR_INTC_CLASS(klass); + XivePresenterClass *xpc =3D XIVE_PRESENTER_CLASS(klass); =20 dc->desc =3D "sPAPR XIVE Interrupt Controller"; dc->props =3D spapr_xive_properties; @@ -708,6 +755,8 @@ static void spapr_xive_class_init(ObjectClass *klass, v= oid *data) sicc->print_info =3D spapr_xive_print_info; sicc->dt =3D spapr_xive_dt; sicc->post_load =3D spapr_xive_post_load; + + xpc->match_nvt =3D spapr_xive_match_nvt; } =20 static const TypeInfo spapr_xive_info =3D { diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 344bb3f3bc4b..da6196ca958f 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -1428,51 +1428,14 @@ static bool xive_presenter_match(XiveRouter *xrtr, = uint8_t format, bool cam_ignore, uint8_t priority, uint32_t logic_serv, XiveTCTXMatch *match) { - CPUState *cs; + XivePresenter *xptr =3D XIVE_PRESENTER(xrtr); + XivePresenterClass *xpc =3D XIVE_PRESENTER_GET_CLASS(xptr); + int count; =20 - /* - * TODO (PowerNV): handle chip_id overwrite of block field for - * hardwired CAM compares - */ - - CPU_FOREACH(cs) { - XiveTCTX *tctx =3D xive_router_get_tctx(xrtr, cs); - int ring; - - /* - * Skip partially initialized vCPUs. This can happen when - * vCPUs are hotplugged. - */ - if (!tctx) { - continue; - } - - /* - * HW checks that the CPU is enabled in the Physical Thread - * Enable Register (PTER). - */ - - /* - * Check the thread context CAM lines and record matches. We - * will handle CPU exception delivery later - */ - ring =3D xive_presenter_tctx_match(XIVE_PRESENTER(xrtr), tctx, for= mat, - nvt_blk, nvt_idx, - cam_ignore, logic_serv); - /* - * Save the context and follow on to catch duplicates, that we - * don't support yet. - */ - if (ring !=3D -1) { - if (match->tctx) { - qemu_log_mask(LOG_GUEST_ERROR, "XIVE: already found a thre= ad " - "context NVT %x/%x\n", nvt_blk, nvt_idx); - return false; - } - - match->ring =3D ring; - match->tctx =3D tctx; - } + count =3D xpc->match_nvt(xptr, format, nvt_blk, nvt_idx, cam_ignore, + priority, logic_serv, match); + if (count < 0) { + return false; } =20 if (!match->tctx) { --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665407; cv=none; d=zohomail.com; s=zohoarc; b=ffGaQmlneozy4AgkApWoo3Xze4z3o1f2de0x3Ngl+JrNfGRR2Wh3x+Bmyic6x0stzrhqPeo8G4HwSr46ZlfOUr9czqD5bKhxpEQRbKV2v6VzIKQzE/86qjg5+T8hesDB/Tj5Y8epkMXW09KXgcX289IvkUmUPlcdO4851UUSuLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665407; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Hoa4bbJleyvewwTTu/e59eqqN6WctzP3AsJFAgdLHfM=; b=bHDtofo4VrUSzqnTuRS0OsSYQgWmClEkqlAp/HRmqu+9hwI8mQVa3nGeU1J+aI5kk/1lSMlL21q493WCChEGjncrl2y879JnGrHRZtZOltKz1uvqyxac0XWBoWqgzbo5HNZ/bnJFrABkQL7XdtlV72SHSXZOK18ffFTrGc5RqAA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665407342566.0276245726775; Sun, 24 Nov 2019 23:03:27 -0800 (PST) Received: from localhost ([::1]:40760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8P7-0004yg-Mh for importer@patchew.org; Mon, 25 Nov 2019 02:03:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41503) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Kk-00020v-NO for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:58:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8Ki-0001Fj-CU for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:58:54 -0500 Received: from 6.mo2.mail-out.ovh.net ([87.98.165.38]:41688) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8Kh-0001Ed-TK for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:58:52 -0500 Received: from player697.ha.ovh.net (unknown [10.109.143.210]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id 34F351B5C51 for ; Mon, 25 Nov 2019 07:58:49 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 043C0C809459; Mon, 25 Nov 2019 06:58:43 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 03/20] ppc/pnv: Instantiate cores separately Date: Mon, 25 Nov 2019 07:58:03 +0100 Message-Id: <20191125065820.927-4-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8910653341843950566 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.165.38 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Greg Kurz Allocating a big void * array to store multiple objects isn't a recommended practice for various reasons: - no compile time type checking - potential dangling pointers if a reference on an individual is taken and the array is freed later on - duplicate boiler plate everywhere the array is browsed through Allocate an array of pointers and populate it instead. Signed-off-by: Greg Kurz Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/pnv.h | 2 +- hw/ppc/pnv.c | 30 ++++++++++++------------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index 90f1343ed07c..03cb429f2131 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -56,7 +56,7 @@ typedef struct PnvChip { =20 uint32_t nr_cores; uint64_t cores_mask; - void *cores; + PnvCore **cores; =20 MemoryRegion xscom_mmio; MemoryRegion xscom; diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index f0adb06c8d65..d899c83e5255 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -280,14 +280,12 @@ static void pnv_dt_icp(PnvChip *chip, void *fdt, uint= 32_t pir, =20 static void pnv_chip_power8_dt_populate(PnvChip *chip, void *fdt) { - const char *typename =3D pnv_chip_core_typename(chip); - size_t typesize =3D object_type_get_instance_size(typename); int i; =20 pnv_dt_xscom(chip, fdt, 0); =20 for (i =3D 0; i < chip->nr_cores; i++) { - PnvCore *pnv_core =3D PNV_CORE(chip->cores + i * typesize); + PnvCore *pnv_core =3D chip->cores[i]; =20 pnv_dt_core(chip, pnv_core, fdt); =20 @@ -302,14 +300,12 @@ static void pnv_chip_power8_dt_populate(PnvChip *chip= , void *fdt) =20 static void pnv_chip_power9_dt_populate(PnvChip *chip, void *fdt) { - const char *typename =3D pnv_chip_core_typename(chip); - size_t typesize =3D object_type_get_instance_size(typename); int i; =20 pnv_dt_xscom(chip, fdt, 0); =20 for (i =3D 0; i < chip->nr_cores; i++) { - PnvCore *pnv_core =3D PNV_CORE(chip->cores + i * typesize); + PnvCore *pnv_core =3D chip->cores[i]; =20 pnv_dt_core(chip, pnv_core, fdt); } @@ -913,8 +909,6 @@ static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error= **errp) { PnvChip *chip =3D PNV_CHIP(chip8); PnvChipClass *pcc =3D PNV_CHIP_GET_CLASS(chip); - const char *typename =3D pnv_chip_core_typename(chip); - size_t typesize =3D object_type_get_instance_size(typename); int i, j; char *name; XICSFabric *xi =3D XICS_FABRIC(qdev_get_machine()); @@ -928,7 +922,7 @@ static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error= **errp) =20 /* Map the ICP registers for each thread */ for (i =3D 0; i < chip->nr_cores; i++) { - PnvCore *pnv_core =3D PNV_CORE(chip->cores + i * typesize); + PnvCore *pnv_core =3D chip->cores[i]; int core_hwid =3D CPU_CORE(pnv_core)->core_id; =20 for (j =3D 0; j < CPU_CORE(pnv_core)->nr_threads; j++) { @@ -1108,8 +1102,6 @@ static void pnv_chip_power9_instance_init(Object *obj) static void pnv_chip_quad_realize(Pnv9Chip *chip9, Error **errp) { PnvChip *chip =3D PNV_CHIP(chip9); - const char *typename =3D pnv_chip_core_typename(chip); - size_t typesize =3D object_type_get_instance_size(typename); int i; =20 chip9->nr_quads =3D DIV_ROUND_UP(chip->nr_cores, 4); @@ -1118,7 +1110,7 @@ static void pnv_chip_quad_realize(Pnv9Chip *chip9, Er= ror **errp) for (i =3D 0; i < chip9->nr_quads; i++) { char eq_name[32]; PnvQuad *eq =3D &chip9->quads[i]; - PnvCore *pnv_core =3D PNV_CORE(chip->cores + (i * 4) * typesize); + PnvCore *pnv_core =3D chip->cores[i * 4]; int core_id =3D CPU_CORE(pnv_core)->core_id; =20 snprintf(eq_name, sizeof(eq_name), "eq[%d]", core_id); @@ -1290,7 +1282,6 @@ static void pnv_chip_core_realize(PnvChip *chip, Erro= r **errp) Error *error =3D NULL; PnvChipClass *pcc =3D PNV_CHIP_GET_CLASS(chip); const char *typename =3D pnv_chip_core_typename(chip); - size_t typesize =3D object_type_get_instance_size(typename); int i, core_hwid; =20 if (!object_class_by_name(typename)) { @@ -1305,21 +1296,24 @@ static void pnv_chip_core_realize(PnvChip *chip, Er= ror **errp) return; } =20 - chip->cores =3D g_malloc0(typesize * chip->nr_cores); + chip->cores =3D g_new0(PnvCore *, chip->nr_cores); =20 for (i =3D 0, core_hwid =3D 0; (core_hwid < sizeof(chip->cores_mask) *= 8) && (i < chip->nr_cores); core_hwid++) { char core_name[32]; - void *pnv_core =3D chip->cores + i * typesize; + PnvCore *pnv_core; uint64_t xscom_core_base; =20 if (!(chip->cores_mask & (1ull << core_hwid))) { continue; } =20 + pnv_core =3D PNV_CORE(object_new(typename)); + snprintf(core_name, sizeof(core_name), "core[%d]", core_hwid); - object_initialize_child(OBJECT(chip), core_name, pnv_core, typesiz= e, - typename, &error_fatal, NULL); + object_property_add_child(OBJECT(chip), core_name, OBJECT(pnv_core= ), + &error_abort); + chip->cores[i] =3D pnv_core; object_property_set_int(OBJECT(pnv_core), ms->smp.threads, "nr-thr= eads", &error_fatal); object_property_set_int(OBJECT(pnv_core), core_hwid, @@ -1340,7 +1334,7 @@ static void pnv_chip_core_realize(PnvChip *chip, Erro= r **errp) } =20 pnv_xscom_add_subregion(chip, xscom_core_base, - &PNV_CORE(pnv_core)->xscom_regs); + &pnv_core->xscom_regs); i++; } } --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665574; cv=none; d=zohomail.com; s=zohoarc; b=isRteG8ETiMZ+KkgAFVIu8WvWJAXzY71v/JN7aWjnyAYiVFKu8PBC7cB2VZU9MZm+QyM7BCriWI9jIXTeasLFXU2o9mDzMVIYCoZw7LohLbLEW/VlcLzMijR/gL42uM+wfCPawA7T8MRTGaOSP/xBgkyKL/BtZZ35SpvkntSEnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665574; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=93lTzLDvxPCWg8yhYNwqD60tuow4HILrEkt9aUe5bYk=; b=R/1I3H+nv22Mfa9lqe4MMQHXm090rjXv7OiHvRB6yULp+n7QZXnB2ipAERElIZt3TLfehoCudDAe3TeeDQNffPbfAVWae+XXP4goUt9cvIG/byj5Rn6Gc1T6eqG3XKdJq9FTE6RieZYjBbQiKi+RxnrBvOcHku49e0s2KNMSlC4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665574896706.54222670001; Sun, 24 Nov 2019 23:06:14 -0800 (PST) Received: from localhost ([::1]:40809 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Rp-0000LQ-Ok for importer@patchew.org; Mon, 25 Nov 2019 02:06:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41521) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Ko-00022f-PV for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8Km-0001Ib-Mw for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:58:58 -0500 Received: from 20.mo7.mail-out.ovh.net ([46.105.49.208]:56521) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8Km-0001I0-E7 for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:58:56 -0500 Received: from player697.ha.ovh.net (unknown [10.108.57.18]) by mo7.mail-out.ovh.net (Postfix) with ESMTP id 7B5BB13DBFE for ; Mon, 25 Nov 2019 07:58:55 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id DC7C0C809465; Mon, 25 Nov 2019 06:58:49 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 04/20] ppc/pnv: Loop on the threads of the chip to find a matching NVT Date: Mon, 25 Nov 2019 07:58:04 +0100 Message-Id: <20191125065820.927-5-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8912342187657759718 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedv Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.49.208 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" CPU_FOREACH() loops on all the CPUs of the machine which is incorrect. Each XIVE Presenter should scan only the HW threads of the chip it belongs to. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz Signed-off-by: C=C3=A9dric Le Goater --- hw/intc/pnv_xive.c | 61 ++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index 8055de89cf63..9798bd9e729f 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -377,34 +377,43 @@ static int pnv_xive_match_nvt(XivePresenter *xptr, ui= nt8_t format, bool cam_ignore, uint8_t priority, uint32_t logic_serv, XiveTCTXMatch *match) { - CPUState *cs; + PnvXive *xive =3D PNV_XIVE(xptr); + PnvChip *chip =3D xive->chip; int count =3D 0; - - CPU_FOREACH(cs) { - PowerPCCPU *cpu =3D POWERPC_CPU(cs); - XiveTCTX *tctx =3D XIVE_TCTX(pnv_cpu_state(cpu)->intc); - int ring; - - /* - * Check the thread context CAM lines and record matches. - */ - ring =3D xive_presenter_tctx_match(xptr, tctx, format, nvt_blk, nv= t_idx, - cam_ignore, logic_serv); - /* - * Save the context and follow on to catch duplicates, that we - * don't support yet. - */ - if (ring !=3D -1) { - if (match->tctx) { - qemu_log_mask(LOG_GUEST_ERROR, "XIVE: already found a " - "thread context NVT %x/%x\n", - nvt_blk, nvt_idx); - return -1; + int i, j; + + for (i =3D 0; i < chip->nr_cores; i++) { + PnvCore *pc =3D chip->cores[i]; + CPUCore *cc =3D CPU_CORE(pc); + + for (j =3D 0; j < cc->nr_threads; j++) { + PowerPCCPU *cpu =3D pc->threads[j]; + XiveTCTX *tctx; + int ring; + + tctx =3D XIVE_TCTX(pnv_cpu_state(cpu)->intc); + + /* + * Check the thread context CAM lines and record matches. + */ + ring =3D xive_presenter_tctx_match(xptr, tctx, format, nvt_blk, + nvt_idx, cam_ignore, logic_se= rv); + /* + * Save the context and follow on to catch duplicates, that we + * don't support yet. + */ + if (ring !=3D -1) { + if (match->tctx) { + qemu_log_mask(LOG_GUEST_ERROR, "XIVE: already found a " + "thread context NVT %x/%x\n", + nvt_blk, nvt_idx); + return -1; + } + + match->ring =3D ring; + match->tctx =3D tctx; + count++; } - - match->ring =3D ring; - match->tctx =3D tctx; - count++; } } =20 --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665719; cv=none; d=zohomail.com; s=zohoarc; b=Aav4jow8z4DE7tzyvwKA9lsEWeRCfNlU0tsvNlsvy2yeiYVQRFDB5OLPUULDYDiX8NuEMfYJ5Z8QY18aa1q4dPpxq3xW2jFVmLGWrGi90aetOMAe/8Hvvq+M4hjIun/M+sdlqHwKHPkr2iJIF6pm9R2vh5gQIItzuNuN187KdvQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665719; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NWZH92owuqdp6B/6dhLS3DsJT6jS9PcUdF++X3aKaHU=; b=NjXthtYEwBLtyU0qlmfU4WX/q7yDbQQXWXpurDsigPrrvRu5t44t/CcVGBM+Pcoy/LJHUYHq34RTQ8UUr/mO7GdxAdVh1jwdy+OtHvz6bbgFcFXya+iMuT0DRHHAyhGLIuv4+1zv3nUqNV/80iQ3sfvj+mIlr5ki8+E6a0WWFyY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15746657199681014.5713742626613; Sun, 24 Nov 2019 23:08:39 -0800 (PST) Received: from localhost ([::1]:40834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8U9-0003fJ-W4 for importer@patchew.org; Mon, 25 Nov 2019 02:08:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41557) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Ku-00029l-Dd for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8Kt-0001Mv-8K for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:04 -0500 Received: from 5.mo69.mail-out.ovh.net ([46.105.43.105]:44945) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8Ks-0001M4-W6 for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:03 -0500 Received: from player697.ha.ovh.net (unknown [10.109.159.48]) by mo69.mail-out.ovh.net (Postfix) with ESMTP id 7E21A6D944 for ; Mon, 25 Nov 2019 07:59:01 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 74A3CC80947F; Mon, 25 Nov 2019 06:58:55 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 05/20] ppc: Introduce a ppc_cpu_pir() helper Date: Mon, 25 Nov 2019 07:58:05 +0100 Message-Id: <20191125065820.927-6-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8914031038632791014 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.43.105 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/ppc.h | 1 + hw/ppc/ppc.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h index 4bdcb8bacd4e..585be6ab98c5 100644 --- a/include/hw/ppc/ppc.h +++ b/include/hw/ppc/ppc.h @@ -5,6 +5,7 @@ =20 void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level); PowerPCCPU *ppc_get_vcpu_by_pir(int pir); +int ppc_cpu_pir(PowerPCCPU *cpu); =20 /* PowerPC hardware exceptions management helpers */ typedef void (*clk_setup_cb)(void *opaque, uint32_t freq); diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 52a18eb7d7a3..8dd982fc1e40 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -1495,15 +1495,20 @@ void PPC_debug_write (void *opaque, uint32_t addr, = uint32_t val) } } =20 +int ppc_cpu_pir(PowerPCCPU *cpu) +{ + CPUPPCState *env =3D &cpu->env; + return env->spr_cb[SPR_PIR].default_value; +} + PowerPCCPU *ppc_get_vcpu_by_pir(int pir) { CPUState *cs; =20 CPU_FOREACH(cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); - CPUPPCState *env =3D &cpu->env; =20 - if (env->spr_cb[SPR_PIR].default_value =3D=3D pir) { + if (ppc_cpu_pir(cpu) =3D=3D pir) { return cpu; } } --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665964; cv=none; d=zohomail.com; s=zohoarc; b=bZxYl3TNI0UrBcTUPVgKvGMwk1bXnzfU0ghdf29B0vY79diSjKMlUgcRTKT16K3ciOUfbVUScNb6LzDMrSNO5Ca3lvIW2jhnCRalKWwZcIDOqLFOG9SaflwW8GWbflq+PNwNOXKL8zzLv0cSwx/N2IKZN9a5bo3lrPprOLK35tk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665964; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q8pnZmDGGtiK5f6vUp4Eq8MUcpAWyj2AGWhLojkrxQI=; b=n9JujSPjMCzL/IUAOILhAbINlbJikNt0rx9wk/9+gkIwQ7USHrzAjZW3kEedXowcI6VrBThlrRA2UaMLpJq6iPR6C1a+epqVLoi0dhdvGk7hMlwY8vOqISiqlqTwzpEBckHqispjCZrvzlBiIxrf5evfpPgxZjnQ/S7tfB0w2BA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665964253173.59040121220676; Sun, 24 Nov 2019 23:12:44 -0800 (PST) Received: from localhost ([::1]:40868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Y6-0007un-OK for importer@patchew.org; Mon, 25 Nov 2019 02:12:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41579) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Kz-0002JT-KK for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8Ky-0001Qj-Hp for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:09 -0500 Received: from 1.mo2.mail-out.ovh.net ([46.105.63.121]:54080) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8Ky-0001Pj-Bn for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:08 -0500 Received: from player697.ha.ovh.net (unknown [10.109.146.175]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id DE5CF1B5BFA for ; Mon, 25 Nov 2019 07:59:06 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 4EDC1C8094A4; Mon, 25 Nov 2019 06:59:01 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 06/20] ppc/pnv: Introduce a pnv_xive_is_cpu_enabled() helper Date: Mon, 25 Nov 2019 07:58:06 +0100 Message-Id: <20191125065820.927-7-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8915438412849712102 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedu Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.63.121 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" and use this helper to exclude CPUs which are not enabled in the XIVE controller. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/pnv.h | 5 +++++ hw/intc/pnv_xive.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index 03cb429f2131..12b0169a4010 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -99,6 +99,11 @@ typedef struct Pnv9Chip { PnvQuad *quads; } Pnv9Chip; =20 +/* + * A SMT8 fused core is a pair of SMT4 cores. + */ +#define PNV9_PIR2FUSEDCORE(pir) (((pir) >> 3) & 0xf) + typedef struct PnvChipClass { /*< private >*/ SysBusDeviceClass parent_class; diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index 9798bd9e729f..ec8349ee4a1f 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -372,6 +372,21 @@ static int pnv_xive_get_eas(XiveRouter *xrtr, uint8_t = blk, uint32_t idx, return pnv_xive_vst_read(xive, VST_TSEL_IVT, blk, idx, eas); } =20 +/* + * One bit per thread id. The first register PC_THREAD_EN_REG0 covers + * the first cores 0-15 (normal) of the chip or 0-7 (fused). The + * second register covers cores 16-23 (normal) or 8-11 (fused). + */ +static bool pnv_xive_is_cpu_enabled(PnvXive *xive, PowerPCCPU *cpu) +{ + int pir =3D ppc_cpu_pir(cpu); + uint32_t fc =3D PNV9_PIR2FUSEDCORE(pir); + uint64_t reg =3D fc < 8 ? PC_THREAD_EN_REG0 : PC_THREAD_EN_REG1; + uint32_t bit =3D pir & 0x3f; + + return xive->regs[reg >> 3] & PPC_BIT(bit); +} + static int pnv_xive_match_nvt(XivePresenter *xptr, uint8_t format, uint8_t nvt_blk, uint32_t nvt_idx, bool cam_ignore, uint8_t priority, @@ -391,6 +406,10 @@ static int pnv_xive_match_nvt(XivePresenter *xptr, uin= t8_t format, XiveTCTX *tctx; int ring; =20 + if (!pnv_xive_is_cpu_enabled(xive, cpu)) { + continue; + } + tctx =3D XIVE_TCTX(pnv_cpu_state(cpu)->intc); =20 /* --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665420; cv=none; d=zohomail.com; s=zohoarc; b=eFDKN6pebUn+acW/T3pJX6m2ZzANXMjbOllq5Jl+BYvdlpNMpFMIFLLVGCX/XMdk1tne7O3JKLpCMx63wme6/F56JF/5tMTSZTYyPY7cbO7PWnb3E8vfn8BKnqNuUXRgoyIPffIULOUDm77WBROJZxnw3RFhfAhcK+pCBXNP1Ek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665420; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e4FImBB8Wi1k7p7+MaEhGhN0Ew54oeUs8NveLQ86jWo=; b=DOUTY6oMsXem0duiwRsnPzVBM0Bz+k8JAZ2xofb//0ZmXHc734GWj2++sYBxnvoseFqgm/6GdH1AzBiyM6TIeL5xP3E/14axlKeGeuDFs6UUa/tm8KwEIDvk1WT7Y6NY/fuJLZ14YR/CrQ2pj+1Ipr3hIYfGgpWDpeTGgVeEfCM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665420741878.1013736479832; Sun, 24 Nov 2019 23:03:40 -0800 (PST) Received: from localhost ([::1]:40762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8PL-0005F5-C5 for importer@patchew.org; Mon, 25 Nov 2019 02:03:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41608) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8L6-0002Ue-KA for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8L5-0001VV-EO for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:16 -0500 Received: from 10.mo68.mail-out.ovh.net ([46.105.79.203]:49033) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8L5-0001UN-8z for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:15 -0500 Received: from player697.ha.ovh.net (unknown [10.109.160.153]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id BAC9B14DE65 for ; Mon, 25 Nov 2019 07:59:13 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id DDBD5C8094C1; Mon, 25 Nov 2019 06:59:06 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 07/20] ppc/pnv: Fix TIMA indirect access Date: Mon, 25 Nov 2019 07:58:07 +0100 Message-Id: <20191125065820.927-8-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8917408738711538662 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.79.203 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When the TIMA of a CPU needs to be accessed from the indirect page, the thread id of the target CPU is first stored in the PC_TCTXT_INDIR0 register. This thread id is relative to the chip and not to the system. Introduce a helper routine to look for a CPU of a given PIR and fix pnv_xive_get_indirect_tctx() to scan only the threads of the local chip and not the whole machine. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/pnv.h | 2 ++ hw/intc/pnv_xive.c | 13 +++++++------ hw/ppc/pnv.c | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index 12b0169a4010..a58cfea3f2fd 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -162,6 +162,8 @@ typedef struct PnvChipClass { #define PNV_CHIP_INDEX(chip) \ (((chip)->chip_id >> 2) * 2 + ((chip)->chip_id & 0x3)) =20 +PowerPCCPU *pnv_chip_find_cpu(PnvChip *chip, uint32_t pir); + #define TYPE_PNV_MACHINE MACHINE_TYPE_NAME("powernv") #define PNV_MACHINE(obj) \ OBJECT_CHECK(PnvMachineState, (obj), TYPE_PNV_MACHINE) diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index ec8349ee4a1f..b2ab2ccc91e7 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -1400,12 +1400,13 @@ static const MemoryRegionOps pnv_xive_ic_lsi_ops = =3D { */ =20 /* - * When the TIMA is accessed from the indirect page, the thread id - * (PIR) has to be configured in the IC registers before. This is used - * for resets and for debug purpose also. + * When the TIMA is accessed from the indirect page, the thread id of + * the target CPU is configured in the PC_TCTXT_INDIR0 register before + * use. This is used for resets and for debug purpose also. */ static XiveTCTX *pnv_xive_get_indirect_tctx(PnvXive *xive) { + PnvChip *chip =3D xive->chip; uint64_t tctxt_indir =3D xive->regs[PC_TCTXT_INDIR0 >> 3]; PowerPCCPU *cpu =3D NULL; int pir; @@ -1415,15 +1416,15 @@ static XiveTCTX *pnv_xive_get_indirect_tctx(PnvXive= *xive) return NULL; } =20 - pir =3D GETFIELD(PC_TCTXT_INDIR_THRDID, tctxt_indir) & 0xff; - cpu =3D ppc_get_vcpu_by_pir(pir); + pir =3D (chip->chip_id << 8) | GETFIELD(PC_TCTXT_INDIR_THRDID, tctxt_i= ndir); + cpu =3D pnv_chip_find_cpu(chip, pir); if (!cpu) { xive_error(xive, "IC: invalid PIR %x for indirect access", pir); return NULL; } =20 /* Check that HW thread is XIVE enabled */ - if (!(xive->regs[PC_THREAD_EN_REG0 >> 3] & PPC_BIT(pir & 0x3f))) { + if (!pnv_xive_is_cpu_enabled(xive, cpu)) { xive_error(xive, "IC: CPU %x is not enabled", pir); } =20 diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index d899c83e5255..8f688f4efc5a 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1371,6 +1371,23 @@ static void pnv_chip_class_init(ObjectClass *klass, = void *data) dc->desc =3D "PowerNV Chip"; } =20 +PowerPCCPU *pnv_chip_find_cpu(PnvChip *chip, uint32_t pir) +{ + int i, j; + + for (i =3D 0; i < chip->nr_cores; i++) { + PnvCore *pc =3D chip->cores[i]; + CPUCore *cc =3D CPU_CORE(pc); + + for (j =3D 0; j < cc->nr_threads; j++) { + if (ppc_cpu_pir(pc->threads[j]) =3D=3D pir) { + return pc->threads[j]; + } + } + } + return NULL; +} + static ICSState *pnv_ics_get(XICSFabric *xi, int irq) { PnvMachineState *pnv =3D PNV_MACHINE(xi); --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665743; cv=none; d=zohomail.com; s=zohoarc; b=Uad6pt1whX7Jpd8LKuco1qZXKNkhDaUlj1ctHmAY9AOiG/UApKtqJX2IpcoYWgNPT3bU9rYLSwC3kWeyQsGcGvHPT0NarkpE9vNuEPFGZ56tAm55R52QExZ4XmQIK8JKlLIMta2y/jiBTGZISwJZcGpIzgsWzX6yw2dG6qLL0q8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665743; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6H0FFsuo09+keOTzOi+fWpsNOquZ4ViYSnNi2ZOmbeQ=; b=LuyAgNajwLuA5NSDnCVtXJRdGWiJS4EiJwoxvnJA8/6fX74Kn0vKGB8FqA5WvF6d/oKvTWNXrQwJMzIeK+uaJLKKA/qguJ1bK3TsakygV8JkbNUyfic3+kSgBMWg3lqN/vEb39g4AeYwR1Yep1nqApqla9U3Xm2gEUGOM3fwGdo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665743037302.6236329634984; Sun, 24 Nov 2019 23:09:03 -0800 (PST) Received: from localhost ([::1]:40838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8UX-0004Hi-Im for importer@patchew.org; Mon, 25 Nov 2019 02:09:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41630) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8LC-0002cS-A8 for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8LA-0001a5-W5 for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:22 -0500 Received: from 2.mo173.mail-out.ovh.net ([178.33.251.49]:53371) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8LA-0001Yy-QC for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:20 -0500 Received: from player697.ha.ovh.net (unknown [10.109.159.48]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id 4CBDB123FAD for ; Mon, 25 Nov 2019 07:59:19 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 9482EC80952F; Mon, 25 Nov 2019 06:59:13 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 08/20] ppc/xive: Introduce a XiveFabric interface Date: Mon, 25 Nov 2019 07:58:08 +0100 Message-Id: <20191125065820.927-9-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8919097587041405926 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpeef Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.251.49 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The XiveFabric QOM interface acts as the PowerBUS interface between the interrupt controller and the system and should be implemented by the QEMU machine. On HW, the XIVE sub-engine is responsible for the communication with the other chip is the Common Queue (CQ) bridge unit. This interface offers a 'match_nvt' handler to perform the CAM line matching when looking for a XIVE Presenter with a dispatched NVT. Reviewed-by: Greg Kurz Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/xive.h | 22 ++++++++++++++++++++++ hw/intc/xive.c | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index f9aa0fa0dac3..b00af988779b 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -399,6 +399,28 @@ int xive_presenter_tctx_match(XivePresenter *xptr, Xiv= eTCTX *tctx, uint8_t nvt_blk, uint32_t nvt_idx, bool cam_ignore, uint32_t logic_serv); =20 +/* + * XIVE Fabric (Interface between Interrupt Controller and Machine) + */ + +typedef struct XiveFabric XiveFabric; + +#define TYPE_XIVE_FABRIC "xive-fabric" +#define XIVE_FABRIC(obj) \ + INTERFACE_CHECK(XiveFabric, (obj), TYPE_XIVE_FABRIC) +#define XIVE_FABRIC_CLASS(klass) \ + OBJECT_CLASS_CHECK(XiveFabricClass, (klass), TYPE_XIVE_FABRIC) +#define XIVE_FABRIC_GET_CLASS(obj) \ + OBJECT_GET_CLASS(XiveFabricClass, (obj), TYPE_XIVE_FABRIC) + +typedef struct XiveFabricClass { + InterfaceClass parent; + int (*match_nvt)(XiveFabric *xfb, uint8_t format, + uint8_t nvt_blk, uint32_t nvt_idx, + bool cam_ignore, uint8_t priority, + uint32_t logic_serv, XiveTCTXMatch *match); +} XiveFabricClass; + /* * XIVE END ESBs */ diff --git a/hw/intc/xive.c b/hw/intc/xive.c index da6196ca958f..1c9e58f8deac 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -1893,8 +1893,18 @@ static const TypeInfo xive_presenter_info =3D { .class_size =3D sizeof(XivePresenterClass), }; =20 +/* + * XIVE Fabric + */ +static const TypeInfo xive_fabric_info =3D { + .name =3D TYPE_XIVE_FABRIC, + .parent =3D TYPE_INTERFACE, + .class_size =3D sizeof(XiveFabricClass), +}; + static void xive_register_types(void) { + type_register_static(&xive_fabric_info); type_register_static(&xive_source_info); type_register_static(&xive_notifier_info); type_register_static(&xive_presenter_info); --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665980; cv=none; d=zohomail.com; s=zohoarc; b=E0fET2iDHBaZq+s+ZHNRrqUTxepSqdqUsxRFgyqpn1WgSuPx3FUNPp4ar8mvfwaqtO1e1mC9Pz1b1HeVQHhw5J+PL5bKqX4ELXo12B6vfUgal4zSVIkn+taloFYurvPaiKuEFrZ6doyyi58ev/wYqqc32IYYjAijGHBRRLyAJTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665980; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VRiS7rUSi2y/Sb8LXJ0oq5DobMtRXJei631ECFJO1Qo=; b=UsbXJKeQnGXAu7csgNFIXFrlXJZ8gBCUXt5dHJ4+LX92H/FMV22+RIgLnI8uBYW31/Jx5sZNIEXjm560j0t4RwNdSJFWWABTgmlHGQNL4A00TgXUGcvzPvV6r0jB1ZA9+LN7ZROJT3K+m//yr25cXTMJlFM0RSJVVP5x46dPB7I= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665980088407.15483895197053; Sun, 24 Nov 2019 23:13:00 -0800 (PST) Received: from localhost ([::1]:40874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8YM-0008Gc-En for importer@patchew.org; Mon, 25 Nov 2019 02:12:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41655) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8LJ-0002hR-Ga for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8LI-0001f4-EL for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:29 -0500 Received: from 4.mo4.mail-out.ovh.net ([178.32.98.131]:44918) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8LI-0001do-8M for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:28 -0500 Received: from player697.ha.ovh.net (unknown [10.108.54.133]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id D557A213525 for ; Mon, 25 Nov 2019 07:59:25 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 45AADC80954F; Mon, 25 Nov 2019 06:59:19 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 09/20] ppc/pnv: Implement the XiveFabric interface Date: Mon, 25 Nov 2019 07:58:09 +0100 Message-Id: <20191125065820.927-10-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8920786437348690918 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedu Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.32.98.131 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The CAM line matching on the PowerNV machine now scans all chips of the system and all CPUs of a chip to find a dispatched NVT in the thread contexts. Reviewed-by: Greg Kurz Signed-off-by: C=C3=A9dric Le Goater --- hw/ppc/pnv.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 8f688f4efc5a..5b8b07f6aedc 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1443,6 +1443,35 @@ static void pnv_pic_print_info(InterruptStatsProvide= r *obj, } } =20 +static int pnv_match_nvt(XiveFabric *xfb, uint8_t format, + uint8_t nvt_blk, uint32_t nvt_idx, + bool cam_ignore, uint8_t priority, + uint32_t logic_serv, + XiveTCTXMatch *match) +{ + PnvMachineState *pnv =3D PNV_MACHINE(xfb); + int total_count =3D 0; + int i; + + for (i =3D 0; i < pnv->num_chips; i++) { + Pnv9Chip *chip9 =3D PNV9_CHIP(pnv->chips[i]); + XivePresenter *xptr =3D XIVE_PRESENTER(&chip9->xive); + XivePresenterClass *xpc =3D XIVE_PRESENTER_GET_CLASS(xptr); + int count; + + count =3D xpc->match_nvt(xptr, format, nvt_blk, nvt_idx, cam_ignor= e, + priority, logic_serv, match); + + if (count < 0) { + return count; + } + + total_count +=3D count; + } + + return total_count; +} + static void pnv_get_num_chips(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -1506,9 +1535,11 @@ static void pnv_machine_power8_class_init(ObjectClas= s *oc, void *data) static void pnv_machine_power9_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); + XiveFabricClass *xfc =3D XIVE_FABRIC_CLASS(oc); =20 mc->desc =3D "IBM PowerNV (Non-Virtualized) POWER9"; mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("power9_v2.0"); + xfc->match_nvt =3D pnv_match_nvt; =20 mc->alias =3D "powernv"; } @@ -1555,6 +1586,10 @@ static const TypeInfo types[] =3D { .name =3D MACHINE_TYPE_NAME("powernv9"), .parent =3D TYPE_PNV_MACHINE, .class_init =3D pnv_machine_power9_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_XIVE_FABRIC }, + { }, + }, }, { .name =3D MACHINE_TYPE_NAME("powernv8"), --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574666204; cv=none; d=zohomail.com; s=zohoarc; b=k7AWS/Nf3n3Sxt8YCRq0zTF+pKn4OCsuM5IJkWRcWeXZiBw+ePQvsvBnMBZmotNeoFaKJ7+5qxhRtFVmqtttkfiZ8QEFNRt1l2lRRmQnGWBRNT+jPt6ZDTFKLaqp6uX3LZzovWOePop6bqi1LZxBULDJQ/ntyiaKndJ2C/jf+Aw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574666204; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XC/ftTfeJeXBnW4BWRTuGXXsaO/MbelJcTBomo6KXEc=; b=nVzGl99Be4ZRusn9a2EYdppEOZq1NBp44TloDXbL40ijP/JFLd0XgnO7pWeI/PeNPCxujjd9JyXjz84ZbGTfdj1En5ZW2uUVqc+sajARm4MgMs0eYeWjj8hGeNUYaPmdbkeAzdP80lWim0gofvCR+5X4xnFPJtt4RNuXSlRkST0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15746662047671016.7537129323971; Sun, 24 Nov 2019 23:16:44 -0800 (PST) Received: from localhost ([::1]:40910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8bz-0003JI-Bn for importer@patchew.org; Mon, 25 Nov 2019 02:16:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41688) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8LN-0002p1-Tf for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8LM-0001i2-NR for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:33 -0500 Received: from 4.mo5.mail-out.ovh.net ([178.33.111.247]:38379) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8LM-0001h9-Hh for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:32 -0500 Received: from player697.ha.ovh.net (unknown [10.109.160.244]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 2980E25BE33 for ; Mon, 25 Nov 2019 07:59:31 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 96283C809587; Mon, 25 Nov 2019 06:59:25 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 10/20] ppc/spapr: Implement the XiveFabric interface Date: Mon, 25 Nov 2019 07:58:10 +0100 Message-Id: <20191125065820.927-11-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8922475289809095654 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedv Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.111.247 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The CAM line matching sequence in the pseries machine does not change much apart from the use of the new QOM interfaces. There is an extra indirection because of the sPAPR IRQ backend of the machine. Only the XIVE backend implements the new 'match_nvt' handler. Reviewed-by: Greg Kurz Signed-off-by: C=C3=A9dric Le Goater --- hw/ppc/spapr.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e076f6023c73..2687bbac37eb 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -4275,6 +4275,42 @@ static void spapr_pic_print_info(InterruptStatsProvi= der *obj, kvm_irqchip_in_kernel() ? "in-kernel" : "emulated"); } =20 +static int spapr_match_nvt(XiveFabric *xfb, uint8_t format, + uint8_t nvt_blk, uint32_t nvt_idx, + bool cam_ignore, uint8_t priority, + uint32_t logic_serv, XiveTCTXMatch *match) +{ + SpaprMachineState *spapr =3D SPAPR_MACHINE(xfb); + XivePresenter *xptr =3D XIVE_PRESENTER(spapr->xive); + XivePresenterClass *xpc =3D XIVE_PRESENTER_GET_CLASS(xptr); + int count; + + /* This is a XIVE only operation */ + assert(spapr->active_intc =3D=3D SPAPR_INTC(spapr->xive)); + + count =3D xpc->match_nvt(xptr, format, nvt_blk, nvt_idx, cam_ignore, + priority, logic_serv, match); + if (count < 0) { + return count; + } + + /* + * When we implement the save and restore of the thread interrupt + * contexts in the enter/exit CPU handlers of the machine and the + * escalations in QEMU, we should be able to handle non dispatched + * vCPUs. + * + * Until this is done, the sPAPR machine should find at least one + * matching context always. + */ + if (count =3D=3D 0) { + qemu_log_mask(LOG_GUEST_ERROR, "XIVE: NVT %x/%x is not dispatched\= n", + nvt_blk, nvt_idx); + } + + return count; +} + int spapr_get_vcpu_id(PowerPCCPU *cpu) { return cpu->vcpu_id; @@ -4371,6 +4407,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) PPCVirtualHypervisorClass *vhc =3D PPC_VIRTUAL_HYPERVISOR_CLASS(oc); XICSFabricClass *xic =3D XICS_FABRIC_CLASS(oc); InterruptStatsProviderClass *ispc =3D INTERRUPT_STATS_PROVIDER_CLASS(o= c); + XiveFabricClass *xfc =3D XIVE_FABRIC_CLASS(oc); =20 mc->desc =3D "pSeries Logical Partition (PAPR compliant)"; mc->ignore_boot_device_suffixes =3D true; @@ -4447,6 +4484,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) smc->linux_pci_probe =3D true; smc->smp_threads_vsmt =3D true; smc->nr_xirqs =3D SPAPR_NR_XIRQS; + xfc->match_nvt =3D spapr_match_nvt; } =20 static const TypeInfo spapr_machine_info =3D { @@ -4465,6 +4503,7 @@ static const TypeInfo spapr_machine_info =3D { { TYPE_PPC_VIRTUAL_HYPERVISOR }, { TYPE_XICS_FABRIC }, { TYPE_INTERRUPT_STATS_PROVIDER }, + { TYPE_XIVE_FABRIC }, { } }, }; --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665683; cv=none; d=zohomail.com; s=zohoarc; b=gvlcnfOCF0telwcFXAWssAe2gswTVFN7BEHq3HqxZbmNZaRA9lX2/eFANq0t6D11yDT/ukPhFd6dDZmHCL7+LL4O8kfZeLjxShxqjwYPrBwpROP4I18tYfqrXpO5i0eieI3xolNGW/aG3SMNG2onqQ73m9p4Z7CDZtpOo+2cQBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665683; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bpuP5RhIqgVo0QZhKNI4p4N902DP8JQTpoO51OKea30=; b=P953kdd1bIdTBote41ZjctCn20atR0/TXP0FrtD6lxwZF/slHD0AUyBTFF8HkUHjL4ZfBq4ehSCuJPZURoaKZZsy1s+u5G5LOxV4jsDp3aJ3u22nG5YjPhr6bXOQdGCRWdN+23ti+vMnC+dtwGzbgRaKofjfvTYnYl4qK6wrqyA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665683227815.0737889468668; Sun, 24 Nov 2019 23:08:03 -0800 (PST) Received: from localhost ([::1]:40832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8TZ-0002ZV-6v for importer@patchew.org; Mon, 25 Nov 2019 02:08:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41740) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8LV-0002v1-8T for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8LT-0001mT-Td for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:41 -0500 Received: from 1.mo2.mail-out.ovh.net ([46.105.63.121]:33360) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8LT-0001l4-NV for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:39 -0500 Received: from player697.ha.ovh.net (unknown [10.109.160.62]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id C37B41B5C75 for ; Mon, 25 Nov 2019 07:59:37 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 2ACBEC8095A6; Mon, 25 Nov 2019 06:59:31 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 11/20] ppc/xive: Use the XiveFabric and XivePresenter interfaces Date: Mon, 25 Nov 2019 07:58:11 +0100 Message-Id: <20191125065820.927-12-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8924164140610915302 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedv Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.63.121 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Now that the machines have handlers implementing the XiveFabric and XivePresenter interfaces, remove xive_presenter_match() and make use of the 'match_nvt' handler of the machine. Reviewed-by: Greg Kurz Signed-off-by: C=C3=A9dric Le Goater --- hw/intc/xive.c | 48 +++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 1c9e58f8deac..8e683847bf81 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -1423,30 +1423,6 @@ int xive_presenter_tctx_match(XivePresenter *xptr, X= iveTCTX *tctx, return -1; } =20 -static bool xive_presenter_match(XiveRouter *xrtr, uint8_t format, - uint8_t nvt_blk, uint32_t nvt_idx, - bool cam_ignore, uint8_t priority, - uint32_t logic_serv, XiveTCTXMatch *match) -{ - XivePresenter *xptr =3D XIVE_PRESENTER(xrtr); - XivePresenterClass *xpc =3D XIVE_PRESENTER_GET_CLASS(xptr); - int count; - - count =3D xpc->match_nvt(xptr, format, nvt_blk, nvt_idx, cam_ignore, - priority, logic_serv, match); - if (count < 0) { - return false; - } - - if (!match->tctx) { - qemu_log_mask(LOG_UNIMP, "XIVE: NVT %x/%x is not dispatched\n", - nvt_blk, nvt_idx); - return false; - } - - return true; -} - /* * This is our simple Xive Presenter Engine model. It is merged in the * Router as it does not require an extra object. @@ -1462,22 +1438,32 @@ static bool xive_presenter_match(XiveRouter *xrtr, = uint8_t format, * * The parameters represent what is sent on the PowerBus */ -static bool xive_presenter_notify(XiveRouter *xrtr, uint8_t format, +static bool xive_presenter_notify(uint8_t format, uint8_t nvt_blk, uint32_t nvt_idx, bool cam_ignore, uint8_t priority, uint32_t logic_serv) { + XiveFabric *xfb =3D XIVE_FABRIC(qdev_get_machine()); + XiveFabricClass *xfc =3D XIVE_FABRIC_GET_CLASS(xfb); XiveTCTXMatch match =3D { .tctx =3D NULL, .ring =3D 0 }; - bool found; + int count; =20 - found =3D xive_presenter_match(xrtr, format, nvt_blk, nvt_idx, cam_ign= ore, - priority, logic_serv, &match); - if (found) { + /* + * Ask the machine to scan the interrupt controllers for a match + */ + count =3D xfc->match_nvt(xfb, format, nvt_blk, nvt_idx, cam_ignore, + priority, logic_serv, &match); + if (count < 0) { + return false; + } + + /* handle CPU exception delivery */ + if (count) { ipb_update(&match.tctx->regs[match.ring], priority); xive_tctx_notify(match.tctx, match.ring); } =20 - return found; + return !!count; } =20 /* @@ -1590,7 +1576,7 @@ static void xive_router_end_notify(XiveRouter *xrtr, = uint8_t end_blk, return; } =20 - found =3D xive_presenter_notify(xrtr, format, nvt_blk, nvt_idx, + found =3D xive_presenter_notify(format, nvt_blk, nvt_idx, xive_get_field32(END_W7_F0_IGNORE, end.w7), priority, xive_get_field32(END_W7_F1_LOG_SERVER_ID, end.w7= )); --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665842; cv=none; d=zohomail.com; s=zohoarc; b=n+FZrbP+T74RLFYmjmQA1T/jJY1XzPgXDGWr5ojiLfX+Ps1gSdN0di0VCTsJjlhKSzSu4Qz0yfq6P6ofWb6YOhz+JkNH1tDpmLFTkCo2LHqYnWiFN5I2cPe/AlOrLe93REsowXnnKrAqXBkblbaHD1gc6WPq9mVbm5XnzhUmuwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665842; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ggipgy06zvGd46VE3atqx0SERuK7CZSBtIctzwzmBkE=; b=UxKHR1igjBkZSQpRiJ+/sM41pOqs/9bWemOEPWpy8s6Wacc+2vQXyBMWFhWNz+9A9oJw99Knp1I/x4h6mQ7k8CR3fOiT3HOVSNB036Y/rI+ZfhrkT9ghl527K/VDV3+FFX4I9LoraA5eX3rMYWkvLykbaDIyZK76K8sG9bg/KSI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665842265277.39726436449405; Sun, 24 Nov 2019 23:10:42 -0800 (PST) Received: from localhost ([::1]:40862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8W8-00066i-Vp for importer@patchew.org; Mon, 25 Nov 2019 02:10:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41767) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Lf-00037n-2C for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8La-0001oo-Ah for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:48 -0500 Received: from 9.mo178.mail-out.ovh.net ([46.105.75.45]:50710) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8LY-0001oK-Ab for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:45 -0500 Received: from player697.ha.ovh.net (unknown [10.108.54.203]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id 4ACEF823DD for ; Mon, 25 Nov 2019 07:59:43 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id C174AC8095E6; Mon, 25 Nov 2019 06:59:37 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 12/20] ppc/xive: Extend the TIMA operation with a XivePresenter parameter Date: Mon, 25 Nov 2019 07:58:12 +0100 Message-Id: <20191125065820.927-13-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8925852990727687142 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedu Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.75.45 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The TIMA operations are performed on behalf of the XIVE IVPE sub-engine (Presenter) on the thread interrupt context registers. The current operations supported by the model are simple and do not require access to the controller but more complex operations will need access to the controller NVT table and to its configuration. Reviewed-by: Greg Kurz Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/xive.h | 7 +++--- hw/intc/pnv_xive.c | 4 +-- hw/intc/xive.c | 58 ++++++++++++++++++++++++------------------- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index b00af988779b..97bbcddb381d 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -463,9 +463,10 @@ typedef struct XiveENDSource { #define XIVE_TM_USER_PAGE 0x3 =20 extern const MemoryRegionOps xive_tm_ops; -void xive_tctx_tm_write(XiveTCTX *tctx, hwaddr offset, uint64_t value, - unsigned size); -uint64_t xive_tctx_tm_read(XiveTCTX *tctx, hwaddr offset, unsigned size); +void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, + uint64_t value, unsigned size); +uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCTX *tctx, hwaddr off= set, + unsigned size); =20 void xive_tctx_pic_print_info(XiveTCTX *tctx, Monitor *mon); Object *xive_tctx_create(Object *cpu, XiveRouter *xrtr, Error **errp); diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index b2ab2ccc91e7..95e9de312cd9 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -1436,7 +1436,7 @@ static void xive_tm_indirect_write(void *opaque, hwad= dr offset, { XiveTCTX *tctx =3D pnv_xive_get_indirect_tctx(PNV_XIVE(opaque)); =20 - xive_tctx_tm_write(tctx, offset, value, size); + xive_tctx_tm_write(XIVE_PRESENTER(opaque), tctx, offset, value, size); } =20 static uint64_t xive_tm_indirect_read(void *opaque, hwaddr offset, @@ -1444,7 +1444,7 @@ static uint64_t xive_tm_indirect_read(void *opaque, h= waddr offset, { XiveTCTX *tctx =3D pnv_xive_get_indirect_tctx(PNV_XIVE(opaque)); =20 - return xive_tctx_tm_read(tctx, offset, size); + return xive_tctx_tm_read(XIVE_PRESENTER(opaque), tctx, offset, size); } =20 static const MemoryRegionOps xive_tm_indirect_ops =3D { diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 8e683847bf81..9e7e5ea57c5c 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -144,19 +144,20 @@ static inline uint32_t xive_tctx_word2(uint8_t *ring) * XIVE Thread Interrupt Management Area (TIMA) */ =20 -static void xive_tm_set_hv_cppr(XiveTCTX *tctx, hwaddr offset, - uint64_t value, unsigned size) +static void xive_tm_set_hv_cppr(XivePresenter *xptr, XiveTCTX *tctx, + hwaddr offset, uint64_t value, unsigned si= ze) { xive_tctx_set_cppr(tctx, TM_QW3_HV_PHYS, value & 0xff); } =20 -static uint64_t xive_tm_ack_hv_reg(XiveTCTX *tctx, hwaddr offset, unsigned= size) +static uint64_t xive_tm_ack_hv_reg(XivePresenter *xptr, XiveTCTX *tctx, + hwaddr offset, unsigned size) { return xive_tctx_accept(tctx, TM_QW3_HV_PHYS); } =20 -static uint64_t xive_tm_pull_pool_ctx(XiveTCTX *tctx, hwaddr offset, - unsigned size) +static uint64_t xive_tm_pull_pool_ctx(XivePresenter *xptr, XiveTCTX *tctx, + hwaddr offset, unsigned size) { uint32_t qw2w2_prev =3D xive_tctx_word2(&tctx->regs[TM_QW2_HV_POOL]); uint32_t qw2w2; @@ -166,13 +167,14 @@ static uint64_t xive_tm_pull_pool_ctx(XiveTCTX *tctx,= hwaddr offset, return qw2w2; } =20 -static void xive_tm_vt_push(XiveTCTX *tctx, hwaddr offset, +static void xive_tm_vt_push(XivePresenter *xptr, XiveTCTX *tctx, hwaddr of= fset, uint64_t value, unsigned size) { tctx->regs[TM_QW3_HV_PHYS + TM_WORD2] =3D value & 0xff; } =20 -static uint64_t xive_tm_vt_poll(XiveTCTX *tctx, hwaddr offset, unsigned si= ze) +static uint64_t xive_tm_vt_poll(XivePresenter *xptr, XiveTCTX *tctx, + hwaddr offset, unsigned size) { return tctx->regs[TM_QW3_HV_PHYS + TM_WORD2] & 0xff; } @@ -315,13 +317,14 @@ static uint64_t xive_tm_raw_read(XiveTCTX *tctx, hwad= dr offset, unsigned size) * state changes (side effects) in addition to setting/returning the * interrupt management area context of the processor thread. */ -static uint64_t xive_tm_ack_os_reg(XiveTCTX *tctx, hwaddr offset, unsigned= size) +static uint64_t xive_tm_ack_os_reg(XivePresenter *xptr, XiveTCTX *tctx, + hwaddr offset, unsigned size) { return xive_tctx_accept(tctx, TM_QW1_OS); } =20 -static void xive_tm_set_os_cppr(XiveTCTX *tctx, hwaddr offset, - uint64_t value, unsigned size) +static void xive_tm_set_os_cppr(XivePresenter *xptr, XiveTCTX *tctx, + hwaddr offset, uint64_t value, unsigned si= ze) { xive_tctx_set_cppr(tctx, TM_QW1_OS, value & 0xff); } @@ -330,8 +333,8 @@ static void xive_tm_set_os_cppr(XiveTCTX *tctx, hwaddr = offset, * Adjust the IPB to allow a CPU to process event queues of other * priorities during one physical interrupt cycle. */ -static void xive_tm_set_os_pending(XiveTCTX *tctx, hwaddr offset, - uint64_t value, unsigned size) +static void xive_tm_set_os_pending(XivePresenter *xptr, XiveTCTX *tctx, + hwaddr offset, uint64_t value, unsigned= size) { ipb_update(&tctx->regs[TM_QW1_OS], value & 0xff); xive_tctx_notify(tctx, TM_QW1_OS); @@ -366,8 +369,8 @@ static void xive_tctx_set_os_cam(XiveTCTX *tctx, uint32= _t qw1w2) memcpy(&tctx->regs[TM_QW1_OS + TM_WORD2], &qw1w2, 4); } =20 -static uint64_t xive_tm_pull_os_ctx(XiveTCTX *tctx, hwaddr offset, - unsigned size) +static uint64_t xive_tm_pull_os_ctx(XivePresenter *xptr, XiveTCTX *tctx, + hwaddr offset, unsigned size) { uint32_t qw1w2; uint32_t qw1w2_new; @@ -396,9 +399,11 @@ typedef struct XiveTmOp { uint8_t page_offset; uint32_t op_offset; unsigned size; - void (*write_handler)(XiveTCTX *tctx, hwaddr offset, uint64_t valu= e, - unsigned size); - uint64_t (*read_handler)(XiveTCTX *tctx, hwaddr offset, unsigned size); + void (*write_handler)(XivePresenter *xptr, XiveTCTX *tctx, + hwaddr offset, + uint64_t value, unsigned size); + uint64_t (*read_handler)(XivePresenter *xptr, XiveTCTX *tctx, hwaddr o= ffset, + unsigned size); } XiveTmOp; =20 static const XiveTmOp xive_tm_operations[] =3D { @@ -444,8 +449,8 @@ static const XiveTmOp *xive_tm_find_op(hwaddr offset, u= nsigned size, bool write) /* * TIMA MMIO handlers */ -void xive_tctx_tm_write(XiveTCTX *tctx, hwaddr offset, uint64_t value, - unsigned size) +void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, + uint64_t value, unsigned size) { const XiveTmOp *xto; =20 @@ -462,7 +467,7 @@ void xive_tctx_tm_write(XiveTCTX *tctx, hwaddr offset, = uint64_t value, qemu_log_mask(LOG_GUEST_ERROR, "XIVE: invalid write access at = TIMA " "@%"HWADDR_PRIx"\n", offset); } else { - xto->write_handler(tctx, offset, value, size); + xto->write_handler(xptr, tctx, offset, value, size); } return; } @@ -472,7 +477,7 @@ void xive_tctx_tm_write(XiveTCTX *tctx, hwaddr offset, = uint64_t value, */ xto =3D xive_tm_find_op(offset, size, true); if (xto) { - xto->write_handler(tctx, offset, value, size); + xto->write_handler(xptr, tctx, offset, value, size); return; } =20 @@ -482,7 +487,8 @@ void xive_tctx_tm_write(XiveTCTX *tctx, hwaddr offset, = uint64_t value, xive_tm_raw_write(tctx, offset, value, size); } =20 -uint64_t xive_tctx_tm_read(XiveTCTX *tctx, hwaddr offset, unsigned size) +uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCTX *tctx, hwaddr off= set, + unsigned size) { const XiveTmOp *xto; =20 @@ -500,7 +506,7 @@ uint64_t xive_tctx_tm_read(XiveTCTX *tctx, hwaddr offse= t, unsigned size) "@%"HWADDR_PRIx"\n", offset); return -1; } - return xto->read_handler(tctx, offset, size); + return xto->read_handler(xptr, tctx, offset, size); } =20 /* @@ -508,7 +514,7 @@ uint64_t xive_tctx_tm_read(XiveTCTX *tctx, hwaddr offse= t, unsigned size) */ xto =3D xive_tm_find_op(offset, size, false); if (xto) { - return xto->read_handler(tctx, offset, size); + return xto->read_handler(xptr, tctx, offset, size); } =20 /* @@ -522,14 +528,14 @@ static void xive_tm_write(void *opaque, hwaddr offset, { XiveTCTX *tctx =3D xive_router_get_tctx(XIVE_ROUTER(opaque), current_c= pu); =20 - xive_tctx_tm_write(tctx, offset, value, size); + xive_tctx_tm_write(XIVE_PRESENTER(opaque), tctx, offset, value, size); } =20 static uint64_t xive_tm_read(void *opaque, hwaddr offset, unsigned size) { XiveTCTX *tctx =3D xive_router_get_tctx(XIVE_ROUTER(opaque), current_c= pu); =20 - return xive_tctx_tm_read(tctx, offset, size); + return xive_tctx_tm_read(XIVE_PRESENTER(opaque), tctx, offset, size); } =20 const MemoryRegionOps xive_tm_ops =3D { --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574666353; cv=none; d=zohomail.com; s=zohoarc; b=i00aZix1dTXiHWvUUBUZ/cqTUqPnzZ5zV9U0S2ofKjCUNaoRv0eetA9tMc+u/a9CC+VuPRMwa6tZj0h7kUjtMMA2g7n8nOvBE44yURq5Zsjbu1CfxP0KZNXvF11s5dCFgr5NOZ/QbYgmsNc5SyDvKsY66Pa54VkLWc7WkgPABj0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574666353; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8IQLuBB7fTi/HWb+K8WvkDz56AIOuhroprDiLwLVPRQ=; b=N/u6h7Kn2d69lhVAFdoykrSJ1SGpjwbyWqb0WuXyYEE6mtZ+PuFgtiYmEMha09jj5R7+CAv4stfCzOz6JuntyZMNX7E57RnBkl0j6Dm+LAEQL2uWxMGJcm1FO2xVYp4oxPxsB0dcN10aLf5JfePxlT9Oa3O5ftJXhcF6+G8saRk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574666353929598.8919191348666; Sun, 24 Nov 2019 23:19:13 -0800 (PST) Received: from localhost ([::1]:40944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8eN-0007Le-TO for importer@patchew.org; Mon, 25 Nov 2019 02:19:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41795) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Lj-0003Gw-6O for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8Lf-0001rz-OH for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:53 -0500 Received: from 6.mo69.mail-out.ovh.net ([46.105.50.107]:39584) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8Lf-0001pc-1g for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:51 -0500 Received: from player697.ha.ovh.net (unknown [10.108.35.159]) by mo69.mail-out.ovh.net (Postfix) with ESMTP id 01D8D71886 for ; Mon, 25 Nov 2019 07:59:48 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 3C162C809626; Mon, 25 Nov 2019 06:59:43 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 13/20] ppc/pnv: Clarify how the TIMA is accessed on a multichip system Date: Mon, 25 Nov 2019 07:58:13 +0100 Message-Id: <20191125065820.927-14-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8927260362331032550 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedv Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.50.107 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The TIMA region gives access to the thread interrupt context registers of a CPU. It is mapped at the same address on all chips and can be accessed by any CPU of the system. To identify the chip from which the access is being done, the PowerBUS uses a 'chip' field in the load/store messages. QEMU does not model these messages, instead, we extract the chip id from the CPU PIR and do a lookup at the machine level to fetch the targeted interrupt controller. Introduce pnv_get_chip() and pnv_xive_tm_get_xive() helpers to clarify this process in pnv_xive_get_tctx(). The latter will be removed in the subsequent patches but the same principle will be kept. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/pnv.h | 3 +++ hw/intc/pnv_xive.c | 40 +++++++++++++++++++++++----------------- hw/ppc/pnv.c | 14 ++++++++++++++ 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index a58cfea3f2fd..3a7bc3c57e0d 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -103,6 +103,7 @@ typedef struct Pnv9Chip { * A SMT8 fused core is a pair of SMT4 cores. */ #define PNV9_PIR2FUSEDCORE(pir) (((pir) >> 3) & 0xf) +#define PNV9_PIR2CHIP(pir) (((pir) >> 8) & 0x7f) =20 typedef struct PnvChipClass { /*< private >*/ @@ -197,6 +198,8 @@ static inline bool pnv_is_power9(PnvMachineState *pnv) return pnv_chip_is_power9(pnv->chips[0]); } =20 +PnvChip *pnv_get_chip(uint32_t chip_id); + #define PNV_FDT_ADDR 0x01000000 #define PNV_TIMEBASE_FREQ 512000000ULL =20 diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index 95e9de312cd9..db9d9c11a8f4 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -439,31 +439,37 @@ static int pnv_xive_match_nvt(XivePresenter *xptr, ui= nt8_t format, return count; } =20 +/* + * The TIMA MMIO space is shared among the chips and to identify the + * chip from which the access is being done, we extract the chip id + * from the PIR. + */ +static PnvXive *pnv_xive_tm_get_xive(PowerPCCPU *cpu) +{ + int pir =3D ppc_cpu_pir(cpu); + PnvChip *chip; + PnvXive *xive; + + chip =3D pnv_get_chip(PNV9_PIR2CHIP(pir)); + assert(chip); + xive =3D &PNV9_CHIP(chip)->xive; + + if (!pnv_xive_is_cpu_enabled(xive, cpu)) { + xive_error(xive, "IC: CPU %x is not enabled", pir); + } + return xive; +} + static XiveTCTX *pnv_xive_get_tctx(XiveRouter *xrtr, CPUState *cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); - XiveTCTX *tctx =3D XIVE_TCTX(pnv_cpu_state(cpu)->intc); - PnvXive *xive =3D NULL; - CPUPPCState *env =3D &cpu->env; - int pir =3D env->spr_cb[SPR_PIR].default_value; + PnvXive *xive =3D pnv_xive_tm_get_xive(cpu); =20 - /* - * Perform an extra check on the HW thread enablement. - * - * The TIMA is shared among the chips and to identify the chip - * from which the access is being done, we extract the chip id - * from the PIR. - */ - xive =3D pnv_xive_get_ic((pir >> 8) & 0xf); if (!xive) { return NULL; } =20 - if (!(xive->regs[PC_THREAD_EN_REG0 >> 3] & PPC_BIT(pir & 0x3f))) { - xive_error(PNV_XIVE(xrtr), "IC: CPU %x is not enabled", pir); - } - - return tctx; + return XIVE_TCTX(pnv_cpu_state(cpu)->intc); } =20 /* diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 5b8b07f6aedc..fa656858b24a 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1472,6 +1472,20 @@ static int pnv_match_nvt(XiveFabric *xfb, uint8_t fo= rmat, return total_count; } =20 +PnvChip *pnv_get_chip(uint32_t chip_id) +{ + PnvMachineState *pnv =3D PNV_MACHINE(qdev_get_machine()); + int i; + + for (i =3D 0; i < pnv->num_chips; i++) { + PnvChip *chip =3D pnv->chips[i]; + if (chip->chip_id =3D=3D chip_id) { + return chip; + } + } + return NULL; +} + static void pnv_get_num_chips(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574666206; cv=none; d=zohomail.com; s=zohoarc; b=fpES66EGzr9Xj7omDHPV3FxEGFvVgG2lPs08iJaW8IPN2m8vCoFHdNZnqkRt91aXtDy6+A6zaBw1Fqzz+3Dx3t3yr7gOuESwh2uruaOAZ38sDo/QK6r5va602JAGfNRFxKDHuw292vcagLX/EJcbneWpF666AC9eDPbVk0jlQvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574666206; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zjbTyf1LyoBltw+dACVIp1NNTngDtFsePbVmsiIQdn4=; b=IXwoH2oIIYHf+kymgOQk1QdmMKyEU+c7b6fOzfKLCkLB9svTGOtrLNeDQnJThGXApbosg6feuXNKot6qkAe6RdT7zI3E80IES4T0qiOrDAYdLIWzROK8ISWolJ4wGoDhBY4R499Oo4SNzEpaX5QnwlI9WlPG5DYLBuZEZ5otXC4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574666206337194.5861043076137; Sun, 24 Nov 2019 23:16:46 -0800 (PST) Received: from localhost ([::1]:40912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8c1-0003Rc-3E for importer@patchew.org; Mon, 25 Nov 2019 02:16:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41828) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Lq-0003VJ-9L for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8Lo-0001ug-Ln for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:02 -0500 Received: from 3.mo179.mail-out.ovh.net ([178.33.251.175]:39066) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8Ll-0001t0-Sn for qemu-devel@nongnu.org; Mon, 25 Nov 2019 01:59:59 -0500 Received: from player697.ha.ovh.net (unknown [10.108.42.66]) by mo179.mail-out.ovh.net (Postfix) with ESMTP id 7937014BC68 for ; Mon, 25 Nov 2019 07:59:54 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 019DDC80965A; Mon, 25 Nov 2019 06:59:48 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 14/20] ppc/xive: Move the TIMA operations to the controller model Date: Mon, 25 Nov 2019 07:58:14 +0100 Message-Id: <20191125065820.927-15-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8928949212470938598 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpeef Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.251.175 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" On the P9 Processor, the thread interrupt context registers of a CPU can be accessed "directly" when by load/store from the CPU or "indirectly" by the IC through an indirect TIMA page. This requires to configure first the PC_TCTXT_INDIRx registers. Today, we rely on the get_tctx() handler to deduce from the CPU PIR the chip from which the TIMA access is being done. By handling the TIMA memory ops under the interrupt controller model of each machine, we can uniformize the TIMA direct and indirect ops under PowerNV. We can also check that the CPUs have been enabled in the XIVE controller. This prepares ground for the future versions of XIVE. Reviewed-by: Greg Kurz Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/xive.h | 1 - hw/intc/pnv_xive.c | 35 ++++++++++++++++++++++++++++++++++- hw/intc/spapr_xive.c | 33 +++++++++++++++++++++++++++++++-- hw/intc/xive.c | 29 ----------------------------- 4 files changed, 65 insertions(+), 33 deletions(-) diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index 97bbcddb381d..dcf897451589 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -462,7 +462,6 @@ typedef struct XiveENDSource { #define XIVE_TM_OS_PAGE 0x2 #define XIVE_TM_USER_PAGE 0x3 =20 -extern const MemoryRegionOps xive_tm_ops; void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, uint64_t value, unsigned size); uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCTX *tctx, hwaddr off= set, diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index db9d9c11a8f4..c14a2d186960 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -1467,6 +1467,39 @@ static const MemoryRegionOps xive_tm_indirect_ops = =3D { }, }; =20 +static void pnv_xive_tm_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size) +{ + PowerPCCPU *cpu =3D POWERPC_CPU(current_cpu); + PnvXive *xive =3D pnv_xive_tm_get_xive(cpu); + XiveTCTX *tctx =3D XIVE_TCTX(pnv_cpu_state(cpu)->intc); + + xive_tctx_tm_write(XIVE_PRESENTER(xive), tctx, offset, value, size); +} + +static uint64_t pnv_xive_tm_read(void *opaque, hwaddr offset, unsigned siz= e) +{ + PowerPCCPU *cpu =3D POWERPC_CPU(current_cpu); + PnvXive *xive =3D pnv_xive_tm_get_xive(cpu); + XiveTCTX *tctx =3D XIVE_TCTX(pnv_cpu_state(cpu)->intc); + + return xive_tctx_tm_read(XIVE_PRESENTER(xive), tctx, offset, size); +} + +const MemoryRegionOps pnv_xive_tm_ops =3D { + .read =3D pnv_xive_tm_read, + .write =3D pnv_xive_tm_write, + .endianness =3D DEVICE_BIG_ENDIAN, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 8, + }, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 8, + }, +}; + /* * Interrupt controller XSCOM region. */ @@ -1809,7 +1842,7 @@ static void pnv_xive_realize(DeviceState *dev, Error = **errp) "xive-pc", PNV9_XIVE_PC_SIZE); =20 /* Thread Interrupt Management Area (Direct) */ - memory_region_init_io(&xive->tm_mmio, OBJECT(xive), &xive_tm_ops, + memory_region_init_io(&xive->tm_mmio, OBJECT(xive), &pnv_xive_tm_ops, xive, "xive-tima", PNV9_XIVE_TM_SIZE); =20 qemu_register_reset(pnv_xive_reset, dev); diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index bb3b2dfdb77f..6292da58f62c 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -205,6 +205,35 @@ void spapr_xive_mmio_set_enabled(SpaprXive *xive, bool= enable) memory_region_set_enabled(&xive->end_source.esb_mmio, false); } =20 +static void spapr_xive_tm_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size) +{ + XiveTCTX *tctx =3D spapr_cpu_state(POWERPC_CPU(current_cpu))->tctx; + + xive_tctx_tm_write(XIVE_PRESENTER(opaque), tctx, offset, value, size); +} + +static uint64_t spapr_xive_tm_read(void *opaque, hwaddr offset, unsigned s= ize) +{ + XiveTCTX *tctx =3D spapr_cpu_state(POWERPC_CPU(current_cpu))->tctx; + + return xive_tctx_tm_read(XIVE_PRESENTER(opaque), tctx, offset, size); +} + +const MemoryRegionOps spapr_xive_tm_ops =3D { + .read =3D spapr_xive_tm_read, + .write =3D spapr_xive_tm_write, + .endianness =3D DEVICE_BIG_ENDIAN, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 8, + }, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 8, + }, +}; + static void spapr_xive_end_reset(XiveEND *end) { memset(end, 0, sizeof(*end)); @@ -314,8 +343,8 @@ static void spapr_xive_realize(DeviceState *dev, Error = **errp) qemu_register_reset(spapr_xive_reset, dev); =20 /* TIMA initialization */ - memory_region_init_io(&xive->tm_mmio, OBJECT(xive), &xive_tm_ops, xive, - "xive.tima", 4ull << TM_SHIFT); + memory_region_init_io(&xive->tm_mmio, OBJECT(xive), &spapr_xive_tm_ops, + xive, "xive.tima", 4ull << TM_SHIFT); sysbus_init_mmio(SYS_BUS_DEVICE(xive), &xive->tm_mmio); =20 /* diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 9e7e5ea57c5c..0ca7099f4e55 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -523,35 +523,6 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTC= TX *tctx, hwaddr offset, return xive_tm_raw_read(tctx, offset, size); } =20 -static void xive_tm_write(void *opaque, hwaddr offset, - uint64_t value, unsigned size) -{ - XiveTCTX *tctx =3D xive_router_get_tctx(XIVE_ROUTER(opaque), current_c= pu); - - xive_tctx_tm_write(XIVE_PRESENTER(opaque), tctx, offset, value, size); -} - -static uint64_t xive_tm_read(void *opaque, hwaddr offset, unsigned size) -{ - XiveTCTX *tctx =3D xive_router_get_tctx(XIVE_ROUTER(opaque), current_c= pu); - - return xive_tctx_tm_read(XIVE_PRESENTER(opaque), tctx, offset, size); -} - -const MemoryRegionOps xive_tm_ops =3D { - .read =3D xive_tm_read, - .write =3D xive_tm_write, - .endianness =3D DEVICE_BIG_ENDIAN, - .valid =3D { - .min_access_size =3D 1, - .max_access_size =3D 8, - }, - .impl =3D { - .min_access_size =3D 1, - .max_access_size =3D 8, - }, -}; - static char *xive_tctx_ring_print(uint8_t *ring) { uint32_t w2 =3D xive_tctx_word2(ring); --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574666099; cv=none; d=zohomail.com; s=zohoarc; b=MUPvrp7p7y+V2FCXwBjfUlXX+0XRnu3F60IqPT1rHAeErj0iHxoR1TUFj697w84xk1R+AAwMXp3QXZv7oNrp8MOaP5UkZHko5BWfQtHIzvjikuTNqAEG+K199PWNH3o538RoiCd5zE1rZyiSNbRQ9xp531lPQ6KOt6w97+O+mAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574666099; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a3YWgOeOPUG5KZtjiGv4qudLcVH2oqomR/RuWYPR8vM=; b=S8b81rxhBFjWowFAH67Nqk8VOPYAkVw2TBcWTJuouYWyQLFoLNmIgvbrlaQab65qyX+4Uq8UX1U2YsO0OjnnqIklvIbGPBAjyKnb7IL8y2oQmfMTRgslDXLL57/bEsIWoa9yuSFtVqJJGBPkPuz6Vt0vVj/OC+EfKwnGuVk8y1Y= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574666099661974.9208580351457; Sun, 24 Nov 2019 23:14:59 -0800 (PST) Received: from localhost ([::1]:40896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8aH-0001wy-PG for importer@patchew.org; Mon, 25 Nov 2019 02:14:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41848) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Ls-0003VW-T1 for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8Lr-0001xK-JN for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:04 -0500 Received: from 14.mo4.mail-out.ovh.net ([46.105.40.29]:51007) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8Lr-0001v2-9j for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:03 -0500 Received: from player697.ha.ovh.net (unknown [10.109.159.152]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id 20C7621369E for ; Mon, 25 Nov 2019 08:00:01 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 6B880C809683; Mon, 25 Nov 2019 06:59:54 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 15/20] ppc/xive: Remove the get_tctx() XiveRouter handler Date: Mon, 25 Nov 2019 07:58:15 +0100 Message-Id: <20191125065820.927-16-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8930919539497798630 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpeeg Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.40.29 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" It is now unused. Reviewed-by: Greg Kurz Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/xive.h | 2 -- hw/intc/pnv_xive.c | 13 ------------- hw/intc/spapr_xive.c | 8 -------- hw/intc/xive.c | 7 ------- 4 files changed, 30 deletions(-) diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index dcf897451589..24315480e7c2 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -351,7 +351,6 @@ typedef struct XiveRouterClass { XiveNVT *nvt); int (*write_nvt)(XiveRouter *xrtr, uint8_t nvt_blk, uint32_t nvt_idx, XiveNVT *nvt, uint8_t word_number); - XiveTCTX *(*get_tctx)(XiveRouter *xrtr, CPUState *cs); } XiveRouterClass; =20 int xive_router_get_eas(XiveRouter *xrtr, uint8_t eas_blk, uint32_t eas_id= x, @@ -364,7 +363,6 @@ int xive_router_get_nvt(XiveRouter *xrtr, uint8_t nvt_b= lk, uint32_t nvt_idx, XiveNVT *nvt); int xive_router_write_nvt(XiveRouter *xrtr, uint8_t nvt_blk, uint32_t nvt_= idx, XiveNVT *nvt, uint8_t word_number); -XiveTCTX *xive_router_get_tctx(XiveRouter *xrtr, CPUState *cs); void xive_router_notify(XiveNotifier *xn, uint32_t lisn); =20 /* diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index c14a2d186960..216ebc150a41 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -460,18 +460,6 @@ static PnvXive *pnv_xive_tm_get_xive(PowerPCCPU *cpu) return xive; } =20 -static XiveTCTX *pnv_xive_get_tctx(XiveRouter *xrtr, CPUState *cs) -{ - PowerPCCPU *cpu =3D POWERPC_CPU(cs); - PnvXive *xive =3D pnv_xive_tm_get_xive(cpu); - - if (!xive) { - return NULL; - } - - return XIVE_TCTX(pnv_cpu_state(cpu)->intc); -} - /* * The internal sources (IPIs) of the interrupt controller have no * knowledge of the XIVE chip on which they reside. Encode the block @@ -1900,7 +1888,6 @@ static void pnv_xive_class_init(ObjectClass *klass, v= oid *data) xrc->write_end =3D pnv_xive_write_end; xrc->get_nvt =3D pnv_xive_get_nvt; xrc->write_nvt =3D pnv_xive_write_nvt; - xrc->get_tctx =3D pnv_xive_get_tctx; =20 xnc->notify =3D pnv_xive_notify; xpc->match_nvt =3D pnv_xive_match_nvt; diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index 6292da58f62c..1542cef91878 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -427,13 +427,6 @@ static int spapr_xive_write_nvt(XiveRouter *xrtr, uint= 8_t nvt_blk, g_assert_not_reached(); } =20 -static XiveTCTX *spapr_xive_get_tctx(XiveRouter *xrtr, CPUState *cs) -{ - PowerPCCPU *cpu =3D POWERPC_CPU(cs); - - return spapr_cpu_state(cpu)->tctx; -} - static int spapr_xive_match_nvt(XivePresenter *xptr, uint8_t format, uint8_t nvt_blk, uint32_t nvt_idx, bool cam_ignore, uint8_t priority, @@ -771,7 +764,6 @@ static void spapr_xive_class_init(ObjectClass *klass, v= oid *data) xrc->write_end =3D spapr_xive_write_end; xrc->get_nvt =3D spapr_xive_get_nvt; xrc->write_nvt =3D spapr_xive_write_nvt; - xrc->get_tctx =3D spapr_xive_get_tctx; =20 sicc->activate =3D spapr_xive_activate; sicc->deactivate =3D spapr_xive_deactivate; diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 0ca7099f4e55..4bff3abdc3eb 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -1317,13 +1317,6 @@ int xive_router_write_nvt(XiveRouter *xrtr, uint8_t = nvt_blk, uint32_t nvt_idx, return xrc->write_nvt(xrtr, nvt_blk, nvt_idx, nvt, word_number); } =20 -XiveTCTX *xive_router_get_tctx(XiveRouter *xrtr, CPUState *cs) -{ - XiveRouterClass *xrc =3D XIVE_ROUTER_GET_CLASS(xrtr); - - return xrc->get_tctx(xrtr, cs); -} - /* * Encode the HW CAM line in the block group mode format : * --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665567; cv=none; d=zohomail.com; s=zohoarc; b=XXkpQZSgwB8UBQV9X/q6vPuNFb85796k66xz+D5PPjsonRw3dtPxYaCzteCFPtVwbX7WZYR7wkVAWwJPRlnPjqPV0Z4dm4gwyID/nQPBWjVQabX4JO/i9bHuOX215YO0vSlTMivr0cZhuOni+C4u5LjymsJo3URniyHVQXW5ks4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665567; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Yy5Nxm1hoPTL8oy4P8wlfYWh/c3zE8ka2WxrXVj7SDY=; b=Z/Xa3cZ6+a6BABbZmjffpXeXEZ1fimRNdNCmowWlL3SFPrwZ47WA6yPpQ18Svv4czyotUt1Z6UEdM8CrE/WL33S7DpYwKpJsVmH1T4m/2SzL1jojsyC8qi0z21MOEFkkP83/eP7fwdWEG5dp6bimpvBCd++rR2aXOmgbhBY9c28= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665567986168.07010017389814; Sun, 24 Nov 2019 23:06:07 -0800 (PST) Received: from localhost ([::1]:40804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Ri-00008b-CC for importer@patchew.org; Mon, 25 Nov 2019 02:06:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41906) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8M5-0003Ze-Jn for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8Lz-00021n-Ji for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:14 -0500 Received: from 4.mo1.mail-out.ovh.net ([46.105.76.26]:59767) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8Lz-00020K-Dw for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:11 -0500 Received: from player697.ha.ovh.net (unknown [10.108.42.66]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id D802819C083 for ; Mon, 25 Nov 2019 08:00:07 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 22B50C8096E5; Mon, 25 Nov 2019 07:00:01 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 16/20] ppc/xive: Introduce a xive_tctx_ipb_update() helper Date: Mon, 25 Nov 2019 07:58:16 +0100 Message-Id: <20191125065820.927-17-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8932608386132904934 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedu Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.76.26 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We will use it to resend missed interrupts when a vCPU context is pushed on a HW thread. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz --- include/hw/ppc/xive.h | 1 + hw/intc/xive.c | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index 24315480e7c2..9c0bf2c301e2 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -469,6 +469,7 @@ void xive_tctx_pic_print_info(XiveTCTX *tctx, Monitor *= mon); Object *xive_tctx_create(Object *cpu, XiveRouter *xrtr, Error **errp); void xive_tctx_reset(XiveTCTX *tctx); void xive_tctx_destroy(XiveTCTX *tctx); +void xive_tctx_ipb_update(XiveTCTX *tctx, uint8_t ring, uint8_t ipb); =20 /* * KVM XIVE device helpers diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 4bff3abdc3eb..7047e45daca1 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -47,12 +47,6 @@ static uint8_t ipb_to_pipr(uint8_t ibp) return ibp ? clz32((uint32_t)ibp << 24) : 0xff; } =20 -static void ipb_update(uint8_t *regs, uint8_t priority) -{ - regs[TM_IPB] |=3D priority_to_ipb(priority); - regs[TM_PIPR] =3D ipb_to_pipr(regs[TM_IPB]); -} - static uint8_t exception_mask(uint8_t ring) { switch (ring) { @@ -135,6 +129,15 @@ static void xive_tctx_set_cppr(XiveTCTX *tctx, uint8_t= ring, uint8_t cppr) xive_tctx_notify(tctx, ring); } =20 +void xive_tctx_ipb_update(XiveTCTX *tctx, uint8_t ring, uint8_t ipb) +{ + uint8_t *regs =3D &tctx->regs[ring]; + + regs[TM_IPB] |=3D ipb; + regs[TM_PIPR] =3D ipb_to_pipr(regs[TM_IPB]); + xive_tctx_notify(tctx, ring); +} + static inline uint32_t xive_tctx_word2(uint8_t *ring) { return *((uint32_t *) &ring[TM_WORD2]); @@ -336,8 +339,7 @@ static void xive_tm_set_os_cppr(XivePresenter *xptr, Xi= veTCTX *tctx, static void xive_tm_set_os_pending(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, uint64_t value, unsigned= size) { - ipb_update(&tctx->regs[TM_QW1_OS], value & 0xff); - xive_tctx_notify(tctx, TM_QW1_OS); + xive_tctx_ipb_update(tctx, TM_QW1_OS, priority_to_ipb(value & 0xff)); } =20 static void xive_os_cam_decode(uint32_t cam, uint8_t *nvt_blk, @@ -1429,8 +1431,7 @@ static bool xive_presenter_notify(uint8_t format, =20 /* handle CPU exception delivery */ if (count) { - ipb_update(&match.tctx->regs[match.ring], priority); - xive_tctx_notify(match.tctx, match.ring); + xive_tctx_ipb_update(match.tctx, match.ring, priority_to_ipb(prior= ity)); } =20 return !!count; --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574666445; cv=none; d=zohomail.com; s=zohoarc; b=XdgdaZQGHd8eHLJVy2E27nguYk1bwsE4i7kDHRFauVYxO4gYPfGCMukIwgeL4WSKRxUS38lDAdqiWcga04dADuaOewLsXPIL0YWXKv3Io/armi+FC4cNpjBlJcZdWv18F3bslqsp4Aa8ql1frOn0VWuz9YfQqYlzMhVrXFxjWfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574666445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=es8dxj7bj50OGNUzDu0nwUuOa5yww71qFTcI+t8Sg+Y=; b=B0cY6WhQ4OxYjvoS7daWkX/tWDlENalRS/ki86OdVz0+WsuWqXhBCKDqfWY4wJKUVC4gZiqYvXj6C3byQ23a6VQUZrO2Up/q+JRc8EbgDtg+7lI5tfCPr+xNVSLedVQm7eFhq43jcbmT8J/bOtANra5A1O3Vf0Zh1PPVV/ujSkE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574666445919698.8376886949042; Sun, 24 Nov 2019 23:20:45 -0800 (PST) Received: from localhost ([::1]:40974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8fs-00010S-Qe for importer@patchew.org; Mon, 25 Nov 2019 02:20:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41944) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8M9-0003b3-VC for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8M8-000253-1G for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:21 -0500 Received: from 2.mo179.mail-out.ovh.net ([178.33.250.45]:38647) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8M7-00022n-QG for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:19 -0500 Received: from player697.ha.ovh.net (unknown [10.109.143.136]) by mo179.mail-out.ovh.net (Postfix) with ESMTP id 8DA9414BC51 for ; Mon, 25 Nov 2019 08:00:13 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id B26BDC809797; Mon, 25 Nov 2019 07:00:07 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 17/20] ppc/xive: Synthesize interrupt from the saved IPB in the NVT Date: Mon, 25 Nov 2019 07:58:17 +0100 Message-Id: <20191125065820.927-18-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8934297236856736742 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.250.45 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When a vCPU is dispatched on a HW thread, its context is pushed in the thread registers and it is activated by setting the VO bit in the CAM line word2. The HW grabs the associated NVT, pulls the IPB bits and merges them with the IPB of the new context. If interrupts were missed while the vCPU was not dispatched, these are synthesized in this sequence. Signed-off-by: C=C3=A9dric Le Goater --- hw/intc/xive.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 7047e45daca1..e022bb7afd28 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -393,6 +393,57 @@ static uint64_t xive_tm_pull_os_ctx(XivePresenter *xpt= r, XiveTCTX *tctx, return qw1w2; } =20 +static void xive_tctx_need_resend(XiveRouter *xrtr, XiveTCTX *tctx, + uint8_t nvt_blk, uint32_t nvt_idx) +{ + XiveNVT nvt; + uint8_t ipb; + + /* + * Grab the associated NVT to pull the pending bits, and merge + * them with the IPB of the thread interrupt context registers + */ + if (xive_router_get_nvt(xrtr, nvt_blk, nvt_idx, &nvt)) { + qemu_log_mask(LOG_GUEST_ERROR, "XIVE: invalid NVT %x/%x\n", + nvt_blk, nvt_idx); + return; + } + + ipb =3D xive_get_field32(NVT_W4_IPB, nvt.w4); + + if (ipb) { + /* Reset the NVT value */ + nvt.w4 =3D xive_set_field32(NVT_W4_IPB, nvt.w4, 0); + xive_router_write_nvt(xrtr, nvt_blk, nvt_idx, &nvt, 4); + + /* Merge in current context */ + xive_tctx_ipb_update(tctx, TM_QW1_OS, ipb); + } +} + +/* + * Updating the OS CAM line can trigger a resend of interrupt + */ +static void xive_tm_push_os_ctx(XivePresenter *xptr, XiveTCTX *tctx, + hwaddr offset, uint64_t value, unsigned si= ze) +{ + uint32_t cam =3D value; + uint32_t qw1w2 =3D cpu_to_be32(cam); + uint8_t nvt_blk; + uint32_t nvt_idx; + bool vo; + + xive_os_cam_decode(cam, &nvt_blk, &nvt_idx, &vo); + + /* First update the registers */ + xive_tctx_set_os_cam(tctx, qw1w2); + + /* Check the interrupt pending bits */ + if (vo) { + xive_tctx_need_resend(XIVE_ROUTER(xptr), tctx, nvt_blk, nvt_idx); + } +} + /* * Define a mapping of "special" operations depending on the TIMA page * offset and the size of the operation. @@ -414,6 +465,7 @@ static const XiveTmOp xive_tm_operations[] =3D { * effects */ { XIVE_TM_OS_PAGE, TM_QW1_OS + TM_CPPR, 1, xive_tm_set_os_cppr, NULL= }, + { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, xive_tm_push_os_ctx, N= ULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, xive_tm_set_hv_cppr, N= ULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, xive_tm_vt_push, NULL= }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, NULL, xive_tm_vt_poll= }, --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665739; cv=none; d=zohomail.com; s=zohoarc; b=cxR1qvBkmChmfLAfBJ6Y0uqvysbonQTcmub3dEsmh6JabFhL3+Z15NzHEJv007OxqmT481FxwmNfGoF9nKraSEDEu0V1LuA1+FlLiQVnO62Ww0kZXuGNqBJSBcT5C4Llr6nsVBzflU3ZUrq5RXHaH1e2ZXg2nra9r1qmK5jNza8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665739; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h1CdKLmdlwfvgpn1dqLgFihXjcyCRtQihnYQ8O+aK/U=; b=MJZDdJxDj/IO4/c9ZSpAXksv9Aq/v60IqkkeO1MV812x5ZKRcwqDIX8jGzAXvRfxKwnuIjOpbw0ORAP8PzJwAV6d0txUBzcoCBFhlrnaPvAiFKXZs9zo75SKxbTBnHT52wmvav8QiJZ5vr+xAV/aaxKwL3Zw+aENerJp0BsYjtg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665739535486.1794146027928; Sun, 24 Nov 2019 23:08:59 -0800 (PST) Received: from localhost ([::1]:40836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8UT-00049W-V1 for importer@patchew.org; Mon, 25 Nov 2019 02:08:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41990) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8MF-0003es-Gh for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8MD-00028A-QQ for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:27 -0500 Received: from 6.mo68.mail-out.ovh.net ([46.105.63.100]:38661) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8M9-00024Y-Sq for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:23 -0500 Received: from player697.ha.ovh.net (unknown [10.108.54.13]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 3599E14CF91 for ; Mon, 25 Nov 2019 08:00:19 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 65846C809808; Mon, 25 Nov 2019 07:00:13 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 18/20] ppc/pnv: Introduce a pnv_xive_block_id() helper Date: Mon, 25 Nov 2019 07:58:18 +0100 Message-Id: <20191125065820.927-19-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8935986086538808294 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.63.100 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When PC_TCTXT_CHIPID_OVERRIDE is configured, the PC_TCTXT_CHIPID field overrides the hardwired chip ID in the Powerbus operations and for CAM compares. This is typically used in the one block-per-chip configuration to associate a unique block id number to each IC of the system. Simplify the model with a pnv_xive_block_id() helper and remove 'tctx_chipid' which becomes useless. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/pnv_xive.h | 3 -- hw/intc/pnv_xive.c | 64 ++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/include/hw/ppc/pnv_xive.h b/include/hw/ppc/pnv_xive.h index 4fdaa9247d65..f4c7caad40ee 100644 --- a/include/hw/ppc/pnv_xive.h +++ b/include/hw/ppc/pnv_xive.h @@ -72,9 +72,6 @@ typedef struct PnvXive { /* Interrupt controller registers */ uint64_t regs[0x300]; =20 - /* Can be configured by FW */ - uint32_t tctx_chipid; - /* * Virtual Structure Descriptor tables : EAT, SBE, ENDT, NVTT, IRQ * These are in a SRAM protected by ECC. diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index 216ebc150a41..23e73641f254 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -85,13 +85,30 @@ static inline uint64_t SETFIELD(uint64_t mask, uint64_t= word, return (word & ~mask) | ((value << ctz64(mask)) & mask); } =20 +/* + * When PC_TCTXT_CHIPID_OVERRIDE is configured, the PC_TCTXT_CHIPID + * field overrides the hardwired chip ID in the Powerbus operations + * and for CAM compares + */ +static uint8_t pnv_xive_block_id(PnvXive *xive) +{ + uint8_t blk =3D xive->chip->chip_id; + uint64_t cfg_val =3D xive->regs[PC_TCTXT_CFG >> 3]; + + if (cfg_val & PC_TCTXT_CHIPID_OVERRIDE) { + blk =3D GETFIELD(PC_TCTXT_CHIPID, cfg_val); + } + + return blk; +} + /* * Remote access to controllers. HW uses MMIOs. For now, a simple scan * of the chips is good enough. * * TODO: Block scope support */ -static PnvXive *pnv_xive_get_ic(uint8_t blk) +static PnvXive *pnv_xive_get_remote(uint8_t blk) { PnvMachineState *pnv =3D PNV_MACHINE(qdev_get_machine()); int i; @@ -100,7 +117,7 @@ static PnvXive *pnv_xive_get_ic(uint8_t blk) Pnv9Chip *chip9 =3D PNV9_CHIP(pnv->chips[i]); PnvXive *xive =3D &chip9->xive; =20 - if (xive->chip->chip_id =3D=3D blk) { + if (pnv_xive_block_id(xive) =3D=3D blk) { return xive; } } @@ -216,7 +233,7 @@ static uint64_t pnv_xive_vst_addr(PnvXive *xive, uint32= _t type, uint8_t blk, =20 /* Remote VST access */ if (GETFIELD(VSD_MODE, vsd) =3D=3D VSD_MODE_FORWARD) { - xive =3D pnv_xive_get_ic(blk); + xive =3D pnv_xive_get_remote(blk); =20 return xive ? pnv_xive_vst_addr(xive, type, blk, idx) : 0; } @@ -364,7 +381,10 @@ static int pnv_xive_get_eas(XiveRouter *xrtr, uint8_t = blk, uint32_t idx, { PnvXive *xive =3D PNV_XIVE(xrtr); =20 - if (pnv_xive_get_ic(blk) !=3D xive) { + /* + * EAT lookups should be local to the IC + */ + if (pnv_xive_block_id(xive) !=3D blk) { xive_error(xive, "VST: EAS %x is remote !?", XIVE_EAS(blk, idx)); return -1; } @@ -470,7 +490,7 @@ static PnvXive *pnv_xive_tm_get_xive(PowerPCCPU *cpu) static void pnv_xive_notify(XiveNotifier *xn, uint32_t srcno) { PnvXive *xive =3D PNV_XIVE(xn); - uint8_t blk =3D xive->chip->chip_id; + uint8_t blk =3D pnv_xive_block_id(xive); =20 xive_router_notify(xn, XIVE_EAS(blk, srcno)); } @@ -834,20 +854,7 @@ static void pnv_xive_ic_reg_write(void *opaque, hwaddr= offset, case PC_TCTXT_CFG: /* * TODO: block group support - * - * PC_TCTXT_CFG_BLKGRP_EN - * PC_TCTXT_CFG_HARD_CHIPID_BLK : - * Moves the chipid into block field for hardwired CAM compares. - * Block offset value is adjusted to 0b0..01 & ThrdId - * - * Will require changes in xive_presenter_tctx_match(). I am - * not sure how to handle that yet. */ - - /* Overrides hardwired chip ID with the chip ID field */ - if (val & PC_TCTXT_CHIPID_OVERRIDE) { - xive->tctx_chipid =3D GETFIELD(PC_TCTXT_CHIPID, val); - } break; case PC_TCTXT_TRACK: /* @@ -1656,19 +1663,20 @@ static const MemoryRegionOps pnv_xive_pc_ops =3D { void pnv_xive_pic_print_info(PnvXive *xive, Monitor *mon) { XiveRouter *xrtr =3D XIVE_ROUTER(xive); - uint8_t blk =3D xive->chip->chip_id; + uint8_t blk =3D pnv_xive_block_id(xive); + uint8_t chip_id =3D xive->chip->chip_id; uint32_t srcno0 =3D XIVE_EAS(blk, 0); uint32_t nr_ipis =3D pnv_xive_nr_ipis(xive, blk); XiveEAS eas; XiveEND end; int i; =20 - monitor_printf(mon, "XIVE[%x] Source %08x .. %08x\n", blk, srcno0, - srcno0 + nr_ipis - 1); + monitor_printf(mon, "XIVE[%x] #%d Source %08x .. %08x\n", chip_id, blk, + srcno0, srcno0 + nr_ipis - 1); xive_source_pic_print_info(&xive->ipi_source, srcno0, mon); =20 - monitor_printf(mon, "XIVE[%x] EAT %08x .. %08x\n", blk, srcno0, - srcno0 + nr_ipis - 1); + monitor_printf(mon, "XIVE[%x] #%d EAT %08x .. %08x\n", chip_id, blk, + srcno0, srcno0 + nr_ipis - 1); for (i =3D 0; i < nr_ipis; i++) { if (xive_router_get_eas(xrtr, blk, i, &eas)) { break; @@ -1678,13 +1686,13 @@ void pnv_xive_pic_print_info(PnvXive *xive, Monitor= *mon) } } =20 - monitor_printf(mon, "XIVE[%x] ENDT\n", blk); + monitor_printf(mon, "XIVE[%x] #%d ENDT\n", chip_id, blk); i =3D 0; while (!xive_router_get_end(xrtr, blk, i, &end)) { xive_end_pic_print_info(&end, i++, mon); } =20 - monitor_printf(mon, "XIVE[%x] END Escalation EAT\n", blk); + monitor_printf(mon, "XIVE[%x] #%d END Escalation EAT\n", chip_id, blk); i =3D 0; while (!xive_router_get_end(xrtr, blk, i, &end)) { xive_end_eas_pic_print_info(&end, i++, mon); @@ -1697,12 +1705,6 @@ static void pnv_xive_reset(void *dev) XiveSource *xsrc =3D &xive->ipi_source; XiveENDSource *end_xsrc =3D &xive->end_source; =20 - /* - * Use the PnvChip id to identify the XIVE interrupt controller. - * It can be overriden by configuration at runtime. - */ - xive->tctx_chipid =3D xive->chip->chip_id; - /* Default page size (Should be changed at runtime to 64k) */ xive->ic_shift =3D xive->vc_shift =3D xive->pc_shift =3D 12; =20 --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574666355; cv=none; d=zohomail.com; s=zohoarc; b=FkR3LYjr4ybnZ24DcRQwIwhwxhh8TOajtgRzFeZo3CIUSWgU4cy9Pst7et8FlFVIuAe7NHJdyvxBHbeblXquFpHcAKUn5H+ZEtV6nhKhfwE3ltdgJVQwkKovHd2Ql/LbfPr/syu+2T+kq0GYxr3Qfasc9sQ1vXeulCkKqfeMzhw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574666355; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w/z30MkyXo97Zef4YwWAa/3l1NJjkLssel52H1738xs=; b=jfic00urnxoDaeIeQsjuCPueFl+0omfZUkVayJeuT0H0aBDaZue4/OqW7UXulFgNmGSu4E1XH+oP4aR90tKest9EhrqKfAvE8J673wo7KJg+9iwWm4HgguFfLG6jh2A3wbdFfja7Wxo/Fyb3jN/lSPaBLQsqMwp5vsWDhGauuT4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574666355319719.2451377512132; Sun, 24 Nov 2019 23:19:15 -0800 (PST) Received: from localhost ([::1]:40946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8eP-0007Ns-Rk for importer@patchew.org; Mon, 25 Nov 2019 02:19:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42009) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8MG-0003gq-Gh for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8ME-0002AB-VH for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:28 -0500 Received: from 1.mo2.mail-out.ovh.net ([46.105.63.121]:43458) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8ME-00027n-Lg for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:26 -0500 Received: from player697.ha.ovh.net (unknown [10.108.42.73]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id D72161AC5A6 for ; Mon, 25 Nov 2019 08:00:24 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 25C2EC80988D; Mon, 25 Nov 2019 07:00:19 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 19/20] ppc/pnv: Extend XiveRouter with a get_block_id() handler Date: Mon, 25 Nov 2019 07:58:19 +0100 Message-Id: <20191125065820.927-20-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8937393462642052070 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedu Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.63.121 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When doing CAM line compares, fetch the block id from the interrupt controller which can have set the PC_TCTXT_CHIPID field. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/xive.h | 2 +- hw/intc/pnv_xive.c | 6 ++++++ hw/intc/spapr_xive.c | 6 ++++++ hw/intc/xive.c | 21 ++++++++++++++++----- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index 9c0bf2c301e2..1b7b89098f71 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -351,6 +351,7 @@ typedef struct XiveRouterClass { XiveNVT *nvt); int (*write_nvt)(XiveRouter *xrtr, uint8_t nvt_blk, uint32_t nvt_idx, XiveNVT *nvt, uint8_t word_number); + uint8_t (*get_block_id)(XiveRouter *xrtr); } XiveRouterClass; =20 int xive_router_get_eas(XiveRouter *xrtr, uint8_t eas_blk, uint32_t eas_id= x, @@ -431,7 +432,6 @@ typedef struct XiveENDSource { DeviceState parent; =20 uint32_t nr_ends; - uint8_t block_id; =20 /* ESB memory region */ uint32_t esb_shift; diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index 23e73641f254..43c760efd137 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -459,6 +459,11 @@ static int pnv_xive_match_nvt(XivePresenter *xptr, uin= t8_t format, return count; } =20 +static uint8_t pnv_xive_get_block_id(XiveRouter *xrtr) +{ + return pnv_xive_block_id(PNV_XIVE(xrtr)); +} + /* * The TIMA MMIO space is shared among the chips and to identify the * chip from which the access is being done, we extract the chip id @@ -1890,6 +1895,7 @@ static void pnv_xive_class_init(ObjectClass *klass, v= oid *data) xrc->write_end =3D pnv_xive_write_end; xrc->get_nvt =3D pnv_xive_get_nvt; xrc->write_nvt =3D pnv_xive_write_nvt; + xrc->get_block_id =3D pnv_xive_get_block_id; =20 xnc->notify =3D pnv_xive_notify; xpc->match_nvt =3D pnv_xive_match_nvt; diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index 1542cef91878..daa0656859a3 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -473,6 +473,11 @@ static int spapr_xive_match_nvt(XivePresenter *xptr, u= int8_t format, return count; } =20 +static uint8_t spapr_xive_get_block_id(XiveRouter *xrtr) +{ + return SPAPR_XIVE_BLOCK_ID; +} + static const VMStateDescription vmstate_spapr_xive_end =3D { .name =3D TYPE_SPAPR_XIVE "/end", .version_id =3D 1, @@ -764,6 +769,7 @@ static void spapr_xive_class_init(ObjectClass *klass, v= oid *data) xrc->write_end =3D spapr_xive_write_end; xrc->get_nvt =3D spapr_xive_get_nvt; xrc->write_nvt =3D spapr_xive_write_nvt; + xrc->get_block_id =3D spapr_xive_get_block_id; =20 sicc->activate =3D spapr_xive_activate; sicc->deactivate =3D spapr_xive_deactivate; diff --git a/hw/intc/xive.c b/hw/intc/xive.c index e022bb7afd28..d4c6e21703b3 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -1371,17 +1371,25 @@ int xive_router_write_nvt(XiveRouter *xrtr, uint8_t= nvt_blk, uint32_t nvt_idx, return xrc->write_nvt(xrtr, nvt_blk, nvt_idx, nvt, word_number); } =20 +static int xive_router_get_block_id(XiveRouter *xrtr) +{ + XiveRouterClass *xrc =3D XIVE_ROUTER_GET_CLASS(xrtr); + + return xrc->get_block_id(xrtr); +} + /* * Encode the HW CAM line in the block group mode format : * * chip << 19 | 0000000 0 0001 thread (7Bit) */ -static uint32_t xive_tctx_hw_cam_line(XiveTCTX *tctx) +static uint32_t xive_tctx_hw_cam_line(XivePresenter *xptr, XiveTCTX *tctx) { CPUPPCState *env =3D &POWERPC_CPU(tctx->cs)->env; uint32_t pir =3D env->spr_cb[SPR_PIR].default_value; + uint8_t blk =3D xive_router_get_block_id(XIVE_ROUTER(xptr)); =20 - return xive_nvt_cam_line((pir >> 8) & 0xf, 1 << 7 | (pir & 0x7f)); + return xive_nvt_cam_line(blk, 1 << 7 | (pir & 0x7f)); } =20 /* @@ -1418,7 +1426,7 @@ int xive_presenter_tctx_match(XivePresenter *xptr, Xi= veTCTX *tctx, =20 /* PHYS ring */ if ((be32_to_cpu(qw3w2) & TM_QW3W2_VT) && - cam =3D=3D xive_tctx_hw_cam_line(tctx)) { + cam =3D=3D xive_tctx_hw_cam_line(xptr, tctx)) { return TM_QW3_HV_PHYS; } =20 @@ -1755,7 +1763,11 @@ static uint64_t xive_end_source_read(void *opaque, h= waddr addr, unsigned size) uint8_t pq; uint64_t ret =3D -1; =20 - end_blk =3D xsrc->block_id; + /* + * The block id should be deduced from the load address on the END + * ESB MMIO but our model only supports a single block per XIVE chip. + */ + end_blk =3D xive_router_get_block_id(xsrc->xrtr); end_idx =3D addr >> (xsrc->esb_shift + 1); =20 if (xive_router_get_end(xsrc->xrtr, end_blk, end_idx, &end)) { @@ -1855,7 +1867,6 @@ static void xive_end_source_realize(DeviceState *dev,= Error **errp) } =20 static Property xive_end_source_properties[] =3D { - DEFINE_PROP_UINT8("block-id", XiveENDSource, block_id, 0), DEFINE_PROP_UINT32("nr-ends", XiveENDSource, nr_ends, 0), DEFINE_PROP_UINT32("shift", XiveENDSource, esb_shift, XIVE_ESB_64K), DEFINE_PROP_LINK("xive", XiveENDSource, xrtr, TYPE_XIVE_ROUTER, --=20 2.21.0 From nobody Sun May 12 08:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574665958; cv=none; d=zohomail.com; s=zohoarc; b=dly6qVa43XgfK2TcmfJhtty1QR1PejHWv3DHf0Ut9W1IFoqkeX/fg36zIHT6vKWY4wLm94tNgPGl7BMlodl10Lj8xd3AAWTD780NCECvMK1LyuuOhpT3b8Gwubb1mC8AypMZa0a0xV/cKYD55+eAV/RFZXiffDZU/IfCgKHoLAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574665958; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sUvBSs2XqAwu3lgVt5i4kqO0ET+hrp4deAaviJ13JzU=; b=IFs+0A0su3YTw2Z2cn1kPcilugvfOR6ObmoUI3x9esOvFsfRclssn0UYvj2s0AdNuGC5/YWdc0kJYdmPhM/0QVv8mpNb4pH1FHoqIrHRVSfOicZnssiJ+xRA3CgQALdmg7viCWHMRg8eLSzHSBoEcZj1goDVOOEN/2PddXSvn2o= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574665958580469.73998661296275; Sun, 24 Nov 2019 23:12:38 -0800 (PST) Received: from localhost ([::1]:40866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8Y0-0007hd-Gr for importer@patchew.org; Mon, 25 Nov 2019 02:12:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42086) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZ8MM-0003sR-LV for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZ8ML-0002HU-3S for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:34 -0500 Received: from 6.mo2.mail-out.ovh.net ([87.98.165.38]:37053) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZ8MK-0002FP-NT for qemu-devel@nongnu.org; Mon, 25 Nov 2019 02:00:32 -0500 Received: from player697.ha.ovh.net (unknown [10.108.54.108]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id 588CB1AFDFF for ; Mon, 25 Nov 2019 08:00:31 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id C945BC8098FB; Mon, 25 Nov 2019 07:00:24 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH v6 20/20] ppc/pnv: Dump the XIVE NVT table Date: Mon, 25 Nov 2019 07:58:20 +0100 Message-Id: <20191125065820.927-21-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191125065820.927-1-clg@kaod.org> References: <20191125065820.927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 8939363785798683622 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeitddggedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrheileejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedv Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.165.38 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This is useful to dump the saved contexts of the vCPUs : configuration of the base END index of the vCPU and the Interrupt Pending Buffer register, which is updated when an interrupt can not be presented. When dumping the NVT table, we skip empty indirect pages which are not necessarily allocated. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/ppc/xive_regs.h | 3 ++ hw/intc/pnv_xive.c | 64 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/include/hw/ppc/xive_regs.h b/include/hw/ppc/xive_regs.h index 1a5622f8ded8..09f243600c5d 100644 --- a/include/hw/ppc/xive_regs.h +++ b/include/hw/ppc/xive_regs.h @@ -252,6 +252,8 @@ typedef struct XiveNVT { uint32_t w0; #define NVT_W0_VALID PPC_BIT32(0) uint32_t w1; +#define NVT_W1_EQ_BLOCK PPC_BITMASK32(0, 3) +#define NVT_W1_EQ_INDEX PPC_BITMASK32(4, 31) uint32_t w2; uint32_t w3; uint32_t w4; @@ -277,6 +279,7 @@ typedef struct XiveNVT { * field of the XIVE END */ #define XIVE_NVT_SHIFT 19 +#define XIVE_NVT_COUNT (1 << XIVE_NVT_SHIFT) =20 static inline uint32_t xive_nvt_cam_line(uint8_t nvt_blk, uint32_t nvt_idx) { diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index 43c760efd137..a0a69b98a713 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -527,6 +527,44 @@ static uint32_t pnv_xive_nr_ipis(PnvXive *xive, uint8_= t blk) return VSD_INDIRECT & vsd ? 0 : vst_tsize * SBE_PER_BYTE; } =20 +/* + * Compute the number of entries per indirect subpage. + */ +static uint64_t pnv_xive_vst_per_subpage(PnvXive *xive, uint32_t type) +{ + uint8_t blk =3D pnv_xive_block_id(xive); + uint64_t vsd =3D xive->vsds[type][blk]; + const XiveVstInfo *info =3D &vst_infos[type]; + uint64_t vsd_addr; + uint32_t page_shift; + + /* For direct tables, fake a valid value */ + if (!(VSD_INDIRECT & vsd)) { + return 1; + } + + /* Get the page size of the indirect table. */ + vsd_addr =3D vsd & VSD_ADDRESS_MASK; + vsd =3D ldq_be_dma(&address_space_memory, vsd_addr); + + if (!(vsd & VSD_ADDRESS_MASK)) { +#ifdef XIVE_DEBUG + xive_error(xive, "VST: invalid %s entry %x !?", info->name, idx); +#endif + return 0; + } + + page_shift =3D GETFIELD(VSD_TSIZE, vsd) + 12; + + if (!pnv_xive_vst_page_size_allowed(page_shift)) { + xive_error(xive, "VST: invalid %s page shift %d", info->name, + page_shift); + return 0; + } + + return (1ull << page_shift) / info->size; +} + /* * EDT Table * @@ -1665,6 +1703,21 @@ static const MemoryRegionOps pnv_xive_pc_ops =3D { }, }; =20 +static void xive_nvt_pic_print_info(XiveNVT *nvt, uint32_t nvt_idx, + Monitor *mon) +{ + uint8_t eq_blk =3D xive_get_field32(NVT_W1_EQ_BLOCK, nvt->w1); + uint32_t eq_idx =3D xive_get_field32(NVT_W1_EQ_INDEX, nvt->w1); + + if (!xive_nvt_is_valid(nvt)) { + return; + } + + monitor_printf(mon, " %08x end:%02x/%04x IPB:%02x\n", nvt_idx, + eq_blk, eq_idx, + xive_get_field32(NVT_W4_IPB, nvt->w4)); +} + void pnv_xive_pic_print_info(PnvXive *xive, Monitor *mon) { XiveRouter *xrtr =3D XIVE_ROUTER(xive); @@ -1674,7 +1727,9 @@ void pnv_xive_pic_print_info(PnvXive *xive, Monitor *= mon) uint32_t nr_ipis =3D pnv_xive_nr_ipis(xive, blk); XiveEAS eas; XiveEND end; + XiveNVT nvt; int i; + uint64_t xive_nvt_per_subpage; =20 monitor_printf(mon, "XIVE[%x] #%d Source %08x .. %08x\n", chip_id, blk, srcno0, srcno0 + nr_ipis - 1); @@ -1702,6 +1757,15 @@ void pnv_xive_pic_print_info(PnvXive *xive, Monitor = *mon) while (!xive_router_get_end(xrtr, blk, i, &end)) { xive_end_eas_pic_print_info(&end, i++, mon); } + + monitor_printf(mon, "XIVE[%x] #%d NVTT %08x .. %08x\n", chip_id, blk, + 0, XIVE_NVT_COUNT - 1); + xive_nvt_per_subpage =3D pnv_xive_vst_per_subpage(xive, VST_TSEL_VPDT); + for (i =3D 0; i < XIVE_NVT_COUNT; i +=3D xive_nvt_per_subpage) { + while (!xive_router_get_nvt(xrtr, blk, i, &nvt)) { + xive_nvt_pic_print_info(&nvt, i++, mon); + } + } } =20 static void pnv_xive_reset(void *dev) --=20 2.21.0