From nobody Tue Feb 10 17:08: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.zohomail.com; dkim=fail; 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 1524119715019673.788373264613; Wed, 18 Apr 2018 23:35:15 -0700 (PDT) Received: from localhost ([::1]:53162 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f93A2-0001Jq-7V for importer@patchew.org; Thu, 19 Apr 2018 02:35:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f934S-0005Z4-Sw for qemu-devel@nongnu.org; Thu, 19 Apr 2018 02:29:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f934O-0005Qc-8J for qemu-devel@nongnu.org; Thu, 19 Apr 2018 02:29:28 -0400 Received: from ozlabs.org ([203.11.71.1]:59861) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f934N-0005Ov-Ry; Thu, 19 Apr 2018 02:29:24 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 40RTbj2ZbPz9s2M; Thu, 19 Apr 2018 16:29:21 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1524119361; bh=MDJY9vDXEccULjJhRfFv5QyA/0T6mUcbgP+hcHmvZus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dtPuSbvszdSTxhVPL7M5JahRcMoKPKVvD6xxhYhm0Q2ZatvSI/BBX8S4up9alPPQ7 1nqMexDzp5o2IJetii917B/phIieRP7sdt6nLMo4by6f2q0jRhOTRJsfldYCnuS/o8 rXStUAJnpmP6DxxUOOb2ApMzNPj3LSzYrHhdgqy4= From: David Gibson To: groug@kaod.org, abologna@redhat.com Date: Thu, 19 Apr 2018 16:29:14 +1000 Message-Id: <20180419062917.31486-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180419062917.31486-1-david@gibson.dropbear.id.au> References: <20180419062917.31486-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: 203.11.71.1 Subject: [Qemu-devel] [RFC for-2.13 4/7] spapr: Add cpu_apply hook to capabilities 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: aik@ozlabs.ru, David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, clg@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" spapr capabilities have an apply hook to actually activate (or deactivate) the feature in the system at reset time. However, a number of capabilities affect the setup of cpus, and need to be applied to each of them - including hotplugged cpus for extra complication. To make this simpler, add an optional cpu_apply hook that is called from spapr_cpu_reset(). Signed-off-by: David Gibson --- hw/ppc/spapr_caps.c | 19 +++++++++++++++++++ hw/ppc/spapr_cpu_core.c | 2 ++ include/hw/ppc/spapr.h | 1 + 3 files changed, 22 insertions(+) diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index 5762b88689..e71de14ffb 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -61,6 +61,8 @@ typedef struct sPAPRCapabilityInfo { sPAPRCapPossible *possible; /* Make sure the virtual hardware can support this capability */ void (*apply)(sPAPRMachineState *spapr, uint8_t val, Error **errp); + void (*cpu_apply)(sPAPRMachineState *spapr, PowerPCCPU *cpu, + uint8_t val, Error **errp); } sPAPRCapabilityInfo; =20 static void spapr_cap_get_bool(Object *obj, Visitor *v, const char *name, @@ -547,6 +549,23 @@ void spapr_caps_reset(sPAPRMachineState *spapr) } } =20 +void spapr_caps_cpu_reset(sPAPRMachineState *spapr, PowerPCCPU *cpu) +{ + int i; + + for (i =3D 0; i < SPAPR_CAP_NUM; i++) { + sPAPRCapabilityInfo *info =3D &capability_table[i]; + + /* + * If the apply function can't set the desired level and thinks it= 's + * fatal, it should cause that. + */ + if (info->cpu_apply) { + info->cpu_apply(spapr, cpu, spapr->eff.caps[i], &error_fatal); + } + } +} + void spapr_caps_add_properties(sPAPRMachineClass *smc, Error **errp) { Error *local_err =3D NULL; diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 0a668b8954..f041182593 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -67,6 +67,8 @@ static void spapr_cpu_reset(void *opaque) =20 /* Set a full AMOR so guest can use the AMR as it sees fit */ env->spr[SPR_AMOR] =3D 0xffffffffffffffffull; + + spapr_caps_cpu_reset(SPAPR_MACHINE(qdev_get_machine()), cpu); } =20 void spapr_cpu_set_entry_state(PowerPCCPU *cpu, target_ulong nip, target_u= long r3) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index a3d616c612..ced3246d0e 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -802,6 +802,7 @@ static inline uint8_t spapr_get_cap(sPAPRMachineState *= spapr, int cap) } =20 void spapr_caps_reset(sPAPRMachineState *spapr); +void spapr_caps_cpu_reset(sPAPRMachineState *spapr, PowerPCCPU *cpu); void spapr_caps_add_properties(sPAPRMachineClass *smc, Error **errp); int spapr_caps_post_migration(sPAPRMachineState *spapr); =20 --=20 2.14.3