@@ -78,7 +78,7 @@ extern unsigned int __ro_after_init kvm_sve_max_vl;
7878int __init kvm_arm_init_sve (void );
7979
8080u32 __attribute_const__ kvm_target_cpu (void );
81- int kvm_reset_vcpu (struct kvm_vcpu * vcpu );
81+ void kvm_reset_vcpu (struct kvm_vcpu * vcpu );
8282void kvm_arm_vcpu_destroy (struct kvm_vcpu * vcpu );
8383
8484struct kvm_hyp_memcache {
@@ -158,6 +158,16 @@ struct kvm_s2_mmu {
158158 phys_addr_t pgd_phys ;
159159 struct kvm_pgtable * pgt ;
160160
161+ /*
162+ * VTCR value used on the host. For a non-NV guest (or a NV
163+ * guest that runs in a context where its own S2 doesn't
164+ * apply), its T0SZ value reflects that of the IPA size.
165+ *
166+ * For a shadow S2 MMU, T0SZ reflects the PARange exposed to
167+ * the guest.
168+ */
169+ u64 vtcr ;
170+
161171 /* The last vcpu id that ran on each physical CPU */
162172 int __percpu * last_vcpu_ran ;
163173
@@ -202,12 +212,34 @@ struct kvm_protected_vm {
202212 struct kvm_hyp_memcache teardown_mc ;
203213};
204214
215+ struct kvm_mpidr_data {
216+ u64 mpidr_mask ;
217+ DECLARE_FLEX_ARRAY (u16 , cmpidr_to_idx );
218+ };
219+
220+ static inline u16 kvm_mpidr_index (struct kvm_mpidr_data * data , u64 mpidr )
221+ {
222+ unsigned long mask = data -> mpidr_mask ;
223+ u64 aff = mpidr & MPIDR_HWID_BITMASK ;
224+ int nbits , bit , bit_idx = 0 ;
225+ u16 index = 0 ;
226+
227+ /*
228+ * If this looks like RISC-V's BEXT or x86's PEXT
229+ * instructions, it isn't by accident.
230+ */
231+ nbits = fls (mask );
232+ for_each_set_bit (bit , & mask , nbits ) {
233+ index |= (aff & BIT (bit )) >> (bit - bit_idx );
234+ bit_idx ++ ;
235+ }
236+
237+ return index ;
238+ }
239+
205240struct kvm_arch {
206241 struct kvm_s2_mmu mmu ;
207242
208- /* VTCR_EL2 value for this VM */
209- u64 vtcr ;
210-
211243 /* Interrupt controller */
212244 struct vgic_dist vgic ;
213245
@@ -239,15 +271,16 @@ struct kvm_arch {
239271#define KVM_ARCH_FLAG_VM_COUNTER_OFFSET 5
240272 /* Timer PPIs made immutable */
241273#define KVM_ARCH_FLAG_TIMER_PPIS_IMMUTABLE 6
242- /* SMCCC filter initialized for the VM */
243- #define KVM_ARCH_FLAG_SMCCC_FILTER_CONFIGURED 7
244274 /* Initial ID reg values loaded */
245- #define KVM_ARCH_FLAG_ID_REGS_INITIALIZED 8
275+ #define KVM_ARCH_FLAG_ID_REGS_INITIALIZED 7
246276 unsigned long flags ;
247277
248278 /* VM-wide vCPU feature set */
249279 DECLARE_BITMAP (vcpu_features , KVM_VCPU_MAX_FEATURES );
250280
281+ /* MPIDR to vcpu index mapping, optional */
282+ struct kvm_mpidr_data * mpidr_data ;
283+
251284 /*
252285 * VM-wide PMU filter, implemented as a bitmap and big enough for
253286 * up to 2^10 events (ARMv8.0) or 2^16 events (ARMv8.1+).
@@ -257,6 +290,9 @@ struct kvm_arch {
257290
258291 cpumask_var_t supported_cpus ;
259292
293+ /* PMCR_EL0.N value for the guest */
294+ u8 pmcr_n ;
295+
260296 /* Hypercall features firmware registers' descriptor */
261297 struct kvm_smccc_features smccc_feat ;
262298 struct maple_tree smccc_filter ;
@@ -574,9 +610,6 @@ struct kvm_vcpu_arch {
574610 /* Cache some mmu pages needed inside spinlock regions */
575611 struct kvm_mmu_memory_cache mmu_page_cache ;
576612
577- /* feature flags */
578- DECLARE_BITMAP (features , KVM_VCPU_MAX_FEATURES );
579-
580613 /* Virtual SError ESR to restore when HCR_EL2.VSE is set */
581614 u64 vsesr_el2 ;
582615
@@ -1025,7 +1058,7 @@ int kvm_arm_pvtime_has_attr(struct kvm_vcpu *vcpu,
10251058extern unsigned int __ro_after_init kvm_arm_vmid_bits ;
10261059int __init kvm_arm_vmid_alloc_init (void );
10271060void __init kvm_arm_vmid_alloc_free (void );
1028- void kvm_arm_vmid_update (struct kvm_vmid * kvm_vmid );
1061+ bool kvm_arm_vmid_update (struct kvm_vmid * kvm_vmid );
10291062void kvm_arm_vmid_clear_active (void );
10301063
10311064static inline void kvm_arm_pvtime_vcpu_init (struct kvm_vcpu_arch * vcpu_arch )
@@ -1078,6 +1111,8 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,
10781111 struct kvm_arm_copy_mte_tags * copy_tags );
10791112int kvm_vm_ioctl_set_counter_offset (struct kvm * kvm ,
10801113 struct kvm_arm_counter_offset * offset );
1114+ int kvm_vm_ioctl_get_reg_writable_masks (struct kvm * kvm ,
1115+ struct reg_mask_range * range );
10811116
10821117/* Guest/host FPSIMD coordination helpers */
10831118int kvm_arch_vcpu_run_map_fp (struct kvm_vcpu * vcpu );
@@ -1109,8 +1144,8 @@ static inline bool kvm_set_pmuserenr(u64 val)
11091144}
11101145#endif
11111146
1112- void kvm_vcpu_load_sysregs_vhe (struct kvm_vcpu * vcpu );
1113- void kvm_vcpu_put_sysregs_vhe (struct kvm_vcpu * vcpu );
1147+ void kvm_vcpu_load_vhe (struct kvm_vcpu * vcpu );
1148+ void kvm_vcpu_put_vhe (struct kvm_vcpu * vcpu );
11141149
11151150int __init kvm_set_ipa_limit (void );
11161151
0 commit comments