From nobody Tue Feb 10 04:29:38 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 1515735411518531.268334226996; Thu, 11 Jan 2018 21:36:51 -0800 (PST) Received: from localhost ([::1]:44292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZs1K-0006ep-Jp for importer@patchew.org; Fri, 12 Jan 2018 00:36:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZryj-0004oa-P5 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 00:34:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZryi-0007QD-Q9 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 00:34:09 -0500 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35256) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZrye-0007LZ-2m; Fri, 12 Jan 2018 00:34:04 -0500 Received: by mail-pf0-x241.google.com with SMTP id t12so3656966pfg.2; Thu, 11 Jan 2018 21:34:03 -0800 (PST) Received: from surajjs1.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id e79sm17253608pfl.61.2018.01.11.21.34.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jan 2018 21:34:02 -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=hNKfBnkU43UC0VWhfEVj4s1tqpc+9kcKm401dG2AXd8=; b=Uj6RAR1rZHuzHYJ5tvAerg63p3+qgXiLmX211bP7veYOXeHnDl1mEbIl9grs9HqkFT dAb0R/01ux8HXTBFh0Mqut+5DJ2xM517/6yzBwhvsYixqnGYwABxcxsF9geKIbmrpTDn t8k/1s9xYgeoAJo2racC0p5dyMEZq3Cpv3AZhWKLbBfUv89zU2V5xbWLOMyIF4sPNe6S e7PIh9mR11Va6rr6yoapAfR4zQgPhlIaHM4Adc6xjrdlf0Et4u/Qxk+oq/u+RXacEV/n GbNwmxtM4d1u5r2MbLD8VYLUGInLPe6TJ9Sfra6rd8z7xK62v3ZczJOqvRq5ZQHbj9R8 ZUKw== 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=hNKfBnkU43UC0VWhfEVj4s1tqpc+9kcKm401dG2AXd8=; b=TrtPhBfBpw1kWe7Js/LI7VjlGwfCuWrF0O/9NE7JVsoiIof/hxpYX82PbR228P1ZBD Rmq8x6lL5fXUMmQLl15RWgjwPDmpNFPcvz8ZYyIZXd+ia7q/M/irkHp5zOY9MVpbvWXC NJvH1qkVSRFqPbyRHkWqUcYY+nXz3wIrktHbs+QgFzKzk9ji/lSqGb5fmbtEZ8CorSi9 Cf7h5tzeS6h+XtA52WgYnGeVsxAwrVtGI3v7gUe/M/g7eGmJdzoty8GJlLoFlDlZKPK5 PO/LFPLoS0gFYvIF3cjZVgcIumMPvQ91gRldbdno3q0JmU7rMJz9j8+Z8VuiQhBTa76Z kVVQ== X-Gm-Message-State: AKwxytc1+MSxQw4BtqSzVpR6NyLb1lZuvz1wbp2HJgIzYgMlAZqBYOW5 eHJqMY3Sl2YF75Ok37LhyiohgHWy X-Google-Smtp-Source: ACJfBovtgSqh7MTgOw9sY0MznhF5yUi2gIEVx8w6IBSg4/vTsMVvb3T+qI51v8TK+kWEnoA4FAO/PQ== X-Received: by 10.159.206.196 with SMTP id x4mr3971486plo.271.1515735242992; Thu, 11 Jan 2018 21:34:02 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 12 Jan 2018 16:33:45 +1100 Message-Id: <20180112053345.13075-4-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180112053345.13075-1-sjitindarsingh@gmail.com> References: <20180112053345.13075-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::241 Subject: [Qemu-devel] [QEMU-PPC] [PATCH 3/3] target/ppc: Add H-Call H_GET_CPU_CHARACTERISTICS 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" The new H-Call H_GET_CPU_CHARACTERISTICS is used by the guest to query behaviours and available characteristics of the cpu. Implement the handler for this new H-Call which formulates its response based on the setting of the new capabilities added in the previous patch. --- hw/ppc/spapr_hcall.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ include/hw/ppc/spapr.h | 1 + 2 files changed, 79 insertions(+) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 51eba52e86..b167554771 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1654,6 +1654,81 @@ static target_ulong h_client_architecture_support(Po= werPCCPU *cpu, return H_SUCCESS; } =20 +/* H_GET_CPU_CHARACTERISTICS return values */ +#define H_CPU_CHAR_SPEC_BAR_ORI31 PPC_BIT(0) +#define H_CPU_CHAR_BCCTRL_SERIALISED PPC_BIT(1) +#define H_CPU_CHAR_L1D_FLUSH_ORI30 PPC_BIT(2) +#define H_CPU_CHAR_L1D_FLUSH_TRIG2 PPC_BIT(3) +#define H_CPU_CHAR_L1D_THREAD_PRIV PPC_BIT(4) +#define H_CPU_CHAR_HON_BRANCH_HINTS PPC_BIT(5) +#define H_CPU_CHAR_THR_RECONF_TRIG PPC_BIT(6) +#define H_CPU_BEHAV_FAVOUR_SECURITY PPC_BIT(0) +#define H_CPU_BEHAV_L1D_FLUSH_PR PPC_BIT(1) +#define H_CPU_BEHAV_BNDS_CHK_SPEC_BAR PPC_BIT(2) + +static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu, + sPAPRMachineState *spapr, + target_ulong opcode, + target_ulong *args) +{ + uint64_t characteristics =3D H_CPU_CHAR_HON_BRANCH_HINTS & + ~H_CPU_CHAR_THR_RECONF_TRIG; + uint64_t behaviour =3D H_CPU_BEHAV_FAVOUR_SECURITY; + uint8_t safe_cache =3D spapr_get_cap(spapr, SPAPR_CAP_CFPC); + uint8_t safe_bounds_check =3D spapr_get_cap(spapr, SPAPR_CAP_SBBC); + uint8_t safe_indirect_branch =3D spapr_get_cap(spapr, SPAPR_CAP_IBS); + + switch (safe_cache) { + case SPAPR_CAP_WORKAROUND: + characteristics |=3D H_CPU_CHAR_L1D_FLUSH_ORI30; + characteristics |=3D H_CPU_CHAR_L1D_FLUSH_TRIG2; + characteristics |=3D H_CPU_CHAR_L1D_THREAD_PRIV; + behaviour |=3D H_CPU_BEHAV_L1D_FLUSH_PR; + break; + case SPAPR_CAP_FIXED: + break; + default: /* broken */ + if (safe_cache !=3D SPAPR_CAP_BROKEN) { + error_report("Invalid value for cap-cfpc (%d), assuming broken= ", + safe_cache); + } + behaviour |=3D H_CPU_BEHAV_L1D_FLUSH_PR; + break; + } + + switch (safe_bounds_check) { + case SPAPR_CAP_WORKAROUND: + characteristics |=3D H_CPU_CHAR_SPEC_BAR_ORI31; + behaviour |=3D H_CPU_BEHAV_BNDS_CHK_SPEC_BAR; + break; + case SPAPR_CAP_FIXED: + break; + default: /* broken */ + if (safe_bounds_check !=3D SPAPR_CAP_BROKEN) { + error_report("Invalid value for cap-sbbc (%d), assuming broken= ", + safe_bounds_check); + } + behaviour |=3D H_CPU_BEHAV_BNDS_CHK_SPEC_BAR; + break; + } + + switch (safe_indirect_branch) { + case SPAPR_CAP_FIXED: + characteristics |=3D H_CPU_CHAR_BCCTRL_SERIALISED; + default: /* broken */ + if (safe_indirect_branch !=3D SPAPR_CAP_BROKEN) { + error_report("Invalid value for cap-ibs (%d), assuming broken", + safe_indirect_branch); + } + break; + } + + args[0] =3D characteristics; + args[1] =3D behaviour; + + return H_SUCCESS; +} + static spapr_hcall_fn papr_hypercall_table[(MAX_HCALL_OPCODE / 4) + 1]; static spapr_hcall_fn kvmppc_hypercall_table[KVMPPC_HCALL_MAX - KVMPPC_HCA= LL_BASE + 1]; =20 @@ -1733,6 +1808,9 @@ static void hypercall_register_types(void) spapr_register_hypercall(H_INVALIDATE_PID, h_invalidate_pid); spapr_register_hypercall(H_REGISTER_PROC_TBL, h_register_process_table= ); =20 + /* hcall-get-cpu-characteristics */ + spapr_register_hypercall(H_GET_CPU_CHARACTERISTICS, h_get_cpu_characte= ristics); + /* "debugger" hcalls (also used by SLOF). Note: We do -not- differenci= ate * here between the "CI" and the "CACHE" variants, they will use whate= ver * mapping attributes qemu is using. When using KVM, the kernel will diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 63ffd422b5..98e76d8b9a 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -392,6 +392,7 @@ struct sPAPRMachineState { #define H_GET_HCA_INFO 0x1B8 #define H_GET_PERF_COUNT 0x1BC #define H_MANAGE_TRACE 0x1C0 +#define H_GET_CPU_CHARACTERISTICS 0x1C8 #define H_FREE_LOGICAL_LAN_BUFFER 0x1D4 #define H_QUERY_INT_STATE 0x1E4 #define H_POLL_PENDING 0x1D8 --=20 2.13.6