* updated maddy (0.7.1 -> 0.8.1), untested
[t2sde.git] / package / xorg / xorg-server / hotfix-ioperm.patch
blob1a059ec7b4e2bdddab03dc6b155ef9a4fc2fd043
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/xorg-server/hotfix-ioperm.patch
3 # Copyright (C) 2024 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 --- b/hw/xfree86/os-support/linux/lnx_video.c
15 +++ a/hw/xfree86/os-support/linux/lnx_video.c
16 @@ -116,38 +116,16 @@
17 static Bool
18 hwEnableIO(void)
20 + if (ioperm(0, 1024, 1) || iopl(3)) {
21 + ErrorF("xf86EnableIOPorts: failed to set IOPL for I/O (%s)\n",
22 - short i;
23 - size_t n=0;
24 - int begin, end;
25 - char *buf=NULL, target[5];
26 - FILE *fp;
28 - if (ioperm(0, 1024, 1)) {
29 - ErrorF("xf86EnableIO: failed to enable I/O ports 0000-03ff (%s)\n",
30 strerror(errno));
31 return FALSE;
34 #if !defined(__alpha__)
35 + /* XXX: this is actually not trapping anything because of iopl(3)
36 + * above */
37 + ioperm(0x40, 4, 0); /* trap access to the timer chip */
38 + ioperm(0x60, 4, 0); /* trap access to the keyboard controller */
39 - target[4] = '\0';
41 - /* trap access to the keyboard controller(s) and timer chip(s) */
42 - fp = fopen("/proc/ioports", "r");
43 - while (getline(&buf, &n, fp) != -1) {
44 - if ((strstr(buf, "keyboard") != NULL) || (strstr(buf, "timer") != NULL)) {
45 - for (i=0; i<4; i++)
46 - target[i] = buf[i+2];
47 - begin = atoi(target);
49 - for (i=0; i<4; i++)
50 - target[i] = buf[i+7];
51 - end = atoi(target);
53 - ioperm(begin, end-begin+1, 0);
54 - }
55 - }
56 - free(buf);
57 - fclose(fp);
58 #endif
60 return TRUE;