Message ID | luc7dpd4iag4nh4wvdhcfab34b2tcpryai3hgy22k3xmgvhyy7@xeglttypvlsf (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <intel-gfx-bounces@lists.freedesktop.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF761D1359C for <intel-gfx@archiver.kernel.org>; Mon, 28 Oct 2024 12:19:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9059C10E485; Mon, 28 Oct 2024 12:19:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="BXdipoLQ"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 87A3310E485 for <intel-gfx@lists.freedesktop.org>; Mon, 28 Oct 2024 12:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730117950; x=1761653950; h=date:from:to:cc:subject:message-id:mime-version; bh=AK77oxGtIoDHtcdZ+BoKeGpX90iiHLVQWxMC8rFl9+0=; b=BXdipoLQJaorf94S7UZ72/Sv4vCXenhaMFmirRfbkDy/st9Orisd+lIN os81qcpT8Bd7cuxHlx4fuE38LUv9BlUUA7LZzM7Qta8I+CP8nE15q5sB2 ZuC08AKt2omMd5DqGyG16X4BR6xLb/kOTsL5aManAq7QmG1pCxrIucXia pmPRfLpkmpwjIcegscz+QXeqTskKLL6hGN3S7D8niRIa6ZunX8zL0SYR4 ArVoPr1suEXkfBWjTIoOzdsvXrjH8mL+F2idlyPidV3gQMuGtvg3QGYyO yQYFtbI/GCeGvb0mQ07/94bhL9/JF7o6e4Mk78Ot6SbpCTbtm7H/hVH7v A==; X-CSE-ConnectionGUID: fjdi3MWBR5Go21RAUnN5+Q== X-CSE-MsgGUID: CdozLL+TQx2LEYWUGjRJsA== X-IronPort-AV: E=McAfee;i="6700,10204,11238"; a="40331557" X-IronPort-AV: E=Sophos;i="6.11,239,1725346800"; d="scan'208";a="40331557" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2024 05:19:10 -0700 X-CSE-ConnectionGUID: TJWN31ppQPGGFOTXZuOabA== X-CSE-MsgGUID: Z049//RxQgy8H4nemBye8Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,239,1725346800"; d="scan'208";a="81501636" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orviesa010.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 28 Oct 2024 05:19:10 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 28 Oct 2024 05:19:09 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Mon, 28 Oct 2024 05:19:09 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.171) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 28 Oct 2024 05:19:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vFn8L6fdHPUOWImw+WFTwaySBR1eRbX+qhod0Y11fW1xV6vg6FDiweYtY0Z0hlqwbQUQ+MlD/Cje9XApN2Zmw55rylpTJ7s3hB2fn1pGcwlNG/8CmbQUMmU1zV9h26Vq8f+MHm5pyJ2cokbQbt2jmLBeb8Xmtei1cpj/Im5J+E0SJdks9b8NM0XETl3WT+B6qTMqR7YjS0QA0QX7yIOT6pINxDUmBd9lNhXsQ80I5PIhnnjKflDIZJZD19RoQPe0cTVWQWklQlTp0KlgVZdUDZtW4el12CLtSpFvzDTQpzI+QXmkZzd9/dApDZFDvjnwoG7B1kTTvahoGfwCaapS1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Dv417JUXG3g1rqEQ1jay+zBepKw8COR7q3JKtJoHgYY=; b=IgaRSJLF9PvPAqndqQAc9cz9xRg5vXnC4AE27GPJ1dpiBRjgHIjghwibjZXjEGCp8PsrHRCNM1ClwJzRSgzrXvEf5CbvTXxdRrKrcb4XAaf/K84qWircnf+N1U0IOrGUivz+QuWlEBzH28+zTNhLgOol18O1S0BTsfr2j+Ap06CboXOaaZJHQF67HQcmixNMa2buGZUjb9XYxPqDjPmoeu8UueLr71kvqlzSxYimZPqqMjEO8lAnitjvLKbDoye30F6KCsE0aCsuIT1WtsXUvyJanxx3AKLtB4wL/6may2T4Krbp0R6wWmb70bUo72Eq3HNU/+YRmjBY18AFStIiiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from CO1PR11MB5057.namprd11.prod.outlook.com (2603:10b6:303:6c::15) by MW4PR11MB6737.namprd11.prod.outlook.com (2603:10b6:303:20d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Mon, 28 Oct 2024 12:19:04 +0000 Received: from CO1PR11MB5057.namprd11.prod.outlook.com ([fe80::4610:6d6c:9af6:2548]) by CO1PR11MB5057.namprd11.prod.outlook.com ([fe80::4610:6d6c:9af6:2548%7]) with mapi id 15.20.8093.023; Mon, 28 Oct 2024 12:19:04 +0000 Date: Mon, 28 Oct 2024 12:18:55 +0000 From: Krzysztof Karas <krzysztof.karas@intel.com> To: <intel-gfx@lists.freedesktop.org> CC: Andi Shyti <andi.shyti@linux.intel.com> Subject: [PATCH v3] drm/i915: ensure segment offset never exceeds allowed max Message-ID: <luc7dpd4iag4nh4wvdhcfab34b2tcpryai3hgy22k3xmgvhyy7@xeglttypvlsf> "Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316" Content-Type: text/plain; charset="utf-8" Content-Disposition: inline X-ClientProxiedBy: DU7P250CA0006.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:54f::21) To CO1PR11MB5057.namprd11.prod.outlook.com (2603:10b6:303:6c::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR11MB5057:EE_|MW4PR11MB6737:EE_ X-MS-Office365-Filtering-Correlation-Id: e348937b-05aa-4b1a-5dca-08dcf74ab6a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|27256017; X-Microsoft-Antispam-Message-Info: =?utf-8?q?mTcQieomrEcSHCelC9QZgG5fjv/Z4lY?= =?utf-8?q?wGPX//iMs2Oc5A3KJlZiKUJ8cY/Bd83slV8dJqu9MNp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=?utf-8?q?mSGeLr2G9LQ3CCtVpVxF3GyJXgIh5GwkNhZhacD/4EqlSQSkkp21m1nyMwEx/n/sh?= =?utf-8?q?Ag0KQuat6VQ05gs3llpj3lv3jMb3DhPMAyrSp0nSDg3arMXV0l1rLKnnnc2zD6K62?= =?utf-8?q?CeVdEYjqHGR4gB9P4H+8r6qNiu48LDNgs07BqtAgfRukuJyFHnywV8naXdNqwpWLC?= =?utf-8?q?IDQPjzG1jzw+kovrMjN0sLxrexvUStKmS4j04Sy+7Tvn0VThFXVD98fb02vw9YXM8?= =?utf-8?q?zVmWKZyD3g6/kY/woJoXauNGNAUJRX3+RSjeONncHuySPVEFFZj+F8DPl99eNWfFr?= =?utf-8?q?qhI6vV9kGMALdDPkJnPdRtLXhysOOOJTSYSFaFiVmfpRNSpU6gzgZ514=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO1PR11MB5057.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(27256017); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?383RmH0fEc4tilHpSw7Dq7Zp6uqE?= =?utf-8?q?ascrc4OPLa1kGt635mGC9G800b8ieDLXhDWlAyCeWzDBwTT9WWZ9mIx2I0aBJCeMl?= =?utf-8?q?gIb0wvgpih2sNE+mfOB2DsvEPMRcZYPDlI2O7BzucJnnqQ3J9sK3iwe0fVBgymQo/?= =?utf-8?q?KzynrY3hfeHg/ataLNapXiFJb/GlglQH147y0A9GknTl2U3zdIXwnPY3soygXTRMG?= =?utf-8?q?XjG241eQj/GnjyDOq1Sl+s1372KZFHyfCkWMWI7fP22lW00uh4tRXr5eK+O9eW2An?= =?utf-8?q?xnuHuo7gWM2CuyHJ8o7/O8wGcs0l83vMmw+/B0cxsk2NEM8pUH0B1YeCGo8vM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?q?5EwSE6YYW77fDvQJSHhOqgcteg5zlfNliq3qIfe33mq7LocnmywqZbApQK8vbDoHk?= =?utf-8?q?3EWJwO+FexhIBIJrgISldOkOu24O0mlnolXAtllJGAgisKi+zjo7Y75PRYXSzxVek?= =?utf-8?q?T4MIKQIcFRIVoNkpAwcMWTtzRVbmwgDnJ6XUqWQsx0osS9v5jVHBjKU85LHvRe3J4?= =?utf-8?q?sEQyb2cKRzA6ptF/79N/xMM7IZ4KFUWziyhvLaVJl4qD6WRNviZYTKsexGP4Z6zyQ?= =?utf-8?q?jQ10ls/u+XJaB7zkPxJ7wQbVpC/XDJySs+jT4QMWh1U3RMIxNCNYNWCwGSlrMLUQJ?= =?utf-8?q?plppDVSc2ryexeOrr/5us68RSwMqt4a/Rg=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: e348937b-05aa-4b1a-5dca-08dcf74ab6a7 X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB5057.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 12:19:04.6114 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: A92VmXZS7v3KQfI7SjVvKwwGulH/O1BOwbmVqICDqg4wiL2wd7ZFycvCWRPLs7j3lv7WITOoFl1cwVXJ2DPfdKhMtIuF4s01p5VuOBQtQcY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB6737 X-OriginatorOrg: intel.com X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development <intel-gfx.lists.freedesktop.org> List-Unsubscribe: <https://lists.freedesktop.org/mailman/options/intel-gfx>, <mailto:intel-gfx-request@lists.freedesktop.org?subject=unsubscribe> List-Archive: <https://lists.freedesktop.org/archives/intel-gfx> List-Post: <mailto:intel-gfx@lists.freedesktop.org> List-Help: <mailto:intel-gfx-request@lists.freedesktop.org?subject=help> List-Subscribe: <https://lists.freedesktop.org/mailman/listinfo/intel-gfx>, <mailto:intel-gfx-request@lists.freedesktop.org?subject=subscribe> Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" <intel-gfx-bounces@lists.freedesktop.org> |
Series |
[v3] drm/i915: ensure segment offset never exceeds allowed max
|
expand
|
diff --git a/drivers/gpu/drm/i915/i915_mm.c b/drivers/gpu/drm/i915/i915_mm.c index 8a2779191f18..3723291f2fef 100644 --- a/drivers/gpu/drm/i915/i915_mm.c +++ b/drivers/gpu/drm/i915/i915_mm.c @@ -143,8 +143,8 @@ int remap_io_sg(struct vm_area_struct *vma, /* We rely on prevalidation of the io-mapping to skip track_pfn(). */ GEM_BUG_ON((vma->vm_flags & EXPECTED_FLAGS) != EXPECTED_FLAGS); - while (offset >= sg_dma_len(r.sgt.sgp) >> PAGE_SHIFT) { - offset -= sg_dma_len(r.sgt.sgp) >> PAGE_SHIFT; + while (offset >= r.sgt.max >> PAGE_SHIFT) { + offset -= r.sgt.max >> PAGE_SHIFT; r.sgt = __sgt_iter(__sg_next(r.sgt.sgp), use_dma(iobase)); if (GEM_WARN_ON(!r.sgt.sgp)) return -EINVAL;
Commit 255fc1703e42 ("drm/i915/gem: Calculate object page offset for partial memory mapping") introduced a new offset that is compared to sg_dma_len(r.sgt.sgp) in remap_io_sg() function. However, later in remap_sg() the offset (which at that point resides in r->sgt.curr) is compared to r->sgt.max. Scatter-gather list's max relies on one of two values (see i915_scatterlist.h): a) sg_dma_len(s.sgp) when `dma` is true, b) s.sgp->length otherwise. This suggests that in cases where `dma` is false, we should use s.sgp->length to determine the max value instead of sg_dma_len(), which is used regardless in remap_io_sg() (use_dma(iobase) might return false there). This patch uses r.sgt.max to check if offset is within allowed bounds, because that max value is already set according to the `dma` setting. v3: - instead of checking if r.sgt.curr would exceed allowed max, changed the value in the while loop to be aligned with `dma` value. Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com> --- drivers/gpu/drm/i915/i915_mm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)