mirror of https://gitee.com/openkylin/linux.git
powerpc/book3s64/kuap: Move KUAP related function outside radix
The next set of patches adds support for kuap with hash translation. In preparation for that rename/move kuap related functions to non radix names. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20201127044424.40686-6-aneesh.kumar@linux.ibm.com
This commit is contained in:
parent
39df17bc20
commit
3b47b7549e
|
@ -1,6 +1,6 @@
|
||||||
/* SPDX-License-Identifier: GPL-2.0 */
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
#ifndef _ASM_POWERPC_BOOK3S_64_KUP_RADIX_H
|
#ifndef _ASM_POWERPC_BOOK3S_64_KUP_H
|
||||||
#define _ASM_POWERPC_BOOK3S_64_KUP_RADIX_H
|
#define _ASM_POWERPC_BOOK3S_64_KUP_H
|
||||||
|
|
||||||
#include <linux/const.h>
|
#include <linux/const.h>
|
||||||
#include <asm/reg.h>
|
#include <asm/reg.h>
|
||||||
|
@ -202,4 +202,4 @@ static inline void restore_user_access(unsigned long flags)
|
||||||
}
|
}
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
|
|
||||||
#endif /* _ASM_POWERPC_BOOK3S_64_KUP_RADIX_H */
|
#endif /* _ASM_POWERPC_BOOK3S_64_KUP_H */
|
|
@ -15,11 +15,13 @@
|
||||||
#define KUAP_CURRENT (KUAP_CURRENT_READ | KUAP_CURRENT_WRITE)
|
#define KUAP_CURRENT (KUAP_CURRENT_READ | KUAP_CURRENT_WRITE)
|
||||||
|
|
||||||
#ifdef CONFIG_PPC_BOOK3S_64
|
#ifdef CONFIG_PPC_BOOK3S_64
|
||||||
#include <asm/book3s/64/kup-radix.h>
|
#include <asm/book3s/64/kup.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_PPC_8xx
|
#ifdef CONFIG_PPC_8xx
|
||||||
#include <asm/nohash/32/kup-8xx.h>
|
#include <asm/nohash/32/kup-8xx.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_PPC_BOOK3S_32
|
#ifdef CONFIG_PPC_BOOK3S_32
|
||||||
#include <asm/book3s/32/kup.h>
|
#include <asm/book3s/32/kup.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,9 +9,12 @@
|
||||||
#include <asm/mmu_context.h>
|
#include <asm/mmu_context.h>
|
||||||
#include <asm/mmu.h>
|
#include <asm/mmu.h>
|
||||||
#include <asm/setup.h>
|
#include <asm/setup.h>
|
||||||
|
#include <asm/smp.h>
|
||||||
|
|
||||||
#include <linux/pkeys.h>
|
#include <linux/pkeys.h>
|
||||||
#include <linux/of_fdt.h>
|
#include <linux/of_fdt.h>
|
||||||
|
|
||||||
|
|
||||||
int num_pkey; /* Max number of pkeys supported */
|
int num_pkey; /* Max number of pkeys supported */
|
||||||
/*
|
/*
|
||||||
* Keys marked in the reservation list cannot be allocated by userspace
|
* Keys marked in the reservation list cannot be allocated by userspace
|
||||||
|
@ -226,6 +229,25 @@ void __init pkey_early_init_devtree(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PPC_KUAP
|
||||||
|
void __init setup_kuap(bool disabled)
|
||||||
|
{
|
||||||
|
if (disabled || !early_radix_enabled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (smp_processor_id() == boot_cpuid) {
|
||||||
|
pr_info("Activating Kernel Userspace Access Prevention\n");
|
||||||
|
cur_cpu_spec->mmu_features |= MMU_FTR_RADIX_KUAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the default kernel AMR values on all cpus.
|
||||||
|
*/
|
||||||
|
mtspr(SPRN_AMR, AMR_KUAP_BLOCKED);
|
||||||
|
isync();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline u64 read_amr(void)
|
static inline u64 read_amr(void)
|
||||||
{
|
{
|
||||||
return mfspr(SPRN_AMR);
|
return mfspr(SPRN_AMR);
|
||||||
|
|
|
@ -609,25 +609,6 @@ void setup_kuep(bool disabled)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_PPC_KUAP
|
|
||||||
void setup_kuap(bool disabled)
|
|
||||||
{
|
|
||||||
if (disabled || !early_radix_enabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (smp_processor_id() == boot_cpuid) {
|
|
||||||
pr_info("Activating Kernel Userspace Access Prevention\n");
|
|
||||||
cur_cpu_spec->mmu_features |= MMU_FTR_RADIX_KUAP;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the default kernel AMR values on all cpus.
|
|
||||||
*/
|
|
||||||
mtspr(SPRN_AMR, AMR_KUAP_BLOCKED);
|
|
||||||
isync();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void __init radix__early_init_mmu(void)
|
void __init radix__early_init_mmu(void)
|
||||||
{
|
{
|
||||||
unsigned long lpcr;
|
unsigned long lpcr;
|
||||||
|
|
Loading…
Reference in New Issue