From patchwork Fri Jan 13 06:28:16 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: 9514675 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 285B560762 for ; Fri, 13 Jan 2017 06:45:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 156F9285E8 for ; Fri, 13 Jan 2017 06:45:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 067FD285ED; Fri, 13 Jan 2017 06:45:00 +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 B47A4285E1 for ; Fri, 13 Jan 2017 06:44:58 +0000 (UTC) Received: from localhost ([::1]:39371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRvbd-0004qG-Rb for patchwork-qemu-devel@patchwork.kernel.org; Fri, 13 Jan 2017 01:44:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRvMM-0006Jw-F0 for qemu-devel@nongnu.org; Fri, 13 Jan 2017 01:29:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cRvML-00021q-BX for qemu-devel@nongnu.org; Fri, 13 Jan 2017 01:29:10 -0500 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:34151) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cRvME-00020C-QY; Fri, 13 Jan 2017 01:29:02 -0500 Received: by mail-pf0-x243.google.com with SMTP id y143so6914152pfb.1; Thu, 12 Jan 2017 22:29:02 -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=dPdga5yr0nQRXfUXDGmZK+JFo1chaKA/PfcU4N8cmyY=; b=R+ahPfcCHrWXekQKP/eNiOGk3KuhIVrvRuAkcf1mstnqDLvfYil0StLun9RiKX5WyQ kOfYhLOH1rQGXdsYdFrUHUkNr1Sb1D8y+M1CoGcuaF0dIuosN28/sXo9IZX8LjxBlUDR j2OwUb2dUuxzC1MEcc0+OmVXLUaeYmNYr1/Tl9fs8dQEq/qCGDtwDCkgorTs4SVm1vXz RscEopQrK+FGS6JBjolhYIXqsRoCJeF1qXT6KpOxpVwd9o6zd0MO+gWp5DZQ9tvudFcH YwQzC5DSj3/O6Y5A79XyiRvzSs0cIiK6NCIRIyP6jDJKP4ZrjQz51gSDfE+FZoDO9fSq S6Ag== 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=dPdga5yr0nQRXfUXDGmZK+JFo1chaKA/PfcU4N8cmyY=; b=dZki84N/cVkjtv7vazSEpWgxXyaq5nHTUi2DZhLdTcMMlA2no6qFXyjsu6phfvMs5R EoXDhCS3QmnmsQvUjyncLjT+Ju3qnqS7mmtyH9AXmmVtJoJiZxwfSRmm1/F/LhLoqcZf Gb4/V8bfta6I9NKi+JvXDc3uLtjeRKvkP0LuYUGODU8HdzuoGHVdZHMls+PI/ZYAqsiu f7KX2Kkpy+S+aF1VI90pH872bmopsSj8QK+7qJOk3LW+i53L+Orz4SaPKwcEYqB6wj6J NPnQX7yfx1eiMs+lNZb8Jf40+00+61slV48MTeVn/1LKO1RJ07+OvnCQg5GClBqGQdlS HV7g== X-Gm-Message-State: AIkVDXILBtJjHPZ1LCerrzl/vhw366MRC8yp49a7W7uuF34SwSbX3YOlb1h1e4Y1p/hLUw== X-Received: by 10.84.217.66 with SMTP id e2mr27584958plj.109.1484288941886; Thu, 12 Jan 2017 22:29:01 -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.28.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jan 2017 22:29:01 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 13 Jan 2017 17:28:16 +1100 Message-Id: <1484288903-18807-11-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::243 Subject: [Qemu-devel] [RFC PATCH 10/17] target/ppc/POWER9: Add POWER9 mmu fault handler 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 Add a new mmu fault handler for the POWER9 cpu and add it as the handler for the POWER9 cpu definition. This handler checks if the guest is radix or hash based on the value in the partition table entry and calls the correct fault handler accordingly. The hash fault handling code has also been updated to check if the partition is using segment tables. Currently only legacy hash (no segment tables) is supported. Signed-off-by: Suraj Jitindar Singh --- target/ppc/mmu-hash64.c | 8 ++++++++ target/ppc/mmu.h | 8 ++++++++ target/ppc/mmu_helper.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ target/ppc/translate_init.c | 2 +- 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c index b9d4f4e..b476b3f 100644 --- a/target/ppc/mmu-hash64.c +++ b/target/ppc/mmu-hash64.c @@ -73,6 +73,14 @@ static ppc_slb_t *slb_lookup(PowerPCCPU *cpu, target_ulong eaddr) } } + /* Check if in-memory segment tables are in use */ + if (ppc64_use_proc_tbl(cpu)) { + /* TODO - Unsupported */ + qemu_log_mask(LOG_UNIMP, "%s: unimplemented - segment table support\n", + __func__); + /* Not much we can do here, caller will generate a segment interrupt */ + } + return NULL; } diff --git a/target/ppc/mmu.h b/target/ppc/mmu.h index c7967c3..e07b128 100644 --- a/target/ppc/mmu.h +++ b/target/ppc/mmu.h @@ -3,6 +3,10 @@ #ifndef CONFIG_USER_ONLY +/* Common Partition Table Entry Fields */ +#define PATBE0_HR 0x8000000000000000 +#define PATBE1_GR 0x8000000000000000 + /* Partition Table Entry */ struct patb_entry { uint64_t patbe0, patbe1; @@ -11,6 +15,10 @@ struct patb_entry { #ifdef TARGET_PPC64 void ppc64_set_external_patb(PowerPCCPU *cpu, void *patb, Error **errp); +bool ppc64_use_proc_tbl(PowerPCCPU *cpu); +bool ppc64_radix_guest(PowerPCCPU *cpu); +int ppc64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx, + int mmu_idx); #endif /* TARGET_PPC64 */ diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c index bc6c117..612f407 100644 --- a/target/ppc/mmu_helper.c +++ b/target/ppc/mmu_helper.c @@ -28,6 +28,7 @@ #include "exec/cpu_ldst.h" #include "exec/log.h" #include "helper_regs.h" +#include "qemu/error-report.h" #include "mmu.h" //#define DEBUG_MMU @@ -1281,6 +1282,17 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUPPCState *env) case POWERPC_MMU_2_07a: dump_slb(f, cpu_fprintf, ppc_env_get_cpu(env)); break; + case POWERPC_MMU_3_00: + if (ppc64_radix_guest(ppc_env_get_cpu(env))) { + /* TODO - Unsupported */ + } else { + if (ppc64_use_proc_tbl(ppc_env_get_cpu(env))) { + /* TODO - Unsupported */ + } else { + dump_slb(f, cpu_fprintf, ppc_env_get_cpu(env)); + break; + } + } #endif default: qemu_log_mask(LOG_UNIMP, "%s: unimplemented\n", __func__); @@ -1422,6 +1434,17 @@ hwaddr ppc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) case POWERPC_MMU_2_07: case POWERPC_MMU_2_07a: return ppc_hash64_get_phys_page_debug(cpu, addr); + case POWERPC_MMU_3_00: + if (ppc64_radix_guest(ppc_env_get_cpu(env))) { + /* TODO - Unsupported */ + } else { + if (ppc64_use_proc_tbl(ppc_env_get_cpu(env))) { + /* TODO - Unsupported */ + } else { + return ppc_hash64_get_phys_page_debug(cpu, addr); + } + } + break; #endif case POWERPC_MMU_32B: @@ -2919,3 +2942,27 @@ void ppc64_set_external_patb(PowerPCCPU *cpu, void *patb, Error **errp) env->external_patbe = (struct patb_entry *) patb; } + +inline bool ppc64_use_proc_tbl(PowerPCCPU *cpu) +{ + return !!(cpu->env.spr[SPR_LPCR] & LPCR_UPRT); +} + +inline bool ppc64_radix_guest(PowerPCCPU *cpu) +{ + struct patb_entry *patbe = cpu->env.external_patbe; + + return patbe && (patbe->patbe1 & PATBE1_GR); +} + +int ppc64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx, + int mmu_idx) +{ + if (ppc64_radix_guest(cpu)) { /* Guest uses radix */ + /* TODO - Unsupported */ + error_report("Guest Radix Support Unimplemented\n"); + abort(); + } else { /* Guest uses hash */ + return ppc_hash64_handle_mmu_fault(cpu, eaddr, rwx, mmu_idx); + } +} diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index c771ba3..87297a7 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -8850,7 +8850,7 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data) (1ull << MSR_LE); pcc->mmu_model = POWERPC_MMU_3_00; #if defined(CONFIG_SOFTMMU) - pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault; + pcc->handle_mmu_fault = ppc64_handle_mmu_fault; /* segment page size remain the same */ pcc->sps = &POWER7_POWER8_sps; #endif