From: Cornelia Huck <cohuck@redhat.com>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [PATCH v2 1/3] arm: handle demuxed ID registers
Date: Wed, 01 Apr 2026 10:17:32 +0200 [thread overview]
Message-ID: <87bjg3drhf.fsf@redhat.com> (raw)
In-Reply-To: <8ecca07b-7ff0-4a46-8de3-6a3f21173a00@linaro.org>
On Thu, Feb 05 2026, Richard Henderson <richard.henderson@linaro.org> wrote:
> On 2/4/26 23:32, Cornelia Huck wrote:
>> 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>
>> Reviewed-by: Sebastian Ott <sebott@redhat.com>
>> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
>> ---
>> target/arm/cpu-sysregs.h | 13 +++++++++++++
>> target/arm/cpu.h | 20 ++++++++++++++++++++
>> 2 files changed, 33 insertions(+)
>>
>> diff --git a/target/arm/cpu-sysregs.h b/target/arm/cpu-sysregs.h
>> index 7877a3b06a8e..911f54bc8a4f 100644
>> --- a/target/arm/cpu-sysregs.h
>> +++ b/target/arm/cpu-sysregs.h
>> @@ -35,6 +35,19 @@ typedef enum ARMSysRegs {
>>
>> #undef DEF
>>
>> +/* ID registers that vary based upon another register */
>> +typedef enum ARMIDRegisterDemuxIdx {
>> + NUM_ID_DEMUX_IDX,
>> +} ARMIDRegisterDemuxIdx;
>> +
>> +/*
>> + * Number of register variants per demuxed register, trying to accommodate
>> + * possible use cases.
>> + * CCSIDR_EL1 currently needs 7*2, could be 7 more with FEAT_MTE2, in which
>> + * case we would need to bump this number.
>> + */
>> +#define ID_DEMUX_ARRAYLEN 16
>> +
>> extern const uint32_t id_register_sysreg[NUM_ID_IDX];
>>
>> int get_sysreg_idx(ARMSysRegs sysreg);
>> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
>> index 21fee5e840b7..f9d51c0fc187 100644
>> --- a/target/arm/cpu.h
>> +++ b/target/arm/cpu.h
>> @@ -906,6 +906,25 @@ typedef struct {
>> i_->idregs[REG ## _EL1_IDX]; \
>> })
>>
>> +#define SET_IDREG_DEMUX(ISAR, REG, INDEX, VALUE) \
>> + ({ \
>> + ARMISARegisters *i_ = (ISAR); \
>> + i_->idregs_demux[REG ## _EL1_DEMUX_IDX][INDEX] = VALUE; \
>> + })
>> +
>> +#define GET_IDREG_DEMUX(ISAR, REG, INDEX) \
>> + ({ \
>> + ARMISARegisters *i_ = (ISAR); \
>> + i_->idregs_demux[REG ## _EL1_DEMUX_IDX][INDEX]; \
>> + })
>> +
>> +#define COPY_IDREG_DEMUX(ISAR, REG, FROM_INDEX, TO_INDEX) \
>> + ({ \
>> + ARMISARegisters *i_ = (ISAR); \
>> + i_->idregs_demux[REG ## _EL1_DEMUX_IDX][TO_INDEX] = \
>> + i_->idregs_demux[REG ## _EL1_DEMUX_IDX][FROM_INDEX]; \
>> + })
>> +
>> /**
>> * ARMCPU:
>> * @env: #CPUARMState
>> @@ -1084,6 +1103,7 @@ struct ArchCPU {
>> uint32_t dbgdevid1;
>> uint64_t reset_pmcr_el0;
>> uint64_t idregs[NUM_ID_IDX];
>> + uint64_t idregs_demux[NUM_ID_DEMUX_IDX][ID_DEMUX_ARRAYLEN];
[Oops, totally overlooked this email! Sorry about that.]
>
> I'm not keen on this. Surely we don't expect all multiplexed ID registers to have the
> same number of sub-registers? A rectangular matrix isn't a great representation. Also,
> you're wasting a hole in idregs[] with CSSIDR_EL1_IDX.
>
> Why not just have the N sub-registers occupy N entries within the regular idregs[]?
> Something like
>
> #define DEF_MUX(NAME, OP0, OP1, CRN, CRM, OP2, NUM) \
> NAME##_DEMUX_IDX, \
> NAME##_DEMUX_LAST = NAME##_DEMUX_IDX + NUM - 1,
>
> #define SET_IDREG_DEMUX(ISAR, REG, INDEX, VALUE) \
> ({ \
> ARMISARegisters *i_ = (ISAR); \
> i_->idregs_demux[REG ## _EL1_DEMUX_IDX + INDEX] = VALUE; \
> })
>
> etc.
Yeah, I was not overly excited about my solution, either. I'll go and
play with this, thanks.
next prev parent reply other threads:[~2026-04-01 8:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 13:32 [PATCH v2 0/3] arm: demuxed ID registers (CCSIDR_EL1) Cornelia Huck
2026-02-04 13:32 ` [PATCH v2 1/3] arm: handle demuxed ID registers Cornelia Huck
2026-02-05 3:24 ` Richard Henderson
2026-04-01 8:17 ` Cornelia Huck [this message]
2026-04-01 16:26 ` Eric Auger
2026-04-02 14:55 ` Cornelia Huck
2026-02-04 13:32 ` [PATCH v2 2/3] arm: handle CCSIDR_EL1 as a demuxed register Cornelia Huck
2026-04-01 16:46 ` Eric Auger
2026-04-02 15:04 ` Cornelia Huck
2026-02-04 13:32 ` [PATCH v2 3/3] arm/kvm: get demuxed ID registers from kvm Cornelia Huck
2026-04-01 17:00 ` Eric Auger
2026-04-02 15:19 ` Cornelia Huck
2026-02-05 11:52 ` [PATCH v2 0/3] arm: demuxed ID registers (CCSIDR_EL1) Peter Maydell
2026-02-05 16:50 ` Cornelia Huck
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=87bjg3drhf.fsf@redhat.com \
--to=cohuck@redhat.com \
--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.