From nobody Wed May 1 05:15:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1599227887; cv=none; d=zohomail.com; s=zohoarc; b=YU4qHpHq7wy5E24XHmudAlCT9PrR5N1gG9nQ2cs5oV24QNtRHaGytokbOWAzFkONbbbAPcTfl3xhzK0f6l+h4eonjyh+USIntI5pBn3ubH6G5DYuCI2cxcq6JfbiHQ78Pnn+7xWY6JvIpnz9ZUZGZixIpd3oIeyiPm4HnNzs3DQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599227887; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yaXUGx5Z0/GOHdtMl0ca+JpE0hz+CrwFr6VPmXocPbo=; b=IQBZ/i+MySCv5/lbuDkt8mvGvcLfwqPp6MFj9yWEvk7c42yfolbTl9c8Uh/3ZZxafJGcDnCGbZt++vC8XJv63/Vh72qgcBU9MkF+Ekys1xU+rvAV5+5EiI5tqEHzvQbiG0mJrHTiFKmUdr6wwU4OIrd0z23CEL8G4qxz2hRNFBE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599227887224868.0317502677221; Fri, 4 Sep 2020 06:58:07 -0700 (PDT) Received: from localhost ([::1]:55402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kECEA-0005JD-AB for importer@patchew.org; Fri, 04 Sep 2020 09:58:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kECCu-0003yJ-N0; Fri, 04 Sep 2020 09:56:48 -0400 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]:43213) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kECCs-00086q-RR; Fri, 04 Sep 2020 09:56:48 -0400 Received: by mail-qk1-x744.google.com with SMTP id o64so6296852qkb.10; Fri, 04 Sep 2020 06:56:46 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:1dc:ffbd:d3fb:97ff:aaca]) by smtp.gmail.com with ESMTPSA id y30sm4682993qth.7.2020.09.04.06.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 06:56:44 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=yaXUGx5Z0/GOHdtMl0ca+JpE0hz+CrwFr6VPmXocPbo=; b=epV1ofJLCkqzww6Swar+AuCfhlaYpOY1ZlZV/FvRsYJcGJG7hJkYJKILGjbGSx/5M6 IsMszHOLiYYcQ7cq3/6dB5a7oHbhde5HykBzpRdiHJ5gcIJ1WBsgu4TShfBeWxc3TiJK U4z2pn+d1GUKqsgHdAq6KhBxwrNUDDvtLUPE0ISzDli8iWpASwiONRESfzYhyyAlDFSy bJ6ckTC5CYOviLx/vMcylUCi9+q0VNv6Ca5yiFE1uFlMpmQxwaX8+mBo/QjSaNh+IErg FOn4b1e1t9FXkr/zpJeZgtdHLobg3NAfQ5JYwCxyMDyYWnyrifu3eM4Vf1L6JmiAxAIy dAgw== 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:mime-version:content-transfer-encoding; bh=yaXUGx5Z0/GOHdtMl0ca+JpE0hz+CrwFr6VPmXocPbo=; b=p9lIsP4bvHALWEF2tzdsy/cvYkGl6vOQQ5VkOTdWYKfZE8N8pqgXkD4lwOPTrwIYRQ 5aT0GMZbVUff7ZF897eWMuxGQBwmPKBkAl8pU52pR3e/L9jZ0GyiiueAVyOvqQjIGYqE ofEDAivUM96E/RjHQYi/DfWyz9uJJEqbzQiZMaHIBg10+r6FTm9cwhCXAZncOo2nK1Sc W+OEMQxM8+vhbqfxz0nJmcUaSzk/impS/DGBN7/pPVdI+8GSToN1pDA58CrPEmuiiCG+ nLZNfhLjwOHeo0ZmGsjR0gpifhNtaZiUAgQXBZnRTFM8XTTnoATvV6gY8B2mKTpn4Erw nLbA== X-Gm-Message-State: AOAM532ICW8mhinFPnQOxvSZqDw8zGQ4w9nhmuUv/gfW9rSv2RsmI/Ys c25ziGb7CAX+q1LZjsnY33moN7Nbi5w= X-Google-Smtp-Source: ABdhPJxFvf3vZ0w3Utkxff9EV2w6ZbEWw+RQ46CTOtFyxfZd6nK1d6bdwBcYhIysiwPrh3mIQuaz8A== X-Received: by 2002:a05:620a:1212:: with SMTP id u18mr8128242qkj.434.1599227805277; Fri, 04 Sep 2020 06:56:45 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v5 1/3] spapr: move h_home_node_associativity to spapr_numa.c Date: Fri, 4 Sep 2020 10:56:29 -0300 Message-Id: <20200904135631.605094-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200904135631.605094-1-danielhb413@gmail.com> References: <20200904135631.605094-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::744; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x744.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Daniel Henrique Barboza , qemu-ppc@nongnu.org, groug@kaod.org, 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-Type: text/plain; charset="utf-8" The implementation of this hypercall will be modified to use spapr->numa_assoc_arrays input. Moving it to spapr_numa.c makes make more sense. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- hw/ppc/spapr_hcall.c | 40 --------------------------------------- hw/ppc/spapr_numa.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index c1d01228c6..c2776b6a7d 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1873,42 +1873,6 @@ static target_ulong h_client_architecture_support(Po= werPCCPU *cpu, return ret; } =20 -static target_ulong h_home_node_associativity(PowerPCCPU *cpu, - SpaprMachineState *spapr, - target_ulong opcode, - target_ulong *args) -{ - target_ulong flags =3D args[0]; - target_ulong procno =3D args[1]; - PowerPCCPU *tcpu; - int idx; - - /* only support procno from H_REGISTER_VPA */ - if (flags !=3D 0x1) { - return H_FUNCTION; - } - - tcpu =3D spapr_find_cpu(procno); - if (tcpu =3D=3D NULL) { - return H_P2; - } - - /* sequence is the same as in the "ibm,associativity" property */ - - idx =3D 0; -#define ASSOCIATIVITY(a, b) (((uint64_t)(a) << 32) | \ - ((uint64_t)(b) & 0xffffffff)) - args[idx++] =3D ASSOCIATIVITY(0, 0); - args[idx++] =3D ASSOCIATIVITY(0, tcpu->node_id); - args[idx++] =3D ASSOCIATIVITY(procno, -1); - for ( ; idx < 6; idx++) { - args[idx] =3D -1; - } -#undef ASSOCIATIVITY - - return H_SUCCESS; -} - static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu, SpaprMachineState *spapr, target_ulong opcode, @@ -2139,10 +2103,6 @@ static void hypercall_register_types(void) spapr_register_hypercall(KVMPPC_H_CAS, h_client_architecture_support); =20 spapr_register_hypercall(KVMPPC_H_UPDATE_DT, h_update_dt); - - /* Virtual Processor Home Node */ - spapr_register_hypercall(H_HOME_NODE_ASSOCIATIVITY, - h_home_node_associativity); } =20 type_init(hypercall_register_types) diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index 93a000b729..368c1a494d 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -165,3 +165,48 @@ void spapr_numa_write_rtas_dt(SpaprMachineState *spapr= , void *fdt, int rtas) _FDT(fdt_setprop(fdt, rtas, "ibm,max-associativity-domains", maxdomains, sizeof(maxdomains))); } + +static target_ulong h_home_node_associativity(PowerPCCPU *cpu, + SpaprMachineState *spapr, + target_ulong opcode, + target_ulong *args) +{ + target_ulong flags =3D args[0]; + target_ulong procno =3D args[1]; + PowerPCCPU *tcpu; + int idx; + + /* only support procno from H_REGISTER_VPA */ + if (flags !=3D 0x1) { + return H_FUNCTION; + } + + tcpu =3D spapr_find_cpu(procno); + if (tcpu =3D=3D NULL) { + return H_P2; + } + + /* sequence is the same as in the "ibm,associativity" property */ + + idx =3D 0; +#define ASSOCIATIVITY(a, b) (((uint64_t)(a) << 32) | \ + ((uint64_t)(b) & 0xffffffff)) + args[idx++] =3D ASSOCIATIVITY(0, 0); + args[idx++] =3D ASSOCIATIVITY(0, tcpu->node_id); + args[idx++] =3D ASSOCIATIVITY(procno, -1); + for ( ; idx < 6; idx++) { + args[idx] =3D -1; + } +#undef ASSOCIATIVITY + + return H_SUCCESS; +} + +static void spapr_numa_register_types(void) +{ + /* Virtual Processor Home Node */ + spapr_register_hypercall(H_HOME_NODE_ASSOCIATIVITY, + h_home_node_associativity); +} + +type_init(spapr_numa_register_types) --=20 2.26.2 From nobody Wed May 1 05:15:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1599227901; cv=none; d=zohomail.com; s=zohoarc; b=YH/4zXWw+B/mzI3mbIfA6CXj8s110STajJks6BBOJvnJWBwWvnG9kF9qdYSnnaT4UtfwP98fWFs51yUx4DVo3HRJW07tsK8XgWvBTmTisBXcAwQkA/1fYS0L7e7K7+y62nLOZSClo651IJuYWOC2OsF9U+Aek34hOKSvBF2ssqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599227901; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=B25qamJo3FWxLu1J43XkdjSAaW2Gpibu700qwm6H0C4=; b=WW9dsGF95W6wNBhSd2S3aesncBeNMrm1Nrqdzfe0EeuZsjyPQWl1/kOrLKXuGQPtGCoPwhcooJ8kR3QA4IhTcdOTkAQ//S3BhhDzGOx94ZKGdWXwOhEUue3rd4ASjZ1qflycuuQySiqB4JPITc8tePwgFwvskn49gqc4fu81DHU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599227901247782.9912736892969; Fri, 4 Sep 2020 06:58:21 -0700 (PDT) Received: from localhost ([::1]:56316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kECEO-0005g3-Ey for importer@patchew.org; Fri, 04 Sep 2020 09:58:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kECCx-00043v-0v; Fri, 04 Sep 2020 09:56:51 -0400 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]:33054) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kECCv-00087C-8a; Fri, 04 Sep 2020 09:56:50 -0400 Received: by mail-qk1-x741.google.com with SMTP id p4so6370199qkf.0; Fri, 04 Sep 2020 06:56:48 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:1dc:ffbd:d3fb:97ff:aaca]) by smtp.gmail.com with ESMTPSA id y30sm4682993qth.7.2020.09.04.06.56.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 06:56:47 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=B25qamJo3FWxLu1J43XkdjSAaW2Gpibu700qwm6H0C4=; b=pQdjT9Ly6b6PtK/+7rEmuzzwBaqMi6ZYqpYaOxj7XuYd62FWZq46fnvqtITY0WhI82 n8U9H2v6Nj+bAGsqXnJD1cPhjeEIHX47MxkYynDnH/wRy8ZR4XMjSIioDzEmAqUpGi1R 9DLxBWOasTkv4Hsay1Z4+BYSN7iKHVwbmpRFfR02LlrQaiTAYlBfcaoP4URTf4/xToT+ Gw9FLL5l/H7wyF8RR2L+x9p9W+s162pFY16xbKBTNqmbygLh0SU9wke/m4285NB5L2of E24wcKA3b5Otp4BqTn4h+9Tj5lX8lJ/Aghjuw8K/+xgUHF/8P2FoW7ds4uLY4WzItvC0 gAbQ== 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:mime-version:content-transfer-encoding; bh=B25qamJo3FWxLu1J43XkdjSAaW2Gpibu700qwm6H0C4=; b=K+KtR69fEuH4KzWpi5MgZqoQZYOLoQnKt2HiKpbaCiznRbi70W8IcJVMZFXsns9Km/ 33463w+JCCp1BL3nhvQ5HvN1+OlH9ADaKw0Vpt7l/xg3k7gYmIUaRI2MXBUpOWrOyIH8 A2Q0JLIUKsF4LxAUF1ZJ5YyJSl36Kd9kTwEhQub8LNWJej1cGG2lKzfxUHIV67sHC22n qzvISH3bw9eCnK7x7Uq8ZZx5qh7sIwtKdevqzLuUOCED/j2fSa3l1V7e2mGYLAxNBG/E psMC+JjaeXf+41KcYDUCphIeIVbcig8Y5/OCO4kOb/BkIR0b2iaZfCUZIQ6DejESEPe/ SAkA== X-Gm-Message-State: AOAM532F1BQuicfhTUa8KFZGRg328LQZ7NdNEHwvc9H+cdXo9TjlFWq5 CIQRvvxoyqfg/d9Q4udqEM+ryXLiUb8= X-Google-Smtp-Source: ABdhPJzhS6UGHelboVCRbZbULbq61hbuYEXERaccmy+HlfLqvXI9xj/9YrZcLFJD9EOhVnQZ3dV7Kg== X-Received: by 2002:a37:c4b:: with SMTP id 72mr8027024qkm.176.1599227807551; Fri, 04 Sep 2020 06:56:47 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v5 2/3] spapr_numa: create a vcpu associativity helper Date: Fri, 4 Sep 2020 10:56:30 -0300 Message-Id: <20200904135631.605094-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200904135631.605094-1-danielhb413@gmail.com> References: <20200904135631.605094-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::741; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x741.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Daniel Henrique Barboza , qemu-ppc@nongnu.org, groug@kaod.org, 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-Type: text/plain; charset="utf-8" The work to be done in h_home_node_associativity() intersects with what is already done in spapr_numa_fixup_cpu_dt(). This patch creates a new helper, spapr_numa_get_vcpu_assoc(), to be used for both spapr_numa_fixup_cpu_dt() and h_home_node_associativity(). While we're at it, use memcpy() instead of loop assignment to created the returned array. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- hw/ppc/spapr_numa.c | 33 ++++++++++++++++++++------------- include/hw/ppc/spapr.h | 7 ++++++- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index 368c1a494d..674d2ee86d 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -71,31 +71,38 @@ void spapr_numa_write_associativity_dt(SpaprMachineStat= e *spapr, void *fdt, sizeof(spapr->numa_assoc_array[nodeid])))); } =20 -int spapr_numa_fixup_cpu_dt(SpaprMachineState *spapr, void *fdt, - int offset, PowerPCCPU *cpu) +static uint32_t *spapr_numa_get_vcpu_assoc(SpaprMachineState *spapr, + PowerPCCPU *cpu) { - uint vcpu_assoc_size =3D NUMA_ASSOC_SIZE + 1; - uint32_t vcpu_assoc[vcpu_assoc_size]; + uint32_t *vcpu_assoc =3D g_malloc(VCPU_ASSOC_SIZE * sizeof(uint32_t)); int index =3D spapr_get_vcpu_id(cpu); - int i; + + g_assert(vcpu_assoc !=3D NULL); =20 /* * VCPUs have an extra 'cpu_id' value in ibm,associativity * compared to other resources. Increment the size at index - * 0, copy all associativity domains already set, then put - * cpu_id last. + * 0, put cpu_id last, then copy the remaining associativity + * domains. */ vcpu_assoc[0] =3D cpu_to_be32(MAX_DISTANCE_REF_POINTS + 1); + vcpu_assoc[VCPU_ASSOC_SIZE - 1] =3D cpu_to_be32(index); + memcpy(vcpu_assoc + 1, spapr->numa_assoc_array[cpu->node_id] + 1, + (VCPU_ASSOC_SIZE - 2) * sizeof(uint32_t)); =20 - for (i =3D 1; i <=3D MAX_DISTANCE_REF_POINTS; i++) { - vcpu_assoc[i] =3D spapr->numa_assoc_array[cpu->node_id][i]; - } + return vcpu_assoc; +} + +int spapr_numa_fixup_cpu_dt(SpaprMachineState *spapr, void *fdt, + int offset, PowerPCCPU *cpu) +{ + g_autofree uint32_t *vcpu_assoc =3D NULL; =20 - vcpu_assoc[vcpu_assoc_size - 1] =3D cpu_to_be32(index); + vcpu_assoc =3D spapr_numa_get_vcpu_assoc(spapr, cpu); =20 /* Advertise NUMA via ibm,associativity */ - return fdt_setprop(fdt, offset, "ibm,associativity", - vcpu_assoc, sizeof(vcpu_assoc)); + return fdt_setprop(fdt, offset, "ibm,associativity", vcpu_assoc, + VCPU_ASSOC_SIZE * sizeof(uint32_t)); } =20 =20 diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 9a63380801..e50a2672e3 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -107,13 +107,18 @@ typedef enum { =20 /* * NUMA related macros. MAX_DISTANCE_REF_POINTS was taken - * from Taken from Linux kernel arch/powerpc/mm/numa.h. + * from Linux kernel arch/powerpc/mm/numa.h. It represents the + * amount of associativity domains for non-CPU resources. * * NUMA_ASSOC_SIZE is the base array size of an ibm,associativity * array for any non-CPU resource. + * + * VCPU_ASSOC_SIZE represents the size of ibm,associativity array + * for CPUs, which has an extra element (vcpu_id) in the end. */ #define MAX_DISTANCE_REF_POINTS 4 #define NUMA_ASSOC_SIZE (MAX_DISTANCE_REF_POINTS + 1) +#define VCPU_ASSOC_SIZE (NUMA_ASSOC_SIZE + 1) =20 typedef struct SpaprCapabilities SpaprCapabilities; struct SpaprCapabilities { --=20 2.26.2 From nobody Wed May 1 05:15:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1599227967; cv=none; d=zohomail.com; s=zohoarc; b=LKWD7uAdYFR9yn6X1grvnNCxtKDDgVnN1mX8bx3OFysVWJJ9MBrJxB6/dAdMMvpaP6O2vFe6rYMpUk8A6jpNrXae6r5VJHnlYK4rFCgOkSwNOXrCoiCMrT0K0WRwRIE0lCw55p+Llf/oWJ699Abe7W01AxBy0lOqdLgc/OqIloQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599227967; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wNjhsHT9PnQc171Bu5J0U/3SN55wMPECoh78l3FuHVs=; b=mRE9lRdJg1+S+7qx+HJvLabInmFV429vTUS3Go+OQmBAjG9wvJMB36QPmF/5f0UkGbehb5L0uS35hLsc2bmVO6KijZEdhG0ejZlnmlKvZMhwWfKDkKpkZee4z3t/JalUoBpwae/ZReWtC9DDViH+if62znBr0Fm/pjs9wyIpO8A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599227967791145.1758659925656; Fri, 4 Sep 2020 06:59:27 -0700 (PDT) Received: from localhost ([::1]:33138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kECFT-0007xY-4C for importer@patchew.org; Fri, 04 Sep 2020 09:59:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kECCy-000489-HW; Fri, 04 Sep 2020 09:56:52 -0400 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]:45648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kECCw-00088B-Tq; Fri, 04 Sep 2020 09:56:52 -0400 Received: by mail-qt1-x844.google.com with SMTP id z2so4592589qtv.12; Fri, 04 Sep 2020 06:56:50 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:1dc:ffbd:d3fb:97ff:aaca]) by smtp.gmail.com with ESMTPSA id y30sm4682993qth.7.2020.09.04.06.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 06:56: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:in-reply-to:references :mime-version:content-transfer-encoding; bh=wNjhsHT9PnQc171Bu5J0U/3SN55wMPECoh78l3FuHVs=; b=SJF5m6XmAq876emIEM73UDIDsrzsZDzSqms4a10X2iMfJsbTcLl0yVjiXBbcafOEgz 5A34vwraEi2i9qmnKDYEEKOVPBmIkEvtp9V7VJCbS508ENAa4VgRz5d9wjZp6Wk/P+PC ITTDFsklS9xvlWUzZEBMS14MohPhg9GpUYZAbEmAn42QIppwJ/9afWoFNJ0hiqHf8hcD zcOaf7kZ0AXJdQUe1NLFxhY2aMMlEGh/Q/WuabN8Ob/EBYIIBJUVVKhgtYQjgQs86fhy Lbeg2HgZKMfrXIc6hfcHXRaVg+s0jPmz4aSgrfg4xCp4Jk/y6ovHYlylJHXc3N4tQYIu TraQ== 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:mime-version:content-transfer-encoding; bh=wNjhsHT9PnQc171Bu5J0U/3SN55wMPECoh78l3FuHVs=; b=eqV52B2UNF4x+TXfZKoW3BOZzf+WvjETzWvAxsLlHIo2hkhFkxf2p5Jr+Px6XqvfD+ G4kV9YoErHENSCnD4GpWlc6XdaOvLfTrjGzutY4T5vQSRpb+CW7H9FhxyloIvVCoqfA2 SSDYDVtZNJrQJ463Ww4C9g7bv7wkOKNnaYY3Iz93kJjshxf/QPWpUXKiW4G+dfnDmEjc EjK8nSNABRzzYEWrdM2uxJJ39lsSao3B1/YLqxJyJiL/f1Rm2/o+cyZB01hh197NBE7u NZR9I8Fcj2GHFmTHlOaxeXgFYTwI10vLAFmvL/1UW2g/OpXrPhzCV7aP1POLcjJeaGvq sxdw== X-Gm-Message-State: AOAM533HVW4ixhyAIf5v+VJMo9Ef2i4u2XPplpepuqzFcF12hpt7Pfte 4I0moC8xrwxbDvs9rCVFXJo+M5Wenn0= X-Google-Smtp-Source: ABdhPJyHmHcJGJyG3le7vvriea/v0bdehQjrHeLL32cco/0taNQQpt9fPRkfMdv2SWYpRv/BZ9w2zA== X-Received: by 2002:ac8:724e:: with SMTP id l14mr8840407qtp.144.1599227809322; Fri, 04 Sep 2020 06:56:49 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v5 3/3] spapr_numa: use spapr_numa_get_vcpu_assoc() in home_node hcall Date: Fri, 4 Sep 2020 10:56:31 -0300 Message-Id: <20200904135631.605094-4-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200904135631.605094-1-danielhb413@gmail.com> References: <20200904135631.605094-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::844; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x844.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Daniel Henrique Barboza , qemu-ppc@nongnu.org, groug@kaod.org, 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-Type: text/plain; charset="utf-8" The current implementation of h_home_node_associativity hard codes the values of associativity domains of the vcpus. Let's make it consider the values already initialized in spapr->numa_assoc_array, via the spapr_numa_get_vcpu_assoc() helper. We want to set it and forget it, and for that we also need to assert that we don't overflow the registers of the hypercall. From R4 to R9 we can squeeze in 12 associativity domains for vcpus, so let's assert that VCPU_ASSOC_SIZE -1 isn't greater than that. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- hw/ppc/spapr_numa.c | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index 674d2ee86d..07eb921737 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -178,10 +178,11 @@ static target_ulong h_home_node_associativity(PowerPC= CPU *cpu, target_ulong opcode, target_ulong *args) { + g_autofree uint32_t *vcpu_assoc =3D NULL; target_ulong flags =3D args[0]; target_ulong procno =3D args[1]; PowerPCCPU *tcpu; - int idx; + int idx, assoc_idx; =20 /* only support procno from H_REGISTER_VPA */ if (flags !=3D 0x1) { @@ -193,16 +194,40 @@ static target_ulong h_home_node_associativity(PowerPC= CPU *cpu, return H_P2; } =20 - /* sequence is the same as in the "ibm,associativity" property */ + /* + * Given that we want to be flexible with the sizes and indexes, + * we must consider that there is a hard limit of how many + * associativities domain we can fit in R4 up to R9, which would be + * 12 associativity domains for vcpus. Assert and bail if that's + * not the case. + */ + G_STATIC_ASSERT((VCPU_ASSOC_SIZE - 1) <=3D 12); + + vcpu_assoc =3D spapr_numa_get_vcpu_assoc(spapr, tcpu); + /* assoc_idx starts at 1 to skip associativity size */ + assoc_idx =3D 1; =20 - idx =3D 0; #define ASSOCIATIVITY(a, b) (((uint64_t)(a) << 32) | \ ((uint64_t)(b) & 0xffffffff)) - args[idx++] =3D ASSOCIATIVITY(0, 0); - args[idx++] =3D ASSOCIATIVITY(0, tcpu->node_id); - args[idx++] =3D ASSOCIATIVITY(procno, -1); - for ( ; idx < 6; idx++) { - args[idx] =3D -1; + + for (idx =3D 0; idx < 6; idx++) { + int32_t a, b; + + /* + * vcpu_assoc[] will contain the associativity domains for tcpu, + * including tcpu->node_id and procno, meaning that we don't + * need to use these variables here. + * + * We'll read 2 values at a time to fill up the ASSOCIATIVITY() + * macro. The ternary will fill the remaining registers with -1 + * after we went through vcpu_assoc[]. + */ + a =3D assoc_idx < VCPU_ASSOC_SIZE ? + be32_to_cpu(vcpu_assoc[assoc_idx++]) : -1; + b =3D assoc_idx < VCPU_ASSOC_SIZE ? + be32_to_cpu(vcpu_assoc[assoc_idx++]) : -1; + + args[idx] =3D ASSOCIATIVITY(a, b); } #undef ASSOCIATIVITY =20 --=20 2.26.2