From nobody Sun Sep 28 17:41:39 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1756257319; cv=none; d=zohomail.com; s=zohoarc; b=X0YTFvSDbNvIeqcRWxA2ZDtGu7L0tscmTe5l3twGo0MEpz3GgLzwKilnHiAOPdKc8mt9C7NxPHbbATiQQyEvEDm06tH82mCF8FbA+iyGQdQN3JZtJyYsObWELQC3atI12RvgPgXvAwr0hzYt/x9jfkCP2Yu/WMD9wsjgu0cf1fQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756257319; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CiTPcH4cN132XrAlCNyqqTcsX5/+34SY6jW1V2d9z4Y=; b=iVvsadBPwGNwfuSJ0P2g1RMgrvEthXGo1W+FY6+Wp/yvhKyaxnzynqIg/ADE1t457eL6sp0NbPSYElbruTX+Nm07+vgtoOOAWirJD/H9J0xXbeWdkIxspsrkj13m2jhhch2byRlFZqqENROSanUKL+MtGR33QNI/uQNBqBIjUAY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756257319469829.2105161239128; Tue, 26 Aug 2025 18:15:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ur4dn-0000B0-Om; Tue, 26 Aug 2025 21:07:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ur4dN-00079Q-R3 for qemu-devel@nongnu.org; Tue, 26 Aug 2025 21:07:33 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ur4dK-0007Xl-MV for qemu-devel@nongnu.org; Tue, 26 Aug 2025 21:07:29 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-771fa65b0e1so659367b3a.0 for ; Tue, 26 Aug 2025 18:07:25 -0700 (PDT) Received: from stoup.. ([144.6.121.55]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7720274534esm1419241b3a.47.2025.08.26.18.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Aug 2025 18:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756256843; x=1756861643; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CiTPcH4cN132XrAlCNyqqTcsX5/+34SY6jW1V2d9z4Y=; b=YSoobIgLYB+MPPwTTpSTO9a/Z+NLKWDbEyFnylZEdnrbchBiWafC1rWvyoeG7KiHPa XvbtFNfK9whRxiK8N8RxVWiADFliMpDNh6puZHRHnvQLKCb9exHUP3Gb0C5+gGwsap+7 oe4OOjT9wpVVYqffl5GAEHhu2O8PzCaiKNmcZlNgCg0lhBMbA10VeUWASF8fJceD4QXK Pv5sgLXwVqtAlWEOrZvFUriT9RL6WDO6uMkVkt65PwhXp8efyeuKeifch8RmSKxu2dE6 RiqFPM2ktDe/G+cIQUYdTWvfiuXntGqAa+lFG1A1YsXQxUg8yQTIwUD/siNtg4hp0AWy GHvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756256843; x=1756861643; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CiTPcH4cN132XrAlCNyqqTcsX5/+34SY6jW1V2d9z4Y=; b=HI+mbdFMgrmDuGaWFiUPqJ3DH3f0EeiH06Jh+MpllLWSD8tN2FS9UkcZ/Ckwe2yYav umpk8nqTq292p3Rsu/8TrjzqcRLOcjmhB/RN17gMuQkg8jvD2TdsAtzVbgOlh6hmOqfF 91QtMmyATdwLpJPpUNzWdHpYV6IHMly7tMK5we+6s2LCn61QqlgvjwsNvTzTzmQR/9yh 79s9rKHD/QIRzt4Drw61LQt9Fe9vS1eeWn4O5+CSIHzQy5jqgm83DgQYmexO8PO3Ktpr HKpXu39apUXGjlYA9crZZWHHvjMZtjF4higcikl0KXa3R4uz+xVIamxBsX8d0ofFuKle 4GXA== X-Gm-Message-State: AOJu0YxaJ6wIsXrQwjPu2rYMdHc86WveiJkSanehACHui89Cd9aLob1f 3pDMZ5Uc6RZ3Xn8lk1hUflJE7QJjYS9O0ZEMrJ1shVryEAKthjGv7Ks6stC4bTYOuUHkVHo1+QR v7ZTRLrc= X-Gm-Gg: ASbGncsQdaJ09kx+/0S/8855E810C3ixw9G7mHujoVXuTCMzKLI6lXv2u4cVP5btrrL 9w9lbmTVZ8e9bWCrJQoRYvzod9LR7WHWg04RLDs2iaLuAdmgCRFIKyMzh0LMOYGH1ogGquoXeMq ORXBie3Rv6H49D2kmg70ylZh0kWr845Eu5Mt8ZSc+HNWqGkbDB2FwHo/Jt61HCIXY+rRKHcBK7k YfNGZn+9PvwmzcMU6jD9Vm2owjTUy5NyRsfwEnNv3k98eZSLdAZfx7CYCyNILQzKkIS+ercEPrA HBzpYTtmua93zJs/j9S8S72pk62qLB6vDirER3/TokBhGMPOw6XtBiliEJeyeoyRMEc527Os9dQ ZPWM0XYMZ3ROYrZnUWEDjlMMwMZyKIhKL9roN X-Google-Smtp-Source: AGHT+IFQVDWFOeS/wZ1LS5SwKVdpALVIw+/wXO+QLvv7MNvP1FXnvJv+ieUAx4+DxhLleFXj4N2waA== X-Received: by 2002:a05:6a00:391f:b0:76e:99fc:db8d with SMTP id d2e1a72fcca58-7702fa08e63mr20625201b3a.3.1756256842850; Tue, 26 Aug 2025 18:07:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 25/61] target/arm: Split out alloc_cpreg Date: Wed, 27 Aug 2025 11:04:16 +1000 Message-ID: <20250827010453.4059782-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250827010453.4059782-1-richard.henderson@linaro.org> References: <20250827010453.4059782-1-richard.henderson@linaro.org> 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::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1756257320859116600 Content-Type: text/plain; charset="utf-8" Include provision for a name suffix. Signed-off-by: Richard Henderson --- target/arm/helper.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index a4cd4cf232..0e4be14606 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7263,6 +7263,28 @@ void register_cp_regs_for_features(ARMCPU *cpu) #endif } =20 +/* + * Copy a ARMCPRegInfo structure, allocating it along with the name + * and an optional suffix to the name. + */ +static ARMCPRegInfo *alloc_cpreg(const ARMCPRegInfo *in, + const char *name, const char *suffix) +{ + size_t name_len =3D strlen(name); + size_t suff_len =3D suffix ? strlen(suffix) : 0; + ARMCPRegInfo *out =3D g_malloc(sizeof(*in) + name_len + suff_len + 1); + char *p =3D (char *)(out + 1); + + *out =3D *in; + out->name =3D p; + + memcpy(p, name, name_len + 1); + if (suffix) { + memcpy(p + name_len, suffix, suff_len + 1); + } + return out; +} + /* * Private utility function for define_one_arm_cp_reg(): * add a single reginfo struct to the hash table. @@ -7275,7 +7297,6 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const= ARMCPRegInfo *r, CPUARMState *env =3D &cpu->env; ARMCPRegInfo *r2; bool ns =3D secstate & ARM_CP_SECSTATE_NS; - size_t name_len; =20 /* Overriding of an existing definition must be explicitly requested. = */ if (!(r->type & ARM_CP_OVERRIDE)) { @@ -7285,11 +7306,7 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, cons= t ARMCPRegInfo *r, } } =20 - /* Combine cpreg and name into one allocation. */ - name_len =3D strlen(name) + 1; - r2 =3D g_malloc(sizeof(*r2) + name_len); - *r2 =3D *r; - r2->name =3D memcpy(r2 + 1, name, name_len); + r2 =3D alloc_cpreg(r, name, NULL); =20 /* * Update fields to match the instantiation, overwiting wildcards --=20 2.43.0