From nobody Tue Feb 10 19:48:00 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 1515998318025945.9799060940778; Sun, 14 Jan 2018 22:38:38 -0800 (PST) Received: from localhost ([::1]:41158 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eayPl-0003Yq-6w for importer@patchew.org; Mon, 15 Jan 2018 01:38:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eayKW-0007qf-Rr for qemu-devel@nongnu.org; Mon, 15 Jan 2018 01:33:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eayKV-0006tT-MZ for qemu-devel@nongnu.org; Mon, 15 Jan 2018 01:33:12 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:42182) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eayKQ-0006q2-82; Mon, 15 Jan 2018 01:33:06 -0500 Received: by mail-pf0-x242.google.com with SMTP id b25so1309085pfd.9; Sun, 14 Jan 2018 22:33:06 -0800 (PST) Received: from surajjs1.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id 13sm62362864pfs.112.2018.01.14.22.33.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Jan 2018 22:33:04 -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=Yt40lKC2CHvBNaVNEhOGrdl6r1TgH8tseJVUlTs/AFo=; b=kTxgwatRxOseT0enBTDoJ4/eBzyEGWMGM+hbonKlv0oTMSoDDvjn1PVn60M4wAWsZ6 b9pGfdWjTMJ6CqUlNiKU9bTj4sB/vLo8L4/fs8/GAD2DFHkT5NH/iXMdxai2MfEd/BTb g5yJzEeL+X7CrH4qWuevVZPHY1ledVzhE85dyfYuOo90AxpYvV+UNgXh5zfJBCY9vvUl a3mOYt1JjU9sBmtGEkT7Cl1Q9241Hej0ahhRjtZyjAAWdLr9tqshC2DgfIxFtyU0up4R EQ5F+Oqo/zXemAxzfszZoqJj1KzKYHmUKdB0Xqqx2nDWYO4HGnMW+Xqbe5/yeZlc0rrs VgVA== 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=Yt40lKC2CHvBNaVNEhOGrdl6r1TgH8tseJVUlTs/AFo=; b=ZbC29tiCHYh9iwwt8sM/RZLhvnN3uMERmuBuqZB1gMjTjzfnAKkRldMB4cY7A2UtzF fXqSaF06sX9EVMGgx5wcsnTD0E1zFtXv4ONvmRTIhKoc41YCRKU6tdqktXONDSXWJQ3R J2V3C2uzyLsl5CFQ6LCfSJYXwgZ80AUTdRSH9ta4BxPvjtXXyUkUYM9mGFPMG1zChRIM q4DgnjtwQ+TbRQ2im4AZOydLrQVNsgG8tLyrmgjHYwYTUpUwwyrjqUTLCc77F/S2sF/v u9gdRICcLWnQ5j4QAb6CfISw+IzvK9i2IBikKRLxC+mchWtVnE2+b6ES5GvlVIxrwSGA fxdQ== X-Gm-Message-State: AKwxytdzRP8AyEmHZI2tOV0MiWnS3hzlrwhwuzo8NNE3XDQrnbJOxIvy h46f2MDOqqRC6zRT8CmcqM1JDJBq X-Google-Smtp-Source: ACJfBovLq68PYj1xPqNW2/6S5cR6xvDMN0gVvAO1vntnHKwIJWl0E3AlJJlxd7tOsaJmlhgxBm2FWA== X-Received: by 10.99.123.91 with SMTP id k27mr15247865pgn.179.1515997985118; Sun, 14 Jan 2018 22:33:05 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Mon, 15 Jan 2018 17:32:32 +1100 Message-Id: <20180115063235.7518-4-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180115063235.7518-1-sjitindarsingh@gmail.com> References: <20180115063235.7518-1-sjitindarsingh@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [QEMU-PPC] [PATCH V3 3/6] target/ppc/spapr_caps: Add new tristate cap safe_cache 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: paulus@ozlabs.org, qemu-devel@nongnu.org, sjitindarsingh@gmail.com, david@gibson.dropbear.id.au 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" Add new tristate cap cap-cfpc to represent the cache flush on privilege change capability. Signed-off-by: Suraj Jitindar Singh Reviewed-by: David Gibson --- hw/ppc/spapr.c | 2 ++ hw/ppc/spapr_caps.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 5 ++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 3e528fe91e..5d62dc9968 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1791,6 +1791,7 @@ static const VMStateDescription vmstate_spapr =3D { &vmstate_spapr_cap_htm, &vmstate_spapr_cap_vsx, &vmstate_spapr_cap_dfp, + &vmstate_spapr_cap_cfpc, NULL } }; @@ -3863,6 +3864,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) smc->default_caps.caps[SPAPR_CAP_HTM] =3D SPAPR_CAP_OFF; smc->default_caps.caps[SPAPR_CAP_VSX] =3D SPAPR_CAP_ON; smc->default_caps.caps[SPAPR_CAP_DFP] =3D SPAPR_CAP_ON; + smc->default_caps.caps[SPAPR_CAP_CFPC] =3D SPAPR_CAP_BROKEN; spapr_caps_add_properties(smc, &error_abort); } =20 diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index 436250d77b..bc2b2c3590 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -180,6 +180,18 @@ static void cap_dfp_apply(sPAPRMachineState *spapr, ui= nt8_t val, Error **errp) } } =20 +static void cap_safe_cache_apply(sPAPRMachineState *spapr, uint8_t val, + Error **errp) +{ + if (tcg_enabled() && val) { + /* TODO - for now only allow broken for TCG */ + error_setg(errp, "Requested safe cache capability level not suppor= ted by tcg, try a different value for cap-cfpc"); + } else if (kvm_enabled() && (val > kvmppc_get_cap_safe_cache())) { + error_setg(errp, "Requested safe cache capability level not suppor= ted by kvm, try a different value for cap-cfpc"); + } +} + +#define VALUE_DESC_TRISTATE " (broken, workaround, fixed)" =20 sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] =3D { [SPAPR_CAP_HTM] =3D { @@ -209,6 +221,15 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = =3D { .type =3D "bool", .apply =3D cap_dfp_apply, }, + [SPAPR_CAP_CFPC] =3D { + .name =3D "cfpc", + .description =3D "Cache Flush on Privilege Change" VALUE_DESC_TRIS= TATE, + .index =3D SPAPR_CAP_CFPC, + .get =3D spapr_cap_get_tristate, + .set =3D spapr_cap_set_tristate, + .type =3D "string", + .apply =3D cap_safe_cache_apply, + }, }; =20 static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, @@ -345,6 +366,25 @@ const VMStateDescription vmstate_spapr_cap_dfp =3D { }, }; =20 +static bool spapr_cap_cfpc_needed(void *opaque) +{ + sPAPRMachineState *spapr =3D opaque; + + return spapr->cmd_line_caps[SPAPR_CAP_CFPC] && + (spapr->eff.caps[SPAPR_CAP_CFPC] !=3D spapr->def.caps[SPAPR_CAP= _CFPC]); +} + +const VMStateDescription vmstate_spapr_cap_cfpc =3D { + .name =3D "spapr/cap/cfpc", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D spapr_cap_cfpc_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(mig.caps[SPAPR_CAP_CFPC], sPAPRMachineState), + VMSTATE_END_OF_LIST() + }, +}; + void spapr_caps_reset(sPAPRMachineState *spapr) { sPAPRCapabilities default_caps; diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 61bb3632c4..ff476693d1 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -60,8 +60,10 @@ typedef enum { #define SPAPR_CAP_VSX 0x01 /* Decimal Floating Point */ #define SPAPR_CAP_DFP 0x02 +/* Cache Flush on Privilege Change */ +#define SPAPR_CAP_CFPC 0x03 /* Num Caps */ -#define SPAPR_CAP_NUM (SPAPR_CAP_DFP + 1) +#define SPAPR_CAP_NUM (SPAPR_CAP_CFPC + 1) =20 /* * Capability Values @@ -779,6 +781,7 @@ int spapr_caps_pre_save(void *opaque); extern const VMStateDescription vmstate_spapr_cap_htm; extern const VMStateDescription vmstate_spapr_cap_vsx; extern const VMStateDescription vmstate_spapr_cap_dfp; +extern const VMStateDescription vmstate_spapr_cap_cfpc; =20 static inline uint8_t spapr_get_cap(sPAPRMachineState *spapr, int cap) { --=20 2.13.6