From patchwork Fri Jan 19 05:00:03 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: 10174547 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 DA40A60386 for ; Fri, 19 Jan 2018 05:08:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB3F828503 for ; Fri, 19 Jan 2018 05:08:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFA9728511; Fri, 19 Jan 2018 05:08:17 +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 0C62128503 for ; Fri, 19 Jan 2018 05:08:17 +0000 (UTC) Received: from localhost ([::1]:52624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecOuW-0005jO-5n for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Jan 2018 00:08:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecOn7-0007Xm-1R for qemu-devel@nongnu.org; Fri, 19 Jan 2018 00:00:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecOn6-0004sF-3m for qemu-devel@nongnu.org; Fri, 19 Jan 2018 00:00:37 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:45169) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ecOn3-0004qm-HG; Fri, 19 Jan 2018 00:00:33 -0500 Received: by mail-pf0-x242.google.com with SMTP id a88so525627pfe.12; Thu, 18 Jan 2018 21:00:33 -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=ZR6OGJajwFmEguoFBQ2woiEVMOqz6SbpWhMNx5/c7M4=; b=L4CBbi7PI51ZJK+LB5utumGGrnTtwiv5DxR9AgcZstkPO6v3OImflXmRjzfjRzW1FQ kTognDfmePhxL6IoOmGt55AA8zt2cvLh50Hj4L36Le06hxZ2y7iU7cKtdreR92bUaB/C DdHBlmUC0vTI4VnJUDdVz+IzQUMh2kSFRWlCx438VfegJuFY+qI/vMiTrji5ianFLFFg GC4mKoMQJgmZ3GvQMEwv6lPwRO2sIPiDSYr6mSYrwLHyh73IFvqs+v4p7mRz9P7l1kZX 50UQQh5tWw21MbHRRW8f06DOba8hEMyzEp1i+/4NtoB8AGm5FA0HWSItiQllOHF9QaX0 A0JA== 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=ZR6OGJajwFmEguoFBQ2woiEVMOqz6SbpWhMNx5/c7M4=; b=p+CSvSGv9hhwgwZKeZGzjZ5W6LmMrBMG5+ZcDVkH3gaeXRo+s/8Z6PGZgeNXyEQpQn GPVxqampoQEZjMNwWfHPSj96KENvnLkvWQjPjB8ngBsMaX4sAnU9evcRQmbDXUIV07Ff dh/A+VIzSeEQXAmgjhvWYiYJoDq2zJv3bvAPQh/zzvLSjPaeJ7YtrDyzyx+9Oh0y/XBQ S05qIF5a2EzlJlOkA9fpYw/gZ/AgPi3IOc6aZoTerMVfpEN6mcPiChC744jTQjpVmfZY QfW+URnTjnGXDspF+A4RXXMJasbFmhvgMtIHgAHpEk/+n673dYrzNoWPzty8q9IKqJwm SrFA== X-Gm-Message-State: AKwxyte1fLtBJoPU3EHI9gpvY//lbZ465W/e6fcDLLY/BzKa8BCBFpx6 xcRfWgY6rcpswNyfE6T70hVmvCSP X-Google-Smtp-Source: ACJfBovXWQ3mKCUdA+g8fdzGTEzIOhsgcE8lcQBeseArOSEaFWuNXMIncuua3W4w67fSbgeBLrbAzA== X-Received: by 10.101.77.8 with SMTP id i8mr12147318pgt.308.1516338032442; Thu, 18 Jan 2018 21:00:32 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 21:00:31 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 19 Jan 2018 16:00:03 +1100 Message-Id: <20180119050005.29392-6-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 5/7] 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, 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-sbbc to represent the speculation barrier bounds checking 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 | 21 +++++++++++++++++++++ include/hw/ppc/spapr.h | 5 ++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ff8f1aeb59..4cbed31b16 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 } }; @@ -3880,6 +3881,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 d53da63b1c..ce1f74f26d 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, @@ -336,6 +356,7 @@ SPAPR_CAP_MIG_STATE(htm, HTM); SPAPR_CAP_MIG_STATE(vsx, VSX); SPAPR_CAP_MIG_STATE(dfp, DFP); SPAPR_CAP_MIG_STATE(cfpc, CFPC); +SPAPR_CAP_MIG_STATE(sbbc, SBBC); void spapr_caps_reset(sPAPRMachineState *spapr) { 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) {