FreeBSD Bugzilla – Attachment 249802 Details for
Bug 278233
PHYS_IN_DMAP and VIRT_IN_DMAP macros assume contiguous DMAP memory
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
bug fix: support non-contiguous memory in PHYS_IN_DMAP and VIRT_IN_DMAP
file_278233.txt (text/plain), 6.50 KB, created by
Zeev Zilberman
on 2024-04-07 13:00:47 UTC
(
hide
)
Description:
bug fix: support non-contiguous memory in PHYS_IN_DMAP and VIRT_IN_DMAP
Filename:
MIME Type:
Creator:
Zeev Zilberman
Created:
2024-04-07 13:00:47 UTC
Size:
6.50 KB
patch
obsolete
>diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c >index ba72f1dac8d0..e44d07e25002 100644 >--- a/sys/arm64/arm64/pmap.c >+++ b/sys/arm64/arm64/pmap.c >@@ -342,6 +342,7 @@ struct pv_chunks_list __exclusive_cache_line pv_chunks[PMAP_MEMDOM]; > vm_paddr_t dmap_phys_base; /* The start of the dmap region */ > vm_paddr_t dmap_phys_max; /* The limit of the dmap region */ > vm_offset_t dmap_max_addr; /* The virtual address limit of the dmap */ >+struct direct_map_desc dmap_desc[MAX_DMAP_ENTRIES]; > > extern pt_entry_t pagetable_l0_ttbr1[]; > >@@ -1156,6 +1157,7 @@ pmap_bootstrap_l3_page(struct pmap_bootstrap_state *state, int i) > static void > pmap_bootstrap_dmap(vm_paddr_t min_pa) > { >+ int dmap_desc_idx; > int i; > > dmap_phys_base = min_pa & ~L1_OFFSET; >@@ -1166,6 +1168,12 @@ pmap_bootstrap_dmap(vm_paddr_t min_pa) > bs_state.pa = physmap[i] & ~L3_OFFSET; > bs_state.va = bs_state.pa - dmap_phys_base + DMAP_MIN_ADDRESS; > >+ dmap_desc_idx = i / 2; >+ dmap_desc[dmap_desc_idx].pa_start = bs_state.pa; >+ dmap_desc[dmap_desc_idx].va_start = bs_state.va; >+ dmap_desc[dmap_desc_idx].size = physmap[i + 1] - dmap_desc[dmap_desc_idx].pa_start; >+ dmap_desc[dmap_desc_idx].flags = DMAP_FLAG_VALID; >+ > /* Create L3 mappings at the start of the region */ > if ((bs_state.pa & L2_OFFSET) != 0) > pmap_bootstrap_l3_page(&bs_state, i); >diff --git a/sys/arm64/include/vmparam.h b/sys/arm64/include/vmparam.h >index d5d4a5691f37..b2775482c6c6 100644 >--- a/sys/arm64/include/vmparam.h >+++ b/sys/arm64/include/vmparam.h >@@ -178,6 +178,21 @@ > * VM_MIN_USER_ADDRESS and VM_MAX_USER_ADDRESS define the start and end of the > * user address space. > */ >+ >+#ifndef LOCORE >+#define DMAP_FLAG_VALID (0x1) >+ >+#define MAX_DMAP_ENTRIES 64 >+struct direct_map_desc { >+ uint64_t pa_start; >+ uint64_t va_start; >+ uint64_t size; >+ uint64_t flags; >+}; >+ >+extern struct direct_map_desc dmap_desc[]; >+#endif >+ > #define VM_MIN_ADDRESS (0x0000000000000000UL) > #define VM_MAX_ADDRESS (0xffffffffffffffffUL) > >@@ -223,12 +238,41 @@ > #define DMAP_MIN_PHYSADDR (dmap_phys_base) > #define DMAP_MAX_PHYSADDR (dmap_phys_max) > >-/* True if pa is in the dmap range */ >-#define PHYS_IN_DMAP(pa) ((pa) >= DMAP_MIN_PHYSADDR && \ >- (pa) < DMAP_MAX_PHYSADDR) >-/* True if va is in the dmap range */ >-#define VIRT_IN_DMAP(va) ((va) >= DMAP_MIN_ADDRESS && \ >- (va) < (dmap_max_addr)) >+#ifndef LOCORE >+static inline int >+PHYS_IN_DMAP(uint64_t pa) >+{ >+ struct direct_map_desc *desc; >diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c >index ba72f1dac8d0..e44d07e25002 100644 >--- a/sys/arm64/arm64/pmap.c >+++ b/sys/arm64/arm64/pmap.c >@@ -342,6 +342,7 @@ struct pv_chunks_list __exclusive_cache_line pv_chunks[PMAP_MEMDOM]; > vm_paddr_t dmap_phys_base; /* The start of the dmap region */ > vm_paddr_t dmap_phys_max; /* The limit of the dmap region */ > vm_offset_t dmap_max_addr; /* The virtual address limit of the dmap */ >+struct direct_map_desc dmap_desc[MAX_DMAP_ENTRIES]; > > extern pt_entry_t pagetable_l0_ttbr1[]; > >@@ -1156,6 +1157,7 @@ pmap_bootstrap_l3_page(struct pmap_bootstrap_state *state, int i) > static void > pmap_bootstrap_dmap(vm_paddr_t min_pa) > { >+ int dmap_desc_idx; > int i; > > dmap_phys_base = min_pa & ~L1_OFFSET; >@@ -1166,6 +1168,12 @@ pmap_bootstrap_dmap(vm_paddr_t min_pa) > bs_state.pa = physmap[i] & ~L3_OFFSET; > bs_state.va = bs_state.pa - dmap_phys_base + DMAP_MIN_ADDRESS; > >+ dmap_desc_idx = i / 2; >+ dmap_desc[dmap_desc_idx].pa_start = bs_state.pa; >+ dmap_desc[dmap_desc_idx].va_start = bs_state.va; >+ dmap_desc[dmap_desc_idx].size = physmap[i + 1] - dmap_desc[dmap_desc_idx].pa_start; >+ dmap_desc[dmap_desc_idx].flags = DMAP_FLAG_VALID; >+ > /* Create L3 mappings at the start of the region */ > if ((bs_state.pa & L2_OFFSET) != 0) > pmap_bootstrap_l3_page(&bs_state, i); >diff --git a/sys/arm64/include/vmparam.h b/sys/arm64/include/vmparam.h >index d5d4a5691f37..b2775482c6c6 100644 >--- a/sys/arm64/include/vmparam.h >+++ b/sys/arm64/include/vmparam.h >@@ -178,6 +178,21 @@ > * VM_MIN_USER_ADDRESS and VM_MAX_USER_ADDRESS define the start and end of the > * user address space. > */ >+ >+#ifndef LOCORE >+#define DMAP_FLAG_VALID (0x1) >+ >+#define MAX_DMAP_ENTRIES 64 >+struct direct_map_desc { >+ uint64_t pa_start; >+ uint64_t va_start; >+ uint64_t size; >+ uint64_t flags; >+}; >+ >+extern struct direct_map_desc dmap_desc[]; >+#endif >+ > #define VM_MIN_ADDRESS (0x0000000000000000UL) > #define VM_MAX_ADDRESS (0xffffffffffffffffUL) > >@@ -223,12 +238,41 @@ > #define DMAP_MIN_PHYSADDR (dmap_phys_base) > #define DMAP_MAX_PHYSADDR (dmap_phys_max) > >-/* True if pa is in the dmap range */ >-#define PHYS_IN_DMAP(pa) ((pa) >= DMAP_MIN_PHYSADDR && \ >- (pa) < DMAP_MAX_PHYSADDR) >-/* True if va is in the dmap range */ >-#define VIRT_IN_DMAP(va) ((va) >= DMAP_MIN_ADDRESS && \ >- (va) < (dmap_max_addr)) >+#ifndef LOCORE >+static inline int >+PHYS_IN_DMAP(uint64_t pa) >+{ >+ struct direct_map_desc *desc; >+ int a; >+ >+ for (a = 0; a < MAX_DMAP_ENTRIES; a++) { >+ desc = &dmap_desc[a]; >+ if (desc->flags == DMAP_FLAG_VALID) { >+ if (pa >= desc->pa_start && pa <= desc->pa_start + desc->size) >+ return (1); >+ } >+ } >+ >+ return (0); >+} >+ >+static inline int >+VIRT_IN_DMAP(uint64_t va) >+{ >+ struct direct_map_desc *desc; >+ int a; >+ >+ for (a = 0; a < MAX_DMAP_ENTRIES; a++) { >+ desc = &dmap_desc[a]; >+ if (desc->flags == DMAP_FLAG_VALID) { >+ if (va >= desc->va_start && va <= desc->va_start + desc->size) >+ return (1); >+ } >+ } >+ >+ return (0); >+} >+#endif > > #define PMAP_HAS_DMAP 1 > #define PHYS_TO_DMAP(pa) \
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 278233
:
249802
|
249803