From patchwork Wed Jan 3 11:48:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 184714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4967083dyb; Wed, 3 Jan 2024 03:49:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmDg0kV25Ooe08iI768bKUch7JISgAwhIuSG0s+R07+nbnOiVVfw7dIu0annUIv+d4U+L/ X-Received: by 2002:a17:902:b191:b0:1d4:672f:4809 with SMTP id s17-20020a170902b19100b001d4672f4809mr6159091plr.129.1704282542858; Wed, 03 Jan 2024 03:49:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704282542; cv=none; d=google.com; s=arc-20160816; b=LXrEXT8BpWB1Fc+fC6jo38j9lervdTaBUCL1Wq2CyR5IeNTxYf1OvDEAWUeu7YL3xK bh48sR2YBvVVHDkRhEQ6FhA7tQSxspf/Hxogaplh3ZkiiHuT/y87kVCqwqo26yM1hdMW 1pWfB/8XvyhhxppUmjyVK0zw3Y8P+RilEwQOa/Eyld1BwPiNwi6HOyVRXaz8+ZC24C3m YWnE72evcv3yzWDMYE4Cq1YaB18f7pRwzhNEwzroVpxHUlCqBKbDpD47sCYm71jpQC9s Q4GcCriH48UNrb962rMTR6di1cHt4GGtuJVhYcRSWF123QUlueSXunQAU7btdpy3h4x/ Qv+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=d4AUuOd4sOZVkN6l0WTBC54HLxxWEgnh+M6UoBveaCM=; fh=FVkEUK/mdN9OZuepOVI4MQ9hEcRaUv39zCZBh50Qcuo=; b=mNkjJoSvJDe/uusUDr22MxMjcdIoQSj7o05/JCY4tpPtYrw1XvxD5JF044AGAtcXK3 pUdtEZehK2UtGXVE52tvVyBErCAKo03MaFBWTQbrWE6VyaWTQxIHFD/UkeYcLuARK500 qw+6z2tFVVuqXuQI5/tXIARcfO2vVnu6jownruMq6hXmJJ2ghi688WJ//H92J0o5mf5G Q6vImGKupjOjG6pVdh4WaYjfxSimY5CMQ361AcAI7THW7GmL19a8FKy2nlFuiN68sgmu YkrgW5+Y6Y7JAsMgQ0MxzWPHbRzhZIEoICWDtjlxF2RYApSgR5WQXLq4Dg33+kqLAsak GeoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kf4DKVDs; spf=pass (google.com: domain of linux-kernel+bounces-15464-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15464-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b5-20020a170902d50500b001d352ecfa69si17838709plg.218.2024.01.03.03.49.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 03:49:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15464-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kf4DKVDs; spf=pass (google.com: domain of linux-kernel+bounces-15464-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15464-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A3928B22DC3 for ; Wed, 3 Jan 2024 11:48:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52C1118ED4; Wed, 3 Jan 2024 11:48:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Kf4DKVDs" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BCD3818EB6 for ; Wed, 3 Jan 2024 11:48:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10F35C433C7; Wed, 3 Jan 2024 11:48:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704282506; bh=TN4lVGjd6QgiOjbr2X4wDvGDWbLRLSblB4xYrWWI6lw=; h=From:To:Cc:Subject:Date:From; b=Kf4DKVDsaGBDnt0o7IU4upkaXehBOSF80PmZtgxGgRffIJ1uxSqOP1/tZyXSBswG+ 1REoSI3SpAFR6jT2GFB2HtuZtLsi6w8pNyFOw8FPN3Cpmja0Ymiy3gZYTAzwTxKIhl WR/7PQFUdC5BRh/5Dzlb9TwWA/cXneE//2OMWKuyxbO8xY5HOPdfgnDXVg38oVwsX/ lUury3x+DdDfHLNMhtIVnEgtYhqFTAPJTTXuPANGO+F6TsEpbeAErEo8BNzzbv9IAO bVNsCnj7LORrfJ8sm6rPqMj5rVx9xwfCT35Dcbt0UrW8Gmerqs+trqLYZSmECGDRJ8 vhQ+2tVYB/KUw== From: Arnd Bergmann To: Lucas De Marchi , Oded Gabbay , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Matthew Brost , Rodrigo Vivi Cc: Arnd Bergmann , Matt Roper , Brian Welty , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/xe: circumvent bogus stringop-overflow warning Date: Wed, 3 Jan 2024 12:48:02 +0100 Message-Id: <20240103114819.2913937-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787069771613759062 X-GMAIL-MSGID: 1787069771613759062 From: Arnd Bergmann gcc-13 warns about an array overflow that it sees but that is prevented by the "asid % NUM_PF_QUEUE" calculation: drivers/gpu/drm/xe/xe_gt_pagefault.c: In function 'xe_guc_pagefault_handler': include/linux/fortify-string.h:57:33: error: writing 16 bytes into a region of size 0 [-Werror=stringop-overflow=] include/linux/fortify-string.h:689:26: note: in expansion of macro '__fortify_memcpy_chk' 689 | #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ | ^~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/xe/xe_gt_pagefault.c:341:17: note: in expansion of macro 'memcpy' 341 | memcpy(pf_queue->data + pf_queue->tail, msg, len * sizeof(u32)); | ^~~~~~ drivers/gpu/drm/xe/xe_gt_types.h:102:25: note: at offset [1144, 265324] into destination object 'tile' of size 8 I found that rewriting the assignment using pointer addition rather than the equivalent array index calculation prevents the warning, so use that instead. I sent a bug report against gcc for the false positive warning. Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs") Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113214 Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/xe/xe_gt_pagefault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/xe/xe_gt_pagefault.c b/drivers/gpu/drm/xe/xe_gt_pagefault.c index 59a70d2e0a7a..78dc08cc2bfe 100644 --- a/drivers/gpu/drm/xe/xe_gt_pagefault.c +++ b/drivers/gpu/drm/xe/xe_gt_pagefault.c @@ -332,7 +332,7 @@ int xe_guc_pagefault_handler(struct xe_guc *guc, u32 *msg, u32 len) return -EPROTO; asid = FIELD_GET(PFD_ASID, msg[1]); - pf_queue = >->usm.pf_queue[asid % NUM_PF_QUEUE]; + pf_queue = gt->usm.pf_queue + (asid % NUM_PF_QUEUE); spin_lock_irqsave(&pf_queue->lock, flags); full = pf_queue_full(pf_queue);