1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/pgtable.h>
4 #include <asm/abs_lowcore.h>
6 unsigned long __bootdata_preserved(__abs_lowcore);
7 int __bootdata_preserved(relocate_lowcore);
9 int abs_lowcore_map(int cpu, struct lowcore *lc, bool alloc)
11 unsigned long addr = __abs_lowcore + (cpu * sizeof(struct lowcore));
12 unsigned long phys = __pa(lc);
15 for (i = 0; i < LC_PAGES; i++) {
16 rc = __vmem_map_4k_page(addr, phys, PAGE_KERNEL, alloc);
19 * Do not unmap allocated page tables in case the
20 * allocation was not requested. In such a case the
21 * request is expected coming from an atomic context,
22 * while the unmap attempt might sleep.
25 for (--i; i >= 0; i--) {
27 vmem_unmap_4k_page(addr);
38 void abs_lowcore_unmap(int cpu)
40 unsigned long addr = __abs_lowcore + (cpu * sizeof(struct lowcore));
43 for (i = 0; i < LC_PAGES; i++) {
44 vmem_unmap_4k_page(addr);