Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (C) 2020 - Google LLC
0004  * Author: David Brazdil <dbrazdil@google.com>
0005  */
0006 
0007 #include <asm/kvm_asm.h>
0008 #include <asm/kvm_hyp.h>
0009 #include <asm/kvm_mmu.h>
0010 
0011 /*
0012  * nVHE copy of data structures tracking available CPU cores.
0013  * Only entries for CPUs that were online at KVM init are populated.
0014  * Other CPUs should not be allowed to boot because their features were
0015  * not checked against the finalized system capabilities.
0016  */
0017 u64 __ro_after_init hyp_cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID };
0018 
0019 u64 cpu_logical_map(unsigned int cpu)
0020 {
0021     BUG_ON(cpu >= ARRAY_SIZE(hyp_cpu_logical_map));
0022 
0023     return hyp_cpu_logical_map[cpu];
0024 }
0025 
0026 unsigned long __hyp_per_cpu_offset(unsigned int cpu)
0027 {
0028     unsigned long *cpu_base_array;
0029     unsigned long this_cpu_base;
0030     unsigned long elf_base;
0031 
0032     BUG_ON(cpu >= ARRAY_SIZE(kvm_arm_hyp_percpu_base));
0033 
0034     cpu_base_array = (unsigned long *)&kvm_arm_hyp_percpu_base;
0035     this_cpu_base = kern_hyp_va(cpu_base_array[cpu]);
0036     elf_base = (unsigned long)&__per_cpu_start;
0037     return this_cpu_base - elf_base;
0038 }