arm: rework id register storage
v2 cover arm: rework id register storage
[Oh, it's been about a month since I posted the last version of this :/
Unfortunately, life happened. I still do plan to post a rebase of the cpu model patches on top of this.]
Original cover letter below.
Changed from v1:
- Noticed that we missed the hvf code. Converted, compiled, but not tested as I'm lacking an environment for testing.
- Hopefully incorporated most of the suggested changes -- if I missed something, it was unintentional unless mentioned below.
- fixed repeated inclusion of definitions
- hopefully made macros more robust
- removed distinction between reading 32/64 values, which was mostly adding churn for little value
- postponed generating property definitions to the cpu model patches, where they are actually used
- juggled hunks and moved them to the right patches
- fixed some typos
- rebased to a more recent code base
NOT changed from v1:
- definitions are still generated from the Linux sysregs file
- I still think updating the generated files on demand (so that we can double check the result) is the right thing to do
- I'm open to changing the source of the definitions from the sysregs file to the JSON definitions published by Arm; however, I first wanted to get the code using it right -- we can switch out the code generating the file to use a different source easily later on, and I'd also like to steal parts of the script from Linux once integrated (which I think hasn't happened yet?)
Also available at
https://gitlab.com/cohuck/qemu/-/commits/arm-rework-idreg-storage-v2
<v1 cover letter>
[Note: I've kept the cc list from the last round of cpu model patches; so if you're confused as to why you're cc:ed here, take it as a heads-up that a new cpu model series will come along soon]
This patch series contains patches extracted from the larger cpu model series (RFC v2 last posted at
https://lore.kernel.org/qemu-devel/[email protected]/)
and aims at providing a base upon which we can continue with building support for cpu models, but which is hopefully already an improvement on its own.
Main changes from the patches in that series include:
- post-pone the changes to handle KVM writable ID registers for cpu models (I have a series including that on top of this one)
- change how we store the list of ID registers, and access them basically, use an enum for indexing, and an enum doing encodings in a pattern similar to cpregs
- move some hunks to different patches
- update the scripts to generate the register descriptions, and run them against a recent Linux sysregs file
What I've kept:
- generating the register descriptions from the Linux sysregs file I think that file is still our best bet to generate the descriptions easily, and updating the definitions is a manual step that can be checked for unintended changes
- most of the hard work that Eric had been doing; all new bugs in there are my own :)
</v1 cover letter>
Cornelia Huck (2):
arm/kvm: add accessors for storing host features into idregs arm/cpu: Add generated files
Eric Auger (12):
arm/cpu: Add sysreg definitions in cpu-sysregs.h arm/cpu: Store aa64isar0/aa64zfr0 into the idregs arrays arm/cpu: Store aa64isar1/2 into the idregs array arm/cpu: Store aa64pfr0/1 into the idregs array arm/cpu: Store aa64mmfr0-3 into the idregs array arm/cpu: Store aa64dfr0/1 into the idregs array arm/cpu: Store aa64smfr0 into the idregs array arm/cpu: Store id_isar0-7 into the idregs array arm/cpu: Store id_pfr0/1/2 into the idregs array arm/cpu: Store id_dfr0/1 into the idregs array arm/cpu: Store id_mmfr0-5 into the idregs array arm/cpu: Add sysreg generation scripts
hw/intc/armv7m_nvic.c | 27 +- scripts/gen-cpu-sysregs-header.awk | 70 ++++ scripts/update-aarch64-sysreg-code.sh | 35 ++ target/arm/cpu-features.h | 317 +++++++++--------- target/arm/cpu-sysregs.h | 22 ++ target/arm/cpu-sysregs.h.inc | 167 ++++++++++ target/arm/cpu.c | 111 +++---- target/arm/cpu.h | 80 +++-- target/arm/cpu64.c | 131 ++++---- target/arm/helper.c | 68 ++-- target/arm/hvf/hvf.c | 36 +- target/arm/internals.h | 6 +- target/arm/kvm.c | 119 +++---- target/arm/ptw.c | 6 +- target/arm/tcg/cpu-v7m.c | 174 +++++----- target/arm/tcg/cpu32.c | 320 +++++++++--------- target/arm/tcg/cpu64.c | 460 +++++++++++++------------- 17 files changed, 1230 insertions(+), 919 deletions(-) create mode 100755 scripts/gen-cpu-sysregs-header.awk create mode 100755 scripts/update-aarch64-sysreg-code.sh create mode 100644 target/arm/cpu-sysregs.h create mode 100644 target/arm/cpu-sysregs.h.inc
Signature · 1 line
2.48.1
PATCH v2 1/14 arm/cpu: Add sysreg definitions in cpu-sysregs.h
From: Eric Auger <[email protected]>
This new header contains macros that define aarch64 registers. In a subsequent patch, this will be replaced by a more exhaustive version that will be generated from linux arch/arm64/tools/sysreg file. Those macros are sufficient to migrate the storage of those ID regs from named fields in isar struct to an array cell.
[CH: reworked to use different structures]
[CH: moved accessors from the patches first using them to here,
dropped interaction with writable registers, which will happen later]
--- target/arm/cpu-sysregs.h | 131 +++++++++++++++++++++++++++++++++++++++ target/arm/cpu.h | 49 +++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 target/arm/cpu-sysregs.h
target/arm/cpu-sysregs.h new file +131 -0
@@ -0,0 +1,131 @@ +#ifndef ARM_CPU_SYSREGS_H +#define ARM_CPU_SYSREGS_H + +/* +* Following is similar to the coprocessor regs encodings, but with an argument +* ordering that matches the ARM ARM. We also reuse the various CP_REG_ defines +* that actually are the same as the equivalent KVM_REG_ values. +*/ +#define ENCODE_ID_REG (op0, op1, crn, crm, op2) \ + (((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \ + ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \ + ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \ + ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \ + ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT)) + +typedef enum ARMIDRegisterIdx { +ID_AA64PFR0_EL1_IDX , +ID_AA64PFR1_EL1_IDX , +ID_AA64SMFR0_EL1_IDX , +ID_AA64DFR0_EL1_IDX , +ID_AA64DFR1_EL1_IDX , +ID_AA64ISAR0_EL1_IDX , +ID_AA64ISAR1_EL1_IDX , +ID_AA64ISAR2_EL1_IDX , +ID_AA64MMFR0_EL1_IDX , +ID_AA64MMFR1_EL1_IDX , +ID_AA64MMFR2_EL1_IDX , +ID_AA64MMFR3_EL1_IDX , +ID_PFR0_EL1_IDX , +ID_PFR1_EL1_IDX , +ID_DFR0_EL1_IDX , +ID_MMFR0_EL1_IDX , +ID_MMFR1_EL1_IDX , +ID_MMFR2_EL1_IDX , +ID_MMFR3_EL1_IDX , +ID_ISAR0_EL1_IDX , +ID_ISAR1_EL1_IDX , +ID_ISAR2_EL1_IDX , +ID_ISAR3_EL1_IDX , +ID_ISAR4_EL1_IDX , +ID_ISAR5_EL1_IDX , +ID_MMFR4_EL1_IDX , +ID_ISAR6_EL1_IDX , +MVFR0_EL1_IDX , +MVFR1_EL1_IDX , +MVFR2_EL1_IDX , +ID_PFR2_EL1_IDX , +ID_DFR1_EL1_IDX , +ID_MMFR5_EL1_IDX , +ID_AA64ZFR0_EL1_IDX , +CTR_EL0_IDX , +NUM_ID_IDX , +}ARMIDRegisterIdx ; + +typedef enum ARMSysRegs { +SYS_ID_AA64PFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,0 ), +SYS_ID_AA64PFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,1 ), +SYS_ID_AA64SMFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,5 ), +SYS_ID_AA64DFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,5 ,0 ), +SYS_ID_AA64DFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,5 ,1 ), +SYS_ID_AA64ISAR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,6 ,0 ), +SYS_ID_AA64ISAR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,6 ,1 ), +SYS_ID_AA64ISAR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,6 ,2 ), +SYS_ID_AA64MMFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,0 ), +SYS_ID_AA64MMFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,1 ), +SYS_ID_AA64MMFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,2 ), +SYS_ID_AA64MMFR3_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,3 ), +SYS_ID_PFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,0 ), +SYS_ID_PFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,1 ), +SYS_ID_DFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,2 ), +SYS_ID_MMFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,4 ), +SYS_ID_MMFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,5 ), +SYS_ID_MMFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,6 ), +SYS_ID_MMFR3_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,7 ), +SYS_ID_ISAR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,0 ), +SYS_ID_ISAR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,1 ), +SYS_ID_ISAR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,2 ), +SYS_ID_ISAR3_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,3 ), +SYS_ID_ISAR4_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,4 ), +SYS_ID_ISAR5_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,5 ), +SYS_ID_MMFR4_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,6 ), +SYS_ID_ISAR6_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,7 ), +SYS_MVFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,0 ), +SYS_MVFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,1 ), +SYS_MVFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,2 ), +SYS_ID_PFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,4 ), +SYS_ID_DFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,5 ), +SYS_ID_MMFR5_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,6 ), +SYS_ID_AA64ZFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,4 ), +SYS_CTR_EL0 =ENCODE_ID_REG (3 ,3 ,0 ,0 ,1 ), +}ARMSysRegs ; + +static const uint32_t id_register_sysreg[NUM_ID_IDX ] = { + [ID_AA64PFR0_EL1_IDX ] =SYS_ID_AA64PFR0_EL1 , + [ID_AA64PFR1_EL1_IDX ] =SYS_ID_AA64PFR1_EL1 , + [ID_AA64SMFR0_EL1_IDX ] =SYS_ID_AA64SMFR0_EL1 , + [ID_AA64DFR0_EL1_IDX ] =SYS_ID_AA64DFR0_EL1 , + [ID_AA64DFR1_EL1_IDX ] =SYS_ID_AA64DFR1_EL1 , + [ID_AA64ISAR0_EL1_IDX ] =SYS_ID_AA64ISAR0_EL1 , + [ID_AA64ISAR1_EL1_IDX ] =SYS_ID_AA64ISAR1_EL1 , + [ID_AA64ISAR2_EL1_IDX ] =SYS_ID_AA64ISAR2_EL1 , + [ID_AA64MMFR0_EL1_IDX ] =SYS_ID_AA64MMFR0_EL1 , + [ID_AA64MMFR1_EL1_IDX ] =SYS_ID_AA64MMFR1_EL1 , + [ID_AA64MMFR2_EL1_IDX ] =SYS_ID_AA64MMFR2_EL1 , + [ID_AA64MMFR3_EL1_IDX ] =SYS_ID_AA64MMFR3_EL1 , + [ID_PFR0_EL1_IDX ] =SYS_ID_PFR0_EL1 , + [ID_PFR1_EL1_IDX ] =SYS_ID_PFR1_EL1 , + [ID_DFR0_EL1_IDX ] =SYS_ID_DFR0_EL1 , + [ID_MMFR0_EL1_IDX ] =SYS_ID_MMFR0_EL1 , + [ID_MMFR1_EL1_IDX ] =SYS_ID_MMFR1_EL1 , + [ID_MMFR2_EL1_IDX ] =SYS_ID_MMFR2_EL1 , + [ID_MMFR3_EL1_IDX ] =SYS_ID_MMFR3_EL1 , + [ID_ISAR0_EL1_IDX ] =SYS_ID_ISAR0_EL1 , + [ID_ISAR1_EL1_IDX ] =SYS_ID_ISAR1_EL1 , + [ID_ISAR2_EL1_IDX ] =SYS_ID_ISAR2_EL1 , + [ID_ISAR3_EL1_IDX ] =SYS_ID_ISAR3_EL1 , + [ID_ISAR4_EL1_IDX ] =SYS_ID_ISAR4_EL1 , + [ID_ISAR5_EL1_IDX ] =SYS_ID_ISAR5_EL1 , + [ID_MMFR4_EL1_IDX ] =SYS_ID_MMFR4_EL1 , + [ID_ISAR6_EL1_IDX ] =SYS_ID_ISAR6_EL1 , + [MVFR0_EL1_IDX ] =SYS_MVFR0_EL1 , + [MVFR1_EL1_IDX ] =SYS_MVFR1_EL1 , + [MVFR2_EL1_IDX ] =SYS_MVFR2_EL1 , + [ID_PFR2_EL1_IDX ] =SYS_ID_PFR2_EL1 , + [ID_DFR1_EL1_IDX ] =SYS_ID_DFR1_EL1 , + [ID_MMFR5_EL1_IDX ] =SYS_ID_MMFR5_EL1 , + [ID_AA64ZFR0_EL1_IDX ] =SYS_ID_AA64ZFR0_EL1 , + [CTR_EL0_IDX ] =SYS_CTR_EL0 , +}; + +#endif /* ARM_CPU_SYSREGS_H */
target/arm/cpu.h +49 -0
67 lines not on this page · raw message
Signature · 1 line
2.48.1
Re: [PATCH v2 01/14] arm/cpu: Add sysreg definitions in cpu-sysregs.h
Quoted 121 lines · Cornelia Huck
+++
b/target/arm/cpu-sysregs.htarget/arm/cpu-sysregs.h new file +119
-0@@ -0,0 +1,131 @@ +#ifndef ARM_CPU_SYSREGS_H +#define ARM_CPU_SYSREGS_H + +/* +* Following is similar to the coprocessor regs encodings, but with an argument +* ordering that matches the ARM ARM. We also reuse the various CP_REG_ defines +* that actually are the same as the equivalent KVM_REG_ values. +*/ +#define ENCODE_ID_REG (op0, op1, crn, crm, op2) \ + (((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \ + ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \ + ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \ + ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \ + ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT)) + +typedef enum ARMIDRegisterIdx { +ID_AA64PFR0_EL1_IDX , +ID_AA64PFR1_EL1_IDX , +ID_AA64SMFR0_EL1_IDX , +ID_AA64DFR0_EL1_IDX , +ID_AA64DFR1_EL1_IDX , +ID_AA64ISAR0_EL1_IDX , +ID_AA64ISAR1_EL1_IDX , +ID_AA64ISAR2_EL1_IDX , +ID_AA64MMFR0_EL1_IDX , +ID_AA64MMFR1_EL1_IDX , +ID_AA64MMFR2_EL1_IDX , +ID_AA64MMFR3_EL1_IDX , +ID_PFR0_EL1_IDX , +ID_PFR1_EL1_IDX , +ID_DFR0_EL1_IDX , +ID_MMFR0_EL1_IDX , +ID_MMFR1_EL1_IDX , +ID_MMFR2_EL1_IDX , +ID_MMFR3_EL1_IDX , +ID_ISAR0_EL1_IDX , +ID_ISAR1_EL1_IDX , +ID_ISAR2_EL1_IDX , +ID_ISAR3_EL1_IDX , +ID_ISAR4_EL1_IDX , +ID_ISAR5_EL1_IDX , +ID_MMFR4_EL1_IDX , +ID_ISAR6_EL1_IDX , +MVFR0_EL1_IDX , +MVFR1_EL1_IDX , +MVFR2_EL1_IDX , +ID_PFR2_EL1_IDX , +ID_DFR1_EL1_IDX , +ID_MMFR5_EL1_IDX , +ID_AA64ZFR0_EL1_IDX , +CTR_EL0_IDX , +NUM_ID_IDX , +}ARMIDRegisterIdx ; + +typedef enum ARMSysRegs { +SYS_ID_AA64PFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,0 ), +SYS_ID_AA64PFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,1 ), +SYS_ID_AA64SMFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,5 ), +SYS_ID_AA64DFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,5 ,0 ), +SYS_ID_AA64DFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,5 ,1 ), +SYS_ID_AA64ISAR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,6 ,0 ), +SYS_ID_AA64ISAR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,6 ,1 ), +SYS_ID_AA64ISAR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,6 ,2 ), +SYS_ID_AA64MMFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,0 ), +SYS_ID_AA64MMFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,1 ), +SYS_ID_AA64MMFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,2 ), +SYS_ID_AA64MMFR3_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,3 ), +SYS_ID_PFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,0 ), +SYS_ID_PFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,1 ), +SYS_ID_DFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,2 ), +SYS_ID_MMFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,4 ), +SYS_ID_MMFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,5 ), +SYS_ID_MMFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,6 ), +SYS_ID_MMFR3_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,7 ), +SYS_ID_ISAR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,0 ), +SYS_ID_ISAR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,1 ), +SYS_ID_ISAR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,2 ), +SYS_ID_ISAR3_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,3 ), +SYS_ID_ISAR4_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,4 ), +SYS_ID_ISAR5_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,5 ), +SYS_ID_MMFR4_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,6 ), +SYS_ID_ISAR6_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,7 ), +SYS_MVFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,0 ), +SYS_MVFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,1 ), +SYS_MVFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,2 ), +SYS_ID_PFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,4 ), +SYS_ID_DFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,5 ), +SYS_ID_MMFR5_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,6 ), +SYS_ID_AA64ZFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,4 ), +SYS_CTR_EL0 =ENCODE_ID_REG (3 ,3 ,0 ,0 ,1 ), +}ARMSysRegs ; + +static const uint32_t id_register_sysreg[NUM_ID_IDX ] = { + [ID_AA64PFR0_EL1_IDX ] =SYS_ID_AA64PFR0_EL1 , + [ID_AA64PFR1_EL1_IDX ] =SYS_ID_AA64PFR1_EL1 , + [ID_AA64SMFR0_EL1_IDX ] =SYS_ID_AA64SMFR0_EL1 , + [ID_AA64DFR0_EL1_IDX ] =SYS_ID_AA64DFR0_EL1 , + [ID_AA64DFR1_EL1_IDX ] =SYS_ID_AA64DFR1_EL1 , + [ID_AA64ISAR0_EL1_IDX ] =SYS_ID_AA64ISAR0_EL1 , + [ID_AA64ISAR1_EL1_IDX ] =SYS_ID_AA64ISAR1_EL1 , + [ID_AA64ISAR2_EL1_IDX ] =SYS_ID_AA64ISAR2_EL1 , + [ID_AA64MMFR0_EL1_IDX ] =SYS_ID_AA64MMFR0_EL1 , + [ID_AA64MMFR1_EL1_IDX ] =SYS_ID_AA64MMFR1_EL1 , + [ID_AA64MMFR2_EL1_IDX ] =SYS_ID_AA64MMFR2_EL1 , + [ID_AA64MMFR3_EL1_IDX ] =SYS_ID_AA64MMFR3_EL1 , + [ID_PFR0_EL1_IDX ] =SYS_ID_PFR0_EL1 , + [ID_PFR1_EL1_IDX ] =SYS_ID_PFR1_EL1 , + [ID_DFR0_EL1_IDX ] =SYS_ID_DFR0_EL1 , + [ID_MMFR0_EL1_IDX ] =SYS_ID_MMFR0_EL1 , + [ID_MMFR1_EL1_IDX ] =SYS_ID_MMFR1_EL1 , + [ID_MMFR2_EL1_IDX ] =SYS_ID_MMFR2_EL1 , + [ID_MMFR3_EL1_IDX ] =SYS_ID_MMFR3_EL1 , + [ID_ISAR0_EL1_IDX ] =SYS_ID_ISAR0_EL1 , + [ID_ISAR1_EL1_IDX ] =SYS_ID_ISAR1_EL1 , + [ID_ISAR2_EL1_IDX ] =SYS_ID_ISAR2_EL1 , + [ID_ISAR3_EL1_IDX ] =SYS_ID_ISAR3_EL1 , + [ID_ISAR4_EL1_IDX ] =SYS_ID_ISAR4_EL1 , + [ID_ISAR5_EL1_IDX ] =SYS_ID_ISAR5_EL1 , + [ID_MMFR4_EL1_IDX] = SYS_ID_MMFR4_EL1,
target/arm/cpu-sysregs.h line 129
Quoted 10 lines
target/arm/cpu-sysregs.h new file +10
-0+ [ID_ISAR6_EL1_IDX] = SYS_ID_ISAR6_EL1, + [MVFR0_EL1_IDX] = SYS_MVFR0_EL1, + [MVFR1_EL1_IDX] = SYS_MVFR1_EL1, + [MVFR2_EL1_IDX] = SYS_MVFR2_EL1, + [ID_PFR2_EL1_IDX] = SYS_ID_PFR2_EL1, + [ID_DFR1_EL1_IDX] = SYS_ID_DFR1_EL1, + [ID_MMFR5_EL1_IDX] = SYS_ID_MMFR5_EL1, + [ID_AA64ZFR0_EL1_IDX] = SYS_ID_AA64ZFR0_EL1, + [CTR_EL0_IDX] = SYS_CTR_EL0, +};
Again, you should NOT place this array in a header, to be replicated in every single user of the header.
This can be a bit more automated to avoid mistakes.
--- target/arm/cpu-sysregs.h.inc
DEF(ID_AA64PFR0_EL1, 3, 0, 0, 4, 0)
...
--- target/arm/cpu-sysregs.h
#define DEF(NAME, OP0, OP1, CRN, CRM, OP2) NAME##_IDX,
typedef enum ARMIDRegisterIdx {
#include "cpu-sysregs.h.inc"
} ARMIDRegisterIdx;
#undef DEF
#define DEF(NAME, OP0, OP1, CRN, CRM, OP2) \
SYS_##NAME = ENCODE_ID_REG(OP0, OP1, CRN, CRM, OP2),typedef enum ARMSysRegs {
#include "cpu-sysregs.h.inc"
} ARMSysRegs;
#undef DEF
r~
Re: [PATCH v2 01/14] arm/cpu: Add sysreg definitions in cpu-sysregs.h
Quoted 127 lines · Richard Henderson
Quoted 126 lines · Cornelia Huck
+++
b/target/arm/cpu-sysregs.htarget/arm/cpu-sysregs.h new file +124
-0@@ -0,0 +1,131 @@ +#ifndef ARM_CPU_SYSREGS_H +#define ARM_CPU_SYSREGS_H + +/* +* Following is similar to the coprocessor regs encodings, but with an argument +* ordering that matches the ARM ARM. We also reuse the various CP_REG_ defines +* that actually are the same as the equivalent KVM_REG_ values. +*/ +#define ENCODE_ID_REG (op0, op1, crn, crm, op2) \ + (((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \ + ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \ + ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \ + ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \ + ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT)) + +typedef enum ARMIDRegisterIdx { +ID_AA64PFR0_EL1_IDX , +ID_AA64PFR1_EL1_IDX , +ID_AA64SMFR0_EL1_IDX , +ID_AA64DFR0_EL1_IDX , +ID_AA64DFR1_EL1_IDX , +ID_AA64ISAR0_EL1_IDX , +ID_AA64ISAR1_EL1_IDX , +ID_AA64ISAR2_EL1_IDX , +ID_AA64MMFR0_EL1_IDX , +ID_AA64MMFR1_EL1_IDX , +ID_AA64MMFR2_EL1_IDX , +ID_AA64MMFR3_EL1_IDX , +ID_PFR0_EL1_IDX , +ID_PFR1_EL1_IDX , +ID_DFR0_EL1_IDX , +ID_MMFR0_EL1_IDX , +ID_MMFR1_EL1_IDX , +ID_MMFR2_EL1_IDX , +ID_MMFR3_EL1_IDX , +ID_ISAR0_EL1_IDX , +ID_ISAR1_EL1_IDX , +ID_ISAR2_EL1_IDX , +ID_ISAR3_EL1_IDX , +ID_ISAR4_EL1_IDX , +ID_ISAR5_EL1_IDX , +ID_MMFR4_EL1_IDX , +ID_ISAR6_EL1_IDX , +MVFR0_EL1_IDX , +MVFR1_EL1_IDX , +MVFR2_EL1_IDX , +ID_PFR2_EL1_IDX , +ID_DFR1_EL1_IDX , +ID_MMFR5_EL1_IDX , +ID_AA64ZFR0_EL1_IDX , +CTR_EL0_IDX , +NUM_ID_IDX , +}ARMIDRegisterIdx ; + +typedef enum ARMSysRegs { +SYS_ID_AA64PFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,0 ), +SYS_ID_AA64PFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,1 ), +SYS_ID_AA64SMFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,5 ), +SYS_ID_AA64DFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,5 ,0 ), +SYS_ID_AA64DFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,5 ,1 ), +SYS_ID_AA64ISAR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,6 ,0 ), +SYS_ID_AA64ISAR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,6 ,1 ), +SYS_ID_AA64ISAR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,6 ,2 ), +SYS_ID_AA64MMFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,0 ), +SYS_ID_AA64MMFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,1 ), +SYS_ID_AA64MMFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,2 ), +SYS_ID_AA64MMFR3_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,3 ), +SYS_ID_PFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,0 ), +SYS_ID_PFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,1 ), +SYS_ID_DFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,2 ), +SYS_ID_MMFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,4 ), +SYS_ID_MMFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,5 ), +SYS_ID_MMFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,6 ), +SYS_ID_MMFR3_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,7 ), +SYS_ID_ISAR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,0 ), +SYS_ID_ISAR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,1 ), +SYS_ID_ISAR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,2 ), +SYS_ID_ISAR3_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,3 ), +SYS_ID_ISAR4_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,4 ), +SYS_ID_ISAR5_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,5 ), +SYS_ID_MMFR4_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,6 ), +SYS_ID_ISAR6_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,7 ), +SYS_MVFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,0 ), +SYS_MVFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,1 ), +SYS_MVFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,2 ), +SYS_ID_PFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,4 ), +SYS_ID_DFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,5 ), +SYS_ID_MMFR5_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,6 ), +SYS_ID_AA64ZFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,4 ), +SYS_CTR_EL0 =ENCODE_ID_REG (3 ,3 ,0 ,0 ,1 ), +}ARMSysRegs ; + +static const uint32_t id_register_sysreg[NUM_ID_IDX ] = { + [ID_AA64PFR0_EL1_IDX ] =SYS_ID_AA64PFR0_EL1 , + [ID_AA64PFR1_EL1_IDX ] =SYS_ID_AA64PFR1_EL1 , + [ID_AA64SMFR0_EL1_IDX ] =SYS_ID_AA64SMFR0_EL1 , + [ID_AA64DFR0_EL1_IDX ] =SYS_ID_AA64DFR0_EL1 , + [ID_AA64DFR1_EL1_IDX ] =SYS_ID_AA64DFR1_EL1 , + [ID_AA64ISAR0_EL1_IDX ] =SYS_ID_AA64ISAR0_EL1 , + [ID_AA64ISAR1_EL1_IDX ] =SYS_ID_AA64ISAR1_EL1 , + [ID_AA64ISAR2_EL1_IDX ] =SYS_ID_AA64ISAR2_EL1 , + [ID_AA64MMFR0_EL1_IDX ] =SYS_ID_AA64MMFR0_EL1 , + [ID_AA64MMFR1_EL1_IDX ] =SYS_ID_AA64MMFR1_EL1 , + [ID_AA64MMFR2_EL1_IDX ] =SYS_ID_AA64MMFR2_EL1 , + [ID_AA64MMFR3_EL1_IDX ] =SYS_ID_AA64MMFR3_EL1 , + [ID_PFR0_EL1_IDX ] =SYS_ID_PFR0_EL1 , + [ID_PFR1_EL1_IDX ] =SYS_ID_PFR1_EL1 , + [ID_DFR0_EL1_IDX ] =SYS_ID_DFR0_EL1 , + [ID_MMFR0_EL1_IDX ] =SYS_ID_MMFR0_EL1 , + [ID_MMFR1_EL1_IDX ] =SYS_ID_MMFR1_EL1 , + [ID_MMFR2_EL1_IDX ] =SYS_ID_MMFR2_EL1 , + [ID_MMFR3_EL1_IDX ] =SYS_ID_MMFR3_EL1 , + [ID_ISAR0_EL1_IDX ] =SYS_ID_ISAR0_EL1 , + [ID_ISAR1_EL1_IDX ] =SYS_ID_ISAR1_EL1 , + [ID_ISAR2_EL1_IDX ] =SYS_ID_ISAR2_EL1 , + [ID_ISAR3_EL1_IDX ] =SYS_ID_ISAR3_EL1 , + [ID_ISAR4_EL1_IDX ] =SYS_ID_ISAR4_EL1 , + [ID_ISAR5_EL1_IDX ] =SYS_ID_ISAR5_EL1 , + [ID_MMFR4_EL1_IDX ] =SYS_ID_MMFR4_EL1 , + [ID_ISAR6_EL1_IDX ] =SYS_ID_ISAR6_EL1 , + [MVFR0_EL1_IDX ] =SYS_MVFR0_EL1 , + [MVFR1_EL1_IDX ] =SYS_MVFR1_EL1 , + [MVFR2_EL1_IDX ] =SYS_MVFR2_EL1 , + [ID_PFR2_EL1_IDX] = SYS_ID_PFR2_EL1,
Quoted 8 lines
target/arm/cpu-sysregs.h line 129
Quoted 5 lines
target/arm/cpu-sysregs.h new file +5
-0+ [ID_DFR1_EL1_IDX] = SYS_ID_DFR1_EL1, + [ID_MMFR5_EL1_IDX] = SYS_ID_MMFR5_EL1, + [ID_AA64ZFR0_EL1_IDX] = SYS_ID_AA64ZFR0_EL1, + [CTR_EL0_IDX] = SYS_CTR_EL0, +};Again, you should NOT place this array in a header, to be replicated in every single user of the header.
Hrm, I thought I had addressed this... but apparently not.
Quoted 3 lines
This can be a bit more automated to avoid mistakes.
You mean to reduce this to a single invocation of the parsing script? (The hand-written version is more error prone, I agree.)
Quoted 26 lines
--- target/arm/cpu-sysregs.h.inc
DEF(ID_AA64PFR0_EL1, 3, 0, 0, 4, 0)
...---
target/arm/cpu-sysregs.h#define
DEF(NAME, OP0, OP1, CRN, CRM, OP2)NAME##_IDX,typedef enum ARMIDRegisterIdx {
#include "cpu-sysregs.h.inc"
} ARMIDRegisterIdx;#undef DEF
#define DEF(NAME, OP0, OP1, CRN, CRM, OP2) \ SYS_##NAME = ENCODE_ID_REG(OP0, OP1, CRN, CRM, OP2),typedef enum ARMSysRegs {
#include "cpu-sysregs.h.inc"
} ARMSysRegs;#undef DEF
r~
PATCH v2 2/14 arm/kvm: add accessors for storing host features into idregs
In reply to Cornelia Huck--- target/arm/cpu-sysregs.h | 3 +++ target/arm/cpu64.c | 25 +++++++++++++++++++++++++ target/arm/kvm.c | 12 ++++++++++++ 3 files changed, 40 insertions(+)
target/arm/cpu-sysregs.h +3 -0
@@ -128,4 +128,7 @@ static const uint32_t id_register_sysreg[NUM_ID_IDX] = { [CTR_EL0_IDX] = SYS_CTR_EL0, }; +int get_sysreg_idx (ARMSysRegs sysreg); +uint64_t idregs_sysreg_to_kvm_reg (ARMSysRegs sysreg); +#endif /* ARM_CPU_SYSREGS_H */
target/arm/cpu64.c +25 -0
@@ -736,6 +736,31 @@ static void aarch64_a53_initfn(Object *obj)define_cortex_a72_a57_a53_cp_reginfo (cpu); } +#ifdef CONFIG_KVM + +int get_sysreg_idx (ARMSysRegs sysreg) +{ +int i; + +for (i =0 ; i <NUM_ID_IDX ; i++) { +if (id_register_sysreg[i] == sysreg) { +return i; + } + } +return -1 ; +} + +uint64_t idregs_sysreg_to_kvm_reg (ARMSysRegs sysreg) +{ +return ARM64_SYS_REG ((sysreg &CP_REG_ARM64_SYSREG_OP0_MASK ) >>CP_REG_ARM64_SYSREG_OP0_SHIFT , + (sysreg &CP_REG_ARM64_SYSREG_OP1_MASK ) >>CP_REG_ARM64_SYSREG_OP1_SHIFT , + (sysreg &CP_REG_ARM64_SYSREG_CRN_MASK ) >>CP_REG_ARM64_SYSREG_CRN_SHIFT , + (sysreg &CP_REG_ARM64_SYSREG_CRM_MASK ) >>CP_REG_ARM64_SYSREG_CRM_SHIFT , + (sysreg &CP_REG_ARM64_SYSREG_OP2_MASK ) >>CP_REG_ARM64_SYSREG_OP2_SHIFT ); +} + +#endif +static void aarch64_host_initfn (Object *obj) {#if defined(CONFIG_KVM )
target/arm/kvm.c +12 -0
@@ -246,6 +246,18 @@ static bool kvm_arm_pauth_supported(void) kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_GENERIC)); } +/* read a sysreg value and store it in the idregs */ +static int get_host_cpu_reg (int fd,ARMHostCPUFeatures *ahcf,ARMIDRegisterIdx index) +{ +uint64_t *reg; +int ret; + + reg = &ahcf->isar.idregs[index]; + ret =read_sys_reg64 (fd, reg, +idregs_sysreg_to_kvm_reg (id_register_sysreg[index])); +return ret; +} +static bool kvm_arm_get_host_cpu_features (ARMHostCPUFeatures *ahcf) {/* Identify the feature bits corresponding to the host CPU, and
Signature · 1 line
2.48.1
Re: [PATCH v2 02/14] arm/kvm: add accessors for storing host features into idregs
Quoted 41 lines · Cornelia Huck
Signed-off-by Cornelia Huck <[email protected]>--- target/arm/cpu-sysregs.h | 3 +++ target/arm/cpu64.c | 25 +++++++++++++++++++++++++ target/arm/kvm.c | 12 ++++++++++++ 3 files changed, 40 insertions(+)target/arm/cpu-sysregs.h +3
-0@@ -128,4 +128,7 @@ static const uint32_t id_register_sysreg[NUM_ID_IDX] = { [CTR_EL0_IDX] = SYS_CTR_EL0, }; +int get_sysreg_idx (ARMSysRegs sysreg); +uint64_t idregs_sysreg_to_kvm_reg (ARMSysRegs sysreg); +#endif /* ARM_CPU_SYSREGS_H */ target/arm/cpu64.c +14
-0@@ -736,6 +736,31 @@ static void aarch64_a53_initfn(Object *obj)define_cortex_a72_a57_a53_cp_reginfo (cpu); } +#ifdef CONFIG_KVM + +int get_sysreg_idx (ARMSysRegs sysreg) +{ +int i; + +for (i =0 ; i <NUM_ID_IDX ; i++) { +if (id_register_sysreg[i] == sysreg) { +return i; + } + } +return -1 ; +} +
target/arm/cpu64.c static void aarch64_a53_initfn(Object *obj) · line 762
Quoted 10 lines
target/arm/cpu64.c +10
-0+uint64_t idregs_sysreg_to_kvm_reg (ARMSysRegs sysreg) +{ +return ARM64_SYS_REG ((sysreg &CP_REG_ARM64_SYSREG_OP0_MASK ) >>CP_REG_ARM64_SYSREG_OP0_SHIFT , + (sysreg &CP_REG_ARM64_SYSREG_OP1_MASK ) >>CP_REG_ARM64_SYSREG_OP1_SHIFT , + (sysreg &CP_REG_ARM64_SYSREG_CRN_MASK ) >>CP_REG_ARM64_SYSREG_CRN_SHIFT , + (sysreg &CP_REG_ARM64_SYSREG_CRM_MASK ) >>CP_REG_ARM64_SYSREG_CRM_SHIFT , + (sysreg &CP_REG_ARM64_SYSREG_OP2_MASK ) >>CP_REG_ARM64_SYSREG_OP2_SHIFT ); +} + +#endif
Why are these here, with an ifdef, instead of in kvm.c?
Rather than a loop over an array, you could do
#define DEF(NAME, OP0, OP1, CRN, CRM, OP2) \
case SYS_##NAME: return NAME##_IDX;int get_sysreg_idx(ARMSysRegs sysreg)
{
switch (sysreg) {
#include "cpu-sysregs.h.inc"
}
g_assert_not_reached();
}#undef DEF
Quoted 9 lines
target/arm/kvm.c +1
-0@@ -246,6 +246,18 @@ static bool kvm_arm_pauth_supported(void) kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_GENERIC)); } +/* read a sysreg value and store it in the idregs */
target/arm/kvm.c static bool kvm_arm_pauth_supported(void) · line 259
Quoted 10 lines
target/arm/kvm.c +10
-0+static int get_host_cpu_reg (int fd,ARMHostCPUFeatures *ahcf,ARMIDRegisterIdx index) +{ +uint64_t *reg; +int ret; + + reg = &ahcf->isar.idregs[index]; + ret =read_sys_reg64 (fd, reg, +idregs_sysreg_to_kvm_reg (id_register_sysreg[index])); +return ret; +}
Surely this patch doesn't compile by itself,
because this will Werror for the unused function.
r~
Re: [PATCH v2 02/14] arm/kvm: add accessors for storing host features into idregs
Quoted 61 lines · Richard Henderson
Quoted 41 lines · Cornelia Huck
Signed-off-by Cornelia Huck <[email protected]>--- target/arm/cpu-sysregs.h | 3 +++ target/arm/cpu64.c | 25 +++++++++++++++++++++++++ target/arm/kvm.c | 12 ++++++++++++ 3 files changed, 40 insertions(+)target/arm/cpu-sysregs.h +3
-0@@ -128,4 +128,7 @@ static const uint32_t id_register_sysreg[NUM_ID_IDX] = { [CTR_EL0_IDX] = SYS_CTR_EL0, }; +int get_sysreg_idx (ARMSysRegs sysreg); +uint64_t idregs_sysreg_to_kvm_reg (ARMSysRegs sysreg); +#endif /* ARM_CPU_SYSREGS_H */ target/arm/cpu64.c +14
-0@@ -736,6 +736,31 @@ static void aarch64_a53_initfn(Object *obj)define_cortex_a72_a57_a53_cp_reginfo (cpu); } +#ifdef CONFIG_KVM + +int get_sysreg_idx (ARMSysRegs sysreg) +{ +int i; + +for (i =0 ; i <NUM_ID_IDX ; i++) { +if (id_register_sysreg[i] == sysreg) { +return i; + } + } +return -1 ; +} +target/arm/cpu64.c static void aarch64_a53_initfn(Object *obj) · line 762
Quoted 10 lines
target/arm/cpu64.c +10
-0+uint64_t idregs_sysreg_to_kvm_reg (ARMSysRegs sysreg) +{ +return ARM64_SYS_REG ((sysreg &CP_REG_ARM64_SYSREG_OP0_MASK ) >>CP_REG_ARM64_SYSREG_OP0_SHIFT , + (sysreg &CP_REG_ARM64_SYSREG_OP1_MASK ) >>CP_REG_ARM64_SYSREG_OP1_SHIFT , + (sysreg &CP_REG_ARM64_SYSREG_CRN_MASK ) >>CP_REG_ARM64_SYSREG_CRN_SHIFT , + (sysreg &CP_REG_ARM64_SYSREG_CRM_MASK ) >>CP_REG_ARM64_SYSREG_CRM_SHIFT , + (sysreg &CP_REG_ARM64_SYSREG_OP2_MASK ) >>CP_REG_ARM64_SYSREG_OP2_SHIFT ); +} + +#endif Why are these here, with an ifdef, instead of in
kvm.c?Rather than a loop over an array, you could do
#define DEF(NAME, OP0, OP1, CRN, CRM, OP2) \ case SYS_##NAME: return NAME##_IDX;int
get_sysreg_idx(ARMSysRegs sysreg)
Quoted 8 lines
{ switch (sysreg) { #include "cpu-sysregs.h.inc" } g_assert_not_reached(); }#undef DEF
Ok, now I see where you're going with the DEF(...) magic.
Quoted 9 lines
Quoted 9 lines
target/arm/kvm.c +0
-0@@ -246,6 +246,18 @@ static bool kvm_arm_pauth_supported(void) kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_GENERIC)); }
Quoted 14 lines
target/arm/kvm.c static bool kvm_arm_pauth_supported(void) · line 259
Quoted 11 lines
target/arm/kvm.c +11
-0+/* read a sysreg value and store it in the idregs */ +static int get_host_cpu_reg (int fd,ARMHostCPUFeatures *ahcf,ARMIDRegisterIdx index) +{ +uint64_t *reg; +int ret; + + reg = &ahcf->isar.idregs[index]; + ret =read_sys_reg64 (fd, reg, +idregs_sysreg_to_kvm_reg (id_register_sysreg[index])); +return ret; +}Surely this patch doesn't compile by itself,
because this will Werror for the unused function.
Hm, I'm pretty positive that I did intermediate compiles while sorting the patches here... let me see if I can improve this.
PATCH v2 3/14 arm/cpu: Store aa64isar0/aa64zfr0 into the idregs arrays
In reply to Cornelia HuckFrom: Eric Auger <[email protected]>
--- target/arm/cpu-features.h | 57 ++++++++++++++++++++------------------- target/arm/cpu.c | 10 +++---- target/arm/cpu.h | 2 -- target/arm/cpu64.c | 8 +++--- target/arm/helper.c | 6 +++-- target/arm/hvf/hvf.c | 3 ++- target/arm/kvm.c | 8 +++--- target/arm/tcg/cpu64.c | 44 ++++++++++++++++++------------ 8 files changed, 75 insertions(+), 63 deletions(-)
target/arm/cpu-features.h +29 -28
@@ -22,6 +22,7 @@#include "hw/registerfields.h" #include "qemu/host-utils.h" +#include "cpu-sysregs.h" /* * Naming convention for isar_feature functions:
@@ -376,92 +377,92 @@ static inline bool isar_feature_aa32_doublelock(const ARMISARegisters *id)*/ static inline bool isar_feature_aa64_aes (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,AES ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,AES ) !=0 ; }static inline bool isar_feature_aa64_pmull (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,AES ) >1 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,AES ) >1 ; }static inline bool isar_feature_aa64_sha1 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,SHA1 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,SHA1 ) !=0 ; }static inline bool isar_feature_aa64_sha256 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,SHA2 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,SHA2 ) !=0 ; }static inline bool isar_feature_aa64_sha512 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,SHA2 ) >1 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,SHA2 ) >1 ; }static inline bool isar_feature_aa64_crc32 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,CRC32 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,CRC32 ) !=0 ; }static inline bool isar_feature_aa64_atomics (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,ATOMIC ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,ATOMIC ) !=0 ; }static inline bool isar_feature_aa64_rdm (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,RDM ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,RDM ) !=0 ; }static inline bool isar_feature_aa64_sha3 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,SHA3 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,SHA3 ) !=0 ; }static inline bool isar_feature_aa64_sm3 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,SM3 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,SM3 ) !=0 ; }static inline bool isar_feature_aa64_sm4 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,SM4 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,SM4 ) !=0 ; }static inline bool isar_feature_aa64_dp (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,DP ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,DP ) !=0 ; }static inline bool isar_feature_aa64_fhm (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,FHM ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,FHM ) !=0 ; }static inline bool isar_feature_aa64_condm_4 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,TS ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,TS ) !=0 ; }static inline bool isar_feature_aa64_condm_5 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,TS ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,TS ) >=2 ; }static inline bool isar_feature_aa64_rndr (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,RNDR ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,RNDR ) !=0 ; }static inline bool isar_feature_aa64_tlbirange (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,TLB ) ==2 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,TLB ) ==2 ; }static inline bool isar_feature_aa64_tlbios (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,TLB ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR0 ,TLB ) !=0 ; }static inline bool isar_feature_aa64_jscvt (const ARMISARegisters *id)
@@ -927,52 +928,52 @@ static inline bool isar_feature_aa64_doublelock(const ARMISARegisters *id)static inline bool isar_feature_aa64_sve2 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64zfr0,ID_AA64ZFR0 ,SVEVER ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ZFR0 ,SVEVER ) !=0 ; }static inline bool isar_feature_aa64_sve2_aes (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64zfr0,ID_AA64ZFR0 ,AES ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ZFR0 ,AES ) !=0 ; }static inline bool isar_feature_aa64_sve2_pmull128 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64zfr0,ID_AA64ZFR0 ,AES ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64ZFR0 ,AES ) >=2 ; }static inline bool isar_feature_aa64_sve2_bitperm (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64zfr0,ID_AA64ZFR0 ,BITPERM ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ZFR0 ,BITPERM ) !=0 ; }static inline bool isar_feature_aa64_sve_bf16 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64zfr0,ID_AA64ZFR0 ,BFLOAT16 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ZFR0 ,BFLOAT16 ) !=0 ; }static inline bool isar_feature_aa64_sve2_sha3 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64zfr0,ID_AA64ZFR0 ,SHA3 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ZFR0 ,SHA3 ) !=0 ; }static inline bool isar_feature_aa64_sve2_sm4 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64zfr0,ID_AA64ZFR0 ,SM4 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ZFR0 ,SM4 ) !=0 ; }static inline bool isar_feature_aa64_sve_i8mm (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64zfr0,ID_AA64ZFR0 ,I8MM ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ZFR0 ,I8MM ) !=0 ; }static inline bool isar_feature_aa64_sve_f32mm (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64zfr0,ID_AA64ZFR0 ,F32MM ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ZFR0 ,F32MM ) !=0 ; }static inline bool isar_feature_aa64_sve_f64mm (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64zfr0,ID_AA64ZFR0 ,F64MM ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ZFR0 ,F64MM ) !=0 ; }static inline bool isar_feature_aa64_sme_f64f64 (const ARMISARegisters *id)
target/arm/cpu.c +4 -6
@@ -1971,6 +1971,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);ARMCPU *cpu =ARM_CPU (dev); +ARMISARegisters *isar = &cpu->isar;ARMCPUClass *acc =ARM_CPU_GET_CLASS (dev);CPUARMState *env = &cpu->env;Error *local_err =NULL ;
@@ -2172,7 +2173,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)unset_feature (env,ARM_FEATURE_NEON ); - t = cpu->isar.id_aa64isar0; + t =GET_IDREG (isar,ID_AA64ISAR0 ); t =FIELD_DP64 (t,ID_AA64ISAR0 ,AES ,0 ); t =FIELD_DP64 (t,ID_AA64ISAR0 ,SHA1 ,0 ); t =FIELD_DP64 (t,ID_AA64ISAR0 ,SHA2 ,0 );
@@ -2180,7 +2181,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) t =FIELD_DP64 (t,ID_AA64ISAR0 ,SM3 ,0 ); t =FIELD_DP64 (t,ID_AA64ISAR0 ,SM4 ,0 ); t =FIELD_DP64 (t,ID_AA64ISAR0 ,DP ,0 ); - cpu->isar.id_aa64isar0 = t; +SET_IDREG (isar,ID_AA64ISAR0 , t); t = cpu->isar.id_aa64isar1; t =FIELD_DP64 (t,ID_AA64ISAR1 ,FCMA ,0 );
@@ -2222,12 +2223,9 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) }if (!cpu->has_neon && !cpu->has_vfp) { -uint64_t t;uint32_t u; - t = cpu->isar.id_aa64isar0; - t =FIELD_DP64 (t,ID_AA64ISAR0 ,FHM ,0 ); - cpu->isar.id_aa64isar0 = t; +FIELD_DP64_IDREG (isar,ID_AA64ISAR0 ,FHM ,0 ); t = cpu->isar.id_aa64isar1; t =FIELD_DP64 (t,ID_AA64ISAR1 ,FRINTTS ,0 );
target/arm/cpu.h +0 -2
@@ -1097,7 +1097,6 @@ struct ArchCPU {uint32_t dbgdidr;uint32_t dbgdevid;uint32_t dbgdevid1; -uint64_t id_aa64isar0;uint64_t id_aa64isar1;uint64_t id_aa64isar2;uint64_t id_aa64pfr0;
@@ -1108,7 +1107,6 @@ struct ArchCPU {uint64_t id_aa64mmfr3;uint64_t id_aa64dfr0;uint64_t id_aa64dfr1; -uint64_t id_aa64zfr0;uint64_t id_aa64smfr0;uint64_t reset_pmcr_el0;uint64_t idregs[NUM_ID_IDX ];
target/arm/cpu64.c +5 -3
@@ -114,7 +114,7 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)* SVE is disabled and so are all vector lengths. Good. * Disable all SVE extensions as well. */ - cpu->isar.id_aa64zfr0 =0 ; +SET_IDREG (&cpu->isar,ID_AA64ZFR0 ,0 );return ; }
@@ -617,6 +617,7 @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp)static void aarch64_a57_initfn (Object *obj) {ARMCPU *cpu =ARM_CPU (obj); +ARMISARegisters *isar = &cpu->isar; cpu->dtb_compatible ="arm,cortex-a57" ;set_feature (&cpu->env,ARM_FEATURE_V8 );
@@ -654,7 +655,7 @@ static void aarch64_a57_initfn(Object *obj) cpu->isar.id_isar6 =0 ; cpu->isar.id_aa64pfr0 =0x00002222 ; cpu->isar.id_aa64dfr0 =0x10305106 ; - cpu->isar.id_aa64isar0 =0x00011120 ; +SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 ); cpu->isar.id_aa64mmfr0 =0x00001124 ; cpu->isar.dbgdidr =0x3516d000 ; cpu->isar.dbgdevid =0x01110f13 ;
@@ -678,6 +679,7 @@ static void aarch64_a57_initfn(Object *obj)static void aarch64_a53_initfn (Object *obj) {ARMCPU *cpu =ARM_CPU (obj); +ARMISARegisters *isar = &cpu->isar; cpu->dtb_compatible ="arm,cortex-a53" ;set_feature (&cpu->env,ARM_FEATURE_V8 );
@@ -715,7 +717,7 @@ static void aarch64_a53_initfn(Object *obj) cpu->isar.id_isar6 =0 ; cpu->isar.id_aa64pfr0 =0x00002222 ; cpu->isar.id_aa64dfr0 =0x10305106 ; - cpu->isar.id_aa64isar0 =0x00011120 ; +SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 ); cpu->isar.id_aa64mmfr0 =0x00001122 ;/* 40 bit physical addr */ cpu->isar.dbgdidr =0x3516d000 ; cpu->isar.dbgdevid =0x00110f13 ;
target/arm/helper.c +4 -2
@@ -7529,6 +7529,8 @@ void register_cp_regs_for_features(ARMCPU *cpu) {/* Register all the coprocessor registers based on feature bits */ CPUARMState *env = &cpu->env; +ARMISARegisters *isar = &cpu->isar; +if (arm_feature (env,ARM_FEATURE_M )) {/* M profile has no coprocessor registers */ return ;
@@ -7718,7 +7720,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_aa64zfr0 }, + .resetvalue = GET_IDREG(isar, ID_AA64ZFR0)}, { .name = "ID_AA64SMFR0_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST,
@@ -7778,7 +7780,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_aa64isar0 }, + .resetvalue = GET_IDREG(isar, ID_AA64ISAR0)}, { .name = "ID_AA64ISAR1_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST,
target/arm/hvf/hvf.c +2 -1
@@ -19,6 +19,7 @@#include "system/hw_accel.h" #include "hvf_arm.h" #include "cpregs.h" +#include "cpu-sysregs.h" #include <mach/mach_time.h>
@@ -865,7 +866,7 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) { HV_SYS_REG_ID_AA64PFR1_EL1, &host_isar.id_aa64pfr1 }, { HV_SYS_REG_ID_AA64DFR0_EL1, &host_isar.id_aa64dfr0 }, { HV_SYS_REG_ID_AA64DFR1_EL1, &host_isar.id_aa64dfr1 }, - { HV_SYS_REG_ID_AA64ISAR0_EL1, &host_isar.id_aa64isar0 }, + { HV_SYS_REG_ID_AA64ISAR0_EL1, &host_isar.idregs[ID_AA64ISAR0_EL1_IDX] }, { HV_SYS_REG_ID_AA64ISAR1_EL1, &host_isar.id_aa64isar1 },/* Add ID_AA64ISAR2_EL1 here when HVF supports it */ { HV_SYS_REG_ID_AA64MMFR0_EL1, &host_isar.id_aa64mmfr0 },
target/arm/kvm.c +4 -4
@@ -26,6 +26,7 @@#include "system/kvm_int.h" #include "kvm_arm.h" #include "cpu.h" +#include "cpu-sysregs.h" #include "trace.h" #include "internals.h" #include "hw/pci/pci.h"
@@ -318,6 +319,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ahcf->target = init.target; ahcf->dtb_compatible ="arm,arm-v8" ; +int fd = fdarray[2 ]; err =read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64pfr0,ARM64_SYS_REG (3 ,0 ,0 ,4 ,0 ));
@@ -349,8 +351,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ARM64_SYS_REG(3, 0, 0, 5, 0)); err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64dfr1,ARM64_SYS_REG (3 ,0 ,0 ,5 ,1 )); - err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64isar0, -ARM64_SYS_REG (3 ,0 ,0 ,6 ,0 )); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64ISAR0_EL1_IDX ); err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64isar1,ARM64_SYS_REG (3 ,0 ,0 ,6 ,1 )); err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar2,
@@ -459,8 +460,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)* enabled SVE support, which resulted in an error rather than RAZ. * So only read the register if we set KVM_ARM_VCPU_SVE above. */ - err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64zfr0, -ARM64_SYS_REG (3 ,0 ,0 ,4 ,4 )); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64ZFR0_EL1_IDX ); } }
target/arm/tcg/cpu64.c +27 -17
197 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH v2 4/14 arm/cpu: Store aa64isar1/2 into the idregs array
In reply to Cornelia HuckFrom: Eric Auger <[email protected]>
--- target/arm/cpu-features.h | 44 +++++++++++++++++++-------------------- target/arm/cpu.c | 12 ++++------- target/arm/cpu.h | 2 -- target/arm/cpu64.c | 9 ++++---- target/arm/helper.c | 4 ++-- target/arm/hvf/hvf.c | 2 +- target/arm/kvm.c | 6 ++---- target/arm/tcg/cpu64.c | 24 ++++++++++----------- 8 files changed, 48 insertions(+), 55 deletions(-)
target/arm/cpu-features.h +22 -22
@@ -467,17 +467,17 @@ static inline bool isar_feature_aa64_tlbios(const ARMISARegisters *id)static inline bool isar_feature_aa64_jscvt (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,JSCVT ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,JSCVT ) !=0 ; }static inline bool isar_feature_aa64_fcma (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,FCMA ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,FCMA ) !=0 ; }static inline bool isar_feature_aa64_xs (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,XS ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,XS ) !=0 ; }/*
@@ -501,9 +501,9 @@ isar_feature_pauth_feature(const ARMISARegisters *id)* Architecturally, only one of {APA,API,APA3} may be active (non-zero) * and the other two must be zero. Thus we may avoid conditionals. */ -return (FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,APA ) | -FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,API ) | -FIELD_EX64 (id->id_aa64isar2,ID_AA64ISAR2 ,APA3 )); +return (FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,APA ) | +FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,API ) | +FIELD_EX64_IDREG (id,ID_AA64ISAR2 ,APA3 )); }static inline bool isar_feature_aa64_pauth (const ARMISARegisters *id)
@@ -521,7 +521,7 @@ static inline bool isar_feature_aa64_pauth_qarma5(const ARMISARegisters *id)* Return true if pauth is enabled with the architected QARMA5 algorithm. * QEMU will always enable or disable both APA and GPA. */ -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,APA ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,APA ) !=0 ; }static inline bool isar_feature_aa64_pauth_qarma3 (const ARMISARegisters *id)
@@ -530,77 +530,77 @@ static inline bool isar_feature_aa64_pauth_qarma3(const ARMISARegisters *id)* Return true if pauth is enabled with the architected QARMA3 algorithm. * QEMU will always enable or disable both APA3 and GPA3. */ -return FIELD_EX64 (id->id_aa64isar2,ID_AA64ISAR2 ,APA3 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR2 ,APA3 ) !=0 ; }static inline bool isar_feature_aa64_sb (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,SB ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,SB ) !=0 ; }static inline bool isar_feature_aa64_predinv (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,SPECRES ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,SPECRES ) !=0 ; }static inline bool isar_feature_aa64_frint (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,FRINTTS ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,FRINTTS ) !=0 ; }static inline bool isar_feature_aa64_dcpop (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,DPB ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,DPB ) !=0 ; }static inline bool isar_feature_aa64_dcpodp (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,DPB ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,DPB ) >=2 ; }static inline bool isar_feature_aa64_bf16 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,BF16 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,BF16 ) !=0 ; }static inline bool isar_feature_aa64_ebf16 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,BF16 ) >1 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,BF16 ) >1 ; }static inline bool isar_feature_aa64_rcpc_8_3 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,LRCPC ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,LRCPC ) !=0 ; }static inline bool isar_feature_aa64_rcpc_8_4 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,LRCPC ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,LRCPC ) >=2 ; }static inline bool isar_feature_aa64_i8mm (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,I8MM ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR1 ,I8MM ) !=0 ; }static inline bool isar_feature_aa64_wfxt (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar2,ID_AA64ISAR2 ,WFXT ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR2 ,WFXT ) >=2 ; }static inline bool isar_feature_aa64_hbc (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar2,ID_AA64ISAR2 ,BC ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64ISAR2 ,BC ) !=0 ; }static inline bool isar_feature_aa64_mops (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar2,ID_AA64ISAR2 ,MOPS ); +return FIELD_EX64_IDREG (id,ID_AA64ISAR2 ,MOPS ); }static inline bool isar_feature_aa64_rpres (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64isar2,ID_AA64ISAR2 ,RPRES ); +return FIELD_EX64_IDREG (id,ID_AA64ISAR2 ,RPRES ); }static inline bool isar_feature_aa64_fp_simd (const ARMISARegisters *id)
target/arm/cpu.c +4 -8
@@ -2128,9 +2128,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)uint64_t t;uint32_t u; - t = cpu->isar.id_aa64isar1; - t =FIELD_DP64 (t,ID_AA64ISAR1 ,JSCVT ,0 ); - cpu->isar.id_aa64isar1 = t; +FIELD_DP64_IDREG (isar,ID_AA64ISAR1 ,JSCVT ,0 ); t = cpu->isar.id_aa64pfr0; t =FIELD_DP64 (t,ID_AA64PFR0 ,FP ,0xf );
@@ -2183,11 +2181,11 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) t =FIELD_DP64 (t,ID_AA64ISAR0 ,DP ,0 );SET_IDREG (isar,ID_AA64ISAR0 , t); - t = cpu->isar.id_aa64isar1; + t =GET_IDREG (isar,ID_AA64ISAR1 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,FCMA ,0 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,BF16 ,0 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,I8MM ,0 ); - cpu->isar.id_aa64isar1 = t; +SET_IDREG (isar,ID_AA64ISAR1 , t); t = cpu->isar.id_aa64pfr0; t =FIELD_DP64 (t,ID_AA64PFR0 ,ADVSIMD ,0xf );
@@ -2227,9 +2225,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)FIELD_DP64_IDREG (isar,ID_AA64ISAR0 ,FHM ,0 ); - t = cpu->isar.id_aa64isar1; - t =FIELD_DP64 (t,ID_AA64ISAR1 ,FRINTTS ,0 ); - cpu->isar.id_aa64isar1 = t; +FIELD_DP64_IDREG (isar,ID_AA64ISAR1 ,FRINTTS ,0 ); u = cpu->isar.mvfr0; u =FIELD_DP32 (u,MVFR0 ,SIMDREG ,0 );
target/arm/cpu.h +0 -2
@@ -1097,8 +1097,6 @@ struct ArchCPU {uint32_t dbgdidr;uint32_t dbgdevid;uint32_t dbgdevid1; -uint64_t id_aa64isar1; -uint64_t id_aa64isar2;uint64_t id_aa64pfr0;uint64_t id_aa64pfr1;uint64_t id_aa64mmfr0;
target/arm/cpu64.c +5 -4
@@ -480,6 +480,7 @@ void aarch64_add_sme_properties(Object *obj)void arm_cpu_pauth_finalize (ARMCPU *cpu,Error **errp) {ARMPauthFeature features =cpu_isar_feature (pauth_feature, cpu); +ARMISARegisters *isar = &cpu->isar;uint64_t isar1, isar2;/*
@@ -490,13 +491,13 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)* * Begin by disabling all fields. */ - isar1 = cpu->isar.id_aa64isar1; + isar1 =GET_IDREG (isar,ID_AA64ISAR1 ); isar1 =FIELD_DP64 (isar1,ID_AA64ISAR1 ,APA ,0 ); isar1 =FIELD_DP64 (isar1,ID_AA64ISAR1 ,GPA ,0 ); isar1 =FIELD_DP64 (isar1,ID_AA64ISAR1 ,API ,0 ); isar1 =FIELD_DP64 (isar1,ID_AA64ISAR1 ,GPI ,0 ); - isar2 = cpu->isar.id_aa64isar2; + isar2 =GET_IDREG (isar,ID_AA64ISAR2 ); isar2 =FIELD_DP64 (isar2,ID_AA64ISAR2 ,APA3 ,0 ); isar2 =FIELD_DP64 (isar2,ID_AA64ISAR2 ,GPA3 ,0 );
@@ -558,8 +559,8 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) } } - cpu->isar.id_aa64isar1 = isar1; - cpu->isar.id_aa64isar2 = isar2; +SET_IDREG (isar,ID_AA64ISAR1 , isar1); +SET_IDREG (isar,ID_AA64ISAR2 , isar2); } static const Property arm_cpu_pauth_property =
target/arm/helper.c +2 -2
@@ -7785,12 +7785,12 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_aa64isar1 }, + .resetvalue = GET_IDREG(isar, ID_AA64ISAR1)}, { .name = "ID_AA64ISAR2_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_aa64isar2 }, + .resetvalue = GET_IDREG(isar, ID_AA64ISAR2)}, { .name = "ID_AA64ISAR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST,
target/arm/hvf/hvf.c +1 -1
@@ -867,7 +867,7 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) { HV_SYS_REG_ID_AA64DFR0_EL1, &host_isar.id_aa64dfr0 }, { HV_SYS_REG_ID_AA64DFR1_EL1, &host_isar.id_aa64dfr1 }, { HV_SYS_REG_ID_AA64ISAR0_EL1, &host_isar.idregs[ID_AA64ISAR0_EL1_IDX] }, - { HV_SYS_REG_ID_AA64ISAR1_EL1, &host_isar.id_aa64isar1 }, + { HV_SYS_REG_ID_AA64ISAR1_EL1, &host_isar.idregs[ID_AA64ISAR1_EL1_IDX] },/* Add ID_AA64ISAR2_EL1 here when HVF supports it */ { HV_SYS_REG_ID_AA64MMFR0_EL1, &host_isar.id_aa64mmfr0 }, { HV_SYS_REG_ID_AA64MMFR1_EL1, &host_isar.id_aa64mmfr1 },
target/arm/kvm.c +2 -4
@@ -352,10 +352,8 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64dfr1,ARM64_SYS_REG (3 ,0 ,0 ,5 ,1 )); err |=get_host_cpu_reg (fd, ahcf,ID_AA64ISAR0_EL1_IDX ); - err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64isar1, -ARM64_SYS_REG (3 ,0 ,0 ,6 ,1 )); - err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64isar2, -ARM64_SYS_REG (3 ,0 ,0 ,6 ,2 )); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64ISAR1_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64ISAR2_EL1_IDX ); err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64mmfr0,ARM64_SYS_REG (3 ,0 ,0 ,7 ,0 )); err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr1,
target/arm/tcg/cpu64.c +12 -12
@@ -68,7 +68,7 @@ static void aarch64_a35_initfn(Object *obj) cpu->isar.id_aa64dfr0 =0x10305106 ; cpu->isar.id_aa64dfr1 =0 ;SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 ); - cpu->isar.id_aa64isar1 =0 ; +SET_IDREG (isar,ID_AA64ISAR1 ,0 ); cpu->isar.id_aa64mmfr0 =0x00101122 ; cpu->isar.id_aa64mmfr1 =0 ; cpu->clidr =0x0a200023 ;
@@ -224,7 +224,7 @@ static void aarch64_a55_initfn(Object *obj) cpu->dcz_blocksize =4 ;/* 64 bytes */ cpu->isar.id_aa64dfr0 =0x0000000010305408ull ;SET_IDREG (isar,ID_AA64ISAR0 ,0x0000100010211120ull ); - cpu->isar.id_aa64isar1 =0x0000000000100001ull ; +SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000100001ull ); cpu->isar.id_aa64mmfr0 =0x0000000000101122ull ; cpu->isar.id_aa64mmfr1 =0x0000000010212122ull ; cpu->isar.id_aa64mmfr2 =0x0000000000001011ull ;
@@ -357,7 +357,7 @@ static void aarch64_a76_initfn(Object *obj) cpu->dcz_blocksize =4 ; cpu->isar.id_aa64dfr0 =0x0000000010305408ull ;SET_IDREG (isar,ID_AA64ISAR0 ,0x0000100010211120ull ); - cpu->isar.id_aa64isar1 =0x0000000000100001ull ; +SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000100001ull ); cpu->isar.id_aa64mmfr0 =0x0000000000101122ull ; cpu->isar.id_aa64mmfr1 =0x0000000010212122ull ; cpu->isar.id_aa64mmfr2 =0x0000000000001011ull ;
@@ -437,7 +437,7 @@ static void aarch64_a64fx_initfn(Object *obj) cpu->isar.id_aa64mmfr1 =0x0000000011212100 ; cpu->isar.id_aa64mmfr2 =0x0000000000001011 ;SET_IDREG (isar,ID_AA64ISAR0 ,0x0000000010211120 ); - cpu->isar.id_aa64isar1 =0x0000000000010001 ; +SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000010001 );SET_IDREG (isar,ID_AA64ZFR0 ,0x0000000000000000 ); cpu->clidr =0x0000000080000023 ;/* 64KB L1 dcache */
@@ -605,7 +605,7 @@ static void aarch64_neoverse_n1_initfn(Object *obj) cpu->dcz_blocksize =4 ; cpu->isar.id_aa64dfr0 =0x0000000110305408ull ;SET_IDREG (isar,ID_AA64ISAR0 ,0x0000100010211120ull ); - cpu->isar.id_aa64isar1 =0x0000000000100001ull ; +SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000100001ull ); cpu->isar.id_aa64mmfr0 =0x0000000000101125ull ; cpu->isar.id_aa64mmfr1 =0x0000000010212122ull ; cpu->isar.id_aa64mmfr2 =0x0000000000001011ull ;
@@ -684,7 +684,7 @@ static void aarch64_neoverse_v1_initfn(Object *obj) cpu->isar.id_aa64dfr0 =0x000001f210305519ull ; cpu->isar.id_aa64dfr1 =0x00000000 ;SET_IDREG (isar,ID_AA64ISAR0 ,0x1011111110212120ull );/* with FEAT_RNG */ - cpu->isar.id_aa64isar1 =0x0011100001211032ull ; +SET_IDREG (isar,ID_AA64ISAR1 ,0x0011000001211032ull ); cpu->isar.id_aa64mmfr0 =0x0000000000101125ull ; cpu->isar.id_aa64mmfr1 =0x0000000010212122ull ; cpu->isar.id_aa64mmfr2 =0x0220011102101011ull ;
@@ -933,7 +933,7 @@ static void aarch64_a710_initfn(Object *obj) cpu->id_aa64afr0 =0 ; cpu->id_aa64afr1 =0 ;SET_IDREG (isar,ID_AA64ISAR0 ,0x0221111110212120ull );/* with Crypto */ - cpu->isar.id_aa64isar1 =0x0010111101211052ull ; +SET_IDREG (isar,ID_AA64ISAR1 ,0x0010111101211052ull ); cpu->isar.id_aa64mmfr0 =0x0000022200101122ull ; cpu->isar.id_aa64mmfr1 =0x0000000010212122ull ; cpu->isar.id_aa64mmfr2 =0x1221011110101011ull ;
@@ -1035,7 +1035,7 @@ static void aarch64_neoverse_n2_initfn(Object *obj) cpu->id_aa64afr0 =0 ; cpu->id_aa64afr1 =0 ;SET_IDREG (isar,ID_AA64ISAR0 ,0x1221111110212120ull );/* with Crypto and FEAT_RNG */ - cpu->isar.id_aa64isar1 =0x0011111101211052ull ; +SET_IDREG (isar,ID_AA64ISAR1 ,0x0011111101211052ull ); cpu->isar.id_aa64mmfr0 =0x0000022200101125ull ; cpu->isar.id_aa64mmfr1 =0x0000000010212122ull ; cpu->isar.id_aa64mmfr2 =0x1221011112101011ull ;
@@ -1160,7 +1160,7 @@ void aarch64_max_tcg_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ISAR0 ,RNDR ,1 );/* FEAT_RNG */ SET_IDREG (isar,ID_AA64ISAR0 , t); - t = cpu->isar.id_aa64isar1; + t =GET_IDREG (isar,ID_AA64ISAR1 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,DPB ,2 );/* FEAT_DPB2 */ t =FIELD_DP64 (t,ID_AA64ISAR1 ,APA , PauthFeat_FPACCOMBINED); t =FIELD_DP64 (t,ID_AA64ISAR1 ,API ,1 );
@@ -1174,14 +1174,14 @@ void aarch64_max_tcg_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ISAR1 ,DGH ,1 );/* FEAT_DGH */ t =FIELD_DP64 (t,ID_AA64ISAR1 ,I8MM ,1 );/* FEAT_I8MM */ t =FIELD_DP64 (t,ID_AA64ISAR1 ,XS ,1 );/* FEAT_XS */ - cpu->isar.id_aa64isar1 = t; +SET_IDREG (isar,ID_AA64ISAR1 , t); - t = cpu->isar.id_aa64isar2; + t =GET_IDREG (isar,ID_AA64ISAR2 ); t =FIELD_DP64 (t,ID_AA64ISAR2 ,RPRES ,1 );/* FEAT_RPRES */ t =FIELD_DP64 (t,ID_AA64ISAR2 ,MOPS ,1 );/* FEAT_MOPS */ t =FIELD_DP64 (t,ID_AA64ISAR2 ,BC ,1 );/* FEAT_HBC */ t =FIELD_DP64 (t,ID_AA64ISAR2 ,WFXT ,2 );/* FEAT_WFxT */ - cpu->isar.id_aa64isar2 = t; +SET_IDREG (isar,ID_AA64ISAR2 , t); t = cpu->isar.id_aa64pfr0; t =FIELD_DP64 (t,ID_AA64PFR0 ,FP ,1 );/* FEAT_FP16 */
Signature · 1 line
2.48.1
PATCH v2 5/14 arm/cpu: Store aa64pfr0/1 into the idregs array
In reply to Cornelia HuckFrom: Eric Auger <[email protected]>
--- target/arm/cpu-features.h | 40 ++++++++++++++++----------------- target/arm/cpu.c | 29 ++++++++---------------- target/arm/cpu.h | 2 -- target/arm/cpu64.c | 14 ++++-------- target/arm/helper.c | 6 ++--- target/arm/hvf/hvf.c | 6 ++--- target/arm/kvm.c | 24 +++++++++----------- target/arm/tcg/cpu64.c | 47 ++++++++++++++++++--------------------- 8 files changed, 71 insertions(+), 97 deletions(-)
target/arm/cpu-features.h +20 -20
@@ -606,68 +606,68 @@ static inline bool isar_feature_aa64_rpres(const ARMISARegisters *id)static inline bool isar_feature_aa64_fp_simd (const ARMISARegisters *id) {/* We always set the AdvSIMD and FP fields identically. */ -return FIELD_EX64 (id->id_aa64pfr0,ID_AA64PFR0 ,FP ) !=0xf ; +return FIELD_EX64_IDREG (id,ID_AA64PFR0 ,FP ) !=0xf ; }static inline bool isar_feature_aa64_fp16 (const ARMISARegisters *id) {/* We always set the AdvSIMD and FP fields identically wrt FP16. */ -return FIELD_EX64 (id->id_aa64pfr0,ID_AA64PFR0 ,FP ) ==1 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR0 ,FP ) ==1 ; }static inline bool isar_feature_aa64_aa32 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr0,ID_AA64PFR0 ,EL0 ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR0 ,EL0 ) >=2 ; }static inline bool isar_feature_aa64_aa32_el1 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr0,ID_AA64PFR0 ,EL1 ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR0 ,EL1 ) >=2 ; }static inline bool isar_feature_aa64_aa32_el2 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr0,ID_AA64PFR0 ,EL2 ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR0 ,EL2 ) >=2 ; }static inline bool isar_feature_aa64_ras (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr0,ID_AA64PFR0 ,RAS ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR0 ,RAS ) !=0 ; }static inline bool isar_feature_aa64_doublefault (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr0,ID_AA64PFR0 ,RAS ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR0 ,RAS ) >=2 ; }static inline bool isar_feature_aa64_sve (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr0,ID_AA64PFR0 ,SVE ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR0 ,SVE ) !=0 ; }static inline bool isar_feature_aa64_sel2 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr0,ID_AA64PFR0 ,SEL2 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR0 ,SEL2 ) !=0 ; }static inline bool isar_feature_aa64_rme (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr0,ID_AA64PFR0 ,RME ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR0 ,RME ) !=0 ; }static inline bool isar_feature_aa64_dit (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr0,ID_AA64PFR0 ,DIT ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR0 ,DIT ) !=0 ; }static inline bool isar_feature_aa64_scxtnum (const ARMISARegisters *id) { -int key =FIELD_EX64 (id->id_aa64pfr0,ID_AA64PFR0 ,CSV2 ); +int key =FIELD_EX64_IDREG (id,ID_AA64PFR0 ,CSV2 );if (key >=2 ) {return true;/* FEAT_CSV2_2 */ }if (key ==1 ) { - key =FIELD_EX64 (id->id_aa64pfr1,ID_AA64PFR1 ,CSV2_FRAC ); + key =FIELD_EX64_IDREG (id,ID_AA64PFR1 ,CSV2_FRAC );return key >=2 ;/* FEAT_CSV2_1p2 */ }return false;
@@ -675,37 +675,37 @@ static inline bool isar_feature_aa64_scxtnum(const ARMISARegisters *id)static inline bool isar_feature_aa64_ssbs (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr1,ID_AA64PFR1 ,SSBS ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR1 ,SSBS ) !=0 ; }static inline bool isar_feature_aa64_bti (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr1,ID_AA64PFR1 ,BT ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR1 ,BT ) !=0 ; }static inline bool isar_feature_aa64_mte_insn_reg (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr1,ID_AA64PFR1 ,MTE ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR1 ,MTE ) !=0 ; }static inline bool isar_feature_aa64_mte (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr1,ID_AA64PFR1 ,MTE ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR1 ,MTE ) >=2 ; }static inline bool isar_feature_aa64_mte3 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr1,ID_AA64PFR1 ,MTE ) >=3 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR1 ,MTE ) >=3 ; }static inline bool isar_feature_aa64_sme (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr1,ID_AA64PFR1 ,SME ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR1 ,SME ) !=0 ; }static inline bool isar_feature_aa64_nmi (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64pfr1,ID_AA64PFR1 ,NMI ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64PFR1 ,NMI ) !=0 ; }static inline bool isar_feature_aa64_tgran4_lpa2 (const ARMISARegisters *id)
target/arm/cpu.c +9 -20
@@ -2125,14 +2125,11 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) }if (!cpu->has_vfp) { -uint64_t t;uint32_t u;FIELD_DP64_IDREG (isar,ID_AA64ISAR1 ,JSCVT ,0 ); - t = cpu->isar.id_aa64pfr0; - t =FIELD_DP64 (t,ID_AA64PFR0 ,FP ,0xf ); - cpu->isar.id_aa64pfr0 = t; +FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,FP ,0xf ); u = cpu->isar.id_isar6; u =FIELD_DP32 (u,ID_ISAR6 ,JSCVT ,0 );
@@ -2187,9 +2184,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) t =FIELD_DP64 (t,ID_AA64ISAR1 ,I8MM ,0 );SET_IDREG (isar,ID_AA64ISAR1 , t); - t = cpu->isar.id_aa64pfr0; - t =FIELD_DP64 (t,ID_AA64PFR0 ,ADVSIMD ,0xf ); - cpu->isar.id_aa64pfr0 = t; +FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,ADVSIMD ,0xf ); u = cpu->isar.id_isar5; u =FIELD_DP32 (u,ID_ISAR5 ,AES ,0 );
@@ -2331,12 +2326,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)*/ cpu->isar.id_pfr1 =FIELD_DP32 (cpu->isar.id_pfr1,ID_PFR1 ,SECURITY ,0 ); cpu->isar.id_dfr0 =FIELD_DP32 (cpu->isar.id_dfr0,ID_DFR0 ,COPSDBG ,0 ); - cpu->isar.id_aa64pfr0 =FIELD_DP64 (cpu->isar.id_aa64pfr0, -ID_AA64PFR0 ,EL3 ,0 ); +FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,EL3 ,0 );/* Disable the realm management extension, which requires EL3. */ - cpu->isar.id_aa64pfr0 =FIELD_DP64 (cpu->isar.id_aa64pfr0, -ID_AA64PFR0 ,RME ,0 ); +FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,RME ,0 ); }if (!cpu->has_el2) {
@@ -2371,8 +2364,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)* Disable the hypervisor feature bits in the processor feature * registers if we don't have EL2. */ - cpu->isar.id_aa64pfr0 =FIELD_DP64 (cpu->isar.id_aa64pfr0, -ID_AA64PFR0 ,EL2 ,0 ); +FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,EL2 ,0 ); cpu->isar.id_pfr1 =FIELD_DP32 (cpu->isar.id_pfr1,ID_PFR1 ,VIRTUALIZATION ,0 ); }
@@ -2393,8 +2385,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)* This matches Cortex-A710 BROADCASTMTE input being LOW. */ if (tcg_enabled () && cpu->tag_memory ==NULL ) { - cpu->isar.id_aa64pfr1 = -FIELD_DP64 (cpu->isar.id_aa64pfr1,ID_AA64PFR1 ,MTE ,1 ); +FIELD_DP64_IDREG (isar,ID_AA64PFR1 ,MTE ,1 ); }/*
@@ -2402,7 +2393,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)* enabled on the guest (i.e mte=off), clear guest's MTE bits." */ if (kvm_enabled () && !cpu->kvm_mte) { -FIELD_DP64 (cpu->isar.id_aa64pfr1,ID_AA64PFR1 ,MTE ,0 ); +FIELD_DP64_IDREG (isar,ID_AA64PFR1 ,MTE ,0 ); }#endif }
@@ -2441,13 +2432,11 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->isar.id_dfr0 =FIELD_DP32 (cpu->isar.id_dfr0,ID_DFR0 ,MMAPTRC ,0 );/* FEAT_AMU (Activity Monitors Extension) */ - cpu->isar.id_aa64pfr0 = -FIELD_DP64 (cpu->isar.id_aa64pfr0,ID_AA64PFR0 ,AMU ,0 ); +FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,AMU ,0 ); cpu->isar.id_pfr0 =FIELD_DP32 (cpu->isar.id_pfr0,ID_PFR0 ,AMU ,0 );/* FEAT_MPAM (Memory Partitioning and Monitoring Extension) */ - cpu->isar.id_aa64pfr0 = -FIELD_DP64 (cpu->isar.id_aa64pfr0,ID_AA64PFR0 ,MPAM ,0 ); +FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,MPAM ,0 ); }/* MPU can be configured out of a PMSA CPU either by setting has-mpu
target/arm/cpu.h +0 -2
@@ -1097,8 +1097,6 @@ struct ArchCPU {uint32_t dbgdidr;uint32_t dbgdevid;uint32_t dbgdevid1; -uint64_t id_aa64pfr0; -uint64_t id_aa64pfr1;uint64_t id_aa64mmfr0;uint64_t id_aa64mmfr1;uint64_t id_aa64mmfr2;
target/arm/cpu64.c +4 -10
@@ -288,16 +288,13 @@ static bool cpu_arm_get_sve(Object *obj, Error **errp)static void cpu_arm_set_sve (Object *obj,bool value,Error **errp) {ARMCPU *cpu =ARM_CPU (obj); -uint64_t t;if (value &&kvm_enabled () && !kvm_arm_sve_supported ()) {error_setg (errp,"'sve' feature not supported by KVM on this host" );return ; } - t = cpu->isar.id_aa64pfr0; - t =FIELD_DP64 (t,ID_AA64PFR0 ,SVE , value); - cpu->isar.id_aa64pfr0 = t; +FIELD_DP64_IDREG (&cpu->isar,ID_AA64PFR0 ,SVE , value); }void arm_cpu_sme_finalize (ARMCPU *cpu,Error **errp)
@@ -348,11 +345,8 @@ static bool cpu_arm_get_sme(Object *obj, Error **errp)static void cpu_arm_set_sme (Object *obj,bool value,Error **errp) {ARMCPU *cpu =ARM_CPU (obj); -uint64_t t; - t = cpu->isar.id_aa64pfr1; - t =FIELD_DP64 (t,ID_AA64PFR1 ,SME , value); - cpu->isar.id_aa64pfr1 = t; +FIELD_DP64_IDREG (&cpu->isar,ID_AA64PFR1 ,SME , value); }static bool cpu_arm_get_sme_fa64 (Object *obj,Error **errp)
@@ -654,7 +648,7 @@ static void aarch64_a57_initfn(Object *obj) cpu->isar.id_isar4 =0x00011142 ; cpu->isar.id_isar5 =0x00011121 ; cpu->isar.id_isar6 =0 ; - cpu->isar.id_aa64pfr0 =0x00002222 ; +SET_IDREG (isar,ID_AA64PFR0 ,0x00002222 ); cpu->isar.id_aa64dfr0 =0x10305106 ;SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 ); cpu->isar.id_aa64mmfr0 =0x00001124 ;
@@ -716,7 +710,7 @@ static void aarch64_a53_initfn(Object *obj) cpu->isar.id_isar4 =0x00011142 ; cpu->isar.id_isar5 =0x00011121 ; cpu->isar.id_isar6 =0 ; - cpu->isar.id_aa64pfr0 =0x00002222 ; +SET_IDREG (isar,ID_AA64PFR0 ,0x00002222 ); cpu->isar.id_aa64dfr0 =0x10305106 ;SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 ); cpu->isar.id_aa64mmfr0 =0x00001122 ;/* 40 bit physical addr */
target/arm/helper.c +3 -3
@@ -6719,7 +6719,7 @@ static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri)static uint64_t id_aa64pfr0_read (CPUARMState *env,const ARMCPRegInfo *ri) {ARMCPU *cpu =env_archcpu (env); -uint64_t pfr0 = cpu->isar.id_aa64pfr0; +uint64_t pfr0 =GET_IDREG (&cpu->isar,ID_AA64PFR0 );if (env->gicv3state) { pfr0 |=1 <<24 ;
@@ -7693,7 +7693,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access = PL1_R, #ifdef CONFIG_USER_ONLY .type =ARM_CP_CONST , - .resetvalue = cpu->isar.id_aa64pfr0 + .resetvalue = GET_IDREG(isar, ID_AA64PFR0) #else .type =ARM_CP_NO_RAW , .accessfn = access_aa64_tid3,
@@ -7705,7 +7705,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_aa64pfr1}, + .resetvalue = GET_IDREG(isar, ID_AA64PFR1)}, { .name = "ID_AA64PFR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST,
target/arm/hvf/hvf.c +3 -3
@@ -862,8 +862,8 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)int reg;uint64_t *val; } regs[] = { - { HV_SYS_REG_ID_AA64PFR0_EL1, &host_isar.id_aa64pfr0 }, - { HV_SYS_REG_ID_AA64PFR1_EL1, &host_isar.id_aa64pfr1 }, + { HV_SYS_REG_ID_AA64PFR0_EL1, &host_isar.idregs[ID_AA64PFR0_EL1_IDX] }, + { HV_SYS_REG_ID_AA64PFR1_EL1, &host_isar.idregs[ID_AA64PFR1_EL1_IDX] }, { HV_SYS_REG_ID_AA64DFR0_EL1, &host_isar.id_aa64dfr0 }, { HV_SYS_REG_ID_AA64DFR1_EL1, &host_isar.id_aa64dfr1 }, { HV_SYS_REG_ID_AA64ISAR0_EL1, &host_isar.idregs[ID_AA64ISAR0_EL1_IDX] },
@@ -915,7 +915,7 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ahcf->reset_sctlr |=0x00800000 ;/* Make sure we don't advertise AArch32 support for EL0/EL1 */ -if ((host_isar.id_aa64pfr0 &0xff ) !=0x11 ) { +if ((GET_IDREG (&host_isar,ID_AA64PFR0 ) &0xff ) !=0x11 ) {return false; }
target/arm/kvm.c +10 -14
@@ -321,8 +321,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ahcf->dtb_compatible ="arm,arm-v8" ;int fd = fdarray[2 ]; - err =read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64pfr0, -ARM64_SYS_REG (3 ,0 ,0 ,4 ,0 )); + err =get_host_cpu_reg (fd, ahcf,ID_AA64PFR0_EL1_IDX );if (unlikely (err <0 )) {/* * Before v4.15, the kernel only exposed a limited number of system
@@ -340,11 +339,10 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)* ??? Either of these sounds like too much effort just * to work around running a modern host kernel. */ - ahcf->isar.id_aa64pfr0 =0x00000011 ;/* EL1&0, AArch64 only */ +SET_IDREG (&ahcf->isar,ID_AA64PFR0 ,0x00000011 );/* EL1&0, AArch64 only */ err =0 ; }else { - err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64pfr1, -ARM64_SYS_REG (3 ,0 ,0 ,4 ,1 )); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64PFR1_EL1_IDX ); err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64smfr0,ARM64_SYS_REG (3 ,0 ,0 ,4 ,5 )); err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr0,
@@ -370,10 +368,8 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)* than skipping the reads and leaving 0, as we must avoid * considering the values in every case. */ - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_pfr0, -ARM64_SYS_REG (3 ,0 ,0 ,1 ,0 )); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_pfr1, -ARM64_SYS_REG (3 ,0 ,0 ,1 ,1 )); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64PFR0_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64PFR1_EL1_IDX ); err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_dfr0,ARM64_SYS_REG (3 ,0 ,0 ,1 ,2 )); err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0,
@@ -424,14 +420,14 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)* arch/arm64/kvm/sys_regs.c:trap_dbgidr() does. * We only do this if the CPU supports AArch32 at EL1. */ -if (FIELD_EX32 (ahcf->isar.id_aa64pfr0,ID_AA64PFR0 ,EL1 ) >=2 ) { -int wrps =FIELD_EX64 (ahcf->isar.id_aa64dfr0,ID_AA64DFR0 ,WRPS ); -int brps =FIELD_EX64 (ahcf->isar.id_aa64dfr0,ID_AA64DFR0 ,BRPS ); +if (FIELD_EX32_IDREG (&ahcf->isar,ID_AA64PFR0 ,EL1 ) >=2 ) { +int wrps =FIELD_EX64 (&ahcf->isar.id_aa64dfr0,ID_AA64DFR0 ,WRPS ); +int brps =FIELD_EX64 (&ahcf->isar.id_aa64dfr0,ID_AA64DFR0 ,BRPS );int ctx_cmps = -FIELD_EX64 (ahcf->isar.id_aa64dfr0,ID_AA64DFR0 ,CTX_CMPS ); +FIELD_EX64 (&ahcf->isar.id_aa64dfr0,ID_AA64DFR0 ,CTX_CMPS );int version =6 ;/* ARMv8 debug architecture */ bool has_el3 = - !!FIELD_EX32 (ahcf->isar.id_aa64pfr0,ID_AA64PFR0 ,EL3 ); + !!FIELD_EX32_IDREG (&ahcf->isar,ID_AA64PFR0 ,EL3 );uint32_t dbgdidr =0 ; dbgdidr =FIELD_DP32 (dbgdidr,DBGDIDR ,WRPS , wrps);
target/arm/tcg/cpu64.c +22 -25
127 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH v2 6/14 arm/cpu: Store aa64mmfr0-3 into the idregs array
In reply to Cornelia HuckFrom: Eric Auger <[email protected]>
--- target/arm/cpu-features.h | 74 +++++++++++++++++++-------------------- target/arm/cpu.h | 4 --- target/arm/cpu64.c | 8 ++--- target/arm/helper.c | 8 ++--- target/arm/hvf/hvf.c | 21 ++++++----- target/arm/kvm.c | 12 +++---- target/arm/ptw.c | 6 ++-- target/arm/tcg/cpu64.c | 64 ++++++++++++++++----------------- 8 files changed, 95 insertions(+), 102 deletions(-)
target/arm/cpu-features.h +37 -37
@@ -710,192 +710,192 @@ static inline bool isar_feature_aa64_nmi(const ARMISARegisters *id)static inline bool isar_feature_aa64_tgran4_lpa2 (const ARMISARegisters *id) { -return FIELD_SEX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,TGRAN4 ) >=1 ; +return FIELD_SEX64_IDREG (id,ID_AA64MMFR0 ,TGRAN4 ) >=1 ; }static inline bool isar_feature_aa64_tgran4_2_lpa2 (const ARMISARegisters *id) { -unsigned t =FIELD_EX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,TGRAN4_2 ); +unsigned t =FIELD_EX64_IDREG (id,ID_AA64MMFR0 ,TGRAN4_2 );return t >=3 || (t ==0 &&isar_feature_aa64_tgran4_lpa2 (id)); }static inline bool isar_feature_aa64_tgran16_lpa2 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,TGRAN16 ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR0 ,TGRAN16 ) >=2 ; }static inline bool isar_feature_aa64_tgran16_2_lpa2 (const ARMISARegisters *id) { -unsigned t =FIELD_EX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,TGRAN16_2 ); +unsigned t =FIELD_EX64_IDREG (id,ID_AA64MMFR0 ,TGRAN16_2 );return t >=3 || (t ==0 &&isar_feature_aa64_tgran16_lpa2 (id)); }static inline bool isar_feature_aa64_tgran4 (const ARMISARegisters *id) { -return FIELD_SEX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,TGRAN4 ) >=0 ; +return FIELD_SEX64_IDREG (id,ID_AA64MMFR0 ,TGRAN4 ) >=0 ; }static inline bool isar_feature_aa64_tgran16 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,TGRAN16 ) >=1 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR0 ,TGRAN16 ) >=1 ; }static inline bool isar_feature_aa64_tgran64 (const ARMISARegisters *id) { -return FIELD_SEX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,TGRAN64 ) >=0 ; +return FIELD_SEX64_IDREG (id,ID_AA64MMFR0 ,TGRAN64 ) >=0 ; }static inline bool isar_feature_aa64_tgran4_2 (const ARMISARegisters *id) { -unsigned t =FIELD_EX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,TGRAN4_2 ); +unsigned t =FIELD_EX64_IDREG (id,ID_AA64MMFR0 ,TGRAN4_2 );return t >=2 || (t ==0 &&isar_feature_aa64_tgran4 (id)); }static inline bool isar_feature_aa64_tgran16_2 (const ARMISARegisters *id) { -unsigned t =FIELD_EX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,TGRAN16_2 ); +unsigned t =FIELD_EX64_IDREG (id,ID_AA64MMFR0 ,TGRAN16_2 );return t >=2 || (t ==0 &&isar_feature_aa64_tgran16 (id)); }static inline bool isar_feature_aa64_tgran64_2 (const ARMISARegisters *id) { -unsigned t =FIELD_EX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,TGRAN64_2 ); +unsigned t =FIELD_EX64_IDREG (id,ID_AA64MMFR0 ,TGRAN64_2 );return t >=2 || (t ==0 &&isar_feature_aa64_tgran64 (id)); }static inline bool isar_feature_aa64_fgt (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,FGT ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR0 ,FGT ) !=0 ; }static inline bool isar_feature_aa64_ecv_traps (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,ECV ) >0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR0 ,ECV ) >0 ; }static inline bool isar_feature_aa64_ecv (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr0,ID_AA64MMFR0 ,ECV ) >1 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR0 ,ECV ) >1 ; }static inline bool isar_feature_aa64_vh (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr1,ID_AA64MMFR1 ,VH ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR1 ,VH ) !=0 ; }static inline bool isar_feature_aa64_lor (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr1,ID_AA64MMFR1 ,LO ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR1 ,LO ) !=0 ; }static inline bool isar_feature_aa64_pan (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr1,ID_AA64MMFR1 ,PAN ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR1 ,PAN ) !=0 ; }static inline bool isar_feature_aa64_ats1e1 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr1,ID_AA64MMFR1 ,PAN ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR1 ,PAN ) >=2 ; }static inline bool isar_feature_aa64_pan3 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr1,ID_AA64MMFR1 ,PAN ) >=3 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR1 ,PAN ) >=3 ; }static inline bool isar_feature_aa64_hcx (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr1,ID_AA64MMFR1 ,HCX ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR1 ,HCX ) !=0 ; }static inline bool isar_feature_aa64_afp (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr1,ID_AA64MMFR1 ,AFP ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR1 ,AFP ) !=0 ; }static inline bool isar_feature_aa64_tidcp1 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr1,ID_AA64MMFR1 ,TIDCP1 ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR1 ,TIDCP1 ) !=0 ; }static inline bool isar_feature_aa64_cmow (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr1,ID_AA64MMFR1 ,CMOW ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR1 ,CMOW ) !=0 ; }static inline bool isar_feature_aa64_hafs (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr1,ID_AA64MMFR1 ,HAFDBS ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR1 ,HAFDBS ) !=0 ; }static inline bool isar_feature_aa64_hdbs (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr1,ID_AA64MMFR1 ,HAFDBS ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR1 ,HAFDBS ) >=2 ; }static inline bool isar_feature_aa64_tts2uxn (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr1,ID_AA64MMFR1 ,XNX ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR1 ,XNX ) !=0 ; }static inline bool isar_feature_aa64_uao (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr2,ID_AA64MMFR2 ,UAO ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,UAO ) !=0 ; }static inline bool isar_feature_aa64_st (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr2,ID_AA64MMFR2 ,ST ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,ST ) !=0 ; }static inline bool isar_feature_aa64_lse2 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr2,ID_AA64MMFR2 ,AT ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,AT ) !=0 ; }static inline bool isar_feature_aa64_fwb (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr2,ID_AA64MMFR2 ,FWB ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,FWB ) !=0 ; }static inline bool isar_feature_aa64_ids (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr2,ID_AA64MMFR2 ,IDS ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,IDS ) !=0 ; }static inline bool isar_feature_aa64_half_evt (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr2,ID_AA64MMFR2 ,EVT ) >=1 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,EVT ) >=1 ; }static inline bool isar_feature_aa64_evt (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr2,ID_AA64MMFR2 ,EVT ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,EVT ) >=2 ; }static inline bool isar_feature_aa64_ccidx (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr2,ID_AA64MMFR2 ,CCIDX ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,CCIDX ) !=0 ; }static inline bool isar_feature_aa64_lva (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr2,ID_AA64MMFR2 ,VARANGE ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,VARANGE ) !=0 ; }static inline bool isar_feature_aa64_e0pd (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr2,ID_AA64MMFR2 ,E0PD ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,E0PD ) !=0 ; }static inline bool isar_feature_aa64_nv (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr2,ID_AA64MMFR2 ,NV ) !=0 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,NV ) !=0 ; }static inline bool isar_feature_aa64_nv2 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64mmfr2,ID_AA64MMFR2 ,NV ) >=2 ; +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,NV ) >=2 ; }static inline bool isar_feature_aa64_pmuv3p1 (const ARMISARegisters *id)
target/arm/cpu.h +0 -4
@@ -1097,10 +1097,6 @@ struct ArchCPU {uint32_t dbgdidr;uint32_t dbgdevid;uint32_t dbgdevid1; -uint64_t id_aa64mmfr0; -uint64_t id_aa64mmfr1; -uint64_t id_aa64mmfr2; -uint64_t id_aa64mmfr3;uint64_t id_aa64dfr0;uint64_t id_aa64dfr1;uint64_t id_aa64smfr0;
target/arm/cpu64.c +4 -4
@@ -601,12 +601,12 @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp)return ; } - t = cpu->isar.id_aa64mmfr0; + t =GET_IDREG (&cpu->isar,ID_AA64MMFR0 ); t =FIELD_DP64 (t,ID_AA64MMFR0 ,TGRAN16 ,2 );/* 16k pages w/ LPA2 */ t =FIELD_DP64 (t,ID_AA64MMFR0 ,TGRAN4 ,1 );/* 4k pages w/ LPA2 */ t =FIELD_DP64 (t,ID_AA64MMFR0 ,TGRAN16_2 ,3 );/* 16k stage2 w/ LPA2 */ t =FIELD_DP64 (t,ID_AA64MMFR0 ,TGRAN4_2 ,3 );/* 4k stage2 w/ LPA2 */ - cpu->isar.id_aa64mmfr0 = t; +SET_IDREG (&cpu->isar,ID_AA64MMFR0 , t); }static void aarch64_a57_initfn (Object *obj)
@@ -651,7 +651,7 @@ static void aarch64_a57_initfn(Object *obj)SET_IDREG (isar,ID_AA64PFR0 ,0x00002222 ); cpu->isar.id_aa64dfr0 =0x10305106 ;SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 ); - cpu->isar.id_aa64mmfr0 =0x00001124 ; +SET_IDREG (isar,ID_AA64MMFR0 ,0x00001124 ); cpu->isar.dbgdidr =0x3516d000 ; cpu->isar.dbgdevid =0x01110f13 ; cpu->isar.dbgdevid1 =0x2 ;
@@ -713,7 +713,7 @@ static void aarch64_a53_initfn(Object *obj)SET_IDREG (isar,ID_AA64PFR0 ,0x00002222 ); cpu->isar.id_aa64dfr0 =0x10305106 ;SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 ); - cpu->isar.id_aa64mmfr0 =0x00001122 ;/* 40 bit physical addr */ +SET_IDREG (isar,ID_AA64MMFR0 ,0x00001122 );/* 40 bit physical addr */ cpu->isar.dbgdidr =0x3516d000 ; cpu->isar.dbgdevid =0x00110f13 ; cpu->isar.dbgdevid1 =0x1 ;
target/arm/helper.c +4 -4
@@ -7820,22 +7820,22 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_aa64mmfr0 }, + .resetvalue = GET_IDREG(isar, ID_AA64MMFR0)}, { .name = "ID_AA64MMFR1_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_aa64mmfr1 }, + .resetvalue = GET_IDREG(isar, ID_AA64MMFR1) }, { .name = "ID_AA64MMFR2_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_aa64mmfr2 }, + .resetvalue = GET_IDREG(isar, ID_AA64MMFR2) }, { .name = "ID_AA64MMFR3_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_aa64mmfr3 }, + .resetvalue = GET_IDREG(isar, ID_AA64MMFR3) }, { .name = "ID_AA64MMFR4_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST,
target/arm/hvf/hvf.c +12 -9
@@ -845,14 +845,17 @@ static uint64_t hvf_get_reg(CPUState *cpu, int rt)return val; } -static void clamp_id_aa64mmfr0_parange_to_ipa_size (uint64_t *id_aa64mmfr0) +static void clamp_id_aa64mmfr0_parange_to_ipa_size (ARMISARegisters *isar) {uint32_t ipa_size = chosen_ipa_bit_size ? chosen_ipa_bit_size :hvf_arm_get_max_ipa_bit_size (); +uint64_t id_aa64mmfr0;/* Clamp down the PARange to the IPA size the kernel supports. */ uint8_t index =round_down_to_parange_index (ipa_size); - *id_aa64mmfr0 = (*id_aa64mmfr0 & ~R_ID_AA64MMFR0_PARANGE_MASK ) | index; + id_aa64mmfr0 =GET_IDREG (isar,ID_AA64MMFR0 ); + id_aa64mmfr0 = (id_aa64mmfr0 & ~R_ID_AA64MMFR0_PARANGE_MASK ) | index; +SET_IDREG (isar,ID_AA64MMFR0 , id_aa64mmfr0); }static bool hvf_arm_get_host_cpu_features (ARMHostCPUFeatures *ahcf)
@@ -869,9 +872,9 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) { HV_SYS_REG_ID_AA64ISAR0_EL1, &host_isar.idregs[ID_AA64ISAR0_EL1_IDX] }, { HV_SYS_REG_ID_AA64ISAR1_EL1, &host_isar.idregs[ID_AA64ISAR1_EL1_IDX] },/* Add ID_AA64ISAR2_EL1 here when HVF supports it */ - { HV_SYS_REG_ID_AA64MMFR0_EL1, &host_isar.id_aa64mmfr0 }, - { HV_SYS_REG_ID_AA64MMFR1_EL1, &host_isar.id_aa64mmfr1 }, - { HV_SYS_REG_ID_AA64MMFR2_EL1, &host_isar.id_aa64mmfr2 }, + { HV_SYS_REG_ID_AA64MMFR0_EL1, &host_isar.idregs[ID_AA64MMFR0_EL1_IDX] }, + { HV_SYS_REG_ID_AA64MMFR1_EL1, &host_isar.idregs[ID_AA64MMFR1_EL1_IDX] }, + { HV_SYS_REG_ID_AA64MMFR2_EL1, &host_isar.idregs[ID_AA64MMFR2_EL1_IDX] }, /* Add ID_AA64MMFR3_EL1 here when HVF supports it */ };hv_vcpu_t fd;
@@ -898,7 +901,7 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) r |=hv_vcpu_get_sys_reg (fd,HV_SYS_REG_MIDR_EL1 , &ahcf->midr); r |=hv_vcpu_destroy (fd); -clamp_id_aa64mmfr0_parange_to_ipa_size (&host_isar.id_aa64mmfr0); +clamp_id_aa64mmfr0_parange_to_ipa_size (&host_isar); ahcf->isar = host_isar;
@@ -1053,12 +1056,12 @@ int hvf_arch_init_vcpu(CPUState *cpu)/* We're limited to underlying hardware caps, override internal versions */ ret =hv_vcpu_get_sys_reg (cpu->accel->fd,HV_SYS_REG_ID_AA64MMFR0_EL1 , - &arm_cpu->isar.id_aa64mmfr0); + &arm_cpu->isar.idregs[ID_AA64MMFR0_EL1_IDX ]);assert_hvf_ok (ret); -clamp_id_aa64mmfr0_parange_to_ipa_size (&arm_cpu->isar.id_aa64mmfr0); +clamp_id_aa64mmfr0_parange_to_ipa_size (&arm_cpu->isar); ret =hv_vcpu_set_sys_reg (cpu->accel->fd,HV_SYS_REG_ID_AA64MMFR0_EL1 , - arm_cpu->isar.id_aa64mmfr0); + arm_cpu->isar.idregs[ID_AA64MMFR0_EL1_IDX ]);assert_hvf_ok (ret);return 0 ;
target/arm/kvm.c +4 -8
@@ -352,14 +352,10 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) err |=get_host_cpu_reg (fd, ahcf,ID_AA64ISAR0_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_AA64ISAR1_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_AA64ISAR2_EL1_IDX ); - err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64mmfr0, -ARM64_SYS_REG (3 ,0 ,0 ,7 ,0 )); - err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64mmfr1, -ARM64_SYS_REG (3 ,0 ,0 ,7 ,1 )); - err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64mmfr2, -ARM64_SYS_REG (3 ,0 ,0 ,7 ,2 )); - err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64mmfr3, -ARM64_SYS_REG (3 ,0 ,0 ,7 ,3 )); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64MMFR0_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64MMFR1_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64MMFR2_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64MMFR3_EL1_IDX );/* * Note that if AArch32 support is not present in the host,
target/arm/ptw.c +3 -3
@@ -120,7 +120,7 @@ unsigned int arm_pamax(ARMCPU *cpu) {if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {unsigned int parange = -FIELD_EX64 (cpu->isar.id_aa64mmfr0,ID_AA64MMFR0 ,PARANGE ); +FIELD_EX64_IDREG (&cpu->isar,ID_AA64MMFR0 ,PARANGE );/* * id_aa64mmfr0 is a read-only register so values outside of the
@@ -330,7 +330,7 @@ static bool granule_protection_check(CPUARMState *env, uint64_t paddress,* physical address size is invalid. */ pps =FIELD_EX64 (gpccr,GPCCR ,PPS ); -if (pps >FIELD_EX64 (cpu->isar.id_aa64mmfr0,ID_AA64MMFR0 ,PARANGE )) { +if (pps >FIELD_EX64_IDREG (&cpu->isar,ID_AA64MMFR0 ,PARANGE )) { goto fault_walk; } pps = pamax_map[pps];
@@ -1701,7 +1701,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,* ID_AA64MMFR0 is a read-only register so values outside of the * supported mappings can be considered an implementation error. */ - ps =FIELD_EX64 (cpu->isar.id_aa64mmfr0,ID_AA64MMFR0 ,PARANGE ); + ps =FIELD_EX64_IDREG (&cpu->isar,ID_AA64MMFR0 ,PARANGE ); ps =MIN (ps, param.ps);assert (ps <ARRAY_SIZE (pamax_map)); outputsize = pamax_map[ps];
target/arm/tcg/cpu64.c +31 -33
145 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH v2 7/14 arm/cpu: Store aa64dfr0/1 into the idregs array
In reply to Cornelia HuckFrom: Eric Auger <[email protected]>
--- target/arm/cpu-features.h | 16 ++++++++-------- target/arm/cpu.c | 15 +++++---------- target/arm/cpu.h | 2 -- target/arm/cpu64.c | 4 ++-- target/arm/helper.c | 4 ++-- target/arm/hvf/hvf.c | 4 ++-- target/arm/internals.h | 6 +++--- target/arm/kvm.c | 12 +++++------- target/arm/tcg/cpu64.c | 33 +++++++++++++++++---------------- 9 files changed, 44 insertions(+), 52 deletions(-)
target/arm/cpu-features.h +8 -8
@@ -900,30 +900,30 @@ static inline bool isar_feature_aa64_nv2(const ARMISARegisters *id)static inline bool isar_feature_aa64_pmuv3p1 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64dfr0,ID_AA64DFR0 ,PMUVER ) >=4 && -FIELD_EX64 (id->id_aa64dfr0,ID_AA64DFR0 ,PMUVER ) !=0xf ; +return FIELD_EX64_IDREG (id,ID_AA64DFR0 ,PMUVER ) >=4 && +FIELD_EX64_IDREG (id,ID_AA64DFR0 ,PMUVER ) !=0xf ; }static inline bool isar_feature_aa64_pmuv3p4 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64dfr0,ID_AA64DFR0 ,PMUVER ) >=5 && -FIELD_EX64 (id->id_aa64dfr0,ID_AA64DFR0 ,PMUVER ) !=0xf ; +return FIELD_EX64_IDREG (id,ID_AA64DFR0 ,PMUVER ) >=5 && +FIELD_EX64_IDREG (id,ID_AA64DFR0 ,PMUVER ) !=0xf ; }static inline bool isar_feature_aa64_pmuv3p5 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64dfr0,ID_AA64DFR0 ,PMUVER ) >=6 && -FIELD_EX64 (id->id_aa64dfr0,ID_AA64DFR0 ,PMUVER ) !=0xf ; +return FIELD_EX64_IDREG (id,ID_AA64DFR0 ,PMUVER ) >=6 && +FIELD_EX64_IDREG (id,ID_AA64DFR0 ,PMUVER ) !=0xf ; }static inline bool isar_feature_aa64_debugv8p2 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64dfr0,ID_AA64DFR0 ,DEBUGVER ) >=8 ; +return FIELD_EX64_IDREG (id,ID_AA64DFR0 ,DEBUGVER ) >=8 ; }static inline bool isar_feature_aa64_doublelock (const ARMISARegisters *id) { -return FIELD_SEX64 (id->id_aa64dfr0,ID_AA64DFR0 ,DOUBLELOCK ) >=0 ; +return FIELD_SEX64_IDREG (id,ID_AA64DFR0 ,DOUBLELOCK ) >=0 ; }static inline bool isar_feature_aa64_sve2 (const ARMISARegisters *id)
target/arm/cpu.c +5 -10
@@ -2352,8 +2352,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu);#endif }else { - cpu->isar.id_aa64dfr0 = -FIELD_DP64 (cpu->isar.id_aa64dfr0,ID_AA64DFR0 ,PMUVER ,0 ); +FIELD_DP64_IDREG (isar,ID_AA64DFR0 ,PMUVER ,0 ); cpu->isar.id_dfr0 =FIELD_DP32 (cpu->isar.id_dfr0,ID_DFR0 ,PERFMON ,0 ); cpu->pmceid0 =0 ; cpu->pmceid1 =0 ;
@@ -2413,19 +2412,15 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)* try to access the non-existent system registers for them. */ /* FEAT_SPE (Statistical Profiling Extension) */ - cpu->isar.id_aa64dfr0 = -FIELD_DP64 (cpu->isar.id_aa64dfr0,ID_AA64DFR0 ,PMSVER ,0 ); +FIELD_DP64_IDREG (isar,ID_AA64DFR0 ,PMSVER ,0 );/* FEAT_TRBE (Trace Buffer Extension) */ - cpu->isar.id_aa64dfr0 = -FIELD_DP64 (cpu->isar.id_aa64dfr0,ID_AA64DFR0 ,TRACEBUFFER ,0 ); +FIELD_DP64_IDREG (isar,ID_AA64DFR0 ,TRACEBUFFER ,0 );/* FEAT_TRF (Self-hosted Trace Extension) */ - cpu->isar.id_aa64dfr0 = -FIELD_DP64 (cpu->isar.id_aa64dfr0,ID_AA64DFR0 ,TRACEFILT ,0 ); +FIELD_DP64_IDREG (isar,ID_AA64DFR0 ,TRACEFILT ,0 ); cpu->isar.id_dfr0 =FIELD_DP32 (cpu->isar.id_dfr0,ID_DFR0 ,TRACEFILT ,0 );/* Trace Macrocell system register access */ - cpu->isar.id_aa64dfr0 = -FIELD_DP64 (cpu->isar.id_aa64dfr0,ID_AA64DFR0 ,TRACEVER ,0 ); +FIELD_DP64_IDREG (isar,ID_AA64DFR0 ,TRACEVER ,0 ); cpu->isar.id_dfr0 =FIELD_DP32 (cpu->isar.id_dfr0,ID_DFR0 ,COPTRC ,0 );/* Memory mapped trace */
target/arm/cpu.h +0 -2
@@ -1097,8 +1097,6 @@ struct ArchCPU {uint32_t dbgdidr;uint32_t dbgdevid;uint32_t dbgdevid1; -uint64_t id_aa64dfr0; -uint64_t id_aa64dfr1;uint64_t id_aa64smfr0;uint64_t reset_pmcr_el0;uint64_t idregs[NUM_ID_IDX ];
target/arm/cpu64.c +2 -2
@@ -649,7 +649,7 @@ static void aarch64_a57_initfn(Object *obj) cpu->isar.id_isar5 =0x00011121 ; cpu->isar.id_isar6 =0 ;SET_IDREG (isar,ID_AA64PFR0 ,0x00002222 ); - cpu->isar.id_aa64dfr0 =0x10305106 ; +SET_IDREG (isar,ID_AA64DFR0 ,0x10305106 );SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 );SET_IDREG (isar,ID_AA64MMFR0 ,0x00001124 ); cpu->isar.dbgdidr =0x3516d000 ;
@@ -711,7 +711,7 @@ static void aarch64_a53_initfn(Object *obj) cpu->isar.id_isar5 =0x00011121 ; cpu->isar.id_isar6 =0 ;SET_IDREG (isar,ID_AA64PFR0 ,0x00002222 ); - cpu->isar.id_aa64dfr0 =0x10305106 ; +SET_IDREG (isar,ID_AA64DFR0 ,0x10305106 );SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 );SET_IDREG (isar,ID_AA64MMFR0 ,0x00001122 );/* 40 bit physical addr */ cpu->isar.dbgdidr =0x3516d000 ;
target/arm/helper.c +2 -2
@@ -7740,12 +7740,12 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_aa64dfr0 }, + .resetvalue = GET_IDREG(isar, ID_AA64DFR0) }, { .name = "ID_AA64DFR1_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_aa64dfr1 }, + .resetvalue = GET_IDREG(isar, ID_AA64DFR1) }, { .name = "ID_AA64DFR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST,
target/arm/hvf/hvf.c +2 -2
@@ -867,8 +867,8 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) } regs[] = { { HV_SYS_REG_ID_AA64PFR0_EL1, &host_isar.idregs[ID_AA64PFR0_EL1_IDX] }, { HV_SYS_REG_ID_AA64PFR1_EL1, &host_isar.idregs[ID_AA64PFR1_EL1_IDX] }, - { HV_SYS_REG_ID_AA64DFR0_EL1, &host_isar.id_aa64dfr0 }, - { HV_SYS_REG_ID_AA64DFR1_EL1, &host_isar.id_aa64dfr1 }, + { HV_SYS_REG_ID_AA64DFR0_EL1, &host_isar.idregs[ID_AA64DFR0_EL1_IDX] }, + { HV_SYS_REG_ID_AA64DFR1_EL1, &host_isar.idregs[ID_AA64DFR1_EL1_IDX] }, { HV_SYS_REG_ID_AA64ISAR0_EL1, &host_isar.idregs[ID_AA64ISAR0_EL1_IDX] }, { HV_SYS_REG_ID_AA64ISAR1_EL1, &host_isar.idregs[ID_AA64ISAR1_EL1_IDX] }, /* Add ID_AA64ISAR2_EL1 here when HVF supports it */
target/arm/internals.h +3 -3
@@ -1035,7 +1035,7 @@ static inline bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx)static inline int arm_num_brps (ARMCPU *cpu) {if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { -return FIELD_EX64 (cpu->isar.id_aa64dfr0,ID_AA64DFR0 ,BRPS ) +1 ; +return FIELD_EX64_IDREG (&cpu->isar,ID_AA64DFR0 ,BRPS ) +1 ; }else {return FIELD_EX32 (cpu->isar.dbgdidr,DBGDIDR ,BRPS ) +1 ; }
@@ -1049,7 +1049,7 @@ static inline int arm_num_brps(ARMCPU *cpu)static inline int arm_num_wrps (ARMCPU *cpu) {if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { -return FIELD_EX64 (cpu->isar.id_aa64dfr0,ID_AA64DFR0 ,WRPS ) +1 ; +return FIELD_EX64_IDREG (&cpu->isar,ID_AA64DFR0 ,WRPS ) +1 ; }else {return FIELD_EX32 (cpu->isar.dbgdidr,DBGDIDR ,WRPS ) +1 ; }
@@ -1063,7 +1063,7 @@ static inline int arm_num_wrps(ARMCPU *cpu)static inline int arm_num_ctx_cmps (ARMCPU *cpu) {if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { -return FIELD_EX64 (cpu->isar.id_aa64dfr0,ID_AA64DFR0 ,CTX_CMPS ) +1 ; +return FIELD_EX64_IDREG (&cpu->isar,ID_AA64DFR0 ,CTX_CMPS ) +1 ; }else {return FIELD_EX32 (cpu->isar.dbgdidr,DBGDIDR ,CTX_CMPS ) +1 ; }
target/arm/kvm.c +5 -7
@@ -345,10 +345,8 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) err |=get_host_cpu_reg (fd, ahcf,ID_AA64PFR1_EL1_IDX ); err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64smfr0,ARM64_SYS_REG (3 ,0 ,0 ,4 ,5 )); - err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64dfr0, -ARM64_SYS_REG (3 ,0 ,0 ,5 ,0 )); - err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64dfr1, -ARM64_SYS_REG (3 ,0 ,0 ,5 ,1 )); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64DFR0_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64DFR1_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_AA64ISAR0_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_AA64ISAR1_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_AA64ISAR2_EL1_IDX );
@@ -417,10 +415,10 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)* We only do this if the CPU supports AArch32 at EL1. */ if (FIELD_EX32_IDREG (&ahcf->isar,ID_AA64PFR0 ,EL1 ) >=2 ) { -int wrps =FIELD_EX64 (&ahcf->isar.id_aa64dfr0,ID_AA64DFR0 ,WRPS ); -int brps =FIELD_EX64 (&ahcf->isar.id_aa64dfr0,ID_AA64DFR0 ,BRPS ); +int wrps =FIELD_EX64_IDREG (&ahcf->isar,ID_AA64DFR0 ,WRPS ); +int brps =FIELD_EX64_IDREG (&ahcf->isar,ID_AA64DFR0 ,BRPS );int ctx_cmps = -FIELD_EX64 (&ahcf->isar.id_aa64dfr0,ID_AA64DFR0 ,CTX_CMPS ); +FIELD_EX64_IDREG (&ahcf->isar,ID_AA64DFR0 ,CTX_CMPS );int version =6 ;/* ARMv8 debug architecture */ bool has_el3 = !!FIELD_EX32_IDREG (&ahcf->isar,ID_AA64PFR0 ,EL3 );
target/arm/tcg/cpu64.c +17 -16
@@ -65,8 +65,8 @@ static void aarch64_a35_initfn(Object *obj) cpu->isar.id_isar5 =0x00011121 ;SET_IDREG (isar,ID_AA64PFR0 ,0x00002222 );SET_IDREG (isar,ID_AA64PFR1 ,0 ); - cpu->isar.id_aa64dfr0 =0x10305106 ; - cpu->isar.id_aa64dfr1 =0 ; +SET_IDREG (isar,ID_AA64DFR0 ,0x10305106 ); +SET_IDREG (isar,ID_AA64DFR1 ,0 );SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 );SET_IDREG (isar,ID_AA64ISAR1 ,0 );SET_IDREG (isar,ID_AA64MMFR0 ,0x00101122 );
@@ -219,7 +219,7 @@ static void aarch64_a55_initfn(Object *obj) cpu->clidr =0x82000023 ; cpu->ctr =0x84448004 ;/* L1Ip = VIPT */ cpu->dcz_blocksize =4 ;/* 64 bytes */ - cpu->isar.id_aa64dfr0 =0x0000000010305408ull ; +SET_IDREG (isar,ID_AA64DFR0 ,0x0000000010305408ull );SET_IDREG (isar,ID_AA64ISAR0 ,0x0000100010211120ull );SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000100001ull );SET_IDREG (isar,ID_AA64MMFR0 ,0x0000000000101122ull );
@@ -310,7 +310,7 @@ static void aarch64_a72_initfn(Object *obj) cpu->isar.id_isar4 =0x00011142 ; cpu->isar.id_isar5 =0x00011121 ;SET_IDREG (isar,ID_AA64PFR0 ,0x00002222 ); - cpu->isar.id_aa64dfr0 =0x10305106 ; +SET_IDREG (isar,ID_AA64DFR0 ,0x10305106 );SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 );SET_IDREG (isar,ID_AA64MMFR0 ,0x00001124 ); cpu->isar.dbgdidr =0x3516d000 ;
@@ -352,7 +352,7 @@ static void aarch64_a76_initfn(Object *obj) cpu->clidr =0x82000023 ; cpu->ctr =0x8444C004 ; cpu->dcz_blocksize =4 ; - cpu->isar.id_aa64dfr0 =0x0000000010305408ull ; +SET_IDREG (isar,ID_AA64DFR0 ,0x0000000010305408ull ),SET_IDREG (isar,ID_AA64ISAR0 ,0x0000100010211120ull );SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000100001ull );SET_IDREG (isar,ID_AA64MMFR0 ,0x0000000000101122ull );
@@ -426,8 +426,8 @@ static void aarch64_a64fx_initfn(Object *obj) cpu->reset_sctlr =0x30000180 ;SET_IDREG (isar,ID_AA64PFR0 ,0x0000000101111111 );/* No RAS Extensions */ SET_IDREG (isar,ID_AA64PFR1 ,0x0000000000000000 ); - cpu->isar.id_aa64dfr0 =0x0000000010305408 ; - cpu->isar.id_aa64dfr1 =0x0000000000000000 ; +SET_IDREG (isar,ID_AA64DFR0 ,0x0000000010305408 ), +SET_IDREG (isar,ID_AA64DFR1 ,0x0000000000000000 ), cpu->id_aa64afr0 =0x0000000000000000 ; cpu->id_aa64afr1 =0x0000000000000000 ;SET_IDREG (isar,ID_AA64MMFR0 ,0x0000000000001122 );
@@ -600,7 +600,7 @@ static void aarch64_neoverse_n1_initfn(Object *obj) cpu->clidr =0x82000023 ; cpu->ctr =0x8444c004 ; cpu->dcz_blocksize =4 ; - cpu->isar.id_aa64dfr0 =0x0000000110305408ull ; +SET_IDREG (isar,ID_AA64DFR0 ,0x0000000110305408ull );SET_IDREG (isar,ID_AA64ISAR0 ,0x0000100010211120ull );SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000100001ull );SET_IDREG (isar,ID_AA64MMFR0 ,0x0000000000101125ull );
@@ -678,8 +678,8 @@ static void aarch64_neoverse_v1_initfn(Object *obj) cpu->dcz_blocksize =4 ; cpu->id_aa64afr0 =0x00000000 ; cpu->id_aa64afr1 =0x00000000 ; - cpu->isar.id_aa64dfr0 =0x000001f210305519ull ; - cpu->isar.id_aa64dfr1 =0x00000000 ; +SET_IDREG (isar,ID_AA64DFR0 ,0x000001f210305519ull ), +SET_IDREG (isar,ID_AA64DFR1 ,0x00000000 ),SET_IDREG (isar,ID_AA64ISAR0 ,0x1011111110212120ull );/* with FEAT_RNG */ SET_IDREG (isar,ID_AA64ISAR1 ,0x0011000001211032ull );SET_IDREG (isar,ID_AA64MMFR0 ,0x0000000000101125ull );
@@ -925,8 +925,9 @@ static void aarch64_a710_initfn(Object *obj)SET_IDREG (isar,ID_AA64PFR0 ,0x1201111120111112ull );/* GIC filled in later */ SET_IDREG (isar,ID_AA64PFR1 ,0x0000000000000221ull );SET_IDREG (isar,ID_AA64ZFR0 ,0x0000110100110021ull );/* with Crypto */ - cpu->isar.id_aa64dfr0 =0x000011f010305619ull ; - cpu->isar.id_aa64dfr1 =0 ; +SET_IDREG (isar,ID_AA64DFR0 ,0x000011f010305619ull ); +SET_IDREG (isar,ID_AA64DFR0 ,0x000011f010305619ull ); +SET_IDREG (isar,ID_AA64DFR1 ,0 ); cpu->id_aa64afr0 =0 ; cpu->id_aa64afr1 =0 ;SET_IDREG (isar,ID_AA64ISAR0 ,0x0221111110212120ull );/* with Crypto */
@@ -1027,8 +1028,8 @@ static void aarch64_neoverse_n2_initfn(Object *obj)SET_IDREG (isar,ID_AA64PFR0 ,0x1201111120111112ull );/* GIC filled in later */ SET_IDREG (isar,ID_AA64PFR1 ,0x0000000000000221ull );SET_IDREG (isar,ID_AA64ZFR0 ,0x0000110100110021ull );/* with Crypto */ - cpu->isar.id_aa64dfr0 =0x000011f210305619ull ; - cpu->isar.id_aa64dfr1 =0 ; +SET_IDREG (isar,ID_AA64DFR0 ,0x000011f210305619ull ); +SET_IDREG (isar,ID_AA64DFR1 ,0 ); cpu->id_aa64afr0 =0 ; cpu->id_aa64afr1 =0 ;SET_IDREG (isar,ID_AA64ISAR0 ,0x1221111110212120ull );/* with Crypto and FEAT_RNG */
@@ -1261,11 +1262,11 @@ void aarch64_max_tcg_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ZFR0 ,F64MM ,1 );/* FEAT_F64MM */ SET_IDREG (isar,ID_AA64ZFR0 , t); - t = cpu->isar.id_aa64dfr0; + t =GET_IDREG (isar,ID_AA64DFR0 ); t =FIELD_DP64 (t,ID_AA64DFR0 ,DEBUGVER ,10 );/* FEAT_Debugv8p8 */ t =FIELD_DP64 (t,ID_AA64DFR0 ,PMUVER ,6 );/* FEAT_PMUv3p5 */ t =FIELD_DP64 (t,ID_AA64DFR0 ,HPMN0 ,1 );/* FEAT_HPMN0 */ - cpu->isar.id_aa64dfr0 = t; +SET_IDREG (isar,ID_AA64DFR0 , t); t = cpu->isar.id_aa64smfr0; t =FIELD_DP64 (t,ID_AA64SMFR0 ,F32F32 ,1 );/* FEAT_SME */
Signature · 1 line
2.48.1
PATCH v2 8/14 arm/cpu: Store aa64smfr0 into the idregs array
In reply to Cornelia HuckFrom: Eric Auger <[email protected]>
--- target/arm/cpu-features.h | 6 +++--- target/arm/cpu.h | 1 - target/arm/cpu64.c | 7 ++----- target/arm/helper.c | 2 +- target/arm/kvm.c | 3 +-- target/arm/tcg/cpu64.c | 4 ++-- 6 files changed, 9 insertions(+), 14 deletions(-)
target/arm/cpu-features.h +3 -3
@@ -978,17 +978,17 @@ static inline bool isar_feature_aa64_sve_f64mm(const ARMISARegisters *id)static inline bool isar_feature_aa64_sme_f64f64 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64smfr0,ID_AA64SMFR0 ,F64F64 ); +return FIELD_EX64_IDREG (id,ID_AA64SMFR0 ,F64F64 ); }static inline bool isar_feature_aa64_sme_i16i64 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64smfr0,ID_AA64SMFR0 ,I16I64 ) ==0xf ; +return FIELD_EX64_IDREG (id,ID_AA64SMFR0 ,I16I64 ) ==0xf ; }static inline bool isar_feature_aa64_sme_fa64 (const ARMISARegisters *id) { -return FIELD_EX64 (id->id_aa64smfr0,ID_AA64SMFR0 ,FA64 ); +return FIELD_EX64_IDREG (id,ID_AA64SMFR0 ,FA64 ); }/*
target/arm/cpu.h +0 -1
@@ -1097,7 +1097,6 @@ struct ArchCPU {uint32_t dbgdidr;uint32_t dbgdevid;uint32_t dbgdevid1; -uint64_t id_aa64smfr0;uint64_t reset_pmcr_el0;uint64_t idregs[NUM_ID_IDX ]; } isar;
target/arm/cpu64.c +2 -5
@@ -306,7 +306,7 @@ void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp)if (vq_map ==0 ) {if (!cpu_isar_feature (aa64_sme, cpu)) { - cpu->isar.id_aa64smfr0 =0 ; +SET_IDREG (&cpu->isar,ID_AA64SMFR0 ,0 );return ; }
@@ -359,11 +359,8 @@ static bool cpu_arm_get_sme_fa64(Object *obj, Error **errp)static void cpu_arm_set_sme_fa64 (Object *obj,bool value,Error **errp) {ARMCPU *cpu =ARM_CPU (obj); -uint64_t t; - t = cpu->isar.id_aa64smfr0; - t =FIELD_DP64 (t,ID_AA64SMFR0 ,FA64 , value); - cpu->isar.id_aa64smfr0 = t; +FIELD_DP64_IDREG (&cpu->isar,ID_AA64SMFR0 ,FA64 , value); }#ifdef CONFIG_USER_ONLY
target/arm/helper.c +1 -1
@@ -7725,7 +7725,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_aa64smfr0 }, + .resetvalue = GET_IDREG(isar, ID_AA64SMFR0)}, { .name = "ID_AA64PFR6_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST,
target/arm/kvm.c +1 -2
@@ -343,8 +343,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) err =0 ; }else { err |=get_host_cpu_reg (fd, ahcf,ID_AA64PFR1_EL1_IDX ); - err |=read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64smfr0, -ARM64_SYS_REG (3 ,0 ,0 ,4 ,5 )); + err |=get_host_cpu_reg (fd, ahcf,ID_AA64SMFR0_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_AA64DFR0_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_AA64DFR1_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_AA64ISAR0_EL1_IDX );
target/arm/tcg/cpu64.c +2 -2
@@ -1268,7 +1268,7 @@ void aarch64_max_tcg_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64DFR0 ,HPMN0 ,1 );/* FEAT_HPMN0 */ SET_IDREG (isar,ID_AA64DFR0 , t); - t = cpu->isar.id_aa64smfr0; + t =GET_IDREG (isar,ID_AA64SMFR0 ); t =FIELD_DP64 (t,ID_AA64SMFR0 ,F32F32 ,1 );/* FEAT_SME */ t =FIELD_DP64 (t,ID_AA64SMFR0 ,B16F32 ,1 );/* FEAT_SME */ t =FIELD_DP64 (t,ID_AA64SMFR0 ,F16F32 ,1 );/* FEAT_SME */
@@ -1276,7 +1276,7 @@ void aarch64_max_tcg_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64SMFR0 ,F64F64 ,1 );/* FEAT_SME_F64F64 */ t =FIELD_DP64 (t,ID_AA64SMFR0 ,I16I64 ,0xf );/* FEAT_SME_I16I64 */ t =FIELD_DP64 (t,ID_AA64SMFR0 ,FA64 ,1 );/* FEAT_SME_FA64 */ - cpu->isar.id_aa64smfr0 = t; +SET_IDREG (isar,ID_AA64SMFR0 , t);/* Replicate the same data to the 32-bit id registers. */ aa32_max_features (cpu);
Signature · 1 line
2.48.1
PATCH v2 9/14 arm/cpu: Store id_isar0-7 into the idregs array
In reply to Cornelia HuckFrom: Eric Auger <[email protected]>
--- hw/intc/armv7m_nvic.c | 12 ++-- target/arm/cpu-features.h | 36 +++++----- target/arm/cpu.c | 24 +++---- target/arm/cpu.h | 7 -- target/arm/cpu64.c | 28 ++++---- target/arm/helper.c | 14 ++-- target/arm/kvm.c | 21 ++---- target/arm/tcg/cpu-v7m.c | 90 +++++++++++++----------- target/arm/tcg/cpu32.c | 144 +++++++++++++++++++++----------------- target/arm/tcg/cpu64.c | 108 ++++++++++++++-------------- 10 files changed, 243 insertions(+), 241 deletions(-)
hw/intc/armv7m_nvic.c +6 -6
@@ -1303,32 +1303,32 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_isar0; +return GET_IDREG (&cpu->isar,ID_ISAR0 );case 0xd64 :/* ISAR1. */ if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_isar1; +return GET_IDREG (&cpu->isar,ID_ISAR1 );case 0xd68 :/* ISAR2. */ if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_isar2; +return GET_IDREG (&cpu->isar,ID_ISAR2 );case 0xd6c :/* ISAR3. */ if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_isar3; +return GET_IDREG (&cpu->isar,ID_ISAR3 );case 0xd70 :/* ISAR4. */ if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_isar4; +return GET_IDREG (&cpu->isar,ID_ISAR4 );case 0xd74 :/* ISAR5. */ if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_isar5; +return GET_IDREG (&cpu->isar,ID_ISAR5 );case 0xd78 :/* CLIDR */ return cpu->clidr;case 0xd7c :/* CTR */
target/arm/cpu-features.h +18 -18
@@ -45,93 +45,93 @@*/ static inline bool isar_feature_aa32_thumb_div (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar0,ID_ISAR0 ,DIVIDE ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR0 ,DIVIDE ) !=0 ; }static inline bool isar_feature_aa32_arm_div (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar0,ID_ISAR0 ,DIVIDE ) >1 ; +return FIELD_EX32_IDREG (id,ID_ISAR0 ,DIVIDE ) >1 ; }static inline bool isar_feature_aa32_lob (const ARMISARegisters *id) {/* (M-profile) low-overhead loops and branch future */ -return FIELD_EX32 (id->id_isar0,ID_ISAR0 ,CMPBRANCH ) >=3 ; +return FIELD_EX32_IDREG (id,ID_ISAR0 ,CMPBRANCH ) >=3 ; }static inline bool isar_feature_aa32_jazelle (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar1,ID_ISAR1 ,JAZELLE ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR1 ,JAZELLE ) !=0 ; }static inline bool isar_feature_aa32_aes (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar5,ID_ISAR5 ,AES ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR5 ,AES ) !=0 ; }static inline bool isar_feature_aa32_pmull (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar5,ID_ISAR5 ,AES ) >1 ; +return FIELD_EX32_IDREG (id,ID_ISAR5 ,AES ) >1 ; }static inline bool isar_feature_aa32_sha1 (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar5,ID_ISAR5 ,SHA1 ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR5 ,SHA1 ) !=0 ; }static inline bool isar_feature_aa32_sha2 (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar5,ID_ISAR5 ,SHA2 ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR5 ,SHA2 ) !=0 ; }static inline bool isar_feature_aa32_crc32 (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar5,ID_ISAR5 ,CRC32 ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR5 ,CRC32 ) !=0 ; }static inline bool isar_feature_aa32_rdm (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar5,ID_ISAR5 ,RDM ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR5 ,RDM ) !=0 ; }static inline bool isar_feature_aa32_vcma (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar5,ID_ISAR5 ,VCMA ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR5 ,VCMA ) !=0 ; }static inline bool isar_feature_aa32_jscvt (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,JSCVT ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR6 ,JSCVT ) !=0 ; }static inline bool isar_feature_aa32_dp (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,DP ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR6 ,DP ) !=0 ; }static inline bool isar_feature_aa32_fhm (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,FHM ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR6 ,FHM ) !=0 ; }static inline bool isar_feature_aa32_sb (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,SB ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR6 ,SB ) !=0 ; }static inline bool isar_feature_aa32_predinv (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,SPECRES ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR6 ,SPECRES ) !=0 ; }static inline bool isar_feature_aa32_bf16 (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,BF16 ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR6 ,BF16 ) !=0 ; }static inline bool isar_feature_aa32_i8mm (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,I8MM ) !=0 ; +return FIELD_EX32_IDREG (id,ID_ISAR6 ,I8MM ) !=0 ; }static inline bool isar_feature_aa32_ras (const ARMISARegisters *id)
target/arm/cpu.c +11 -13
@@ -2131,10 +2131,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,FP ,0xf ); - u = cpu->isar.id_isar6; + u =GET_IDREG (isar,ID_ISAR6 ); u =FIELD_DP32 (u,ID_ISAR6 ,JSCVT ,0 ); u =FIELD_DP32 (u,ID_ISAR6 ,BF16 ,0 ); - cpu->isar.id_isar6 = u; +SET_IDREG (isar,ID_ISAR6 , u); u = cpu->isar.mvfr0; u =FIELD_DP32 (u,MVFR0 ,FPSP ,0 );
@@ -2186,20 +2186,20 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,ADVSIMD ,0xf ); - u = cpu->isar.id_isar5; + u =GET_IDREG (isar,ID_ISAR5 ); u =FIELD_DP32 (u,ID_ISAR5 ,AES ,0 ); u =FIELD_DP32 (u,ID_ISAR5 ,SHA1 ,0 ); u =FIELD_DP32 (u,ID_ISAR5 ,SHA2 ,0 ); u =FIELD_DP32 (u,ID_ISAR5 ,RDM ,0 ); u =FIELD_DP32 (u,ID_ISAR5 ,VCMA ,0 ); - cpu->isar.id_isar5 = u; +SET_IDREG (isar,ID_ISAR5 , u); - u = cpu->isar.id_isar6; + u =GET_IDREG (isar,ID_ISAR6 ); u =FIELD_DP32 (u,ID_ISAR6 ,DP ,0 ); u =FIELD_DP32 (u,ID_ISAR6 ,FHM ,0 ); u =FIELD_DP32 (u,ID_ISAR6 ,BF16 ,0 ); u =FIELD_DP32 (u,ID_ISAR6 ,I8MM ,0 ); - cpu->isar.id_isar6 = u; +SET_IDREG (isar,ID_ISAR6 , u);if (!arm_feature (env,ARM_FEATURE_M )) { u = cpu->isar.mvfr1;
@@ -2237,19 +2237,17 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)unset_feature (env,ARM_FEATURE_THUMB_DSP ); - u = cpu->isar.id_isar1; - u =FIELD_DP32 (u,ID_ISAR1 ,EXTEND ,1 ); - cpu->isar.id_isar1 = u; +FIELD_DP32_IDREG (isar,ID_ISAR1 ,EXTEND ,1 ); - u = cpu->isar.id_isar2; + u =GET_IDREG (isar,ID_ISAR2 ); u =FIELD_DP32 (u,ID_ISAR2 ,MULTU ,1 ); u =FIELD_DP32 (u,ID_ISAR2 ,MULTS ,1 ); - cpu->isar.id_isar2 = u; +SET_IDREG (isar,ID_ISAR2 , u); - u = cpu->isar.id_isar3; + u =GET_IDREG (isar,ID_ISAR3 ); u =FIELD_DP32 (u,ID_ISAR3 ,SIMD ,1 ); u =FIELD_DP32 (u,ID_ISAR3 ,SATURATE ,0 ); - cpu->isar.id_isar3 = u; +SET_IDREG (isar,ID_ISAR3 , u); }
target/arm/cpu.h +0 -7
@@ -1073,13 +1073,6 @@ struct ArchCPU {* field by reading the value from the KVM vCPU. */ struct ARMISARegisters { -uint32_t id_isar0; -uint32_t id_isar1; -uint32_t id_isar2; -uint32_t id_isar3; -uint32_t id_isar4; -uint32_t id_isar5; -uint32_t id_isar6;uint32_t id_mmfr0;uint32_t id_mmfr1;uint32_t id_mmfr2;
target/arm/cpu64.c +14 -14
@@ -638,13 +638,13 @@ static void aarch64_a57_initfn(Object *obj) cpu->isar.id_mmfr1 =0x40000000 ; cpu->isar.id_mmfr2 =0x01260000 ; cpu->isar.id_mmfr3 =0x02102211 ; - cpu->isar.id_isar0 =0x02101110 ; - cpu->isar.id_isar1 =0x13112111 ; - cpu->isar.id_isar2 =0x21232042 ; - cpu->isar.id_isar3 =0x01112131 ; - cpu->isar.id_isar4 =0x00011142 ; - cpu->isar.id_isar5 =0x00011121 ; - cpu->isar.id_isar6 =0 ; +SET_IDREG (isar,ID_ISAR0 ,0x02101110 ); +SET_IDREG (isar,ID_ISAR1 ,0x13112111 ); +SET_IDREG (isar,ID_ISAR2 ,0x21232042 ); +SET_IDREG (isar,ID_ISAR3 ,0x01112131 ); +SET_IDREG (isar,ID_ISAR4 ,0x00011142 ); +SET_IDREG (isar,ID_ISAR5 ,0x00011121 ); +SET_IDREG (isar,ID_ISAR6 ,0 );SET_IDREG (isar,ID_AA64PFR0 ,0x00002222 );SET_IDREG (isar,ID_AA64DFR0 ,0x10305106 );SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 );
@@ -700,13 +700,13 @@ static void aarch64_a53_initfn(Object *obj) cpu->isar.id_mmfr1 =0x40000000 ; cpu->isar.id_mmfr2 =0x01260000 ; cpu->isar.id_mmfr3 =0x02102211 ; - cpu->isar.id_isar0 =0x02101110 ; - cpu->isar.id_isar1 =0x13112111 ; - cpu->isar.id_isar2 =0x21232042 ; - cpu->isar.id_isar3 =0x01112131 ; - cpu->isar.id_isar4 =0x00011142 ; - cpu->isar.id_isar5 =0x00011121 ; - cpu->isar.id_isar6 =0 ; +SET_IDREG (isar,ID_ISAR0 ,0x02101110 ); +SET_IDREG (isar,ID_ISAR1 ,0x13112111 ); +SET_IDREG (isar,ID_ISAR2 ,0x21232042 ); +SET_IDREG (isar,ID_ISAR3 ,0x01112131 ); +SET_IDREG (isar,ID_ISAR4 ,0x00011142 ); +SET_IDREG (isar,ID_ISAR5 ,0x00011121 ); +SET_IDREG (isar,ID_ISAR6 ,0 );SET_IDREG (isar,ID_AA64PFR0 ,0x00002222 );SET_IDREG (isar,ID_AA64DFR0 ,0x10305106 );SET_IDREG (isar,ID_AA64ISAR0 ,0x00011120 );
target/arm/helper.c +7 -7
@@ -7607,32 +7607,32 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_isar0 }, + .resetvalue = GET_IDREG(isar, ID_ISAR0)}, { .name = "ID_ISAR1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_isar1 }, + .resetvalue = GET_IDREG(isar, ID_ISAR1)}, { .name = "ID_ISAR2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_isar2 }, + .resetvalue = GET_IDREG(isar, ID_ISAR2)}, { .name = "ID_ISAR3", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_isar3 }, + .resetvalue = GET_IDREG(isar, ID_ISAR3) }, { .name = "ID_ISAR4", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_isar4 }, + .resetvalue = GET_IDREG(isar, ID_ISAR4) }, { .name = "ID_ISAR5", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_isar5 }, + .resetvalue = GET_IDREG(isar, ID_ISAR5) }, { .name = "ID_MMFR4", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST,
@@ -7642,7 +7642,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_isar6 }, + .resetvalue = GET_IDREG(isar, ID_ISAR6) }, };define_arm_cp_regs (cpu, v6_idregs);define_arm_cp_regs (cpu, v6_cp_reginfo);
target/arm/kvm.c +7 -14
@@ -373,22 +373,15 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ARM64_SYS_REG(3, 0, 0, 1, 6)); err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_mmfr3,ARM64_SYS_REG (3 ,0 ,0 ,1 ,7 )); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_isar0, -ARM64_SYS_REG (3 ,0 ,0 ,2 ,0 )); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_isar1, -ARM64_SYS_REG (3 ,0 ,0 ,2 ,1 )); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_isar2, -ARM64_SYS_REG (3 ,0 ,0 ,2 ,2 )); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_isar3, -ARM64_SYS_REG (3 ,0 ,0 ,2 ,3 )); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_isar4, -ARM64_SYS_REG (3 ,0 ,0 ,2 ,4 )); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_isar5, -ARM64_SYS_REG (3 ,0 ,0 ,2 ,5 )); + err |=get_host_cpu_reg (fd, ahcf,ID_ISAR0_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_ISAR1_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_ISAR2_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_ISAR3_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_ISAR4_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_ISAR5_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_ISAR6_EL1_IDX ); err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_mmfr4,ARM64_SYS_REG (3 ,0 ,0 ,2 ,6 )); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_isar6, -ARM64_SYS_REG (3 ,0 ,0 ,2 ,7 )); err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.mvfr0,ARM64_SYS_REG (3 ,0 ,0 ,3 ,0 ));
target/arm/tcg/cpu-v7m.c +48 -42
158 lines not on this page · raw message
target/arm/tcg/cpu32.c +78 -66
309 lines not on this page · raw message
target/arm/tcg/cpu64.c +54 -54
158 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH v2 10/14 arm/cpu: Store id_pfr0/1/2 into the idregs array
In reply to Cornelia HuckFrom: Eric Auger <[email protected]>
--- hw/intc/armv7m_nvic.c | 5 +- target/arm/cpu-features.h | 10 ++-- target/arm/cpu.c | 8 +-- target/arm/cpu.h | 3 - target/arm/cpu64.c | 8 +-- target/arm/helper.c | 8 +-- target/arm/kvm.c | 3 +- target/arm/tcg/cpu-v7m.c | 120 +++++++++++++++++++------------------- target/arm/tcg/cpu32.c | 52 ++++++++--------- target/arm/tcg/cpu64.c | 44 +++++++------- 10 files changed, 128 insertions(+), 133 deletions(-)
hw/intc/armv7m_nvic.c +3 -2
@@ -988,6 +988,7 @@ static void nvic_nmi_trigger(void *opaque, int n, int level)static uint32_t nvic_readl (NVICState *s,uint32_t offset,MemTxAttrs attrs) {ARMCPU *cpu = s->cpu; +ARMISARegisters *isar = &cpu->isar;uint32_t val;switch (offset) {
@@ -1263,12 +1264,12 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_pfr0; +return GET_IDREG (isar,ID_PFR0 );case 0xd44 :/* PFR1. */ if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_pfr1; +return GET_IDREG (isar,ID_PFR1 );case 0xd48 :/* DFR0. */ if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset;
target/arm/cpu-features.h +5 -5
@@ -136,12 +136,12 @@ static inline bool isar_feature_aa32_i8mm(const ARMISARegisters *id)static inline bool isar_feature_aa32_ras (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_pfr0,ID_PFR0 ,RAS ) !=0 ; +return FIELD_EX32_IDREG (id,ID_PFR0 ,RAS ) !=0 ; }static inline bool isar_feature_aa32_mprofile (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_pfr1,ID_PFR1 ,MPROGMOD ) !=0 ; +return FIELD_EX32_IDREG (id,ID_PFR1 ,MPROGMOD ) !=0 ; }static inline bool isar_feature_aa32_m_sec_state (const ARMISARegisters *id)
@@ -150,7 +150,7 @@ static inline bool isar_feature_aa32_m_sec_state(const ARMISARegisters *id)* Return true if M-profile state handling insns * (VSCCLRM, CLRM, FPCTX access insns) are implemented */ -return FIELD_EX32 (id->id_pfr1,ID_PFR1 ,SECURITY ) >=3 ; +return FIELD_EX32_IDREG (id,ID_PFR1 ,SECURITY ) >=3 ; }static inline bool isar_feature_aa32_fp16_arith (const ARMISARegisters *id)
@@ -349,12 +349,12 @@ static inline bool isar_feature_aa32_evt(const ARMISARegisters *id)static inline bool isar_feature_aa32_dit (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_pfr0,ID_PFR0 ,DIT ) !=0 ; +return FIELD_EX32_IDREG (id,ID_PFR0 ,DIT ) !=0 ; }static inline bool isar_feature_aa32_ssbs (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_pfr2,ID_PFR2 ,SSBS ) !=0 ; +return FIELD_EX32_IDREG (id,ID_PFR2 ,SSBS ) !=0 ; }static inline bool isar_feature_aa32_debugv7p1 (const ARMISARegisters *id)
target/arm/cpu.c +3 -5
@@ -2322,7 +2322,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)* Disable the security extension feature bits in the processor * feature registers as well. */ - cpu->isar.id_pfr1 =FIELD_DP32 (cpu->isar.id_pfr1,ID_PFR1 ,SECURITY ,0 ); +FIELD_DP32_IDREG (isar,ID_PFR1 ,SECURITY ,0 ); cpu->isar.id_dfr0 =FIELD_DP32 (cpu->isar.id_dfr0,ID_DFR0 ,COPSDBG ,0 );FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,EL3 ,0 );
@@ -2362,8 +2362,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)* registers if we don't have EL2. */ FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,EL2 ,0 ); - cpu->isar.id_pfr1 =FIELD_DP32 (cpu->isar.id_pfr1, -ID_PFR1 ,VIRTUALIZATION ,0 ); +FIELD_DP32_IDREG (isar,ID_PFR1 ,VIRTUALIZATION ,0 ); }if (cpu_isar_feature (aa64_mte, cpu)) {
@@ -2426,8 +2425,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)FIELD_DP32 (cpu->isar.id_dfr0,ID_DFR0 ,MMAPTRC ,0 );/* FEAT_AMU (Activity Monitors Extension) */ FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,AMU ,0 ); - cpu->isar.id_pfr0 = -FIELD_DP32 (cpu->isar.id_pfr0,ID_PFR0 ,AMU ,0 ); +FIELD_DP32_IDREG (isar,ID_PFR0 ,AMU ,0 );/* FEAT_MPAM (Memory Partitioning and Monitoring Extension) */ FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,MPAM ,0 ); }
target/arm/cpu.h +0 -3
@@ -1079,9 +1079,6 @@ struct ArchCPU {uint32_t id_mmfr3;uint32_t id_mmfr4;uint32_t id_mmfr5; -uint32_t id_pfr0; -uint32_t id_pfr1; -uint32_t id_pfr2;uint32_t mvfr0;uint32_t mvfr1;uint32_t mvfr2;
target/arm/cpu64.c +4 -4
@@ -630,8 +630,8 @@ static void aarch64_a57_initfn(Object *obj) cpu->isar.mvfr2 =0x00000043 ; cpu->ctr =0x8444c004 ; cpu->reset_sctlr =0x00c50838 ; - cpu->isar.id_pfr0 =0x00000131 ; - cpu->isar.id_pfr1 =0x00011011 ; +SET_IDREG (isar,ID_PFR0 ,0x00000131 ); +SET_IDREG (isar,ID_PFR1 ,0x00011011 ); cpu->isar.id_dfr0 =0x03010066 ; cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x10101105 ;
@@ -692,8 +692,8 @@ static void aarch64_a53_initfn(Object *obj) cpu->isar.mvfr2 =0x00000043 ; cpu->ctr =0x84448004 ;/* L1Ip = VIPT */ cpu->reset_sctlr =0x00c50838 ; - cpu->isar.id_pfr0 =0x00000131 ; - cpu->isar.id_pfr1 =0x00011011 ; +SET_IDREG (isar,ID_PFR0 ,0x00000131 ); +SET_IDREG (isar,ID_PFR1 ,0x00011011 ); cpu->isar.id_dfr0 =0x03010066 ; cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x10101105 ;
target/arm/helper.c +4 -4
@@ -6708,7 +6708,7 @@ static void define_pmu_regs(ARMCPU *cpu)static uint64_t id_pfr1_read (CPUARMState *env,const ARMCPRegInfo *ri) {ARMCPU *cpu =env_archcpu (env); -uint64_t pfr1 = cpu->isar.id_pfr1; +uint64_t pfr1 =GET_IDREG (&cpu->isar,ID_PFR1 );if (env->gicv3state) { pfr1 |=1 <<28 ;
@@ -7554,7 +7554,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_pfr0 }, + .resetvalue = GET_IDREG(isar, ID_PFR0)},/* * ID_PFR1 is not a plain ARM_CP_CONST because we don't know * the value of the GIC field until after we define these regs.
@@ -7565,7 +7565,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .accessfn = access_aa32_tid3, #ifdef CONFIG_USER_ONLY .type =ARM_CP_CONST , - .resetvalue = cpu->isar.id_pfr1, + .resetvalue = GET_IDREG(isar, ID_PFR1), #else .type =ARM_CP_NO_RAW , .accessfn = access_aa32_tid3,
@@ -7907,7 +7907,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_pfr2 }, + .resetvalue = GET_IDREG(isar, ID_PFR2)}, { .name = "ID_DFR1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST,
target/arm/kvm.c +1 -2
@@ -389,8 +389,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ARM64_SYS_REG(3, 0, 0, 3, 1)); err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.mvfr2,ARM64_SYS_REG (3 ,0 ,0 ,3 ,2 )); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_pfr2, -ARM64_SYS_REG (3 ,0 ,0 ,3 ,4 )); + err |=get_host_cpu_reg (fd, ahcf,ID_PFR2_EL1_IDX ); err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_dfr1,ARM64_SYS_REG (3 ,0 ,0 ,3 ,5 )); err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr5,
target/arm/tcg/cpu-v7m.c +60 -60
223 lines not on this page · raw message
target/arm/tcg/cpu32.c +26 -26
130 lines not on this page · raw message
target/arm/tcg/cpu64.c +22 -22
104 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH v2 11/14 arm/cpu: Store id_dfr0/1 into the idregs array
In reply to Cornelia HuckFrom: Eric Auger <[email protected]>
--- hw/intc/armv7m_nvic.c | 2 +- target/arm/cpu-features.h | 16 ++++++++-------- target/arm/cpu.c | 13 +++++-------- target/arm/cpu.h | 2 -- target/arm/cpu64.c | 4 ++-- target/arm/helper.c | 4 ++-- target/arm/kvm.c | 6 ++---- target/arm/tcg/cpu-v7m.c | 12 ++++++------ target/arm/tcg/cpu32.c | 30 ++++++++++++++---------------- target/arm/tcg/cpu64.c | 16 ++++++++-------- 10 files changed, 48 insertions(+), 57 deletions(-)
hw/intc/armv7m_nvic.c +1 -1
@@ -1274,7 +1274,7 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_dfr0; +return GET_IDREG (isar,ID_DFR0 );case 0xd4c :/* AFR0. */ if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset;
target/arm/cpu-features.h +8 -8
@@ -299,22 +299,22 @@ static inline bool isar_feature_aa32_ats1e1(const ARMISARegisters *id)static inline bool isar_feature_aa32_pmuv3p1 (const ARMISARegisters *id) {/* 0xf means "non-standard IMPDEF PMU" */ -return FIELD_EX32 (id->id_dfr0,ID_DFR0 ,PERFMON ) >=4 && -FIELD_EX32 (id->id_dfr0,ID_DFR0 ,PERFMON ) !=0xf ; +return FIELD_EX32_IDREG (id,ID_DFR0 ,PERFMON ) >=4 && +FIELD_EX32_IDREG (id,ID_DFR0 ,PERFMON ) !=0xf ; }static inline bool isar_feature_aa32_pmuv3p4 (const ARMISARegisters *id) {/* 0xf means "non-standard IMPDEF PMU" */ -return FIELD_EX32 (id->id_dfr0,ID_DFR0 ,PERFMON ) >=5 && -FIELD_EX32 (id->id_dfr0,ID_DFR0 ,PERFMON ) !=0xf ; +return FIELD_EX32_IDREG (id,ID_DFR0 ,PERFMON ) >=5 && +FIELD_EX32_IDREG (id,ID_DFR0 ,PERFMON ) !=0xf ; }static inline bool isar_feature_aa32_pmuv3p5 (const ARMISARegisters *id) {/* 0xf means "non-standard IMPDEF PMU" */ -return FIELD_EX32 (id->id_dfr0,ID_DFR0 ,PERFMON ) >=6 && -FIELD_EX32 (id->id_dfr0,ID_DFR0 ,PERFMON ) !=0xf ; +return FIELD_EX32_IDREG (id,ID_DFR0 ,PERFMON ) >=6 && +FIELD_EX32_IDREG (id,ID_DFR0 ,PERFMON ) !=0xf ; }static inline bool isar_feature_aa32_hpd (const ARMISARegisters *id)
@@ -359,12 +359,12 @@ static inline bool isar_feature_aa32_ssbs(const ARMISARegisters *id)static inline bool isar_feature_aa32_debugv7p1 (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_dfr0,ID_DFR0 ,COPDBG ) >=5 ; +return FIELD_EX32_IDREG (id,ID_DFR0 ,COPDBG ) >=5 ; }static inline bool isar_feature_aa32_debugv8p2 (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_dfr0,ID_DFR0 ,COPDBG ) >=8 ; +return FIELD_EX32_IDREG (id,ID_DFR0 ,COPDBG ) >=8 ; }static inline bool isar_feature_aa32_doublelock (const ARMISARegisters *id)
target/arm/cpu.c +5 -8
@@ -2323,7 +2323,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)* feature registers as well. */ FIELD_DP32_IDREG (isar,ID_PFR1 ,SECURITY ,0 ); - cpu->isar.id_dfr0 =FIELD_DP32 (cpu->isar.id_dfr0,ID_DFR0 ,COPSDBG ,0 ); +FIELD_DP32_IDREG (isar,ID_DFR0 ,COPSDBG ,0 );FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,EL3 ,0 );/* Disable the realm management extension, which requires EL3. */
@@ -2351,7 +2351,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)#endif }else {FIELD_DP64_IDREG (isar,ID_AA64DFR0 ,PMUVER ,0 ); - cpu->isar.id_dfr0 =FIELD_DP32 (cpu->isar.id_dfr0,ID_DFR0 ,PERFMON ,0 ); +FIELD_DP32_IDREG (isar,ID_DFR0 ,PERFMON ,0 ); cpu->pmceid0 =0 ; cpu->pmceid1 =0 ; }
@@ -2414,15 +2414,12 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)FIELD_DP64_IDREG (isar,ID_AA64DFR0 ,TRACEBUFFER ,0 );/* FEAT_TRF (Self-hosted Trace Extension) */ FIELD_DP64_IDREG (isar,ID_AA64DFR0 ,TRACEFILT ,0 ); - cpu->isar.id_dfr0 = -FIELD_DP32 (cpu->isar.id_dfr0,ID_DFR0 ,TRACEFILT ,0 ); +FIELD_DP32_IDREG (isar,ID_DFR0 ,TRACEFILT ,0 );/* Trace Macrocell system register access */ FIELD_DP64_IDREG (isar,ID_AA64DFR0 ,TRACEVER ,0 ); - cpu->isar.id_dfr0 = -FIELD_DP32 (cpu->isar.id_dfr0,ID_DFR0 ,COPTRC ,0 ); +FIELD_DP32_IDREG (isar,ID_DFR0 ,COPTRC ,0 );/* Memory mapped trace */ - cpu->isar.id_dfr0 = -FIELD_DP32 (cpu->isar.id_dfr0,ID_DFR0 ,MMAPTRC ,0 ); +FIELD_DP32_IDREG (isar,ID_DFR0 ,MMAPTRC ,0 );/* FEAT_AMU (Activity Monitors Extension) */ FIELD_DP64_IDREG (isar,ID_AA64PFR0 ,AMU ,0 );FIELD_DP32_IDREG (isar,ID_PFR0 ,AMU ,0 );
target/arm/cpu.h +0 -2
@@ -1082,8 +1082,6 @@ struct ArchCPU {uint32_t mvfr0;uint32_t mvfr1;uint32_t mvfr2; -uint32_t id_dfr0; -uint32_t id_dfr1;uint32_t dbgdidr;uint32_t dbgdevid;uint32_t dbgdevid1;
target/arm/cpu64.c +2 -2
@@ -632,7 +632,7 @@ static void aarch64_a57_initfn(Object *obj) cpu->reset_sctlr =0x00c50838 ;SET_IDREG (isar,ID_PFR0 ,0x00000131 );SET_IDREG (isar,ID_PFR1 ,0x00011011 ); - cpu->isar.id_dfr0 =0x03010066 ; +SET_IDREG (isar,ID_DFR0 ,0x03010066 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x10101105 ; cpu->isar.id_mmfr1 =0x40000000 ;
@@ -694,7 +694,7 @@ static void aarch64_a53_initfn(Object *obj) cpu->reset_sctlr =0x00c50838 ;SET_IDREG (isar,ID_PFR0 ,0x00000131 );SET_IDREG (isar,ID_PFR1 ,0x00011011 ); - cpu->isar.id_dfr0 =0x03010066 ; +SET_IDREG (isar,ID_DFR0 ,0x03010066 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x10101105 ; cpu->isar.id_mmfr1 =0x40000000 ;
target/arm/helper.c +2 -2
@@ -7577,7 +7577,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_dfr0 }, + .resetvalue = GET_IDREG(isar, ID_DFR0)}, { .name = "ID_AFR0", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST,
@@ -7912,7 +7912,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_dfr1 }, + .resetvalue = GET_IDREG(isar, ID_DFR1)}, { .name = "ID_MMFR5", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST,
target/arm/kvm.c +2 -4
@@ -363,8 +363,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)*/ err |=get_host_cpu_reg (fd, ahcf,ID_AA64PFR0_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_AA64PFR1_EL1_IDX ); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_dfr0, -ARM64_SYS_REG (3 ,0 ,0 ,1 ,2 )); + err |=get_host_cpu_reg (fd, ahcf,ID_DFR0_EL1_IDX ); err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_mmfr0,ARM64_SYS_REG (3 ,0 ,0 ,1 ,4 )); err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr1,
@@ -390,8 +389,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.mvfr2,ARM64_SYS_REG (3 ,0 ,0 ,3 ,2 )); err |=get_host_cpu_reg (fd, ahcf,ID_PFR2_EL1_IDX ); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_dfr1, -ARM64_SYS_REG (3 ,0 ,0 ,3 ,5 )); + err |=get_host_cpu_reg (fd, ahcf,ID_DFR1_EL1_IDX ); err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_mmfr5,ARM64_SYS_REG (3 ,0 ,0 ,3 ,6 ));
target/arm/tcg/cpu-v7m.c +6 -6
@@ -62,7 +62,7 @@ static void cortex_m0_initfn(Object *obj)*/ SET_IDREG (isar,ID_PFR0 ,0x00000030 );SET_IDREG (isar,ID_PFR1 ,0x00000200 ); - cpu->isar.id_dfr0 =0x00100000 ; +SET_IDREG (isar,ID_DFR0 ,0x00100000 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x00000030 ; cpu->isar.id_mmfr1 =0x00000000 ;
@@ -88,7 +88,7 @@ static void cortex_m3_initfn(Object *obj) cpu->pmsav7_dregion =8 ;SET_IDREG (isar,ID_PFR0 ,0x00000030 );SET_IDREG (isar,ID_PFR1 ,0x00000200 ); - cpu->isar.id_dfr0 =0x00100000 ; +SET_IDREG (isar,ID_DFR0 ,0x00100000 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x00000030 ; cpu->isar.id_mmfr1 =0x00000000 ;
@@ -119,7 +119,7 @@ static void cortex_m4_initfn(Object *obj) cpu->isar.mvfr2 =0x00000000 ;SET_IDREG (isar,ID_PFR0 ,0x00000030 );SET_IDREG (isar,ID_PFR1 ,0x00000200 ); - cpu->isar.id_dfr0 =0x00100000 ; +SET_IDREG (isar,ID_DFR0 ,0x00100000 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x00000030 ; cpu->isar.id_mmfr1 =0x00000000 ;
@@ -150,7 +150,7 @@ static void cortex_m7_initfn(Object *obj) cpu->isar.mvfr2 =0x00000040 ;SET_IDREG (isar,ID_PFR0 ,0x00000030 );SET_IDREG (isar,ID_PFR1 ,0x00000200 ); - cpu->isar.id_dfr0 =0x00100000 ; +SET_IDREG (isar,ID_DFR0 ,0x00100000 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x00100030 ; cpu->isar.id_mmfr1 =0x00000000 ;
@@ -183,7 +183,7 @@ static void cortex_m33_initfn(Object *obj) cpu->isar.mvfr2 =0x00000040 ;SET_IDREG (isar,ID_PFR0 ,0x00000030 );SET_IDREG (isar,ID_PFR1 ,0x00000210 ); - cpu->isar.id_dfr0 =0x00200000 ; +SET_IDREG (isar,ID_DFR0 ,0x00200000 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x00101F40 ; cpu->isar.id_mmfr1 =0x00000000 ;
@@ -221,7 +221,7 @@ static void cortex_m55_initfn(Object *obj) cpu->isar.mvfr2 =0x00000040 ;SET_IDREG (isar,ID_PFR0 ,0x20000030 );SET_IDREG (isar,ID_PFR1 ,0x00000230 ); - cpu->isar.id_dfr0 =0x10200000 ; +SET_IDREG (isar,ID_DFR0 ,0x10200000 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x00111040 ; cpu->isar.id_mmfr1 =0x00000000 ;
target/arm/tcg/cpu32.c +14 -16
@@ -82,11 +82,11 @@ void aa32_max_features(ARMCPU *cpu) t =FIELD_DP32 (t,ID_PFR2 ,SSBS ,1 );/* FEAT_SSBS */ SET_IDREG (isar,ID_PFR2 , t); - t = cpu->isar.id_dfr0; + t =GET_IDREG (isar,ID_DFR0 ); t =FIELD_DP32 (t,ID_DFR0 ,COPDBG ,10 );/* FEAT_Debugv8p8 */ t =FIELD_DP32 (t,ID_DFR0 ,COPSDBG ,10 );/* FEAT_Debugv8p8 */ t =FIELD_DP32 (t,ID_DFR0 ,PERFMON ,6 );/* FEAT_PMUv3p5 */ - cpu->isar.id_dfr0 = t; +SET_IDREG (isar,ID_DFR0 , t);/* Debug ID registers. */
@@ -116,9 +116,7 @@ void aa32_max_features(ARMCPU *cpu) t =FIELD_DP32 (t,DBGDEVID1 ,PCSROFFSET ,2 ); cpu->isar.dbgdevid1 = t; - t = cpu->isar.id_dfr1; - t =FIELD_DP32 (t,ID_DFR1 ,HPMN0 ,1 );/* FEAT_HPMN0 */ - cpu->isar.id_dfr1 = t; +FIELD_DP32_IDREG (isar,ID_DFR1 ,HPMN0 ,1 );/* FEAT_HPMN0 */ }/* CPU models. These are not needed for the AArch64 linux-user build. */
@@ -230,7 +228,7 @@ static void arm1136_r2_initfn(Object *obj) cpu->reset_sctlr =0x00050078 ;SET_IDREG (isar,ID_PFR0 ,0x111 );SET_IDREG (isar,ID_PFR1 ,0x1 ); - cpu->isar.id_dfr0 =0x2 ; +SET_IDREG (isar,ID_DFR0 ,0x2 ); cpu->id_afr0 =0x3 ; cpu->isar.id_mmfr0 =0x01130003 ; cpu->isar.id_mmfr1 =0x10030302 ;
@@ -262,7 +260,7 @@ static void arm1136_initfn(Object *obj) cpu->reset_sctlr =0x00050078 ;SET_IDREG (isar,ID_PFR0 ,0x111 );SET_IDREG (isar,ID_PFR1 ,0x1 ); - cpu->isar.id_dfr0 =0x2 ; +SET_IDREG (isar,ID_DFR0 ,0x2 ); cpu->id_afr0 =0x3 ; cpu->isar.id_mmfr0 =0x01130003 ; cpu->isar.id_mmfr1 =0x10030302 ;
@@ -295,7 +293,7 @@ static void arm1176_initfn(Object *obj) cpu->reset_sctlr =0x00050078 ;SET_IDREG (isar,ID_PFR0 ,0x111 );SET_IDREG (isar,ID_PFR1 ,0x11 ); - cpu->isar.id_dfr0 =0x33 ; +SET_IDREG (isar,ID_DFR0 ,0x33 ); cpu->id_afr0 =0 ; cpu->isar.id_mmfr0 =0x01130003 ; cpu->isar.id_mmfr1 =0x10030302 ;
@@ -325,7 +323,7 @@ static void arm11mpcore_initfn(Object *obj) cpu->ctr =0x1d192992 ;/* 32K icache 32K dcache */ SET_IDREG (isar,ID_PFR0 ,0x111 );SET_IDREG (isar,ID_PFR1 ,0x1 ); - cpu->isar.id_dfr0 =0 ; +SET_IDREG (isar,ID_DFR0 ,0 ); cpu->id_afr0 =0x2 ; cpu->isar.id_mmfr0 =0x01100103 ; cpu->isar.id_mmfr1 =0x10020302 ;
@@ -365,7 +363,7 @@ static void cortex_a8_initfn(Object *obj) cpu->reset_sctlr =0x00c50078 ;SET_IDREG (isar,ID_PFR0 ,0x1031 );SET_IDREG (isar,ID_PFR1 ,0x11 ); - cpu->isar.id_dfr0 =0x400 ; +SET_IDREG (isar,ID_DFR0 ,0x400 ); cpu->id_afr0 =0 ; cpu->isar.id_mmfr0 =0x31100003 ; cpu->isar.id_mmfr1 =0x20000000 ;
@@ -441,7 +439,7 @@ static void cortex_a9_initfn(Object *obj) cpu->reset_sctlr =0x00c50078 ;SET_IDREG (isar,ID_PFR0 ,0x1031 );SET_IDREG (isar,ID_PFR1 ,0x11 ); - cpu->isar.id_dfr0 =0x000 ; +SET_IDREG (isar,ID_DFR0 ,0x000 ); cpu->id_afr0 =0 ; cpu->isar.id_mmfr0 =0x00100103 ; cpu->isar.id_mmfr1 =0x20000000 ;
@@ -507,7 +505,7 @@ static void cortex_a7_initfn(Object *obj) cpu->reset_sctlr =0x00c50078 ;SET_IDREG (isar,ID_PFR0 ,0x00001131 );SET_IDREG (isar,ID_PFR1 ,0x00011011 ); - cpu->isar.id_dfr0 =0x02010555 ; +SET_IDREG (isar,ID_DFR0 ,0x02010555 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x10101105 ; cpu->isar.id_mmfr1 =0x40000000 ;
@@ -559,7 +557,7 @@ static void cortex_a15_initfn(Object *obj) cpu->reset_sctlr =0x00c50078 ;SET_IDREG (isar,ID_PFR0 ,0x00001131 );SET_IDREG (isar,ID_PFR1 ,0x00011011 ); - cpu->isar.id_dfr0 =0x02010555 ; +SET_IDREG (isar,ID_DFR0 ,0x02010555 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x10201105 ; cpu->isar.id_mmfr1 =0x20000000 ;
@@ -603,7 +601,7 @@ static void cortex_r5_initfn(Object *obj) cpu->midr =0x411fc153 ;/* r1p3 */ SET_IDREG (isar,ID_PFR0 ,0x0131 );SET_IDREG (isar,ID_PFR1 ,0x001 ); - cpu->isar.id_dfr0 =0x010400 ; +SET_IDREG (isar,ID_DFR0 ,0x010400 ); cpu->id_afr0 =0x0 ; cpu->isar.id_mmfr0 =0x0210030 ; cpu->isar.id_mmfr1 =0x00000000 ;
@@ -750,7 +748,7 @@ static void cortex_r52_initfn(Object *obj) cpu->reset_sctlr =0x30c50838 ;SET_IDREG (isar,ID_PFR0 ,0x00000131 );SET_IDREG (isar,ID_PFR1 ,0x10111001 ); - cpu->isar.id_dfr0 =0x03010006 ; +SET_IDREG (isar,ID_DFR0 ,0x03010006 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x00211040 ; cpu->isar.id_mmfr1 =0x40000000 ;
@@ -982,7 +980,7 @@ static void arm_max_initfn(Object *obj) cpu->reset_sctlr =0x00c50838 ;SET_IDREG (isar,ID_PFR0 ,0x00000131 );SET_IDREG (isar,ID_PFR1 ,0x00011011 ); - cpu->isar.id_dfr0 =0x03010066 ; +SET_IDREG (isar,ID_DFR0 ,0x03010066 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x10101105 ; cpu->isar.id_mmfr1 =0x40000000 ;
target/arm/tcg/cpu64.c +8 -8
@@ -51,7 +51,7 @@ static void aarch64_a35_initfn(Object *obj) cpu->ctr =0x84448004 ;SET_IDREG (isar,ID_PFR0 ,0x00000131 );SET_IDREG (isar,ID_PFR1 ,0x00011011 ); - cpu->isar.id_dfr0 =0x03010066 ; +SET_IDREG (isar,ID_DFR0 ,0x03010066 ); cpu->id_afr0 =0 ; cpu->isar.id_mmfr0 =0x10201105 ; cpu->isar.id_mmfr1 =0x40000000 ;
@@ -228,7 +228,7 @@ static void aarch64_a55_initfn(Object *obj)SET_IDREG (isar,ID_AA64PFR0 ,0x0000000010112222ull );SET_IDREG (isar,ID_AA64PFR1 ,0x0000000000000010ull ); cpu->id_afr0 =0x00000000 ; - cpu->isar.id_dfr0 =0x04010088 ; +SET_IDREG (isar,ID_DFR0 ,0x04010088 );SET_IDREG (isar,ID_ISAR0 ,0x02101110 );SET_IDREG (isar,ID_ISAR1 ,0x13112111 );SET_IDREG (isar,ID_ISAR2 ,0x21232042 );
@@ -297,7 +297,7 @@ static void aarch64_a72_initfn(Object *obj) cpu->reset_sctlr =0x00c50838 ;SET_IDREG (isar,ID_PFR0 ,0x00000131 );SET_IDREG (isar,ID_PFR1 ,0x00011011 ); - cpu->isar.id_dfr0 =0x03010066 ; +SET_IDREG (isar,ID_DFR0 ,0x03010066 ); cpu->id_afr0 =0x00000000 ; cpu->isar.id_mmfr0 =0x10201105 ; cpu->isar.id_mmfr1 =0x40000000 ;
@@ -361,7 +361,7 @@ static void aarch64_a76_initfn(Object *obj)SET_IDREG (isar,ID_AA64PFR0 ,0x1100000010111112ull );/* GIC filled in later */ SET_IDREG (isar,ID_AA64PFR1 ,0x0000000000000010ull ); cpu->id_afr0 =0x00000000 ; - cpu->isar.id_dfr0 =0x04010088 ; +SET_IDREG (isar,ID_DFR0 ,0x04010088 );SET_IDREG (isar,ID_ISAR0 ,0x02101110 );SET_IDREG (isar,ID_ISAR1 ,0x13112111 );SET_IDREG (isar,ID_ISAR2 ,0x21232042 );
@@ -609,7 +609,7 @@ static void aarch64_neoverse_n1_initfn(Object *obj)SET_IDREG (isar,ID_AA64PFR0 ,0x1100000010111112ull );/* GIC filled in later */ SET_IDREG (isar,ID_AA64PFR1 ,0x0000000000000020ull ); cpu->id_afr0 =0x00000000 ; - cpu->isar.id_dfr0 =0x04010088 ; +SET_IDREG (isar,ID_DFR0 ,0x04010088 );SET_IDREG (isar,ID_ISAR0 ,0x02101110 );SET_IDREG (isar,ID_ISAR1 ,0x13112111 );SET_IDREG (isar,ID_ISAR2 ,0x21232042 );
@@ -688,7 +688,7 @@ static void aarch64_neoverse_v1_initfn(Object *obj)SET_IDREG (isar,ID_AA64PFR0 ,0x1101110120111112ull );/* GIC filled in later */ SET_IDREG (isar,ID_AA64PFR1 ,0x0000000000000020ull ); cpu->id_afr0 =0x00000000 ; - cpu->isar.id_dfr0 =0x15011099 ; +SET_IDREG (isar,ID_DFR0 ,0x15011099 );SET_IDREG (isar,ID_ISAR0 ,0x02101110 );SET_IDREG (isar,ID_ISAR1 ,0x13112111 );SET_IDREG (isar,ID_ISAR2 ,0x21232042 );
@@ -904,7 +904,7 @@ static void aarch64_a710_initfn(Object *obj) cpu->revidr =0 ;SET_IDREG (isar,ID_PFR0 ,0x21110131 );SET_IDREG (isar,ID_PFR1 ,0x00010000 );/* GIC filled in later */ - cpu->isar.id_dfr0 =0x16011099 ; +SET_IDREG (isar,ID_DFR0 ,0x16011099 ); cpu->id_afr0 =0 ; cpu->isar.id_mmfr0 =0x10201105 ; cpu->isar.id_mmfr1 =0x40000000 ;
@@ -1007,7 +1007,7 @@ static void aarch64_neoverse_n2_initfn(Object *obj) cpu->revidr =0 ;SET_IDREG (isar,ID_PFR0 ,0x21110131 );SET_IDREG (isar,ID_PFR1 ,0x00010000 );/* GIC filled in later */ - cpu->isar.id_dfr0 =0x16011099 ; +SET_IDREG (isar,ID_DFR0 ,0x16011099 ); cpu->id_afr0 =0 ; cpu->isar.id_mmfr0 =0x10201105 ; cpu->isar.id_mmfr1 =0x40000000 ;
Signature · 1 line
2.48.1
PATCH v2 12/14 arm/cpu: Store id_mmfr0-5 into the idregs array
In reply to Cornelia HuckFrom: Eric Auger <[email protected]>
--- hw/intc/armv7m_nvic.c | 8 ++-- target/arm/cpu-features.h | 18 ++++---- target/arm/cpu.h | 6 --- target/arm/cpu64.c | 16 +++---- target/arm/helper.c | 12 ++--- target/arm/kvm.c | 18 +++----- target/arm/tcg/cpu-v7m.c | 48 ++++++++++---------- target/arm/tcg/cpu32.c | 94 +++++++++++++++++++-------------------- target/arm/tcg/cpu64.c | 76 +++++++++++++++---------------- 9 files changed, 140 insertions(+), 156 deletions(-)
hw/intc/armv7m_nvic.c +4 -4
@@ -1284,22 +1284,22 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_mmfr0; +return GET_IDREG (isar,ID_MMFR0 );case 0xd54 :/* MMFR1. */ if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_mmfr1; +return GET_IDREG (isar,ID_MMFR1 );case 0xd58 :/* MMFR2. */ if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_mmfr2; +return GET_IDREG (isar,ID_MMFR2 );case 0xd5c :/* MMFR3. */ if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset; } -return cpu->isar.id_mmfr3; +return GET_IDREG (isar,ID_MMFR3 );case 0xd60 :/* ISAR0. */ if (!arm_feature (&cpu->env,ARM_FEATURE_M_MAIN )) { goto bad_offset;
target/arm/cpu-features.h +9 -9
@@ -283,17 +283,17 @@ static inline bool isar_feature_aa32_vminmaxnm(const ARMISARegisters *id)static inline bool isar_feature_aa32_pxn (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_mmfr0,ID_MMFR0 ,VMSA ) >=4 ; +return FIELD_EX32_IDREG (id,ID_MMFR0 ,VMSA ) >=4 ; }static inline bool isar_feature_aa32_pan (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_mmfr3,ID_MMFR3 ,PAN ) !=0 ; +return FIELD_EX32_IDREG (id,ID_MMFR3 ,PAN ) !=0 ; }static inline bool isar_feature_aa32_ats1e1 (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_mmfr3,ID_MMFR3 ,PAN ) >=2 ; +return FIELD_EX32_IDREG (id,ID_MMFR3 ,PAN ) >=2 ; }static inline bool isar_feature_aa32_pmuv3p1 (const ARMISARegisters *id)
@@ -319,32 +319,32 @@ static inline bool isar_feature_aa32_pmuv3p5(const ARMISARegisters *id)static inline bool isar_feature_aa32_hpd (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_mmfr4,ID_MMFR4 ,HPDS ) !=0 ; +return FIELD_EX32_IDREG (id,ID_MMFR4 ,HPDS ) !=0 ; }static inline bool isar_feature_aa32_ac2 (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_mmfr4,ID_MMFR4 ,AC2 ) !=0 ; +return FIELD_EX32_IDREG (id,ID_MMFR4 ,AC2 ) !=0 ; }static inline bool isar_feature_aa32_ccidx (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_mmfr4,ID_MMFR4 ,CCIDX ) !=0 ; +return FIELD_EX32_IDREG (id,ID_MMFR4 ,CCIDX ) !=0 ; }static inline bool isar_feature_aa32_tts2uxn (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_mmfr4,ID_MMFR4 ,XNX ) !=0 ; +return FIELD_EX32_IDREG (id,ID_MMFR4 ,XNX ) !=0 ; }static inline bool isar_feature_aa32_half_evt (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_mmfr4,ID_MMFR4 ,EVT ) >=1 ; +return FIELD_EX32_IDREG (id,ID_MMFR4 ,EVT ) >=1 ; }static inline bool isar_feature_aa32_evt (const ARMISARegisters *id) { -return FIELD_EX32 (id->id_mmfr4,ID_MMFR4 ,EVT ) >=2 ; +return FIELD_EX32_IDREG (id,ID_MMFR4 ,EVT ) >=2 ; }static inline bool isar_feature_aa32_dit (const ARMISARegisters *id)
target/arm/cpu.h +0 -6
@@ -1073,12 +1073,6 @@ struct ArchCPU {* field by reading the value from the KVM vCPU. */ struct ARMISARegisters { -uint32_t id_mmfr0; -uint32_t id_mmfr1; -uint32_t id_mmfr2; -uint32_t id_mmfr3; -uint32_t id_mmfr4; -uint32_t id_mmfr5;uint32_t mvfr0;uint32_t mvfr1;uint32_t mvfr2;
target/arm/cpu64.c +8 -8
@@ -634,10 +634,10 @@ static void aarch64_a57_initfn(Object *obj)SET_IDREG (isar,ID_PFR1 ,0x00011011 );SET_IDREG (isar,ID_DFR0 ,0x03010066 ); cpu->id_afr0 =0x00000000 ; - cpu->isar.id_mmfr0 =0x10101105 ; - cpu->isar.id_mmfr1 =0x40000000 ; - cpu->isar.id_mmfr2 =0x01260000 ; - cpu->isar.id_mmfr3 =0x02102211 ; +SET_IDREG (isar,ID_MMFR0 ,0x10101105 ); +SET_IDREG (isar,ID_MMFR1 ,0x40000000 ); +SET_IDREG (isar,ID_MMFR2 ,0x01260000 ); +SET_IDREG (isar,ID_MMFR3 ,0x02102211 );SET_IDREG (isar,ID_ISAR0 ,0x02101110 );SET_IDREG (isar,ID_ISAR1 ,0x13112111 );SET_IDREG (isar,ID_ISAR2 ,0x21232042 );
@@ -696,10 +696,10 @@ static void aarch64_a53_initfn(Object *obj)SET_IDREG (isar,ID_PFR1 ,0x00011011 );SET_IDREG (isar,ID_DFR0 ,0x03010066 ); cpu->id_afr0 =0x00000000 ; - cpu->isar.id_mmfr0 =0x10101105 ; - cpu->isar.id_mmfr1 =0x40000000 ; - cpu->isar.id_mmfr2 =0x01260000 ; - cpu->isar.id_mmfr3 =0x02102211 ; +SET_IDREG (isar,ID_MMFR0 ,0x10101105 ); +SET_IDREG (isar,ID_MMFR1 ,0x40000000 ); +SET_IDREG (isar,ID_MMFR2 ,0x01260000 ); +SET_IDREG (isar,ID_MMFR3 ,0x02102211 );SET_IDREG (isar,ID_ISAR0 ,0x02101110 );SET_IDREG (isar,ID_ISAR1 ,0x13112111 );SET_IDREG (isar,ID_ISAR2 ,0x21232042 );
target/arm/helper.c +6 -6
@@ -7587,22 +7587,22 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_mmfr0 }, + .resetvalue = GET_IDREG(isar, ID_MMFR0)}, { .name = "ID_MMFR1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_mmfr1 }, + .resetvalue = GET_IDREG(isar, ID_MMFR1)}, { .name = "ID_MMFR2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_mmfr2 }, + .resetvalue = GET_IDREG(isar, ID_MMFR2)}, { .name = "ID_MMFR3", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_mmfr3 }, + .resetvalue = GET_IDREG(isar, ID_MMFR3)}, { .name = "ID_ISAR0", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST,
@@ -7637,7 +7637,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa32_tid3, - .resetvalue = cpu->isar.id_mmfr4 }, + .resetvalue = GET_IDREG(isar, ID_MMFR4)}, { .name = "ID_ISAR6", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST,
@@ -7917,7 +7917,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = cpu->isar.id_mmfr5 }, + .resetvalue = GET_IDREG(isar, ID_MMFR5)}, { .name = "RES_0_C0_C3_7", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST,
target/arm/kvm.c +6 -12
@@ -364,14 +364,10 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) err |=get_host_cpu_reg (fd, ahcf,ID_AA64PFR0_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_AA64PFR1_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_DFR0_EL1_IDX ); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_mmfr0, -ARM64_SYS_REG (3 ,0 ,0 ,1 ,4 )); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_mmfr1, -ARM64_SYS_REG (3 ,0 ,0 ,1 ,5 )); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_mmfr2, -ARM64_SYS_REG (3 ,0 ,0 ,1 ,6 )); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_mmfr3, -ARM64_SYS_REG (3 ,0 ,0 ,1 ,7 )); + err |=get_host_cpu_reg (fd, ahcf,ID_MMFR0_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_MMFR1_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_MMFR2_EL1_IDX ); + err |=get_host_cpu_reg (fd, ahcf,ID_MMFR3_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_ISAR0_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_ISAR1_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_ISAR2_EL1_IDX );
@@ -379,8 +375,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) err |=get_host_cpu_reg (fd, ahcf,ID_ISAR4_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_ISAR5_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_ISAR6_EL1_IDX ); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_mmfr4, -ARM64_SYS_REG (3 ,0 ,0 ,2 ,6 )); + err |=get_host_cpu_reg (fd, ahcf,ID_MMFR4_EL1_IDX ); err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.mvfr0,ARM64_SYS_REG (3 ,0 ,0 ,3 ,0 ));
@@ -390,8 +385,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ARM64_SYS_REG(3, 0, 0, 3, 2)); err |=get_host_cpu_reg (fd, ahcf,ID_PFR2_EL1_IDX ); err |=get_host_cpu_reg (fd, ahcf,ID_DFR1_EL1_IDX ); - err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_mmfr5, -ARM64_SYS_REG (3 ,0 ,0 ,3 ,6 )); + err |=get_host_cpu_reg (fd, ahcf,ID_MMFR5_EL1_IDX );/* * DBGDIDR is a bit complicated because the kernel doesn't
target/arm/tcg/cpu-v7m.c +24 -24
84 lines not on this page · raw message
target/arm/tcg/cpu32.c +45 -49
173 lines not on this page · raw message
target/arm/tcg/cpu64.c +38 -38
136 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH v2 13/14 arm/cpu: Add sysreg generation scripts
In reply to Cornelia HuckFrom: Eric Auger <[email protected]>
Introduce scripts that automate the generation of system register definitions from a given linux source tree arch/arm64/tools/sysreg.
Invocation of
./update-aarch64-sysreg-code.sh $PATH_TO_LINUX_SOURCE_TREE in scripts directory generates target/arm/cpu-sysregs.h.inc containing defines for all system registers.
[CH: update to handle current kernel sysregs structure, and to emit
the re-worked register structures; cpu properties will be added later]
--- scripts/gen-cpu-sysregs-header.awk | 70 +++++++++++++++++++++++++++ scripts/update-aarch64-sysreg-code.sh | 35 ++++++++++++++ 2 files changed, 105 insertions(+) create mode 100755 scripts/gen-cpu-sysregs-header.awk create mode 100755 scripts/update-aarch64-sysreg-code.sh
scripts/gen-cpu-sysregs-header.awk new file +70 -0
@@ -0,0 +1,70 @@ +#!/bin/awk -f +# SPDX-License-Identifier: GPL-2.0 +# gen-cpu-sysregs-header.awk: arm64 sysreg header generator +# +# Usage: awk -f gen-cpu-sysregs-header.awk -- -v structure=xxx $LINUX_PATH/arch/arm64/tools/sysreg +# where structure is one of "idx" "reg" "table" + +BEGIN { + print "" + if (structure == "idx") { + print "typedef enum ARMIDRegisterIdx {" + } + if (structure == "reg") { + print "typedef enum ARMSysRegs {" + } + if (structure == "table") { + print "static const uint32_t id_register_sysreg[NUM_ID_IDX] = {" + } +} END { + if (structure == "idx") { + print " NUM_ID_IDX," + print "} ARMIDRegisterIdx;" + } + if (structure == "reg") { + print "} ARMSysRegs;" + } + if (structure == "table") { + print "};" + } + print "" +} + +# skip blank lines and comment lines +/^$/ { next } +/^[\t ]*#/ { next } + +/^Sysreg\t/ || /^Sysreg /{ + + reg = $2 + op0 = $3 + op1 = $4 + crn = $5 + crm = $6 + op2 = $7 + + if (op0 == 3 && (op1>=0 && op1<=3) && crn==0 && (crm>=0 && crm<=7) && (op2>=0 && op2<=7)) { + idreg = 1 + } else { + idreg = 0 + } + + if (idreg) { + if (structure == "idx") { + print " "reg"_IDX," + } + if (structure == "reg") { + print " SYS_"reg" = ENCODE_ID_REG("op0", "op1", "crn", "crm", "op2")," + } + if (structure == "table") { + print " ["reg"_IDX] = SYS_"reg"," + } + } + + next +} + +{ + /* skip all other lines */ + next +}
scripts/update-aarch64-sysreg-code.sh new file +35 -0
@@ -0,0 +1,35 @@ +#!/bin/sh -e +# +# Update target/arm/cpu-sysregs.h +# from a linux source tree (arch/arm64/tools/sysreg) +# +# Copyright Red Hat, Inc. 2024 +# +# Authors: +# Eric Auger <[email protected]> +# + +linux="$1" +output="$PWD" + +if [ -z "$linux" ] || ! [ -d "$linux" ]; then + cat << EOF +usage: update-aarch64-sysreg-code.sh LINUX_PATH + +LINUX_PATH Linux kernel directory to obtain the headers from +EOF + exit 1 +fi + + cat <<EOF >../target/arm/cpu-sysregs.h.inc +/* GENERATED FILE -- DO NOT EDIT */ +#ifndef ARCH_ARM_CPU_SYSREGS_H_INC +#define ARCH_ARM_CPU_SYSREGS_H_INC +EOF + +for structure in "idx" "reg" "table"; do + awk -f gen-cpu-sysregs-header.awk -v structure="$structure"\ + $linux/arch/arm64/tools/sysreg >> ../target/arm/cpu-sysregs.h.inc +done + +echo "#endif /* ARCH_ARM_CPU_SYSREGS_H_INC */" >> ../target/arm/cpu-sysregs.h.inc
Signature · 1 line
2.48.1
PATCH v2 14/14 arm/cpu: Add generated files
In reply to Cornelia HuckAnd switch to using the generated definitions.
Generated against Linux 6.14-rc1.
--- target/arm/cpu-sysregs.h | 116 +----------------------- target/arm/cpu-sysregs.h.inc | 167 +++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+), 114 deletions(-) create mode 100644 target/arm/cpu-sysregs.h.inc
target/arm/cpu-sysregs.h +2 -114
@@ -13,120 +13,8 @@ ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \ ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT)) -typedef enum ARMIDRegisterIdx { -ID_AA64PFR0_EL1_IDX , -ID_AA64PFR1_EL1_IDX , -ID_AA64SMFR0_EL1_IDX , -ID_AA64DFR0_EL1_IDX , -ID_AA64DFR1_EL1_IDX , -ID_AA64ISAR0_EL1_IDX , -ID_AA64ISAR1_EL1_IDX , -ID_AA64ISAR2_EL1_IDX , -ID_AA64MMFR0_EL1_IDX , -ID_AA64MMFR1_EL1_IDX , -ID_AA64MMFR2_EL1_IDX , -ID_AA64MMFR3_EL1_IDX , -ID_PFR0_EL1_IDX , -ID_PFR1_EL1_IDX , -ID_DFR0_EL1_IDX , -ID_MMFR0_EL1_IDX , -ID_MMFR1_EL1_IDX , -ID_MMFR2_EL1_IDX , -ID_MMFR3_EL1_IDX , -ID_ISAR0_EL1_IDX , -ID_ISAR1_EL1_IDX , -ID_ISAR2_EL1_IDX , -ID_ISAR3_EL1_IDX , -ID_ISAR4_EL1_IDX , -ID_ISAR5_EL1_IDX , -ID_MMFR4_EL1_IDX , -ID_ISAR6_EL1_IDX , -MVFR0_EL1_IDX , -MVFR1_EL1_IDX , -MVFR2_EL1_IDX , -ID_PFR2_EL1_IDX , -ID_DFR1_EL1_IDX , -ID_MMFR5_EL1_IDX , -ID_AA64ZFR0_EL1_IDX , -CTR_EL0_IDX , -NUM_ID_IDX , -}ARMIDRegisterIdx ; - -typedef enum ARMSysRegs { -SYS_ID_AA64PFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,0 ), -SYS_ID_AA64PFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,1 ), -SYS_ID_AA64SMFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,5 ), -SYS_ID_AA64DFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,5 ,0 ), -SYS_ID_AA64DFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,5 ,1 ), -SYS_ID_AA64ISAR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,6 ,0 ), -SYS_ID_AA64ISAR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,6 ,1 ), -SYS_ID_AA64ISAR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,6 ,2 ), -SYS_ID_AA64MMFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,0 ), -SYS_ID_AA64MMFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,1 ), -SYS_ID_AA64MMFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,2 ), -SYS_ID_AA64MMFR3_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,7 ,3 ), -SYS_ID_PFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,0 ), -SYS_ID_PFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,1 ), -SYS_ID_DFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,2 ), -SYS_ID_MMFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,4 ), -SYS_ID_MMFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,5 ), -SYS_ID_MMFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,6 ), -SYS_ID_MMFR3_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,1 ,7 ), -SYS_ID_ISAR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,0 ), -SYS_ID_ISAR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,1 ), -SYS_ID_ISAR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,2 ), -SYS_ID_ISAR3_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,3 ), -SYS_ID_ISAR4_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,4 ), -SYS_ID_ISAR5_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,5 ), -SYS_ID_MMFR4_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,6 ), -SYS_ID_ISAR6_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,2 ,7 ), -SYS_MVFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,0 ), -SYS_MVFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,1 ), -SYS_MVFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,2 ), -SYS_ID_PFR2_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,4 ), -SYS_ID_DFR1_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,5 ), -SYS_ID_MMFR5_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,3 ,6 ), -SYS_ID_AA64ZFR0_EL1 =ENCODE_ID_REG (3 ,0 ,0 ,4 ,4 ), -SYS_CTR_EL0 =ENCODE_ID_REG (3 ,3 ,0 ,0 ,1 ), -}ARMSysRegs ; - -static const uint32_t id_register_sysreg[NUM_ID_IDX ] = { - [ID_AA64PFR0_EL1_IDX ] =SYS_ID_AA64PFR0_EL1 , - [ID_AA64PFR1_EL1_IDX ] =SYS_ID_AA64PFR1_EL1 , - [ID_AA64SMFR0_EL1_IDX ] =SYS_ID_AA64SMFR0_EL1 , - [ID_AA64DFR0_EL1_IDX ] =SYS_ID_AA64DFR0_EL1 , - [ID_AA64DFR1_EL1_IDX ] =SYS_ID_AA64DFR1_EL1 , - [ID_AA64ISAR0_EL1_IDX ] =SYS_ID_AA64ISAR0_EL1 , - [ID_AA64ISAR1_EL1_IDX ] =SYS_ID_AA64ISAR1_EL1 , - [ID_AA64ISAR2_EL1_IDX ] =SYS_ID_AA64ISAR2_EL1 , - [ID_AA64MMFR0_EL1_IDX ] =SYS_ID_AA64MMFR0_EL1 , - [ID_AA64MMFR1_EL1_IDX ] =SYS_ID_AA64MMFR1_EL1 , - [ID_AA64MMFR2_EL1_IDX ] =SYS_ID_AA64MMFR2_EL1 , - [ID_AA64MMFR3_EL1_IDX ] =SYS_ID_AA64MMFR3_EL1 , - [ID_PFR0_EL1_IDX ] =SYS_ID_PFR0_EL1 , - [ID_PFR1_EL1_IDX ] =SYS_ID_PFR1_EL1 , - [ID_DFR0_EL1_IDX ] =SYS_ID_DFR0_EL1 , - [ID_MMFR0_EL1_IDX ] =SYS_ID_MMFR0_EL1 , - [ID_MMFR1_EL1_IDX ] =SYS_ID_MMFR1_EL1 , - [ID_MMFR2_EL1_IDX ] =SYS_ID_MMFR2_EL1 , - [ID_MMFR3_EL1_IDX ] =SYS_ID_MMFR3_EL1 , - [ID_ISAR0_EL1_IDX ] =SYS_ID_ISAR0_EL1 , - [ID_ISAR1_EL1_IDX ] =SYS_ID_ISAR1_EL1 , - [ID_ISAR2_EL1_IDX ] =SYS_ID_ISAR2_EL1 , - [ID_ISAR3_EL1_IDX ] =SYS_ID_ISAR3_EL1 , - [ID_ISAR4_EL1_IDX ] =SYS_ID_ISAR4_EL1 , - [ID_ISAR5_EL1_IDX ] =SYS_ID_ISAR5_EL1 , - [ID_MMFR4_EL1_IDX ] =SYS_ID_MMFR4_EL1 , - [ID_ISAR6_EL1_IDX ] =SYS_ID_ISAR6_EL1 , - [MVFR0_EL1_IDX ] =SYS_MVFR0_EL1 , - [MVFR1_EL1_IDX ] =SYS_MVFR1_EL1 , - [MVFR2_EL1_IDX ] =SYS_MVFR2_EL1 , - [ID_PFR2_EL1_IDX ] =SYS_ID_PFR2_EL1 , - [ID_DFR1_EL1_IDX ] =SYS_ID_DFR1_EL1 , - [ID_MMFR5_EL1_IDX ] =SYS_ID_MMFR5_EL1 , - [ID_AA64ZFR0_EL1_IDX ] =SYS_ID_AA64ZFR0_EL1 , - [CTR_EL0_IDX ] =SYS_CTR_EL0 , -}; +/* include generated definitions */ +#include "cpu-sysregs.h.inc" int get_sysreg_idx (ARMSysRegs sysreg);uint64_t idregs_sysreg_to_kvm_reg (ARMSysRegs sysreg);
target/arm/cpu-sysregs.h.inc new file +167 -0
167 lines not on this page · raw message
Signature · 1 line
2.48.1