From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D751C606A322 for ; Fri, 4 Dec 2026 17:04:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bV9NPF3i Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F9A810E8AC; Fri, 4 Dec 2026 17:04:17 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5E8101130A2 for ; Fri, 4 Dec 2026 17:04:11 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 120B7434D4; Fri, 4 Dec 2026 17:04:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B93961F000C2; Fri, 4 Dec 2026 17:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796403850; bh=LitKc/DHOm4MpIo6EjfRLAPy3J9GGE6CbCiq7LkovCA=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=bV9NPF3iVbshwIjoKdjoVDkMj5ObMLhicgx9eNDY23yyrHO9svG14cUQ63533jwTp VEXqYNNfYOx38JjCZJ1ht+xp9SR7myAmoZWNiDO2w28anvh2VqynGYKGlpQbl8a4Ok MyoIPmxg0Qz7br6Uy6RRN1bc3GHHDeK5fBro6akeuwkWS22QzHwwlyZPQ9cic+EGRD cfz2VQdivpQuTJQ9oFyQ5M40S83gWfOuvZA030U4pKIZn+40pKAZEfZUFT2jW8TkRd k8H+oauqdBChW0M70bf8y/k67hmTrsgDGRX9zymULIx/Nlia4uypiB748ND5HJUwCY 2SZcNzJtF5BiQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC 07/11] drm/xe/vf: Register VF GuC log and debug state capture buffers To: "Satyanarayana K V P" , intel-xe@lists.freedesktop.org In-Reply-To: <20261204144712.3520695-20-satyanarayana.k.v.p@intel.com> References: <20261204144712.3520695-13-satyanarayana.k.v.p@intel.com> <20261204144712.3520695-20-satyanarayana.k.v.p@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 17:04:10 +0000 X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "Intel-xe" X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Medium] drm/xe/vf: unzeroed, over-allocated ads->bo in xe_guc_ads_init() - [Medium] drm/xe/vf: xe_guc_ads_capture_init_vf() registers unzeroed oversized ads->bo - [Medium] drm/xe: 32-bit PAGE_ALIGN() overflow in guc_ads_capture_size() on VF - [Medium] drm/xe: vf_uc_load_hw() treats optional VF debug buffer failures as fatal - [Medium] drm/xe: unlocked GuC MMIO and GGTT reads race in vf_uc_load_hw() -- commit 7024ffdee54876cf009415bddb46a20639b5f1de Author: Satyanarayana K V P drm/xe/vf: Register VF GuC log and debug state capture buffers This commit adds VF helpers to register the GuC log and debug state capture buffers with GuC via self-configuration KLVs and invokes them from vf_uc_load_hw(). [ ... ] > diff --git a/drivers/gpu/drm/xe/xe_guc_ads.c b/drivers/gpu/drm/xe/xe_guc_= ads.c > index 1cce54cc711d4..e6d7833ea8b91 100644 > --- a/drivers/gpu/drm/xe/xe_guc_ads.c > +++ b/drivers/gpu/drm/xe/xe_guc_ads.c > @@ -1206,3 +1206,23 @@ int xe_guc_ads_scheduler_policy_toggle_reset(struc= t xe_guc_ads *ads, > =20 > return guc_ads_action_update_policies(ads, xe_guc_buf_flush(buf)); > } > + > +/** > + * xe_guc_ads_capture_init_vf() - Initialize the GuC debug state capture= buffer for a VF. > + * @ads: Additional data structures object > + * > + * Return: 0 on success, or a negative error code on failure. > + */ > +int xe_guc_ads_capture_init_vf(struct xe_guc_ads *ads) > +{ > + struct xe_device *xe =3D ads_to_xe(ads); > + struct xe_gt *gt =3D ads_to_gt(ads); > + struct xe_bo *bo =3D ads->bo; > + > + xe_gt_assert(gt, IS_SRIOV_VF(xe)); > + > + if (!xe_guc_debug_capture_support(ads)) > + return 0; > + > + return xe_gt_sriov_vf_register_debug_state_capt_buff(gt, xe_bo_ggtt_add= r(bo)); > +} [Severity: Medium] Does xe_guc_ads_capture_init_vf() register an unzeroed and over-allocated ads->bo with GuC? xe_guc_ads_init() allocates ads->bo with xe_managed_bo_create_pin_map() (a ttm_bo_type_kernel BO, which does not set TTM_TT_FLAG_ZERO_ALLOC) and returns early on VF without calling xe_map_memset(). Since neither xe_guc_ads_populate() nor xe_guc_ads_populate_minimal() runs on VF, stale kernel pages are exposed to GuC and later capture readers. It also allocates guc_ads_size(ads) + MAX_GOLDEN_LRC_SIZE, wasting over 256 KiB of pinned system memory and GGTT space per GT on native ADS sections that VFs do not use. [Severity: Medium] Should the VF debug state capture output buffer be separated from guc->ads.bo and cleared on load and reset? Overloading guc->ads.bo breaks the invariant that ads->bo is NULL on VFs, ties the allocation to PF-only ADS headers, regsets, WAKLV, and MAX_GOLDEN_LRC_SIZE (over 264 KiB of wasted pinned RAM and PF-partitioned VF GGTT per GT), and leaves struct guc_debug_snapshot_buffer_state_vf at offset 0 uninitialized on first load or stale across GT resets and resumes when vf_uc_load_hw() re-registers the buffer. Keeping a dedicated BO in xe_guc_capture sized to PAGE_ALIGN(size) and zeroed on init and reset would avoid both issues. [Severity: Medium] Can guc_ads_capture_size() overflow in 32-bit arithmetic and cause xe_guc_ads_capture_init_vf() to register an undersized BO with GuC? guc_capture_size() stores the GuC-reported capture buffer size directly into u32 ads->capture_size without an upper-bound check. In guc_ads_capture_size(), PAGE_ALIGN(ads->capture_size) is evaluated in 32-bit arithmetic, so any value above 0xfffff000 wraps to 0 while if (!ads->capture_size) in xe_guc_ads_init() still passes. Registering the resulting undersized ads->bo risks out-of-bounds GGTT DMA writes from GuC into adjacent VF kernel buffers. [ ... ] > diff --git a/drivers/gpu/drm/xe/xe_uc.c b/drivers/gpu/drm/xe/xe_uc.c > index ff13f6e6ccb66..d2e863d457b7f 100644 > --- a/drivers/gpu/drm/xe/xe_uc.c > +++ b/drivers/gpu/drm/xe/xe_uc.c [ ... ] > @@ -298,6 +300,14 @@ static int vf_uc_load_hw(struct xe_uc *uc) > if (err) > return err; > =20 > + err =3D xe_guc_log_init_vf(&uc->guc.log); > + if (err) > + return err; > + > + err =3D xe_guc_ads_capture_init_vf(&uc->guc.ads); > + if (err) > + return err; > + > return 0; > } [Severity: Medium] Should failures from xe_guc_log_init_vf() and xe_guc_ads_capture_init_vf() be fatal to vf_uc_load_hw()? vf_uc_load_hw() is called during VF probe, system resume, and GT reset recovery (gt_reset_worker() -> vf_gt_restart()), where any non-zero error permanently wedges the device via xe_wedge_declare(). Because guc_log_enabled and debug_state_capture_enabled are cached once at probe and never re-queried, a PF reset or VF migration to a PF without VF debug logging enabled can cause GuC to reject the HOST2GUC_SELF_CFG registration with an error such as -ENOKEY or -ENXIO. Logging the failure and clearing the corresponding VF debug flag instead of returning the error would match how guc_log_size() and guc_capture_size() already treat optional VF debug buffer errors. Also, since these helpers re-register buffers on every reset and resume rather than doing one-time SW init, a register/enable-oriented name would be clearer. [Severity: Medium] Can xe_guc_log_init_vf() and xe_guc_ads_capture_init_vf() race with vf_post_migration_recovery() or gt_reset_worker() on the unlocked GuC MMIO scratch registers and GGTT addresses? Both helpers run after xe_guc_enable_communication() has enabled memirq and CT, while xe_gt_init() and xe_gt_resume() execute outside gt->ordered_wq: CPU0 (xe_gt_init / xe_gt_resume) CPU1 (gt->ordered_wq) vf_uc_load_hw() xe_guc_enable_communication() ... xe_guc_log_init_vf() addr =3D xe_bo_ggtt_addr(bo) vf_post_migration_recovery() vf_post_migration_resfix_start() xe_guc_mmio_send_recv() xe_guc_self_cfg64(..., addr) xe_guc_mmio_send_recv() <-- races on VF_SW_FLAG(0..3) vf_post_migration_fixups() xe_ggtt_shift_nodes() xe_guc_mmio_send_recv() writes and polls VF_SW_FLAG(0..3) or MED_VF_SW_FLAG(0..3) without locking, so concurrent MMIO requests from vf_post_migration_recovery() (or from gt_reset_worker() triggered by a G2H fault during xe_gt_init()) can corrupt HxG requests and replies. In addition, sampling xe_bo_ggtt_addr(bo) without synchronizing against xe_ggtt_shift_nodes() can register a stale pre-migration GGTT address with the post-migration GuC. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204144712.3520= 695-13-satyanarayana.k.v.p@intel.com?part=3D7