xserver: Branch 'xwayland-23.2' - 7 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Oct 12 09:39:45 UTC 2023


 glamor/glamor.c                   |    4 ++++
 glamor/glamor_xv.c                |    4 ++--
 hw/xwayland/man/Xwayland.man      |    9 +++++++++
 hw/xwayland/meson.build           |    1 +
 hw/xwayland/xwayland-glamor-gbm.c |   22 +++++++++++++++++++---
 hw/xwayland/xwayland-present.c    |    8 +++++---
 hw/xwayland/xwayland-screen.c     |    7 +++++++
 hw/xwayland/xwayland-screen.h     |    1 +
 hw/xwayland/xwayland-xtest.c      |   10 ++++++++--
 hw/xwayland/xwayland.c            |    6 ++++++
 10 files changed, 62 insertions(+), 10 deletions(-)

New commits:
commit 4f8a851b60cab2d6ea43c821532e486ce92da066
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Oct 10 17:37:37 2023 +0200

    xwayland: Cancel the EI disconnect timer when freed
    
    Xwayland maintains a connection to EI up for 10 minutes after an X11
    client has vanished, to avoid going through the connection phase every
    time a short lived X11 client comes and goes.
    
    However, if the EI client gets freed (through some other event, e.g. the
    user decides to terminate the EI session), Xwayland would still keep the
    callback alive and end up trying to free an already freed EI client:
    
     Invalid read of size 4
        at 0x4C5E6F9: object_unref (util-object.h:89)
        by 0x4C5E6F9: ei_unref (libei.c:77)
        by 0x429525: free_ei (xwayland-xtest.c:224)
        by 0x429A6E: disconnect_timer_cb (xwayland-xtest.c:404)
        by 0x5E63FF: DoTimer (WaitFor.c:276)
        by 0x5E6463: DoTimers (WaitFor.c:290)
        by 0x5E6164: check_timers (WaitFor.c:133)
        by 0x5E61E9: WaitForSomething (WaitFor.c:195)
        by 0x4AD50E: Dispatch (dispatch.c:487)
        by 0x4BBA0B: dix_main (main.c:272)
        by 0x43615D: main (stubmain.c:34)
      Address 0x15cc6ee8 is 8 bytes inside a block of size 240 free'd
        at 0x48452AC: free (vg_replace_malloc.c:974)
        by 0x4C5E729: object_destroy (util-object.h:73)
        by 0x4C5E729: object_unref (util-object.h:91)
        by 0x4C5E729: ei_unref (libei.c:77)
        by 0x429525: free_ei (xwayland-xtest.c:224)
        by 0x42A946: xwl_handle_ei_event (xwayland-xtest.c:804)
        by 0x5EA977: HandleNotifyFd (connection.c:809)
        by 0x5EE8E3: ospoll_wait (ospoll.c:657)
        by 0x5E624D: WaitForSomething (WaitFor.c:208)
        by 0x4AD50E: Dispatch (dispatch.c:487)
        by 0x4BBA0B: dix_main (main.c:272)
        by 0x43615D: main (stubmain.c:34)
      Block was alloc'd at
        at 0x484782C: calloc (vg_replace_malloc.c:1554)
        by 0x4C5E777: ei_create (libei.c:73)
        by 0x4C5E777: ei_create_context (libei.c:97)
        by 0x42994B: setup_ei (xwayland-xtest.c:366)
        by 0x42A383: xwayland_xtest_send_events (xwayland-xtest.c:658)
        by 0x54ED4C: ProcXTestFakeInput (xtest.c:441)
        by 0x54EE56: ProcXTestDispatch (xtest.c:475)
        by 0x4AD6E6: Dispatch (dispatch.c:546)
        by 0x4BBA0B: dix_main (main.c:272)
        by 0x43615D: main (stubmain.c:34)
    
    To avoid that issue, make sure to cancel the timer as soon as a EI
    client is freed.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    See-also: https://bugzilla.redhat.com/2243076
    (cherry picked from commit 9617de733becb04f547191570978dcbc449bb11e)

diff --git a/hw/xwayland/xwayland-xtest.c b/hw/xwayland/xwayland-xtest.c
index 69686daab..b5eef57e6 100644
--- a/hw/xwayland/xwayland-xtest.c
+++ b/hw/xwayland/xwayland-xtest.c
@@ -200,6 +200,7 @@ free_ei(struct xwl_ei_client *xwl_ei_client)
     struct xwl_abs_device *abs, *tmp;
     ClientPtr client = xwl_ei_client->client;
 
