* [PATCH] drm/msm/adreno: Ensure that the zap shader region is big enough
@ 2019-05-31 22:09 Jordan Crouse
[not found] ` <1559340578-11482-1-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Jordan Crouse @ 2019-05-31 22:09 UTC (permalink / raw)
To: freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Douglas Anderson, Kees Cook, Jonathan Marek, David Airlie,
linux-arm-msm-u79uwXL29TY76Z2rM5mHXA, Sharat Masetty,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A, Rob Clark, Mamta Shukla,
Daniel Vetter, Sean Paul
Before loading the zap shader we should ensure that the reserved memory
region is big enough to hold the loaded file.
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---
drivers/gpu/drm/msm/adreno/adreno_gpu.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 6f7f411..3db8e49 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -67,7 +67,6 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
return ret;
mem_phys = r.start;
- mem_size = resource_size(&r);
/* Request the MDT file for the firmware */
fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
@@ -83,6 +82,13 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
goto out;
}
+ if (mem_size > resource_size(&r)) {
+ DRM_DEV_ERROR(dev,
+ "memory region is too small to load the MDT\n");
+ ret = -E2BIG;
+ goto out;
+ }
+
/* Allocate memory for the firmware image */
mem_region = memremap(mem_phys, mem_size, MEMREMAP_WC);
if (!mem_region) {
--
2.7.4
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/msm/adreno: Ensure that the zap shader region is big enough
[not found] ` <1559340578-11482-1-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
@ 2019-06-01 5:48 ` Bjorn Andersson
2019-06-03 14:56 ` Jeffrey Hugo
1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2019-06-01 5:48 UTC (permalink / raw)
To: Jordan Crouse
Cc: Kees Cook, Jonathan Marek, David Airlie,
freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Sharat Masetty,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Douglas Anderson,
Rob Clark, Mamta Shukla, Daniel Vetter,
linux-arm-msm-u79uwXL29TY76Z2rM5mHXA, Sean Paul
On Fri 31 May 15:09 PDT 2019, Jordan Crouse wrote:
> Before loading the zap shader we should ensure that the reserved memory
> region is big enough to hold the loaded file.
>
> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>
> drivers/gpu/drm/msm/adreno/adreno_gpu.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index 6f7f411..3db8e49 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -67,7 +67,6 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> return ret;
>
> mem_phys = r.start;
> - mem_size = resource_size(&r);
>
> /* Request the MDT file for the firmware */
> fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> @@ -83,6 +82,13 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> goto out;
> }
>
> + if (mem_size > resource_size(&r)) {
> + DRM_DEV_ERROR(dev,
> + "memory region is too small to load the MDT\n");
> + ret = -E2BIG;
> + goto out;
> + }
> +
> /* Allocate memory for the firmware image */
> mem_region = memremap(mem_phys, mem_size, MEMREMAP_WC);
> if (!mem_region) {
> --
> 2.7.4
>
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/msm/adreno: Ensure that the zap shader region is big enough
[not found] ` <1559340578-11482-1-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2019-06-01 5:48 ` Bjorn Andersson
@ 2019-06-03 14:56 ` Jeffrey Hugo
1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey Hugo @ 2019-06-03 14:56 UTC (permalink / raw)
To: Jordan Crouse
Cc: Sean Paul, Kees Cook, Jonathan Marek, David Airlie, MSM,
Sharat Masetty, Douglas Anderson, open list:DRM PANEL DRIVERS,
lkml, Rob Clark, Mamta Shukla, Daniel Vetter, Bjorn Andersson,
freedreno
On Fri, May 31, 2019 at 4:09 PM Jordan Crouse <jcrouse@codeaurora.org> wrote:
>
> Before loading the zap shader we should ensure that the reserved memory
> region is big enough to hold the loaded file.
>
> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Reviewed-by: Jeffrey Hugo <jeffrey.l.hugo@gmail.com>
> ---
>
> drivers/gpu/drm/msm/adreno/adreno_gpu.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index 6f7f411..3db8e49 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -67,7 +67,6 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> return ret;
>
> mem_phys = r.start;
> - mem_size = resource_size(&r);
>
> /* Request the MDT file for the firmware */
> fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> @@ -83,6 +82,13 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> goto out;
> }
>
> + if (mem_size > resource_size(&r)) {
> + DRM_DEV_ERROR(dev,
> + "memory region is too small to load the MDT\n");
> + ret = -E2BIG;
> + goto out;
> + }
> +
> /* Allocate memory for the firmware image */
> mem_region = memremap(mem_phys, mem_size, MEMREMAP_WC);
> if (!mem_region) {
> --
> 2.7.4
>
> _______________________________________________
> Freedreno mailing list
> Freedreno@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/freedreno
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-03 14:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-31 22:09 [PATCH] drm/msm/adreno: Ensure that the zap shader region is big enough Jordan Crouse
[not found] ` <1559340578-11482-1-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2019-06-01 5:48 ` Bjorn Andersson
2019-06-03 14:56 ` Jeffrey Hugo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox