Commit 9dd4c324 authored by Nikita Panov's avatar Nikita Panov Committed by Denis Darvish
Browse files

arm64: make power management aware about kernel replication

kunpeng inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IBOJU2



-------------------------------------------------

Acked-by: default avatarArtem Kuzin <artem.kuzin@huawei.com>
Acked-by: default avatarAlexander Grubnikov <alexander.grubnikov@huawei.com>
Acked-by: default avatarIlya Hanov <ilya.hanov@huawei-partners.com>
Acked-by: default avatarDenis Darvish <darvish.denis@huawei.com>
Signed-off-by: default avatarNikita Panov <panov.nikita@huawei.com>
parent 6cf30591
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -162,7 +162,11 @@ static inline void cpu_replace_ttbr1(pgd_t *pgdp, pgd_t *idmap)
	/* phys_to_ttbr() zeros lower 2 bits of ttbr with 52-bit PA */
	phys_addr_t ttbr1 = phys_to_ttbr(virt_to_phys(pgdp));

#ifdef CONFIG_KERNEL_REPLICATION
	if (system_supports_cnp() && !WARN_ON(pgdp != init_mm.pgd_numa[numa_node_id()])) {
#else
	if (system_supports_cnp() && !WARN_ON(pgdp != lm_alias(swapper_pg_dir))) {
#endif /* CONFIG_KERNEL_REPLICATION */
		/*
		 * cpu_replace_ttbr1() is used when there's a boot CPU
		 * up (i.e. cpufeature framework is not up yet) and
+5 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@
#include <linux/cpu.h>
#include <linux/kasan.h>
#include <linux/percpu.h>
#include <linux/numa_kernel_replication.h>

#include <asm/cpu.h>
#include <asm/cpufeature.h>
@@ -3677,7 +3678,11 @@ subsys_initcall_sync(init_32bit_el0_mask);

static void __maybe_unused cpu_enable_cnp(struct arm64_cpu_capabilities const *cap)
{
#ifdef CONFIG_KERNEL_REPLICATION
	cpu_replace_ttbr1(this_node_pgd(&init_mm), idmap_pg_dir);
#else
	cpu_replace_ttbr1(lm_alias(swapper_pg_dir), idmap_pg_dir);
#endif /* CONFIG_KERNEL_REPLICATION */
}

/*
+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include <linux/sched.h>
#include <linux/suspend.h>
#include <linux/utsname.h>
#include <linux/numa_kernel_replication.h>

#include <asm/barrier.h>
#include <asm/cacheflush.h>
@@ -113,7 +114,11 @@ int arch_hibernation_header_save(void *addr, unsigned int max_size)
		return -EOVERFLOW;

	arch_hdr_invariants(&hdr->invariants);
#ifdef CONFIG_KERNEL_REPLICATION
	hdr->ttbr1_el1		= virt_to_phys(this_node_pgd(&init_mm));
#else
	hdr->ttbr1_el1		= __pa_symbol(swapper_pg_dir);
#endif /* CONFIG_KERNEL_REPLICATION */
	hdr->reenter_kernel	= _cpu_resume;

	/* We can't use __hyp_get_vectors() because kvm may still be loaded */
+8 −0
Original line number Diff line number Diff line
@@ -5,6 +5,10 @@
#include <asm/assembler.h>
#include <asm/smp.h>

#ifdef CONFIG_KERNEL_REPLICATION
.extern numa_setup_pgd
#endif

	.text
/*
 * Implementation of MPIDR_EL1 hash algorithm through shifting
@@ -147,6 +151,10 @@ SYM_FUNC_START(_cpu_resume)
	bl	kasan_unpoison_task_stack_below
#endif

#ifdef CONFIG_KERNEL_REPLICATION
	bl 	numa_setup_pgd
#endif

	ldp	x19, x20, [x29, #16]
	ldp	x21, x22, [x29, #32]
	ldp	x23, x24, [x29, #48]
+6 −0
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@
#include <linux/uaccess.h>
#include <linux/pgtable.h>
#include <linux/cpuidle.h>
#include <linux/numa_kernel_replication.h>

#include <asm/alternative.h>
#include <asm/cacheflush.h>
#include <asm/cpufeature.h>
@@ -56,7 +58,11 @@ void notrace __cpu_suspend_exit(void)

	/* Restore CnP bit in TTBR1_EL1 */
	if (system_supports_cnp())
#ifdef CONFIG_KERNEL_REPLICATION
		cpu_replace_ttbr1(this_node_pgd(&init_mm), idmap_pg_dir);
#else
		cpu_replace_ttbr1(lm_alias(swapper_pg_dir), idmap_pg_dir);
#endif /* CONFIG_KERNEL_REPLICATION */

	/*
	 * PSTATE was not saved over suspend/resume, re-enable any detected