[PATCH v3 07/23] KVM: arm64: Prepare sys_regs.c for sharing with s390
From: Steffen Eiden
Date: Fri Nov 06 2026 - 11:13:28 EST
Prepare sharing of sys_regs.c with s390 by moving
reset_{vm,vcpu}_ftr_id_regs just before the UAPI definitions. Also, move
kvm_handle_cp14_load_store to other cp functions. This small refactoring
allows to have less shared sections.
No functional changes.
Co-developed-by: Andreas Grapentin <gra@xxxxxxxxxxxxx>
Signed-off-by: Andreas Grapentin <gra@xxxxxxxxxxxxx>
Signed-off-by: Steffen Eiden <seiden@xxxxxxxxxxxxx>
---
arch/arm64/kvm/sys_regs.c | 52 +++++++++++++++++++++++++----------------------
1 file changed, 28 insertions(+), 24 deletions(-)
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 8c91de6a4097..e71c1b169b49 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -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)
@@ -4888,6 +4882,12 @@ static void perform_access(struct kvm_vcpu *vcpu,
kvm_incr_pc(vcpu);
}
+int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu)
+{
+ kvm_inject_undefined(vcpu);
+ return 1;
+}
+
/*
* emulate_cp -- tries to match a sys_reg access in a handling table, and
* call the corresponding trap handler.
@@ -5340,25 +5340,9 @@ void kvm_sys_regs_create_debugfs(struct kvm *kvm)
&sr_resx_fops);
}
-static void reset_vm_ftr_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *reg)
-{
- u32 id = reg_to_encoding(reg);
- struct kvm *kvm = vcpu->kvm;
-
- if (test_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags))
- return;
-
- kvm_set_vm_id_reg(kvm, id, reg->reset(vcpu, reg));
-}
-
+static void reset_vm_ftr_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *reg);
static void reset_vcpu_ftr_id_reg(struct kvm_vcpu *vcpu,
- const struct sys_reg_desc *reg)
-{
- if (kvm_vcpu_initialized(vcpu))
- return;
-
- reg->reset(vcpu, reg);
-}
+ const struct sys_reg_desc *reg);
/**
* kvm_reset_sys_regs - sets system registers to reset value
@@ -5432,6 +5416,26 @@ int kvm_handle_sys_reg(struct kvm_vcpu *vcpu)
return 1;
}
+static void reset_vm_ftr_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *reg)
+{
+ u32 id = reg_to_encoding(reg);
+ struct kvm *kvm = vcpu->kvm;
+
+ if (test_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags))
+ return;
+
+ kvm_set_vm_id_reg(kvm, id, reg->reset(vcpu, reg));
+}
+
+static void reset_vcpu_ftr_id_reg(struct kvm_vcpu *vcpu,
+ const struct sys_reg_desc *reg)
+{
+ if (kvm_vcpu_initialized(vcpu))
+ return;
+
+ reg->reset(vcpu, reg);
+}
+
/******************************************************************************
* Userspace API
*****************************************************************************/
--
2.56.0