Page MenuHomeFreeBSD

D42724.diff
No OneTemporary

D42724.diff

diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c
--- a/sys/arm64/arm64/nexus.c
+++ b/sys/arm64/arm64/nexus.c
@@ -462,7 +462,8 @@
struct resource_map_request *argsp, struct resource_map *map)
{
struct resource_map_request args;
- rman_res_t end, length, start;
+ rman_res_t length, start;
+ int error;
/* Resources must be active to be mapped. */
if ((rman_get_flags(r) & RF_ACTIVE) == 0)
@@ -478,18 +479,9 @@
}
resource_init_map_request(&args);
- if (argsp != NULL)
- bcopy(argsp, &args, imin(argsp->size, args.size));
- start = rman_get_start(r) + args.offset;
- if (args.length == 0)
- length = rman_get_size(r);
- else
- length = args.length;
- end = start + length - 1;
- if (start > rman_get_end(r) || start < rman_get_start(r))
- return (EINVAL);
- if (end > rman_get_end(r) || end < start)
- return (EINVAL);
+ error = resource_validate_map_request(r, argsp, &args, &start, &length);
+ if (error)
+ return (error);
map->r_vaddr = pmap_mapdev_attr(start, length, args.memattr);
map->r_bustag = &memmap_bus;
diff --git a/sys/powerpc/powerpc/nexus.c b/sys/powerpc/powerpc/nexus.c
--- a/sys/powerpc/powerpc/nexus.c
+++ b/sys/powerpc/powerpc/nexus.c
@@ -353,9 +353,9 @@
nexus_map_resource(device_t bus, device_t child, int type, struct resource *r,
struct resource_map_request *argsp, struct resource_map *map)
{
-
struct resource_map_request args;
- rman_res_t end, length, start;
+ rman_res_t length, start;
+ int error;
/* Resources must be active to be mapped. */
if (!(rman_get_flags(r) & RF_ACTIVE))
@@ -371,21 +371,9 @@
}
resource_init_map_request(&args);
- if (argsp != NULL)
- bcopy(argsp, &args, imin(argsp->size, args.size));
-
- start = rman_get_start(r) + args.offset;
- if (args.length == 0)
- length = rman_get_size(r);
- else
- length = args.length;
-
- end = start + length - 1;
- if (start > rman_get_end(r) || start < rman_get_start(r))
- return (EINVAL);
-
- if (end > rman_get_end(r) || end < start)
- return (EINVAL);
+ error = resource_validate_map_request(r, argsp, &args, &start, &length);
+ if (error)
+ return (error);
/*
* If this is a memory resource, map it into the kernel.
diff --git a/sys/riscv/riscv/nexus.c b/sys/riscv/riscv/nexus.c
--- a/sys/riscv/riscv/nexus.c
+++ b/sys/riscv/riscv/nexus.c
@@ -424,7 +424,8 @@
struct resource_map_request *argsp, struct resource_map *map)
{
struct resource_map_request args;
- rman_res_t end, length, start;
+ rman_res_t length, start;
+ int error;
/* Resources must be active to be mapped. */
if ((rman_get_flags(r) & RF_ACTIVE) == 0)
@@ -440,18 +441,9 @@
}
resource_init_map_request(&args);
- if (argsp != NULL)
- bcopy(argsp, &args, imin(argsp->size, args.size));
- start = rman_get_start(r) + args.offset;
- if (args.length == 0)
- length = rman_get_size(r);
- else
- length = args.length;
- end = start + length - 1;
- if (start > rman_get_end(r) || start < rman_get_start(r))
- return (EINVAL);
- if (end > rman_get_end(r) || end < start)
- return (EINVAL);
+ error = resource_validate_map_request(r, argsp, &args, &start, &length);
+ if (error)
+ return (error);
map->r_vaddr = pmap_mapdev(start, length);
map->r_bustag = &memmap_bus;
diff --git a/sys/x86/x86/nexus.c b/sys/x86/x86/nexus.c
--- a/sys/x86/x86/nexus.c
+++ b/sys/x86/x86/nexus.c
@@ -458,7 +458,8 @@
struct resource_map_request *argsp, struct resource_map *map)
{
struct resource_map_request args;
- rman_res_t end, length, start;
+ rman_res_t length, start;
+ int error;
/* Resources must be active to be mapped. */
if (!(rman_get_flags(r) & RF_ACTIVE))
@@ -474,18 +475,9 @@
}
resource_init_map_request(&args);
- if (argsp != NULL)
- bcopy(argsp, &args, imin(argsp->size, args.size));
- start = rman_get_start(r) + args.offset;
- if (args.length == 0)
- length = rman_get_size(r);
- else
- length = args.length;
- end = start + length - 1;
- if (start > rman_get_end(r) || start < rman_get_start(r))
- return (EINVAL);
- if (end > rman_get_end(r) || end < start)
- return (EINVAL);
+ error = resource_validate_map_request(r, argsp, &args, &start, &length);
+ if (error)
+ return (error);
/*
* If this is a memory resource, map it into the kernel.

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 4:26 AM (21 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14689771
Default Alt Text
D42724.diff (4 KB)

Event Timeline