+    TimerCancel(xwl_ei_client->disconnect_timer);
     xorg_list_del(&xwl_ei_client->link);
 
     debug_ei("Removing EI fd=%d\n", xwl_ei_client->ei_fd);
commit cc79b2a83696e9e1d046ecad82820977226b444b
Author: Jeffy Chen <jeffy.chen at rock-chips.com>
Date:   Fri Nov 8 15:44:41 2019 +0800

    glamor: xv: Fix invalid accessing of plane attributes for NV12
    
    NV12 only has 2 planes.
    
    Signed-off-by: Jeffy Chen <jeffy.chen at rock-chips.com>
    (cherry picked from commit 0076671e24670f1ddb151946e490497f171589f0)

diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index a3d6b3bc3..e0e8e0ba9 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -291,10 +291,10 @@ glamor_xv_query_image_attributes(int id,
             pitches[0] = size;
         size *= *h;
         if (offsets)
-            offsets[1] = offsets[2] = size;
+            offsets[1] = size;
         tmp = ALIGN(*w, 4);
         if (pitches)
-            pitches[1] = pitches[2] = tmp;
+            pitches[1] = tmp;
         tmp *= (*h >> 1);
         size += tmp;
         break;
commit 07c18c90e49180a30c08b6ca6caa1196e21cf703
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Fri Sep 29 18:04:49 2023 +0200

    xwayland: Give up on EI on setup failure
    
    If we fail to setup EI, give up on using EI for XTEST and restore the
    default XTEST handlers.
    
    This happens when neither the portal nor the socket backends are usable.
    
    This does not affect the portal operation though, if the user choose not
    to allow a particular client, Xwayland would continue to use EI.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Joshua Ashton <joshua at froggi.es>
    (cherry picked from commit 6b56ae68e5476bdda00a6c5f4e2311a13b3d12cc)

diff --git a/hw/xwayland/xwayland-xtest.c b/hw/xwayland/xwayland-xtest.c
index 74778ce8b..69686daab 100644
--- a/hw/xwayland/xwayland-xtest.c
+++ b/hw/xwayland/xwayland-xtest.c
@@ -387,6 +387,8 @@ setup_ei(ClientPtr client)
         xwl_ei_client = NULL;
         ei_unref(ei);
         error_ei("EI setup failed\n");
+        /* We failed to setup EI using either backends, give up on EI. */
+        xwayland_restore_xtest();
     }
 
  out:
commit 10353a01a2cead8f118df01698225d1284cbc067
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Fri Sep 29 10:19:13 2023 +0200

    xwayland: Add an option to enable EI portal support
    
    With EI support wired to XTEST, and oeffis being enabled unconditionally
    means that Xwayland will always go through the XDG portal for XTEST when
    supported.
    
    While this the intended behavior for the general use case of Xwayland
    running rootless on a desktop compositor, that breaks when Xwayland is
    running on a nested compositor, because the portal is for the entire
    session and not limited to the nested Wayland compositor.
    
    Xwayland itself, as a regular Wayland client, has no way to tell that it
    is running on a nested compositor.
    
    So to keep backward compatibility with existing (and also common) use
    cases such as nested compositors, best is to disable support for the XDG
    portal by default, and add a new command line option "-enable-ei-portal"
    for the Wayland compositors (who spawn Xwayland rootless) to explicitly
    enable support for the input emulation XDG portal in Xwayland.
    
    A Wayland compositor running nested should not use that command line
    option with Xwayland.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Joshua Ashton <joshua at froggi.es>
    Fixes: a1333342 - xwayland: Add XTEST support using EIS
    Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1586
    See-also: https://gitlab.gnome.org/GNOME/mutter/-/issues/3047
    (cherry picked from commit cfcbb075c23fc668e84a381c9c2c165a95798cf4)

diff --git a/hw/xwayland/man/Xwayland.man b/hw/xwayland/man/Xwayland.man
index 02b333be9..9ecb65001 100644
--- a/hw/xwayland/man/Xwayland.man
+++ b/hw/xwayland/man/Xwayland.man
@@ -61,6 +61,15 @@ backend first, then fallback to the GBM backend if EGLStream is not supported
 by the Wayland server. Without this option, \fIXwayland\fP tries the GBM
 backend first, and fallback to EGLStream if GBM is not usable.
 .TP 8
+.B \-enable-ei-portal
+Enable support for the XDG portal for input emulation.
+
+A Wayland compositor running nested should not use that command line
+option with Xwayland.
+
+This option has no effect if the compositor doesn't support the relevant
+XDG portal or if Xwayland was not compiled with EI and OEFFIS support.
+.TP 8
 .B \-fullscreen
 Set the Xwayland window fullscreen when running rootful.
 
diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build
index f2038ab7c..54529b64e 100644
--- a/hw/xwayland/meson.build
+++ b/hw/xwayland/meson.build
@@ -186,6 +186,7 @@ xwayland_vars = [
     'have_fullscreen=true',
     'have_host_grab=true',
     'have_decorate=' + have_libdecor.to_string(),
+    'have_enable_ei_portal=' + build_ei_portal.to_string(),
     'have_byteswappedclients=true',
 ]
 
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index c00f976a8..cc14e0771 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -812,6 +812,13 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
             use_fixed_size = 1;
 #else
             ErrorF("This build does not have libdecor support\n");
+#endif
+        }
+        else if (strcmp(argv[i], "-enable-ei-portal") == 0) {
+#ifdef XWL_HAS_EI_PORTAL
+            xwl_screen->enable_ei_portal = 1;
+#else
+            ErrorF("This build does not have XDG portal support\n");
 #endif
         }
     }
diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h
index 94033aabf..bd66dd681 100644
--- a/hw/xwayland/xwayland-screen.h
+++ b/hw/xwayland/xwayland-screen.h
@@ -67,6 +67,7 @@ struct xwl_screen {
     int host_grab;
     int has_grab;
     int decorate;
+    int enable_ei_portal;
 
     CreateScreenResourcesProcPtr CreateScreenResources;
     CloseScreenProcPtr CloseScreen;
diff --git a/hw/xwayland/xwayland-xtest.c b/hw/xwayland/xwayland-xtest.c
index 333013cea..74778ce8b 100644
--- a/hw/xwayland/xwayland-xtest.c
+++ b/hw/xwayland/xwayland-xtest.c
@@ -334,12 +334,14 @@ setup_ei_from_socket(struct xwl_ei_client *xwl_ei_client)
 static struct xwl_ei_client *
 setup_ei(ClientPtr client)
 {
+    ScreenPtr pScreen = screenInfo.screens[0];
     struct xwl_ei_client *xwl_ei_client = NULL;
+    struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
     struct ei *ei = NULL;
     char buffer[PATH_MAX];
     const char *cmdname;
     char *client_name = NULL;
-    bool status;
+    bool status = false;
 
     cmdname = GetClientCmdName(client);
     if (cmdname) {
@@ -375,7 +377,8 @@ setup_ei(ClientPtr client)
     xorg_list_init(&xwl_ei_client->pending_emulated_events);
     xorg_list_init(&xwl_ei_client->abs_devices);
 
-    status = setup_oeffis(xwl_ei_client);
+    if (xwl_screen->enable_ei_portal)
+        status = setup_oeffis(xwl_ei_client);
     if (!status)
         status = setup_ei_from_socket(xwl_ei_client);
 
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 672dc3168..3f9c5c269 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -109,6 +109,9 @@ ddxUseMsg(void)
 #ifdef XWL_HAS_LIBDECOR
     ErrorF("-decorate              add decorations to Xwayland when rootful\n");
 #endif
+#ifdef XWL_HAS_EI_PORTAL
+    ErrorF("-enable-ei-portal      use the XDG portal for input emulation\n");
+#endif
 }
 
 static int init_fd = -1;
@@ -246,6 +249,9 @@ ddxProcessArgument(int argc, char *argv[], int i)
     else if (strcmp(argv[i], "-decorate") == 0) {
         return 1;
     }
+    else if (strcmp(argv[i], "-enable-ei-portal") == 0) {
+        return 1;
+    }
 
     return 0;
 }
commit 4f8e209d2c32d68c8dfaa99dbf29cf1c95663d46
Author: José Expósito <jexposit at redhat.com>
Date:   Wed Aug 30 18:38:03 2023 +0200

    xwayland/glamor/gbm: Set GBM_BO_USE_LINEAR if only LINEAR modifier is supported
    
    Some drivers might not support explicit format modifiers. On these
    drivers `gbm_bo_create_with_modifiers()` will fail and the
    `gbm_bo_create()` code path will be used instead.
    
    In this case, if the LINEAR modifier is advertised (and the INVALID
    modifier is not) add the `GBM_BO_USE_LINEAR` flag.
    
    Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1438
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>
    Signed-off-by: José Expósito's avatarJosé Expósito <jexposit at redhat.com>
    (cherry picked from commit 287638db59d0938ceb263fcef1bf0c28eefb2033)

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index b177b77e0..cfcd39a35 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -284,6 +284,8 @@ xwl_glamor_gbm_create_pixmap_internal(struct xwl_screen *xwl_screen,
     struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
     struct gbm_bo *bo = NULL;
     PixmapPtr pixmap = NULL;
+    uint32_t num_modifiers = 0;
+    uint64_t *modifiers = NULL;
 
     if (width > 0 && height > 0 && depth >= 15 &&
         (hint == CREATE_PIXMAP_USAGE_BACKING_PIXMAP ||
@@ -294,8 +296,6 @@ xwl_glamor_gbm_create_pixmap_internal(struct xwl_screen *xwl_screen,
 
 #ifdef GBM_BO_WITH_MODIFIERS
         if (xwl_gbm->dmabuf_capable) {
-            uint32_t num_modifiers = 0;
-            uint64_t *modifiers = NULL;
             Bool supports_scanout = FALSE;
 
             if (drawable) {
@@ -324,7 +324,6 @@ xwl_glamor_gbm_create_pixmap_internal(struct xwl_screen *xwl_screen,
                                                   format, modifiers, num_modifiers);
 #endif
             }
-            free(modifiers);
         }
 #endif
         if (bo == NULL) {
@@ -332,6 +331,22 @@ xwl_glamor_gbm_create_pixmap_internal(struct xwl_screen *xwl_screen,
             implicit = TRUE;
             if (implicit_scanout)
                 usage |= GBM_BO_USE_SCANOUT;
+
+            if (num_modifiers > 0) {
+                Bool has_mod_invalid = FALSE, has_mod_linear = FALSE;
+                int i;
+
+                for (i = 0; i < num_modifiers; i++) {
+                    if (modifiers[i] == DRM_FORMAT_MOD_INVALID)
+                        has_mod_invalid = TRUE;
+                    else if (modifiers[i] == DRM_FORMAT_MOD_LINEAR)
+                        has_mod_linear = TRUE;
+                }
+
+                if (!has_mod_invalid && has_mod_linear)
+                    usage |= GBM_BO_USE_LINEAR;
+            }
+
             bo = gbm_bo_create(xwl_gbm->gbm, width, height, format, usage);
         }
 
@@ -350,6 +365,7 @@ xwl_glamor_gbm_create_pixmap_internal(struct xwl_screen *xwl_screen,
     if (!pixmap)
         pixmap = glamor_create_pixmap(xwl_screen->screen, width, height, depth, hint);
 
+    free(modifiers);
     return pixmap;
 }
 
commit c9a842e60720fffcd851922114127b9ed86d2972
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Mon Sep 25 10:47:20 2023 +0200

    xwayland/present: Handle NULL window_priv in xwl_present_cleanup
    
    This can happen if the window has never completed a Present operation.
    
    Fixes: 42301760802e ("xwayland/present: Embed present_vblank_rec in xwl_present_event")
    (cherry picked from commit 32c5b2c044604c5b1039035fd1f320c33988a2e3)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 5ede33e4c..941be06da 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -414,9 +414,11 @@ xwl_present_cleanup(WindowPtr window)
         xwl_present_window->sync_callback = NULL;
     }
 
-    /* Clear remaining events */
-    xorg_list_for_each_entry_safe(event, tmp, &window_priv->vblank, vblank.window_list)
-        xwl_present_free_event(event);
+    if (window_priv) {
+        /* Clear remaining events */
+        xorg_list_for_each_entry_safe(event, tmp, &window_priv->vblank, vblank.window_list)
+            xwl_present_free_event(event);
+    }
 
     /* Clear timer */
     xwl_present_free_timer(xwl_present_window);
commit 2bd43be92c81385b3ea3fff5a237b0f8f7c63414
Author: Konstantin <ria.freelander at gmail.com>
Date:   Fri Dec 2 16:22:15 2022 +0300

    glamor: fixes GL_INVALID_ENUM errors on ES if there is no quads
    
    If there is no quads to draw, then we have a possibility to call
    glDrawElements with type as zero, which will generate
    GL_INVALID_ENUM error. While this error is harmless, it is annoying.
    
    Signed-off-by: Konstantin <ria.freelander at gmail.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    (cherry picked from commit baaddf47d593b51d215d836a796b95a3cb14a220)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 617766c2a..848b484cf 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -307,6 +307,10 @@ glamor_gldrawarrays_quads_using_indices(glamor_screen_private *glamor_priv,
 {
     unsigned i;
 
+    /* If there is no quads to draw, just exit */
+    if (count == 0)
+        return;
+
     /* For a single quad, don't bother with an index buffer. */
     if (count ==  1)
         goto fallback;


More information about the xorg-commit mailing list