From nobody Sun May 19 13:34:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1589187618; cv=none; d=zohomail.com; s=zohoarc; b=ivzG/TrLJe6KaKUSoIsBbscMOrkXvZwEIPhNGTHBt7w19K4L2bNUFECl7yFqOU861dJNAcBPzluaEPsFo6uRzJnKXrSefzH/f7kMpRt7V5Hkif0PngDKTjzWDCnuqRnVFrKS6tTfmJQIfOOrSKfDRJkPgE1ofoP9U29aJtQv0zU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589187618; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=+zggRNwl4snXgB/n8e6vrckJAwzBZIWcSnM0TiWDXrM=; b=WVVVXZiFg2dgFuuchvnHWQFQnO+4fGnxmE2PsFwvKO1GtjPT4hLXy6A77rIDuWrSkWQcCibCy8FYj3V5sGTGXKca6fZBm3dYz/HCNDtO1A1Hqgiq7BFmD7ba8NKbNz9EefCsuiqKhUGJ9Pq0WYXjZT/9W0pwHtQYySZLnooflXM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589187618186748.0998688682004; Mon, 11 May 2020 02:00:18 -0700 (PDT) Received: from localhost ([::1]:51670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jY4IK-0000LV-SU for importer@patchew.org; Mon, 11 May 2020 05:00:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jY4HG-0007ye-5G for qemu-devel@nongnu.org; Mon, 11 May 2020 04:59:10 -0400 Received: from 5.mo1.mail-out.ovh.net ([178.33.45.107]:47108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jY4HA-0003o2-H8 for qemu-devel@nongnu.org; Mon, 11 May 2020 04:59:09 -0400 Received: from player779.ha.ovh.net (unknown [10.110.208.43]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id 1F23D1B9C61 for ; Mon, 11 May 2020 10:58:49 +0200 (CEST) Received: from kaod.org (82-64-250-170.subs.proxad.net [82.64.250.170]) (Authenticated sender: clg@kaod.org) by player779.ha.ovh.net (Postfix) with ESMTPSA id 7101E123098AA; Mon, 11 May 2020 08:58:41 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH] ppc/pnv: Add definitions for interrupts occurring in power-saving mode Date: Mon, 11 May 2020 10:58:22 +0200 Message-Id: <20200511085822.65319-1-clg@kaod.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 1425670759773277158 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduhedrledtgddthecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkofggtgfgsehtkeertdertdejnecuhfhrohhmpeevrogurhhitgcunfgvucfiohgrthgvrhcuoegtlhhgsehkrghougdrohhrgheqnecuggftrfgrthhtvghrnhepieekkeelffetgeelveevjeehteduvdeivdeljeevvdeuvedtgfeiudeiveeiudfgnecukfhppedtrddtrddtrddtpdekvddrieegrddvhedtrddujedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpqdhouhhtpdhhvghlohepphhlrgihvghrjeejledrhhgrrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpegtlhhgsehkrghougdrohhrghdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhg Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.33.45.107; envelope-from=clg@kaod.org; helo=5.mo1.mail-out.ovh.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/11 04:58:50 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" If an interrupt occurred when the thread was in power-saving mode, bits [42:45] of SRR1 indicate the exception that caused exit from power-saving mode. bits [46:47] of SRR1 indicate the power-saving mode in which the thread was when the interrupt occured. Signed-off-by: C=C3=A9dric Le Goater --- target/ppc/cpu.h | 21 +++++++++++++++++++++ hw/ppc/pnv.c | 8 ++++---- target/ppc/excp_helper.c | 16 ++++++++-------- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index df5c30160da8..9648623677d2 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -476,6 +476,27 @@ typedef struct ppc_v3_pate_t { #define SRR1_PROTFAULT DSISR_PROTFAULT #define SRR1_IAMR DSISR_AMR =20 +/* SRR1[42:45] wakeup fields for System Reset Interrupt */ + +#define SRR1_WAKEMASK 0x003c0000 /* reason for wakeup */ + +#define SRR1_WAKEHMI 0x00280000 /* Hypervisor maintenance */ +#define SRR1_WAKEHVI 0x00240000 /* Hypervisor Virt. Interrupt (= P9) */ +#define SRR1_WAKEEE 0x00200000 /* External interrupt */ +#define SRR1_WAKEDEC 0x00180000 /* Decrementer interrupt */ +#define SRR1_WAKEDBELL 0x00140000 /* Privileged doorbell */ +#define SRR1_WAKERESET 0x00100000 /* System reset */ +#define SRR1_WAKEHDBELL 0x000c0000 /* Hypervisor doorbell */ +#define SRR1_WAKESCOM 0x00080000 /* SCOM not in power-saving mod= e */ + +/* SRR1[46:47] power-saving exit mode */ + +#define SRR1_WAKESTATE 0x00030000 /* Powersave exit mask */ + +#define SRR1_WS_HVLOSS 0x00030000 /* HV resources not maintained = */ +#define SRR1_WS_GPRLOSS 0x00020000 /* GPRs not maintained */ +#define SRR1_WS_NOLOSS 0x00010000 /* All resources maintained */ + /* Facility Status and Control (FSCR) bits */ #define FSCR_EBB (63 - 56) /* Event-Based Branch Facility */ #define FSCR_TAR (63 - 55) /* Target Address Register */ diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 1b4748ce6dc3..182b62565022 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1986,15 +1986,15 @@ static void pnv_cpu_do_nmi_on_cpu(CPUState *cs, run= _on_cpu_data arg) =20 cpu_synchronize_state(cs); ppc_cpu_do_system_reset(cs); - if (env->spr[SPR_SRR1] & PPC_BITMASK(46, 47)) { + if (env->spr[SPR_SRR1] & SRR1_WAKESTATE) { /* * Power-save wakeups, as indicated by non-zero SRR1[46:47] put the * wakeup reason in SRR1[42:45], system reset is indicated with 0b0100 * (PPC_BIT(43)). */ - if (!(env->spr[SPR_SRR1] & PPC_BIT(43))) { + if (!(env->spr[SPR_SRR1] & SRR1_WAKERESET)) { warn_report("ppc_cpu_do_system_reset does not set system reset= wakeup reason"); - env->spr[SPR_SRR1] |=3D PPC_BIT(43); + env->spr[SPR_SRR1] |=3D SRR1_WAKERESET; } } else { /* @@ -2004,7 +2004,7 @@ static void pnv_cpu_do_nmi_on_cpu(CPUState *cs, run_o= n_cpu_data arg) * another CPU requesting a NMI IPI) system reset exception should be * 0b0010 (PPC_BIT(44)). */ - env->spr[SPR_SRR1] |=3D PPC_BIT(44); + env->spr[SPR_SRR1] |=3D SRR1_WAKESCOM; } } =20 diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 14d39029825a..a988ba15f4f7 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -101,7 +101,7 @@ static int powerpc_reset_wakeup(CPUState *cs, CPUPPCSta= te *env, int excp, env->resume_as_sreset =3D false; =20 /* Pretend to be returning from doze always as we don't lose state */ - *msr |=3D (0x1ull << (63 - 47)); + *msr |=3D SRR1_WS_NOLOSS; =20 /* Machine checks are sent normally */ if (excp =3D=3D POWERPC_EXCP_MCHECK) { @@ -109,25 +109,25 @@ static int powerpc_reset_wakeup(CPUState *cs, CPUPPCS= tate *env, int excp, } switch (excp) { case POWERPC_EXCP_RESET: - *msr |=3D 0x4ull << (63 - 45); + *msr |=3D SRR1_WAKERESET; break; case POWERPC_EXCP_EXTERNAL: - *msr |=3D 0x8ull << (63 - 45); + *msr |=3D SRR1_WAKEEE; break; case POWERPC_EXCP_DECR: - *msr |=3D 0x6ull << (63 - 45); + *msr |=3D SRR1_WAKEDEC; break; case POWERPC_EXCP_SDOOR: - *msr |=3D 0x5ull << (63 - 45); + *msr |=3D SRR1_WAKEDBELL; break; case POWERPC_EXCP_SDOOR_HV: - *msr |=3D 0x3ull << (63 - 45); + *msr |=3D SRR1_WAKEHDBELL; break; case POWERPC_EXCP_HV_MAINT: - *msr |=3D 0xaull << (63 - 45); + *msr |=3D SRR1_WAKEHMI; break; case POWERPC_EXCP_HVIRT: - *msr |=3D 0x9ull << (63 - 45); + *msr |=3D SRR1_WAKEHVI; break; default: cpu_abort(cs, "Unsupported exception %d in Power Save mode\n", --=20 2.25.4