Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F140537821
D40244.id122709.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D40244.id122709.diff
View Options
diff --git a/sys/amd64/amd64/efirt_machdep.c b/sys/amd64/amd64/efirt_machdep.c
--- a/sys/amd64/amd64/efirt_machdep.c
+++ b/sys/amd64/amd64/efirt_machdep.c
@@ -92,12 +92,12 @@
* indicate a failed mapping so that the caller may handle error.
*/
vm_offset_t
-efi_phys_to_kva(vm_paddr_t paddr)
+efi_phys_to_kva(vm_paddr_t paddr, vm_size_t size)
{
- if (paddr >= dmaplimit)
- return (0);
- return (PHYS_TO_DMAP(paddr));
+ if (PHYS_IN_DMAP(paddr) && PHYS_SZ_IN_DMAP(paddr, size))
+ return (PHYS_TO_DMAP(paddr));
+ return (0);
}
static vm_page_t
diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h
--- a/sys/amd64/include/vmparam.h
+++ b/sys/amd64/include/vmparam.h
@@ -244,6 +244,7 @@
* vt fb startup needs to be reworked.
*/
#define PHYS_IN_DMAP(pa) (dmaplimit == 0 || (pa) < dmaplimit)
+#define PHYS_SZ_IN_DMAP(pa, sz) PHYS_IN_DMAP((pa) + (sz))
#define VIRT_IN_DMAP(va) ((va) >= DMAP_MIN_ADDRESS && \
(va) < (DMAP_MIN_ADDRESS + dmaplimit))
diff --git a/sys/arm64/arm64/efirt_machdep.c b/sys/arm64/arm64/efirt_machdep.c
--- a/sys/arm64/arm64/efirt_machdep.c
+++ b/sys/arm64/arm64/efirt_machdep.c
@@ -148,11 +148,11 @@
* indicate a failed mapping so that the caller may handle error.
*/
vm_offset_t
-efi_phys_to_kva(vm_paddr_t paddr)
+efi_phys_to_kva(vm_paddr_t paddr, vm_size_t size)
{
vm_offset_t vaddr;
- if (PHYS_IN_DMAP(paddr)) {
+ if (PHYS_IN_DMAP(paddr) && PHYS_SZ_IN_DMAP(paddr, size)) {
vaddr = PHYS_TO_DMAP(paddr);
if (pmap_klookup(vaddr, NULL))
return (vaddr);
diff --git a/sys/arm64/include/vmparam.h b/sys/arm64/include/vmparam.h
--- a/sys/arm64/include/vmparam.h
+++ b/sys/arm64/include/vmparam.h
@@ -192,6 +192,7 @@
/* True if pa is in the dmap range */
#define PHYS_IN_DMAP(pa) ((pa) >= DMAP_MIN_PHYSADDR && \
(pa) < DMAP_MAX_PHYSADDR)
+#define PHYS_SZ_IN_DMAP(pa, sz) PHYS_IN_DMAP((pa) + (sz))
/* True if va is in the dmap range */
#define VIRT_IN_DMAP(va) ((va) >= DMAP_MIN_ADDRESS && \
(va) < (dmap_max_addr))
diff --git a/sys/dev/efidev/efirt.c b/sys/dev/efidev/efirt.c
--- a/sys/dev/efidev/efirt.c
+++ b/sys/dev/efidev/efirt.c
@@ -185,7 +185,8 @@
return (0);
}
- efi_systbl = (struct efi_systbl *)efi_phys_to_kva(efi_systbl_phys);
+ efi_systbl = (struct efi_systbl *)efi_phys_to_kva(efi_systbl_phys,
+ sizeof(struct efi_systbl));
if (efi_systbl == NULL || efi_systbl->st_hdr.th_sig != EFI_SYSTBL_SIG) {
efi_systbl = NULL;
if (bootverbose)
@@ -239,7 +240,8 @@
* with an old loader.efi, check if the RS->GetTime function is within
* the EFI map, and fail to attach if not.
*/
- rtdm = (struct efi_rt *)efi_phys_to_kva((uintptr_t)efi_runtime);
+ rtdm = (struct efi_rt *)efi_phys_to_kva((uintptr_t)efi_runtime,
+ sizeof(struct efi_rt));
if (rtdm == NULL || !efi_is_in_map(map, ndesc, efihdr->descriptor_size,
(vm_offset_t)rtdm->rt_gettime)) {
if (bootverbose)
@@ -534,7 +536,7 @@
#define EFI_RT_METHOD_PA(method) \
((uintptr_t)((struct efi_rt *)efi_phys_to_kva((uintptr_t) \
- efi_runtime))->method)
+ efi_runtime, sizeof(struct efi_rt)))->method)
static int
efi_get_time_locked(struct efi_tm *tm, struct efi_tmcap *tmcap)
diff --git a/sys/sys/efi.h b/sys/sys/efi.h
--- a/sys/sys/efi.h
+++ b/sys/sys/efi.h
@@ -236,7 +236,7 @@
/* Internal MD EFI functions */
int efi_arch_enter(void);
void efi_arch_leave(void);
-vm_offset_t efi_phys_to_kva(vm_paddr_t);
+vm_offset_t efi_phys_to_kva(vm_paddr_t, vm_size_t);
int efi_rt_arch_call(struct efirt_callinfo *);
bool efi_create_1t1_map(struct efi_md *, int, int);
void efi_destroy_1t1_map(void);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 26, 12:36 AM (2 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27270297
Default Alt Text
D40244.id122709.diff (3 KB)
Attached To
Mode
D40244: efi: Update efi_phys_to_kva to accept the size of the object being mapped.
Attached
Detach File
Event Timeline
Log In to Comment