From nobody Mon May 13 20:12:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1566881943; cv=none; d=zoho.com; s=zohoarc; b=euVQtYDoqSkW25XZUMjBPtJcAmNUALtTZxGUFvmX3vdbHB3Fb4kVa+V0RgV4lxdnWMn+4c55sFvf0lfCrgtWBXMVgO1GaF4AYftP+05O5II8jtVSvHKgf2zwgY4p8hyEDwuW8SUlnmNTnWyOBkDXrNT1mub2cSDWCUrJTRHDlA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566881943; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=P25ICHlvC9T2Gq4NKXejplGEdwCcHrENc9J7umEtneY=; b=AoMXiQBRodh1oh/OxjAYV7mXcRhkbEGC5L0uO+Z2hH8CBue0SZUYthrOTjMpMO/8bEJ0/FZ2KQv/gmeESznGrFm6jlNE+kGcMuOgws8WLEbgPgLE3sg8I97sQLY3bcVWtnuyclmo8XUZFpYYDBruATzgC5SgzygqGmSLP9YKU4k= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566881943534648.0927943512193; Mon, 26 Aug 2019 21:59:03 -0700 (PDT) Received: from localhost ([::1]:46644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2TZH-0007G1-3W for importer@patchew.org; Tue, 27 Aug 2019 00:58:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36843) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2TYW-0006hv-Ja for qemu-devel@nongnu.org; Tue, 27 Aug 2019 00:58:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2TYV-0004hw-EU for qemu-devel@nongnu.org; Tue, 27 Aug 2019 00:58:08 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:36786) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2TYS-0004e7-Id; Tue, 27 Aug 2019 00:58:04 -0400 Received: by mail-pl1-x641.google.com with SMTP id f19so11146657plr.3; Mon, 26 Aug 2019 21:58:03 -0700 (PDT) Received: from localhost.majoof.com (150.24.220.111.sta.wbroadband.net.au. [111.220.24.150]) by smtp.gmail.com with ESMTPSA id t189sm14535883pfd.58.2019.08.26.21.58.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Aug 2019 21:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=P25ICHlvC9T2Gq4NKXejplGEdwCcHrENc9J7umEtneY=; b=gEj2MMjtrUKk35Id62KIdE4iZ3VhdM6oF+p5AqVXcEtWOJtyIztJPz+5rTrg4429VX TwraiyUA0OVQXBYi/U84KWf6G1LbUGXSrtnEPKerbrtKOXCVQ9hNQkNSiBg1SWeZ1JQr vt1tdR65IqIKqt7Ou+0X1USSpvJUXrQEvZ279bZkum5Oy8fg0hN7hrt0elm6Ui7aijQg 4BBzkZB0M9NIQUC8y6yktevXikEzyf8Jka1puUwAuTY0S73P2eHzi1ovEsrVtxSPxmpW 9eQ4sPUkXUNgCP3HMMC7OzQ2SeW/jVDLOL1GA7pt6DiQ5/6t1fvIj+axbu/W1r+cr12n XUxw== 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; bh=P25ICHlvC9T2Gq4NKXejplGEdwCcHrENc9J7umEtneY=; b=EK8ASxUQ8iDOWkARu4pVUlI/sCR+ZKe3Vai3tjvc3ioFl/lHeVRfkLIQwu1TmmuM7e O9lgDNKcHQnql/cL5aell9IWrNgEGivIB3i023qyKwHOdnDXrH2+OvrB6wt3FmNkRWI5 cFT3O6WH6pZb1Va6l12zekcYI+BNztG9wjPXekDnsu/Cx3o5WbbSpc2dDQhUDc5Vu6J1 ebPvH6W+zdEZV2RoYqz/zqQD15ZhrPcdF6jJMw3FW2Wt8Ed7SmSQ3KWbfb2RSZoSvLNA 8scFZAt1M7nmP3oxvM9Uqb63QiRTjfxqcr4RhJf0vVAkhWTi0EagAMfhSiugVENggdMk n0FQ== X-Gm-Message-State: APjAAAWq1Dh5DzADP+3Sp1ExuIiblkohUMJGXUXOkRm+rZHyQLuDvXFX JlAKJSlkkWQ3ninU8/0Ejc/KTdPC X-Google-Smtp-Source: APXvYqxeP5e+pEEzTAsCdlsa8i7Ma5v0KK2GnWtla/b3XyWV7wVtK3DhN5QN6Xq/Hf69mV/unS6SAw== X-Received: by 2002:a17:902:a410:: with SMTP id p16mr22519249plq.150.1566881882515; Mon, 26 Aug 2019 21:58:02 -0700 (PDT) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Tue, 27 Aug 2019 14:57:51 +1000 Message-Id: <20190827045751.22123-1-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [QEMU-PPC] [PATCH V4] powerpc/spapr: Add host threads parameter to ibm, get_system_parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Suraj Jitindar Singh , 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) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The ibm,get_system_parameter rtas call is used by the guest to retrieve data relating to certain parameters of the system. The SPLPAR characteristics option (token 20) is used to determine characteristics of the environment in which the lpar will run. It may be useful for a guest to know the number of physical host threads present on the underlying system where it is being run. Add the characteristic "HostThrs" to the SPLPAR Characteristics ibm,get_system_parameter rtas call to expose this information to a guest. Add a n_host_threads property to the processor class which is then used to retrieve this information and define it for POWER8 and POWER9. Other processors will default to 0 and the charateristic won't be added. Signed-off-by: Suraj Jitindar Singh --- V1 -> V2: - Take into account that the core may be operating in split core mode meaning a single core may be split into multiple subcores. V2 -> V3: - Add curly braces for single line if statements V3 -> V4; - Add a host threads property to the processor class and use this to derive the information rather than the device tree. --- hw/ppc/spapr_rtas.c | 15 +++++++++++++++ target/ppc/cpu-qom.h | 1 + target/ppc/translate_init.inc.c | 2 ++ 3 files changed, 18 insertions(+) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 526b489297..bee3835214 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -266,6 +266,7 @@ static void rtas_ibm_get_system_parameter(PowerPCCPU *c= pu, target_ulong args, uint32_t nret, target_ulong rets) { + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); MachineState *ms =3D MACHINE(qdev_get_machine()); unsigned int max_cpus =3D ms->smp.max_cpus; target_ulong parameter =3D rtas_ld(args, 0); @@ -283,6 +284,20 @@ static void rtas_ibm_get_system_parameter(PowerPCCPU *= cpu, current_machine->ram_size / MiB, ms->smp.cpus, max_cpus); + if (pcc->n_host_threads > 0) { + char *hostthr_val, *old =3D param_val; + + /* + * Add HostThrs property. This property is not present in PAPR= but + * is expected by some guests to communicate the number of phy= sical + * host threads per core on the system so that they can scale + * information which varies based on the thread configuration. + */ + hostthr_val =3D g_strdup_printf(",HostThrs=3D%d", pcc->n_host_= threads); + param_val =3D g_strconcat(param_val, hostthr_val, NULL); + g_free(hostthr_val); + g_free(old); + } ret =3D sysparm_st(buffer, length, param_val, strlen(param_val) + = 1); g_free(param_val); break; diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 7ffdb0a706..e499575dc8 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -191,6 +191,7 @@ typedef struct PowerPCCPUClass { const PPCHash64Options *hash64_opts; struct ppc_radix_page_info *radix_page_info; uint32_t lrg_decr_bits; + int n_host_threads; void (*init_proc)(CPUPPCState *env); int (*check_pow)(CPUPPCState *env); int (*handle_mmu_fault)(PowerPCCPU *cpu, vaddr eaddr, int rwx, int mmu= _idx); diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 4a21ed7289..41f77b7ef8 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -8770,6 +8770,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) pcc->handle_mmu_fault =3D ppc_hash64_handle_mmu_fault; pcc->hash64_opts =3D &ppc_hash64_opts_POWER7; pcc->lrg_decr_bits =3D 32; + pcc->n_host_threads =3D 8; #endif pcc->excp_model =3D POWERPC_EXCP_POWER8; pcc->bus_model =3D PPC_FLAGS_INPUT_POWER7; @@ -8981,6 +8982,7 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data) pcc->hash64_opts =3D &ppc_hash64_opts_POWER7; pcc->radix_page_info =3D &POWER9_radix_page_info; pcc->lrg_decr_bits =3D 56; + pcc->n_host_threads =3D 4; #endif pcc->excp_model =3D POWERPC_EXCP_POWER9; pcc->bus_model =3D PPC_FLAGS_INPUT_POWER9; --=20 2.13.6