From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
qemu-devel@nongnu.org, qemu-arm@nongnu.org,
peter.maydell@linaro.org, cohuck@redhat.com, maz@kernel.org,
oliver.upton@linux.dev, sebott@redhat.com, gshan@redhat.com,
ddutile@redhat.com, peterx@redhat.com, philmd@linaro.org,
pbonzini@redhat.com
Subject: [PATCH 5/7] target/arm/cpu: Implement hide_reg callback()
Date: Thu, 16 Oct 2025 15:55:17 +0200 [thread overview]
Message-ID: <20251016135625.249551-6-eric.auger@redhat.com> (raw)
In-Reply-To: <20251016135625.249551-1-eric.auger@redhat.com>
Checks if the register is hidden.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
target/arm/cpu.h | 2 ++
target/arm/cpu.c | 12 ++++++++++++
target/arm/kvm.c | 23 ++---------------------
3 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 30d59a51d6..3ae4d65422 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -2687,4 +2687,6 @@ static inline bool is_fake_reg(ARMCPU *cpu, uint64_t regidx)
#define LOG2_TAG_GRANULE 4
#define TAG_GRANULE (1 << LOG2_TAG_GRANULE)
+bool arm_cpu_hide_reg(CPUState *s, uint64_t regidx);
+
#endif
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 3b556f1404..60eee82742 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -2366,6 +2366,17 @@ static const TCGCPUOps arm_tcg_ops = {
};
#endif /* CONFIG_TCG */
+bool arm_cpu_hide_reg(CPUState *s, uint64_t regidx)
+{
+ ARMCPU *cpu = ARM_CPU(s);
+ for (int i = 0; i < cpu->nr_kvm_hidden_regs; i++) {
+ if (cpu->kvm_hidden_regs[i] == regidx) {
+ return true;
+ }
+ }
+ return false;
+}
+
static void arm_cpu_class_init(ObjectClass *oc, const void *data)
{
ARMCPUClass *acc = ARM_CPU_CLASS(oc);
@@ -2394,6 +2405,7 @@ static void arm_cpu_class_init(ObjectClass *oc, const void *data)
cc->gdb_get_core_xml_file = arm_gdb_get_core_xml_file;
cc->gdb_stop_before_watchpoint = true;
cc->disas_set_info = arm_disas_set_info;
+ cc->hide_reg = arm_cpu_hide_reg;
#ifdef CONFIG_TCG
cc->tcg_ops = &arm_tcg_ops;
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 7551c43e79..1a95e2c667 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -754,25 +754,6 @@ static bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx)
}
}
-/**
- * kvm_vcpu_compat_hidden_reg:
- * @cpu: ARMCPU
- * @regidx: index of the register to check
- *
- * Depending on the CPU compat returns true if @regidx must be
- * ignored during sync & migration
- */
-static inline bool
-kvm_vcpu_compat_hidden_reg(ARMCPU *cpu, uint64_t regidx)
-{
- for (int i = 0; i < cpu->nr_kvm_hidden_regs; i++) {
- if (cpu->kvm_hidden_regs[i] == regidx) {
- return true;
- }
- }
- return false;
-}
-
/**
* kvm_arm_init_cpreg_list:
* @cpu: ARMCPU
@@ -834,7 +815,7 @@ static int kvm_arm_init_cpreg_list(ARMCPU *cpu)
uint64_t regidx = rlp->reg[i];
if (!kvm_arm_reg_syncs_via_cpreg_list(regidx) ||
- kvm_vcpu_compat_hidden_reg(cpu, regidx)) {
+ arm_cpu_hide_reg(&cpu->parent_obj, regidx)) {
continue;
}
switch (rlp->reg[i] & KVM_REG_SIZE_MASK) {
@@ -867,7 +848,7 @@ static int kvm_arm_init_cpreg_list(ARMCPU *cpu)
if (!kvm_arm_reg_syncs_via_cpreg_list(regidx)) {
continue;
}
- if (kvm_vcpu_compat_hidden_reg(cpu, regidx)) {
+ if (arm_cpu_hide_reg(&cpu->parent_obj, regidx)) {
trace_kvm_arm_init_cpreg_list_skip_hidden_reg(rlp->reg[i]);
continue;
}
--
2.49.0
next prev parent reply other threads:[~2025-10-16 13:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 13:55 [PATCH 0/7] Mitigation of "failed to load cpu:cpreg_vmstate_array_len" migration failures Eric Auger
2025-10-16 13:55 ` [PATCH 1/7] target/arm/machine: Improve traces on register mismatch during migration Eric Auger
2025-10-16 13:55 ` [PATCH 2/7] target/arm/kvm: Introduce the concept of hidden KVM regs Eric Auger
2025-10-16 13:55 ` [PATCH 3/7] target/arm/kvm: Introduce the concept of enforced/fake registers Eric Auger
2025-10-16 13:55 ` [PATCH 4/7] kvm-all: Add the capability to blacklist some KVM regs Eric Auger
2025-10-16 13:55 ` Eric Auger [this message]
2025-10-16 13:55 ` [PATCH 6/7] target/arm/kvm: Expose kvm-hidden-regs and kvm-fake-regs properties Eric Auger
2025-10-16 14:02 ` [PATCH 0/7] Mitigation of "failed to load cpu:cpreg_vmstate_array_len" migration failures Eric Auger
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=20251016135625.249551-6-eric.auger@redhat.com \
--to=eric.auger@redhat.com \
--cc=cohuck@redhat.com \
--cc=ddutile@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=gshan@redhat.com \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=sebott@redhat.com \
/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).