Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7070929rdb; Wed, 3 Jan 2024 03:48:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4gi3czX/ZbwPK7BcSHAJyy+uPX9fPrI6CoYzI4qKpYCmJy1JCXw6NAN5fjzDOMxFj2zwn X-Received: by 2002:a05:6830:22d5:b0:6dc:2b4:14a4 with SMTP id q21-20020a05683022d500b006dc02b414a4mr9295186otc.32.1704282525838; Wed, 03 Jan 2024 03:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704282525; cv=none; d=google.com; s=arc-20160816; b=ZnvQ3iDXs13fLbSj9rBy+uhKPiWf/GRUw5nJdPb4rIzxWcRfFlfgWkjXRkSM8mnrHc iHpWjynGDpwUKuOdS+gpaZtuXcK7GLareiGJH1RC4J6zsihA6QUZRENuoAyZcPRXxdzu RcReeQRrAYpDSbhDkks3QAz3dSzUGEr8FcsDbbJjuOVXkwdRs0voCguejdLyOCAV7k5r Ym/sagCIVEjoRgg3qye1huCwx7sPN+WsdTm5mjba2zJkXtkoKMOPgWO9olPNq0PYEG1V 85qgpTicxkoCMdjNiZq4HobEDGoCxlCVN1iVpBC/MARGjE0noHrFm0QUzDh7IKsaxTWC Q7YQ== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15464-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a13-20020a65418d000000b005bdf5961646si21760263pgq.268.2024.01.03.03.48.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 03:48:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15464-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15464-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7778328422A for ; Wed, 3 Jan 2024 11:48:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85F8018EC1; Wed, 3 Jan 2024 11:48:27 +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=20Hellstr=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 Content-Transfer-Encoding: 8bit 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); -- 2.39.2