From patchwork Mon Jan 15 06:32:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 10163167 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 6717A601C0 for ; Mon, 15 Jan 2018 06:38:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C8B928856 for ; Mon, 15 Jan 2018 06:38:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4048E28926; Mon, 15 Jan 2018 06:38:08 +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 B63D928856 for ; Mon, 15 Jan 2018 06:38:07 +0000 (UTC) Received: from localhost ([::1]:41158 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eayPH-0003Yq-1K for patchwork-qemu-devel@patchwork.kernel.org; Mon, 15 Jan 2018 01:38:07 -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) 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) 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) 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 = { &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] = SPAPR_CAP_OFF; smc->default_caps.caps[SPAPR_CAP_VSX] = SPAPR_CAP_ON; smc->default_caps.caps[SPAPR_CAP_DFP] = SPAPR_CAP_ON; + smc->default_caps.caps[SPAPR_CAP_CFPC] = SPAPR_CAP_BROKEN; spapr_caps_add_properties(smc, &error_abort); } 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, uint8_t val, Error **errp) } } +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 supported 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 supported by kvm, try a different value for cap-cfpc"); + } +} + +#define VALUE_DESC_TRISTATE " (broken, workaround, fixed)" sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = { [SPAPR_CAP_HTM] = { @@ -209,6 +221,15 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = { .type = "bool", .apply = cap_dfp_apply, }, + [SPAPR_CAP_CFPC] = { + .name = "cfpc", + .description = "Cache Flush on Privilege Change" VALUE_DESC_TRISTATE, + .index = SPAPR_CAP_CFPC, + .get = spapr_cap_get_tristate, + .set = spapr_cap_set_tristate, + .type = "string", + .apply = cap_safe_cache_apply, + }, }; static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, @@ -345,6 +366,25 @@ const VMStateDescription vmstate_spapr_cap_dfp = { }, }; +static bool spapr_cap_cfpc_needed(void *opaque) +{ + sPAPRMachineState *spapr = opaque; + + return spapr->cmd_line_caps[SPAPR_CAP_CFPC] && + (spapr->eff.caps[SPAPR_CAP_CFPC] != spapr->def.caps[SPAPR_CAP_CFPC]); +} + +const VMStateDescription vmstate_spapr_cap_cfpc = { + .name = "spapr/cap/cfpc", + .version_id = 1, + .minimum_version_id = 1, + .needed = spapr_cap_cfpc_needed, + .fields = (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) /* * 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; static inline uint8_t spapr_get_cap(sPAPRMachineState *spapr, int cap) {