[Mesa-dev] [PATCH] util: Don't block SIGSYS for new threads
SIGSYS is needed for programs using seccomp for sandboxing. --- src/util/u_thread.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/u_thread.h b/src/util/u_thread.h index 7538d7d634b2..a46c18d3db20 100644 --- a/src/util/u_thread.h +++ b/src/util/u_thread.h @@ -44,7 +44,8 @@ static inline thrd_t u_thread_create(int (*routine)(void *), void *param) int ret; sigfillset(&new_set); - pthread_sigmask(SIG_SETMASK, &new_set, &saved_set); + sigdelset(&new_set, SIGSYS); + pthread_sigmask(SIG_BLOCK, &new_set, &saved_set); ret = thrd_create( &thread, routine, param ); pthread_sigmask(SIG_SETMASK, &saved_set, NULL); #else -- 2.20.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] st/va: Fix potential buffer overread
VASurfaceAttribExternalBuffers.pitches is indexed by plane. Current implementation only supports single plane layout. --- src/gallium/state_trackers/va/surface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 8604136944..6fe21b89e5 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -574,7 +574,7 @@ suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, memset(&whandle, 0, sizeof(struct winsys_handle)); whandle.type = DRM_API_HANDLE_TYPE_FD; whandle.handle = memory_attibute->buffers[index]; - whandle.stride = memory_attibute->pitches[index]; + whandle.stride = memory_attibute->pitches[0]; resource = pscreen->resource_from_handle(pscreen, &res_templ, &whandle, PIPE_HANDLE_USAGE_READ_WRITE); -- 2.17.0.441.gb46fe60e1d-goog ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] st/va: Fix typos
s/attibute/attribute/ s/suface/surface/ --- src/gallium/state_trackers/va/surface.c | 48 - 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 8604136944..1dc4466560 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -525,9 +525,9 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config_id, } static VAStatus -suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, -VASurfaceAttribExternalBuffers *memory_attibute, -unsigned index, struct pipe_video_buffer *templat) +surface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, + VASurfaceAttribExternalBuffers *memory_attribute, + unsigned index, struct pipe_video_buffer *templat) { vlVaDriver *drv; struct pipe_screen *pscreen; @@ -539,21 +539,21 @@ suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, pscreen = VL_VA_PSCREEN(ctx); drv = VL_VA_DRIVER(ctx); - if (!memory_attibute || !memory_attibute->buffers || - index > memory_attibute->num_buffers) + if (!memory_attribute || !memory_attribute->buffers || + index > memory_attribute->num_buffers) return VA_STATUS_ERROR_INVALID_PARAMETER; - if (surface->templat.width != memory_attibute->width || - surface->templat.height != memory_attibute->height || - memory_attibute->num_planes < 1) + if (surface->templat.width != memory_attribute->width || + surface->templat.height != memory_attribute->height || + memory_attribute->num_planes < 1) return VA_STATUS_ERROR_INVALID_PARAMETER; - switch (memory_attibute->pixel_format) { + switch (memory_attribute->pixel_format) { case VA_FOURCC_RGBA: case VA_FOURCC_RGBX: case VA_FOURCC_BGRA: case VA_FOURCC_BGRX: - if (memory_attibute->num_planes != 1) + if (memory_attribute->num_planes != 1) return VA_STATUS_ERROR_INVALID_PARAMETER; break; default: @@ -565,16 +565,16 @@ suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, res_templ.last_level = 0; res_templ.depth0 = 1; res_templ.array_size = 1; - res_templ.width0 = memory_attibute->width; - res_templ.height0 = memory_attibute->height; + res_templ.width0 = memory_attribute->width; + res_templ.height0 = memory_attribute->height; res_templ.format = surface->templat.buffer_format; res_templ.bind = PIPE_BIND_SAMPLER_VIEW; res_templ.usage = PIPE_USAGE_DEFAULT; memset(&whandle, 0, sizeof(struct winsys_handle)); whandle.type = DRM_API_HANDLE_TYPE_FD; - whandle.handle = memory_attibute->buffers[index]; - whandle.stride = memory_attibute->pitches[index]; + whandle.handle = memory_attribute->buffers[index]; + whandle.stride = memory_attribute->pitches[index]; resource = pscreen->resource_from_handle(pscreen, &res_templ, &whandle, PIPE_HANDLE_USAGE_READ_WRITE); @@ -629,7 +629,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, VASurfaceAttrib *attrib_list, unsigned int num_attribs) { vlVaDriver *drv; - VASurfaceAttribExternalBuffers *memory_attibute; + VASurfaceAttribExternalBuffers *memory_attribute; struct pipe_video_buffer templat; struct pipe_screen *pscreen; int i; @@ -655,7 +655,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, return VA_STATUS_ERROR_INVALID_CONTEXT; /* Default. */ - memory_attibute = NULL; + memory_attribute = NULL; memory_type = VA_SURFACE_ATTRIB_MEM_TYPE_VA; expected_fourcc = 0; @@ -687,7 +687,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, (attrib_list[i].flags == VA_SURFACE_ATTRIB_SETTABLE)) { if (attrib_list[i].value.type != VAGenericValueTypePointer) return VA_STATUS_ERROR_INVALID_PARAMETER; - memory_attibute = (VASurfaceAttribExternalBuffers *)attrib_list[i].value.value.p; + memory_attribute = (VASurfaceAttribExternalBuffers *)attrib_list[i].value.value.p; } } @@ -703,10 +703,10 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, case VA_SURFACE_ATTRIB_MEM_TYPE_VA: break; case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME: - if (!memory_attibute) + if (!memory_attribute) return VA_STATUS_ERROR_INVALID_PARAMETER; - expected_fourcc = memory_attibute->pixel_format; + expected_fourcc = memory_attribute->pixel_format; break; default: assert(0); @@ -730,7 +730,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, if (expected_fourcc) { enum pipe_format expected_format = VaFourccToPipeFormat(expected_fourcc); - if (expected_format !=
[Mesa-dev] [PATCH] st/va: Support YUV formats in vaCreateSurfaces
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 0824f1b74a..003f88f1f9 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -531,10 +531,12 @@ surface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, { vlVaDriver *drv; struct pipe_screen *pscreen; - struct pipe_resource *resource; struct pipe_resource res_templ; struct winsys_handle whandle; struct pipe_resource *resources[VL_NUM_COMPONENTS]; + const enum pipe_format *resource_formats = NULL; + VAStatus result; + int i; pscreen = VL_VA_PSCREEN(ctx); drv = VL_VA_DRIVER(ctx); @@ -548,17 +550,12 @@ surface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, memory_attribute->num_planes < 1) return VA_STATUS_ERROR_INVALID_PARAMETER; - switch (memory_attribute->pixel_format) { - case VA_FOURCC_RGBA: - case VA_FOURCC_RGBX: - case VA_FOURCC_BGRA: - case VA_FOURCC_BGRX: - if (memory_attribute->num_planes != 1) - return VA_STATUS_ERROR_INVALID_PARAMETER; - break; - default: + if (memory_attribute->num_planes > VL_NUM_COMPONENTS) + return VA_STATUS_ERROR_INVALID_PARAMETER; + + resource_formats = vl_video_buffer_formats(pscreen, templat->buffer_format); + if (!resource_formats) return VA_STATUS_ERROR_INVALID_PARAMETER; - } memset(&res_templ, 0, sizeof(res_templ)); res_templ.target = PIPE_TEXTURE_2D; @@ -567,29 +564,45 @@ surface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, res_templ.array_size = 1; res_templ.width0 = memory_attribute->width; res_templ.height0 = memory_attribute->height; - res_templ.format = surface->templat.buffer_format; res_templ.bind = PIPE_BIND_SAMPLER_VIEW; res_templ.usage = PIPE_USAGE_DEFAULT; memset(&whandle, 0, sizeof(struct winsys_handle)); whandle.type = DRM_API_HANDLE_TYPE_FD; whandle.handle = memory_attribute->buffers[index]; - whandle.stride = memory_attribute->pitches[0]; - - resource = pscreen->resource_from_handle(pscreen, &res_templ, &whandle, -PIPE_HANDLE_USAGE_READ_WRITE); - - if (!resource) - return VA_STATUS_ERROR_ALLOCATION_FAILED; + // Create a resource for each plane. memset(resources, 0, sizeof resources); - resources[0] = resource; + for (i = 0; i < memory_attribute->num_planes; i++) { + res_templ.format = resource_formats[i]; + if (res_templ.format == PIPE_FORMAT_NONE) { + result = VA_STATUS_ERROR_INVALID_PARAMETER; + goto fail; + } - surface->buffer = vl_video_buffer_create_ex2(drv->pipe, templat, resources); - if (!surface->buffer) - return VA_STATUS_ERROR_ALLOCATION_FAILED; + whandle.stride = memory_attribute->pitches[i]; + whandle.offset = memory_attribute->offsets[i]; + resources[i] = pscreen->resource_from_handle(pscreen, &res_templ, &whandle, + PIPE_HANDLE_USAGE_READ_WRITE); + if (!resources[i]) { + result = VA_STATUS_ERROR_ALLOCATION_FAILED; + goto fail; + } + } + surface->buffer = vl_video_buffer_create_ex2(drv->pipe, templat, resources); + if (!surface->buffer) { + result = VA_STATUS_ERROR_ALLOCATION_FAILED; + goto fail; + } return VA_STATUS_SUCCESS; + +fail: + for (i = 0; i < VL_NUM_COMPONENTS; i++) { + if (resources[i]) + pscreen->resource_destroy(pscreen, resources[i]); + } + return result; } VAStatus -- 2.17.0.441.gb46fe60e1d-goog ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] virgl: Support ARB_framebuffer_no_attachments
This change lets the following test pass on virgl: dEQP-GLES31.functional.state_query.framebuffer_default.framebuffer_default_samples_get_framebuffer_parameteriv --- src/gallium/drivers/virgl/virgl_screen.c | 4 1 file changed, 4 insertions(+) diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c index 1eefbd6519f..3035d4b5e20 100644 --- a/src/gallium/drivers/virgl/virgl_screen.c +++ b/src/gallium/drivers/virgl/virgl_screen.c @@ -495,6 +495,10 @@ virgl_is_format_supported( struct pipe_screen *screen, } if (bind & PIPE_BIND_RENDER_TARGET) { + /* For ARB_framebuffer_no_attachments. */ + if (format == PIPE_FORMAT_NONE) + return TRUE; + if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) return FALSE; -- 2.16.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] virgl: Support ARB_framebuffer_no_attachments
On Wed, Jun 27, 2018 at 1:57 AM Emil Velikov wrote: > > On 27 June 2018 at 09:55, Emil Velikov wrote: > > Hi Drew, > > > > Just some food for thought. The patch in itself looks correct albeit > > partial. > > > > On 27 June 2018 at 00:00, Drew Davenport wrote: > >> This change lets the following test pass on virgl: > >> dEQP-GLES31.functional.state_query.framebuffer_default.framebuffer_default_samples_get_framebuffer_parameteriv > >> --- > >> src/gallium/drivers/virgl/virgl_screen.c | 4 > >> 1 file changed, 4 insertions(+) > >> > >> diff --git a/src/gallium/drivers/virgl/virgl_screen.c > >> b/src/gallium/drivers/virgl/virgl_screen.c > >> index 1eefbd6519f..3035d4b5e20 100644 > >> --- a/src/gallium/drivers/virgl/virgl_screen.c > >> +++ b/src/gallium/drivers/virgl/virgl_screen.c > >> @@ -495,6 +495,10 @@ virgl_is_format_supported( struct pipe_screen *screen, > >> } > >> > >> if (bind & PIPE_BIND_RENDER_TARGET) { > >> + /* For ARB_framebuffer_no_attachments. */ > >> + if (format == PIPE_FORMAT_NONE) > >> + return TRUE; > >> + > > > > For ARB_framebuffer_no_attachments to be advertised, one should return > > 1 for the PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT query. > > In current master says "not supported" (returns 0) and I couldn't spot > > any patch that toggles it. This patch was on top of the gl-4.3 branch from https://gitlab.freedesktop.org/airlied/mesa.git, which does advertise support for that capability. > > > > Is this a test which requires the functionality, without checking for > > the extension presence? > > Or perhaps the test is part of a larger series, which flips the switch? Perhaps I jumped the gun sending this patch now, since it depends on a bunch of other work that hasn't been merged yet. If it makes more sense I don't mind holding onto this patch for now and trying to get it merged later. > > > Silly typo, above should read > "Or perhaps the patch is part ..." > > -Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] virgl: Support ARB_framebuffer_no_attachments
On Wed, Jun 27, 2018 at 6:47 AM Ilia Mirkin wrote: > > On Tue, Jun 26, 2018 at 7:00 PM, Drew Davenport > wrote: > > This change lets the following test pass on virgl: > > dEQP-GLES31.functional.state_query.framebuffer_default.framebuffer_default_samples_get_framebuffer_parameteriv > > --- > > src/gallium/drivers/virgl/virgl_screen.c | 4 > > 1 file changed, 4 insertions(+) > > > > diff --git a/src/gallium/drivers/virgl/virgl_screen.c > > b/src/gallium/drivers/virgl/virgl_screen.c > > index 1eefbd6519f..3035d4b5e20 100644 > > --- a/src/gallium/drivers/virgl/virgl_screen.c > > +++ b/src/gallium/drivers/virgl/virgl_screen.c > > @@ -495,6 +495,10 @@ virgl_is_format_supported( struct pipe_screen *screen, > > } > > > > if (bind & PIPE_BIND_RENDER_TARGET) { > > + /* For ARB_framebuffer_no_attachments. */ > > + if (format == PIPE_FORMAT_NONE) > > + return TRUE; > > + > > This has to be gated on the host driver supporting this functionality, > right? I.e. ES 3.1 or having this ext. > > Also dEQP has a lot of no-fb tests (unfortunately I don't remember > what they're called off-hand... maybe *no_framebuffer* or > *no_attach*), you should ensure they all pass (or fail for > known/understood reasons). Yes, there are a bunch of tests (dEQP-GLES31.functional.fbo.no_attachments.*) that are currently failing. If you'd prefer to have a series of patches that address these all together, I can hold off on this patch for now. Thanks for your feedback. > > Cheers, > > -ilia ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] RFC: Workaround for pthread_setaffinity_np() seccomp filtering
We ran into a similar issue with this syscall in Chrome OS. This patch addressed the issue: https://lists.freedesktop.org/archives/mesa-dev/2019-February/215721.html Does it help in this case as well? On Wed, Feb 27, 2019 at 4:13 PM wrote: > > From: Marc-André Lureau > > Since commit d877451b48a59ab0f9a4210fc736f51da5851c9a ("util/u_queue: > add UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY"), mesa calls > sched_setaffinity syscall. Unfortunately, qemu crashes with SIGSYS > when sandboxing is enabled (by default with libvirt), as this syscall > is filtered. > > There doesn't seem to be a way to check for the seccomp rule other > than doing a call, which may result in various behaviour depending on > seccomp actions. There is a PTRACE_SECCOMP_GET_FILTER, but it is > low-level and a priviledged operation (but there might be a way to use > it?). A safe way would be to try the call in a subprocess, > unfortunately, qemu also prohibits fork(). Also this could be subject > to TOCTOU. > > There seems to be few solutions, but the issue can be considered a > regression for various libvirt/Boxes users. > > Introduce MESA_NO_THREAD_AFFINITY environment variable to prevent the > offending call. Wrap pthread_setaffinity_np() in a utility function > u_pthread_setaffinity_np(), returning a EACCESS error if the variable > is set. > > Note: one call is left with a FIXME, as I didn't investigate how to > build and test it, help welcome! > > See also: > https://bugs.freedesktop.org/show_bug.cgi?id=109695 > > Signed-off-by: Marc-André Lureau > --- > .../drivers/swr/rasterizer/core/threads.cpp | 1 + > src/util/u_queue.c| 2 +- > src/util/u_thread.h | 15 ++- > 3 files changed, 16 insertions(+), 2 deletions(-) > > diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp > b/src/gallium/drivers/swr/rasterizer/core/threads.cpp > index e30c1170568..d10c79512a1 100644 > --- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp > +++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp > @@ -364,6 +364,7 @@ void bindThread(SWR_CONTEXT* pContext, > CPU_ZERO(&cpuset); > CPU_SET(threadId, &cpuset); > > +/* FIXME: use u_pthread_setaffinity_np() if possible */ > int err = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset); > if (err != 0) > { > diff --git a/src/util/u_queue.c b/src/util/u_queue.c > index 3812c824b6d..dea8d2bb4ae 100644 > --- a/src/util/u_queue.c > +++ b/src/util/u_queue.c > @@ -249,7 +249,7 @@ util_queue_thread_func(void *input) >for (unsigned i = 0; i < CPU_SETSIZE; i++) > CPU_SET(i, &cpuset); > > - pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset); > + u_pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset); > } > #endif > > diff --git a/src/util/u_thread.h b/src/util/u_thread.h > index a46c18d3db2..a4e6dbae5d7 100644 > --- a/src/util/u_thread.h > +++ b/src/util/u_thread.h > @@ -70,6 +70,19 @@ static inline void u_thread_setname( const char *name ) > (void)name; > } > > +#if defined(HAVE_PTHREAD_SETAFFINITY) > +static inline int u_pthread_setaffinity_np(pthread_t thread, size_t > cpusetsize, > + const cpu_set_t *cpuset) > +{ > + if (getenv("MESA_NO_THREAD_AFFINITY")) { > + errno = EACCES; > + return -1; > + } > + > + return pthread_setaffinity_np(thread, cpusetsize, cpuset); > +} > +#endif > + > /** > * An AMD Zen CPU consists of multiple modules where each module has its own > L3 > * cache. Inter-thread communication such as locks and atomics between > modules > @@ -89,7 +102,7 @@ util_pin_thread_to_L3(thrd_t thread, unsigned L3_index, > unsigned cores_per_L3) > CPU_ZERO(&cpuset); > for (unsigned i = 0; i < cores_per_L3; i++) >CPU_SET(L3_index * cores_per_L3 + i, &cpuset); > - pthread_setaffinity_np(thread, sizeof(cpuset), &cpuset); > + u_pthread_setaffinity_np(thread, sizeof(cpuset), &cpuset); > #endif > } > > -- > 2.21.0 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev