From patchwork Mon Feb 20 04:04:33 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: 9581975 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 C3F2E6047C for ; Mon, 20 Feb 2017 04:11:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3E6828851 for ; Mon, 20 Feb 2017 04:11:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6E3C28857; Mon, 20 Feb 2017 04:11:11 +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 1ECEC28851 for ; Mon, 20 Feb 2017 04:11:10 +0000 (UTC) Received: from localhost ([::1]:35998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cffJc-0005H8-PM for patchwork-qemu-devel@patchwork.kernel.org; Sun, 19 Feb 2017 23:11:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cffDq-0000Gm-EX for qemu-devel@nongnu.org; Sun, 19 Feb 2017 23:05:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cffDo-0002fP-Kt for qemu-devel@nongnu.org; Sun, 19 Feb 2017 23:05:10 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:35135) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cffDj-0002aO-Hq; Sun, 19 Feb 2017 23:05:03 -0500 Received: by mail-pf0-x244.google.com with SMTP id 68so8188416pfx.2; Sun, 19 Feb 2017 20:05:03 -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=Ae4xeXIbtYCtdB0f4X+aqUvdLOAmA5fSCtMVXC0uwD4=; b=lrRh97kz86uZUJ4IjsAeEGrlmvEplBiUQc/Fb3hSL8+ub26sykB5lMLiGJj0WX7xib eMbGDqiwHkDHgRuCFs+U+vk2bWNm1vAyDHs2iOLQrXAIM7HcH/FBy9+xTE117AxmEj8C 3LV0ljPDXmbsE2PqiRUr2PBr0qjXbrZjbtNqqCu5Dyvzd0wLHZEksDwOc50Hoc865kql XbTKOo9w6hnBkHg4oZpqGaoelEKuY+I1s9i5v2+Deh0SizWuhaSENXF7cd9WOf+sNpKv TDSqdH9Bx73Gx1CUCz7B6gopeFfjj9eJwOAg33hZT4mP3TXJv6cBHyuPXzXBF9N/9r2v 6jdA== 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=Ae4xeXIbtYCtdB0f4X+aqUvdLOAmA5fSCtMVXC0uwD4=; b=Uel8YAAF80nuHknpH5DMEj9P7nNOyft0TLTevHXusHb0lusiPOyxUwzfmWsJwy51Kb GD7QIspxz4RGP+nRvrIm6OKSrbSrBY3vt00qDLbYiCrGsU9Sx3VqtHKlvgUTO5TClRXN HMZ3TNYqRFx+tnitmK9gNxYSrxm136JXkZbjI46jsI26VOQZuY3ltpjgjOIKAqrlRTWh ofZHv6Tqqu07u4dCGkrB8nE9NjaLqVXxKkbKyUocL1damuHZQqTqVQGvuXftH+sqsjp+ KvoM7uH6EC6Jgo8hhpNsFMLhsI01lzoXWDiv8pVorM70dgopimCwabdiJIQg4sy+cmcT THWA== X-Gm-Message-State: AMke39klo8F0RI/bckTa7dEdF2zzKJCNkGtSYm7K8VO2dDMp/bAnO9VVKvTCfNe5yT/0MQ== X-Received: by 10.99.36.71 with SMTP id k68mr1184197pgk.68.1487563502589; Sun, 19 Feb 2017 20:05:02 -0800 (PST) Received: from surajjs.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id d78sm31622707pfb.43.2017.02.19.20.04.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Feb 2017 20:05:02 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Mon, 20 Feb 2017 15:04:33 +1100 Message-Id: <1487563478-22265-6-git-send-email-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1487563478-22265-1-git-send-email-sjitindarsingh@gmail.com> References: <1487563478-22265-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::244 Subject: [Qemu-devel] [QEMU-PPC] [PATCH V3 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, sjitindarsingh@gmail.com, 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 --- V2->V3: - Only add patbe to migration stream if non-zero --- 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 e465d7a..2fbf193 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1018,6 +1018,13 @@ static void emulate_spapr_hypercall(PPCVirtualHypervisor *vhyp, } } +static uint64_t spapr_get_patbe(PPCVirtualHypervisor *vhyp) +{ + sPAPRMachineState *spapr = 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_VALID) #define HPTE_DIRTY(_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_HPTE_DIRTY) @@ -1141,6 +1148,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), @@ -1327,6 +1336,24 @@ static const VMStateDescription vmstate_spapr_ov5_cas = { }, }; +static bool spapr_patb_entry_needed(void *opaque) +{ + sPAPRMachineState *spapr = opaque; + + return !!spapr->patb_entry; +} + +static const VMStateDescription vmstate_spapr_patb_entry = { + .name = "spapr_patb_entry", + .version_id = 1, + .minimum_version_id = 1, + .needed = spapr_patb_entry_needed, + .fields = (VMStateField[]) { + VMSTATE_UINT64(patb_entry, sPAPRMachineState), + VMSTATE_END_OF_LIST() + }, +}; + static const VMStateDescription vmstate_spapr = { .name = "spapr", .version_id = 3, @@ -1344,6 +1371,7 @@ static const VMStateDescription vmstate_spapr = { }, .subsections = (const VMStateDescription*[]) { &vmstate_spapr_ov5_cas, + &vmstate_spapr_patb_entry, NULL } }; @@ -2733,6 +2761,7 @@ 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->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..684d632 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1218,6 +1218,7 @@ struct PPCVirtualHypervisor { struct PPCVirtualHypervisorClass { InterfaceClass parent; void (*hypercall)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu); + uint64_t (*get_patbe)(PPCVirtualHypervisor *vhyp); }; #define TYPE_PPC_VIRTUAL_HYPERVISOR "ppc-virtual-hypervisor"