From: Sebastian Ott <sebott@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
Eric Auger <eauger@redhat.com>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Alireza Sanaee <alireza.sanaee@huawei.com>,
Richard Henderson <richard.henderson@linaro.org>,
Cornelia Huck <cohuck@redhat.com>,
khushit.shah@nutanix.com
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org,
Eric Auger <eric.auger@redhat.com>,
Sebastian Ott <sebott@redhat.com>
Subject: [PATCH v5 1/3] arm: handle demuxed ID registers
Date: Wed, 9 Sep 2026 16:41:49 +0200 [thread overview]
Message-ID: <20260909144151.26803-2-sebott@redhat.com> (raw)
In-Reply-To: <20260909144151.26803-1-sebott@redhat.com>
From: Cornelia Huck <cohuck@redhat.com>
For some registers, we do not have a single ID register, but actually
an array of values (e.g. CCSIDR_EL1, where the actual value is
determined by whatever CSSELR_EL1 points to.) If we want to avoid
using a different way to handle registers like that for every
instance, we should provide some kind of infrastructure. Therefore,
add accessors {GET,SET}_IDREG_DEMUX that are similar to the accessors
we already use for regular ID registers.
Tested-by: Alireza Sanaee <alireza.sanaee@huawei.com>
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Sebastian Ott <sebott@redhat.com>
---
target/arm/cpu-sysregs.h | 9 +++++++++
target/arm/cpu.h | 12 ++++++++++++
target/arm/cpu64.c | 8 ++++++++
3 files changed, 29 insertions(+)
diff --git a/target/arm/cpu-sysregs.h b/target/arm/cpu-sysregs.h
index 7877a3b06a..a4b9621a7e 100644
--- a/target/arm/cpu-sysregs.h
+++ b/target/arm/cpu-sysregs.h
@@ -20,20 +20,29 @@
#define DEF(NAME, OP0, OP1, CRN, CRM, OP2) NAME##_IDX,
+#define DEF_MUX(NAME, OP0, OP1, CRN, CRM, OP2, NUM) \
+ NAME##_IDX, \
+ NAME##_IDX_LAST = NAME##_IDX + NUM - 1,
+
typedef enum ARMIDRegisterIdx {
#include "cpu-sysregs.h.inc"
NUM_ID_IDX,
} ARMIDRegisterIdx;
#undef DEF
+#undef DEF_MUX
#define DEF(NAME, OP0, OP1, CRN, CRM, OP2) \
SYS_##NAME = ENCODE_ID_REG(OP0, OP1, CRN, CRM, OP2),
+#define DEF_MUX(NAME, OP0, OP1, CRN, CRM, OP2, NUM) \
+ DEF(NAME, OP0, OP1, CRN, CRM, OP2)
+
typedef enum ARMSysRegs {
#include "cpu-sysregs.h.inc"
} ARMSysRegs;
#undef DEF
+#undef DEF_MUX
extern const uint32_t id_register_sysreg[NUM_ID_IDX];
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index e3f931dba2..9652f8b0bf 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -919,6 +919,18 @@ typedef struct {
i_->idregs[REG ## _EL1_IDX]; \
})
+#define SET_IDREG_DEMUX(ISAR, REG, INDEX, VALUE) \
+ ({ \
+ ARMISARegisters *i_ = (ISAR); \
+ i_->idregs[REG ## _IDX + INDEX] = VALUE; \
+ })
+
+#define GET_IDREG_DEMUX(ISAR, REG, INDEX) \
+ ({ \
+ ARMISARegisters *i_ = (ISAR); \
+ i_->idregs[REG ## _IDX + INDEX]; \
+ })
+
/**
* ARMCPU:
* @env: #CPUARMState
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index 4e8c472530..c11ab2da21 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -42,14 +42,21 @@
#define DEF(NAME, OP0, OP1, CRN, CRM, OP2) \
[NAME##_IDX] = SYS_##NAME,
+#define DEF_MUX(NAME, OP0, OP1, CRN, CRM, OP2, NUM) \
+ DEF(NAME, OP0, OP1, CRN, CRM, OP2)
+
const uint32_t id_register_sysreg[NUM_ID_IDX] = {
#include "cpu-sysregs.h.inc"
};
#undef DEF
+#undef DEF_MUX
#define DEF(NAME, OP0, OP1, CRN, CRM, OP2) \
case SYS_##NAME: return NAME##_IDX;
+#define DEF_MUX(NAME, OP0, OP1, CRN, CRM, OP2, NUM) \
+ DEF(NAME, OP0, OP1, CRN, CRM, OP2)
+
int get_sysreg_idx(ARMSysRegs sysreg)
{
switch (sysreg) {
@@ -59,6 +66,7 @@ int get_sysreg_idx(ARMSysRegs sysreg)
}
#undef DEF
+#undef DEF_MUX
void aarch64_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
{
--
2.55.0
next prev parent reply other threads:[~2026-09-09 14:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 14:41 [PATCH v5 0/3] arm: demuxed ID registers (CCSIDR_EL1) Sebastian Ott
2026-09-09 14:41 ` Sebastian Ott [this message]
2026-09-09 14:41 ` [PATCH v5 2/3] arm: handle CCSIDR_EL1 as a demuxed register Sebastian Ott
2026-09-09 14:41 ` [PATCH v5 3/3] arm/kvm: get demuxed ID registers from kvm Sebastian Ott
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=20260909144151.26803-2-sebott@redhat.com \
--to=sebott@redhat.com \
--cc=alireza.sanaee@huawei.com \
--cc=cohuck@redhat.com \
--cc=eauger@redhat.com \
--cc=eric.auger@redhat.com \
--cc=jonathan.cameron@huawei.com \
--cc=khushit.shah@nutanix.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.