# --- T2-COPYRIGHT-BEGIN --- # t2/package/*/xorg-server/hotfix-ioperm.patch # Copyright (C) 2024 - 2026 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 or patched project license # --- T2-COPYRIGHT-END --- --- a/hw/xfree86/os-support/linux/lnx_video.c +++ b/hw/xfree86/os-support/linux/lnx_video.c @@ -116,38 +116,16 @@ static Bool hwEnableIO(void) { - short i; - size_t n=0; - int begin, end; - char *buf=NULL, target[5]; - FILE *fp; - if (ioperm(0, 1024, 1) || iopl(3)) { - ErrorF("xf86EnableIO: failed to enable I/O ports access (%s)\n", + ErrorF("xf86EnableIOPorts: failed to set IOPL for I/O (%s)\n", strerror(errno)); return FALSE; } - #if !defined(__alpha__) - target[4] = '\0'; - - /* trap access to the keyboard controller(s) and timer chip(s) */ - fp = fopen("/proc/ioports", "r"); - while (getline(&buf, &n, fp) != -1) { - if ((strstr(buf, "keyboard") != NULL) || (strstr(buf, "timer") != NULL)) { - for (i=0; i<4; i++) - target[i] = buf[i+2]; - begin = atoi(target); - - for (i=0; i<4; i++) - target[i] = buf[i+7]; - end = atoi(target); - - ioperm(begin, end-begin+1, 0); - } - } - free(buf); - fclose(fp); + /* XXX: this is actually not trapping anything because of iopl(3) + * above */ + ioperm(0x40, 4, 0); /* trap access to the timer chip */ + ioperm(0x60, 4, 0); /* trap access to the keyboard controller */ #endif return TRUE;