* [Qemu-devel] [PATCH v2] ui/console: Precautionary glBindTexture and surface->texture validation in surface_gl_update_texture
@ 2019-05-07 5:49 Marcel Apfelbaum
2019-05-07 6:25 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 5+ messages in thread
From: Marcel Apfelbaum @ 2019-05-07 5:49 UTC (permalink / raw)
To: qemu-devel; +Cc: kraxel, hqm03ster
From: HQM <hqm03ster@gmail.com>
In a GVT-g setup with dmabuf and GTK GUI, the current 2D texture at
surface_gl_update_texture is not necessarily
surface->texture. Adding a glBindTexture fixes related crashes and
artifacts, and is generally more secure.
Signed-off-by: HQM <hqm03ster@gmail.com>
Tested-by: Marcel Apfelbaum<marcel.apfelbaum@gmail.com>
[fixed malformed patch, rebase to master]
Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
---
v2:
- fixed malformed patch
- rebased to master
ui/console-gl.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/ui/console-gl.c b/ui/console-gl.c
index a56e1cd8eb..c1cb3bd673 100644
--- a/ui/console-gl.c
+++ b/ui/console-gl.c
@@ -92,13 +92,17 @@ void surface_gl_update_texture(QemuGLShader *gls,
assert(gls);
- glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
- surface_stride(surface) / surface_bytes_per_pixel(surface));
- glTexSubImage2D(GL_TEXTURE_2D, 0,
- x, y, w, h,
- surface->glformat, surface->gltype,
- data + surface_stride(surface) * y
- + surface_bytes_per_pixel(surface) * x);
+ if (surface->texture) {
+ glBindTexture(GL_TEXTURE_2D, surface->texture);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
+ surface_stride(surface)
+ / surface_bytes_per_pixel(surface));
+ glTexSubImage2D(GL_TEXTURE_2D, 0,
+ x, y, w, h,
+ surface->glformat, surface->gltype,
+ data + surface_stride(surface) * y
+ + surface_bytes_per_pixel(surface) * x);
+ }
}
void surface_gl_render_texture(QemuGLShader *gls,
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2] ui/console: Precautionary glBindTexture and surface->texture validation in surface_gl_update_texture
2019-05-07 5:49 [Qemu-devel] [PATCH v2] ui/console: Precautionary glBindTexture and surface->texture validation in surface_gl_update_texture Marcel Apfelbaum
@ 2019-05-07 6:25 ` Philippe Mathieu-Daudé
2019-05-07 6:49 ` Hou Qiming
0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-07 6:25 UTC (permalink / raw)
To: Marcel Apfelbaum, qemu-devel; +Cc: kraxel, hqm03ster
Hi Marcel,
On 5/7/19 7:49 AM, Marcel Apfelbaum wrote:
> From: HQM <hqm03ster@gmail.com>
>
> In a GVT-g setup with dmabuf and GTK GUI, the current 2D texture at
> surface_gl_update_texture is not necessarily
> surface->texture. Adding a glBindTexture fixes related crashes and
> artifacts, and is generally more secure.
>
> Signed-off-by: HQM <hqm03ster@gmail.com>
This looks like an acronym, per
https://wiki.qemu.org/Contribute/SubmitAPatch#Patch_emails_must_include_a_Signed-off-by:_line
"Patch emails must include a Signed-off-by: line [...] Please use your
real name to sign a patch (not an alias or acronym)."
> Tested-by: Marcel Apfelbaum<marcel.apfelbaum@gmail.com>
> [fixed malformed patch, rebase to master]
> Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> ---
>
> v2:
> - fixed malformed patch
> - rebased to master
>
> ui/console-gl.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/ui/console-gl.c b/ui/console-gl.c
> index a56e1cd8eb..c1cb3bd673 100644
> --- a/ui/console-gl.c
> +++ b/ui/console-gl.c
> @@ -92,13 +92,17 @@ void surface_gl_update_texture(QemuGLShader *gls,
>
> assert(gls);
>
> - glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
> - surface_stride(surface) / surface_bytes_per_pixel(surface));
> - glTexSubImage2D(GL_TEXTURE_2D, 0,
> - x, y, w, h,
> - surface->glformat, surface->gltype,
> - data + surface_stride(surface) * y
> - + surface_bytes_per_pixel(surface) * x);
> + if (surface->texture) {
> + glBindTexture(GL_TEXTURE_2D, surface->texture);
> + glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
> + surface_stride(surface)
> + / surface_bytes_per_pixel(surface));
> + glTexSubImage2D(GL_TEXTURE_2D, 0,
> + x, y, w, h,
> + surface->glformat, surface->gltype,
> + data + surface_stride(surface) * y
> + + surface_bytes_per_pixel(surface) * x);
> + }
> }
>
> void surface_gl_render_texture(QemuGLShader *gls,
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2] ui/console: Precautionary glBindTexture and surface->texture validation in surface_gl_update_texture
2019-05-07 6:25 ` Philippe Mathieu-Daudé
@ 2019-05-07 6:49 ` Hou Qiming
2019-05-07 7:44 ` Philippe Mathieu-Daudé
2019-05-07 8:00 ` Marcel Apfelbaum
0 siblings, 2 replies; 5+ messages in thread
From: Hou Qiming @ 2019-05-07 6:49 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel, Gerd Hoffmann
My real name is "HOU Qiming". @Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
can you incorporate that in your v2 patch? Thanks!
Qiming
On Tue, May 7, 2019 at 2:25 PM Philippe Mathieu-Daudé <philmd@redhat.com>
wrote:
> Hi Marcel,
>
> On 5/7/19 7:49 AM, Marcel Apfelbaum wrote:
> > From: HQM <hqm03ster@gmail.com>
> >
> > In a GVT-g setup with dmabuf and GTK GUI, the current 2D texture at
> > surface_gl_update_texture is not necessarily
> > surface->texture. Adding a glBindTexture fixes related crashes and
> > artifacts, and is generally more secure.
> >
> > Signed-off-by: HQM <hqm03ster@gmail.com>
>
> This looks like an acronym, per
>
> https://wiki.qemu.org/Contribute/SubmitAPatch#Patch_emails_must_include_a_Signed-off-by:_line
>
> "Patch emails must include a Signed-off-by: line [...] Please use your
> real name to sign a patch (not an alias or acronym)."
>
> > Tested-by: Marcel Apfelbaum<marcel.apfelbaum@gmail.com>
> > [fixed malformed patch, rebase to master]
> > Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> > ---
> >
> > v2:
> > - fixed malformed patch
> > - rebased to master
> >
> > ui/console-gl.c | 18 +++++++++++-------
> > 1 file changed, 11 insertions(+), 7 deletions(-)
> >
> > diff --git a/ui/console-gl.c b/ui/console-gl.c
> > index a56e1cd8eb..c1cb3bd673 100644
> > --- a/ui/console-gl.c
> > +++ b/ui/console-gl.c
> > @@ -92,13 +92,17 @@ void surface_gl_update_texture(QemuGLShader *gls,
> >
> > assert(gls);
> >
> > - glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
> > - surface_stride(surface) /
> surface_bytes_per_pixel(surface));
> > - glTexSubImage2D(GL_TEXTURE_2D, 0,
> > - x, y, w, h,
> > - surface->glformat, surface->gltype,
> > - data + surface_stride(surface) * y
> > - + surface_bytes_per_pixel(surface) * x);
> > + if (surface->texture) {
> > + glBindTexture(GL_TEXTURE_2D, surface->texture);
> > + glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
> > + surface_stride(surface)
> > + / surface_bytes_per_pixel(surface));
> > + glTexSubImage2D(GL_TEXTURE_2D, 0,
> > + x, y, w, h,
> > + surface->glformat, surface->gltype,
> > + data + surface_stride(surface) * y
> > + + surface_bytes_per_pixel(surface) * x);
> > + }
> > }
> >
> > void surface_gl_render_texture(QemuGLShader *gls,
> >
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2] ui/console: Precautionary glBindTexture and surface->texture validation in surface_gl_update_texture
2019-05-07 6:49 ` Hou Qiming
@ 2019-05-07 7:44 ` Philippe Mathieu-Daudé
2019-05-07 8:00 ` Marcel Apfelbaum
1 sibling, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-07 7:44 UTC (permalink / raw)
To: Hou Qiming; +Cc: qemu-devel, Gerd Hoffmann
On 5/7/19 8:49 AM, Hou Qiming wrote:
> My real name is "HOU Qiming". @Marcel Apfelbaum
> <mailto:marcel.apfelbaum@gmail.com> can you incorporate that in your v2
> patch? Thanks!
Thanks a lot Qiming :)
> On Tue, May 7, 2019 at 2:25 PM Philippe Mathieu-Daudé <philmd@redhat.com
> <mailto:philmd@redhat.com>> wrote:
>
> Hi Marcel,
>
> On 5/7/19 7:49 AM, Marcel Apfelbaum wrote:
> > From: HQM <hqm03ster@gmail.com <mailto:hqm03ster@gmail.com>>
> >
> > In a GVT-g setup with dmabuf and GTK GUI, the current 2D texture at
> > surface_gl_update_texture is not necessarily
> > surface->texture. Adding a glBindTexture fixes related crashes and
> > artifacts, and is generally more secure.
> >
> > Signed-off-by: HQM <hqm03ster@gmail.com <mailto:hqm03ster@gmail.com>>
>
> This looks like an acronym, per
> https://wiki.qemu.org/Contribute/SubmitAPatch#Patch_emails_must_include_a_Signed-off-by:_line
>
> "Patch emails must include a Signed-off-by: line [...] Please use your
> real name to sign a patch (not an alias or acronym)."
>
> > Tested-by: Marcel Apfelbaum<marcel.apfelbaum@gmail.com
> <mailto:marcel.apfelbaum@gmail.com>>
> > [fixed malformed patch, rebase to master]
> > Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com
> <mailto:marcel.apfelbaum@gmail.com>>
> > ---
> >
> > v2:
> > - fixed malformed patch
> > - rebased to master
> >
> > ui/console-gl.c | 18 +++++++++++-------
> > 1 file changed, 11 insertions(+), 7 deletions(-)
> >
> > diff --git a/ui/console-gl.c b/ui/console-gl.c
> > index a56e1cd8eb..c1cb3bd673 100644
> > --- a/ui/console-gl.c
> > +++ b/ui/console-gl.c
> > @@ -92,13 +92,17 @@ void surface_gl_update_texture(QemuGLShader *gls,
> >
> > assert(gls);
> >
> > - glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
> > - surface_stride(surface) /
> surface_bytes_per_pixel(surface));
> > - glTexSubImage2D(GL_TEXTURE_2D, 0,
> > - x, y, w, h,
> > - surface->glformat, surface->gltype,
> > - data + surface_stride(surface) * y
> > - + surface_bytes_per_pixel(surface) * x);
> > + if (surface->texture) {
> > + glBindTexture(GL_TEXTURE_2D, surface->texture);
> > + glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
> > + surface_stride(surface)
> > + / surface_bytes_per_pixel(surface));
> > + glTexSubImage2D(GL_TEXTURE_2D, 0,
> > + x, y, w, h,
> > + surface->glformat, surface->gltype,
> > + data + surface_stride(surface) * y
> > + + surface_bytes_per_pixel(surface) * x);
> > + }
> > }
> >
> > void surface_gl_render_texture(QemuGLShader *gls,
> >
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2] ui/console: Precautionary glBindTexture and surface->texture validation in surface_gl_update_texture
2019-05-07 6:49 ` Hou Qiming
2019-05-07 7:44 ` Philippe Mathieu-Daudé
@ 2019-05-07 8:00 ` Marcel Apfelbaum
1 sibling, 0 replies; 5+ messages in thread
From: Marcel Apfelbaum @ 2019-05-07 8:00 UTC (permalink / raw)
To: Hou Qiming, Philippe Mathieu-Daudé; +Cc: qemu-devel, Gerd Hoffmann
On 5/7/19 9:49 AM, Hou Qiming wrote:
> My real name is "HOU Qiming". @Marcel Apfelbaum
> <mailto:marcel.apfelbaum@gmail.com> can you incorporate that in your
> v2 patch? Thanks!
>
Sure thing,
Thanks,
Marcel
> Qiming
>
> On Tue, May 7, 2019 at 2:25 PM Philippe Mathieu-Daudé
> <philmd@redhat.com <mailto:philmd@redhat.com>> wrote:
>
> Hi Marcel,
>
> On 5/7/19 7:49 AM, Marcel Apfelbaum wrote:
> > From: HQM <hqm03ster@gmail.com <mailto:hqm03ster@gmail.com>>
> >
> > In a GVT-g setup with dmabuf and GTK GUI, the current 2D texture at
> > surface_gl_update_texture is not necessarily
> > surface->texture. Adding a glBindTexture fixes related crashes and
> > artifacts, and is generally more secure.
> >
> > Signed-off-by: HQM <hqm03ster@gmail.com
> <mailto:hqm03ster@gmail.com>>
>
> This looks like an acronym, per
> https://wiki.qemu.org/Contribute/SubmitAPatch#Patch_emails_must_include_a_Signed-off-by:_line
>
> "Patch emails must include a Signed-off-by: line [...] Please use your
> real name to sign a patch (not an alias or acronym)."
>
> > Tested-by: Marcel Apfelbaum<marcel.apfelbaum@gmail.com
> <mailto:marcel.apfelbaum@gmail.com>>
> > [fixed malformed patch, rebase to master]
> > Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com
> <mailto:marcel.apfelbaum@gmail.com>>
> > ---
> >
> > v2:
> > - fixed malformed patch
> > - rebased to master
> >
> > ui/console-gl.c | 18 +++++++++++-------
> > 1 file changed, 11 insertions(+), 7 deletions(-)
> >
> > diff --git a/ui/console-gl.c b/ui/console-gl.c
> > index a56e1cd8eb..c1cb3bd673 100644
> > --- a/ui/console-gl.c
> > +++ b/ui/console-gl.c
> > @@ -92,13 +92,17 @@ void surface_gl_update_texture(QemuGLShader
> *gls,
> >
> > assert(gls);
> >
> > - glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
> > - surface_stride(surface) /
> surface_bytes_per_pixel(surface));
> > - glTexSubImage2D(GL_TEXTURE_2D, 0,
> > - x, y, w, h,
> > - surface->glformat, surface->gltype,
> > - data + surface_stride(surface) * y
> > - + surface_bytes_per_pixel(surface) * x);
> > + if (surface->texture) {
> > + glBindTexture(GL_TEXTURE_2D, surface->texture);
> > + glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
> > + surface_stride(surface)
> > + / surface_bytes_per_pixel(surface));
> > + glTexSubImage2D(GL_TEXTURE_2D, 0,
> > + x, y, w, h,
> > + surface->glformat, surface->gltype,
> > + data + surface_stride(surface) * y
> > + + surface_bytes_per_pixel(surface) * x);
> > + }
> > }
> >
> > void surface_gl_render_texture(QemuGLShader *gls,
> >
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-05-07 8:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-07 5:49 [Qemu-devel] [PATCH v2] ui/console: Precautionary glBindTexture and surface->texture validation in surface_gl_update_texture Marcel Apfelbaum
2019-05-07 6:25 ` Philippe Mathieu-Daudé
2019-05-07 6:49 ` Hou Qiming
2019-05-07 7:44 ` Philippe Mathieu-Daudé
2019-05-07 8:00 ` Marcel Apfelbaum
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.