Compare commits

...
Author SHA1 Message Date
xXJsonDeruloXx 7f5e128a25 test: revert 275
Revert 0607bb0b3a for a signed test build comparing behavior without the KGSL GEM_CLOSE fix.
2026-10-05 22:40:29 -04:00
2 changed files with 9 additions and 44 deletions

No files matched your search

+1 -1
View File
@@ -343,7 +343,7 @@ jobs:
echo "::error::libfakeinput.so exports the C++ runtime"; exit 1 echo "::error::libfakeinput.so exports the C++ runtime"; exit 1
fi fi
SESSION=$(syms "$D/libblsession.so") SESSION=$(syms "$D/libblsession.so")
for sym in socket bind getsockname setsockopt statfs statvfs syscall shm_open shm_unlink mmap mmap64 munmap drmPrimeFDToHandle drmCloseBufferHandle drmIoctl; do for sym in socket bind getsockname setsockopt statfs statvfs syscall shm_open shm_unlink mmap mmap64 munmap; do
grep -qx "$sym" <<<"$SESSION" || { echo "::error::libblsession.so does not export $sym"; exit 1; } grep -qx "$sym" <<<"$SESSION" || { echo "::error::libblsession.so does not export $sym"; exit 1; }
done done
test -f "$D/usr/local/bin/droiddeck-session" test -f "$D/usr/local/bin/droiddeck-session"
+8 -43
View File
@@ -12,19 +12,11 @@
#include <pthread.h> #include <pthread.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#define MAX_HANDLES 4096 #define MAX_HANDLES 4096
/* DRM_IOCTL_GEM_CLOSE from drm.h: _IOW('d', 0x09, struct drm_gem_close { u32 handle, pad; }). */
struct gem_close {
uint32_t handle;
uint32_t pad;
};
#define GEM_CLOSE _IOW('d', 0x09, struct gem_close)
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static int handle_fds[MAX_HANDLES]; static int handle_fds[MAX_HANDLES];
static dev_t kgsl_dev; static dev_t kgsl_dev;
@@ -90,47 +82,20 @@ int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd) {
return ret; return ret;
} }
/* Drops a handle's descriptor; false when the handle was never given out. */
static int release_handle(uint32_t handle) {
int found = 0;
pthread_mutex_lock(&lock);
if (handle > 0 && handle < MAX_HANDLES && handle_fds[handle] > 0) {
close(handle_fds[handle]);
handle_fds[handle] = 0;
found = 1;
}
pthread_mutex_unlock(&lock);
return found;
}
int drmCloseBufferHandle(int fd, uint32_t handle) { int drmCloseBufferHandle(int fd, uint32_t handle) {
if (!is_kgsl(fd)) { if (!is_kgsl(fd)) {
int (*fn)(int, uint32_t) = (int (*)(int, uint32_t)) real("drmCloseBufferHandle"); int (*fn)(int, uint32_t) = (int (*)(int, uint32_t)) real("drmCloseBufferHandle");
return fn ? fn(fd, handle) : -ENOSYS; return fn ? fn(fd, handle) : -ENOSYS;
} }
return release_handle(handle) ? 0 : -EINVAL; int ret = -EINVAL;
} pthread_mutex_lock(&lock);
if (handle > 0 && handle < MAX_HANDLES && handle_fds[handle] > 0) {
/* close(handle_fds[handle]);
* Zink gives its handles back with the GEM_CLOSE ioctl itself, not drmCloseBufferHandle handle_fds[handle] = 0;
* (zink_bo.c, bo_destroy). KGSL refuses the ioctl, so the duplicated descriptor stayed open and ret = 0;
* kept the whole buffer alive: Xwayland asks for a handle for every buffer it imports, and a game
* whose swapchain was recreated on each resize piled up gigabytes of old swapchain images until
* Android killed the session.
*/
int drmIoctl(int fd, unsigned long request, void *arg) {
if (request == GEM_CLOSE && arg && is_kgsl(fd)) {
if (release_handle(((struct gem_close *) arg)->handle)) {
return 0;
}
errno = EINVAL;
return -1;
} }
int (*fn)(int, unsigned long, void *) = (int (*)(int, unsigned long, void *)) real("drmIoctl"); pthread_mutex_unlock(&lock);
if (!fn) { return ret;
return -1;
}
return fn(fd, request, arg);
} }
/* /*