From patchwork Fri Jan 13 06:28:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 9514669 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A1F0601E5 for ; Fri, 13 Jan 2017 06:38:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 730CC285AE for ; Fri, 13 Jan 2017 06:38:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 668A8285D0; Fri, 13 Jan 2017 06:38:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D5D7285AE for ; Fri, 13 Jan 2017 06:38:39 +0000 (UTC) Received: from localhost ([::1]:39327 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRvVW-0007L3-4A for patchwork-qemu-devel@patchwork.kernel.org; Fri, 13 Jan 2017 01:38:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRvMR-0006QS-GH for qemu-devel@nongnu.org; Fri, 13 Jan 2017 01:29:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cRvMQ-00023J-Eo for qemu-devel@nongnu.org; Fri, 13 Jan 2017 01:29:15 -0500 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:36033) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cRvMO-00022U-2f; Fri, 13 Jan 2017 01:29:12 -0500 Received: by mail-pf0-x241.google.com with SMTP id b22so6876692pfd.3; Thu, 12 Jan 2017 22:29:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=R1aT9mLqcL2PSF7vHsem029Bp+GjKsnxglOCpJG5xvY=; b=JPjhTSxEzaQDPa2yx9ij3YtalxfbmQwo1LQYmWZj7nls0ns9VZwDnPyRsuUUxPeauL Dj3Q9faQ2NpzrbvB98rtEKqto+7ILu5nQL9PNlZVcGOU83AHcEUdv6IMgHiZcPX9udgg n2s9NLkPArdMI5SpEImHnElJp1WiRzhSipPBkeF/ThM2RGG8ldX3VZwNdabzgznVfwmy EAopOp5VD2ENq+0u1S2aErCuUzpWAzsn+arowpdvJDEMvQvzoBZw9spIMI8UkRvrEp2n 0xe2frjrKohsu1Z05dK6nhhVqs+4Hl/pq9trt5hg/kLB2xRME+cjg8S9ehmPO56felH3 Uhaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=R1aT9mLqcL2PSF7vHsem029Bp+GjKsnxglOCpJG5xvY=; b=eJwsO5paPFLIKM0VEOheK8FUbeeKvO13P0RRaaLzl2/7BnG6M+5SIr0STnGyIOhjiv JSl+Hxd3nDaPLxm2mn6wWfPbNfswDetEKjkpQnWtwb6jp8wtuGqcJ1wOo+IG3qlLVHzg sFYzZJ10xNsyl03ROExv6hz0YvEbSAZ5hIjcWncps0gaaeWALsHwT8jbg2MB/EcLNTIG udou+LDnrQaMbuBCZbdEtMf8pB3b4q5QnynV1IdbxxUi3zMvy7VNFiu3SMP5m1n94X7q Y80M5zwr09lSVjNopVXNMUlUYLKt4uy9X8O5RjC8P18xVURHVF1NNwqCxIH0L9uukBuc EgCQ== X-Gm-Message-State: AIkVDXLLZzkf1RIY6qCenrr9bBK3jQ9zjqxYCGDtgaro3JMdGPe9/tcWy+/PTicMQZZTUA== X-Received: by 10.98.192.216 with SMTP id g85mr20758855pfk.117.1484288951133; Thu, 12 Jan 2017 22:29:11 -0800 (PST) Received: from dyn253.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id r2sm26004999pfi.67.2017.01.12.22.29.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jan 2017 22:29:10 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 13 Jan 2017 17:28:19 +1100 Message-Id: <1484288903-18807-14-git-send-email-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1484288903-18807-1-git-send-email-sjitindarsingh@gmail.com> References: <1484288903-18807-1-git-send-email-sjitindarsingh@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [RFC PATCH 13/17] target/ppc/POWER9: Add cpu_has_work function for 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: qemu-devel@nongnu.org, agraf@suse.de, Suraj Jitindar Singh , david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The cpu has work function is used to mask interrupts used to determine if there is work for the cpu based on the LPCR. Add a function to do this for POWER9 and add it to the POWER9 cpu definition. This is similar to that for POWER8 except using the LPCR bits as defined for POWER9. Signed-off-by: Suraj Jitindar Singh Reviewed-by: David Gibson --- target/ppc/translate_init.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 87297a7..9db004d 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -8797,10 +8797,54 @@ static bool ppc_pvr_match_power9(PowerPCCPUClass *pcc, uint32_t pvr) return false; } +static bool cpu_has_work_POWER9(CPUState *cs) +{ + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; + + if (cs->halted) { + if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) { + return false; + } + /* External Exception */ + if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) && + (env->spr[SPR_LPCR] & LPCR_EEE)) { + return true; + } + /* Decrementer Exception */ + if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) && + (env->spr[SPR_LPCR] & LPCR_DEE)) { + return true; + } + /* Machine Check or Hypervisor Maintenance Exception */ + if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK | + 1u << PPC_INTERRUPT_HMI)) && (env->spr[SPR_LPCR] & LPCR_OEE)) { + return true; + } + /* Privileged Doorbell Exception */ + if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) && + (env->spr[SPR_LPCR] & LPCR_PDEE)) { + return true; + } + /* Hypervisor Doorbell Exception */ + if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) && + (env->spr[SPR_LPCR] & LPCR_HDEE)) { + return true; + } + if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) { + return true; + } + return false; + } else { + return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD); + } +} + POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); + CPUClass *cc = CPU_CLASS(oc); dc->fw_name = "PowerPC,POWER9"; dc->desc = "POWER9"; @@ -8811,6 +8855,7 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data) PCR_COMPAT_2_05; pcc->init_proc = init_proc_POWER9; pcc->check_pow = check_pow_nocheck; + cc->has_work = cpu_has_work_POWER9; pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |