From patchwork Mon Jan 15 06:32:33 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: 10163159 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 A0513601C0 for ; Mon, 15 Jan 2018 06:34:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8324A28920 for ; Mon, 15 Jan 2018 06:34:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 771EA28926; Mon, 15 Jan 2018 06:34:59 +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 EA22928920 for ; Mon, 15 Jan 2018 06:34:58 +0000 (UTC) Received: from localhost ([::1]:41101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eayME-0000jp-7h for patchwork-qemu-devel@patchwork.kernel.org; Mon, 15 Jan 2018 01:34:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eayKX-0007r0-2M for qemu-devel@nongnu.org; Mon, 15 Jan 2018 01:33:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eayKW-0006tq-4N for qemu-devel@nongnu.org; Mon, 15 Jan 2018 01:33:13 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:41676) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eayKS-0006rm-UE; Mon, 15 Jan 2018 01:33:09 -0500 Received: by mail-pf0-x242.google.com with SMTP id j3so7595371pfh.8; Sun, 14 Jan 2018 22:33:08 -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=RLkMFWIb6s0irXUs+zSkbL0IEW/z1i8OpEAnlVEd9WA=; b=pDUV1O+qNrLnnk6Mv7onJygMtwfxMl2fv6RxpfBNS684uEV8uU0Yjtq3490iMV1vCV mr3C4LTGCZXruagoqfzn2qPWLPJDJr0p6IlnD6ooLd3fVNtEWOxkqohjtVZiOXwOggqm PPCAxu+EYLI+Fxw2Z0wyPl8V/YCl0zfl/RTHp615rJjPctYjGtw4xkgff2p6OOAbO1vH 1MKZbsTz7sazBugbnJXZRQhRaYrLSl9snEThoHjYL8+zKa0C4ZPtZTrSbY6gBVXB9z5o z6L9Awg09nfPKI7JqqenY0re6kEifYEoNytYQKVMMhsTBndgkmvH9UT4ZWWzfppsas4i Bcpg== 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=RLkMFWIb6s0irXUs+zSkbL0IEW/z1i8OpEAnlVEd9WA=; b=P9Aq0mgjavqlTuwN9so9nn0uVucx/DAE/bZAumhS4pCNk24homy/4z/pQ2MBdB7lzQ n3MwEya+ppycpE8SL9K5s7iQwzQnsXhQcw/r+3ekD+KugqmolbWwKDFmWC7yrDORlQOk b4FHlXL4Y2s8djvEWatdrBK0yXx959tEeb1qPhBZk6JWVUVIe5Pmj6BxFLpff8OpYCPj mRbInjaIELubcRM0hTLggukafc+RKPfbxXm2Xy4qK1nnkUA+PFkTHBku6zzitx+ndtpB 4S/e/2YjcY6SOmCXRYqMbjxNcdZQKJFDBPBaXwUo5NnnFnjCQ4oIIf5VxIlQeFbR7+KD JWuA== X-Gm-Message-State: AKGB3mIdGKiVSIEfga19Rgg1GvZt+mfQaLbvjwcYBpvFPnty0RK+eE2D 1cmGFTowJ0NcHsAFVQqnUi/hOitu X-Google-Smtp-Source: ACJfBotruZo18JXcQIEa/icJcMHyrEp6Y7v6r3hSGSDLGrmbYmB2y7FpQ9nx5bmnaZhFeF1J8+/V0w== X-Received: by 10.99.42.83 with SMTP id q80mr26100077pgq.183.1515997987831; Sun, 14 Jan 2018 22:33:07 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Jan 2018 22:33:07 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Mon, 15 Jan 2018 17:32:33 +1100 Message-Id: <20180115063235.7518-5-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 4/6] target/ppc/spapr_caps: Add new tristate cap safe_bounds_check 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-sbbc to represent the speculation barrier bounds checking capability. Signed-off-by: Suraj Jitindar Singh Reviewed-by: David Gibson --- hw/ppc/spapr.c | 2 ++ hw/ppc/spapr_caps.c | 39 +++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 5 ++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 5d62dc9968..02a0cb656b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1792,6 +1792,7 @@ static const VMStateDescription vmstate_spapr = { &vmstate_spapr_cap_vsx, &vmstate_spapr_cap_dfp, &vmstate_spapr_cap_cfpc, + &vmstate_spapr_cap_sbbc, NULL } }; @@ -3865,6 +3866,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) 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; + smc->default_caps.caps[SPAPR_CAP_SBBC] = 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 bc2b2c3590..518e019cf7 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -191,6 +191,17 @@ static void cap_safe_cache_apply(sPAPRMachineState *spapr, uint8_t val, } } +static void cap_safe_bounds_check_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 bounds check capability level not supported by tcg, try a different value for cap-sbbc"); + } else if (kvm_enabled() && (val > kvmppc_get_cap_safe_bounds_check())) { + error_setg(errp, "Requested safe bounds check capability level not supported by kvm, try a different value for cap-sbbc"); + } +} + #define VALUE_DESC_TRISTATE " (broken, workaround, fixed)" sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = { @@ -230,6 +241,15 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = { .type = "string", .apply = cap_safe_cache_apply, }, + [SPAPR_CAP_SBBC] = { + .name = "sbbc", + .description = "Speculation Barrier Bounds Checking" VALUE_DESC_TRISTATE, + .index = SPAPR_CAP_SBBC, + .get = spapr_cap_get_tristate, + .set = spapr_cap_set_tristate, + .type = "string", + .apply = cap_safe_bounds_check_apply, + }, }; static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, @@ -385,6 +405,25 @@ const VMStateDescription vmstate_spapr_cap_cfpc = { }, }; +static bool spapr_cap_sbbc_needed(void *opaque) +{ + sPAPRMachineState *spapr = opaque; + + return spapr->cmd_line_caps[SPAPR_CAP_SBBC] && + (spapr->eff.caps[SPAPR_CAP_SBBC] != spapr->def.caps[SPAPR_CAP_SBBC]); +} + +const VMStateDescription vmstate_spapr_cap_sbbc = { + .name = "spapr/cap/sbbc", + .version_id = 1, + .minimum_version_id = 1, + .needed = spapr_cap_sbbc_needed, + .fields = (VMStateField[]) { + VMSTATE_UINT8(mig.caps[SPAPR_CAP_SBBC], 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 ff476693d1..c65be62e92 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -62,8 +62,10 @@ typedef enum { #define SPAPR_CAP_DFP 0x02 /* Cache Flush on Privilege Change */ #define SPAPR_CAP_CFPC 0x03 +/* Speculation Barrier Bounds Checking */ +#define SPAPR_CAP_SBBC 0x04 /* Num Caps */ -#define SPAPR_CAP_NUM (SPAPR_CAP_CFPC + 1) +#define SPAPR_CAP_NUM (SPAPR_CAP_SBBC + 1) /* * Capability Values @@ -782,6 +784,7 @@ 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; +extern const VMStateDescription vmstate_spapr_cap_sbbc; static inline uint8_t spapr_get_cap(sPAPRMachineState *spapr, int cap) {