From patchwork Fri Feb 10 05:25:59 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: 9566011 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 64527601EA for ; Fri, 10 Feb 2017 05:36:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 479422844A for ; Fri, 10 Feb 2017 05:36:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B3452854F; Fri, 10 Feb 2017 05:36:13 +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 CD8C62844A for ; Fri, 10 Feb 2017 05:36:12 +0000 (UTC) Received: from localhost ([::1]:41954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cc3sR-0006Y2-O1 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 10 Feb 2017 00:36:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cc3jO-0006tx-U6 for qemu-devel@nongnu.org; Fri, 10 Feb 2017 00:26:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cc3jO-0001h5-3X for qemu-devel@nongnu.org; Fri, 10 Feb 2017 00:26:50 -0500 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:35072) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cc3jL-0001fy-GU; Fri, 10 Feb 2017 00:26:47 -0500 Received: by mail-pf0-x243.google.com with SMTP id b145so843075pfb.2; Thu, 09 Feb 2017 21:26:47 -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=m0hM1FDHMX/ciXzKD+XWcgjADfuYuG7QQ+6nO+uxslc=; b=JqgUhsJ+nxXG/F6wAaKAPW2A3pg9dEVfywTpn5syibLp5N5UuyfEBZu8xWNWdyj6xJ zGX+huvPM5BuGfqNQwW4xWuqOVJ1H5OcnJTnUVDNdK88g1ojDwbmWZnQuRBST6Me72xC Jlfm9fd1KEA1yvg3ftyoK7Z94fSbKT8THaewcYoFK0JIgTlt47ZKrogBmOvXZTHLKlPz REFJT3CvgRrAdA0HsICA2nlbhp/U7glIwf6Wsx0DF8y1TvIopuZRexTAg/IOwDbXatC+ IPbcYGI47DCqqujCbcCoY2HJssdFeq9pCol9Omu7m8+mJWlEe/BrkCH+lh58NtCWBVaA pMNQ== 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=m0hM1FDHMX/ciXzKD+XWcgjADfuYuG7QQ+6nO+uxslc=; b=tU5JkUcpX//1EV5uXViB/JaHZZR/cWPe84qyhD+k/wq5v94fVVgSISZGkfdbAjmAl8 tsUJT9fc2oaJCaayUWQ4dqq4aTv5LTu5Sq5GyAO843LRBMQa0LSn0+Pdj0YcVBWg4YvS eDye0/sDcpbQJ79ngqQLmNLAodQAnwwqCOtOFwkrolMW2I5jk0b3liWV8SxbiD665RQX vN2IiJjTXmtUr4XmwMW526nYCDOKFpVlMXFTxszyyNIRw11C5mMuPm2kKxD6p/xAaBJb TyMXfMOmzddAVyfXtd6c43/es5xqT9lP9CP+paGQsnMVzyPqOMawLKG1dyggcnHvIXh0 5h2Q== X-Gm-Message-State: AMke39nYmQ40Ckd2neagl1HxQm9X33IjaI9v9hJrITqPVnqnhqHcn3RmTeK7awsce/zpuA== X-Received: by 10.98.15.21 with SMTP id x21mr7852647pfi.93.1486704406745; Thu, 09 Feb 2017 21:26:46 -0800 (PST) Received: from surajjs.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id r78sm1308298pfl.63.2017.02.09.21.26.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 21:26:45 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 10 Feb 2017 16:25:59 +1100 Message-Id: <1486704360-27361-10-git-send-email-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1486704360-27361-1-git-send-email-sjitindarsingh@gmail.com> References: <1486704360-27361-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::243 Subject: [Qemu-devel] [QEMU-PPC] [PATCH V2 09/10] 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, Suraj Jitindar Singh , agraf@suse.de, sam.bobroff@au1.ibm.com, 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 a3a23d8..cc8ab1f 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -8776,10 +8776,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"; @@ -8790,6 +8834,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 |