Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] dma-buf: heaps: double encryption and memory leak in
system_heap_allocate() [1]
--
commit 8e29228b9a5d6486d110b63bcefe3df39d060082
Author: Ying Xiao <eagleshaw(a)google.com>
dma-buf: heaps: system: zero pages after set_memory_decrypted()
This commit skips __GFP_ZERO when allocating pages for the
system_cc_shared heap and zeroes the pages in
system_heap_set_page_decrypted() after set_memory_decrypted() succeeds.
> diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
> index c8959eadc71d1..5f98d0df11e76 100644
> --- a/drivers/dma-buf/heaps/system_heap.c
> +++ b/drivers/dma-buf/heaps/system_heap.c
[ ... ]
> @@ -438,7 +453,8 @@ static struct dma_buf *system_heap_allocate(struct dma_heap *heap,
> goto free_buffer;
> }
>
> - page = alloc_largest_available(size_remaining, max_order);
> + page = alloc_largest_available(size_remaining, max_order,
> + cc_shared_buffer(buffer));
> if (!page)
> goto free_buffer;
>
[Severity: Critical]
This problem wasn't introduced by this patch, but does the free_pages
error path in system_heap_allocate() call system_heap_set_page_encrypted()
on pages that were never decrypted [1] when
system_heap_set_page_decrypted() fails partway through the scatterlist?
drivers/dma-buf/heaps/system_heap.c:system_heap_allocate() {
...
if (cc_shared_buffer(buffer)) {
for_each_sgtable_sg(table, sg, i) {
ret = system_heap_set_page_decrypted(sg_page(sg));
if (ret)
goto free_pages;
}
}
...
free_pages:
for_each_sgtable_sg(table, sg, i) {
struct page *p = sg_page(sg);
...
if (cc_shared_buffer(buffer) &&
system_heap_set_page_encrypted(p))
continue;
__free_pages(p, compound_order(p));
}
...
}
At free_pages, for_each_sgtable_sg() resets i to 0 and iterates over the
entire scatterlist instead of only the entries that were decrypted.
Calling system_heap_set_page_encrypted() on pages that are still encrypted
can fault in confidential computing guests, or fail and skip
__free_pages(), leaking the pages.
[1] https://sashiko.dev/#/bug/linux-ece74ffb-d452-4ab2-b56e-aa5701dddcf3
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117155431.1654298-1-eagleshaw@google.co…
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/msm/adreno: missing qcom_pas_metadata_release() in
zap_shader_load_mdt()
--
commit d13b2477d9bf69676164fdb8068bcf949f328d1e
Author: Mukesh Ojha <mukesh.ojha(a)oss.qualcomm.com>
drm/msm/adreno: migrate zap shader loading to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset()
This commit replaces qcom_mdt_load() and qcom_pas_auth_and_reset() in
zap_shader_load_mdt() with qcom_mdt_pas_load() and
qcom_pas_prepare_and_auth_reset() using a stack-allocated
struct qcom_pas_context.
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index dadfe4c694384..12e35841763d8 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -34,11 +34,11 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> struct device *dev = &gpu->pdev->dev;
> const struct firmware *fw;
> const char *signed_fwname = NULL;
> + struct qcom_pas_context ctx;
> struct device_node *np;
> struct resource r;
> phys_addr_t mem_phys;
> ssize_t mem_size;
> - void *mem_region = NULL;
> int ret;
>
> if (!IS_ENABLED(CONFIG_ARCH_QCOM)) {
> @@ -121,39 +121,32 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> goto out;
> }
>
> - /* Allocate memory for the firmware image */
> - mem_region = memremap(mem_phys, mem_size, MEMREMAP_WC);
> - if (!mem_region) {
> - ret = -ENOMEM;
> - goto out;
> - }
> + qcom_pas_context_init(&ctx, dev, pasid, mem_phys, mem_size);
>
> /*
> * Load the rest of the MDT
> *
> * Note that we could be dealing with two different paths, since
> * with upstream linux-firmware it would be in a qcom/ subdir..
> - * adreno_request_fw() handles this, but qcom_mdt_load() does
> + * adreno_request_fw() handles this, but qcom_mdt_pas_load() does
> * not. But since we've already gotten through adreno_request_fw()
> * we know which of the two cases it is:
> */
> if (signed_fwname || (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY)) {
> - ret = qcom_mdt_load(dev, fw, fwname, pasid,
> - mem_region, mem_phys, mem_size, NULL);
> + ret = qcom_mdt_pas_load(&ctx, fw, fwname, NULL);
> } else {
> char *newname;
>
> newname = kasprintf(GFP_KERNEL, "qcom/%s", fwname);
>
> - ret = qcom_mdt_load(dev, fw, newname, pasid,
> - mem_region, mem_phys, mem_size, NULL);
> + ret = qcom_mdt_pas_load(&ctx, fw, newname, NULL);
> kfree(newname);
> }
> if (ret)
> goto out;
>
> /* Send the image to the secure world */
> - ret = qcom_pas_auth_and_reset(pasid);
> + ret = qcom_pas_prepare_and_auth_reset(&ctx);
>
> /*
> * If the pas call returns -EOPNOTSUPP we assume that this target
> @@ -165,9 +158,6 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> DRM_DEV_ERROR(dev, "Unable to authorize the image\n");
>
> out:
> - if (mem_region)
> - memunmap(mem_region);
> -
> release_firmware(fw);
>
> return ret;
[Severity: High]
Does zap_shader_load_mdt() leak the PAS metadata buffer stored in ctx.ptr?
Previously, qcom_mdt_load() passed a NULL struct qcom_pas_context to
__qcom_mdt_pas_init(), which caused qcom_scm_pas_init_image() and
qcom_pas_tee_init_image() to free the metadata buffer immediately.
Passing non-NULL &ctx via qcom_mdt_pas_load() retains the metadata
allocation in ctx.ptr, which is leaked when ctx goes out of scope unless
qcom_pas_metadata_release(&ctx) is called before returning. Note that
2aa8fafc08e7 ("firmware: qcom: pas: Make MDT buffer retention explicit")
changes qcom_pas_init_image() to release metadata unless keep_mdt_buf is
set, but that commit is not present in this tree.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116162148.2864501-1-mukesh.ojha@oss.qua…
Dear Neil Armstrong:
Thanks for your patches! Unfortunately the Media CI robot detected some
issues:
# Test checkpatch:./0002-media-qcom-iris-venc-drop-operating-rate-to-match-sp.patch checkpatch
WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?)
#9:
This also sets the coded frame interval on the CAPTURE queue to the same value.
total: 0 errors, 1 warnings, 0 checks, 165 lines checked
Please fix your series, and upload a new version. If you have a patchwork
account, do not forget to mark the current series as Superseded.
For more details, check the full report at:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/11638299… .
Best regards, and Happy Hacking!
Media CI robot on behalf of the linux-media community.
---
Check the latest rules for contributing your patches at:
https://docs.kernel.org/driver-api/media/maintainer-entry-profile.html
If you believe that the CI is wrong, kindly open an issue at
https://gitlab.freedesktop.org/linux-media/media-ci/-/issues or reply-all
to this message.
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] media: qcom: iris: iris_venc_g_param() still accepts CAPTURE
buffer type
- [Medium] media: qcom: iris: iris_venc_enum_fmt() advertises CAPTURE
frame interval
- [Low] media: qcom: iris: missing Fixes trailer for VIDIOC_S_PARM
framerate fix
--
commit 9aac0239cfb5e625cff9d17d7e2e9cdf50f128ea
Author: Neil Armstrong <neil.armstrong(a)linaro.org>
> media: qcom: iris: venc: drop operating rate to match spec
>
> Per the V4L2 Stateful Video Encoder UAPI documentation:
> Set the raw frame interval on the OUTPUT queue via VIDIOC_S_PARM().
> This also sets the coded frame interval on the CAPTURE queue to the same value.
>
> This implies setting the frame interval on the OUTPUT queue _should_ be
> supported as a single operation, and setting the frame interval on the
> CAPTURE queue can be considered as optional since the S_PARM on
> the OUTPUT queue will set the same frame interval on the CAPTURE
> queue.
>
> The current iris implementation maps:
> - inst->operating_rate to OUTPUT
> - inst->frame_rate to CAPTURE
>
> Only inst->frame_rate is set to the firmware, and inst->operating_rate
> is used in combination with inst->frame_rate to calculate
> the entire iris bandwidth in iris_check_core_mbps() plus
> returing the frame interval with G_PARM on the CAPTURE queue.
>
> So per the Documentation, the two major V4L2 Stateful Video Encoder
> client implementation (FFMpeg & GStreamer) only calls S_PARM
> on the OUTPUT queue, leaving inst->frame_rate to DEFAULT_FPS,
> and only setting inst->operating_rate.
>
> Since inst->operating_rate is currently useless and breaks the
> conformance, let's just remove operating_rate entirely
> and just set inst->frame_rate only with S_PARM on the OUTPUT
> queue.
>
> The two rate variables were probably added to allow scaling
> the iris OPP to allow faster encode speed, but wasn't yet
> properly implemented and breaks the S_PARM compliance.
>
> Signed-off-by: Neil Armstrong <neil.armstrong(a)linaro.org>
[Severity: Low]
This fixes VIDIOC_S_PARM on the encoder OUTPUT queue leaving inst->frame_rate
at DEFAULT_FPS. Should this include:
Fixes: 4ff586ff28e3 ("media: iris: Add support for G/S_PARM for encoder video device")
> diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/platform/qcom/iris/iris_venc.c
> index 2f2c56bf9122c..0db6ed1056bf6 100644
> --- a/drivers/media/platform/qcom/iris/iris_venc.c
> +++ b/drivers/media/platform/qcom/iris/iris_venc.c
> @@ -396,24 +395,17 @@ int iris_venc_s_param(struct iris_inst *inst, struct v4l2_streamparm *s_parm)
> {
> struct platform_inst_caps *caps = inst->core->iris_platform_data->inst_caps;
> struct vb2_queue *src_q = v4l2_m2m_get_src_vq(inst->m2m_ctx);
> - struct vb2_queue *dst_q = v4l2_m2m_get_dst_vq(inst->m2m_ctx);
> struct v4l2_fract *timeperframe = NULL;
> u32 default_rate = DEFAULT_FPS;
> - bool is_frame_rate = false;
> - u32 fps, max_rate;
> + u32 fps;
>
> int ret = 0;
>
> - if (s_parm->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
> - timeperframe = &s_parm->parm.output.timeperframe;
> - max_rate = caps->max_operating_rate;
> - s_parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
> - } else {
> - timeperframe = &s_parm->parm.capture.timeperframe;
> - is_frame_rate = true;
> - max_rate = caps->max_frame_rate;
> - s_parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
> - }
> + if (s_parm->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
> + return -EINVAL;
> +
> + timeperframe = &s_parm->parm.output.timeperframe;
> + s_parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
[Severity: Medium]
Should iris_venc_enum_fmt() also drop V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL now
that iris_venc_s_param() rejects V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE?
drivers/media/platform/qcom/iris/iris_venc.c:iris_venc_enum_fmt() {
...
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
fmt = find_format_by_index(inst, f->index, f->type);
if (!fmt)
return -EINVAL;
f->pixelformat = fmt;
f->flags = V4L2_FMT_FLAG_COMPRESSED | V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL;
break;
...
}
Advertising V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL tells userspace and
v4l2-compliance that setting the coded frame interval on the CAPTURE queue via
VIDIOC_S_PARM is supported, which now fails with -EINVAL.
[ ... ]
> @@ -463,17 +447,10 @@ int iris_venc_g_param(struct iris_inst *inst, struct v4l2_streamparm *s_parm)
> {
> struct v4l2_fract *timeperframe = NULL;
>
> - if (s_parm->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
> - timeperframe = &s_parm->parm.output.timeperframe;
> - timeperframe->numerator = 1;
> - timeperframe->denominator = inst->operating_rate;
> - s_parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
> - } else {
> - timeperframe = &s_parm->parm.capture.timeperframe;
> - timeperframe->numerator = 1;
> - timeperframe->denominator = inst->frame_rate;
> - s_parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
> - }
> + timeperframe = &s_parm->parm.output.timeperframe;
> + timeperframe->numerator = 1;
> + timeperframe->denominator = inst->frame_rate;
> + s_parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
>
> return 0;
> }
[Severity: Medium]
Should iris_venc_g_param() also reject s_parm->type !=
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE (or should iris_g_parm() and iris_s_parm()
in iris_vidc.c reject V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)?
iris_g_parm() still allows V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE into
iris_venc_g_param(), so VIDIOC_G_PARM on the CAPTURE queue succeeds and
reports V4L2_CAP_TIMEPERFRAME while VIDIOC_S_PARM on the CAPTURE queue returns
-EINVAL, breaking G_PARM/S_PARM symmetry in v4l2-compliance.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-topic-iris-encoder-fixes-v1-0-169ce…
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] media: qcom: iris: missing Fixes trailer for encoder property
subscription fix
--
commit 4aa187f4ac5b1a7930aa9f72c2011118f2583eeb
Author: Neil Armstrong <neil.armstrong(a)linaro.org>
> media: qcom: iris: gen2: subscribe to the picture type on the encoder instance
>
> The GEN2 iris expects the HFI_PROP_PICTURE_TYPE for the encoded
> buffers, but HFI_PROP_PICTURE_TYPE is never subscribed for the
> ENCODER instance in iris_hfi_gen2_subscribe_property().
>
> Add the necessary tables along the vdec input and output properties
> table for the GEN2 hardware.
>
> The tables are aligned with the vdec and downstream iris driver
> implementation subscribing to HFI_PROP_NO_OUTPUT for the input
> queue and HFI_PROP_PICTURE_TYPE for the output queue.
>
> Signed-off-by: Neil Armstrong <neil.armstrong(a)linaro.org>
[Severity: Low]
This fixes the missing encoder property subscriptions in
iris_hfi_gen2_subscribe_property(). Should this include:
Fixes: 92e007ca5ab6 ("media: iris: Add V4L2 streaming support for encoder video device")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-topic-iris-encoder-fixes-v1-0-169ce…