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