From 407b6a4e445a9517dc733100621bef721c7276ff Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Thu, 1 Aug 2019 22:48:06 +0000 Subject: [PATCH] Use ATTR_DBM even when hardware dirty bit management is not enabled. The ARMv8 reference manual only states that the bit is reserved in this case; following Linux's example, use it instead of a software-defined bit for the purpose of indicating that a managed mapping is writable. Reviewed by: alc, andrew MFC after: r350004 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21121 --- sys/arm64/arm64/pmap.c | 14 ++++---------- sys/arm64/include/pte.h | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index bf67d7317b20..f3fa571b5942 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -221,8 +221,11 @@ __FBSDID("$FreeBSD$"); * The presence of this flag indicates that the mapping is writeable. * If the ATTR_AP_RO bit is also set, then the mapping is clean, otherwise it is * dirty. This flag may only be set on managed mappings. + * + * The DBM bit is reserved on ARMv8.0 but it seems we can safely treat it + * as a software managed bit. */ -static pt_entry_t ATTR_SW_DBM; +#define ATTR_SW_DBM ATTR_DBM struct pmap kernel_pmap_store; @@ -784,15 +787,6 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_paddr_t kernstart, uint64_t kern_delta; int i; -#ifdef notyet - /* Determine whether the hardware implements DBM management. */ - uint64_t reg = READ_SPECIALREG(ID_AA64MMFR1_EL1); - ATTR_SW_DBM = ID_AA64MMFR1_HAFDBS(reg) == ID_AA64MMFR1_HAFDBS_AF_DBS ? - ATTR_DBM : _ATTR_SW_DBM; -#else - ATTR_SW_DBM = _ATTR_SW_DBM; -#endif - kern_delta = KERNBASE - kernstart; printf("pmap_bootstrap %lx %lx %lx\n", l1pt, kernstart, kernlen); diff --git a/sys/arm64/include/pte.h b/sys/arm64/include/pte.h index b739b0b14054..261d04d013c5 100644 --- a/sys/arm64/include/pte.h +++ b/sys/arm64/include/pte.h @@ -43,8 +43,8 @@ typedef uint64_t pt_entry_t; /* page table entry */ #define ATTR_MASK_L UINT64_C(0x0000000000000fff) #define ATTR_MASK (ATTR_MASK_H | ATTR_MASK_L) /* Bits 58:55 are reserved for software */ -#define ATTR_SW_UNUSED (1UL << 58) -#define _ATTR_SW_DBM (1UL << 57) +#define ATTR_SW_UNUSED2 (1UL << 58) +#define ATTR_SW_UNUSED1 (1UL << 57) #define ATTR_SW_MANAGED (1UL << 56) #define ATTR_SW_WIRED (1UL << 55) #define ATTR_UXN (1UL << 54)