From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, peter.maydell@linaro.org
Subject: [PATCH v2 07/36] target/arm/hvf: Replace hvf_sreg_match with hvf_sreg_list
Date: Tue, 16 Sep 2025 07:22:08 -0700 [thread overview]
Message-ID: <20250916142238.664316-8-richard.henderson@linaro.org> (raw)
In-Reply-To: <20250916142238.664316-1-richard.henderson@linaro.org>
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 <richard.henderson@linaro.org>
---
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 98f49ce33a..b043eac8c6 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[] = {
{ HV_SIMD_FP_REG_Q31, offsetof(CPUARMState, vfp.zregs[31]) },
};
-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 {
#undef DEF_SYSREG
-#define DEF_SYSREG(HVF_ID, op0, op1, crn, crm, op2) { HVF_ID },
+#define DEF_SYSREG(HVF_ID, op0, op1, crn, crm, op2) HVF_ID,
-static struct hvf_sreg_match hvf_sreg_match[] = {
+static const hv_sys_reg_t hvf_sreg_list[] = {
#include "sysreg.c.inc"
};
@@ -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;
for (i = 0; i < ARRAY_SIZE(hvf_reg_match); i++) {
ret = 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);
- for (i = 0; i < ARRAY_SIZE(hvf_sreg_match); i++) {
- int hvf_id = hvf_sreg_match[i].reg;
- uint64_t kvm_id = HVF_TO_KVMID(hvf_id);
-
- if (hvf_sreg_match[i].cp_idx == -1) {
- continue;
- }
+ for (i = 0, n = arm_cpu->cpreg_array_len; i < n; i++) {
+ uint64_t kvm_id = arm_cpu->cpreg_indexes[i];
+ int hvf_id = KVMID_TO_HVF(kvm_id);
if (cpu->accel->guest_debug_enabled) {
/* Handle debug registers */
@@ -553,7 +544,7 @@ int hvf_get_registers(CPUState *cpu)
val = read_raw_cp_reg(env, ri);
- arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx] = val;
+ arm_cpu->cpreg_values[i] = val;
continue;
}
}
@@ -562,7 +553,7 @@ int hvf_get_registers(CPUState *cpu)
ret = hv_vcpu_get_sys_reg(cpu->accel->fd, hvf_id, &val);
assert_hvf_ok(ret);
- arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx] = val;
+ arm_cpu->cpreg_values[i] = val;
}
assert(write_list_to_cpustate(arm_cpu));
@@ -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;
for (i = 0; i < ARRAY_SIZE(hvf_reg_match); i++) {
val = *(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));
assert(write_cpustate_to_list(arm_cpu, false));
- for (i = 0; i < ARRAY_SIZE(hvf_sreg_match); i++) {
- int hvf_id = hvf_sreg_match[i].reg;
-
- if (hvf_sreg_match[i].cp_idx == -1) {
- continue;
- }
+ for (i = 0, n = arm_cpu->cpreg_array_len; i < n; i++) {
+ uint64_t kvm_id = arm_cpu->cpreg_indexes[i];
+ int hvf_id = KVMID_TO_HVF(kvm_id);
if (cpu->accel->guest_debug_enabled) {
/* Handle debug registers */
@@ -688,7 +676,7 @@ int hvf_put_registers(CPUState *cpu)
}
}
- val = arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx];
+ val = arm_cpu->cpreg_values[i];
ret = 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 = ARM_CPU(cpu);
CPUARMState *env = &arm_cpu->env;
- uint32_t sregs_match_len = ARRAY_SIZE(hvf_sreg_match);
+ uint32_t sregs_match_len = ARRAY_SIZE(hvf_sreg_list);
uint32_t sregs_cnt = 0;
uint64_t pfr;
hv_return_t ret;
@@ -924,17 +912,14 @@ int hvf_arch_init_vcpu(CPUState *cpu)
/* Populate cp list for all known sysregs */
for (i = 0; i < sregs_match_len; i++) {
- int hvf_id = hvf_sreg_match[i].reg;
+ hv_sys_reg_t hvf_id = hvf_sreg_list[i];
uint64_t kvm_id = HVF_TO_KVMID(hvf_id);
uint32_t key = kvm_to_cpreg_id(kvm_id);
const ARMCPRegInfo *ri = get_arm_cp_reginfo(arm_cpu->cp_regs, key);
if (ri) {
assert(!(ri->type & ARM_CP_NO_RAW));
- hvf_sreg_match[i].cp_idx = sregs_cnt;
arm_cpu->cpreg_indexes[sregs_cnt++] = kvm_id;
- } else {
- hvf_sreg_match[i].cp_idx = -1;
}
}
arm_cpu->cpreg_array_len = sregs_cnt;
--
2.43.0
next prev parent reply other threads:[~2025-09-16 14:26 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 14:22 [PATCH v2 00/36] target/arm: Reorg VHE redirection Richard Henderson
2025-09-16 14:22 ` [PATCH v2 01/36] target/arm: Introduce KVMID_AA64_SYS_REG64 Richard Henderson
2025-09-23 10:40 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 02/36] target/arm: Move compare_u64 to helper.c Richard Henderson
2025-09-23 10:39 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 03/36] target/arm/hvf: Split out sysreg.c.inc Richard Henderson
2025-09-23 10:38 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 04/36] target/arm/hvf: Reorder DEF_SYSREG arguments Richard Henderson
2025-09-23 10:38 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 05/36] target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID Richard Henderson
2025-09-23 10:39 ` Philippe Mathieu-Daudé
2025-09-25 10:31 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 06/36] target/arm/hvf: Remove hvf_sreg_match.key Richard Henderson
2025-09-25 10:31 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` Richard Henderson [this message]
2025-09-25 10:32 ` [PATCH v2 07/36] target/arm/hvf: Replace hvf_sreg_match with hvf_sreg_list Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 08/36] target/arm/hvf: Sort the cpreg_indexes array Richard Henderson
2025-09-25 10:33 ` Philippe Mathieu-Daudé
2025-09-25 13:23 ` Peter Maydell
2025-09-25 13:38 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 09/36] target/arm/hvf: Use raw_read, raw_write to access Richard Henderson
2025-09-25 10:35 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 10/36] target/arm: Use raw_write in cp_reg_reset Richard Henderson
2025-09-25 10:36 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 11/36] target/arm: Rename all ARMCPRegInfo from opaque to ri Richard Henderson
2025-09-23 10:31 ` Philippe Mathieu-Daudé
2025-09-25 10:36 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 12/36] target/arm: Drop define_one_arm_cp_reg_with_opaque Richard Henderson
2025-09-23 10:44 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 13/36] target/arm: Restrict the scope of CPREG_FIELD32, CPREG_FIELD64 Richard Henderson
2025-09-23 10:37 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 14/36] target/arm: Replace cpreg_field_is_64bit with cpreg_field_type Richard Henderson
2025-09-25 10:37 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 15/36] target/arm: Add CP_REG_AA32_64BIT_{SHIFT,MASK} Richard Henderson
2025-09-25 10:38 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 16/36] target/arm: Rename CP_REG_AA32_NS_{SHIFT,MASK} Richard Henderson
2025-09-25 10:39 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 17/36] target/arm: Convert init_cpreg_list to g_hash_table_foreach Richard Henderson
2025-09-25 10:43 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 18/36] target/arm: Remove cp argument to ENCODE_AA64_CP_REG Richard Henderson
2025-09-25 10:45 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 19/36] target/arm: Reorder ENCODE_AA64_CP_REG arguments Richard Henderson
2025-09-23 10:47 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 20/36] target/arm: Split out add_cpreg_to_hashtable_aa{32, 64} Richard Henderson
2025-09-25 10:55 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 21/36] target/arm: Improve asserts in define_one_arm_cp_reg Richard Henderson
2025-09-25 10:59 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 22/36] target/arm: Move cp processing to define_one_arm_cp_reg Richard Henderson
2025-09-25 11:00 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 23/36] target/arm: Move cpreg elimination " Richard Henderson
2025-09-25 13:27 ` Philippe Mathieu-Daudé
2025-09-25 13:44 ` Peter Maydell
2025-09-16 14:22 ` [PATCH v2 24/36] target/arm: Add key parameter to add_cpreg_to_hashtable Richard Henderson
2025-09-25 11:07 ` Philippe Mathieu-Daudé
2025-09-25 14:51 ` Peter Maydell
2025-09-25 15:54 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 25/36] target/arm: Split out alloc_cpreg Richard Henderson
2025-09-25 11:09 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 26/36] target/arm: Hoist the allocation of ARMCPRegInfo Richard Henderson
2025-09-25 11:13 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 27/36] target/arm: Remove name argument to alloc_cpreg Richard Henderson
2025-09-25 11:15 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 28/36] target/arm: Move alias setting for wildcards Richard Henderson
2025-09-25 11:40 ` Philippe Mathieu-Daudé
2025-09-25 14:55 ` Peter Maydell
2025-09-16 14:22 ` [PATCH v2 29/36] target/arm: Move writeback of CP_ANY fields Richard Henderson
2025-09-25 11:43 ` Philippe Mathieu-Daudé
2025-09-25 11:43 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 30/36] target/arm: Move endianness fixup for 32-bit registers Richard Henderson
2025-09-25 11:49 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 31/36] target/arm: Rename TBFLAG_A64_NV2_MEM_E20 with *_E2H Richard Henderson
2025-09-25 11:29 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 32/36] target/arm: Split out redirect_cpreg Richard Henderson
2025-09-25 11:30 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 33/36] target/arm: Redirect VHE FOO_EL1 -> FOO_EL2 during translation Richard Henderson
2025-09-25 13:27 ` Philippe Mathieu-Daudé
2025-09-25 13:54 ` Peter Maydell
2025-09-25 14:10 ` Peter Maydell
2025-09-16 14:22 ` [PATCH v2 34/36] target/arm: Redirect VHE FOO_EL12 to FOO_EL1 " Richard Henderson
2025-09-25 13:27 ` Philippe Mathieu-Daudé
2025-09-25 14:27 ` Peter Maydell
2025-09-16 14:22 ` [PATCH v2 35/36] target/arm: Rename some cpreg to their aarch64 names Richard Henderson
2025-09-25 11:32 ` Philippe Mathieu-Daudé
2025-09-16 14:22 ` [PATCH v2 36/36] target/arm: Remove define_arm_vh_e2h_redirects_aliases Richard Henderson
2025-09-25 13:27 ` Philippe Mathieu-Daudé
2025-09-25 14:37 ` Peter Maydell
2025-09-25 15:10 ` [PATCH v2 00/36] target/arm: Reorg VHE redirection Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250916142238.664316-8-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).