From patchwork Fri Feb 10 05:25:55 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: 9566013 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 D2B3F601EA for ; Fri, 10 Feb 2017 05:36:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE6312843A for ; Fri, 10 Feb 2017 05:36:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2B4E2854F; Fri, 10 Feb 2017 05:36:41 +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 2F6292843A for ; Fri, 10 Feb 2017 05:36:41 +0000 (UTC) Received: from localhost ([::1]:41957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cc3su-0006wI-8q for patchwork-qemu-devel@patchwork.kernel.org; Fri, 10 Feb 2017 00:36:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cc3jB-0006K8-Oc for qemu-devel@nongnu.org; Fri, 10 Feb 2017 00:26:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cc3jA-0001bE-GX for qemu-devel@nongnu.org; Fri, 10 Feb 2017 00:26:37 -0500 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:35716) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cc3j5-0001Zx-Sd; Fri, 10 Feb 2017 00:26:32 -0500 Received: by mail-pg0-x241.google.com with SMTP id 204so2200772pge.2; Thu, 09 Feb 2017 21:26:31 -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=IoE9u474s98ohhvXeptESpieBTQT79l+jYO8QvdzUNI=; b=G3zyrTMqnK2RnJm4K0q/iMK0/eEde8jxLWC8Rn1m1WZCeXiwiiR3QZHlFCsbICc6yC G7fbWE5GlFVt/bkJvxJa1zbT7CMvFDjZ/3lex9IIVF6YicZnH/Q3Sp1HQ3fwVmEY07Yq x/kHo49qtLiTrUpEYI9o53S+jjjX2hkP8LwEyFR60Obh89vO1jrsBNfW5NIPyGl59nQy Xc7myWOyqx8nSnPHwbB8G/AZmx0q2Z/pgkFfvEbq44wPx+rk9vxkcECkjVcNSbdxEx4R putuILmR9uEXY+2eueXxtLOWu5zmRiHI64Okx3AhCCnkc8iyTLUZPNsrHnqUUqzLGQM0 R8Hg== 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=IoE9u474s98ohhvXeptESpieBTQT79l+jYO8QvdzUNI=; b=LvzCpPY2f0OHfQECu7OjAgg9HR4yuGg0AO0yCqAnKQFZeoPI1LWET3CHkMCrRkY2+8 48nKDdoFSkoU42XahXa+T9+/9xcuHiOZkKTeS0FUTIdeJouP9ZsOxi5GTZ9UAZJDv/pc 4cO6Ohnj/fmhOT1I6DDzOA32IqUUMVDpXXCD57yBS/3H3oGjXYD61e1vwOvC86T1f2Fz 7GhbTLYKnsjz/ZfI9EQ5vtwSRSzNP1iUwz0+xaVugFfDSsNlmZQE9x8Tq51xQnURBK5v ekWw9IZ2QY6dEsRzFDvf5aBsh9is6Bx9NLf0MiRIJ9rFWaFUircD2aA+wd+YPuUEJh3H qo1Q== X-Gm-Message-State: AMke39kdAD2mk6XZkd/JlMcDGkxpElGzT0N5DUNih9iaaIGf+9I1kNu+Qw/PmFsOS3m/Eg== X-Received: by 10.98.55.66 with SMTP id e63mr8086053pfa.156.1486704391097; Thu, 09 Feb 2017 21:26:31 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 21:26:30 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 10 Feb 2017 16:25:55 +1100 Message-Id: <1486704360-27361-6-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:c05::241 Subject: [Qemu-devel] [QEMU-PPC] [PATCH V2 05/10] target/ppc: Add patb_entry 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, 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 ISA v3.00 adds the idea of a partition table which is used to store the address translation details for all partitions on the system. The partition table consists of double word entries indexed by partition id where the second double word contains the location of the process table in guest memory. The process table is registered by the guest via a h-call. We need somewhere to store the address of the process table so we add an entry to the sPAPRMachineState struct called patb_entry to represent the second doubleword of a single partition table entry corresponding to the current guest. We need to store this value so we know if the guest is using radix or hash translation and the location of the corresponding process table in guest memory. Since we only have a single guest per qemu instance, we only need one entry. Since the partition table is technically a hypervisor resource we require that access to it is abstracted by the virtual hypervisor through the calls [set/get]_patbe(). Currently the value of the entry is never set (and thus defaults to 0 indicating hash), but it will be required to both implement POWER9 kvm support and tcg radix support. We also add this field to be migrated as part of the sPAPRMachineState as we will need it on the receiving side as the guest will never tell us this information again and we need it to perform translation. Signed-off-by: Suraj Jitindar Singh --- hw/ppc/spapr.c | 19 +++++++++++++++++++ include/hw/ppc/spapr.h | 1 + target/ppc/cpu.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e465d7a..057adae 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1018,6 +1018,20 @@ static void emulate_spapr_hypercall(PPCVirtualHypervisor *vhyp, } } +static void spapr_set_patbe(PPCVirtualHypervisor *vhyp, uint64_t val) +{ + sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); + + spapr->patb_entry = val; +} + +static uint64_t spapr_get_patbe(PPCVirtualHypervisor *vhyp) +{ + sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); + + return spapr->patb_entry; +} + #define HPTE(_table, _i) (void *)(((uint64_t *)(_table)) + ((_i) * 2)) #define HPTE_VALID(_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_VALID) #define HPTE_DIRTY(_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_HPTE_DIRTY) @@ -1141,6 +1155,8 @@ static void ppc_spapr_reset(void) /* Check for unknown sysbus devices */ foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL); + spapr->patb_entry = 0; + /* Allocate and/or reset the hash page table */ spapr_reallocate_hpt(spapr, spapr_hpt_shift_for_ramsize(machine->maxram_size), @@ -1340,6 +1356,7 @@ static const VMStateDescription vmstate_spapr = { VMSTATE_UINT64_TEST(rtc_offset, sPAPRMachineState, version_before_3), VMSTATE_PPC_TIMEBASE_V(tb, sPAPRMachineState, 2), + VMSTATE_UINT64(patb_entry, sPAPRMachineState), VMSTATE_END_OF_LIST() }, .subsections = (const VMStateDescription*[]) { @@ -2733,6 +2750,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) nc->nmi_monitor_handler = spapr_nmi; smc->phb_placement = spapr_phb_placement; vhc->hypercall = emulate_spapr_hypercall; + vhc->set_patbe = spapr_set_patbe; + vhc->get_patbe = spapr_get_patbe; } static const TypeInfo spapr_machine_info = { diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index a2d8964..c6a929a 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; + uint64_t patb_entry; /* Process tbl registed in H_REGISTER_PROCESS_TABLE */ hwaddr rma_size; int vrma_adjust; ssize_t rtas_size; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 425e79d..a148729 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1218,6 +1218,8 @@ struct PPCVirtualHypervisor { struct PPCVirtualHypervisorClass { InterfaceClass parent; void (*hypercall)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu); + void (*set_patbe)(PPCVirtualHypervisor *vhyp, uint64_t val); + uint64_t (*get_patbe)(PPCVirtualHypervisor *vhyp); }; #define TYPE_PPC_VIRTUAL_HYPERVISOR "ppc-virtual-hypervisor"