From nobody Tue Apr 30 11:48:31 2024 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.zohomail.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 1528209641720425.47862510814207; Tue, 5 Jun 2018 07:40:41 -0700 (PDT) Received: from localhost ([::1]:47232 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQD8a-0004fZ-7j for importer@patchew.org; Tue, 05 Jun 2018 10:40:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQD6m-0003Oq-T3 for qemu-devel@nongnu.org; Tue, 05 Jun 2018 10:38:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQD6j-0004sI-KN for qemu-devel@nongnu.org; Tue, 05 Jun 2018 10:38:48 -0400 Received: from 2.mo179.mail-out.ovh.net ([178.33.250.45]:46762) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQD6j-0004rY-Dx for qemu-devel@nongnu.org; Tue, 05 Jun 2018 10:38:45 -0400 Received: from player787.ha.ovh.net (unknown [10.109.105.119]) by mo179.mail-out.ovh.net (Postfix) with ESMTP id 96890CC09F for ; Tue, 5 Jun 2018 16:38:43 +0200 (CEST) Received: from bahia.lan (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player787.ha.ovh.net (Postfix) with ESMTPA id 374BD6000CA; Tue, 5 Jun 2018 16:38:36 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 05 Jun 2018 16:38:30 +0200 Message-ID: <152820951004.885713.15116723374602433120.stgit@bahia.lan> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 11561584671524166044 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedthedrjeefgdejkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.250.45 Subject: [Qemu-devel] [PATCH v3] target/ppc: migrate VPA related state 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: Paul Mackerras , qemu-ppc@nongnu.org, Michael Roth , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 QEMU implements the "Shared Processor LPAR" (SPLPAR) option, which allows the hypervisor to time-slice a physical processor into multiple virtual processor. The intent is to allow more guests to run, and to optimize processor utilization. The guest OS can cede idle VCPUs, so that their processing capacity may be used by other VCPUs, with the H_CEDE hcall. The guest OS can also optimize spinlocks, by confering the time-slice of a spinning VCPU to the spinlock holder if it's currently notrunning, with the H_CONFER hcall. Both hcalls depend on a "Virtual Processor Area" (VPA) to be registered by the guest OS, generally during early boot. Other per-VCPU areas can be registered: the "SLB Shadow Buffer" which allows a more efficient dispatching of VCPUs, and the "Dispatch Trace Log Buffer" (DTL) which is used to compute time stolen by the hypervisor. Both DTL and SLB Shadow areas depend on the VPA to be registered. The VPA/SLB Shadow/DTL are state that QEMU should migrate, but this doesn't happen, for no apparent reason other than it was just never coded. This causes the features listed above to stop working after migration, and it breaks the logic of the H_REGISTER_VPA hcall in the destination. This patch fixes it for newer machine types (ie, version > 2.12) by adding a "cpu/vpa" subsection to the CPU migration stream. It ensures backward migration to existing QEMU versions. Since DTL and SLB Shadow are optional and both depend on VPA, they get their own subsections "cpu/vpa/slb_shadow" and "cpu/vpa/dtl" hanging from the "cpu/vpa" subsection. Signed-off-by: Greg Kurz --- v3: - switched to pre_3_0_migration v2: - added missing TARGET_PP64 ifdefs (patchew) --- target/ppc/machine.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 62 insertions(+) diff --git a/target/ppc/machine.c b/target/ppc/machine.c index b2745ec4e519..d439f5cd4961 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -677,6 +677,67 @@ static const VMStateDescription vmstate_compat =3D { } }; =20 +static bool slb_shadow_needed(void *opaque) +{ + PowerPCCPU *cpu =3D opaque; + + return cpu->env.slb_shadow_addr !=3D 0; +} + +static const VMStateDescription vmstate_slb_shadow =3D { + .name =3D "cpu/vpa/slb_shadow", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D slb_shadow_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(env.slb_shadow_addr, PowerPCCPU), + VMSTATE_UINT64(env.slb_shadow_size, PowerPCCPU), + VMSTATE_END_OF_LIST() + } +}; + +static bool dtl_needed(void *opaque) +{ + PowerPCCPU *cpu =3D opaque; + + return cpu->env.dtl_addr !=3D 0; +} + +static const VMStateDescription vmstate_dtl =3D { + .name =3D "cpu/vpa/dtl", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D dtl_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(env.dtl_addr, PowerPCCPU), + VMSTATE_UINT64(env.dtl_size, PowerPCCPU), + VMSTATE_END_OF_LIST() + } +}; + +static bool vpa_needed(void *opaque) +{ + PowerPCCPU *cpu =3D opaque; + + return !cpu->pre_3_0_migration && cpu->env.vpa_addr !=3D 0; +} + +static const VMStateDescription vmstate_vpa =3D { + .name =3D "cpu/vpa", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D vpa_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(env.vpa_addr, PowerPCCPU), + VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * []) { + &vmstate_slb_shadow, + &vmstate_dtl, + NULL + } +}; + const VMStateDescription vmstate_ppc_cpu =3D { .name =3D "cpu", .version_id =3D 5, @@ -731,6 +792,7 @@ const VMStateDescription vmstate_ppc_cpu =3D { &vmstate_tlbemb, &vmstate_tlbmas, &vmstate_compat, + &vmstate_vpa, NULL } };