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 BE5DB606A330 for ; Fri, 4 Dec 2026 17:31:02 +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=Oe/l8II3 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8298B10EC53; Fri, 4 Dec 2026 17:30:57 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2C05E10EC4B for ; Fri, 4 Dec 2026 17:30:51 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id F036441918; Fri, 4 Dec 2026 17:30:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B89BC1F00936; Fri, 4 Dec 2026 17:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796405450; bh=OPykZwLEaWK5mguSqMZn9t5SflsOZQujWQ42BXip+hg=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Oe/l8II3A/KSwsrAeYohJyb58cjYYkaNS5rWOG4AupB/GYDPRRJWj35m9s7qJsTYI /z8htPDtDv7jGVtqFjCWuNJLUMDXVlsD4iqPQULJL0star1F3qiIngCg9B70IynHhc orLVX4W/sBkdazsUdwwSVGyFlomLqkGDracPahd9cFOwV51Jvcr4uKoacsy9TSKZRu yPccI3lbd0k3wJV/i1ePZavODGkYqPUDkpXZzMwVIP6aTCWnmvSmjCdyWKAywEBy3c Foud6tkSCBsNBM0bYEGQJPyESsBdfWUZFAgvDs+nVwPhiY4bfff2cwEpLbOmhMCwHW 2PAVSD6FYo1kA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC 08/11] drm/xe/vf: Initialize GuC logging buffers during GuC setup To: "Satyanarayana K V P" , intel-xe@lists.freedesktop.org In-Reply-To: <20261204144712.3520695-21-satyanarayana.k.v.p@intel.com> References: <20261204144712.3520695-13-satyanarayana.k.v.p@intel.com> <20261204144712.3520695-21-satyanarayana.k.v.p@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 17:30:50 +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=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,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 15 potential issues to consider: - [High] drm/xe/vf: vf_guc_fini_hw() registered before log and ADS BO allocations - [Medium] drm/xe/vf: xe_guc_ads_init() over-allocates PF ADS and golden LRC space - [Medium] drm/xe: complete() called on uninitialized vf_log_ready completion - [Medium] drm/xe: unsynchronized xe_guc_mmio_send() races with VF reset and migration - [Medium] drm/xe: vf_log_capture_lock dropped before log->bo copy and ct_mode TOCTOU - [Medium] drm/xe: completion race in xe_guc_log_vf_request_snapshot_ct_locked() - [Medium] drm/xe: stale or missing GUC_PMTIMESTAMP in VF xe_guc_log_snapshot_capture() - [Medium] drm/xe: guc_init_vf() initializes guc->capture when capture BO is NULL - [Medium] drm/xe: missing page alignment for VF GuC log size in xe_guc_log_init() - [Low] drm/xe/vf: guc_init_params_vf() fills unused guc->params with PF sizes - [Low] drm/xe/vf: commit message omits G2H handler, snapshot APIs, and debugfs - [Low] drm/xe: guc_log_vf() mis-sizes seq_file buffer for ASCII85 and zstd dumps - [Low] drm/xe: commit message omits VF log capture protocol and debugfs changes - [Low] drm/xe: stale CT mode check before mutex in xe_guc_log_vf_request_snapshot() - [Low] drm/xe: 32-bit wraparound in PAGE_ALIGN() in guc_ads_capture_size() -- commit 90511c95d48796d8b3f7ed4ec94220879d274db8 Author: Satyanarayana K V P > drm/xe/vf: Initialize GuC logging buffers during GuC setup > > Initialize VF GuC log and debug capture resources as part of GuC > initialization, so their buffers are ready before the VF GuC load path > registers them. > > Signed-off-by: Satyanarayana K V P > Cc: Piotr Pi=C3=B3rkowski > Cc: Micha=C5=82 Winiarski [Severity: Low] Does the commit message describe all of the significant changes in this patch? Beyond initializing the VF GuC log and debug capture buffers in xe_guc.c, this commit also adds the XE_GUC_ACTION_GUC2VF_NOTIFY_GUC_LOG_READY G2H handler, VF firmware version handling in xe_guc_log_snapshot_capture(), the CTB and MMIO VF log snapshot helpers, and the VF guc_log debugfs entry. [Severity: Low] Should the VF GuC log capture protocol and debugfs exposure either be described in the commit message or split into separate patches so this commit matches its title? > diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c > index b8939f04ea24c..2d3a174e74c9a 100644 > --- a/drivers/gpu/drm/xe/xe_guc.c > +++ b/drivers/gpu/drm/xe/xe_guc.c > @@ -260,10 +260,31 @@ static void guc_print_params(struct xe_guc *guc) > xe_gt_dbg(gt, "GuC param[%2d] =3D 0x%08x\n", i, params[i]); > } > =20 > +static void guc_init_params_vf(struct xe_guc *guc) > +{ > + bool debug_capt_en =3D xe_guc_debug_capture_support(&guc->ads); > + bool guc_log_en =3D xe_guc_log_vf_supported(&guc->log); > + u32 *params =3D guc->params; > + > + params[GUC_CTL_LOG_PARAMS] =3D guc_log_en ? guc_ctl_log_params_flags(gu= c) : 0; > + params[GUC_CTL_DEBUG] =3D guc_log_en ? guc_ctl_debug_flags(guc) : 0; > + params[GUC_CTL_ADS] =3D debug_capt_en ? guc_ctl_ads_flags(guc) : 0; > + params[GUC_CTL_FEATURE] =3D 0; > + params[GUC_CTL_WA] =3D 0; > + params[GUC_CTL_DEVID] =3D guc_ctl_devid(guc); > + > + guc_print_params(guc); > +} [Severity: Low] Is guc_init_params_vf() dead code on VFs? guc->params is only read by guc_write_params() during PF firmware upload, which VFs never run, and guc_ctl_log_params_flags() encodes compile-time PF buffer sizes rather than the queried VF log size, causing guc_print_params() to emit misleading debug output. [ ... ] > @@ -796,6 +817,44 @@ int xe_guc_init_noalloc(struct xe_guc *guc) > return ret; > } > =20 > +static int guc_init_vf(struct xe_guc *guc) > +{ > + struct xe_device *xe =3D guc_to_xe(guc); > + struct xe_gt *gt =3D guc_to_gt(guc); > + int ret; > + > + xe_gt_assert(gt, IS_SRIOV_VF(xe)); > + > + ret =3D devm_add_action_or_reset(xe->drm.dev, vf_guc_fini_hw, guc); > + if (ret) > + goto out; > + > + xe_sriov_vf_debug_log_init_early(xe); > + > + ret =3D xe_guc_log_init(&guc->log); > + if (ret) > + goto out; [Severity: High] Does registering vf_guc_fini_hw() before xe_guc_log_init() and xe_guc_ads_init() invert the devm teardown order? Because devm actions run in LIFO order and xe_managed_bo_create_pin_map() registers __xe_bo_unpin_map_no_vm() on the same devm list, unbinding the VF driver will unpin log->bo and ads->bo, clear their GGTT PTEs, and free their backing pages before vf_guc_fini_hw() resets VF GuC state. Since neither buffer is deregistered earlier, GuC can still DMA to those GGTT addresses during teardown, causing GGTT page faults or use-after-free. Registering vf_guc_fini_hw() after the BO allocations, matching PF guc_fini_hw(), would keep the buffers pinned until VF reset. > + > + ret =3D xe_guc_capture_init(guc); > + if (ret) > + goto out; [Severity: Medium] Can calling xe_guc_capture_init() unconditionally on VFs cause a NULL pointer dereference when debug state capture is disabled or unsupported? When VF debug state capture is disabled by the PF or unsupported by GuC firmware, xe_guc_ads_init() returns 0 with guc->ads.bo left NULL (and xe_guc_log_init() leaves guc->log.bo NULL when VF logging is disabled). Because guc->capture is now non-NULL, xe_guc_capture_process() enters __guc_capture_process_output() and dereferences &guc->log.bo->vmap (or reads hardcoded PF capture offsets out of bounds on a VF log BO). Although commit "drm/xe/guc: Process VF GuC error state captures" later switches VFs to guc_capture_process_output_vf() reading &guc->ads.bo->vmap, an unexpected G2H capture notification on a VF with debug capture disabled still dereferences NULL guc->ads.bo, and VFs with capture disabled still allocate guc->capture unnecessarily. Moving the IS_SRIOV_VF() check before xe_guc_capture_ads_input_worst_size() in guc_capture_size() allows skipping xe_guc_capture_init() when VF debug capture is disabled, provided capture consumers check guc->capture and guc->ads.bo. > + > + ret =3D xe_guc_ads_init(&guc->ads); > + if (ret) > + goto out; [Severity: Medium] Does calling xe_guc_ads_init() on VFs over-allocate pinned memory and GGTT space? xe_guc_ads_init() allocates guc_ads_size(ads) + MAX_GOLDEN_LRC_SIZE, which includes the PF ADS blob, regsets, WA KLVs, and 256 KiB of golden LRC space, even though VFs only use ads->bo as the debug state capture buffer of size PAGE_ALIGN(ads->capture_size). That wastes roughly 280 KiB of pinned system memory and provisioned VF GGTT quota per VF GT whenever debug state capture is enabled. [Severity: Low] Can PAGE_ALIGN(ads->capture_size) in guc_ads_capture_size() wrap around to 0 in 32-bit arithmetic? xe_guc_ads_init() sets ads->capture_size (u32) from the GuC KLV query GUC_KLV_GLOBAL_CFG_GUC_DEBUG_CAPTURE_BUFF_SIZE_KEY with no upper-bound check. Because PAGE_ALIGN() preserves __typeof__(x), any value in [0xfffff001, 0xffffffff] wraps to 0 before widening to size_t, causing xe_guc_ads_init() to allocate and register an undersized BO with zero bytes reserved for capture instead of failing. Widening capture_size to size_t or bounds-checking it in guc_capture_size() avoids the wraparound. [ ... ] > diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_c= t.c > index 121955ac4abf9..3cc1851b96add 100644 > --- a/drivers/gpu/drm/xe/xe_guc_ct.c > +++ b/drivers/gpu/drm/xe/xe_guc_ct.c > @@ -1863,6 +1863,9 @@ static int process_g2h_msg(struct xe_guc_ct *ct, u3= 2 *msg, u32 len) > case XE_GUC_ACTION_NOTIFY_FLUSH_LOG_BUFFER_TO_FILE: > /* FIXME: Handle this */ > break; > + case XE_GUC_ACTION_GUC2VF_NOTIFY_GUC_LOG_READY: > + ret =3D xe_guc_log_vf_handler(&guc->log, payload, adj_len); > + break; [Severity: Medium] Can XE_GUC_ACTION_GUC2VF_NOTIFY_GUC_LOG_READY trigger a NULL pointer dereference on an uninitialized vf_log_ready completion? xe_guc_log_init() only calls init_completion(&log->vf_log_ready) when IS_SRIOV_VF(xe) is true and guc_log_size() is non-zero, leaving vf_log_ready zero-initialized on PF/native devices and on VFs with logging disabled. If an unexpected G2H notification arrives, xe_guc_log_vf_handler() calls complete(&log->vf_log_ready) directly; in swake_up_locked(), list_empty(&q->task_list) returns false when task_list.next is NULL, causing a near-NULL dereference in try_to_wake_up(). Validating IS_SRIOV_VF(xe) and xe_guc_log_vf_supported(log) in xe_guc_log_vf_handler() (or unconditionally initializing vf_log_ready) avoids the crash. > diff --git a/drivers/gpu/drm/xe/xe_guc_debugfs.c b/drivers/gpu/drm/xe/xe_= guc_debugfs.c > index 2f23119686d44..bc5f10a34236b 100644 > --- a/drivers/gpu/drm/xe/xe_guc_debugfs.c > +++ b/drivers/gpu/drm/xe/xe_guc_debugfs.c [ ... ] > @@ -104,6 +106,35 @@ static int guc_pc(struct xe_guc *guc, struct drm_pri= nter *p) > return 0; > } > =20 > +static int guc_log_vf(struct xe_guc *guc, struct drm_printer *p) > +{ > + struct seq_file *m =3D p->arg; > + size_t size; > + char *buf; > + > + size =3D xe_guc_log_vf_size(&guc->log); > + if (!size) { > + drm_printf(p, "GuC log capture from VF is not supported / disabled by = PF!!!\n"); > + return 0; > + } > + > + if (IS_ENABLED(CONFIG_DRM_XE_COMPRESS_DUMP)) > + size =3D max(size, zstd_compress_bound(size)); > + > + if (seq_get_buf(m, &buf) <=3D size) { > + seq_commit(m, -1); > + return 0; > + } > + > + xe_guc_log_vf_print(&guc->log, p); > + > + return 0; > +} [Severity: Low] Does guc_log_vf() mis-size the seq_file buffer for both uncompressed and ZSTD-compressed dumps? xe_guc_log_vf_print() emits metadata headers and ASCII85-encoded text (expanding 4 binary bytes up to 5 characters), which exceeds the raw or zstd_compress_bound() byte size checked against seq_get_buf(). When compression is disabled or falls back to raw, m->buf can still overflow and cause seq_file to re-run guc_log_vf() and request a second GuC log snapshot. Conversely, when CONFIG_DRM_XE_COMPRESS_DUMP is enabled, requiring seq_get_buf() > zstd_compress_bound(size) up front forces repeated seq_file kvmalloc() doublings up to 32 MiB even when the compressed output is much smaller. [ ... ] > diff --git a/drivers/gpu/drm/xe/xe_guc_log.c b/drivers/gpu/drm/xe/xe_guc_= log.c > index 0ed905c739dd3..e2cf275b7fd72 100644 > --- a/drivers/gpu/drm/xe/xe_guc_log.c > +++ b/drivers/gpu/drm/xe/xe_guc_log.c [ ... ] > @@ -223,8 +227,13 @@ struct xe_guc_log_snapshot *xe_guc_log_snapshot_capt= ure(struct xe_guc_log *log, > =20 > snapshot->ktime =3D ktime_get_boottime_ns(); > snapshot->level =3D log->level; > - snapshot->ver_found =3D guc->fw.versions.found[XE_UC_FW_VER_RELEASE]; > - snapshot->ver_want =3D guc->fw.versions.wanted; > + if (!IS_SRIOV_VF(xe)) { > + snapshot->ver_found =3D guc->fw.versions.found[XE_UC_FW_VER_RELEASE]; > + snapshot->ver_want =3D guc->fw.versions.wanted; > + } else { > + snapshot->ver_found =3D gt->sriov.vf.guc_version; > + snapshot->ver_want =3D gt->sriov.vf.wanted_guc_version; > + } [Severity: Medium] Will GUC_PMTIMESTAMP_LO/HI in xe_guc_log_snapshot_capture() return a stale or zero timestamp on VFs? GUC_PMTIMESTAMP_LO and GUC_PMTIMESTAMP_HI are defined without XE_REG_OPTION_VF, so xe_mmio_read64_2x32() diverts VF reads to xe_gt_sriov_vf_read32(), which consults the static VF runtime register cache. Those registers are only in ver_35_runtime_regs[] and are read once during PF init, so on GRAPHICS_VER < 35 VFs read 0 with two xe_gt_WARN() splats under CONFIG_DRM_XE_DEBUG, and on GRAPHICS_VER >=3D 35 snapshot->stamp stays frozen at the PF boot-time value instead of the live GuC timestamp. [ ... ] > @@ -857,12 +867,22 @@ int xe_guc_log_init(struct xe_guc_log *log) > struct xe_device *xe =3D log_to_xe(log); > struct xe_gt *gt =3D log_to_gt(log); > struct xe_tile *tile =3D gt_to_tile(gt); > - size_t size =3D guc_log_size(gt); > + size_t size =3D guc_log_size(log); > struct xe_bo *bo; > + int err; > =20 > if (!size) > return 0; > =20 > + if (IS_SRIOV_VF(xe)) { > + err =3D drmm_mutex_init(&xe->drm, &log->vf_log_capture_lock); > + if (err) { > + gt->sriov.vf.debug_log.guc_log_enabled =3D false; > + return err; > + } > + init_completion(&log->vf_log_ready); > + } > + > bo =3D xe_managed_bo_create_pin_map(xe, tile, size, [Severity: Medium] Can an unaligned VF GuC log size from GuC hit BUG_ON() in drm_gem_private_object_init()? guc_log_size() returns the raw u32 byte count from GUC_KLV_GLOBAL_CFG_GUC_LOG_BUFF_SIZE_KEY without checking IS_ALIGNED(size, PAGE_SIZE) or applying PAGE_ALIGN(). For XE_BO_FLAG_SYSTEM kernel BOs, xe_bo_init_locked() passes size straight to drm_gem_private_object_init(), which panics on BUG_ON((size & (PAGE_SIZE - 1)) !=3D 0) if GuC returns a non-page-aligned size. Validating alignment or using PAGE_ALIGN(size) (with bounds checking) avoids the panic. [ ... ] > +static int xe_guc_log_vf_request_snapshot_mmio_locked(struct xe_guc_log = *log) > +{ > + struct xe_guc *guc =3D log_to_guc(log); > + struct xe_gt *gt =3D log_to_gt(log); > + int ret; > + u32 request[GUC_HXG_REQUEST_MSG_MIN_LEN] =3D { > + FIELD_PREP(GUC_HXG_MSG_0_ORIGIN, GUC_HXG_ORIGIN_HOST) | > + FIELD_PREP(GUC_HXG_MSG_0_TYPE, GUC_HXG_TYPE_REQUEST) | > + FIELD_PREP(GUC_HXG_REQUEST_MSG_0_ACTION, > + XE_GUC_ACTION_VF2GUC_REQUEST_GUC_LOGS_MMIO), > + }; > + > + xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); > + xe_gt_notice(gt, "Requesting Guc log using MMIO mode\n"); > + > + ret =3D xe_guc_mmio_send(guc, request, ARRAY_SIZE(request)); > + > + return ret > 0 ? -EPROTO : ret; > +} [Severity: Medium] Can xe_guc_log_vf_request_snapshot_mmio_locked() race with GT reset or VF post-migration recovery on the shared MMIO mailbox? xe_guc_mmio_send_recv() writes and polls VF_SW_FLAG / MED_VF_SW_FLAG with no lock. When CT is stopped during gt_reset_worker() or vf_post_migration_shutdown(), a concurrent debugfs read of guc_log falls back to MMIO mode while holding only vf_log_capture_lock: CPU0 (debugfs guc_log) CPU1 (gt_reset_worker) guc_log_vf() xe_uc_stop() /* CT now disabled */ xe_guc_ct_enabled() =3D=3D false do_gt_restart() -> vf_uc_load_hw() xe_guc_mmio_send() xe_guc_mmio_send_recv() write VF_SW_FLAG(0) write VF_SW_FLAG(0..len-1) poll reply <-- corrupted HXG Overlapping MMIO HXG transactions corrupt both exchanges, which can fail VF post-migration recovery or fail GT reset and wedge the GPU. > + > +static int xe_guc_log_vf_request_snapshot_ct_locked(struct xe_guc_log *l= og) > +{ > + struct xe_guc *guc =3D log_to_guc(log); > + struct xe_gt *gt =3D log_to_gt(log); > + int ret; > + u32 action[] =3D { > + XE_GUC_ACTION_VF2GUC_REQUEST_GUC_LOGS, > + }; > + > + xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); > + xe_gt_notice(gt, "Requesting Guc log using CTB mode\n"); > + > + reinit_completion(&log->vf_log_ready); > + ret =3D xe_guc_ct_send(&guc->ct, action, ARRAY_SIZE(action), 0, 0); > + if (ret < 0) { > + xe_gt_err(gt, "Failed to request GuC log snapshot from GuC: %d\n", ret= ); > + return ret; > + } else if (!wait_for_completion_timeout(&log->vf_log_ready, > + GUC_LOG_VF_READY_TIMEOUT)) { > + xe_gt_err(gt, "Timedout waiting for Guc log capture!\n"); > + return -ETIMEDOUT; > + } > + return 0; > +} [Severity: Medium] Can a delayed G2H notification after a timeout race with reinit_completion() and prematurely wake a later snapshot request? reinit_completion() stores vf_log_ready.done =3D 0 without locking, which data-races with complete() in xe_guc_log_vf_handler() on ct->g2h_wq, and requests have no sequence correlation: CPU0 (caller 2) ct->g2h_wq (late reply to caller 1) reinit_completion(&vf_log_ready) xe_guc_ct_send(REQUEST_GUC_LOGS) xe_guc_log_vf_handler() complete(&vf_log_ready) wait_for_completion_timeout() /* wakes early while GuC writes */ xe_guc_log_snapshot_capture() <-- reads log->bo during GuC DMA Caller 2 then copies log->bo while GuC is still writing caller 2's snapshot into it, producing a torn log dump. > + > +int xe_guc_log_vf_request_snapshot(struct xe_guc_log *log) > +{ > + struct xe_guc *guc =3D log_to_guc(log); > + bool ct_mode =3D xe_guc_ct_enabled(&guc->ct); > + > + xe_gt_assert(guc_to_gt(guc), IS_SRIOV_VF(guc_to_xe(guc))); > + > + if (!xe_guc_log_vf_supported(log)) > + return 0; > + > + guard(mutex)(&log->vf_log_capture_lock); > + > + if (ct_mode) > + return xe_guc_log_vf_request_snapshot_ct_locked(log); > + else > + return xe_guc_log_vf_request_snapshot_mmio_locked(log); > +} [Severity: Low] Can ct_mode become stale before vf_log_capture_lock is acquired? xe_guc_ct_enabled(&guc->ct) is sampled before blocking on log->vf_log_capture_lock, which another caller can hold for up to GUC_LOG_VF_READY_TIMEOUT (5 seconds). If CT state transitions while waiting (for example during GT reset or migration), the waiter dispatches using the stale transport mode; sampling xe_guc_ct_enabled() after acquiring vf_log_capture_lock avoids this. > + > +void xe_guc_log_vf_print(struct xe_guc_log *log, struct drm_printer *p) > +{ > + int err; > + > + err =3D xe_guc_log_vf_request_snapshot(log); > + if (err < 0) { > + drm_printf(p, "Error in capturing Guc log!!\n"); > + return; > + } > + > + xe_guc_log_print(log, p); > +} [Severity: Medium] Does dropping vf_log_capture_lock before xe_guc_log_print() allow a concurrent reader to overwrite log->bo mid-copy? xe_guc_log_vf_request_snapshot() releases log->vf_log_capture_lock upon return, before xe_guc_log_print() -> xe_guc_log_snapshot_capture() copies multi-MB chunks out of log->bo->vmap: CPU0 (reader 1) CPU1 (reader 2) xe_guc_log_vf_request_snapshot() lock(&vf_log_capture_lock) ... GuC writes log->bo ... unlock(&vf_log_capture_lock) xe_guc_log_print() xe_guc_log_vf_request_snapshot() xe_map_memcpy_from(log->bo) lock(&vf_log_capture_lock) request GuC DMA to log->bo <-- race Holding vf_log_capture_lock across both the GuC snapshot request and xe_guc_log_snapshot_capture() prevents concurrent readers from tearing log->bo. In addition, ct_mode is sampled before acquiring vf_log_capture_lock, and delayed G2H notifications after a timeout can prematurely wake a subsequent CTB request. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204144712.3520= 695-13-satyanarayana.k.v.p@intel.com?part=3D8