From patchwork Fri Jan 13 06:28:13 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: 9514645 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 E50D0601E5 for ; Fri, 13 Jan 2017 06:34:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE7AD284F9 for ; Fri, 13 Jan 2017 06:34:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D21FA28723; Fri, 13 Jan 2017 06:34:31 +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 AE86C284F9 for ; Fri, 13 Jan 2017 06:34:30 +0000 (UTC) Received: from localhost ([::1]:39294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRvRV-0002vy-8L for patchwork-qemu-devel@patchwork.kernel.org; Fri, 13 Jan 2017 01:34:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRvMD-0006Bo-EF for qemu-devel@nongnu.org; Fri, 13 Jan 2017 01:29:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cRvMC-0001zB-CD for qemu-devel@nongnu.org; Fri, 13 Jan 2017 01:29:01 -0500 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:33329) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cRvM5-0001xZ-Q1; Fri, 13 Jan 2017 01:28:53 -0500 Received: by mail-pf0-x241.google.com with SMTP id 127so6889357pfg.0; Thu, 12 Jan 2017 22:28:53 -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=OCFwEsw6KnReAL47BUdvSiGfbFhQEr2dD7EBqQATt90=; b=CsIIu8kdv3rLEmx5j+BchTfhRadoINeNyW2ynZea7vwTPYwBYE5vUGJlISZNvdMx+r ZEdE9vOBOhPl86baUehkZeloqW38HhtQn+Ek7HVebZWCrkBaYtK6NzWNYhjBteanUabl i9dd9/Lj2rdNEKnXoTXbNPIgTAbdxiVocAxnAdEGIGS1YzAP4BGGj3WRlQDFvEWUK3XE 2G9f1AqtqSACL82b3k1RNetGh2CLlEAArbn4D/jzneefqfnIYvo/IfbI6qYAoA4VGvKC p3FSSBDmxVh+3mjTo0tC0m3oO6yJw1XSBX1mbPw7HHc99yXEpLfjv9XKVV+H2Q10yZTd UQsw== 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=OCFwEsw6KnReAL47BUdvSiGfbFhQEr2dD7EBqQATt90=; b=Bu/1g5YdpTMjuhH5UTin1mpoiI66XAAM/2c5WU3haWICFjY2JTobKkQBaCvhvM7ifQ IKVTMknA+/FEr0bEwJGr84iGYGyFrs7eVNildy7PRth4TBfSZd4mG8XsaVujhbjeTtet 4Gnu7GjwmmXjWNBk+JUAGSwd6OGTbrXcWz+/Mg26Mpgfnb9SUlyps1FGe4bcv8QLVqA1 TkSpCR2AS8i/BY9poN+sf2U8bOh9B1eu00GevAtT8Zg+Qm5FrncCyTTnozNrLDfzh/YZ YvkS2RxNKJmkSDg10Qd+GoU13N7NIYXMmShnSZ4+QA0oUVtvddNpeRBdKdQRiwIiWd4Y cFVQ== X-Gm-Message-State: AIkVDXLT4Xfy+uvzNdG/oA4DzdVEaSICkwRgil/oMOWghihgcbbKntl6GHFTCt8FsjvDEA== X-Received: by 10.84.133.129 with SMTP id f1mr27003608plf.64.1484288932912; Thu, 12 Jan 2017 22:28:52 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jan 2017 22:28:52 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 13 Jan 2017 17:28:13 +1100 Message-Id: <1484288903-18807-8-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 07/17] target/ppc/POWER9: Add partition table pointer to sPAPRMachineState 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 POWER9 uses a partition table to store information relating to how address translation is performed on a per partition basis. Add a data area for this to the sPAPRMachineState struct and (re)allocate it on machine reset. Signed-off-by: Suraj Jitindar Singh --- hw/ppc/spapr.c | 38 ++++++++++++++++++++++++++++++++------ include/hw/ppc/spapr.h | 1 + target/ppc/mmu.h | 13 +++++++++++++ 3 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 target/ppc/mmu.h diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 208ef7b..45bd2de 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -41,6 +41,7 @@ #include "migration/migration.h" #include "mmu-hash64.h" #include "qom/cpu.h" +#include "mmu.h" #include "hw/boards.h" #include "hw/ppc/ppc.h" @@ -1115,6 +1116,26 @@ static void spapr_reallocate_hpt(sPAPRMachineState *spapr, int shift, } } +static void spapr_reallocate_patb(sPAPRMachineState *spapr, Error **errp) +{ + g_free(spapr->patb); + spapr->patb = NULL; + + if (!kvm_enabled()) { + /* We need to allocate a partition table entry */ + size_t size = sizeof(struct patb_entry); + + spapr->patb = qemu_memalign(size, size); + if (!spapr->patb) { + error_setg_errno(errp, errno, "Could not allocate memory for " + "partition table entry"); + return; + } + + memset(spapr->patb, 0, size); + } +} + static void find_unknown_sysbus_device(SysBusDevice *sbdev, void *opaque) { bool matched = false; @@ -1134,7 +1155,7 @@ static void ppc_spapr_reset(void) { MachineState *machine = MACHINE(qdev_get_machine()); sPAPRMachineState *spapr = SPAPR_MACHINE(machine); - PowerPCCPU *first_ppc_cpu; + PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu); uint32_t rtas_limit; hwaddr rtas_addr, fdt_addr; void *fdt; @@ -1143,10 +1164,16 @@ static void ppc_spapr_reset(void) /* Check for unknown sysbus devices */ foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL); - /* Allocate and/or reset the hash page table */ - spapr_reallocate_hpt(spapr, - spapr_hpt_shift_for_ramsize(machine->maxram_size), - &error_fatal); + switch (first_ppc_cpu->env.mmu_model) { + case POWERPC_MMU_3_00: + /* Allocate the partition table */ + spapr_reallocate_patb(spapr, &error_fatal); + default: + /* Allocate and/or reset the hash page table */ + spapr_reallocate_hpt(spapr, + spapr_hpt_shift_for_ramsize(machine->maxram_size), + &error_fatal); + } /* Update the RMA size if necessary */ if (spapr->vrma_adjust) { @@ -1193,7 +1220,6 @@ static void ppc_spapr_reset(void) g_free(fdt); /* Set up the entry state */ - first_ppc_cpu = POWERPC_CPU(first_cpu); first_ppc_cpu->env.gpr[3] = fdt_addr; first_ppc_cpu->env.gpr[5] = 0; first_cpu->halted = 0; diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index bd5bcf7..b654773 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -63,6 +63,7 @@ struct sPAPRMachineState { void *htab; uint32_t htab_shift; + void *patb; hwaddr rma_size; int vrma_adjust; ssize_t rtas_size; diff --git a/target/ppc/mmu.h b/target/ppc/mmu.h new file mode 100644 index 0000000..67b9707 --- /dev/null +++ b/target/ppc/mmu.h @@ -0,0 +1,13 @@ +#ifndef MMU_H +#define MMU_H + +#ifndef CONFIG_USER_ONLY + +/* Partition Table Entry */ +struct patb_entry { + uint64_t patbe0, patbe1; +}; + +#endif /* CONFIG_USER_ONLY */ + +#endif /* MMU_H */