2021-06-03 16:41:36 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#include <asm/kup.h>
|
2021-06-03 16:41:41 +08:00
|
|
|
#include <asm/smp.h>
|
2021-06-03 16:41:36 +08:00
|
|
|
|
2021-06-28 14:56:11 +08:00
|
|
|
void setup_kuap(bool disabled)
|
2021-06-03 16:41:36 +08:00
|
|
|
{
|
2021-10-19 15:29:18 +08:00
|
|
|
if (!disabled) {
|
2023-07-11 23:59:19 +08:00
|
|
|
update_user_segments(mfsr(0) | SR_KS);
|
|
|
|
isync(); /* Context sync required after mtsr() */
|
2021-10-19 15:29:18 +08:00
|
|
|
init_mm.context.sr0 |= SR_KS;
|
|
|
|
current->thread.sr0 |= SR_KS;
|
|
|
|
}
|
2021-06-03 16:41:41 +08:00
|
|
|
|
|
|
|
if (smp_processor_id() != boot_cpuid)
|
|
|
|
return;
|
|
|
|
|
2021-06-03 16:41:36 +08:00
|
|
|
if (disabled)
|
2023-07-11 23:59:18 +08:00
|
|
|
cur_cpu_spec->mmu_features &= ~MMU_FTR_KUAP;
|
2021-06-03 16:41:43 +08:00
|
|
|
else
|
|
|
|
pr_info("Activating Kernel Userspace Access Protection\n");
|
2021-06-03 16:41:36 +08:00
|
|
|
}
|