diff mbox series

[3/6] KVM: arm64: Spin off helper for calling visibility hook

Message ID 20220817214818.3243383-4-oliver.upton@linux.dev (mailing list archive)
State New, archived
Headers show
Series KVM: arm64: Treat 32bit ID registers as RAZ/WI on 64bit-only system | expand

Commit Message

Oliver Upton Aug. 17, 2022, 9:48 p.m. UTC
No functional change intended.

Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
---
 arch/arm64/kvm/sys_regs.h | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

Comments

Reiji Watanabe Aug. 30, 2022, 6:01 a.m. UTC | #1
On Wed, Aug 17, 2022 at 2:48 PM Oliver Upton <oliver.upton@linux.dev> wrote:
>
> No functional change intended.
>
> Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
> ---
>  arch/arm64/kvm/sys_regs.h | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arm64/kvm/sys_regs.h b/arch/arm64/kvm/sys_regs.h
> index a8c4cc32eb9a..e78b51059622 100644
> --- a/arch/arm64/kvm/sys_regs.h
> +++ b/arch/arm64/kvm/sys_regs.h
> @@ -136,22 +136,25 @@ static inline void reset_val(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r
>         __vcpu_sys_reg(vcpu, r->reg) = r->val;
>  }
>
> -static inline bool sysreg_hidden(const struct kvm_vcpu *vcpu,
> -                                const struct sys_reg_desc *r)
> +static inline unsigned int sysreg_visibility(const struct kvm_vcpu *vcpu,
> +                                            const struct sys_reg_desc *r)
>  {
>         if (likely(!r->visibility))
> -               return false;
> +               return 0;
>
> -       return r->visibility(vcpu, r) & REG_HIDDEN;
> +       return r->visibility(vcpu, r);
> +}
> +
> +static inline bool sysreg_hidden(const struct kvm_vcpu *vcpu,
> +                                const struct sys_reg_desc *r)
> +{
> +       return sysreg_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;
> +       return sysreg_visibility(vcpu, r) & REG_RAZ;
>  }
>
>  static inline int cmp_sys_reg(const struct sys_reg_desc *i1,

Reviewed-by: Reiji Watanabe <reijiw@google.com>

Thank you,
Reiji
diff mbox series

Patch

diff --git a/arch/arm64/kvm/sys_regs.h b/arch/arm64/kvm/sys_regs.h
index a8c4cc32eb9a..e78b51059622 100644
--- a/arch/arm64/kvm/sys_regs.h
+++ b/arch/arm64/kvm/sys_regs.h
@@ -136,22 +136,25 @@  static inline void reset_val(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r
 	__vcpu_sys_reg(vcpu, r->reg) = r->val;
 }
 
-static inline bool sysreg_hidden(const struct kvm_vcpu *vcpu,
-				 const struct sys_reg_desc *r)
+static inline unsigned int sysreg_visibility(const struct kvm_vcpu *vcpu,
+					     const struct sys_reg_desc *r)
 {
 	if (likely(!r->visibility))
-		return false;
+		return 0;
 
-	return r->visibility(vcpu, r) & REG_HIDDEN;
+	return r->visibility(vcpu, r);
+}
+
+static inline bool sysreg_hidden(const struct kvm_vcpu *vcpu,
+				 const struct sys_reg_desc *r)
+{
+	return sysreg_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;
+	return sysreg_visibility(vcpu, r) & REG_RAZ;
 }
 
 static inline int cmp_sys_reg(const struct sys_reg_desc *i1,