From: kettenis Date: Sun, 16 Apr 2023 11:14:26 +0000 (+0000) Subject: Make enabling the BTI feature a per-pmap thing by storing the ATTR_GP bit X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2c3273c1dc7912446870ac9ec7a9086cfe0bb5ba;p=openbsd Make enabling the BTI feature a per-pmap thing by storing the ATTR_GP bit in a new pm_guarded member of struct pmap and using this member to add the bits to the PTEs ok deraadt@ --- diff --git a/sys/arch/arm64/arm64/pmap.c b/sys/arch/arm64/arm64/pmap.c index 23bb1d2e436..038adcfca31 100644 --- a/sys/arch/arm64/arm64/pmap.c +++ b/sys/arch/arm64/arm64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.95 2023/04/13 15:23:22 miod Exp $ */ +/* $OpenBSD: pmap.c,v 1.96 2023/04/16 11:14:26 kettenis Exp $ */ /* * Copyright (c) 2008-2009,2014-2016 Dale Rahn * @@ -1220,10 +1220,12 @@ pmap_bootstrap(long kvo, paddr_t lpt1, long kernelstart, long kernelend, vp1 = (struct pmapvp1 *)pt1pa; pmap_kernel()->pm_vp.l1 = (struct pmapvp1 *)va; pmap_kernel()->pm_privileged = 1; + pmap_kernel()->pm_guarded = ATTR_GP; pmap_kernel()->pm_asid = 0; pmap_tramp.pm_vp.l1 = (struct pmapvp1 *)va + 1; pmap_tramp.pm_privileged = 1; + pmap_tramp.pm_guarded = ATTR_GP; pmap_tramp.pm_asid = 0; /* Mark ASID 0 as in-use. */ @@ -1689,8 +1691,7 @@ pmap_pte_update(struct pte_desc *pted, uint64_t *pl3) access_bits = ap_bits_user[pted->pted_pte & PROT_MASK]; #ifndef SMALL_KERNEL - if (pm == pmap_kernel()) - access_bits |= ATTR_GP; + access_bits |= pm->pm_guarded; #endif pte = (pted->pted_pte & PTE_RPGN) | attr | access_bits | L3_P; diff --git a/sys/arch/arm64/include/pmap.h b/sys/arch/arm64/include/pmap.h index 89fa7cdd5e3..d61d9936c66 100644 --- a/sys/arch/arm64/include/pmap.h +++ b/sys/arch/arm64/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.22 2023/02/16 20:32:39 miod Exp $ */ +/* $OpenBSD: pmap.h,v 1.23 2023/04/16 11:14:26 kettenis Exp $ */ /* * Copyright (c) 2008,2009,2014 Dale Rahn * @@ -66,6 +66,7 @@ struct pmap { } pm_vp; uint64_t pm_pt0pa; uint64_t pm_asid; + uint64_t pm_guarded; int have_4_level_pt; int pm_privileged; int pm_refs; /* ref count */