aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/kvm/sys_regs.h
diff options
context:
space:
mode:
authorAndrew Jones <drjones@redhat.com>2020-11-05 10:10:21 +0100
committerMarc Zyngier <maz@kernel.org>2020-11-06 16:00:29 +0000
commit912dee572691ffb2b387dd8b4f183d549a6b24d1 (patch)
treeed4dd944ade856e5536271a1055d3771ccdba752 /arch/arm64/kvm/sys_regs.h
parentKVM: arm64: Consolidate REG_HIDDEN_GUEST/USER (diff)
downloadlinux-dev-912dee572691ffb2b387dd8b4f183d549a6b24d1.tar.xz
linux-dev-912dee572691ffb2b387dd8b4f183d549a6b24d1.zip
KVM: arm64: Check RAZ visibility in ID register accessors
The instruction encodings of ID registers are preallocated. Until an encoding is assigned a purpose the register is RAZ. KVM's general ID register accessor functions already support both paths, RAZ or not. If for each ID register we can determine if it's RAZ or not, then all ID registers can build on the general functions. The register visibility function allows us to check whether a register should be completely hidden or not, extending it to also report when the register should be RAZ or not allows us to use it for ID registers as well. Check for RAZ visibility in the ID register accessor functions, allowing the RAZ case to be handled in a generic way for all system registers. The new REG_RAZ flag will be used in a later patch. This patch has no intended functional change. Signed-off-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20201105091022.15373-4-drjones@redhat.com
Diffstat (limited to 'arch/arm64/kvm/sys_regs.h')
-rw-r--r--arch/arm64/kvm/sys_regs.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/arm64/kvm/sys_regs.h b/arch/arm64/kvm/sys_regs.h
index 2641b2ee6a91..0f95964339b1 100644
--- a/arch/arm64/kvm/sys_regs.h
+++ b/arch/arm64/kvm/sys_regs.h
@@ -60,6 +60,7 @@ struct sys_reg_desc {
};
#define REG_HIDDEN (1 << 0) /* hidden from userspace and guest */
+#define REG_RAZ (1 << 1) /* RAZ from userspace and guest */
static __printf(2, 3)
inline void print_sys_reg_msg(const struct sys_reg_params *p,
@@ -119,6 +120,15 @@ static inline bool sysreg_hidden(const struct kvm_vcpu *vcpu,
return r->visibility(vcpu, r) & REG_HIDDEN;
}
+static inline bool sysreg_visible_as_raz(const struct kvm_vcpu *vcpu,
+ const struct sys_reg_desc *r)
+{
+ if (likely(!r->visibility))
+ return false;
+
+ return r->visibility(vcpu, r) & REG_RAZ;
+}
+
static inline int cmp_sys_reg(const struct sys_reg_desc *i1,
const struct sys_reg_desc *i2)
{