From patchwork Mon Feb 20 04:04:37 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: 9581979 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 9BDD86047C for ; Mon, 20 Feb 2017 04:15:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C90328853 for ; Mon, 20 Feb 2017 04:15:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 806E028857; Mon, 20 Feb 2017 04:15:04 +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 D48DF28853 for ; Mon, 20 Feb 2017 04:15:03 +0000 (UTC) Received: from localhost ([::1]:36018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cffNO-0000Z5-Rt for patchwork-qemu-devel@patchwork.kernel.org; Sun, 19 Feb 2017 23:15:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cffE0-0000dO-PC for qemu-devel@nongnu.org; Sun, 19 Feb 2017 23:05:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cffDz-0002u3-Qq for qemu-devel@nongnu.org; Sun, 19 Feb 2017 23:05:20 -0500 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:34063) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cffDv-0002nu-ML; Sun, 19 Feb 2017 23:05:15 -0500 Received: by mail-pf0-x243.google.com with SMTP id o64so8179912pfb.1; Sun, 19 Feb 2017 20:05:15 -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=bZ9koW0z4met6CqxsNjs/m0uGnNRPQ58t+amqfW542s=; b=Av4Yb4n2ngIDAWz1exPyjEF8aO3ZVFUuSIo1Ilh60QZDU1mrfewyXeW+w9w2hazrt9 qjhakCGn00Y0DUzFUmYJdHBwVFdJvG04/5EH3FVszGwlOh2+CsAerdhTBp+vcOJgwKkT V79exE4ipPpfSidebht/BZ9K5MQcSHrSEuhHfF1MPpkdXQlr5zG2vwYx63ygJljY4V7O nyYTyCwbHir3Ln3W3MdQ69Fiv0YV5kqf5ewwuOOraRnE5VUqg9yMLCqoi+yAyNBij1lm UYrvHr4U41KHal77B6L2XrgY4Hykq8m+ddnJK+rGyffvnguN0qIghG6vP3RG7WZJbBm+ 8Tnw== 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=bZ9koW0z4met6CqxsNjs/m0uGnNRPQ58t+amqfW542s=; b=G9AswmZbAcE59UlLwPvRG4kX9cV6j15gS/3JFaDsBw6l+SfcOYcVV5kuaYHtZt0TER hT9KsEuQpA15wNCC4Fxu6e079Pdvg2lrLLcIsACF4Krdw6hXNarrV6zyIHWg86M19hzR k1TyN++C6oloKvFqRy/Hfi9L3iwqWNKrcnn9IONUjGj6Fm2WgZqMHoDwAK71BlnlTkzL Jiwhw2fbhsm0wXralnwCBPzbVTU8kon3K6G29hWcT0qXK5AygzHDiuoB+HG5NmrAgULp Dzly8KKKeamoD4jKr+jFWPHT/roK2y43vePMkELrj4oKyYaDcB88vjyKSVI0oRl8vHH9 u9JA== X-Gm-Message-State: AMke39kClAZshkN9iFWa23WqcVZWY0bqeawc3M89+m4ZnxM1YXOTywJQzdQXf5Px07FVrA== X-Received: by 10.98.113.9 with SMTP id m9mr23331293pfc.121.1487563514806; Sun, 19 Feb 2017 20:05:14 -0800 (PST) Received: from surajjs.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id d78sm31622707pfb.43.2017.02.19.20.05.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Feb 2017 20:05:14 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Mon, 20 Feb 2017 15:04:37 +1100 Message-Id: <1487563478-22265-10-git-send-email-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1487563478-22265-1-git-send-email-sjitindarsingh@gmail.com> References: <1487563478-22265-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 V3 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, sjitindarsingh@gmail.com, 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 7661c21..840d62e 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -8846,10 +8846,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"; @@ -8860,6 +8904,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 |