From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513317566232108.62291600978995; Thu, 14 Dec 2017 21:59:26 -0800 (PST) Received: from localhost ([::1]:44595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePj1Z-0007bN-7U for importer@patchew.org; Fri, 15 Dec 2017 00:59:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixI-0003Zv-Mu for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixH-0004aO-Qz for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:44 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:59755) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixH-0004WH-Fz; Fri, 15 Dec 2017 00:54:43 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflM2wTlz9t2Z; Fri, 15 Dec 2017 16:54:39 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317279; bh=W1xnHzpgZc+mTZlXqGmfBhnmOc/XJTeaxjxw0mIGZdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EU5wqqhQL26Pki0wvFgeDX+yHhURk9kw7PqesMuwGoQ9HD1wmqf7YdqjjxIiX97m5 HHVW0M46f9Txem8Ti6ejlsJVJbbwAnt+WkCiBb6EkJt7bi1A/mQhnO1Njlm4uK/PWy GcrSLsIqLCrV0QpKZj+Dpk1IpWrv2fG7//zlZNLQ= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:12 +1100 Message-Id: <20171215055435.24204-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 01/24] target/ppc: Use tcg_gen_lookup_and_goto_ptr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Daniel Henrique Barboza Signed-off-by: David Gibson --- target/ppc/translate.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 998fbed848..4075fc8589 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3419,7 +3419,7 @@ static inline bool use_goto_tb(DisasContext *ctx, tar= get_ulong dest) } =20 /*** Branch = ***/ -static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest) +static void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest) { if (NARROW_MODE(ctx)) { dest =3D (uint32_t) dest; @@ -3441,7 +3441,7 @@ static inline void gen_goto_tb(DisasContext *ctx, int= n, target_ulong dest) gen_debug_exception(ctx); } } - tcg_gen_exit_tb(0); + tcg_gen_lookup_and_goto_ptr(); } } =20 @@ -3479,7 +3479,7 @@ static void gen_b(DisasContext *ctx) #define BCOND_CTR 2 #define BCOND_TAR 3 =20 -static inline void gen_bcond(DisasContext *ctx, int type) +static void gen_bcond(DisasContext *ctx, int type) { uint32_t bo =3D BO(ctx->opcode); TCGLabel *l1; @@ -3543,26 +3543,19 @@ static inline void gen_bcond(DisasContext *ctx, int= type) } else { gen_goto_tb(ctx, 0, li); } - if ((bo & 0x14) !=3D 0x14) { - gen_set_label(l1); - gen_goto_tb(ctx, 1, ctx->nip); - } } else { if (NARROW_MODE(ctx)) { tcg_gen_andi_tl(cpu_nip, target, (uint32_t)~3); } else { tcg_gen_andi_tl(cpu_nip, target, ~3); } - tcg_gen_exit_tb(0); - if ((bo & 0x14) !=3D 0x14) { - gen_set_label(l1); - gen_update_nip(ctx, ctx->nip); - tcg_gen_exit_tb(0); - } - } - if (type =3D=3D BCOND_LR || type =3D=3D BCOND_CTR || type =3D=3D BCOND= _TAR) { + tcg_gen_lookup_and_goto_ptr(); tcg_temp_free(target); } + if ((bo & 0x14) !=3D 0x14) { + gen_set_label(l1); + gen_goto_tb(ctx, 1, ctx->nip); + } } =20 static void gen_bc(DisasContext *ctx) --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513317403900920.2302123747153; Thu, 14 Dec 2017 21:56:43 -0800 (PST) Received: from localhost ([::1]:44581 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePizC-00057R-90 for importer@patchew.org; Fri, 15 Dec 2017 00:56:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixJ-0003a3-1P for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixI-0004am-A5 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:45 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:59557) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixH-0004WY-UC; Fri, 15 Dec 2017 00:54:44 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflM4rbgz9t3m; Fri, 15 Dec 2017 16:54:39 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317279; bh=h5UbQClWtreCbufMUA7uqEOYaORU84s8mnXs4sTJ2S8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jEgq4cMAw4yUvwAapKmGHz9BjUcyUnPMVLbUWsM7fpu5ZjQVeZ/7tYZBbts31rce7 6r1WHp1wItzGfh2fHKhrtzyc7uJzrwSYRfuhkj/vD28besNynogjqhaJOsLSZGDFbp qg/8W9TYYj7n94f9EodQ4GxiOVKQBshorrMfoNLM= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:13 +1100 Message-Id: <20171215055435.24204-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 02/24] ppc/xics: remove useless if condition X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater The previous code section uses a 'first < 0' test and returns. Therefore, there is no need to test the 'first' variable against '>=3D 0' afterwards. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz Signed-off-by: David Gibson --- hw/intc/xics_spapr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index d98ea8b130..e8c0a1b3e9 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -329,10 +329,8 @@ int spapr_ics_alloc_block(ICSState *ics, int num, bool= lsi, return -1; } =20 - if (first >=3D 0) { - for (i =3D first; i < first + num; ++i) { - ics_set_irq_type(ics, i, lsi); - } + for (i =3D first; i < first + num; ++i) { + ics_set_irq_type(ics, i, lsi); } first +=3D ics->offset; =20 --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513317402011797.717814231399; Thu, 14 Dec 2017 21:56:42 -0800 (PST) Received: from localhost ([::1]:44582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePizA-00057i-CH for importer@patchew.org; Fri, 15 Dec 2017 00:56:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixJ-0003a9-OT for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixI-0004bh-Tr for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:45 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:33693) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixI-0004X8-J4; Fri, 15 Dec 2017 00:54:44 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflN00PRz9t4B; Fri, 15 Dec 2017 16:54:39 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317280; bh=0coxTQN17N/EYoQzfkJwitMUSFNEKOBb6SfP94JcF1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UM9/KR5typ5RUqT/MvcdrS8Mhzflaw+QavFnqvWElg3ztq1SqcgobwHdKK6lGvZfE 5SEJEYSYLWUd/tYT8E1ahVbej86nAsIvXIfRxdZzdqhKapiw8Y5x/lMAVd8y002D+M a8OgNR9jfXmNsBRrQEjmdHXB3nODR9FRnwiPI4Ig= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:14 +1100 Message-Id: <20171215055435.24204-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 03/24] spapr: Add pseries-2.12 machine type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" While we're at it fix a couple of small errors in the 2.11 and 2.10 models (they didn't have any real effect, but don't quite match the template). Signed-off-by: David Gibson --- hw/ppc/spapr.c | 26 +++++++++++++++++++++++--- include/hw/compat.h | 2 ++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 1ac7eb0f8c..8881f2f1e8 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3713,28 +3713,48 @@ static const TypeInfo spapr_machine_info =3D { } \ type_init(spapr_machine_register_##suffix) =20 +/* + * pseries-2.12 + */ +static void spapr_machine_2_12_instance_options(MachineState *machine) +{ +} + +static void spapr_machine_2_12_class_options(MachineClass *mc) +{ + /* Defaults for the latest behaviour inherited from the base class */ +} + +DEFINE_SPAPR_MACHINE(2_12, "2.12", true); + /* * pseries-2.11 */ +#define SPAPR_COMPAT_2_11 \ + HW_COMPAT_2_11 + static void spapr_machine_2_11_instance_options(MachineState *machine) { + spapr_machine_2_12_instance_options(machine); } =20 static void spapr_machine_2_11_class_options(MachineClass *mc) { - /* Defaults for the latest behaviour inherited from the base class */ + spapr_machine_2_12_class_options(mc); + SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_11); } =20 -DEFINE_SPAPR_MACHINE(2_11, "2.11", true); +DEFINE_SPAPR_MACHINE(2_11, "2.11", false); =20 /* * pseries-2.10 */ #define SPAPR_COMPAT_2_10 \ - HW_COMPAT_2_10 \ + HW_COMPAT_2_10 =20 static void spapr_machine_2_10_instance_options(MachineState *machine) { + spapr_machine_2_11_instance_options(machine); } =20 static void spapr_machine_2_10_class_options(MachineClass *mc) diff --git a/include/hw/compat.h b/include/hw/compat.h index cf389b4e85..0d2a6ac468 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -1,6 +1,8 @@ #ifndef HW_COMPAT_H #define HW_COMPAT_H =20 +#define HW_COMPAT_2_11 + #define HW_COMPAT_2_10 \ {\ .driver =3D "virtio-mouse-device",\ --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513317740222418.71649346829247; Thu, 14 Dec 2017 22:02:20 -0800 (PST) Received: from localhost ([::1]:44617 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePj4c-0001qE-Bm for importer@patchew.org; Fri, 15 Dec 2017 01:02:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixK-0003ay-HD for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixJ-0004cI-Av for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:46 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:50037) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixI-0004Wr-7I; Fri, 15 Dec 2017 00:54:45 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflM5nzTz9t3t; Fri, 15 Dec 2017 16:54:39 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317279; bh=77aOGAqPIDbX2Z0HrX1ejiSEeGMfFkRFPWjnPNUW/mM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SuV/8s/SM+dknBa/24e6G95EA8dADe/FqsMcAL2mk8heWu1u/TKdA0UctVacI6YjY QunNy85mTi/BYf3JFKBznKckZTK66weFViaiYag2q1lUru7BFviJrIzAQRbTlCFiJ1 +ynE9ScDwO7V5gIUgQUHlzeAo0aP+1sPwhqRjtUE= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:15 +1100 Message-Id: <20171215055435.24204-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 04/24] spapr_cpu_core: instantiate CPUs separately X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz The current code assumes that only the CPU core object holds a reference on each individual CPU object, and happily frees their allocated memory when the core is unrealized. This is dangerous as some other code can legitimely keep a pointer to a CPU if it calls object_ref(), but it would end up with a dangling pointer. Let's allocate all CPUs with object_new() and let QOM free them when their reference count reaches zero. This greatly simplify the code as we don't have to fiddle with the instance size anymore. Signed-off-by: Greg Kurz Acked-by: Igor Mammedov Signed-off-by: David Gibson --- hw/ppc/spapr.c | 11 +++-------- hw/ppc/spapr_cpu_core.c | 19 +++++++------------ include/hw/ppc/spapr_cpu_core.h | 2 +- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 8881f2f1e8..f1b96a4e92 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3180,12 +3180,10 @@ void spapr_core_release(DeviceState *dev) =20 if (smc->pre_2_10_has_unused_icps) { sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(OBJECT(dev)); - sPAPRCPUCoreClass *scc =3D SPAPR_CPU_CORE_GET_CLASS(OBJECT(cc)); - size_t size =3D object_type_get_instance_size(scc->cpu_type); int i; =20 for (i =3D 0; i < cc->nr_threads; i++) { - CPUState *cs =3D CPU(sc->threads + i * size); + CPUState *cs =3D CPU(sc->threads[i]); =20 pre_2_10_vmstate_register_dummy_icp(cs->cpu_index); } @@ -3231,7 +3229,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); sPAPRCPUCore *core =3D SPAPR_CPU_CORE(OBJECT(dev)); CPUCore *cc =3D CPU_CORE(dev); - CPUState *cs =3D CPU(core->threads); + CPUState *cs =3D CPU(core->threads[0]); sPAPRDRConnector *drc; Error *local_err =3D NULL; int smt =3D kvmppc_smt_threads(); @@ -3276,15 +3274,12 @@ static void spapr_core_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, core_slot->cpu =3D OBJECT(dev); =20 if (smc->pre_2_10_has_unused_icps) { - sPAPRCPUCoreClass *scc =3D SPAPR_CPU_CORE_GET_CLASS(OBJECT(cc)); - size_t size =3D object_type_get_instance_size(scc->cpu_type); int i; =20 for (i =3D 0; i < cc->nr_threads; i++) { sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(dev); - void *obj =3D sc->threads + i * size; =20 - cs =3D CPU(obj); + cs =3D CPU(sc->threads[i]); pre_2_10_vmstate_unregister_dummy_icp(cs->cpu_index); } } diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 3a4c174012..588f9b4571 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -79,13 +79,11 @@ const char *spapr_get_cpu_core_type(const char *cpu_typ= e) static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp) { sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(OBJECT(dev)); - sPAPRCPUCoreClass *scc =3D SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev)); - size_t size =3D object_type_get_instance_size(scc->cpu_type); CPUCore *cc =3D CPU_CORE(dev); int i; =20 for (i =3D 0; i < cc->nr_threads; i++) { - void *obj =3D sc->threads + i * size; + Object *obj =3D OBJECT(sc->threads[i]); DeviceState *dev =3D DEVICE(obj); CPUState *cs =3D CPU(dev); PowerPCCPU *cpu =3D POWERPC_CPU(cs); @@ -146,9 +144,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Er= ror **errp) sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(OBJECT(dev)); sPAPRCPUCoreClass *scc =3D SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev)); CPUCore *cc =3D CPU_CORE(OBJECT(dev)); - size_t size; Error *local_err =3D NULL; - void *obj; + Object *obj; int i, j; =20 if (!spapr) { @@ -156,18 +153,16 @@ static void spapr_cpu_core_realize(DeviceState *dev, = Error **errp) return; } =20 - size =3D object_type_get_instance_size(scc->cpu_type); - sc->threads =3D g_malloc0(size * cc->nr_threads); + sc->threads =3D g_new(PowerPCCPU *, cc->nr_threads); for (i =3D 0; i < cc->nr_threads; i++) { char id[32]; CPUState *cs; PowerPCCPU *cpu; =20 - obj =3D sc->threads + i * size; + obj =3D object_new(scc->cpu_type); =20 - object_initialize(obj, size, scc->cpu_type); cs =3D CPU(obj); - cpu =3D POWERPC_CPU(cs); + cpu =3D sc->threads[i] =3D POWERPC_CPU(obj); cs->cpu_index =3D cc->core_id + i; cpu->vcpu_id =3D (cc->core_id * spapr->vsmt / smp_threads) + i; if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->vcpu_id)) { @@ -192,7 +187,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Er= ror **errp) } =20 for (j =3D 0; j < cc->nr_threads; j++) { - obj =3D sc->threads + j * size; + obj =3D OBJECT(sc->threads[j]); =20 spapr_cpu_core_realize_child(obj, spapr, &local_err); if (local_err) { @@ -203,7 +198,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Er= ror **errp) =20 err: while (--i >=3D 0) { - obj =3D sc->threads + i * size; + obj =3D OBJECT(sc->threads[i]); object_unparent(obj); } g_free(sc->threads); diff --git a/include/hw/ppc/spapr_cpu_core.h b/include/hw/ppc/spapr_cpu_cor= e.h index f2d48d6a67..1129f344aa 100644 --- a/include/hw/ppc/spapr_cpu_core.h +++ b/include/hw/ppc/spapr_cpu_core.h @@ -28,7 +28,7 @@ typedef struct sPAPRCPUCore { CPUCore parent_obj; =20 /*< public >*/ - void *threads; + PowerPCCPU **threads; int node_id; } sPAPRCPUCore; =20 --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151331794696142.54000782771027; Thu, 14 Dec 2017 22:05:46 -0800 (PST) Received: from localhost ([::1]:44632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePj7l-0004gZ-5z for importer@patchew.org; Fri, 15 Dec 2017 01:05:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixM-0003dI-Ez for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixJ-0004cN-C6 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:48 -0500 Received: from ozlabs.org ([103.22.144.67]:36975) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixJ-0004ZD-0U; Fri, 15 Dec 2017 00:54:45 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflN1Qq0z9t3x; Fri, 15 Dec 2017 16:54:39 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317280; bh=hAJqIT0eOCeh8IbuaAxWODyU+GBSNQWb8CBvce1lb7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j003hzjy9rYwo0dzn0lR/L4d8hflK2wDuSKCnxtRhNn116SGB/D7xPtGMqq4+euQu 3I6p5mIGF6xkHa6BboUAKlWDRkL4++rajJ0ph1/7XpGR1pi9bCvsQpTQkUhPCN1Wmr MoiZxoMc6VB9PsuWJenc6gzVxEJe3h1uaKFvqrnY= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:16 +1100 Message-Id: <20171215055435.24204-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 05/24] e500: name openpic and pci host bridge X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, Michael Davidsaver , mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Michael Davidsaver Signed-off-by: Michael Davidsaver Signed-off-by: David Gibson --- hw/ppc/e500.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 5cf0dabef3..c4fe06ea2a 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -685,6 +685,8 @@ static DeviceState *ppce500_init_mpic_qemu(PPCE500Param= s *params, int i, j, k; =20 dev =3D qdev_create(NULL, TYPE_OPENPIC); + object_property_add_child(qdev_get_machine(), "pic", OBJECT(dev), + &error_fatal); qdev_prop_set_uint32(dev, "model", params->mpic_version); qdev_prop_set_uint32(dev, "nb_cpus", smp_cpus); =20 @@ -884,6 +886,8 @@ void ppce500_init(MachineState *machine, PPCE500Params = *params) =20 /* PCI */ dev =3D qdev_create(NULL, "e500-pcihost"); + object_property_add_child(qdev_get_machine(), "pci-host", OBJECT(dev), + &error_abort); qdev_prop_set_uint32(dev, "first_slot", params->pci_first_slot); qdev_prop_set_uint32(dev, "first_pin_irq", pci_irq_nrs[0]); qdev_init_nofail(dev); --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513317594177256.269813963939; Thu, 14 Dec 2017 21:59:54 -0800 (PST) Received: from localhost ([::1]:44598 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePj2D-0008CJ-9o for importer@patchew.org; Fri, 15 Dec 2017 00:59:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixL-0003c3-IB for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixK-0004dc-3k for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:47 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:38189) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixJ-0004ZO-PD; Fri, 15 Dec 2017 00:54:46 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflN3d2Yz9t4V; Fri, 15 Dec 2017 16:54:39 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317280; bh=vns/9Wj2IYeZU6UoTj8I9vdJy6zvmvzPiuFETuzy8hs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JNY/+UH606OT6OIXpp2pBW5RZHMnoUDzVDwypKha6/6hqpStj2m9JT/VXy8Qnpv+D CPnjAJv2V88XIAnvN4V5jORfHIq0RErmfDzGP+aCHh9NVJbGVkn0rcE+6NVQMopMSS HVnL2vYvY9M/j4/QPFRaIvioEM0eMLTLyPbG+tn8= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:17 +1100 Message-Id: <20171215055435.24204-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 06/24] nvram: add AT24Cx i2c eeprom X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, Michael Davidsaver , mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Michael Davidsaver Signed-off-by: Michael Davidsaver Signed-off-by: David Gibson --- hw/nvram/Makefile.objs | 1 + hw/nvram/eeprom_at24c.c | 205 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 206 insertions(+) create mode 100644 hw/nvram/eeprom_at24c.c diff --git a/hw/nvram/Makefile.objs b/hw/nvram/Makefile.objs index c018f6b2ff..0f4ee71dcb 100644 --- a/hw/nvram/Makefile.objs +++ b/hw/nvram/Makefile.objs @@ -1,5 +1,6 @@ common-obj-$(CONFIG_DS1225Y) +=3D ds1225y.o common-obj-y +=3D eeprom93xx.o +common-obj-y +=3D eeprom_at24c.o common-obj-y +=3D fw_cfg.o common-obj-y +=3D chrp_nvram.o common-obj-$(CONFIG_MAC_NVRAM) +=3D mac_nvram.o diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c new file mode 100644 index 0000000000..efa3621ac6 --- /dev/null +++ b/hw/nvram/eeprom_at24c.c @@ -0,0 +1,205 @@ +/* + * *AT24C* series I2C EEPROM + * + * Copyright (c) 2015 Michael Davidsaver + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the LICENSE file in the top-level directory. + */ + +#include + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/hw.h" +#include "hw/i2c/i2c.h" +#include "sysemu/block-backend.h" + +/* #define DEBUG_AT24C */ + +#ifdef DEBUG_AT24C +#define DPRINTK(FMT, ...) printf(TYPE_AT24C_EE " : " FMT, ## __VA_ARGS__) +#else +#define DPRINTK(FMT, ...) do {} while (0) +#endif + +#define ERR(FMT, ...) fprintf(stderr, TYPE_AT24C_EE " : " FMT, \ + ## __VA_ARGS__) + +#define TYPE_AT24C_EE "at24c-eeprom" +#define AT24C_EE(obj) OBJECT_CHECK(EEPROMState, (obj), TYPE_AT24C_EE) + +typedef struct EEPROMState { + I2CSlave parent_obj; + + /* address counter */ + uint16_t cur; + /* total size in bytes */ + uint32_t rsize; + bool writable; + /* cells changed since last START? */ + bool changed; + /* during WRITE, # of address bytes transfered */ + uint8_t haveaddr; + + uint8_t *mem; + + BlockBackend *blk; +} EEPROMState; + +static +int at24c_eeprom_event(I2CSlave *s, enum i2c_event event) +{ + EEPROMState *ee =3D container_of(s, EEPROMState, parent_obj); + + switch (event) { + case I2C_START_SEND: + case I2C_START_RECV: + case I2C_FINISH: + ee->haveaddr =3D 0; + DPRINTK("clear\n"); + if (ee->blk && ee->changed) { + int len =3D blk_pwrite(ee->blk, 0, ee->mem, ee->rsize, 0); + if (len !=3D ee->rsize) { + ERR(TYPE_AT24C_EE + " : failed to write backing file\n"); + } + DPRINTK("Wrote to backing file\n"); + } + ee->changed =3D false; + break; + case I2C_NACK: + break; + } + return 0; +} + +static +int at24c_eeprom_recv(I2CSlave *s) +{ + EEPROMState *ee =3D AT24C_EE(s); + int ret; + + ret =3D ee->mem[ee->cur]; + + ee->cur =3D (ee->cur + 1u) % ee->rsize; + DPRINTK("Recv %02x %c\n", ret, ret); + + return ret; +} + +static +int at24c_eeprom_send(I2CSlave *s, uint8_t data) +{ + EEPROMState *ee =3D AT24C_EE(s); + + if (ee->haveaddr < 2) { + ee->cur <<=3D 8; + ee->cur |=3D data; + ee->haveaddr++; + if (ee->haveaddr =3D=3D 2) { + ee->cur %=3D ee->rsize; + DPRINTK("Set pointer %04x\n", ee->cur); + } + + } else { + if (ee->writable) { + DPRINTK("Send %02x\n", data); + ee->mem[ee->cur] =3D data; + ee->changed =3D true; + } else { + DPRINTK("Send error %02x read-only\n", data); + } + ee->cur =3D (ee->cur + 1u) % ee->rsize; + + } + + return 0; +} + +static +int at24c_eeprom_init(I2CSlave *i2c) +{ + EEPROMState *ee =3D AT24C_EE(i2c); + + ee->mem =3D g_malloc0(ee->rsize); + + if (ee->blk) { + int64_t len =3D blk_getlength(ee->blk); + + if (len !=3D ee->rsize) { + ERR(TYPE_AT24C_EE " : Backing file size %lu !=3D %u\n", + (unsigned long)len, (unsigned)ee->rsize); + exit(1); + } + + if (blk_set_perm(ee->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRIT= E, + BLK_PERM_ALL, &error_fatal) < 0) + { + ERR(TYPE_AT24C_EE + " : Backing file incorrect permission\n"); + exit(1); + } + } + return 0; +} + +static +void at24c_eeprom_reset(DeviceState *state) +{ + EEPROMState *ee =3D AT24C_EE(state); + + ee->changed =3D false; + ee->cur =3D 0; + ee->haveaddr =3D 0; + + memset(ee->mem, 0, ee->rsize); + + if (ee->blk) { + int len =3D blk_pread(ee->blk, 0, ee->mem, ee->rsize); + + if (len !=3D ee->rsize) { + ERR(TYPE_AT24C_EE + " : Failed initial sync with backing file\n"); + } + DPRINTK("Reset read backing file\n"); + } +} + +static Property at24c_eeprom_props[] =3D { + DEFINE_PROP_UINT32("rom-size", EEPROMState, rsize, 0), + DEFINE_PROP_BOOL("writable", EEPROMState, writable, true), + DEFINE_PROP_DRIVE("drive", EEPROMState, blk), + DEFINE_PROP_END_OF_LIST() +}; + +static +void at24c_eeprom_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + I2CSlaveClass *k =3D I2C_SLAVE_CLASS(klass); + + k->init =3D &at24c_eeprom_init; + k->event =3D &at24c_eeprom_event; + k->recv =3D &at24c_eeprom_recv; + k->send =3D &at24c_eeprom_send; + + dc->props =3D at24c_eeprom_props; + dc->reset =3D at24c_eeprom_reset; +} + +static +const TypeInfo at24c_eeprom_type =3D { + .name =3D TYPE_AT24C_EE, + .parent =3D TYPE_I2C_SLAVE, + .instance_size =3D sizeof(EEPROMState), + .class_size =3D sizeof(I2CSlaveClass), + .class_init =3D at24c_eeprom_class_init, +}; + +static void at24c_eeprom_register(void) +{ + type_register_static(&at24c_eeprom_type); +} + +type_init(at24c_eeprom_register) --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513317739968861.9599463764208; Thu, 14 Dec 2017 22:02:19 -0800 (PST) Received: from localhost ([::1]:44616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePj4X-0001jw-3M for importer@patchew.org; Fri, 15 Dec 2017 01:02:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixN-0003fI-RD for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixL-0004fr-Id for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:49 -0500 Received: from ozlabs.org ([103.22.144.67]:58789) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixL-0004aq-5N; Fri, 15 Dec 2017 00:54:47 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflN4ggwz9t7B; Fri, 15 Dec 2017 16:54:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317280; bh=VWMY4bghnJEEni9O2XakGFMzRvAjKCMx7RxdgTjM5DU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=en9qXHjvfT8k7aWkzH4HwE2DQxFYghwq5sIqkTyEd0+u+PmMvdoGqCbMmUK9OBhJR swlpR7RValI/bwjaCELCdA7uBM+5OafOheyYuBW6mvygS972X5DNJA5hvqCErDzsgK O0EaHCwLf5dVq3/98ZbaR0nSZXgyAnrgLPI+RTW4= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:18 +1100 Message-Id: <20171215055435.24204-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 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: 103.22.144.67 Subject: [Qemu-devel] [PULL 07/24] pcc: define the Power-saving mode Exit Cause Enable bits in PowerPCCPUClass X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater and use the value to define precisely the default value of the LPCR in the helper routine cpu_ppc_set_papr() Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- target/ppc/cpu-qom.h | 1 + target/ppc/translate_init.c | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 429b47f959..deaa46a14b 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -191,6 +191,7 @@ typedef struct PowerPCCPUClass { uint64_t insns_flags; uint64_t insns_flags2; uint64_t msr_mask; + uint64_t lpcr_pm; /* Power-saving mode Exit Cause Enable bit= s */ powerpc_mmu_t mmu_model; powerpc_excp_t excp_model; powerpc_input_t bus_model; diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 4e11e6f489..074c3a1d45 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -8535,6 +8535,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data) pcc->l1_dcache_size =3D 0x8000; pcc->l1_icache_size =3D 0x8000; pcc->interrupts_big_endian =3D ppc_cpu_interrupts_big_endian_lpcr; + pcc->lpcr_pm =3D LPCR_P7_PECE0 | LPCR_P7_PECE1 | LPCR_P7_PECE2; } =20 static void init_proc_POWER8(CPUPPCState *env) @@ -8704,6 +8705,8 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) pcc->l1_dcache_size =3D 0x8000; pcc->l1_icache_size =3D 0x8000; pcc->interrupts_big_endian =3D ppc_cpu_interrupts_big_endian_lpcr; + pcc->lpcr_pm =3D LPCR_P8_PECE0 | LPCR_P8_PECE1 | LPCR_P8_PECE2 | + LPCR_P8_PECE3 | LPCR_P8_PECE4; } =20 #ifdef CONFIG_SOFTMMU @@ -8898,11 +8901,13 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data) pcc->l1_dcache_size =3D 0x8000; pcc->l1_icache_size =3D 0x8000; pcc->interrupts_big_endian =3D ppc_cpu_interrupts_big_endian_lpcr; + pcc->lpcr_pm =3D LPCR_PDEE | LPCR_HDEE | LPCR_EEE | LPCR_DEE | LPCR_OE= E; } =20 #if !defined(CONFIG_USER_ONLY) void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp) { + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); CPUPPCState *env =3D &cpu->env; ppc_spr_t *lpcr =3D &env->spr_cb[SPR_LPCR]; ppc_spr_t *amor =3D &env->spr_cb[SPR_AMOR]; @@ -8932,8 +8937,7 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHype= rvisor *vhyp) lpcr->default_value &=3D ~LPCR_RMLS; lpcr->default_value |=3D 1ull << LPCR_RMLS_SHIFT; =20 - switch (env->mmu_model) { - case POWERPC_MMU_3_00: + if (env->mmu_model =3D=3D POWERPC_MMU_3_00) { /* By default we choose legacy mode and switch to new hash or radix * when a register process table hcall is made. So disable process * tables and guest translation shootdown by default @@ -8947,18 +8951,13 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHy= pervisor *vhyp) } else { lpcr->default_value &=3D ~(LPCR_UPRT | LPCR_GTSE); } - lpcr->default_value |=3D LPCR_PDEE | LPCR_HDEE | LPCR_EEE | LPCR_D= EE | - LPCR_OEE; - break; - default: - /* P7 and P8 has slightly different PECE bits, mostly because P8 a= dds - * bit 47 and 48 which are reserved on P7. Here we set them all, w= hich - * will work as expected for both implementations - */ - lpcr->default_value |=3D LPCR_P8_PECE0 | LPCR_P8_PECE1 | LPCR_P8_P= ECE2 | - LPCR_P8_PECE3 | LPCR_P8_PECE4; } =20 + /* Also set the power-saving mode bits which depend on the CPU + * family + */ + lpcr->default_value |=3D pcc->lpcr_pm; + /* We should be followed by a CPU reset but update the active value * just in case... */ --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513317940216709.1870450135788; Thu, 14 Dec 2017 22:05:40 -0800 (PST) Received: from localhost ([::1]:44631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePj7W-0004Te-3V for importer@patchew.org; Fri, 15 Dec 2017 01:05:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixQ-0003i7-JC for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixM-0004gg-0b for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:52 -0500 Received: from ozlabs.org ([103.22.144.67]:57015) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixL-0004cT-CO; Fri, 15 Dec 2017 00:54:47 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflP26C7z9tBT; Fri, 15 Dec 2017 16:54:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317281; bh=okYSbI/PMCMyrln4jZmFXmIJpJtFDtRmsevZtqHyKbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QzBEN21cMqAD6TRiTHsCsQJC8fvVjGAqu7p0RSbE64bH2DMSP3iJfhEuVDIKyz6Z1 dlbgkVa4vIDmmq63DtGBw+rMtFejjbu2ZXthqCyWUfGex6gzZKJ4fUKWgWbw1Sd3/y MFoLx/M9qbiWpNgVF2QMlesVRegfpBsghGZ/y0nk= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:19 +1100 Message-Id: <20171215055435.24204-9-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 08/24] openpic: debug w/ info_report() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, Michael Davidsaver , mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Michael Davidsaver Replace *printf() with *_report(). Remove trailing new lines. Signed-off-by: Michael Davidsaver Signed-off-by: David Gibson --- hw/intc/openpic.c | 102 +++++++++++++++++++++++++++-----------------------= ---- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c index 10d6e871fb..9159a06f07 100644 --- a/hw/intc/openpic.c +++ b/hw/intc/openpic.c @@ -46,6 +46,7 @@ #include "qapi/qmp/qerror.h" #include "qemu/log.h" #include "qemu/timer.h" +#include "qemu/error-report.h" =20 //#define DEBUG_OPENPIC =20 @@ -58,8 +59,7 @@ static const int debug_openpic =3D 0; static int get_current_cpu(void); #define DPRINTF(fmt, ...) do { \ if (debug_openpic) { \ - printf("Core%d: ", get_current_cpu()); \ - printf(fmt , ## __VA_ARGS__); \ + info_report("Core%d: " fmt, get_current_cpu(), ## __VA_ARGS__)= ; \ } \ } while (0) =20 @@ -173,7 +173,7 @@ static int inttgt_to_output(int inttgt) } } =20 - fprintf(stderr, "%s: unsupported inttgt %d\n", __func__, inttgt); + error_report("%s: unsupported inttgt %d", __func__, inttgt); return OPENPIC_OUTPUT_INT; } =20 @@ -372,7 +372,7 @@ static void IRQ_check(OpenPICState *opp, IRQQueue *q) break; } =20 - DPRINTF("IRQ_check: irq %d set ivpr_pr=3D%d pr=3D%d\n", + DPRINTF("IRQ_check: irq %d set ivpr_pr=3D%d pr=3D%d", irq, IVPR_PRIORITY(opp->src[irq].ivpr), priority); =20 if (IVPR_PRIORITY(opp->src[irq].ivpr) > priority) { @@ -403,11 +403,11 @@ static void IRQ_local_pipe(OpenPICState *opp, int n_C= PU, int n_IRQ, dst =3D &opp->dst[n_CPU]; src =3D &opp->src[n_IRQ]; =20 - DPRINTF("%s: IRQ %d active %d was %d\n", + DPRINTF("%s: IRQ %d active %d was %d", __func__, n_IRQ, active, was_active); =20 if (src->output !=3D OPENPIC_OUTPUT_INT) { - DPRINTF("%s: output %d irq %d active %d was %d count %d\n", + DPRINTF("%s: output %d irq %d active %d was %d count %d", __func__, src->output, n_IRQ, active, was_active, dst->outputs_active[src->output]); =20 @@ -417,13 +417,13 @@ static void IRQ_local_pipe(OpenPICState *opp, int n_C= PU, int n_IRQ, */ if (active) { if (!was_active && dst->outputs_active[src->output]++ =3D=3D 0= ) { - DPRINTF("%s: Raise OpenPIC output %d cpu %d irq %d\n", + DPRINTF("%s: Raise OpenPIC output %d cpu %d irq %d", __func__, src->output, n_CPU, n_IRQ); qemu_irq_raise(dst->irqs[src->output]); } } else { if (was_active && --dst->outputs_active[src->output] =3D=3D 0)= { - DPRINTF("%s: Lower OpenPIC output %d cpu %d irq %d\n", + DPRINTF("%s: Lower OpenPIC output %d cpu %d irq %d", __func__, src->output, n_CPU, n_IRQ); qemu_irq_lower(dst->irqs[src->output]); } @@ -446,7 +446,7 @@ static void IRQ_local_pipe(OpenPICState *opp, int n_CPU= , int n_IRQ, IRQ_check(opp, &dst->raised); =20 if (active && priority <=3D dst->ctpr) { - DPRINTF("%s: IRQ %d priority %d too low for ctpr %d on CPU %d\n", + DPRINTF("%s: IRQ %d priority %d too low for ctpr %d on CPU %d", __func__, n_IRQ, priority, dst->ctpr, n_CPU); active =3D 0; } @@ -454,10 +454,10 @@ static void IRQ_local_pipe(OpenPICState *opp, int n_C= PU, int n_IRQ, if (active) { if (IRQ_get_next(opp, &dst->servicing) >=3D 0 && priority <=3D dst->servicing.priority) { - DPRINTF("%s: IRQ %d is hidden by servicing IRQ %d on CPU %d\n", + DPRINTF("%s: IRQ %d is hidden by servicing IRQ %d on CPU %d", __func__, n_IRQ, dst->servicing.next, n_CPU); } else { - DPRINTF("%s: Raise OpenPIC INT output cpu %d irq %d/%d\n", + DPRINTF("%s: Raise OpenPIC INT output cpu %d irq %d/%d", __func__, n_CPU, n_IRQ, dst->raised.next); qemu_irq_raise(opp->dst[n_CPU].irqs[OPENPIC_OUTPUT_INT]); } @@ -465,12 +465,12 @@ static void IRQ_local_pipe(OpenPICState *opp, int n_C= PU, int n_IRQ, IRQ_get_next(opp, &dst->servicing); if (dst->raised.priority > dst->ctpr && dst->raised.priority > dst->servicing.priority) { - DPRINTF("%s: IRQ %d inactive, IRQ %d prio %d above %d/%d, CPU = %d\n", + DPRINTF("%s: IRQ %d inactive, IRQ %d prio %d above %d/%d, CPU = %d", __func__, n_IRQ, dst->raised.next, dst->raised.priorit= y, dst->ctpr, dst->servicing.priority, n_CPU); /* IRQ line stays asserted */ } else { - DPRINTF("%s: IRQ %d inactive, current prio %d/%d, CPU %d\n", + DPRINTF("%s: IRQ %d inactive, current prio %d/%d, CPU %d", __func__, n_IRQ, dst->ctpr, dst->servicing.priority, n= _CPU); qemu_irq_lower(opp->dst[n_CPU].irqs[OPENPIC_OUTPUT_INT]); } @@ -489,7 +489,7 @@ static void openpic_update_irq(OpenPICState *opp, int n= _IRQ) =20 if ((src->ivpr & IVPR_MASK_MASK) && !src->nomask) { /* Interrupt source is disabled */ - DPRINTF("%s: IRQ %d is disabled\n", __func__, n_IRQ); + DPRINTF("%s: IRQ %d is disabled", __func__, n_IRQ); active =3D false; } =20 @@ -500,7 +500,7 @@ static void openpic_update_irq(OpenPICState *opp, int n= _IRQ) * ctpr may have changed and we need to withdraw the interrupt. */ if (!active && !was_active) { - DPRINTF("%s: IRQ %d is already inactive\n", __func__, n_IRQ); + DPRINTF("%s: IRQ %d is already inactive", __func__, n_IRQ); return; } =20 @@ -512,7 +512,7 @@ static void openpic_update_irq(OpenPICState *opp, int n= _IRQ) =20 if (src->destmask =3D=3D 0) { /* No target */ - DPRINTF("%s: IRQ %d has no target\n", __func__, n_IRQ); + DPRINTF("%s: IRQ %d has no target", __func__, n_IRQ); return; } =20 @@ -547,12 +547,12 @@ static void openpic_set_irq(void *opaque, int n_IRQ, = int level) IRQSource *src; =20 if (n_IRQ >=3D OPENPIC_MAX_IRQ) { - fprintf(stderr, "%s: IRQ %d out of range\n", __func__, n_IRQ); + error_report("%s: IRQ %d out of range", __func__, n_IRQ); abort(); } =20 src =3D &opp->src[n_IRQ]; - DPRINTF("openpic: set irq %d =3D %d ivpr=3D0x%08x\n", + DPRINTF("openpic: set irq %d =3D %d ivpr=3D0x%08x", n_IRQ, level, src->ivpr); if (src->level) { /* level-sensitive irq */ @@ -612,13 +612,13 @@ static inline void write_IRQreg_idr(OpenPICState *opp= , int n_IRQ, uint32_t val) } =20 src->idr =3D val & mask; - DPRINTF("Set IDR %d to 0x%08x\n", n_IRQ, src->idr); + DPRINTF("Set IDR %d to 0x%08x", n_IRQ, src->idr); =20 if (opp->flags & OPENPIC_FLAG_IDR_CRIT) { if (src->idr & crit_mask) { if (src->idr & normal_mask) { DPRINTF("%s: IRQ configured for multiple output types, usi= ng " - "critical\n", __func__); + "critical", __func__); } =20 src->output =3D OPENPIC_OUTPUT_CINT; @@ -648,7 +648,7 @@ static inline void write_IRQreg_ilr(OpenPICState *opp, = int n_IRQ, uint32_t val) IRQSource *src =3D &opp->src[n_IRQ]; =20 src->output =3D inttgt_to_output(val & ILR_INTTGT_MASK); - DPRINTF("Set ILR %d to 0x%08x, output %d\n", n_IRQ, src->idr, + DPRINTF("Set ILR %d to 0x%08x, output %d", n_IRQ, src->idr, src->output); =20 /* TODO: on MPIC v4.0 only, set nomask for non-INT */ @@ -688,7 +688,7 @@ static inline void write_IRQreg_ivpr(OpenPICState *opp,= int n_IRQ, uint32_t val) } =20 openpic_update_irq(opp, n_IRQ); - DPRINTF("Set IVPR %d to 0x%08x -> 0x%08x\n", n_IRQ, val, + DPRINTF("Set IVPR %d to 0x%08x -> 0x%08x", n_IRQ, val, opp->src[n_IRQ].ivpr); } =20 @@ -719,7 +719,7 @@ static void openpic_gbl_write(void *opaque, hwaddr addr= , uint64_t val, IRQDest *dst; int idx; =20 - DPRINTF("%s: addr %#" HWADDR_PRIx " <=3D %08" PRIx64 "\n", + DPRINTF("%s: addr %#" HWADDR_PRIx " <=3D %08" PRIx64, __func__, addr, val); if (addr & 0xF) { return; @@ -747,11 +747,11 @@ static void openpic_gbl_write(void *opaque, hwaddr ad= dr, uint64_t val, case 0x1090: /* PIR */ for (idx =3D 0; idx < opp->nb_cpus; idx++) { if ((val & (1 << idx)) && !(opp->pir & (1 << idx))) { - DPRINTF("Raise OpenPIC RESET output for CPU %d\n", idx); + DPRINTF("Raise OpenPIC RESET output for CPU %d", idx); dst =3D &opp->dst[idx]; qemu_irq_raise(dst->irqs[OPENPIC_OUTPUT_RESET]); } else if (!(val & (1 << idx)) && (opp->pir & (1 << idx))) { - DPRINTF("Lower OpenPIC RESET output for CPU %d\n", idx); + DPRINTF("Lower OpenPIC RESET output for CPU %d", idx); dst =3D &opp->dst[idx]; qemu_irq_lower(dst->irqs[OPENPIC_OUTPUT_RESET]); } @@ -781,7 +781,7 @@ static uint64_t openpic_gbl_read(void *opaque, hwaddr a= ddr, unsigned len) OpenPICState *opp =3D opaque; uint32_t retval; =20 - DPRINTF("%s: addr %#" HWADDR_PRIx "\n", __func__, addr); + DPRINTF("%s: addr %#" HWADDR_PRIx, __func__, addr); retval =3D 0xFFFFFFFF; if (addr & 0xF) { return retval; @@ -828,7 +828,7 @@ static uint64_t openpic_gbl_read(void *opaque, hwaddr a= ddr, unsigned len) default: break; } - DPRINTF("%s: =3D> 0x%08x\n", __func__, retval); + DPRINTF("%s: =3D> 0x%08x", __func__, retval); =20 return retval; } @@ -843,7 +843,7 @@ static void qemu_timer_cb(void *opaque) uint32_t val =3D tmr->tbcr & ~TBCR_CI; uint32_t tog =3D ((tmr->tccr & TCCR_TOG) ^ TCCR_TOG); /* invert toggl= e. */ =20 - DPRINTF("%s n_IRQ=3D%d\n", __func__, n_IRQ); + DPRINTF("%s n_IRQ=3D%d", __func__, n_IRQ); /* Reload current count from base count and setup timer. */ tmr->tccr =3D val | tog; openpic_tmr_set_tmr(tmr, val, /*enabled=3D*/true); @@ -898,7 +898,7 @@ static void openpic_tmr_write(void *opaque, hwaddr addr= , uint64_t val, OpenPICState *opp =3D opaque; int idx; =20 - DPRINTF("%s: addr %#" HWADDR_PRIx " <=3D %08" PRIx64 "\n", + DPRINTF("%s: addr %#" HWADDR_PRIx " <=3D %08" PRIx64, __func__, (addr + 0x10f0), val); if (addr & 0xF) { return; @@ -943,7 +943,7 @@ static uint64_t openpic_tmr_read(void *opaque, hwaddr a= ddr, unsigned len) uint32_t retval =3D -1; int idx; =20 - DPRINTF("%s: addr %#" HWADDR_PRIx "\n", __func__, addr + 0x10f0); + DPRINTF("%s: addr %#" HWADDR_PRIx, __func__, addr + 0x10f0); if (addr & 0xF) { goto out; } @@ -970,7 +970,7 @@ static uint64_t openpic_tmr_read(void *opaque, hwaddr a= ddr, unsigned len) } =20 out: - DPRINTF("%s: =3D> 0x%08x\n", __func__, retval); + DPRINTF("%s: =3D> 0x%08x", __func__, retval); =20 return retval; } @@ -981,7 +981,7 @@ static void openpic_src_write(void *opaque, hwaddr addr= , uint64_t val, OpenPICState *opp =3D opaque; int idx; =20 - DPRINTF("%s: addr %#" HWADDR_PRIx " <=3D %08" PRIx64 "\n", + DPRINTF("%s: addr %#" HWADDR_PRIx " <=3D %08" PRIx64, __func__, addr, val); =20 addr =3D addr & 0xffff; @@ -1006,7 +1006,7 @@ static uint64_t openpic_src_read(void *opaque, uint64= _t addr, unsigned len) uint32_t retval; int idx; =20 - DPRINTF("%s: addr %#" HWADDR_PRIx "\n", __func__, addr); + DPRINTF("%s: addr %#" HWADDR_PRIx, __func__, addr); retval =3D 0xFFFFFFFF; =20 addr =3D addr & 0xffff; @@ -1024,7 +1024,7 @@ static uint64_t openpic_src_read(void *opaque, uint64= _t addr, unsigned len) break; } =20 - DPRINTF("%s: =3D> 0x%08x\n", __func__, retval); + DPRINTF("%s: =3D> 0x%08x", __func__, retval); return retval; } =20 @@ -1035,7 +1035,7 @@ static void openpic_msi_write(void *opaque, hwaddr ad= dr, uint64_t val, int idx =3D opp->irq_msi; int srs, ibs; =20 - DPRINTF("%s: addr %#" HWADDR_PRIx " <=3D 0x%08" PRIx64 "\n", + DPRINTF("%s: addr %#" HWADDR_PRIx " <=3D 0x%08" PRIx64, __func__, addr, val); if (addr & 0xF) { return; @@ -1061,7 +1061,7 @@ static uint64_t openpic_msi_read(void *opaque, hwaddr= addr, unsigned size) uint64_t r =3D 0; int i, srs; =20 - DPRINTF("%s: addr %#" HWADDR_PRIx "\n", __func__, addr); + DPRINTF("%s: addr %#" HWADDR_PRIx, __func__, addr); if (addr & 0xF) { return -1; } @@ -1096,7 +1096,7 @@ static uint64_t openpic_summary_read(void *opaque, hw= addr addr, unsigned size) { uint64_t r =3D 0; =20 - DPRINTF("%s: addr %#" HWADDR_PRIx "\n", __func__, addr); + DPRINTF("%s: addr %#" HWADDR_PRIx, __func__, addr); =20 /* TODO: EISR/EIMR */ =20 @@ -1106,7 +1106,7 @@ static uint64_t openpic_summary_read(void *opaque, hw= addr addr, unsigned size) static void openpic_summary_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { - DPRINTF("%s: addr %#" HWADDR_PRIx " <=3D 0x%08" PRIx64 "\n", + DPRINTF("%s: addr %#" HWADDR_PRIx " <=3D 0x%08" PRIx64, __func__, addr, val); =20 /* TODO: EISR/EIMR */ @@ -1120,7 +1120,7 @@ static void openpic_cpu_write_internal(void *opaque, = hwaddr addr, IRQDest *dst; int s_IRQ, n_IRQ; =20 - DPRINTF("%s: cpu %d addr %#" HWADDR_PRIx " <=3D 0x%08x\n", __func__, i= dx, + DPRINTF("%s: cpu %d addr %#" HWADDR_PRIx " <=3D 0x%08x", __func__, idx, addr, val); =20 if (idx < 0 || idx >=3D opp->nb_cpus) { @@ -1146,16 +1146,16 @@ static void openpic_cpu_write_internal(void *opaque= , hwaddr addr, case 0x80: /* CTPR */ dst->ctpr =3D val & 0x0000000F; =20 - DPRINTF("%s: set CPU %d ctpr to %d, raised %d servicing %d\n", + DPRINTF("%s: set CPU %d ctpr to %d, raised %d servicing %d", __func__, idx, dst->ctpr, dst->raised.priority, dst->servicing.priority); =20 if (dst->raised.priority <=3D dst->ctpr) { - DPRINTF("%s: Lower OpenPIC INT output cpu %d due to ctpr\n", + DPRINTF("%s: Lower OpenPIC INT output cpu %d due to ctpr", __func__, idx); qemu_irq_lower(dst->irqs[OPENPIC_OUTPUT_INT]); } else if (dst->raised.priority > dst->servicing.priority) { - DPRINTF("%s: Raise OpenPIC INT output cpu %d irq %d\n", + DPRINTF("%s: Raise OpenPIC INT output cpu %d irq %d", __func__, idx, dst->raised.next); qemu_irq_raise(dst->irqs[OPENPIC_OUTPUT_INT]); } @@ -1168,11 +1168,11 @@ static void openpic_cpu_write_internal(void *opaque= , hwaddr addr, /* Read-only register */ break; case 0xB0: /* EOI */ - DPRINTF("EOI\n"); + DPRINTF("EOI"); s_IRQ =3D IRQ_get_next(opp, &dst->servicing); =20 if (s_IRQ < 0) { - DPRINTF("%s: EOI with no interrupt in service\n", __func__); + DPRINTF("%s: EOI with no interrupt in service", __func__); break; } =20 @@ -1185,7 +1185,7 @@ static void openpic_cpu_write_internal(void *opaque, = hwaddr addr, if (n_IRQ !=3D -1 && (s_IRQ =3D=3D -1 || IVPR_PRIORITY(src->ivpr) > dst->servicing.priority)) { - DPRINTF("Raise OpenPIC INT output cpu %d irq %d\n", + DPRINTF("Raise OpenPIC INT output cpu %d irq %d", idx, n_IRQ); qemu_irq_raise(opp->dst[idx].irqs[OPENPIC_OUTPUT_INT]); } @@ -1207,11 +1207,11 @@ static uint32_t openpic_iack(OpenPICState *opp, IRQ= Dest *dst, int cpu) IRQSource *src; int retval, irq; =20 - DPRINTF("Lower OpenPIC INT output\n"); + DPRINTF("Lower OpenPIC INT output"); qemu_irq_lower(dst->irqs[OPENPIC_OUTPUT_INT]); =20 irq =3D IRQ_get_next(opp, &dst->raised); - DPRINTF("IACK: irq=3D%d\n", irq); + DPRINTF("IACK: irq=3D%d", irq); =20 if (irq =3D=3D -1) { /* No more interrupt pending */ @@ -1221,7 +1221,7 @@ static uint32_t openpic_iack(OpenPICState *opp, IRQDe= st *dst, int cpu) src =3D &opp->src[irq]; if (!(src->ivpr & IVPR_ACTIVITY_MASK) || !(IVPR_PRIORITY(src->ivpr) > dst->ctpr)) { - fprintf(stderr, "%s: bad raised IRQ %d ctpr %d ivpr 0x%08x\n", + error_report("%s: bad raised IRQ %d ctpr %d ivpr 0x%08x", __func__, irq, dst->ctpr, src->ivpr); openpic_update_irq(opp, irq); retval =3D opp->spve; @@ -1241,7 +1241,7 @@ static uint32_t openpic_iack(OpenPICState *opp, IRQDe= st *dst, int cpu) /* Timers and IPIs support multicast. */ if (((irq >=3D opp->irq_ipi0) && (irq < (opp->irq_ipi0 + OPENPIC_MAX_I= PI))) || ((irq >=3D opp->irq_tim0) && (irq < (opp->irq_tim0 + OPENPIC_MAX_T= MR)))) { - DPRINTF("irq is IPI or TMR\n"); + DPRINTF("irq is IPI or TMR"); src->destmask &=3D ~(1 << cpu); if (src->destmask && !src->level) { /* trigger on CPUs that didn't know about it yet */ @@ -1262,7 +1262,7 @@ static uint32_t openpic_cpu_read_internal(void *opaqu= e, hwaddr addr, IRQDest *dst; uint32_t retval; =20 - DPRINTF("%s: cpu %d addr %#" HWADDR_PRIx "\n", __func__, idx, addr); + DPRINTF("%s: cpu %d addr %#" HWADDR_PRIx, __func__, idx, addr); retval =3D 0xFFFFFFFF; =20 if (idx < 0 || idx >=3D opp->nb_cpus) { @@ -1290,7 +1290,7 @@ static uint32_t openpic_cpu_read_internal(void *opaqu= e, hwaddr addr, default: break; } - DPRINTF("%s: =3D> 0x%08x\n", __func__, retval); + DPRINTF("%s: =3D> 0x%08x", __func__, retval); =20 return retval; } --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513318111579228.3958536834241; Thu, 14 Dec 2017 22:08:31 -0800 (PST) Received: from localhost ([::1]:44654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePjAQ-00078l-Qt for importer@patchew.org; Fri, 15 Dec 2017 01:08:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixM-0003dc-Pb for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixL-0004fV-Da for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:48 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:56459) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixK-0004aj-WD; Fri, 15 Dec 2017 00:54:47 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflN5Pwvz9t8R; Fri, 15 Dec 2017 16:54:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317280; bh=LD76bNOtdlptH01qDNarQL7TeCt0tL2Bg/ntTDS8JLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ja70EdPCEaF5wC6pFf2vvx+ABKyxP4Pg5qGAqXPDaOVxNTWYJUQp8NDDz1fSVZxCh JSGeRrjl7F80YkmZUHUxBX8X6PGUsGNr35ZCGvNiVl71QeuBWzzxgnkn2ImeIbOBIC FlXZzqMEJjDaQF4R1trhuvxMJeVKxFCG5RVNi4zI= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:20 +1100 Message-Id: <20171215055435.24204-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 09/24] e500: fix pci host bridge class/type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, Michael Davidsaver , mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Michael Davidsaver Correct some confusion wrt. the PCI facing side of the PCI host bridge (not PCIe root complex). The ref. manual for the mpc8533 (as well as mpc8540 and mpc8540) give the class code as PCI_CLASS_PROCESSOR_POWERPC. While the PCI_HEADER_TYPE field is oddly omitted, the tables in the "PCI Configuration Header" section shows a type 0 layout using all 6 BAR registers (as 2x 32, and 2x 64 bit regions) So 997505065dc92e533debf5cb23012ba4e673d387 seems to be in error. Although there was perhaps some confusion as the mpc8533 has a separate PCIe root complex. With PCIe, a root complex has PCI_HEADER_TYPE=3D1. Neither the PCI host bridge, nor the PCIe root complex advertise class PCI_CLASS_BRIDGE_PCI. This was confusing Linux guests, which try to interpret the host bridge as a pci-pci bridge, but get confused and re-enumerate the bus when the primary/secondary/subordinate bus registers don't have valid values. Signed-off-by: Michael Davidsaver Signed-off-by: David Gibson --- hw/pci-host/ppce500.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c index 39cd24464d..279badc894 100644 --- a/hw/pci-host/ppce500.c +++ b/hw/pci-host/ppce500.c @@ -423,11 +423,6 @@ static void e500_pcihost_bridge_realize(PCIDevice *d, = Error **errp) PPCE500CCSRState *ccsr =3D CCSR(container_get(qdev_get_machine(), "/e500-ccsr")); =20 - pci_config_set_class(d->config, PCI_CLASS_BRIDGE_PCI); - d->config[PCI_HEADER_TYPE] =3D - (d->config[PCI_HEADER_TYPE] & PCI_HEADER_TYPE_MULTI_FUNCTION) | - PCI_HEADER_TYPE_BRIDGE; - memory_region_init_alias(&b->bar0, OBJECT(ccsr), "e500-pci-bar0", &ccs= r->ccsr_space, 0, int128_get64(ccsr->ccsr_space.size)); pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &b->bar0); --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15133179206751.1149317815953736; Thu, 14 Dec 2017 22:05:20 -0800 (PST) Received: from localhost ([::1]:44630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePj7L-0004LC-1I for importer@patchew.org; Fri, 15 Dec 2017 01:05:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixM-0003dO-Hx for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixL-0004f5-3p for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:48 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:59103) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixK-0004bF-P1; Fri, 15 Dec 2017 00:54:47 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflN6TZCz9tBC; Fri, 15 Dec 2017 16:54:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317280; bh=ltY9xQA+/JqHX1Uu0eVNvp2FJ3D4FSr6dpSARvVOIdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jrJbEcP+E9mdn/9V/ajNi8iGnZHI0Uc5Pzl20TkTgHThcdy9Djea3uwJzoekocXSD sAPe+Os4oiQY1CB5nP/s3hp0TxwEmo8EfDr0ZNXkaZeCwgiJIRqsgRVF9AtqJrO1mD OwF7HyD7x7WOHGafZMn3847O+JeSlKRnOHPv9ZJ4= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:21 +1100 Message-Id: <20171215055435.24204-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 10/24] spapr/rtas: disable the decrementer interrupt when a CPU is unplugged X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater When a CPU is stopped with the 'stop-self' RTAS call, its state 'halted' is switched to 1 and, in this case, the MSR is not taken into account anymore in the cpu_has_work() routine. Only the pending hardware interrupts are checked with their LPCR:PECE* enablement bit. If the DECR timer fires after 'stop-self' is called and before the CPU 'stop' state is reached, the nearly-dead CPU will have some work to do and the guest will crash. This case happens very frequently with the not yet upstream P9 XIVE exploitation mode. In XICS mode, the DECR is occasionally fired but after 'stop' state, so no work is to be done and the guest survives. I suspect there is a race between the QEMU mainloop triggering the timers and the TCG CPU thread but I could not quite identify the root cause. To be safe, let's disable in the LPCR all the exceptions which can cause an exit while the CPU is in power-saving mode and reenable them when the CPU is started. Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/ppc/spapr_rtas.c | 11 +++++++++++ target/ppc/translate_init.c | 9 ++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index cdf0b607a0..858adb1bf3 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -162,6 +162,7 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachi= neState *spapr, if (cpu !=3D NULL) { CPUState *cs =3D CPU(cpu); CPUPPCState *env =3D &cpu->env; + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); =20 if (!cs->halted) { rtas_st(rets, 0, RTAS_OUT_HW_ERROR); @@ -174,6 +175,10 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMach= ineState *spapr, kvm_cpu_synchronize_state(cs); =20 env->msr =3D (1ULL << MSR_SF) | (1ULL << MSR_ME); + + /* Enable Power-saving mode Exit Cause exceptions for the new CPU = */ + env->spr[SPR_LPCR] |=3D pcc->lpcr_pm; + env->nip =3D start; env->gpr[3] =3D r3; cs->halted =3D 0; @@ -197,6 +202,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachin= eState *spapr, { CPUState *cs =3D CPU(cpu); CPUPPCState *env =3D &cpu->env; + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); =20 cs->halted =3D 1; qemu_cpu_kick(cs); @@ -210,6 +216,11 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachi= neState *spapr, * no need to bother with specific bits, we just clear it. */ env->msr =3D 0; + + /* Disable Power-saving mode Exit Cause exceptions for the CPU. + * This could deliver an interrupt on a dying CPU and crash the + * guest */ + env->spr[SPR_LPCR] &=3D ~pcc->lpcr_pm; } =20 static inline int sysparm_st(target_ulong addr, target_ulong len, diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 074c3a1d45..70ff15a51a 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -8911,6 +8911,7 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHype= rvisor *vhyp) CPUPPCState *env =3D &cpu->env; ppc_spr_t *lpcr =3D &env->spr_cb[SPR_LPCR]; ppc_spr_t *amor =3D &env->spr_cb[SPR_AMOR]; + CPUState *cs =3D CPU(cpu); =20 cpu->vhyp =3D vhyp; =20 @@ -8953,10 +8954,12 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHy= pervisor *vhyp) } } =20 - /* Also set the power-saving mode bits which depend on the CPU - * family + /* Only enable Power-saving mode Exit Cause exceptions on the boot + * CPU. The RTAS command start-cpu will enable them on secondaries. */ - lpcr->default_value |=3D pcc->lpcr_pm; + if (cs =3D=3D first_cpu) { + lpcr->default_value |=3D pcc->lpcr_pm; + } =20 /* We should be followed by a CPU reset but update the active value * just in case... --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513317769175121.42467296362634; Thu, 14 Dec 2017 22:02:49 -0800 (PST) Received: from localhost ([::1]:44619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePj55-0002EQ-IS for importer@patchew.org; Fri, 15 Dec 2017 01:02:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixM-0003d8-B8 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixL-0004fL-A4 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:48 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:35765) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixK-0004bK-TW; Fri, 15 Dec 2017 00:54:47 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflP0XNBz9tBP; Fri, 15 Dec 2017 16:54:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317281; bh=aFrGemCxWviQZcvN1L1g2Ro1TicBsYYaDMynwH5efMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T62vai+aeWWMO+cygMjrD1n99SKwN3Lh1JCi7nRZtwo45yMPIf57ScYpp9sDfpEJn I9gxcaAecF81k/sj1BnBRQKsuwz+aUdFwqWh1TeEVwy9rB7LsTFLf0wAiWZfZ5CuV3 BP+SVW4x6jzAjXCJEYgAmJnGXHBmGhBONE2yo11A= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:22 +1100 Message-Id: <20171215055435.24204-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 11/24] spapr/rtas: fix reboot of a a SMP TCG guest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater Just like for hot unplug CPUs, when a guest is rebooted, the secondary CPUs can be awaken by the decrementer and start entering SLOF at the same time the boot CPU is. To be safe, let's disable on the secondaries all the exceptions which can cause an exit while the CPU is in power-saving mode. Based on previous work from Nikunj A Dadhania Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: David Gibson Signed-off-by: David Gibson --- hw/ppc/spapr_cpu_core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 588f9b4571..1ea0e295dd 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -26,6 +26,7 @@ static void spapr_cpu_reset(void *opaque) PowerPCCPU *cpu =3D opaque; CPUState *cs =3D CPU(cpu); CPUPPCState *env =3D &cpu->env; + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); =20 cpu_reset(cs); =20 @@ -35,6 +36,13 @@ static void spapr_cpu_reset(void *opaque) cs->halted =3D 1; =20 env->spr[SPR_HIOR] =3D 0; + + /* Disable Power-saving mode Exit Cause exceptions for the CPU. + * This can cause issues when rebooting the guest if a secondary + * is awaken */ + if (cs !=3D first_cpu) { + env->spr[SPR_LPCR] &=3D ~pcc->lpcr_pm; + } } =20 static void spapr_cpu_destroy(PowerPCCPU *cpu) --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513317407504479.73188075087273; Thu, 14 Dec 2017 21:56:47 -0800 (PST) Received: from localhost ([::1]:44583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePizF-0005BX-R0 for importer@patchew.org; Fri, 15 Dec 2017 00:56:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixQ-0003i2-8E for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixO-0004k3-9W for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:52 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:32813) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixN-0004gE-QL; Fri, 15 Dec 2017 00:54:50 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflQ6sq6z9tBx; Fri, 15 Dec 2017 16:54:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317282; bh=PS5tOMUmSdenobIiUpP5X4ecJ4NboZP5X9BpZNrOxEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Htfs9tyftEcZH9bpP4AeLnKqpZRrbpIMkLOQXERejwN96Y4DykVM7HRxAJ3tCSHAD ovVdrUxIWtdkVYbH0SWHRmr99agGkzsIoekcoKNEL+ekiBzqXgh/UjGazVVmNt/plb fsTCw3TaR6u3UVpCahvHGSMn/ArvCquDxNkJzep4= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:23 +1100 Message-Id: <20171215055435.24204-13-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 12/24] spapr/rtas: do not reset the MSR in stop-self command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater When a CPU is stopped with the 'stop-self' RTAS call, its state 'halted' is switched to 1 and, in this case, the MSR is not taken into account anymore in the cpu_has_work() routine. Only the pending hardware interrupts are checked with their LPCR:PECE* enablement bit. The CPU is now also protected from the decrementer interrupt by the LPCR:PECE* bits which are disabled in the 'stop-self' RTAS call. Reseting the MSR is pointless. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: David Gibson Signed-off-by: David Gibson --- hw/ppc/spapr_rtas.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 858adb1bf3..4bb939d3d1 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -206,16 +206,6 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachi= neState *spapr, =20 cs->halted =3D 1; qemu_cpu_kick(cs); - /* - * While stopping a CPU, the guest calls H_CPPR which - * effectively disables interrupts on XICS level. - * However decrementer interrupts in TCG can still - * wake the CPU up so here we disable interrupts in MSR - * as well. - * As rtas_start_cpu() resets the whole MSR anyway, there is - * no need to bother with specific bits, we just clear it. - */ - env->msr =3D 0; =20 /* Disable Power-saving mode Exit Cause exceptions for the CPU. * This could deliver an interrupt on a dying CPU and crash the --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151331757525431.10129388106475; Thu, 14 Dec 2017 21:59:35 -0800 (PST) Received: from localhost ([::1]:44597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePj1x-0007wR-4G for importer@patchew.org; Fri, 15 Dec 2017 00:59:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixO-0003fb-1x for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixM-0004hQ-Ce for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:50 -0500 Received: from ozlabs.org ([103.22.144.67]:35509) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixL-0004cs-Ur; Fri, 15 Dec 2017 00:54:48 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflP6wZLz9tCG; Fri, 15 Dec 2017 16:54:41 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317281; bh=9odXnAETlgZ6JwAmIIAVhDGDRNL2/CouoqIkIOe21hU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p0pbiRU5m+T/L3zE4H+NjrvVm58Pf+gm3k1nZIj7k3CUGtNDV5IfNBTWOVRB6leAb o0HSCDlts0fihcNk52MZazgLUBxONrC6rCES5sE5sryfG1jci50jAohzEH8dp6Zmto kum96bUSPjLkDm3rOsHeX9TR0Dt4WsQUmHZPruC8= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:24 +1100 Message-Id: <20171215055435.24204-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 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: 103.22.144.67 Subject: [Qemu-devel] [PULL 13/24] ppc/xics: introduce an icp_create() helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater The sPAPR and the PowerNV core objects create the interrupt presenter object of the CPUs in a very similar way. Let's provide a common routine in which we use the presenter 'type' as a child identifier. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: David Gibson Reviewed-by: Greg Kurz Signed-off-by: David Gibson --- hw/intc/xics.c | 21 +++++++++++++++++++++ hw/ppc/pnv_core.c | 10 +--------- hw/ppc/spapr_cpu_core.c | 13 ++----------- include/hw/ppc/xics.h | 3 +++ 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index a1cc0e420c..bfc6b5bb23 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -384,6 +384,27 @@ static const TypeInfo icp_info =3D { .class_size =3D sizeof(ICPStateClass), }; =20 +Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **= errp) +{ + Error *local_err =3D NULL; + Object *obj; + + obj =3D object_new(type); + object_property_add_child(cpu, type, obj, &error_abort); + object_unref(obj); + object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(xi), + &error_abort); + object_property_add_const_link(obj, ICP_PROP_CPU, cpu, &error_abort); + object_property_set_bool(obj, true, "realized", &local_err); + if (local_err) { + object_unparent(obj); + error_propagate(errp, local_err); + obj =3D NULL; + } + + return obj; +} + /* * ICS: Source layer */ diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 82ff440b33..8d966e0802 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -126,7 +126,6 @@ static void pnv_core_realize_child(Object *child, XICSF= abric *xi, Error **errp) Error *local_err =3D NULL; CPUState *cs =3D CPU(child); PowerPCCPU *cpu =3D POWERPC_CPU(cs); - Object *obj; =20 object_property_set_bool(child, true, "realized", &local_err); if (local_err) { @@ -134,13 +133,7 @@ static void pnv_core_realize_child(Object *child, XICS= Fabric *xi, Error **errp) return; } =20 - obj =3D object_new(TYPE_PNV_ICP); - object_property_add_child(child, "icp", obj, NULL); - object_unref(obj); - object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(xi), - &error_abort); - object_property_add_const_link(obj, ICP_PROP_CPU, child, &error_abort); - object_property_set_bool(obj, true, "realized", &local_err); + icp_create(child, TYPE_PNV_ICP, xi, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -148,7 +141,6 @@ static void pnv_core_realize_child(Object *child, XICSF= abric *xi, Error **errp) =20 powernv_cpu_init(cpu, &local_err); if (local_err) { - object_unparent(obj); error_propagate(errp, local_err); return; } diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 1ea0e295dd..70e757f808 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -110,7 +110,6 @@ static void spapr_cpu_core_realize_child(Object *child, Error *local_err =3D NULL; CPUState *cs =3D CPU(child); PowerPCCPU *cpu =3D POWERPC_CPU(cs); - Object *obj; =20 object_property_set_bool(child, true, "realized", &local_err); if (local_err) { @@ -122,21 +121,13 @@ static void spapr_cpu_core_realize_child(Object *chil= d, goto error; } =20 - obj =3D object_new(spapr->icp_type); - object_property_add_child(child, "icp", obj, &error_abort); - object_unref(obj); - object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(spapr), - &error_abort); - object_property_add_const_link(obj, ICP_PROP_CPU, child, &error_abort); - object_property_set_bool(obj, true, "realized", &local_err); + icp_create(child, spapr->icp_type, XICS_FABRIC(spapr), &local_err); if (local_err) { - goto free_icp; + goto error; } =20 return; =20 -free_icp: - object_unparent(obj); error: error_propagate(errp, local_err); } diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 2df99be111..2ba8b12208 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -212,4 +212,7 @@ typedef struct sPAPRMachineState sPAPRMachineState; int xics_kvm_init(sPAPRMachineState *spapr, Error **errp); void xics_spapr_init(sPAPRMachineState *spapr); =20 +Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, + Error **errp); + #endif /* XICS_H */ --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513318245031817.1685206354608; Thu, 14 Dec 2017 22:10:45 -0800 (PST) Received: from localhost ([::1]:44671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePjCk-0000sc-1S for importer@patchew.org; Fri, 15 Dec 2017 01:10:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixP-0003hz-GW for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixN-0004jL-SF for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:51 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:51903) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixN-0004ft-Fc; Fri, 15 Dec 2017 00:54:49 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflQ58LMz9tCM; Fri, 15 Dec 2017 16:54:41 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317282; bh=dKsnQFqUBevJF+qIpzZGFKlmPeS+vcFWiOCBc1XCioQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EZxtAkyeDp2Lhc7e3cqcZqGJdEMO45clieMKrPSYTssgij/7YwAKTSb2C0AcnTQjY ZFy55AZEJqkN2JAro/GR9ATzg1nnKyEq4cjnwzeiVpIBqaRMRRCzqi4VxLWdyDA+Yc Z/aa0wbgfl6M4SKIWyI6I+a+Jm4tqMFrBEoO4eb4= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:25 +1100 Message-Id: <20171215055435.24204-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 14/24] ppc/xics: assign of the CPU 'intc' pointer under the core X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater The 'intc' pointer of the CPU references the interrupt presenter in the XICS interrupt mode. When the XIVE interrupt mode is available and activated, the machine will need to reassign this pointer to reflect the change. Moving this assignment under the realize routine of the CPU will ease the process when the interrupt mode is toggled. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: David Gibson Reviewed-by: Greg Kurz Signed-off-by: David Gibson --- hw/intc/xics.c | 1 - hw/ppc/pnv_core.c | 2 +- hw/ppc/spapr_cpu_core.c | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index bfc6b5bb23..700f6baa13 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -334,7 +334,6 @@ static void icp_realize(DeviceState *dev, Error **errp) } =20 cpu =3D POWERPC_CPU(obj); - cpu->intc =3D OBJECT(icp); icp->cs =3D CPU(obj); =20 env =3D &cpu->env; diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 8d966e0802..03317db853 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -133,7 +133,7 @@ static void pnv_core_realize_child(Object *child, XICSF= abric *xi, Error **errp) return; } =20 - icp_create(child, TYPE_PNV_ICP, xi, &local_err); + cpu->intc =3D icp_create(child, TYPE_PNV_ICP, xi, &local_err); if (local_err) { error_propagate(errp, local_err); return; diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 70e757f808..032438b9ce 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -121,7 +121,8 @@ static void spapr_cpu_core_realize_child(Object *child, goto error; } =20 - icp_create(child, spapr->icp_type, XICS_FABRIC(spapr), &local_err); + cpu->intc =3D icp_create(child, spapr->icp_type, XICS_FABRIC(spapr), + &local_err); if (local_err) { goto error; } --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513317749118186.51596101960024; Thu, 14 Dec 2017 22:02:29 -0800 (PST) Received: from localhost ([::1]:44618 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePj4l-0001xF-6j for importer@patchew.org; Fri, 15 Dec 2017 01:02:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixQ-0003i6-FM for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixM-0004he-Gs for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:52 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:36057) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixL-0004cp-Oi; Fri, 15 Dec 2017 00:54:48 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflP4B34z9t9s; Fri, 15 Dec 2017 16:54:41 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317281; bh=vazLff6+Xc685yXTLgbvyz2YTzit286fgfwPbsE4auQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NcvJi6pKG+clpQNAHnhZKXtXD9aGXviSlw/bDp5+tVPXKRWNsgdc4VJk0uqwQcg2i r7wclKMSLO1ClPH+LvMtmggHTyOonj6oD4uX1tLFote9o9lcDQe06y5Zyfy7y9i5uy LQGtVmYYMyWUZZKNSyy61CaHtrMBocLwmogbxGz0= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:26 +1100 Message-Id: <20171215055435.24204-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 15/24] spapr: move the IRQ allocation routines under the machine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater Also change the prototype to use a sPAPRMachineState and prefix them with spapr_irq_. It will let us synchronise the IRQ allocation with the XIVE interrupt mode when available. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: David Gibson Reviewed-by: Greg Kurz Signed-off-by: David Gibson --- hw/intc/trace-events | 4 -- hw/intc/xics_spapr.c | 114 ---------------------------------------------= ---- hw/ppc/spapr.c | 114 +++++++++++++++++++++++++++++++++++++++++++++= ++++ hw/ppc/spapr_events.c | 4 +- hw/ppc/spapr_pci.c | 8 ++-- hw/ppc/spapr_vio.c | 2 +- hw/ppc/trace-events | 4 ++ include/hw/ppc/spapr.h | 6 +++ include/hw/ppc/xics.h | 4 -- 9 files changed, 131 insertions(+), 129 deletions(-) diff --git a/hw/intc/trace-events b/hw/intc/trace-events index b298fac7c6..7077aaaee6 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -64,10 +64,6 @@ xics_ics_simple_set_irq_lsi(int srcno, int nr) "set_irq_= lsi: srcno %d [irq 0x%x] xics_ics_simple_write_xive(int nr, int srcno, int server, uint8_t priority= ) "ics_write_xive: irq 0x%x [src %d] server 0x%x prio 0x%x" xics_ics_simple_reject(int nr, int srcno) "reject irq 0x%x [src %d]" xics_ics_simple_eoi(int nr) "ics_eoi: irq 0x%x" -xics_alloc(int irq) "irq %d" -xics_alloc_block(int first, int num, bool lsi, int align) "first irq %d, %= d irqs, lsi=3D%d, alignnum %d" -xics_ics_free(int src, int irq, int num) "Source#%d, first irq %d, %d irqs" -xics_ics_free_warn(int src, int irq) "Source#%d, irq %d is already free" =20 # hw/intc/s390_flic_kvm.c flic_create_device(int err) "flic: create device failed %d" diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index e8c0a1b3e9..5a0967caf4 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -245,120 +245,6 @@ void xics_spapr_init(sPAPRMachineState *spapr) spapr_register_hypercall(H_IPOLL, h_ipoll); } =20 -#define ICS_IRQ_FREE(ics, srcno) \ - (!((ics)->irqs[(srcno)].flags & (XICS_FLAGS_IRQ_MASK))) - -static int ics_find_free_block(ICSState *ics, int num, int alignnum) -{ - int first, i; - - for (first =3D 0; first < ics->nr_irqs; first +=3D alignnum) { - if (num > (ics->nr_irqs - first)) { - return -1; - } - for (i =3D first; i < first + num; ++i) { - if (!ICS_IRQ_FREE(ics, i)) { - break; - } - } - if (i =3D=3D (first + num)) { - return first; - } - } - - return -1; -} - -int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp) -{ - int irq; - - if (!ics) { - return -1; - } - if (irq_hint) { - if (!ICS_IRQ_FREE(ics, irq_hint - ics->offset)) { - error_setg(errp, "can't allocate IRQ %d: already in use", irq_= hint); - return -1; - } - irq =3D irq_hint; - } else { - irq =3D ics_find_free_block(ics, 1, 1); - if (irq < 0) { - error_setg(errp, "can't allocate IRQ: no IRQ left"); - return -1; - } - irq +=3D ics->offset; - } - - ics_set_irq_type(ics, irq - ics->offset, lsi); - trace_xics_alloc(irq); - - return irq; -} - -/* - * Allocate block of consecutive IRQs, and return the number of the first = IRQ in - * the block. If align=3D=3Dtrue, aligns the first IRQ number to num. - */ -int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, - bool align, Error **errp) -{ - int i, first =3D -1; - - if (!ics) { - return -1; - } - - /* - * MSIMesage::data is used for storing VIRQ so - * it has to be aligned to num to support multiple - * MSI vectors. MSI-X is not affected by this. - * The hint is used for the first IRQ, the rest should - * be allocated continuously. - */ - if (align) { - assert((num =3D=3D 1) || (num =3D=3D 2) || (num =3D=3D 4) || - (num =3D=3D 8) || (num =3D=3D 16) || (num =3D=3D 32)); - first =3D ics_find_free_block(ics, num, num); - } else { - first =3D ics_find_free_block(ics, num, 1); - } - if (first < 0) { - error_setg(errp, "can't find a free %d-IRQ block", num); - return -1; - } - - for (i =3D first; i < first + num; ++i) { - ics_set_irq_type(ics, i, lsi); - } - first +=3D ics->offset; - - trace_xics_alloc_block(first, num, lsi, align); - - return first; -} - -static void ics_free(ICSState *ics, int srcno, int num) -{ - int i; - - for (i =3D srcno; i < srcno + num; ++i) { - if (ICS_IRQ_FREE(ics, i)) { - trace_xics_ics_free_warn(0, i + ics->offset); - } - memset(&ics->irqs[i], 0, sizeof(ICSIRQState)); - } -} - -void spapr_ics_free(ICSState *ics, int irq, int num) -{ - if (ics_valid_irq(ics, irq)) { - trace_xics_ics_free(0, irq, num); - ics_free(ics, irq - ics->offset, num); - } -} - void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle) { uint32_t interrupt_server_ranges_prop[] =3D { diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f1b96a4e92..53c2c58a25 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3558,6 +3558,120 @@ static ICPState *spapr_icp_get(XICSFabric *xi, int = vcpu_id) return cpu ? ICP(cpu->intc) : NULL; } =20 +#define ICS_IRQ_FREE(ics, srcno) \ + (!((ics)->irqs[(srcno)].flags & (XICS_FLAGS_IRQ_MASK))) + +static int ics_find_free_block(ICSState *ics, int num, int alignnum) +{ + int first, i; + + for (first =3D 0; first < ics->nr_irqs; first +=3D alignnum) { + if (num > (ics->nr_irqs - first)) { + return -1; + } + for (i =3D first; i < first + num; ++i) { + if (!ICS_IRQ_FREE(ics, i)) { + break; + } + } + if (i =3D=3D (first + num)) { + return first; + } + } + + return -1; +} + +int spapr_irq_alloc(sPAPRMachineState *spapr, int irq_hint, bool lsi, + Error **errp) +{ + ICSState *ics =3D spapr->ics; + int irq; + + if (!ics) { + return -1; + } + if (irq_hint) { + if (!ICS_IRQ_FREE(ics, irq_hint - ics->offset)) { + error_setg(errp, "can't allocate IRQ %d: already in use", irq_= hint); + return -1; + } + irq =3D irq_hint; + } else { + irq =3D ics_find_free_block(ics, 1, 1); + if (irq < 0) { + error_setg(errp, "can't allocate IRQ: no IRQ left"); + return -1; + } + irq +=3D ics->offset; + } + + ics_set_irq_type(ics, irq - ics->offset, lsi); + trace_spapr_irq_alloc(irq); + + return irq; +} + +/* + * Allocate block of consecutive IRQs, and return the number of the first = IRQ in + * the block. If align=3D=3Dtrue, aligns the first IRQ number to num. + */ +int spapr_irq_alloc_block(sPAPRMachineState *spapr, int num, bool lsi, + bool align, Error **errp) +{ + ICSState *ics =3D spapr->ics; + int i, first =3D -1; + + if (!ics) { + return -1; + } + + /* + * MSIMesage::data is used for storing VIRQ so + * it has to be aligned to num to support multiple + * MSI vectors. MSI-X is not affected by this. + * The hint is used for the first IRQ, the rest should + * be allocated continuously. + */ + if (align) { + assert((num =3D=3D 1) || (num =3D=3D 2) || (num =3D=3D 4) || + (num =3D=3D 8) || (num =3D=3D 16) || (num =3D=3D 32)); + first =3D ics_find_free_block(ics, num, num); + } else { + first =3D ics_find_free_block(ics, num, 1); + } + if (first < 0) { + error_setg(errp, "can't find a free %d-IRQ block", num); + return -1; + } + + for (i =3D first; i < first + num; ++i) { + ics_set_irq_type(ics, i, lsi); + } + first +=3D ics->offset; + + trace_spapr_irq_alloc_block(first, num, lsi, align); + + return first; +} + +void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num) +{ + ICSState *ics =3D spapr->ics; + int srcno =3D irq - ics->offset; + int i; + + if (ics_valid_irq(ics, irq)) { + trace_spapr_irq_free(0, irq, num); + for (i =3D srcno; i < srcno + num; ++i) { + if (ICS_IRQ_FREE(ics, i)) { + trace_spapr_irq_free_warn(0, i + ics->offset); + } + memset(&ics->irqs[i], 0, sizeof(ICSIRQState)); + } + } +} + static void spapr_pic_print_info(InterruptStatsProvider *obj, Monitor *mon) { diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index e377fc7dde..cead596f3e 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -718,7 +718,7 @@ void spapr_events_init(sPAPRMachineState *spapr) spapr->event_sources =3D spapr_event_sources_new(); =20 spapr_event_sources_register(spapr->event_sources, EVENT_CLASS_EPOW, - spapr_ics_alloc(spapr->ics, 0, false, + spapr_irq_alloc(spapr, 0, false, &error_fatal)); =20 /* NOTE: if machine supports modern/dedicated hotplug event source, @@ -731,7 +731,7 @@ void spapr_events_init(sPAPRMachineState *spapr) */ if (spapr->use_hotplug_event_source) { spapr_event_sources_register(spapr->event_sources, EVENT_CLASS_HOT= _PLUG, - spapr_ics_alloc(spapr->ics, 0, false, + spapr_irq_alloc(spapr, 0, false, &error_fatal)); } =20 diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 5a3122a9f9..e0ef77a480 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -314,7 +314,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRM= achineState *spapr, return; } =20 - spapr_ics_free(spapr->ics, msi->first_irq, msi->num); + spapr_irq_free(spapr, msi->first_irq, msi->num); if (msi_present(pdev)) { spapr_msi_setmsg(pdev, 0, false, 0, 0); } @@ -352,7 +352,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRM= achineState *spapr, } =20 /* Allocate MSIs */ - irq =3D spapr_ics_alloc_block(spapr->ics, req_num, false, + irq =3D spapr_irq_alloc_block(spapr, req_num, false, ret_intr_type =3D=3D RTAS_TYPE_MSI, &err); if (err) { error_reportf_err(err, "Can't allocate MSIs for device %x: ", @@ -363,7 +363,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRM= achineState *spapr, =20 /* Release previous MSIs */ if (msi) { - spapr_ics_free(spapr->ics, msi->first_irq, msi->num); + spapr_irq_free(spapr, msi->first_irq, msi->num); g_hash_table_remove(phb->msi, &config_addr); } =20 @@ -1675,7 +1675,7 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) uint32_t irq; Error *local_err =3D NULL; =20 - irq =3D spapr_ics_alloc_block(spapr->ics, 1, true, false, &local_e= rr); + irq =3D spapr_irq_alloc_block(spapr, 1, true, false, &local_err); if (local_err) { error_propagate(errp, local_err); error_prepend(errp, "can't allocate LSIs: "); diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index ea3bc8bd9e..bb7ed2c537 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -454,7 +454,7 @@ static void spapr_vio_busdev_realize(DeviceState *qdev,= Error **errp) dev->qdev.id =3D id; } =20 - dev->irq =3D spapr_ics_alloc(spapr->ics, dev->irq, false, &local_err); + dev->irq =3D spapr_irq_alloc(spapr, dev->irq, false, &local_err); if (local_err) { error_propagate(errp, local_err); return; diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events index 4a6a6490fa..b7c3e64b5e 100644 --- a/hw/ppc/trace-events +++ b/hw/ppc/trace-events @@ -12,6 +12,10 @@ spapr_pci_msi_retry(unsigned config_addr, unsigned req_n= um, unsigned max_irqs) " # hw/ppc/spapr.c spapr_cas_failed(unsigned long n) "DT diff buffer is too small: %ld bytes" spapr_cas_continue(unsigned long n) "Copy changes to the guest: %ld bytes" +spapr_irq_alloc(int irq) "irq %d" +spapr_irq_alloc_block(int first, int num, bool lsi, int align) "first irq = %d, %d irqs, lsi=3D%d, alignnum %d" +spapr_irq_free(int src, int irq, int num) "Source#%d, first irq %d, %d irq= s" +spapr_irq_free_warn(int src, int irq) "Source#%d, irq %d is already free" =20 # hw/ppc/spapr_hcall.c spapr_cas_pvr_try(uint32_t pvr) "0x%x" diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 9d21ca9bde..895f48471e 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -707,4 +707,10 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on= _cpu_data arg); int spapr_vcpu_id(PowerPCCPU *cpu); PowerPCCPU *spapr_find_cpu(int vcpu_id); =20 +int spapr_irq_alloc(sPAPRMachineState *spapr, int irq_hint, bool lsi, + Error **errp); +int spapr_irq_alloc_block(sPAPRMachineState *spapr, int num, bool lsi, + bool align, Error **errp); +void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num); + #endif /* HW_SPAPR_H */ diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 2ba8b12208..0b67abbbb9 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -181,10 +181,6 @@ typedef struct XICSFabricClass { =20 #define XICS_IRQS_SPAPR 1024 =20 -int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp); -int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, bool align, - Error **errp); -void spapr_ics_free(ICSState *ics, int irq, int num); void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle); =20 qemu_irq xics_get_qirq(XICSFabric *xi, int irq); --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513317565093330.2635908936428; Thu, 14 Dec 2017 21:59:25 -0800 (PST) Received: from localhost ([::1]:44596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePj1i-0007kJ-Bj for importer@patchew.org; Fri, 15 Dec 2017 00:59:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixN-0003fQ-UO for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixM-0004iF-Rf for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:50 -0500 Received: from ozlabs.org ([103.22.144.67]:46881) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixM-0004eH-Cl; Fri, 15 Dec 2017 00:54:48 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflQ2WGMz9tBt; Fri, 15 Dec 2017 16:54:41 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317282; bh=VrCFrRkC87tjE/usTp6PqdfMImXIAJ/gEGclZ3Mod2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S1uRyRbo9hBHUx3/JLBmIeTNyDpdrqea9ZL5++7u78kLvsUjXn1Eqc8LgL1J1cYjA p02gIGRSb/KexMCi4zXDmvgdmopXomk1Xy7iIsHuRawD/qfKOezLwKSjW4ars7+QBb UasnE/A0Xj0rw79+ynAJVcvosz+D4NMpFBhL44Fk= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:27 +1100 Message-Id: <20171215055435.24204-17-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 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: 103.22.144.67 Subject: [Qemu-devel] [PULL 16/24] spapr: introduce a spapr_irq_set_lsi() helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater It will make synchronisation easier with the XIVE interrupt mode when available. The 'irq' parameter refers to the global IRQ number space. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: David Gibson Signed-off-by: David Gibson --- hw/ppc/spapr.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 53c2c58a25..02cc7ffd4d 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3582,6 +3582,14 @@ static int ics_find_free_block(ICSState *ics, int nu= m, int alignnum) return -1; } =20 +/* + * Allocate the IRQ number and set the IRQ type, LSI or MSI + */ +static void spapr_irq_set_lsi(sPAPRMachineState *spapr, int irq, bool lsi) +{ + ics_set_irq_type(spapr->ics, irq - spapr->ics->offset, lsi); +} + int spapr_irq_alloc(sPAPRMachineState *spapr, int irq_hint, bool lsi, Error **errp) { @@ -3606,7 +3614,7 @@ int spapr_irq_alloc(sPAPRMachineState *spapr, int irq= _hint, bool lsi, irq +=3D ics->offset; } =20 - ics_set_irq_type(ics, irq - ics->offset, lsi); + spapr_irq_set_lsi(spapr, irq, lsi); trace_spapr_irq_alloc(irq); =20 return irq; @@ -3645,10 +3653,10 @@ int spapr_irq_alloc_block(sPAPRMachineState *spapr,= int num, bool lsi, return -1; } =20 + first +=3D ics->offset; for (i =3D first; i < first + num; ++i) { - ics_set_irq_type(ics, i, lsi); + spapr_irq_set_lsi(spapr, i, lsi); } - first +=3D ics->offset; =20 trace_spapr_irq_alloc_block(first, num, lsi, align); =20 --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513318472144996.7580064784058; Thu, 14 Dec 2017 22:14:32 -0800 (PST) Received: from localhost ([::1]:44702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePjGI-00044S-F1 for importer@patchew.org; Fri, 15 Dec 2017 01:14:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixS-0003iA-02 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixP-0004m5-CS for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:54 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:50277) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixO-0004ha-V7; Fri, 15 Dec 2017 00:54:51 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflS0dlSz9tCr; Fri, 15 Dec 2017 16:54:41 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317284; bh=cTXXGuUEK3MCwaXrB01L8LD2cARhQqdudAHN0ZgZFKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XU8oxxFskwiCjmENqWcNvddaMQoUcTU9Ji37/+7isark+hYrL4V29CH8ESmSftlCL an1maWn1pCZny+b/UPlekTQmWOO6o4FXChIqfJ4dEyKNjj7WOi9FmtFi+IyPZw8oID 8K2V1fxociFoS9xvx2HvJmYdAwh+OlsYA+LeveMw= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:28 +1100 Message-Id: <20171215055435.24204-18-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 17/24] spapr: introduce a spapr_qirq() helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater xics_get_qirq() is only used by the sPAPR machine. Let's move it there and change its name to reflect its scope. It will be useful for XIVE support which will use its own set of qirqs. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: David Gibson Signed-off-by: David Gibson --- hw/intc/xics.c | 12 ------------ hw/ppc/spapr.c | 11 +++++++++++ hw/ppc/spapr_events.c | 12 +++++------- hw/ppc/spapr_pci.c | 2 +- include/hw/pci-host/spapr.h | 2 +- include/hw/ppc/spapr.h | 1 + include/hw/ppc/spapr_vio.h | 2 +- include/hw/ppc/xics.h | 1 - 8 files changed, 20 insertions(+), 23 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 700f6baa13..e73e623e3b 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -713,18 +713,6 @@ static const TypeInfo xics_fabric_info =3D { /* * Exported functions */ -qemu_irq xics_get_qirq(XICSFabric *xi, int irq) -{ - XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(xi); - ICSState *ics =3D xic->ics_get(xi, irq); - - if (ics) { - return ics->qirqs[irq - ics->offset]; - } - - return NULL; -} - ICPState *xics_icp_get(XICSFabric *xi, int server) { XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(xi); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 02cc7ffd4d..8a6a59f098 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3680,6 +3680,17 @@ void spapr_irq_free(sPAPRMachineState *spapr, int ir= q, int num) } } =20 +qemu_irq spapr_qirq(sPAPRMachineState *spapr, int irq) +{ + ICSState *ics =3D spapr->ics; + + if (ics_valid_irq(ics, irq)) { + return ics->qirqs[irq - ics->offset]; + } + + return NULL; +} + static void spapr_pic_print_info(InterruptStatsProvider *obj, Monitor *mon) { diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index cead596f3e..7dc87fc7bd 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -472,9 +472,8 @@ static void spapr_powerdown_req(Notifier *n, void *opaq= ue) =20 rtas_event_log_queue(spapr, entry); =20 - qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr), - rtas_event_log_to_irq(spapr, - RTAS_LOG_TYPE_EPOW)= )); + qemu_irq_pulse(spapr_qirq(spapr, + rtas_event_log_to_irq(spapr, RTAS_LOG_TYPE_EPOW))); } =20 static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action, @@ -556,9 +555,8 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint= 8_t hp_action, =20 rtas_event_log_queue(spapr, entry); =20 - qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr), - rtas_event_log_to_irq(spapr, - RTAS_LOG_TYPE_HOTPL= UG))); + qemu_irq_pulse(spapr_qirq(spapr, + rtas_event_log_to_irq(spapr, RTAS_LOG_TYPE_HOTPLUG))); } =20 void spapr_hotplug_req_add_by_index(sPAPRDRConnector *drc) @@ -678,7 +676,7 @@ static void check_exception(PowerPCCPU *cpu, sPAPRMachi= neState *spapr, spapr_event_sources_get_source(spapr->event_sources, i); =20 g_assert(source->enabled); - qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr), source->irq)); + qemu_irq_pulse(spapr_qirq(spapr, source->irq)); } } =20 diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index e0ef77a480..39134f0ef0 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -723,7 +723,7 @@ static void spapr_msi_write(void *opaque, hwaddr addr, =20 trace_spapr_pci_msi_write(addr, data, irq); =20 - qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr), irq)); + qemu_irq_pulse(spapr_qirq(spapr, irq)); } =20 static const MemoryRegionOps spapr_msi_ops =3D { diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 38470b2f0e..0fae4fc6a4 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -108,7 +108,7 @@ static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRP= HBState *phb, int pin) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); =20 - return xics_get_qirq(XICS_FABRIC(spapr), phb->lsi_table[pin].irq); + return spapr_qirq(spapr, phb->lsi_table[pin].irq); } =20 PCIHostState *spapr_create_phb(sPAPRMachineState *spapr, int index); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 895f48471e..6b8e04c787 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -712,5 +712,6 @@ int spapr_irq_alloc(sPAPRMachineState *spapr, int irq_h= int, bool lsi, int spapr_irq_alloc_block(sPAPRMachineState *spapr, int num, bool lsi, bool align, Error **errp); void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num); +qemu_irq spapr_qirq(sPAPRMachineState *spapr, int irq); =20 #endif /* HW_SPAPR_H */ diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index 2e9685a5d9..e8b006d18f 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -87,7 +87,7 @@ static inline qemu_irq spapr_vio_qirq(VIOsPAPRDevice *dev) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); =20 - return xics_get_qirq(XICS_FABRIC(spapr), dev->irq); + return spapr_qirq(spapr, dev->irq); } =20 static inline bool spapr_vio_dma_valid(VIOsPAPRDevice *dev, uint64_t taddr, diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 0b67abbbb9..6cebff47a7 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -183,7 +183,6 @@ typedef struct XICSFabricClass { =20 void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle); =20 -qemu_irq xics_get_qirq(XICSFabric *xi, int irq); ICPState *xics_icp_get(XICSFabric *xi, int server); =20 /* Internal XICS interfaces */ --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513318379368157.5160737572587; Thu, 14 Dec 2017 22:12:59 -0800 (PST) Received: from localhost ([::1]:44693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePjEn-0002pl-CO for importer@patchew.org; Fri, 15 Dec 2017 01:12:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixT-0003l8-NV for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixP-0004mW-MA for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:55 -0500 Received: from ozlabs.org ([103.22.144.67]:40585) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixO-0004iJ-Td; Fri, 15 Dec 2017 00:54:51 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflS2S7hz9tCf; Fri, 15 Dec 2017 16:54:42 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317284; bh=o1rX1JWoIidmp+Wx489pLsY3dyaHSJIfngrIs8LHUt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U2my/yN6s2E10LAzSA5hPhNl0hPIIqjoWYUkIxy7CduBsPJ5eEkhTGVJbdBkL0W5Q EG2SuKUC8RHIOWhgz76E/mfwessM4FO0EjiK7lVUj7/m2YtybXlis3yKjq/DXioP+6 nr1y8M+9HGKWOS5EUtMmWYPp4MKjXJrTNsDC3ji0= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:29 +1100 Message-Id: <20171215055435.24204-19-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 18/24] spapr: replace numa_get_node() with lookup in pc-dimm list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, Igor Mammedov , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov SPAPR is the last user of numa_get_node() and a bunch of supporting code to maintain numa_info[x].addr list. Get LMB node id from pc-dimm list, which allows to remove ~80LOC maintaining dynamic address range lookup list. It also removes pc-dimm dependency on numa_[un]set_mem_node_id() and makes pc-dimms a sole source of information about which node it belongs to and removes duplicate data from global numa_info. Signed-off-by: Igor Mammedov Signed-off-by: David Gibson --- hw/mem/pc-dimm.c | 2 -- hw/ppc/spapr.c | 29 +++++++++++++++- include/sysemu/numa.h | 10 ------ numa.c | 94 -----------------------------------------------= ---- 4 files changed, 28 insertions(+), 107 deletions(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 66eace5a5c..6e74b61cb6 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -109,7 +109,6 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplu= gState *hpms, =20 memory_region_add_subregion(&hpms->mr, addr - hpms->base, mr); vmstate_register_ram(vmstate_mr, dev); - numa_set_mem_node_id(addr, memory_region_size(mr), dimm->node); =20 out: error_propagate(errp, local_err); @@ -122,7 +121,6 @@ void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotp= lugState *hpms, PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm); =20 - numa_unset_mem_node_id(dimm->addr, memory_region_size(mr), dimm->node); memory_region_del_subregion(&hpms->mr, mr); vmstate_unregister_ram(vmstate_mr, dev); } diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 8a6a59f098..306875e123 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -641,6 +641,26 @@ static void spapr_populate_cpus_dt_node(void *fdt, sPA= PRMachineState *spapr) =20 } =20 +static uint32_t spapr_pc_dimm_node(MemoryDeviceInfoList *list, ram_addr_t = addr) +{ + MemoryDeviceInfoList *info; + + for (info =3D list; info; info =3D info->next) { + MemoryDeviceInfo *value =3D info->value; + + if (value && value->type =3D=3D MEMORY_DEVICE_INFO_KIND_DIMM) { + PCDIMMDeviceInfo *pcdimm_info =3D value->u.dimm.data; + + if (pcdimm_info->addr >=3D addr && + addr < (pcdimm_info->addr + pcdimm_info->size)) { + return pcdimm_info->node; + } + } + } + + return -1; +} + /* * Adds ibm,dynamic-reconfiguration-memory node. * Refer to docs/specs/ppc-spapr-hotplug.txt for the documentation @@ -658,6 +678,7 @@ static int spapr_populate_drconf_memory(sPAPRMachineSta= te *spapr, void *fdt) lmb_size; uint32_t *int_buf, *cur_index, buf_len; int nr_nodes =3D nb_numa_nodes ? nb_numa_nodes : 1; + MemoryDeviceInfoList *dimms =3D NULL; =20 /* * Don't create the node if there is no hotpluggable memory @@ -692,6 +713,11 @@ static int spapr_populate_drconf_memory(sPAPRMachineSt= ate *spapr, void *fdt) goto out; } =20 + if (hotplug_lmb_start) { + MemoryDeviceInfoList **prev =3D &dimms; + qmp_pc_dimm_device_list(qdev_get_machine(), &prev); + } + /* ibm,dynamic-memory */ int_buf[0] =3D cpu_to_be32(nr_lmbs); cur_index++; @@ -709,7 +735,7 @@ static int spapr_populate_drconf_memory(sPAPRMachineSta= te *spapr, void *fdt) dynamic_memory[1] =3D cpu_to_be32(addr & 0xffffffff); dynamic_memory[2] =3D cpu_to_be32(spapr_drc_index(drc)); dynamic_memory[3] =3D cpu_to_be32(0); /* reserved */ - dynamic_memory[4] =3D cpu_to_be32(numa_get_node(addr, NULL)); + dynamic_memory[4] =3D cpu_to_be32(spapr_pc_dimm_node(dimms, ad= dr)); if (memory_region_present(get_system_memory(), addr)) { dynamic_memory[5] =3D cpu_to_be32(SPAPR_LMB_FLAGS_ASSIGNED= ); } else { @@ -732,6 +758,7 @@ static int spapr_populate_drconf_memory(sPAPRMachineSta= te *spapr, void *fdt) =20 cur_index +=3D SPAPR_DR_LMB_LIST_ENTRY_SIZE; } + qapi_free_MemoryDeviceInfoList(dimms); ret =3D fdt_setprop(fdt, offset, "ibm,dynamic-memory", int_buf, buf_le= n); if (ret < 0) { goto out; diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 5c6df2820b..b3545215f6 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -10,17 +10,10 @@ extern int nb_numa_nodes; /* Number of NUMA nodes */ extern bool have_numa_distance; =20 -struct numa_addr_range { - ram_addr_t mem_start; - ram_addr_t mem_end; - QLIST_ENTRY(numa_addr_range) entry; -}; - struct node_info { uint64_t node_mem; struct HostMemoryBackend *node_memdev; bool present; - QLIST_HEAD(, numa_addr_range) addr; /* List to store address ranges */ uint8_t distance[MAX_NODES]; }; =20 @@ -33,9 +26,6 @@ extern NodeInfo numa_info[MAX_NODES]; void parse_numa_opts(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[]); extern QemuOptsList qemu_numa_opts; -void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node); -void numa_unset_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node); -uint32_t numa_get_node(ram_addr_t addr, Error **errp); void numa_legacy_auto_assign_ram(MachineClass *mc, NodeInfo *nodes, int nb_nodes, ram_addr_t size); void numa_default_auto_assign_ram(MachineClass *mc, NodeInfo *nodes, diff --git a/numa.c b/numa.c index 7151b24d1c..98fa9a4bcf 100644 --- a/numa.c +++ b/numa.c @@ -55,92 +55,6 @@ int nb_numa_nodes; bool have_numa_distance; NodeInfo numa_info[MAX_NODES]; =20 -void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node) -{ - struct numa_addr_range *range; - - /* - * Memory-less nodes can come here with 0 size in which case, - * there is nothing to do. - */ - if (!size) { - return; - } - - range =3D g_malloc0(sizeof(*range)); - range->mem_start =3D addr; - range->mem_end =3D addr + size - 1; - QLIST_INSERT_HEAD(&numa_info[node].addr, range, entry); -} - -void numa_unset_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node) -{ - struct numa_addr_range *range, *next; - - QLIST_FOREACH_SAFE(range, &numa_info[node].addr, entry, next) { - if (addr =3D=3D range->mem_start && (addr + size - 1) =3D=3D range= ->mem_end) { - QLIST_REMOVE(range, entry); - g_free(range); - return; - } - } -} - -static void numa_set_mem_ranges(void) -{ - int i; - ram_addr_t mem_start =3D 0; - - /* - * Deduce start address of each node and use it to store - * the address range info in numa_info address range list - */ - for (i =3D 0; i < nb_numa_nodes; i++) { - numa_set_mem_node_id(mem_start, numa_info[i].node_mem, i); - mem_start +=3D numa_info[i].node_mem; - } -} - -/* - * Check if @addr falls under NUMA @node. - */ -static bool numa_addr_belongs_to_node(ram_addr_t addr, uint32_t node) -{ - struct numa_addr_range *range; - - QLIST_FOREACH(range, &numa_info[node].addr, entry) { - if (addr >=3D range->mem_start && addr <=3D range->mem_end) { - return true; - } - } - return false; -} - -/* - * Given an address, return the index of the NUMA node to which the - * address belongs to. - */ -uint32_t numa_get_node(ram_addr_t addr, Error **errp) -{ - uint32_t i; - - /* For non NUMA configurations, check if the addr falls under node 0 */ - if (!nb_numa_nodes) { - if (numa_addr_belongs_to_node(addr, 0)) { - return 0; - } - } - - for (i =3D 0; i < nb_numa_nodes; i++) { - if (numa_addr_belongs_to_node(addr, i)) { - return i; - } - } - - error_setg(errp, "Address 0x" RAM_ADDR_FMT " doesn't belong to any " - "NUMA node", addr); - return -1; -} =20 static void parse_numa_node(MachineState *ms, NumaNodeOptions *node, Error **errp) @@ -497,12 +411,6 @@ void parse_numa_opts(MachineState *ms) exit(1); } =20 - for (i =3D 0; i < nb_numa_nodes; i++) { - QLIST_INIT(&numa_info[i].addr); - } - - numa_set_mem_ranges(); - /* QEMU needs at least all unique node pair distances to build * the whole NUMA distance table. QEMU treats the distance table * as symmetric by default, i.e. distance A->B =3D=3D distance B->= A. @@ -522,8 +430,6 @@ void parse_numa_opts(MachineState *ms) /* Validation succeeded, now fill in any missing distances. */ complete_init_numa_distance(); } - } else { - numa_set_mem_node_id(0, ram_size, 0); } } =20 --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513318262137164.86724480315263; Thu, 14 Dec 2017 22:11:02 -0800 (PST) Received: from localhost ([::1]:44675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePjCs-00013X-ON for importer@patchew.org; Fri, 15 Dec 2017 01:10:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixR-0003i9-Lp for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixO-0004kf-Ef for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:53 -0500 Received: from ozlabs.org ([103.22.144.67]:57033) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixN-0004gd-SD; Fri, 15 Dec 2017 00:54:50 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflR4p6zz9tD6; Fri, 15 Dec 2017 16:54:42 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317283; bh=981IAS9x6CUnq7muyl5zclsGDw2zpkRrrnh6GL6JbEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eL5tffU5agR/fk+KPeU+YviwSJz75ZU9ODRIKOG682VtZnhV22A9kp3h7GilLr4i5 7lCpvADWcR6a9yaYMZUIILJDbOgxx3EGPdbGz47dXCYquacr4bcmYCBaJU0ZhsDW1v b/+NjaFcaDIZyvpRf+4OC87LTFFpQU2JI5rWaUIo= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:30 +1100 Message-Id: <20171215055435.24204-20-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 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: 103.22.144.67 Subject: [Qemu-devel] [PULL 19/24] spapr: fix LSI interrupt specifiers in the device tree X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz LoPAPR 1.1 B.6.9.1.2 describes the "#interrupt-cells" property of the PowerPC External Interrupt Source Controller node as follows: =E2=80=9C#interrupt-cells=E2=80=9D Standard property name to define the number of cells in an interrupt- specifier within an interrupt domain. prop-encoded-array: An integer, encoded as with encode-int, that denotes the number of cells required to represent an interrupt specifier in its child nodes. The value of this property for the PowerPC External Interrupt option shall be 2. Thus all interrupt specifiers (as used in the standard =E2=80=9Cint= errupts=E2=80=9D property) shall consist of two cells, each containing an integer encoded as with encode-int. The first integer represents the interrupt number the second integer is the trigger code: 0 for edge triggered, 1 for level triggered. This patch fixes the interrupt specifiers in the "interrupt-map" property of the PHB node, that were setting the second cell to 8 (confusion with IRQ_TYPE_LEVEL_LOW ?) instead of 1. VIO devices and RTAS event sources use the same format for interrupt specifiers: while here, we introduce a common helper to handle the encoding details. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater -- v3: - reference public LoPAPR instead of internal PAPR+ in changelog - change helper name to spapr_dt_xics_irq() v2: - drop the erroneous changes to the "interrupts" prop in PCI device nod= es - introduce a common helper to encode interrupt specifiers Signed-off-by: David Gibson --- hw/ppc/spapr_events.c | 3 +-- hw/ppc/spapr_pci.c | 3 +-- hw/ppc/spapr_vio.c | 3 ++- include/hw/ppc/spapr.h | 10 ++++++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index 7dc87fc7bd..c7a64e6b8d 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -282,8 +282,7 @@ void spapr_dt_events(sPAPRMachineState *spapr, void *fd= t) continue; } =20 - interrupts[0] =3D cpu_to_be32(source->irq); - interrupts[1] =3D 0; + spapr_dt_xics_irq(interrupts, source->irq, false); =20 _FDT(node_offset =3D fdt_add_subnode(fdt, event_sources, source_na= me)); _FDT(fdt_setprop(fdt, node_offset, "interrupts", interrupts, diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 39134f0ef0..88797b3d36 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2121,8 +2121,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, irqmap[2] =3D 0; irqmap[3] =3D cpu_to_be32(j+1); irqmap[4] =3D cpu_to_be32(xics_phandle); - irqmap[5] =3D cpu_to_be32(phb->lsi_table[lsi_num].irq); - irqmap[6] =3D cpu_to_be32(0x8); + spapr_dt_xics_irq(&irqmap[5], phb->lsi_table[lsi_num].irq, tru= e); } } /* Write interrupt map */ diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index bb7ed2c537..472dd6f33a 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -126,8 +126,9 @@ static int vio_make_devnode(VIOsPAPRDevice *dev, } =20 if (dev->irq) { - uint32_t ints_prop[] =3D {cpu_to_be32(dev->irq), 0}; + uint32_t ints_prop[2]; =20 + spapr_dt_xics_irq(ints_prop, dev->irq, false); ret =3D fdt_setprop(fdt, node_off, "interrupts", ints_prop, sizeof(ints_prop)); if (ret < 0) { diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 6b8e04c787..14757b805e 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -590,6 +590,16 @@ void spapr_load_rtas(sPAPRMachineState *spapr, void *f= dt, hwaddr addr); =20 #define RTAS_EVENT_SCAN_RATE 1 =20 +/* This helper should be used to encode interrupt specifiers when the rela= ted + * "interrupt-controller" node has its "#interrupt-cells" property set to = 2 (ie, + * VIO devices, RTAS event sources and PHBs). + */ +static inline void spapr_dt_xics_irq(uint32_t *intspec, int irq, bool is_l= si) +{ + intspec[0] =3D cpu_to_be32(irq); + intspec[1] =3D is_lsi ? cpu_to_be32(1) : 0; +} + typedef struct sPAPRTCETable sPAPRTCETable; =20 #define TYPE_SPAPR_TCE_TABLE "spapr-tce-table" --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513318101645784.9837596309391; Thu, 14 Dec 2017 22:08:21 -0800 (PST) Received: from localhost ([::1]:44653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePjAJ-000735-OC for importer@patchew.org; Fri, 15 Dec 2017 01:08:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixP-0003i0-Ip for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixO-0004k5-7v for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:51 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:58689) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixN-0004gR-Pz; Fri, 15 Dec 2017 00:54:50 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflR1kzhz9tBZ; Fri, 15 Dec 2017 16:54:42 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317283; bh=4l7ts9Bb6R9sgGBMUePksxJHO+9EP0BH0BrMiBhGz1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xx3FyAIr4Qy07DLmeMXpLS6HbpBAPZ37DG8fZ8DbRl2w6Ix8LsmlfYuTI7sXtMsZj 4qMCwQP88/3CFSKJ2ftrL0M3lv3QY/sTh60a5/qTo+Sfeze9ULDfSz2wLyIgt0gKjg 8wiMlh5/4EUtaQtynR1MicARZfgSjyKV8sVGMciA= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:31 +1100 Message-Id: <20171215055435.24204-21-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 20/24] spapr_events: drop bogus cell from "interrupt-ranges" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz According to LoPAPR 1.1 B.6.12, the "/event-sources" node has an "interrupt- ranges" property, the format of which is described in B.6.9.1.2 as follows: =E2=80=9Cinterrupt-ranges=E2=80=9D Standard property name that defines the interrupt number(s) and range(s) handled by this unit. prop-encoded-array: List of (int-number, range) specifications. Int-number is encoded as with encode-int. Range is encoded as with encode-int. The first entry in this list shall contain the int-number associated with the first =E2=80=9Creg=E2=80=9D property entry. The int-num-ber is the val= ue representing the interrupt source as would appear in the PowerPC External Interrupt Architecture XISR. The range shall be the number of sequential interrupt numbers which this unit can generate. There's no such thing as a cell count at the end of the array, like the one introduced by commit ffbb1705a33d in QEMU 2.8. It doesn't seem it had any impact on existing guests and I couldn't find any related workaround in linux. So, let's just drop the bogus lines. Signed-off-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/spapr_events.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index c7a64e6b8d..86836f0626 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -292,9 +292,6 @@ void spapr_dt_events(sPAPRMachineState *spapr, void *fd= t) irq_ranges[count++] =3D cpu_to_be32(1); } =20 - irq_ranges[count] =3D cpu_to_be32(count); - count++; - _FDT((fdt_setprop(fdt, event_sources, "interrupt-controller", NULL, 0)= )); _FDT((fdt_setprop_cell(fdt, event_sources, "#interrupt-cells", 2))); _FDT((fdt_setprop(fdt, event_sources, "interrupt-ranges", --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513318245171608.8381207385155; Thu, 14 Dec 2017 22:10:45 -0800 (PST) Received: from localhost ([::1]:44668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePjCW-0000hN-C4 for importer@patchew.org; Fri, 15 Dec 2017 01:10:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixS-0003iz-Ot for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixQ-0004nC-2D for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:54 -0500 Received: from ozlabs.org ([103.22.144.67]:38071) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixP-0004iM-2B; Fri, 15 Dec 2017 00:54:51 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflS4qCnz9tCj; Fri, 15 Dec 2017 16:54:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317284; bh=Qny6BsTFtQf3aNsOWIpJhrhc1NK6ez2+2SdrbMZuUZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VVvfkt88/mLQYDrGTv67y7/GLcysdd68UsihIIHOhCRx5W6HDVwFQomRR7ckPe0ds mC6pSnM5oakd5AN5dvk0pOjfGSHvtDqRZYy9QLHcZLNxmpWL/zhT14y5Uc+i5jFPkm uwizm7C00VnCKfubpzurCTAQ/17M2ho5C+W0Fr+w= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:32 +1100 Message-Id: <20171215055435.24204-22-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 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: 103.22.144.67 Subject: [Qemu-devel] [PULL 21/24] target/ppc: introduce the PPC_BIT() macro X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater and use them in a couple of obvious places. Other macros will be used in the model of the XIVE interrupt controller. Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- target/ppc/cpu.h | 105 +++++++++++++++++++++++++++++----------------------= ---- 1 file changed, 56 insertions(+), 49 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 989761b795..370b05e76e 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -87,6 +87,13 @@ #define PPC_ELF_MACHINE EM_PPC #endif =20 +#define PPC_BIT(bit) (0x8000000000000000UL >> (bit)) +#define PPC_BIT32(bit) (0x80000000UL >> (bit)) +#define PPC_BIT8(bit) (0x80UL >> (bit)) +#define PPC_BITMASK(bs, be) ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs)) +#define PPC_BITMASK32(bs, be) ((PPC_BIT32(bs) - PPC_BIT32(be)) | \ + PPC_BIT32(bs)) + /*************************************************************************= ****/ /* Exception vectors definitions = */ enum { @@ -371,10 +378,10 @@ struct ppc_slb_t { #define MSR_LE 0 /* Little-endian mode 1 hfla= gs */ =20 /* LPCR bits */ -#define LPCR_VPM0 (1ull << (63 - 0)) -#define LPCR_VPM1 (1ull << (63 - 1)) -#define LPCR_ISL (1ull << (63 - 2)) -#define LPCR_KBV (1ull << (63 - 3)) +#define LPCR_VPM0 PPC_BIT(0) +#define LPCR_VPM1 PPC_BIT(1) +#define LPCR_ISL PPC_BIT(2) +#define LPCR_KBV PPC_BIT(3) #define LPCR_DPFD_SHIFT (63 - 11) #define LPCR_DPFD (0x7ull << LPCR_DPFD_SHIFT) #define LPCR_VRMASD_SHIFT (63 - 16) @@ -382,41 +389,41 @@ struct ppc_slb_t { /* P9: Power-saving mode Exit Cause Enable (Upper Section) Mask */ #define LPCR_PECE_U_SHIFT (63 - 19) #define LPCR_PECE_U_MASK (0x7ull << LPCR_PECE_U_SHIFT) -#define LPCR_HVEE (1ull << (63 - 17)) /* Hypervisor Virt Exit Enab= le */ +#define LPCR_HVEE PPC_BIT(17) /* Hypervisor Virt Exit Enable */ #define LPCR_RMLS_SHIFT (63 - 37) #define LPCR_RMLS (0xfull << LPCR_RMLS_SHIFT) -#define LPCR_ILE (1ull << (63 - 38)) +#define LPCR_ILE PPC_BIT(38) #define LPCR_AIL_SHIFT (63 - 40) /* Alternate interrupt location */ #define LPCR_AIL (3ull << LPCR_AIL_SHIFT) -#define LPCR_UPRT (1ull << (63 - 41)) /* Use Process Table */ -#define LPCR_EVIRT (1ull << (63 - 42)) /* Enhanced Virtualisation */ -#define LPCR_ONL (1ull << (63 - 45)) -#define LPCR_LD (1ull << (63 - 46)) /* Large Decrementer */ -#define LPCR_P7_PECE0 (1ull << (63 - 49)) -#define LPCR_P7_PECE1 (1ull << (63 - 50)) -#define LPCR_P7_PECE2 (1ull << (63 - 51)) -#define LPCR_P8_PECE0 (1ull << (63 - 47)) -#define LPCR_P8_PECE1 (1ull << (63 - 48)) -#define LPCR_P8_PECE2 (1ull << (63 - 49)) -#define LPCR_P8_PECE3 (1ull << (63 - 50)) -#define LPCR_P8_PECE4 (1ull << (63 - 51)) +#define LPCR_UPRT PPC_BIT(41) /* Use Process Table */ +#define LPCR_EVIRT PPC_BIT(42) /* Enhanced Virtualisation */ +#define LPCR_ONL PPC_BIT(45) +#define LPCR_LD PPC_BIT(46) /* Large Decrementer */ +#define LPCR_P7_PECE0 PPC_BIT(49) +#define LPCR_P7_PECE1 PPC_BIT(50) +#define LPCR_P7_PECE2 PPC_BIT(51) +#define LPCR_P8_PECE0 PPC_BIT(47) +#define LPCR_P8_PECE1 PPC_BIT(48) +#define LPCR_P8_PECE2 PPC_BIT(49) +#define LPCR_P8_PECE3 PPC_BIT(50) +#define LPCR_P8_PECE4 PPC_BIT(51) /* P9: Power-saving mode Exit Cause Enable (Lower Section) Mask */ #define LPCR_PECE_L_SHIFT (63 - 51) #define LPCR_PECE_L_MASK (0x1full << LPCR_PECE_L_SHIFT) -#define LPCR_PDEE (1ull << (63 - 47)) /* Privileged Doorbell Exit = EN */ -#define LPCR_HDEE (1ull << (63 - 48)) /* Hyperv Doorbell Exit Enab= le */ -#define LPCR_EEE (1ull << (63 - 49)) /* External Exit Enable = */ -#define LPCR_DEE (1ull << (63 - 50)) /* Decrementer Exit Enable = */ -#define LPCR_OEE (1ull << (63 - 51)) /* Other Exit Enable = */ -#define LPCR_MER (1ull << (63 - 52)) -#define LPCR_GTSE (1ull << (63 - 53)) /* Guest Translation Shootdo= wn */ -#define LPCR_TC (1ull << (63 - 54)) -#define LPCR_HEIC (1ull << (63 - 59)) /* HV Extern Interrupt Contr= ol */ -#define LPCR_LPES0 (1ull << (63 - 60)) -#define LPCR_LPES1 (1ull << (63 - 61)) -#define LPCR_RMI (1ull << (63 - 62)) -#define LPCR_HVICE (1ull << (63 - 62)) /* HV Virtualisation Int Ena= ble */ -#define LPCR_HDICE (1ull << (63 - 63)) +#define LPCR_PDEE PPC_BIT(47) /* Privileged Doorbell Exit EN */ +#define LPCR_HDEE PPC_BIT(48) /* Hyperv Doorbell Exit Enable */ +#define LPCR_EEE PPC_BIT(49) /* External Exit Enable */ +#define LPCR_DEE PPC_BIT(50) /* Decrementer Exit Enable */ +#define LPCR_OEE PPC_BIT(51) /* Other Exit Enable */ +#define LPCR_MER PPC_BIT(52) +#define LPCR_GTSE PPC_BIT(53) /* Guest Translation Shootdown */ +#define LPCR_TC PPC_BIT(54) +#define LPCR_HEIC PPC_BIT(59) /* HV Extern Interrupt Control */ +#define LPCR_LPES0 PPC_BIT(60) +#define LPCR_LPES1 PPC_BIT(61) +#define LPCR_RMI PPC_BIT(62) +#define LPCR_HVICE PPC_BIT(62) /* HV Virtualisation Int Enable */ +#define LPCR_HDICE PPC_BIT(63) =20 #define msr_sf ((env->msr >> MSR_SF) & 1) #define msr_isf ((env->msr >> MSR_ISF) & 1) @@ -507,22 +514,22 @@ struct ppc_slb_t { #define FSCR_IC_TAR 8 =20 /* Exception state register bits definition = */ -#define ESR_PIL (1 << (63 - 36)) /* Illegal Instruction = */ -#define ESR_PPR (1 << (63 - 37)) /* Privileged Instruction = */ -#define ESR_PTR (1 << (63 - 38)) /* Trap = */ -#define ESR_FP (1 << (63 - 39)) /* Floating-Point Operation = */ -#define ESR_ST (1 << (63 - 40)) /* Store Operation = */ -#define ESR_AP (1 << (63 - 44)) /* Auxiliary Processor Operation = */ -#define ESR_PUO (1 << (63 - 45)) /* Unimplemented Operation = */ -#define ESR_BO (1 << (63 - 46)) /* Byte Ordering = */ -#define ESR_PIE (1 << (63 - 47)) /* Imprecise exception = */ -#define ESR_DATA (1 << (63 - 53)) /* Data Access (Embedded page table) = */ -#define ESR_TLBI (1 << (63 - 54)) /* TLB Ineligible (Embedded page table)= */ -#define ESR_PT (1 << (63 - 55)) /* Page Table (Embedded page table) = */ -#define ESR_SPV (1 << (63 - 56)) /* SPE/VMX operation = */ -#define ESR_EPID (1 << (63 - 57)) /* External Process ID operation = */ -#define ESR_VLEMI (1 << (63 - 58)) /* VLE operation = */ -#define ESR_MIF (1 << (63 - 62)) /* Misaligned instruction (VLE) = */ +#define ESR_PIL PPC_BIT(36) /* Illegal Instruction */ +#define ESR_PPR PPC_BIT(37) /* Privileged Instruction */ +#define ESR_PTR PPC_BIT(38) /* Trap */ +#define ESR_FP PPC_BIT(39) /* Floating-Point Operation */ +#define ESR_ST PPC_BIT(40) /* Store Operation */ +#define ESR_AP PPC_BIT(44) /* Auxiliary Processor Operation */ +#define ESR_PUO PPC_BIT(45) /* Unimplemented Operation */ +#define ESR_BO PPC_BIT(46) /* Byte Ordering */ +#define ESR_PIE PPC_BIT(47) /* Imprecise exception */ +#define ESR_DATA PPC_BIT(53) /* Data Access (Embedded page table) */ +#define ESR_TLBI PPC_BIT(54) /* TLB Ineligible (Embedded page table) */ +#define ESR_PT PPC_BIT(55) /* Page Table (Embedded page table) */ +#define ESR_SPV PPC_BIT(56) /* SPE/VMX operation */ +#define ESR_EPID PPC_BIT(57) /* External Process ID operation */ +#define ESR_VLEMI PPC_BIT(58) /* VLE operation */ +#define ESR_MIF PPC_BIT(62) /* Misaligned instruction (VLE) */ =20 /* Transaction EXception And Summary Register bits = */ #define TEXASR_FAILURE_PERSISTENT (63 - 7) @@ -1991,7 +1998,7 @@ void ppc_compat_add_property(Object *obj, const char = *name, #define HID0_DEEPNAP (1 << 24) /* pre-2.06 */ #define HID0_DOZE (1 << 23) /* pre-2.06 */ #define HID0_NAP (1 << 22) /* pre-2.06 */ -#define HID0_HILE (1ull << (63 - 19)) /* POWER8 */ +#define HID0_HILE PPC_BIT(19) /* POWER8 */ =20 /*************************************************************************= ****/ /* PowerPC Instructions types definitions = */ --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513318384458980.5591819502331; Thu, 14 Dec 2017 22:13:04 -0800 (PST) Received: from localhost ([::1]:44691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePjEg-0002jW-Cj for importer@patchew.org; Fri, 15 Dec 2017 01:12:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixS-0003iB-0M for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixQ-0004n7-2U for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:54 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:39439) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixP-0004if-Dw; Fri, 15 Dec 2017 00:54:51 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflS6fj0z9tD8; Fri, 15 Dec 2017 16:54:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317284; bh=wNVyeUnUyOBoJJgFoLUjy0TPx4pUrFAvlsAzYUsujKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i1Bj2fOU6V0nD5Yqr1841kq8Dld1lVrduImq1cB2cx0WVQPMhToz+7tmZ+ERvPPpV 2S9sFqjsYpC5M2SGUYxqKI4305nFscqXUn/ctX4Mw2B80Qhr+BV1K8ANKpIGOE39+o JcVfJYyp+GnbfO9wzRRRvkZSpmrO5GzTcOoq16yA= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:33 +1100 Message-Id: <20171215055435.24204-23-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 22/24] spapr: Rename machine init functions for clarity X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Machine objects have two init functions - the generic QOM level instance_init which should only do static object initialization, and the Machine specific MachineClass::init which does the actual construction of the machine. In spapr the functions implementing these two have names - ppc_machine_initfn() and ppc_spapr_init() - which don't correspond closely to either of those. To prevent people (read, me) from confusing which is which, rename them spapr_instance_init() and spapr_machine_init() to make it clearer which is which. While we're there rename ppc_spapr_reset() to spapr_machine_reset() to match. Signed-off-by: David Gibson Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz Reviewed-by: Suraj Jitindar Singh --- hw/ppc/spapr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 306875e123..42d6a2302a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1454,7 +1454,7 @@ static int spapr_reset_drcs(Object *child, void *opaq= ue) return 0; } =20 -static void ppc_spapr_reset(void) +static void spapr_machine_reset(void) { MachineState *machine =3D MACHINE(qdev_get_machine()); sPAPRMachineState *spapr =3D SPAPR_MACHINE(machine); @@ -2292,7 +2292,7 @@ out: } =20 /* pSeries LPAR / sPAPR hardware init */ -static void ppc_spapr_init(MachineState *machine) +static void spapr_machine_init(MachineState *machine) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(machine); sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(machine); @@ -2820,7 +2820,7 @@ static void spapr_set_vsmt(Object *obj, Visitor *v, c= onst char *name, visit_type_uint32(v, name, (uint32_t *)opaque, errp); } =20 -static void spapr_machine_initfn(Object *obj) +static void spapr_instance_init(Object *obj) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(obj); =20 @@ -3777,8 +3777,8 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) * functions for the specific versioned machine types can override * these details for backwards compatibility */ - mc->init =3D ppc_spapr_init; - mc->reset =3D ppc_spapr_reset; + mc->init =3D spapr_machine_init; + mc->reset =3D spapr_machine_reset; mc->block_default_type =3D IF_SCSI; mc->max_cpus =3D 1024; mc->no_parallel =3D 1; @@ -3825,7 +3825,7 @@ static const TypeInfo spapr_machine_info =3D { .parent =3D TYPE_MACHINE, .abstract =3D true, .instance_size =3D sizeof(sPAPRMachineState), - .instance_init =3D spapr_machine_initfn, + .instance_init =3D spapr_instance_init, .instance_finalize =3D spapr_machine_finalizefn, .class_size =3D sizeof(sPAPRMachineClass), .class_init =3D spapr_machine_class_init, --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513317939766481.32088550361345; Thu, 14 Dec 2017 22:05:39 -0800 (PST) Received: from localhost ([::1]:44633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePj7n-0004ik-3v for importer@patchew.org; Fri, 15 Dec 2017 01:05:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixS-0003iK-Ge for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixR-0004pE-7F for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:54 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:42441) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixQ-0004kv-Pq; Fri, 15 Dec 2017 00:54:53 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflT2m94z9tDV; Fri, 15 Dec 2017 16:54:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317285; bh=PXWESxV2JFEdHdsu/H1MYd01qZwRfjA9gelv8jrtrus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mA502LCdgU9u1b48wl0qStL6Pym+spxkmoJYXXWqUljGiCMLIjFlzS5OGUqgOhnQK RlSCShC5mDHu2tgLWRn7S3Syd6map7fhNVtTOaTg30euq/0vuhMB6oPyXAr7iYv+zs DGqumZ1nf8GvLpuIxOsPo+dKEaol4xBeWN0kS7K8= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:34 +1100 Message-Id: <20171215055435.24204-24-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 23/24] spapr: Assume msi_nonbroken X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We conditionally adjust part of the guest device tree based on the global msi_nonbroken flag. However, the main machine type code initializes msi_nonbroken to true and there's nothing that would set it to false again. So replace the test with an assert(). Signed-off-by: David Gibson Reviewed-by: Alexey Kardashevskiy --- hw/ppc/spapr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 42d6a2302a..4f354a8760 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -943,9 +943,8 @@ static void spapr_dt_rtas(sPAPRMachineState *spapr, voi= d *fdt) _FDT(fdt_setprop_cell(fdt, rtas, "rtas-event-scan-rate", RTAS_EVENT_SCAN_RATE)); =20 - if (msi_nonbroken) { - _FDT(fdt_setprop(fdt, rtas, "ibm,change-msix-capable", NULL, 0)); - } + g_assert(msi_nonbroken); + _FDT(fdt_setprop(fdt, rtas, "ibm,change-msix-capable", NULL, 0)); =20 /* * According to PAPR, rtas ibm,os-term does not guarantee a return --=20 2.14.3 From nobody Sun May 5 16:47:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513318111420235.25488501736993; Thu, 14 Dec 2017 22:08:31 -0800 (PST) Received: from localhost ([::1]:44655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePjAS-0007Ah-SE for importer@patchew.org; Fri, 15 Dec 2017 01:08:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePixT-0003kh-CD for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePixR-0004pM-79 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 00:54:55 -0500 Received: from ozlabs.org ([103.22.144.67]:60821) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePixQ-0004kY-Mu; Fri, 15 Dec 2017 00:54:53 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yyflT1lJ9z9tDG; Fri, 15 Dec 2017 16:54:44 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1513317285; bh=ME8oL7BDXLClnaXGao1nFRee1kcdcXKo65tDsqInZ6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ts6KYvI6mKNOZRRvVizI2PJgel/0zHC7i21U0w9RT14Bywpf9WuN8nLYZWBpkmfz2 lBdMDJAtyCgywEgzPKyiUwxE3iPWy/igGxl//pDsr9Qoz97whYxgNqBba7qcfE7fzA s9IKcFy95UseuiBjDlgnBG9r9SPsUpajyqKCAqag= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 15 Dec 2017 16:54:35 +1100 Message-Id: <20171215055435.24204-25-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215055435.24204-1-david@gibson.dropbear.id.au> References: <20171215055435.24204-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 24/24] spapr: don't initialize PATB entry if max-cpu-compat < power9 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Laurent Vivier if KVM is enabled and KVM capabilities MMU radix is available, the partition table entry (patb_entry) for the radix mode is initialized by default in ppc_spapr_reset(). It's a problem if we want to migrate the guest to a POWER8 host while the kernel is not started to set the value to the one expected for a POWER8 CPU. The "-machine max-cpu-compat=3Dpower8" should allow to migrate a POWER9 KVM host to a POWER8 KVM host, but because patb_entry is set, the destination QEMU tries to enable radix mode on the POWER8 host. This fails and cancels the migration: Process table config unsupported by the host error while loading state for instance 0x0 of device 'spapr' load of migration failed: Invalid argument This patch doesn't set the PATB entry if the user provides a CPU compatibility mode that doesn't support radix mode. Signed-off-by: Laurent Vivier Signed-off-by: David Gibson --- hw/ppc/spapr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 4f354a8760..6785a90c60 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1466,7 +1466,10 @@ static void spapr_machine_reset(void) /* Check for unknown sysbus devices */ foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL); =20 - if (kvm_enabled() && kvmppc_has_cap_mmu_radix()) { + first_ppc_cpu =3D POWERPC_CPU(first_cpu); + if (kvm_enabled() && kvmppc_has_cap_mmu_radix() && + ppc_check_compat(first_ppc_cpu, CPU_POWERPC_LOGICAL_3_00, 0, + spapr->max_compat_pvr)) { /* If using KVM with radix mode available, VCPUs can be started * without a HPT because KVM will start them in radix mode. * Set the GR bit in PATB so that we know there is no HPT. */ @@ -1525,7 +1528,6 @@ static void spapr_machine_reset(void) g_free(fdt); =20 /* Set up the entry state */ - first_ppc_cpu =3D POWERPC_CPU(first_cpu); first_ppc_cpu->env.gpr[3] =3D fdt_addr; first_ppc_cpu->env.gpr[5] =3D 0; first_cpu->halted =3D 0; --=20 2.14.3