From patchwork Fri Jan 19 05:00:02 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: 10174543 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 4001360386 for ; Fri, 19 Jan 2018 05:05:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 247AE284D1 for ; Fri, 19 Jan 2018 05:05:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 156BC284F5; Fri, 19 Jan 2018 05:05:39 +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 C9D46284D1 for ; Fri, 19 Jan 2018 05:05:37 +0000 (UTC) Received: from localhost ([::1]:52467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecOrx-0003MI-0f for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Jan 2018 00:05:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecOn5-0007Wq-QH for qemu-devel@nongnu.org; Fri, 19 Jan 2018 00:00:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecOn4-0004rl-RY for qemu-devel@nongnu.org; Fri, 19 Jan 2018 00:00:35 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:44661) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ecOn0-0004q6-UW; Fri, 19 Jan 2018 00:00:31 -0500 Received: by mail-pf0-x242.google.com with SMTP id m26so530183pfj.11; Thu, 18 Jan 2018 21:00:30 -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=Mo5SwhWD7QMs1hH/sC099MTslZX/Cfi7l6V1DcxjFf4=; b=eyDprReYojcCXXoCeu6bDFhoYr68wtLpvJhGSKqnjPMV+aPCM8eSfUJy3rbQkhNOXK TM7VsBoxUS4O7/lD28rsjCSIVkpeU9DdrOdtxf0wFKLaxjZVmLXV/c8JUnHp06wdeO4S 7mj+XQXqMg9WiMZswNILd0+2I+Eat+0G90b3ApE6mf8nKz7wu4TTqYlJ5uyWYYuLv135 E5rEhR03JHvosJw97bi7Bir5ybRPMMBKROfkyazooS/rfPZ8wCi9sJdCp2Rr3SN24fr6 +UqFPy1JEohN8HwhbX0+E+8nIr6cExjZPDsjO+2mOfYLkbvQsdatc9PDTPgfQp460VOP S5uA== 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=Mo5SwhWD7QMs1hH/sC099MTslZX/Cfi7l6V1DcxjFf4=; b=DVVt441b8mWRm8rrhsn3APPrxz+wC39fSiGf2iM69jXWLojveRCwtm9cvE4rjGx5tZ aQmmcpPBOatYvpVorzST/WzGZqVNEiWuctCJkw2mQwYgvhCIMVyrc+BEdFOUwrmH1zcC E77PbZlnUgfAtTsA4p5AbdvGBlq9XVjWFLC+56ra70LYzSdTe/HDtp3tm0Ma11W4Hk7y cocJBUi+j4QjionktnWK3tpENsecspNxR/pqRymFN/VUWytArdUdP/bnjiXzKwh8MIX1 q5V+Ta+Ko9g1spmtuVGZBYpcq4PQVOYVVzJ8tD2pCaGGsRYuaUEP2nEo8KuH4UP9euN3 earw== X-Gm-Message-State: AKwxytfH7bqFzdkyPKyRbUm/ZpZv6/YB125Vns9SFiG1DaDD/9L5KpkL yCDILPrVb3rQJmPASbq8LAvFZ5za X-Google-Smtp-Source: ACJfBotvakQ8USGfla/1odgCtsovbsKZos93pM4vq/hViZeOkIfvx3kVh87fnf6VnhMnCfRgmcto2A== X-Received: by 10.101.66.193 with SMTP id l1mr22188794pgp.17.1516338029636; Thu, 18 Jan 2018 21:00:29 -0800 (PST) Received: from surajjs1.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id i128sm14653163pfg.83.2018.01.18.21.00.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 21:00:29 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 19 Jan 2018 16:00:02 +1100 Message-Id: <20180119050005.29392-5-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180119050005.29392-1-sjitindarsingh@gmail.com> References: <20180119050005.29392-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 V5 4/7] 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, Suraj Jitindar Singh , 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 --- V4 -> V5: - Use macro to generate migration state --- hw/ppc/spapr.c | 2 ++ hw/ppc/spapr_caps.c | 36 ++++++++++++++++++++++++++---------- include/hw/ppc/spapr.h | 5 ++++- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 02e45dd010..ff8f1aeb59 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 } }; @@ -3878,6 +3879,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 d6f82b18fc..d53da63b1c 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -73,11 +73,8 @@ static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name, spapr->eff.caps[cap->index] = value ? SPAPR_CAP_ON : SPAPR_CAP_OFF; } -static void __attribute__ ((unused)) spapr_cap_get_tristate(Object *obj, - Visitor *v, - const char *name, - void *opaque, - Error **errp) +static void spapr_cap_get_tristate(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { sPAPRCapabilityInfo *cap = opaque; sPAPRMachineState *spapr = SPAPR_MACHINE(obj); @@ -103,11 +100,8 @@ static void __attribute__ ((unused)) spapr_cap_get_tristate(Object *obj, g_free(val); } -static void __attribute__ ((unused)) spapr_cap_set_tristate(Object *obj, - Visitor *v, - const char *name, - void *opaque, - Error **errp) +static void spapr_cap_set_tristate(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { sPAPRCapabilityInfo *cap = opaque; sPAPRMachineState *spapr = SPAPR_MACHINE(obj); @@ -186,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] = { @@ -215,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, @@ -320,6 +335,7 @@ const VMStateDescription vmstate_spapr_cap_##cap = { \ SPAPR_CAP_MIG_STATE(htm, HTM); SPAPR_CAP_MIG_STATE(vsx, VSX); SPAPR_CAP_MIG_STATE(dfp, DFP); +SPAPR_CAP_MIG_STATE(cfpc, CFPC); void spapr_caps_reset(sPAPRMachineState *spapr) { 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) {