From nobody Wed May 15 12:04:10 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=1561340456; cv=none; d=zoho.com; s=zohoarc; b=OD0Dy7vDkBeQaewZ1+p5J5OXv0aIN9DvHfa4DRcOgGe3rHx7i3C127815fmh3xIxLhY5ep237OPyrtfalxsdoTx+uNqYHWE7LE6Kmvw06Lm2rxTuu4Iw7y6LTZW1ykS8aFBjpksh0YQusQuhRSOL3lwieugIIE2U5FQyA+utoEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561340456; 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=A7KAWEKUMNrndfGHBvS4f2aODZGCXViLo82IWAShxPA=; b=UhbmT06U1QbvdnJf85n0SJ3dP5hjgybQQ2qHrgissC4rOhp3ajY7FSDnPIXWfYtcBljzqjngLmZOBAVyIV1JQcj/BWOL7AedxXSiMRjuQZyqZlC+eEY681yJS4ZkF3TnrwchXvhc615j7Q0PC1D6br3tF/qtROtwfEPxxEl5J7E= 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 1561340456831708.8415646783611; Sun, 23 Jun 2019 18:40:56 -0700 (PDT) Received: from localhost ([::1]:47562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfDyF-0007DW-86 for importer@patchew.org; Sun, 23 Jun 2019 21:40:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47277) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfDxf-0006Sn-TU for qemu-devel@nongnu.org; Sun, 23 Jun 2019 21:40:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfDxe-0003nQ-Pg for qemu-devel@nongnu.org; Sun, 23 Jun 2019 21:39:59 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:32996) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfDxY-0003ER-VZ; Sun, 23 Jun 2019 21:39:53 -0400 Received: by mail-pg1-x542.google.com with SMTP id m4so5597886pgk.0; Sun, 23 Jun 2019 18:39:51 -0700 (PDT) Received: from surajjs2.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id k22sm9025036pfk.157.2019.06.23.18.39.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 18:39:48 -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=A7KAWEKUMNrndfGHBvS4f2aODZGCXViLo82IWAShxPA=; b=Fl5HU9Vtx1MOuszJnVLnVrQNZMnww0fjYwbXHayxk9YVXOftLNbI3mErewvy2dWYxn c8gRebcl7nGsoHUHg/32pOOFUq0moAxTcMEbuJalYmEO9GTOpBTHLId1HUAtbsv0oQF9 wjrJst5AVje4ZVmjzovQRo9pf2k7IFh1V1uo4ATydkLfF1ZJ8+hZREDfg1OGnJNA/DPL sE+OTrNWbpzhCQjzNR2xMf1At18An5s9vuJ8pyFiMYb5W/QKGZgB+Rqo2Nd+sI/c5ANv vHTtG9S3wsIqvDraEAta/v0XXZclH6NAutEMtK34gm+0xY1I56VkjP6S9NHWUxgxAlAG 2l+w== 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=A7KAWEKUMNrndfGHBvS4f2aODZGCXViLo82IWAShxPA=; b=t9Vpp/g5gTeYv1SVxKnz3Th3c1LAEE8syNfsnr28GtrtWf7Xsv6Ny6dW9Il7jz/vru LSM7qV4h+jY1ns5T70lvFsA9W/WDFYH/bhR21IN1b+VOskfr58VqkCOiEKfF95okQ/N0 vhtuB5+UYYUvYG8WvG7gD914vg7LdHY6LnFglipzmXEAKvyO5OKcCZmHNQcaDIFjF6Jl D6wMqlHZcS6ZkEUaibfQ/6VDfO+Jj43gdfiMUHR9fzMVLTPq6dtCZwDjYwrrdLwu34u/ hGYG6UYbE43RMsSeSi0c40i49zxYvRmyQ7ay+aDCfvUPTa4FAWkI8XXtlzsy1goIVru/ qGIQ== X-Gm-Message-State: APjAAAWfhz3xqkTJgYh7+dK8zLtUlYMtziGcWmA/9ZxQkUo11wWA7zD+ 7jbwXYj9jueSzAPfXNsNct8wHCeF X-Google-Smtp-Source: APXvYqxlRm36N5nyA8Vd3sq8RQLLn3gbCHge7oxOL0AxPNrjCgp+laRVWnHokpKbOceu4h5T/zab9w== X-Received: by 2002:a63:455c:: with SMTP id u28mr31342893pgk.416.1561340389652; Sun, 23 Jun 2019 18:39:49 -0700 (PDT) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Mon, 24 Jun 2019 11:39:21 +1000 Message-Id: <20190624013921.11944-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::542 Subject: [Qemu-devel] [QEMU-PPC] [PATCH] 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, 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) 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 determin 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 and provide an implementation which determines this information based on the number of interrupt servers present in the device tree. Signed-off-by: Suraj Jitindar Singh --- hw/ppc/spapr_rtas.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 5bc1a93271..a33d87794c 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -229,6 +229,40 @@ static inline int sysparm_st(target_ulong addr, target= _ulong len, return RTAS_OUT_SUCCESS; } =20 +static int rtas_get_num_host_threads(void) +{ + const char *entry, *name =3D "/proc/device-tree/cpus/"; + int num_threads =3D -1; + GDir *dir; + + if (!kvm_enabled()) + return 1; + + dir =3D g_dir_open(name, 0, NULL); + if (!dir) + return -1; + + while ((entry =3D g_dir_read_name(dir))) { + if (!strncmp(entry, "PowerPC,POWER", strlen("PowerPC,POWER"))) { + unsigned long len; + char *path, *buf; + + path =3D g_strconcat(name, entry, "/ibm,ppc-interrupt-server#s= ", + NULL); + if (g_file_get_contents(path, &buf, &len, NULL)) { + num_threads =3D len / sizeof(int); + g_free(buf); + } + + g_free(path); + break; + } + } + + g_dir_close(dir); + return num_threads; +} + static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu, SpaprMachineState *spapr, uint32_t token, uint32_t nargs, @@ -250,6 +284,16 @@ static void rtas_ibm_get_system_parameter(PowerPCCPU *= cpu, current_machine->ram_size / MiB, smp_cpus, max_cpus); + int num_host_threads =3D rtas_get_num_host_threads(); + + if (num_host_threads > 0) { + char *hostthr_val, *old =3D param_val; + + hostthr_val =3D g_strdup_printf(",HostThrs=3D%d", num_host_thr= eads); + 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; --=20 2.13.6