# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/xorg-server/hotfix-ioperm.patch # Copyright (C) 2024 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License version 2 as used by the T2 SDE. # --- T2-COPYRIGHT-NOTE-END --- --- b/hw/xfree86/os-support/linux/lnx_video.c +++ a/hw/xfree86/os-support/linux/lnx_video.c @@ -116,38 +116,16 @@ static Bool hwEnableIO(void) { + if (ioperm(0, 1024, 1) || iopl(3)) { + ErrorF("xf86EnableIOPorts: failed to set IOPL for I/O (%s)\n", - short i; - size_t n=0; - int begin, end; - char *buf=NULL, target[5]; - FILE *fp; - - if (ioperm(0, 1024, 1)) { - ErrorF("xf86EnableIO: failed to enable I/O ports 0000-03ff (%s)\n", strerror(errno)); return FALSE; } - #if !defined(__alpha__) + /* 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 */ - 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); #endif return TRUE;