From nobody Wed Jan 03 20:45:35 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T51vN26Bvz56fkX; Wed, 3 Jan 2024 20:45:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T51vM60QQz4PMR; Wed, 3 Jan 2024 20:45:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704314735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nlB0uatRuDhQw7GSA0rnFAQizxJsUE8tteVmr8uoGI0=; b=Qs0r4wEYXZz5lfbnxVBLJvPBFfpA5Gy3xW60uarF8Z+6Zead9WG/Xn4s1i8qynvR7oZWvO RTbQoFNy76QdS6wIDbEArl51zyj3OxMwU645SO3DqEMQTATB2XpIN9gJltdiOuqFfYSxQz OCtU+DBJAv5sdi8bIksmv9HRkPlF8lDL1hhcfP/n13IAYdT6+4EqCJO4lhVNz/GaaxBc+Q NQybuPrCYl8nomXyx7BrwOdN4mrxegP8Kqvp8OUk3UGG6lHs9uPG54HEhl1XutBt+G1g/g taHnvl+I4Y+2SdRhdi7Y68c4eqePIQDAI1Sz83Ja2P6IoOVZMQBpQlB02AAttg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704314735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nlB0uatRuDhQw7GSA0rnFAQizxJsUE8tteVmr8uoGI0=; b=SMPq5Q8dvjct4R2G1O2QqZv/zvGraqDxuVXRfGiXz4t0Y0x9fCoLkcL+GhzdDxhi2St3pm XlCEIsjkIxs+OKPkffpHYv7jdFExej0l3kODlGtiskSVrX9tSaI/OsruH3BFyzcYuvjMLD DSHSIub/9X0EON57Dp+aW5DLhRlZwCN9jC5cdKEvOXUIRBwpV+YxQwP74BQkeWyrXvL5cT sLaa/ybqs7LtgnOlbvowTsv3wLciokQaMewB5VcaWhfCQd9Ucy6UzEuypq/MxTqzdBtIp7 dTjae4X7oAniMnzrjJRkOHm7hdZ107TMRL1O8m6zPulk5YZzCmZMu3zG6f2sPA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704314735; a=rsa-sha256; cv=none; b=hG5ER9Eft8JD96L/Q+8bkAjeiLnQWS0+2BNcXUMrsPHtbGAI7cWykaRaDS4WmWa3l5S4hO 1G2qgZvG2XRmLAZNeZrpKqHGda1knXX3IA8lK1CY4Ka9/8OcYzWm1BWxscB37RTRgBkITi 7RiW/L/L9pKcSdC5Tcrr6P1A6pucAO2MLEMCGq4ac/BmXq6MfkzGJ+I0RuO7baMdfWQdaT mhULqNKpdLe7/YOem7GBYH15kOhZIh7o9kzwnoqvEWxhkDOoekVULEzAnznXkSAAQN9rSy 2tRlhH9+m2gBnm2GaVG/BC4NT7UDIGexvY0m+KdZi5afU0Hy+ve3PxgkM0AQwA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T51vM56Msz10yg; Wed, 3 Jan 2024 20:45:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 403KjZQV037438; Wed, 3 Jan 2024 20:45:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 403KjZBV037435; Wed, 3 Jan 2024 20:45:35 GMT (envelope-from git) Date: Wed, 3 Jan 2024 20:45:35 GMT Message-Id: <202401032045.403KjZBV037435@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 3125b3e82c73 - stable/14 - nexus: Use resource_validate_map_request List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 3125b3e82c732c65c4e0f3dd230b10e9b21e3af8 Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=3125b3e82c732c65c4e0f3dd230b10e9b21e3af8 commit 3125b3e82c732c65c4e0f3dd230b10e9b21e3af8 Author: John Baldwin AuthorDate: 2023-11-23 17:06:37 +0000 Commit: John Baldwin CommitDate: 2024-01-03 20:34:20 +0000 nexus: Use resource_validate_map_request Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D42724 (cherry picked from commit b887b665ebc044f246d261e8af543765b846ed38) --- sys/arm64/arm64/nexus.c | 18 +++++------------- sys/powerpc/powerpc/nexus.c | 22 +++++----------------- sys/riscv/riscv/nexus.c | 18 +++++------------- sys/x86/x86/nexus.c | 18 +++++------------- 4 files changed, 20 insertions(+), 56 deletions(-) diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c index 2394ad912391..25d23f74d92b 100644 --- a/sys/arm64/arm64/nexus.c +++ b/sys/arm64/arm64/nexus.c @@ -460,7 +460,8 @@ 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) == 0) @@ -476,18 +477,9 @@ nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, } 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 index 03f16dfa9de0..c5f460baf44e 100644 --- a/sys/powerpc/powerpc/nexus.c +++ b/sys/powerpc/powerpc/nexus.c @@ -353,9 +353,9 @@ static int 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 @@ nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, } 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 index 2e693e6cf655..936db3e548e9 100644 --- a/sys/riscv/riscv/nexus.c +++ b/sys/riscv/riscv/nexus.c @@ -424,7 +424,8 @@ 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) == 0) @@ -440,18 +441,9 @@ nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, } 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 index 4896271b92bd..54c655c4fafd 100644 --- a/sys/x86/x86/nexus.c +++ b/sys/x86/x86/nexus.c @@ -458,7 +458,8 @@ 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)) @@ -474,18 +475,9 @@ nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, } 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.