[PATCH v2 06/20] KVM: arm64: Prepare sys_regs.c for sharing with s390
Marc Zyngier
maz at kernel.org
Tue Sep 1 01:17:39 PDT 2026
On Mon, 31 Aug 2026 15:55:21 +0100,
Steffen Eiden <seiden at linux.ibm.com> wrote:
>
> Prepare sharing of sys_regs.c with s390 by moving functions to another
> location inside sys_regs.c. This reduces the number of shared regions.
>
> Signed-off-by: Steffen Eiden <seiden at linux.ibm.com>
> ---
> arch/arm64/kvm/sys_regs.c | 100 +++++++++++++++++++-------------------
> arch/s390/kvm/arm64/arm.c | 2 +
> 2 files changed, 52 insertions(+), 50 deletions(-)
>
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 7d0047b542f4..53d096803d9d 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -2043,13 +2043,6 @@ static inline bool is_vcpu_ftr_id_reg(u32 id)
> return is_feature_id_reg(id) && !is_vm_ftr_id_reg(id);
> }
>
> -static inline bool is_aa32_id_reg(u32 id)
> -{
> - return (sys_reg_Op0(id) == 3 && sys_reg_Op1(id) == 0 &&
> - sys_reg_CRn(id) == 0 && sys_reg_CRm(id) >= 1 &&
> - sys_reg_CRm(id) <= 3);
> -}
> -
> static unsigned int id_visibility(const struct kvm_vcpu *vcpu,
> const struct sys_reg_desc *r)
> {
> @@ -2065,20 +2058,6 @@ static unsigned int id_visibility(const struct kvm_vcpu *vcpu,
> return 0;
> }
>
> -static unsigned int aa32_id_visibility(const struct kvm_vcpu *vcpu,
> - const struct sys_reg_desc *r)
> -{
> - /*
> - * AArch32 ID registers are UNKNOWN if AArch32 isn't implemented at any
> - * EL. Promote to RAZ/WI in order to guarantee consistency between
> - * systems.
> - */
> - if (!kvm_supports_32bit_el0())
> - return REG_RAZ | REG_USER_WI;
> -
> - return id_visibility(vcpu, r);
> -}
> -
> static unsigned int raz_visibility(const struct kvm_vcpu *vcpu,
> const struct sys_reg_desc *r)
> {
> @@ -2099,6 +2078,27 @@ static bool access_id_reg(struct kvm_vcpu *vcpu,
> return true;
> }
>
> +static unsigned int aa32_id_visibility(const struct kvm_vcpu *vcpu,
> + const struct sys_reg_desc *r)
> +{
> + /*
> + * AArch32 ID registers are UNKNOWN if AArch32 isn't implemented at any
> + * EL. Promote to RAZ/WI in order to guarantee consistency between
> + * systems.
> + */
> + if (!kvm_supports_32bit_el0())
> + return REG_RAZ | REG_USER_WI;
> +
> + return id_visibility(vcpu, r);
> +}
> +
> +static inline bool is_aa32_id_reg(u32 id)
> +{
> + return (sys_reg_Op0(id) == 3 && sys_reg_Op1(id) == 0 &&
> + sys_reg_CRn(id) == 0 && sys_reg_CRm(id) >= 1 &&
> + sys_reg_CRm(id) <= 3);
> +}
> +
> /* Visibility overrides for SVE-specific control registers */
> static unsigned int sve_visibility(const struct kvm_vcpu *vcpu,
> const struct sys_reg_desc *rd)
> @@ -2553,29 +2553,6 @@ void kvm_set_vm_id_reg(struct kvm *kvm, u32 reg, u64 val)
> *p = val;
> }
>
> -static int get_raz_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> - u64 *val)
> -{
> - *val = 0;
> - return 0;
> -}
> -
> -static int set_wi_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> - u64 val)
> -{
> - return 0;
> -}
> -
> -static bool access_ctr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
> - const struct sys_reg_desc *r)
> -{
> - if (p->is_write)
> - return write_to_read_only(vcpu, p, r);
> -
> - p->regval = kvm_read_vm_id_reg(vcpu->kvm, SYS_CTR_EL0);
> - return true;
> -}
> -
> static bool access_clidr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
> const struct sys_reg_desc *r)
> {
> @@ -2684,6 +2661,29 @@ static bool access_ccsidr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
> return true;
> }
>
> +static int get_raz_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> + u64 *val)
> +{
> + *val = 0;
> + return 0;
> +}
> +
> +static int set_wi_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> + u64 val)
> +{
> + return 0;
> +}
> +
> +static bool access_ctr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
> + const struct sys_reg_desc *r)
> +{
> + if (p->is_write)
> + return write_to_read_only(vcpu, p, r);
> +
> + p->regval = kvm_read_vm_id_reg(vcpu->kvm, SYS_CTR_EL0);
> + return true;
> +}
> +
> static unsigned int mte_visibility(const struct kvm_vcpu *vcpu,
> const struct sys_reg_desc *rd)
> {
> @@ -4855,12 +4855,6 @@ static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
> return true;
> }
>
> -int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu)
> -{
> - kvm_inject_undefined(vcpu);
> - return 1;
> -}
> -
> static void perform_access(struct kvm_vcpu *vcpu,
> struct sys_reg_params *params,
> const struct sys_reg_desc *r)
> @@ -4944,6 +4938,12 @@ static void unhandled_cp_access(struct kvm_vcpu *vcpu,
> kvm_inject_undefined(vcpu);
> }
>
> +int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu)
> +{
> + kvm_inject_undefined(vcpu);
> + return 1;
> +}
> +
> /**
> * kvm_handle_cp_64 -- handles a mrrc/mcrr trap on a guest CP14/CP15 access
> * @vcpu: The VCPU pointer
> diff --git a/arch/s390/kvm/arm64/arm.c b/arch/s390/kvm/arm64/arm.c
> index 3caa72f780a5..2740ee3b703e 100644
> --- a/arch/s390/kvm/arm64/arm.c
> +++ b/arch/s390/kvm/arm64/arm.c
> @@ -9,6 +9,7 @@
> #include <linux/kvm_host.h>
> #include <linux/cleanup.h>
> #include <linux/fpu.h>
> +#include <linux/bitfield.h>
>
> #include <asm/access-regs.h>
>
> @@ -25,6 +26,7 @@
> #include "trace.h"
>
> static unsigned long system_supported_vcpu_features(void);
> +#define read_sanitised_ftr_reg(_id) 0
>
> #define __INCL_GEN_ARM_FILE
> #include "generated/arm.inc"
Please split this. arm64 refactor and S390 changes should not be part
of the same patch.
M.
--
Jazz isn't dead. It just smells funny.
More information about the linux-arm-kernel
mailing list