From nobody Tue Feb 10 08:01:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148670506606766.14516090936979; Thu, 9 Feb 2017 21:37:46 -0800 (PST) Received: from localhost ([::1]:41964 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cc3tw-0008Dh-Qe for importer@patchew.org; Fri, 10 Feb 2017 00:37:44 -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) 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) 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) 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 sec= ond 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 en= try 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 gue= st memory. Since we only have a single guest per qemu instance, we only need o= ne entry. Since the partition table is technically a hypervisor resource we require t= hat 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(PPCVirtualHyperv= isor *vhyp, } } =20 +static void spapr_set_patbe(PPCVirtualHypervisor *vhyp, uint64_t val) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); + + spapr->patb_entry =3D val; +} + +static uint64_t spapr_get_patbe(PPCVirtualHypervisor *vhyp) +{ + sPAPRMachineState *spapr =3D 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_VAL= ID) #define HPTE_DIRTY(_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_HPT= E_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); =20 + spapr->patb_entry =3D 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 =3D { VMSTATE_UINT64_TEST(rtc_offset, sPAPRMachineState, version_before_= 3), =20 VMSTATE_PPC_TIMEBASE_V(tb, sPAPRMachineState, 2), + VMSTATE_UINT64(patb_entry, sPAPRMachineState), VMSTATE_END_OF_LIST() }, .subsections =3D (const VMStateDescription*[]) { @@ -2733,6 +2750,8 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) nc->nmi_monitor_handler =3D spapr_nmi; smc->phb_placement =3D spapr_phb_placement; vhc->hypercall =3D emulate_spapr_hypercall; + vhc->set_patbe =3D spapr_set_patbe; + vhc->get_patbe =3D spapr_get_patbe; } =20 static const TypeInfo spapr_machine_info =3D { 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 { =20 void *htab; uint32_t htab_shift; + uint64_t patb_entry; /* Process tbl registed in H_REGISTER_PROCESS_TAB= LE */ 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); }; =20 #define TYPE_PPC_VIRTUAL_HYPERVISOR "ppc-virtual-hypervisor" --=20 2.5.5