1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Jocelyn Falempe <jfalempe@redhat.com>
3 Date: Thu, 14 Apr 2022 14:39:37 +0200
4 Subject: [PATCH] Refuse to run if framebuffer or dri devices are present
6 The simpledrm driver, introduced in kernel 5.14,
7 can replace efifb to provide the efi framebuffer.
9 This fixes a bug on Fedora 36 (first version to use simpledrm driver):
10 https://bugzilla.redhat.com/show_bug.cgi?id=2074789
12 v2: check for framebuffer or dri devices instead of efi framebuffer interface.
14 Reviewed-by: Adam Jackson <ajax@redhat.com>
15 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
16 Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
18 src/vesa.c | 39 ++++++++++++++++++++++++++++++++++-----
19 1 file changed, 34 insertions(+), 5 deletions(-)
21 diff --git a/src/vesa.c b/src/vesa.c
22 index b2a1922c2332..2bf18e9f278c 100644
32 /* All drivers initialising the SW cursor need this */
33 @@ -439,22 +440,50 @@ VESAInitScrn(ScrnInfoPtr pScrn)
34 pScrn->FreeScreen = VESAFreeScreen;
37 +#ifdef XSERVER_LIBPCIACCESS
40 + * check if a file exist in directory
41 + * should be equivalent to a glob ${directory}/${prefix}*
45 +VESAFileExistsPrefix(const char *directory, const char *prefix) {
47 + struct dirent *entry;
49 + int len = strlen(prefix);
51 + dir = opendir(directory);
55 + while ((entry = readdir(dir)) != NULL) {
56 + if (strlen(entry->d_name) > len &&
57 + !memcmp(entry->d_name, prefix, len)) {
68 * This function is called once, at the start of the first server generation to
69 * do a minimal probe for supported hardware.
72 -#ifdef XSERVER_LIBPCIACCESS
74 VESAPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
80 - if (access("/sys/devices/platform/efi-framebuffer.0", F_OK) == 0 ||
81 - access("/sys/devices/platform/efifb.0", F_OK) == 0) {
82 - ErrorF("vesa: Refusing to run on UEFI\n");
83 + if (VESAFileExistsPrefix("/dev", "fb") ||
84 + VESAFileExistsPrefix("/dev/dri", "card")) {
85 + ErrorF("vesa: Refusing to run, Framebuffer or dri device present\n");