summaryrefslogtreecommitdiffstats
path: root/target/arm/cpu.h
diff options
context:
space:
mode:
authorAlex Bennée2019-02-15 10:56:38 +0100
committerPeter Maydell2019-02-15 10:56:38 +0100
commit6c5c0fec29bbfe36c64eca1edfd8455be46b77c6 (patch)
treec4a444a50fe3ae3bd222b422c3bf9245ee07860d /target/arm/cpu.h
parenttarget/arm: relax permission checks for HWCAP_CPUID registers (diff)
downloadqemu-6c5c0fec29bbfe36c64eca1edfd8455be46b77c6.tar.gz
qemu-6c5c0fec29bbfe36c64eca1edfd8455be46b77c6.tar.xz
qemu-6c5c0fec29bbfe36c64eca1edfd8455be46b77c6.zip
target/arm: expose CPUID registers to userspace
A number of CPUID registers are exposed to userspace by modern Linux kernels thanks to the "ARM64 CPU Feature Registers" ABI. For QEMU's user-mode emulation we don't need to emulate the kernels trap but just return the value the trap would have done. To avoid too much #ifdef hackery we process ARMCPRegInfo with a new helper (modify_arm_cp_regs) before defining the registers. The modify routine is driven by a simple data structure which describes which bits are exported and which are fixed. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 20190205190224.2198-3-alex.bennee@linaro.org Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'target/arm/cpu.h')
-rw-r--r--target/arm/cpu.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index c92c097b44..7c31e5a2d1 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -2464,6 +2464,27 @@ static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs)
}
const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp);
+/*
+ * Definition of an ARM co-processor register as viewed from
+ * userspace. This is used for presenting sanitised versions of
+ * registers to userspace when emulating the Linux AArch64 CPU
+ * ID/feature ABI (advertised as HWCAP_CPUID).
+ */
+typedef struct ARMCPRegUserSpaceInfo {
+ /* Name of register */
+ const char *name;
+
+ /* Only some bits are exported to user space */
+ uint64_t exported_bits;
+
+ /* Fixed bits are applied after the mask */
+ uint64_t fixed_bits;
+} ARMCPRegUserSpaceInfo;
+
+#define REGUSERINFO_SENTINEL { .name = NULL }
+
+void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods);
+
/* CPWriteFn that can be used to implement writes-ignored behaviour */
void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value);