Lines Matching +full:local +full:- +full:pid

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2008-2011 Freescale Semiconductor, Inc. All rights reserved.
36 * (guestAS,guestTID,guestPR) --> ID of physical cpu
49 * ID --> address of vcpu_id_table item.
58 /* This variable keeps last used shadow ID on local core.
73 int ret = -1; in local_sid_setup_one()
78 entry->val = sid; in local_sid_setup_one()
79 entry->pentry = this_cpu_ptr(&pcpu_sids.entry[sid]); in local_sid_setup_one()
84 * If sid == NUM_TIDS, we've run out of sids. We return -1, and in local_sid_setup_one()
106 if (entry && entry->val != 0 && in local_sid_lookup()
107 __this_cpu_read(pcpu_sids.entry[entry->val]) == entry && in local_sid_lookup()
108 entry->pentry == this_cpu_ptr(&pcpu_sids.entry[entry->val])) in local_sid_lookup()
109 return entry->val; in local_sid_lookup()
110 return -1; in local_sid_lookup()
113 /* Invalidate all id mappings on local core -- call with preempt disabled */
122 vcpu_e500->idt = kzalloc(sizeof(struct vcpu_id_table), GFP_KERNEL); in kvmppc_e500_id_table_alloc()
123 return vcpu_e500->idt; in kvmppc_e500_id_table_alloc()
128 kfree(vcpu_e500->idt); in kvmppc_e500_id_table_free()
129 vcpu_e500->idt = NULL; in kvmppc_e500_id_table_free()
132 /* Map guest pid to shadow.
133 * We use PID to keep shadow of current guest non-zero PID,
134 * and use PID1 to keep shadow of guest zero PID.
139 vcpu_e500->vcpu.arch.shadow_pid = kvmppc_e500_get_sid(vcpu_e500, in kvmppc_e500_recalc_shadow_pid()
140 get_cur_as(&vcpu_e500->vcpu), in kvmppc_e500_recalc_shadow_pid()
141 get_cur_pid(&vcpu_e500->vcpu), in kvmppc_e500_recalc_shadow_pid()
142 get_cur_pr(&vcpu_e500->vcpu), 1); in kvmppc_e500_recalc_shadow_pid()
143 vcpu_e500->vcpu.arch.shadow_pid1 = kvmppc_e500_get_sid(vcpu_e500, in kvmppc_e500_recalc_shadow_pid()
144 get_cur_as(&vcpu_e500->vcpu), 0, in kvmppc_e500_recalc_shadow_pid()
145 get_cur_pr(&vcpu_e500->vcpu), 1); in kvmppc_e500_recalc_shadow_pid()
152 memset(vcpu_e500->idt, 0, sizeof(struct vcpu_id_table)); in kvmppc_e500_id_table_reset_all()
154 /* Update shadow pid when mappings are changed */ in kvmppc_e500_id_table_reset_all()
161 int as, int pid, int pr) in kvmppc_e500_id_table_reset_one() argument
163 struct vcpu_id_table *idt = vcpu_e500->idt; in kvmppc_e500_id_table_reset_one()
166 BUG_ON(pid >= NUM_TIDS); in kvmppc_e500_id_table_reset_one()
169 idt->id[as][pid][pr].val = 0; in kvmppc_e500_id_table_reset_one()
170 idt->id[as][pid][pr].pentry = NULL; in kvmppc_e500_id_table_reset_one()
172 /* Update shadow pid when mappings are changed */ in kvmppc_e500_id_table_reset_one()
189 struct vcpu_id_table *idt = vcpu_e500->idt; in kvmppc_e500_get_sid()
196 sid = local_sid_lookup(&idt->id[as][gid][pr]); in kvmppc_e500_get_sid()
200 sid = local_sid_setup_one(&idt->id[as][gid][pr]); in kvmppc_e500_get_sid()
206 /* Update shadow pid when mappings are changed */ in kvmppc_e500_get_sid()
221 void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid) in kvmppc_set_pid() argument
225 if (vcpu->arch.pid != pid) { in kvmppc_set_pid()
226 vcpu_e500->pid[0] = vcpu->arch.pid = pid; in kvmppc_set_pid()
235 struct vcpu_id_table *idt = vcpu_e500->idt; in kvmppc_e500_tlbil_one()
237 int pid; in kvmppc_e500_tlbil_one() local
249 * The shadow PID can have a valid mapping on at most one in kvmppc_e500_tlbil_one()
251 * CPU, in which case we do a local invalidation of the in kvmppc_e500_tlbil_one()
254 * If the shadow PID is not valid on the current host CPU, in kvmppc_e500_tlbil_one()
255 * we invalidate the entire shadow PID. in kvmppc_e500_tlbil_one()
257 pid = local_sid_lookup(&idt->id[ts][tid][pr]); in kvmppc_e500_tlbil_one()
258 if (pid <= 0) { in kvmppc_e500_tlbil_one()
264 * The guest is invalidating a 4K entry which is in a PID in kvmppc_e500_tlbil_one()
269 val = (pid << MAS6_SPID_SHIFT) | MAS6_SAS; in kvmppc_e500_tlbil_one()
295 /* Recalc shadow pid since MSR changes */ in kvmppc_mmu_msr_notify()
303 /* Shadow PID may be expired on local core */ in kvmppc_core_vcpu_load_e500()
310 if (vcpu->arch.shadow_msr & MSR_SPE) in kvmppc_core_vcpu_put_e500()
321 if (strcmp(cur_cpu_spec->cpu_name, "e500v2") == 0) in kvmppc_core_check_processor_compat()
324 r = -ENOTSUPP; in kvmppc_core_check_processor_compat()
335 tlbe->mas1 = MAS1_VALID | MAS1_TSIZE(BOOK3E_PAGESZ_256M); in kvmppc_e500_tlb_setup()
336 tlbe->mas2 = 0; in kvmppc_e500_tlb_setup()
337 tlbe->mas7_3 = E500_TLB_SUPER_PERM_MASK; in kvmppc_e500_tlb_setup()
341 tlbe->mas1 = MAS1_VALID | MAS1_TSIZE(BOOK3E_PAGESZ_4K); in kvmppc_e500_tlb_setup()
342 tlbe->mas2 = (0xe0004500 & 0xFFFFF000) | MAS2_I | MAS2_G; in kvmppc_e500_tlb_setup()
343 tlbe->mas7_3 = (0xe0004500 & 0xFFFFF000) | E500_TLB_SUPER_PERM_MASK; in kvmppc_e500_tlb_setup()
353 vcpu->arch.pvr = mfspr(SPRN_PVR); in kvmppc_core_vcpu_setup()
354 vcpu_e500->svr = mfspr(SPRN_SVR); in kvmppc_core_vcpu_setup()
356 vcpu->arch.cpu_type = KVM_CPU_E500V2; in kvmppc_core_vcpu_setup()
366 sregs->u.e.features |= KVM_SREGS_E_ARCH206_MMU | KVM_SREGS_E_SPE | in kvmppc_core_get_sregs_e500()
368 sregs->u.e.impl_id = KVM_SREGS_E_IMPL_FSL; in kvmppc_core_get_sregs_e500()
370 sregs->u.e.impl.fsl.features = 0; in kvmppc_core_get_sregs_e500()
371 sregs->u.e.impl.fsl.svr = vcpu_e500->svr; in kvmppc_core_get_sregs_e500()
372 sregs->u.e.impl.fsl.hid0 = vcpu_e500->hid0; in kvmppc_core_get_sregs_e500()
373 sregs->u.e.impl.fsl.mcar = vcpu_e500->mcar; in kvmppc_core_get_sregs_e500()
375 sregs->u.e.ivor_high[0] = vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_UNAVAIL]; in kvmppc_core_get_sregs_e500()
376 sregs->u.e.ivor_high[1] = vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_FP_DATA]; in kvmppc_core_get_sregs_e500()
377 sregs->u.e.ivor_high[2] = vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_FP_ROUND]; in kvmppc_core_get_sregs_e500()
378 sregs->u.e.ivor_high[3] = in kvmppc_core_get_sregs_e500()
379 vcpu->arch.ivor[BOOKE_IRQPRIO_PERFORMANCE_MONITOR]; in kvmppc_core_get_sregs_e500()
392 if (sregs->u.e.impl_id == KVM_SREGS_E_IMPL_FSL) { in kvmppc_core_set_sregs_e500()
393 vcpu_e500->svr = sregs->u.e.impl.fsl.svr; in kvmppc_core_set_sregs_e500()
394 vcpu_e500->hid0 = sregs->u.e.impl.fsl.hid0; in kvmppc_core_set_sregs_e500()
395 vcpu_e500->mcar = sregs->u.e.impl.fsl.mcar; in kvmppc_core_set_sregs_e500()
402 if (!(sregs->u.e.features & KVM_SREGS_E_IVOR)) in kvmppc_core_set_sregs_e500()
405 if (sregs->u.e.features & KVM_SREGS_E_SPE) { in kvmppc_core_set_sregs_e500()
406 vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_UNAVAIL] = in kvmppc_core_set_sregs_e500()
407 sregs->u.e.ivor_high[0]; in kvmppc_core_set_sregs_e500()
408 vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_FP_DATA] = in kvmppc_core_set_sregs_e500()
409 sregs->u.e.ivor_high[1]; in kvmppc_core_set_sregs_e500()
410 vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_FP_ROUND] = in kvmppc_core_set_sregs_e500()
411 sregs->u.e.ivor_high[2]; in kvmppc_core_set_sregs_e500()
414 if (sregs->u.e.features & KVM_SREGS_E_PM) { in kvmppc_core_set_sregs_e500()
415 vcpu->arch.ivor[BOOKE_IRQPRIO_PERFORMANCE_MONITOR] = in kvmppc_core_set_sregs_e500()
416 sregs->u.e.ivor_high[3]; in kvmppc_core_set_sregs_e500()
445 return -ENOMEM; in kvmppc_core_vcpu_create_e500()
451 vcpu->arch.shared = (void*)__get_free_page(GFP_KERNEL|__GFP_ZERO); in kvmppc_core_vcpu_create_e500()
452 if (!vcpu->arch.shared) { in kvmppc_core_vcpu_create_e500()
453 err = -ENOMEM; in kvmppc_core_vcpu_create_e500()
470 free_page((unsigned long)vcpu->arch.shared); in kvmppc_core_vcpu_free_e500()
526 handler_len = handler[i + 1] - handler[i]; in kvmppc_e500_init()
530 handler_len = handler[max_ivor + 1] - handler[max_ivor]; in kvmppc_e500_init()