[MPlayer-dev-eng] Re: amd64 -sws 0 fix (iow: playing with NX bit)

Ian Lindsay iml at formicary.org
Fri Jan 21 01:56:55 CET 2005


trivial diff to disable NX bit via mprotect().
-------------- next part --------------
Index: postproc/swscale.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale.c,v
retrieving revision 1.147
diff -u -r1.147 swscale.c
--- postproc/swscale.c	21 Oct 2004 11:55:20 -0000	1.147
+++ postproc/swscale.c	21 Jan 2005 00:52:39 -0000
@@ -61,6 +61,10 @@
 #else
 #include <stdlib.h>
 #endif
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/types.h>
+#include <sys/mman.h>
+#endif
 #include "swscale.h"
 #include "swscale_internal.h"
 #include "../cpudetect.h"
@@ -2004,6 +2008,12 @@
 			c->lumMmx2FilterPos= (int32_t*)memalign(8, (dstW      /2/8+8)*sizeof(int32_t));
 			c->chrMmx2FilterPos= (int32_t*)memalign(8, (c->chrDstW/2/4+8)*sizeof(int32_t));
 
+			if (mprotect(c->funnyYCode, sizeof(c->funnyYCode), \
+			    PROT_EXEC | PROT_READ | PROT_WRITE) || \
+			    mprotect(c->funnyUVCode, sizeof(c->funnyUVCode), \
+			    PROT_EXEC | PROT_READ | PROT_WRITE))
+				MSG_ERR("swScaler: generated code may be NX\n");
+
 			initMMX2HScaler(      dstW, c->lumXInc, c->funnyYCode , c->lumMmx2Filter, c->lumMmx2FilterPos, 8);
 			initMMX2HScaler(c->chrDstW, c->chrXInc, c->funnyUVCode, c->chrMmx2Filter, c->chrMmx2FilterPos, 4);
 		}


More information about the MPlayer-dev-eng mailing list