[PATCH 02/12] arm64: Share timer and smccc functionality with s390

Steffen Eiden seiden at linux.ibm.com
Wed Dec 2 06:11:40 PST 2026


Share functions and definitions required to implement guest timers and
smccc.

Signed-off-by: Steffen Eiden <seiden at linux.ibm.com>
---
 arch/arm64/include/asm/kvm_emulate.h |  4 ++--
 arch/arm64/include/asm/kvm_host.h    | 36 ++++++++++++++++++++----------------
 arch/arm64/include/asm/kvm_mmu.h     |  2 ++
 arch/arm64/include/asm/pvclock-abi.h |  1 +
 4 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
index 9e75db26929c..71e4024825eb 100644
--- a/arch/arm64/include/asm/kvm_emulate.h
+++ b/arch/arm64/include/asm/kvm_emulate.h
@@ -546,13 +546,13 @@ static inline bool kvm_is_write_fault(struct kvm_vcpu *vcpu)
 	return esr_abt_is_write_fault(kvm_vcpu_get_esr(vcpu));
 }
 
-#endif /* ARM64_S390_COMMON == 1 */
-
 static inline unsigned long kvm_vcpu_get_mpidr_aff(struct kvm_vcpu *vcpu)
 {
 	return __vcpu_sys_reg(vcpu, MPIDR_EL1) & MPIDR_HWID_BITMASK;
 }
 
+#endif /* ARM64_S390_COMMON == 1 */
+
 /* In nVHE hyp code, registers are always in memory: use the raw accessors. */
 #if defined(__KVM_NVHE_HYPERVISOR__)
 #define vcpu_read_sys_reg(v, r)		__vcpu_sys_reg(v, r)
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 5072de2ac8ce..4ed8c2bd2101 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -124,6 +124,20 @@ struct kvm_vm_id_regs {
 	u64 ctr_el0;
 };
 
+/**
+ * struct kvm_smccc_features: Descriptor of the hypercall services exposed to the guests
+ *
+ * @std_bmap: Bitmap of standard secure service calls
+ * @std_hyp_bmap: Bitmap of standard hypervisor service calls
+ * @vendor_hyp_bmap: Bitmap of vendor specific hypervisor service calls
+ */
+struct kvm_smccc_features {
+	unsigned long std_bmap;
+	unsigned long std_hyp_bmap;
+	unsigned long vendor_hyp_bmap; /* Function numbers 0-63 */
+	unsigned long vendor_hyp_bmap_2; /* Function numbers 64-127 */
+};
+
 #endif /* ARM64_S390_COMMON == 1 */
 
 #define KVM_DIRTY_LOG_MANUAL_CAPS   (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE | \
@@ -354,20 +368,6 @@ struct kvm_s2_mmu {
 struct kvm_arch_memory_slot {
 };
 
-/**
- * struct kvm_smccc_features: Descriptor of the hypercall services exposed to the guests
- *
- * @std_bmap: Bitmap of standard secure service calls
- * @std_hyp_bmap: Bitmap of standard hypervisor service calls
- * @vendor_hyp_bmap: Bitmap of vendor specific hypervisor service calls
- */
-struct kvm_smccc_features {
-	unsigned long std_bmap;
-	unsigned long std_hyp_bmap;
-	unsigned long vendor_hyp_bmap; /* Function numbers 0-63 */
-	unsigned long vendor_hyp_bmap_2; /* Function numbers 64-127 */
-};
-
 struct kvm_protected_vm {
 	pkvm_handle_t handle;
 	struct kvm_hyp_memcache stage2_teardown_mc;
@@ -381,6 +381,8 @@ struct kvm_protected_vm {
 	bool is_dying;
 };
 
+#if ARM64_S390_COMMON == 1
+
 struct kvm_mpidr_data {
 	u64			mpidr_mask;
 	DECLARE_FLEX_ARRAY(u16, cmpidr_to_idx);
@@ -398,6 +400,8 @@ static inline u16 kvm_mpidr_index(struct kvm_mpidr_data *data, u64 mpidr)
 
 struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr);
 
+#endif /* ARM64_S390_COMMON == 1 */
+
 struct kvm_sysreg_masks;
 
 enum fgt_group_id {
@@ -1406,8 +1410,6 @@ unsigned long kvm_mmio_read_buf(const void *buf, unsigned int len);
 int kvm_handle_mmio_return(struct kvm_vcpu *vcpu);
 int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa);
 
-#endif /* ARM64_S390_COMMON == 1 */
-
 /*
  * Returns true if a Performance Monitoring Interrupt (PMI), a.k.a. perf event,
  * arrived in guest context.  For arm64, any event that arrives while a vCPU is
@@ -1430,6 +1432,8 @@ int kvm_arm_pvtime_get_attr(struct kvm_vcpu *vcpu,
 int kvm_arm_pvtime_has_attr(struct kvm_vcpu *vcpu,
 			    struct kvm_device_attr *attr);
 
+#endif /* ARM64_S390_COMMON == 1 */
+
 extern unsigned int __ro_after_init kvm_arm_vmid_bits;
 int __init kvm_arm_vmid_alloc_init(void);
 void __init kvm_arm_vmid_alloc_free(void);
diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h
index 32392abf2e21..7f11b7d76c82 100644
--- a/arch/arm64/include/asm/kvm_mmu.h
+++ b/arch/arm64/include/asm/kvm_mmu.h
@@ -297,6 +297,7 @@ static inline int kvm_read_guest_lock(struct kvm *kvm,
 	return ret;
 }
 
+#if ARM64_S390_COMMON == 1
 static inline int kvm_write_guest_lock(struct kvm *kvm, gpa_t gpa,
 				       const void *data, unsigned long len)
 {
@@ -307,6 +308,7 @@ static inline int kvm_write_guest_lock(struct kvm *kvm, gpa_t gpa,
 
 	return ret;
 }
+#endif /* ARM64_S390_COMMON == 1 */
 
 #define kvm_phys_to_vttbr(addr)		phys_to_ttbr(addr)
 
diff --git a/arch/arm64/include/asm/pvclock-abi.h b/arch/arm64/include/asm/pvclock-abi.h
index c4f1c0a0789c..0e38e38fc804 100644
--- a/arch/arm64/include/asm/pvclock-abi.h
+++ b/arch/arm64/include/asm/pvclock-abi.h
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Copyright (C) 2019 Arm Ltd. */
+/* Whole file is shared with s390 */
 
 #ifndef __ASM_PVCLOCK_ABI_H
 #define __ASM_PVCLOCK_ABI_H

-- 
2.56.1




More information about the linux-arm-kernel mailing list