Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/machdep.c
| Show First 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | |||||
| pan_check(const struct cpu_feat *feat __unused, u_int midr __unused) | pan_check(const struct cpu_feat *feat __unused, u_int midr __unused) | ||||
| { | { | ||||
| uint64_t id_aa64mfr1; | uint64_t id_aa64mfr1; | ||||
| id_aa64mfr1 = READ_SPECIALREG(id_aa64mmfr1_el1); | id_aa64mfr1 = READ_SPECIALREG(id_aa64mmfr1_el1); | ||||
| return (ID_AA64MMFR1_PAN_VAL(id_aa64mfr1) != ID_AA64MMFR1_PAN_NONE); | return (ID_AA64MMFR1_PAN_VAL(id_aa64mfr1) != ID_AA64MMFR1_PAN_NONE); | ||||
| } | } | ||||
| static void | static bool | ||||
| pan_enable(const struct cpu_feat *feat __unused, | pan_enable(const struct cpu_feat *feat __unused, | ||||
| cpu_feat_errata errata_status __unused, u_int *errata_list __unused, | cpu_feat_errata errata_status __unused, u_int *errata_list __unused, | ||||
| u_int errata_count __unused) | u_int errata_count __unused) | ||||
| { | { | ||||
| has_pan = 1; | has_pan = 1; | ||||
| /* | /* | ||||
| * This sets the PAN bit, stopping the kernel from accessing | * This sets the PAN bit, stopping the kernel from accessing | ||||
| * memory when userspace can also access it unless the kernel | * memory when userspace can also access it unless the kernel | ||||
| * uses the userspace load/store instructions. | * uses the userspace load/store instructions. | ||||
| */ | */ | ||||
| WRITE_SPECIALREG(sctlr_el1, | WRITE_SPECIALREG(sctlr_el1, | ||||
| READ_SPECIALREG(sctlr_el1) & ~SCTLR_SPAN); | READ_SPECIALREG(sctlr_el1) & ~SCTLR_SPAN); | ||||
| __asm __volatile( | __asm __volatile( | ||||
| ".arch_extension pan \n" | ".arch_extension pan \n" | ||||
| "msr pan, #1 \n" | "msr pan, #1 \n" | ||||
| ".arch_extension nopan \n"); | ".arch_extension nopan \n"); | ||||
| return (true); | |||||
| } | } | ||||
| CPU_FEAT(feat_pan, | CPU_FEAT(feat_pan, "Privileged access never", | ||||
| pan_check, NULL, pan_enable, | pan_check, NULL, pan_enable, | ||||
| CPU_FEAT_EARLY_BOOT | CPU_FEAT_PER_CPU); | CPU_FEAT_EARLY_BOOT | CPU_FEAT_PER_CPU); | ||||
| bool | bool | ||||
| has_hyp(void) | has_hyp(void) | ||||
| { | { | ||||
| return (boot_el == CURRENTEL_EL_EL2); | return (boot_el == CURRENTEL_EL_EL2); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 818 Lines • Show Last 20 Lines | |||||