Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp757864rdb; Thu, 22 Feb 2024 21:00:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUmDDpTCsbSwgN4iFye8rqS/N1ez2xJRQjngp0arkPOkC0zs0UWnw6sT0VQyIq11x/mK2lwK2Wq0/y00bWIXpDpPeTd4JIfUzCw4zP/lg== X-Google-Smtp-Source: AGHT+IFt73JhwTBDARDLCBV2FTXVPATfkrkHhPiTvHT8caISGX42RmdTRm8k1H1hOmqyPhLu23c7 X-Received: by 2002:a05:620a:222b:b0:787:1ccd:feda with SMTP id n11-20020a05620a222b00b007871ccdfedamr1065817qkh.77.1708664426609; Thu, 22 Feb 2024 21:00:26 -0800 (PST) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id qr22-20020a05620a391600b00785d9bbb481si15983481qkn.627.2024.02.22.21.00.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 21:00:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LsYLGvsm; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-77776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CD4DB1C22BA7 for ; Fri, 23 Feb 2024 05:00:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DAC8E11705; Fri, 23 Feb 2024 05:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LsYLGvsm" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 303FBBA30; Fri, 23 Feb 2024 05:00:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.12 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708664413; cv=fail; b=N+ssoJhNbbvz+FXhs5Bnfstj8Za+5r4P52oKEsPB7DO8nJnAp4RQlWDGgAUAhc+cWDJ35GIod4JoHsbg5WRdRS55tj2bGRsAGljFVJ9XWileJ1Ef2rPM4GrJ0O7l1UYOkKjnRjC0JUkJZd49hO2l2FvSdYhDT1pG89/i21X7zFY= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708664413; c=relaxed/simple; bh=Gh8fMymxW8zAqfjnXoXhzOr2reTUfUHKzgPAUg8RKQg=; h=Date:From:To:CC:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=dFF3SBhQVUDVOHiAAEufpSSOTcnWNzGiLvH5qZWVT9Fo1Ooxgb1fNk4xnVyvIQD22vNL3h0aiGRgwsyeBjo3OjFLGCmETw4emjLCMLNLwVyJVAf16YsoOz9js0j9MQnu+G4vtzJ0ilP29dkYSeAIOsVk7BhR4f2iDCjJPU9Vc7Y= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=LsYLGvsm; arc=fail smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708664411; x=1740200411; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=Gh8fMymxW8zAqfjnXoXhzOr2reTUfUHKzgPAUg8RKQg=; b=LsYLGvsm639k4XAlXpK3MOa8xpbhxspke2Euz6ZqQReRnHx6BvK1/sHH Uoc1FY6ztojFahUcgrQd4lt1pFmDswTDXfVfrs7sWppPpT9n5Mv0TEtHN /Fwf7su5UgE/ZdJ04WCStO1KcjiCi7skRl0QAqErkmWfSSUcXFyyjdXJ+ th9kDTzjFdPUUpyMdwiO/GPvyb1zSMVfpMzwiuwwTp6tqWmG6D/SRnrRa HNf0HvhXLV0uh3MDTfeV2/kLDYOtJJbnKyMZDIBz4BC2dKh0TZwxd5tkd dFqpjUu870sLDCUEIbrIG9oV2vGJvIl2L475xeBbcSQi5Wx/vZC8+3eEE A==; X-IronPort-AV: E=McAfee;i="6600,9927,10992"; a="14389841" X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="14389841" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2024 21:00:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="36808374" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmviesa001.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 22 Feb 2024 21:00:09 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) 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.35; Thu, 22 Feb 2024 21:00:08 -0800 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 22 Feb 2024 21:00:08 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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.35 via Frontend Transport; Thu, 22 Feb 2024 21:00:08 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 22 Feb 2024 21:00:07 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=agd3VquJXn1fLgm0FiAYdwAZ+kkpgqEd9+FXt2607gtKQxHu6yoLtnJcWk85HeuY7c+mahsVS0pM1g8Vvim6kJSpagn4tPE6nBsx5tHq6JRhBbZ3mwYTwv8MIufXCSPIWLPzUVVBAwyUt2V/lpnmq9xBRobYo62rp9GQovuuk0NkcL/0VkW4N6T2rZj4vJj+5hzIcRgZk8xWWhRb6PNVMEz2YCdu3nhOP4JCViXQ/q0+CrMe12KJOKfo0KrUYEkuwIUZn4EPSpqAaMBkZbcVpeLa8stgjDlAIGvbG8aWVjIXF46KP84PrvUWCY8Rapa0FWSWz5lOgCcaKMNRjCAVmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=CGq6HzXZNqpirI+zzsugW7kJI4TsGnG2e0cxTXBZMWA=; b=W8xoIIrY3V2OAyjh7aJfVBDSb1PucHIzC+8ZFb3xyqsrZJrW/EToN5pCj+YZ2uNqZjJgq5KKIAKIDvN0QfytbIC2LQqKY8qLEUkdlKMrojs5Ma7b/DYKv2M8Xd0Oxf4ksxagy0HZpL9o9z+Kka6WGv1Thdus+d5pCjcQ4Ezkcrek4Ve6XgRtjlA/pVyPP54zQ1xn0b7u5fsGLIg+WOE3KfxGC/mNga/CYq67N+MuNBwrq5C/Jzmi6Q+uV55N+nGV9Jsq04W5sIjF1tP7pGD11qtU8P3OYcSVVP7HZn0BBWnn4R5d7tVJ3irwmYYMUCJwJe84PAV3MbEDnLuwEHJWQg== 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 CY5PR11MB6139.namprd11.prod.outlook.com (2603:10b6:930:29::17) by MW4PR11MB5776.namprd11.prod.outlook.com (2603:10b6:303:183::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.39; Fri, 23 Feb 2024 05:00:06 +0000 Received: from CY5PR11MB6139.namprd11.prod.outlook.com ([fe80::7352:aa4b:e13e:cb01]) by CY5PR11MB6139.namprd11.prod.outlook.com ([fe80::7352:aa4b:e13e:cb01%7]) with mapi id 15.20.7339.009; Fri, 23 Feb 2024 05:00:06 +0000 Date: Thu, 22 Feb 2024 23:00:03 -0600 From: Lucas De Marchi To: "Gustavo A. R. Silva" CC: Erick Archer , Oded Gabbay , Thomas =?utf-8?Q?Hellstr=C3=B6m?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , "Gustavo A. R. Silva" , Kees Cook , , , , Subject: Re: Re: [PATCH] drm/xe: Prefer struct_size over open coded arithmetic Message-ID: References: <20240210141913.6611-1-erick.archer@gmx.com> <30715dc4-3285-4f4a-a041-a718a8509721@embeddedor.com> Content-Type: text/plain; charset="us-ascii"; format=flowed Content-Disposition: inline In-Reply-To: <30715dc4-3285-4f4a-a041-a718a8509721@embeddedor.com> X-ClientProxiedBy: SJ0PR13CA0126.namprd13.prod.outlook.com (2603:10b6:a03:2c6::11) To CY5PR11MB6139.namprd11.prod.outlook.com (2603:10b6:930:29::17) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR11MB6139:EE_|MW4PR11MB5776:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d0d8df2-16bc-4bd2-04fc-08dc342c4d6d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qi6r2H4vyLqvFib486o8Ua+FkwnAIg2/rh6OKGYUE/LInqEbtWfOpxn+f0kYzEutcApspSXShms2/54xjZAKXKQjHRwxqiZu5qt6hWAmMtV8jqTOvdC+QtH5tg3q6HEbigM1pRmy/D9j0sonmu8FYvnd/K8ld+x+gTUxv+XmJCnweuS8iGw8ahi4a0/iU23gf8RdXmug+CP+ECe92UGjZ3x3Nk297+ioYSmwnzrk/HC+Vh9Xm/co9ARiR2qTI19gVAgAoD6SKvPH900ArZZNrmuKhtjdalEfWtWC2ixyRnf5j7etyDftvJocRR6Tqw/DkRUIaySR+XsuV4dRVUN6WRFOo+s2LqJGWk8EsCs4b7BqAtLdPDpE7Y7J7gRnvKvIaVwFXBoRt0CcN/oueDXhMfOkNEbu4Dmux8Oj2pdTx795sm1wYPtfvD5mDI5HDOdmi0NmUaLBIO3J/WZL00VdMQtPpCjza25jF1sePRMFpmS8Zx6j9e6VR/XZtwCael1QohAsqc/gEb3rMFKQTBOjqA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR11MB6139.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Z/hDHoExQ4Sd4HqUzD0q56F1bK1iR4rWjHCvqEUuRVWUFrx6Jfpq06CZLU4Z?= =?us-ascii?Q?tcBAyF3zFszs0XXC2kgy0BbBlO83sMi1WztGcLAwkrp5wXC1lc6RXjUgOwaT?= =?us-ascii?Q?l9gNLnb7cmW9WhOpo3UuiL7iBKlw3m1CgW3yHxa0W2mJuwP4n6ebeogTLb85?= =?us-ascii?Q?ayt87VR4TcOKk03VqXI4uitARba2uZ5trXYK7fbzMSLMa8UJgpJp9AkNv4Nb?= =?us-ascii?Q?eIMhHIV308j8oMiF0K0/IGdTl3L0Txdsx7o+evtOL1VRK/j1vzdu6ihtj33d?= =?us-ascii?Q?TrYq/oL8AYqCY5NKra753EsROlSMJNlfWm5kboFUCXTEWUwNR9QR5mVrDVf9?= =?us-ascii?Q?YtmCaE1aIQZn/gpW9DYEY9a2A2qUvVoPZ34ZOXRkyJBUzZysUJRyMdHHnMjY?= =?us-ascii?Q?907Z4Ckd6bklhMRDS6JqymWFL+oT6Eq2YW57Dnba8iQuhBG+EzPNYlGBWi8m?= =?us-ascii?Q?CpJVF4z2dde7EX8Jgo2y9MF4KG/26d7NbQAAikVDLd/+PwaxvKjcmAI018VR?= =?us-ascii?Q?wYXIO3yPJvORCmQe28sH8ZJ+lNXv083bDBw5tbGJWRqKWr4H1yFEd13N3/qe?= =?us-ascii?Q?LA9pMa9nYIg23JfoWujsTz3X9llmYrF1EIfspX68hdu9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dw8S6ApdtLCMVq2XqB+BJfI2rXdH2u4?= =?us-ascii?Q?/lTA5MzVDY1VQ4z045HziS50dr8hiNuTP0AuPgqj2cAFd5Br4ofIl+Y7Vetn?= =?us-ascii?Q?2Q=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5d0d8df2-16bc-4bd2-04fc-08dc342c4d6d X-MS-Exchange-CrossTenant-AuthSource: CY5PR11MB6139.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2024 05:00:06.2739 (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: 1JScZqZo5FJh0qumdNUhUQDxfUwLkFdg4jb7QAHhCK4jkMLqcddijUmQUyGBtQNgts8schxvHTpXw5Hq37TQrQaBm71E8K5AON9iBCLomJc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB5776 X-OriginatorOrg: intel.com On Sat, Feb 10, 2024 at 10:49:57AM -0600, Gustavo A. R. Silva wrote: > > >On 2/10/24 08:19, Erick Archer wrote: >>This is an effort to get rid of all multiplications from allocation >>functions in order to prevent integer overflows [1]. >> >>As the "q" variable is a pointer to "struct xe_exec_queue" and this >>structure ends in a flexible array: >> >>struct xe_exec_queue { >> [...] >> struct xe_lrc lrc[]; >>}; >> >>the preferred way in the kernel is to use the struct_size() helper to >>do the arithmetic instead of the argument "size + size * count" in the >>kzalloc() function. >> >>This way, the code is more readable and more safer. >> >>Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] >>Link: https://github.com/KSPP/linux/issues/160 [2] >>Signed-off-by: Erick Archer > >LGTM: > >Reviewed-by: Gustavo A. R. Silva applied to drm-xe-next. Thanks for the patch and review. Lucas De Marchi