git: deb1e3b71998 - main - physmem: Add physmem_excluded to query if a region is excluded
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 25 Oct 2022 15:33:04 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=deb1e3b719985466b0cc84825846519acdd0a2e7 commit deb1e3b719985466b0cc84825846519acdd0a2e7 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2022-10-06 03:55:26 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2022-10-25 15:32:49 +0000 physmem: Add physmem_excluded to query if a region is excluded In order to safely reuse excluded memory when it's reserved for special purpose, we need to test whether or not the memory has been reserved early in boot. physmem_excluded will return true when the entire range is excluded, false otherwise. Sponsored by: Netflix --- sys/kern/subr_physmem.c | 14 ++++++++++++++ sys/sys/physmem.h | 1 + 2 files changed, 15 insertions(+) diff --git a/sys/kern/subr_physmem.c b/sys/kern/subr_physmem.c index 5caff7da4f50..498ad2440f40 100644 --- a/sys/kern/subr_physmem.c +++ b/sys/kern/subr_physmem.c @@ -483,6 +483,20 @@ physmem_avail(vm_paddr_t *avail, size_t maxavail) return (regions_to_avail(avail, EXFLAG_NOALLOC, maxavail, 0, NULL, NULL)); } +bool +physmem_excluded(vm_paddr_t pa, vm_size_t sz) +{ + const struct region *exp; + size_t exi; + + for (exi = 0, exp = exregions; exi < excnt; ++exi, ++exp) { + if (pa < exp->addr || pa + sz > exp->addr + exp->size) + continue; + return (true); + } + return (false); +} + #ifdef _KERNEL /* * Process all the regions added earlier into the global avail lists. diff --git a/sys/sys/physmem.h b/sys/sys/physmem.h index f9ba69228c95..dcf12b589d05 100644 --- a/sys/sys/physmem.h +++ b/sys/sys/physmem.h @@ -54,6 +54,7 @@ void physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t flags); size_t physmem_avail(vm_paddr_t *avail, size_t maxavail); void physmem_init_kernel_globals(void); void physmem_print_tables(void); +bool physmem_excluded(vm_paddr_t pa, vm_size_t sz); /* * Convenience routines for FDT.