From nobody Sat Nov 15 07:41:32 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=1755491192; cv=none; d=zohomail.com; s=zohoarc; b=HdrBSWhQjAbIf2CY/dW6J3KE6I9eoS80O06kLumHKbhpXWEjQk8nDux9GijIFszVPEIqjxmEaQzOwyFe1enBUH6u9MhxZM6oRIfoRIbfP5BiuBooCuW047KPJikyNwMyvV2PbBilnqlpsIrQN+3Gn63mpM/2+eVewZys1FArJPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755491192; 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=RWOUahuffRODKn11bwqIgWpsGqBtiathLmHpxPmSXXk=; b=cMgGbNmzGCnEwoEmnHuBoLtop7v8gtcjw058Eod2xo9rj/jUVZ5kdjOofb4xftRZa57hnSbjn0S8yO7Ne1Z+7MsuEdChIveNORpr5+H4YeUN16NHq7C/VZuZ82srbC5mxPbOFy0C9uaU3MgB3prjgZe4MHjQ/zIbzGmoiwT0Yw8= 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 175549119291967.82126640975878; Sun, 17 Aug 2025 21:26:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1unrRa-0000Pn-9n; Mon, 18 Aug 2025 00:26:02 -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 1unrGV-0005te-Q1 for qemu-devel@nongnu.org; Mon, 18 Aug 2025 00:14:37 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1unrGO-0002Dm-Bv for qemu-devel@nongnu.org; Mon, 18 Aug 2025 00:14:34 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-32326e2f0b3so2578888a91.2 for ; Sun, 17 Aug 2025 21:14:27 -0700 (PDT) Received: from localhost.localdomain ([206.83.122.207]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3232f8c8e4bsm5498344a91.2.2025.08.17.21.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Aug 2025 21:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755490467; x=1756095267; 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=RWOUahuffRODKn11bwqIgWpsGqBtiathLmHpxPmSXXk=; b=jIaHnN/Vb9xoxT6biZ9gaEaTx8iAk36CHkzJaHYTJDEcJpiAMeuojOdvNP9p6K9jP5 84mXZVg5unUzz87T9kTI1ybsTY9B/xjBmCiPtGvavOruLFVDvWI4fD+V3s4ODkHKGr+N Sn1JrESgouN7xxuiD5qpzxjiXzD1oz+49l2jP0IA4Sctl0+r3xyahcgfRdFDPVm5J/54 adrhNpmWnROa/jSbiFZDFtE/0LVaTgebhnBBc6n+4mGebvrafU4iV70NY5y+hDQzNbCw 3d2oxYQ4aXeMQXEblTagqpDroSGM2kXuxMNQMRCDmysomgA160ZYK7epz1P8djH7nuqn yuLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755490467; x=1756095267; 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=RWOUahuffRODKn11bwqIgWpsGqBtiathLmHpxPmSXXk=; b=IeWLWrXNmJ/vVae3F95nmgRg+9vbV7/WVcLHW+RkeYnkWy2BHg+mSPKBRvwB773o+G Ud7MvDjdC6FB/0dE6SLzV3cVy7V4YAdXu2h+dw3lGFcsH+fyQ/RrNy+yjmVPWWE5rucb Z/Wtldo4zpUybwoGe62F9Oz/JD+ithwvxmujRDCwodrBhuYxAR+k/i5f4E8XJ/nU2PIM RcPmz3GIqoTWaOvDn4+RisL9EKJwatf41pnbXlmXqEDiJZuBWFnaUmd6yVhpQ0bj+vkj 380DBIQlFNWXHxuf+ANZuevgCNS1SDGNrmWikf/ZrrpS3RdOT7iyJJbfGwHXtQGmEwAd 1fww== X-Gm-Message-State: AOJu0YxVIv9pA2QQeipOra7NPHn273+GQYGsjhLXFw7UNpd6TEeJ9Hb5 YUfhMxhJekc9XC86iASn09q96TzmHJu9YpQT1kpR3TECqcAU2FGddEEVjF0nVf2FsA/SczHfyO+ K8ceT7Sk= X-Gm-Gg: ASbGnctH2WlolxRYYppsJWVwNzijgtcaJZAkOQrsVswA8E8BwomUuJ1rVAuVkRkQySh YO5Hx/1w4l00ohcufTnklum4BlZxzM3SHAruSlUK3/OzZSdA155qlsnhBILzjIqngBAQt02nwec jNml21l4D1B1e1sOO9wNb/r5naRHbTSyx99sZkjVQfiN+0XNbIWTRyKElPOiAlbcxn85huAQyaY 0D5+0HkCmo4QdugEOWhWyjsjK/dF33JghTZJmA/DH+S3oOweU5r+o2TQBTcgRAjQepa9YroA0t0 t5e0tYH7U47ucwPncnPskhuFaCTPp+giJIR9a0iXw1HEV1LLXN9Bvn/58zjC+CVhs6SCfuz0wKS QZPHa9oiD7grM0wGy//G4w9Jf5JmjWrQi6b8TDrM8RvF38Ow= X-Google-Smtp-Source: AGHT+IERuxfI1O3EnWUjPF1v8hyZkTDZfdphL7bxohaPt1o99+f9scheIVJlf2X0zFf120QXhMD5Xw== X-Received: by 2002:a17:90b:2b4e:b0:321:c37e:e325 with SMTP id 98e67ed59e1d1-32341ec4eccmr14885378a91.12.1755490466711; Sun, 17 Aug 2025 21:14:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mads@ynddal.dk, agraf@csgraf.de, qemu-arm@nongnu.org, philmd@linaro.org Subject: [PATCH 6/7] target/arm/hvf: Replace hvf_sreg_match with hvf_sreg_list Date: Mon, 18 Aug 2025 14:13:53 +1000 Message-ID: <20250818041354.2393041-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250818041354.2393041-1-richard.henderson@linaro.org> References: <20250818041354.2393041-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::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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=unavailable 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: 1755491196067116600 Content-Type: text/plain; charset="utf-8" Change hvf_get_registers and hvf_put_registers to iterate over cpregs_indexes instead of hvf_sreg_match. This lets us drop the cp_idx member of hvf_sreg_match, which leaves only one member in the struct. Replace the struct with a const array. Instead of int, use the proper enum type: hv_sys_reg_t. Rename from hvf_sreg_match to hvf_sreg_list because there is no longer any matching going on. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/hvf/hvf.c | 45 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 46e52e8d34..647eb675ef 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -394,11 +394,6 @@ static const struct hvf_reg_match hvf_fpreg_match[] = =3D { { HV_SIMD_FP_REG_Q31, offsetof(CPUARMState, vfp.zregs[31]) }, }; =20 -struct hvf_sreg_match { - int reg; - uint32_t cp_idx; -}; - /* * QEMU uses KVM system register ids in the migration format. * Conveniently, HVF uses the same encoding of the op* and cr* parameters @@ -419,9 +414,9 @@ struct hvf_sreg_match { =20 #undef DEF_SYSREG =20 -#define DEF_SYSREG(HVF_ID, crn, crm, op0, op1, op2) { HVF_ID }, +#define DEF_SYSREG(HVF_ID, crn, crm, op0, op1, op2) HVF_ID, =20 -static struct hvf_sreg_match hvf_sreg_match[] =3D { +static const hv_sys_reg_t hvf_sreg_list[] =3D { #include "sysreg.c.inc" }; =20 @@ -434,7 +429,7 @@ int hvf_get_registers(CPUState *cpu) hv_return_t ret; uint64_t val; hv_simd_fp_uchar16_t fpval; - int i; + int i, n; =20 for (i =3D 0; i < ARRAY_SIZE(hvf_reg_match); i++) { ret =3D hv_vcpu_get_reg(cpu->accel->fd, hvf_reg_match[i].reg, &val= ); @@ -463,13 +458,9 @@ int hvf_get_registers(CPUState *cpu) assert_hvf_ok(ret); pstate_write(env, val); =20 - for (i =3D 0; i < ARRAY_SIZE(hvf_sreg_match); i++) { - int hvf_id =3D hvf_sreg_match[i].reg; - uint64_t kvm_id =3D HVF_TO_KVMID(hvf_id); - - if (hvf_sreg_match[i].cp_idx =3D=3D -1) { - continue; - } + for (i =3D 0, n =3D arm_cpu->cpreg_array_len; i < n; i++) { + uint64_t kvm_id =3D arm_cpu->cpreg_indexes[i]; + int hvf_id =3D KVMID_TO_HVF(kvm_id); =20 if (cpu->accel->guest_debug_enabled) { /* Handle debug registers */ @@ -553,7 +544,7 @@ int hvf_get_registers(CPUState *cpu) =20 val =3D read_raw_cp_reg(env, ri); =20 - arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx] =3D val; + arm_cpu->cpreg_values[i] =3D val; continue; } } @@ -562,7 +553,7 @@ int hvf_get_registers(CPUState *cpu) ret =3D hv_vcpu_get_sys_reg(cpu->accel->fd, hvf_id, &val); assert_hvf_ok(ret); =20 - arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx] =3D val; + arm_cpu->cpreg_values[i] =3D val; } assert(write_list_to_cpustate(arm_cpu)); =20 @@ -578,7 +569,7 @@ int hvf_put_registers(CPUState *cpu) hv_return_t ret; uint64_t val; hv_simd_fp_uchar16_t fpval; - int i; + int i, n; =20 for (i =3D 0; i < ARRAY_SIZE(hvf_reg_match); i++) { val =3D *(uint64_t *)((void *)env + hvf_reg_match[i].offset); @@ -605,12 +596,9 @@ int hvf_put_registers(CPUState *cpu) aarch64_save_sp(env, arm_current_el(env)); =20 assert(write_cpustate_to_list(arm_cpu, false)); - for (i =3D 0; i < ARRAY_SIZE(hvf_sreg_match); i++) { - int hvf_id =3D hvf_sreg_match[i].reg; - - if (hvf_sreg_match[i].cp_idx =3D=3D -1) { - continue; - } + for (i =3D 0, n =3D arm_cpu->cpreg_array_len; i < n; i++) { + uint64_t kvm_id =3D arm_cpu->cpreg_indexes[i]; + int hvf_id =3D KVMID_TO_HVF(kvm_id); =20 if (cpu->accel->guest_debug_enabled) { /* Handle debug registers */ @@ -688,7 +676,7 @@ int hvf_put_registers(CPUState *cpu) } } =20 - val =3D arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx]; + val =3D arm_cpu->cpreg_values[i]; ret =3D hv_vcpu_set_sys_reg(cpu->accel->fd, hvf_id, val); assert_hvf_ok(ret); } @@ -899,7 +887,7 @@ int hvf_arch_init_vcpu(CPUState *cpu) { ARMCPU *arm_cpu =3D ARM_CPU(cpu); CPUARMState *env =3D &arm_cpu->env; - uint32_t sregs_match_len =3D ARRAY_SIZE(hvf_sreg_match); + uint32_t sregs_match_len =3D ARRAY_SIZE(hvf_sreg_list); uint32_t sregs_cnt =3D 0; uint64_t pfr; hv_return_t ret; @@ -924,17 +912,14 @@ int hvf_arch_init_vcpu(CPUState *cpu) =20 /* Populate cp list for all known sysregs */ for (i =3D 0; i < sregs_match_len; i++) { - int hvf_id =3D hvf_sreg_match[i].reg; + hv_sys_reg_t hvf_id =3D hvf_sreg_list[i]; uint64_t kvm_id =3D HVF_TO_KVMID(hvf_id); uint32_t key =3D kvm_to_cpreg_id(kvm_id); const ARMCPRegInfo *ri =3D get_arm_cp_reginfo(arm_cpu->cp_regs, ke= y); =20 if (ri) { assert(!(ri->type & ARM_CP_NO_RAW)); - hvf_sreg_match[i].cp_idx =3D sregs_cnt; arm_cpu->cpreg_indexes[sregs_cnt++] =3D kvm_id; - } else { - hvf_sreg_match[i].cp_idx =3D -1; } } arm_cpu->cpreg_array_len =3D sregs_cnt; --=20 2.43.0