From nobody Mon Feb 9 20:32:22 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 1488511893883620.67846383209; Thu, 2 Mar 2017 19:31:33 -0800 (PST) Received: from localhost ([::1]:55878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjdwK-0003p8-A8 for importer@patchew.org; Thu, 02 Mar 2017 22:31:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjdqV-00083t-F5 for qemu-devel@nongnu.org; Thu, 02 Mar 2017 22:25:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjdqT-0001LA-Ij for qemu-devel@nongnu.org; Thu, 02 Mar 2017 22:25:31 -0500 Received: from ozlabs.org ([103.22.144.67]:60143) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cjdqT-0001Hh-6p; Thu, 02 Mar 2017 22:25:29 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vZF1S610hz9s7l; Fri, 3 Mar 2017 14:25:16 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1488511516; bh=TbmZvUMbreGKnDyc/3+AqXX7mb2e8cmVMQxxC7mvDwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZBht+6m3Wlafw0Hr1AZiYug6I6zRHIRzPDjYRErGAlcUTr71dgy3h1pgjqZfoHUJw sh1y03paRTN2LHmG8/oMkVsU1qNCYVQC7P5itLWV+Q4Pv9cHbJ+4OIpblF+Azn0d3i KgFZ9OnoOT7qAKJucKFehxMSoAxPtRCkUWk/hZrw= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 3 Mar 2017 14:24:55 +1100 Message-Id: <20170303032507.16142-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170303032507.16142-1-david@gibson.dropbear.id.au> References: <20170303032507.16142-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 05/17] 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: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, agraf@suse.de, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, sjitindarsingh@gmail.com, sam.bobroff@au1.ibm.com, David Gibson 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" From: Suraj Jitindar Singh 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 get_patbe() call. 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 Reviewed-by: David Gibson Signed-off-by: David Gibson --- hw/ppc/spapr.c | 29 +++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 1 + target/ppc/cpu.h | 1 + 3 files changed, 31 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 81c6c1c..1cc5e00 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1055,6 +1055,13 @@ static void emulate_spapr_hypercall(PPCVirtualHyperv= isor *vhyp, } } =20 +static uint64_t spapr_get_patbe(PPCVirtualHypervisor *vhyp) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(vhyp); + + 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) @@ -1234,6 +1241,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), @@ -1427,6 +1436,24 @@ static const VMStateDescription vmstate_spapr_ov5_ca= s =3D { }, }; =20 +static bool spapr_patb_entry_needed(void *opaque) +{ + sPAPRMachineState *spapr =3D opaque; + + return !!spapr->patb_entry; +} + +static const VMStateDescription vmstate_spapr_patb_entry =3D { + .name =3D "spapr_patb_entry", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D spapr_patb_entry_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(patb_entry, sPAPRMachineState), + VMSTATE_END_OF_LIST() + }, +}; + static const VMStateDescription vmstate_spapr =3D { .name =3D "spapr", .version_id =3D 3, @@ -1444,6 +1471,7 @@ static const VMStateDescription vmstate_spapr =3D { }, .subsections =3D (const VMStateDescription*[]) { &vmstate_spapr_ov5_cas, + &vmstate_spapr_patb_entry, NULL } }; @@ -3049,6 +3077,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) vhc->map_hptes =3D spapr_map_hptes; vhc->unmap_hptes =3D spapr_unmap_hptes; vhc->store_hpte =3D spapr_store_hpte; + vhc->get_patbe =3D spapr_get_patbe; xic->ics_get =3D spapr_ics_get; xic->ics_resend =3D spapr_ics_resend; xic->icp_get =3D spapr_icp_get; diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index cfd2711..3258eaa 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 d33c17e..674bb3f 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1216,6 +1216,7 @@ struct PPCVirtualHypervisorClass { hwaddr ptex, int n); void (*store_hpte)(PPCVirtualHypervisor *vhyp, hwaddr ptex, uint64_t pte0, uint64_t pte1); + uint64_t (*get_patbe)(PPCVirtualHypervisor *vhyp); }; =20 #define TYPE_PPC_VIRTUAL_HYPERVISOR "ppc-virtual-hypervisor" --=20 2.9.3