From d5f724544afd2949cebfcf4f0b4510ec0c701bec Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 16 Jun 2011 17:40:24 -0400 Subject: [PATCH 01/11] os: Repack ConnectionOutput for LP64 Reviewed-by: Daniel Stone Signed-off-by: Adam Jackson --- os/osdep.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/osdep.h b/os/osdep.h index 71a7e44e3..5fe019f5f 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -124,8 +124,8 @@ typedef struct _connectionInput { typedef struct _connectionOutput { struct _connectionOutput *next; - int size; unsigned char *buf; + int size; int count; } ConnectionOutput, *ConnectionOutputPtr; From f702372822dadb1fef92cfc25086481f640147b3 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 17 Jun 2011 12:58:25 -0400 Subject: [PATCH 02/11] dix: Repack ClientRec sizeof(ClientRec) ILP32 LP64 before 120 184 after 104 136 Reviewed-by: Daniel Stone Signed-off-by: Adam Jackson --- include/dixstruct.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/include/dixstruct.h b/include/dixstruct.h index 0a85f40b6..5fd595dc7 100644 --- a/include/dixstruct.h +++ b/include/dixstruct.h @@ -90,23 +90,22 @@ typedef struct _Client { Mask clientAsMask; pointer requestBuffer; pointer osPrivate; /* for OS layer, including scheduler */ - Bool swapped; + char swapped; + char big_requests; + char closeDownMode; + char clientGone; + char noClientException; /* this client died or needs to be + * killed */ + char clientState; ReplySwapPtr pSwapReplyFunc; XID errorValue; int sequence; - int closeDownMode; - int clientGone; - int noClientException; /* this client died or needs to be - * killed */ int ignoreCount; /* count for Attend/IgnoreClient */ - SaveSetElt *saveSet; int numSaved; - int (**requestVector) ( - ClientPtr /* pClient */); + SaveSetElt *saveSet; + int (**requestVector) (ClientPtr /* pClient */); CARD32 req_len; /* length of current request */ - Bool big_requests; /* supports large requests */ int priority; - ClientState clientState; PrivateRec *devPrivates; unsigned short xkbClientFlags; unsigned short mapNotifyMask; @@ -114,16 +113,16 @@ typedef struct _Client { unsigned short vMajor,vMinor; KeyCode minKC,maxKC; - unsigned long replyBytesRemaining; + unsigned int replyBytesRemaining; int smart_priority; - long smart_start_tick; - long smart_stop_tick; - long smart_check_tick; + int smart_start_tick; + int smart_stop_tick; + int smart_check_tick; DeviceIntPtr clientPtr; ClientIdPtr clientIds; unsigned short majorOp, minorOp; -} ClientRec; +} ClientRec; /* * Scheduling interface From 49d38b75c8f3276cfce33ffe6b8c4fbeb1081b96 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 17 Jun 2011 13:22:41 -0400 Subject: [PATCH 03/11] dix: Pull client-is-local flag up to the ClientRec Reviewed-by: Daniel Stone Signed-off-by: Adam Jackson --- Xext/xf86bigfont.c | 4 ++-- hw/kdrive/ephyr/ephyrdriext.c | 4 ++-- hw/xfree86/dixmods/extmod/xf86dga2.c | 2 +- hw/xfree86/dixmods/extmod/xf86vmode.c | 6 +++--- hw/xfree86/dri/xf86dri.c | 4 ++-- hw/xfree86/dri2/dri2ext.c | 2 +- hw/xquartz/applewm.c | 4 ++-- hw/xquartz/xpr/appledri.c | 4 ++-- hw/xwin/winwindowswm.c | 4 ++-- include/dixstruct.h | 1 + include/os.h | 2 -- os/access.c | 9 +-------- os/connection.c | 2 +- os/osdep.h | 1 - 14 files changed, 20 insertions(+), 29 deletions(-) diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index 4b63a13a1..5053852a4 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -300,7 +300,7 @@ ProcXF86BigfontQueryVersion( #endif reply.capabilities = #ifdef HAS_SHM - (LocalClient(client) && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0) + (client->local && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0) #else 0 #endif @@ -367,7 +367,7 @@ ProcXF86BigfontQueryFont( #else switch (client->req_len) { case 2: /* client with version 1.0 libX11 */ - stuff_flags = (LocalClient(client) && !client->swapped ? XF86Bigfont_FLAGS_Shm : 0); + stuff_flags = (client->local && !client->swapped ? XF86Bigfont_FLAGS_Shm : 0); break; case 3: /* client with version 1.1 libX11 */ stuff_flags = stuff->flags; diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c index 0741a7294..85e38e058 100644 --- a/hw/kdrive/ephyr/ephyrdriext.c +++ b/hw/kdrive/ephyr/ephyrdriext.c @@ -586,7 +586,7 @@ ProcXF86DRIQueryDirectRenderingCapable (register ClientPtr client) } rep.isCapable = isCapable; - if (!LocalClient(client) || client->swapped) + if (!client->local || client->swapped) rep.isCapable = 0; if (client->swapped) { @@ -1253,7 +1253,7 @@ ProcXF86DRIDispatch (register ClientPtr client) } } - if (!LocalClient(client)) + if (!client->local) return DRIErrorBase + XF86DRIClientNotLocal; switch (stuff->data) diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c index 4bcf77efd..4b17f152e 100644 --- a/hw/xfree86/dixmods/extmod/xf86dga2.c +++ b/hw/xfree86/dixmods/extmod/xf86dga2.c @@ -928,7 +928,7 @@ ProcXDGADispatch (ClientPtr client) { REQUEST(xReq); - if (!LocalClient(client)) + if (!client->local) return DGAErrorBase + XF86DGAClientNotLocal; #ifdef DGA_REQ_DEBUG diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c index 6d3d5fcbc..6e5e3f94c 100644 --- a/hw/xfree86/dixmods/extmod/xf86vmode.c +++ b/hw/xfree86/dixmods/extmod/xf86vmode.c @@ -1527,7 +1527,7 @@ ProcXF86VidModeGetPermissions(ClientPtr client) rep.sequenceNumber = client->sequence; rep.permissions = XF86VM_READ_PERMISSION; if (xf86GetVidModeEnabled() && - (xf86GetVidModeAllowNonLocal() || LocalClient (client))) { + (xf86GetVidModeAllowNonLocal() || client->local)) { rep.permissions |= XF86VM_WRITE_PERMISSION; } if(client->swapped) { @@ -1597,7 +1597,7 @@ ProcXF86VidModeDispatch(ClientPtr client) default: if (!xf86GetVidModeEnabled()) return VidModeErrorBase + XF86VidModeExtensionDisabled; - if (xf86GetVidModeAllowNonLocal() || LocalClient (client)) { + if (xf86GetVidModeAllowNonLocal() || client->local) { switch (stuff->data) { case X_XF86VidModeAddModeLine: return ProcXF86VidModeAddModeLine(client); @@ -2017,7 +2017,7 @@ SProcXF86VidModeDispatch(ClientPtr client) default: if (!xf86GetVidModeEnabled()) return VidModeErrorBase + XF86VidModeExtensionDisabled; - if (xf86GetVidModeAllowNonLocal() || LocalClient(client)) { + if (xf86GetVidModeAllowNonLocal() || client->local) { switch (stuff->data) { case X_XF86VidModeAddModeLine: return SProcXF86VidModeAddModeLine(client); diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index c35ba2f94..723e52622 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -130,7 +130,7 @@ ProcXF86DRIQueryDirectRenderingCapable( } rep.isCapable = isCapable; - if (!LocalClient(client) || client->swapped) + if (!client->local || client->swapped) rep.isCapable = 0; if (client->swapped) { @@ -557,7 +557,7 @@ ProcXF86DRIDispatch ( return ProcXF86DRIQueryDirectRenderingCapable(client); } - if (!LocalClient(client)) + if (!client->local) return DRIErrorBase + XF86DRIClientNotLocal; switch (stuff->data) diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c index 73ef7f25e..21331559f 100644 --- a/hw/xfree86/dri2/dri2ext.c +++ b/hw/xfree86/dri2/dri2ext.c @@ -547,7 +547,7 @@ ProcDRI2Dispatch (ClientPtr client) return ProcDRI2QueryVersion(client); } - if (!LocalClient(client)) + if (!client->local) return BadRequest; switch (stuff->data) { diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c index 55976c454..7077a6c6a 100644 --- a/hw/xquartz/applewm.c +++ b/hw/xquartz/applewm.c @@ -630,7 +630,7 @@ ProcAppleWMDispatch ( return ProcAppleWMQueryVersion(client); } - if (!LocalClient(client)) + if (!client->local) return WMErrorBase + AppleWMClientNotLocal; switch (stuff->data) @@ -693,7 +693,7 @@ SProcAppleWMDispatch ( REQUEST(xReq); /* It is bound to be non-local when there is byte swapping */ - if (!LocalClient(client)) + if (!client->local) return WMErrorBase + AppleWMClientNotLocal; /* only local clients are allowed WM access */ diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index 44c132abc..091145be3 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -133,7 +133,7 @@ ProcAppleDRIQueryDirectRenderingCapable( } rep.isCapable = isCapable; - if (!LocalClient(client)) + if (!client->local) rep.isCapable = 0; if (client->swapped) { @@ -365,7 +365,7 @@ ProcAppleDRIDispatch ( return ProcAppleDRIQueryDirectRenderingCapable(client); } - if (!LocalClient(client)) + if (!client->local) return DRIErrorBase + AppleDRIClientNotLocal; switch (stuff->data) diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c index 577614db6..f43834d5e 100644 --- a/hw/xwin/winwindowswm.c +++ b/hw/xwin/winwindowswm.c @@ -548,7 +548,7 @@ ProcWindowsWMDispatch (ClientPtr client) return ProcWindowsWMQueryVersion(client); } - if (!LocalClient(client)) + if (!client->local) return WMErrorBase + WindowsWMClientNotLocal; switch (stuff->data) @@ -598,7 +598,7 @@ SProcWindowsWMDispatch (ClientPtr client) REQUEST(xReq); /* It is bound to be non-local when there is byte swapping */ - if (!LocalClient(client)) + if (!client->local) return WMErrorBase + WindowsWMClientNotLocal; /* only local clients are allowed WM access */ diff --git a/include/dixstruct.h b/include/dixstruct.h index 5fd595dc7..cb370519e 100644 --- a/include/dixstruct.h +++ b/include/dixstruct.h @@ -91,6 +91,7 @@ typedef struct _Client { pointer requestBuffer; pointer osPrivate; /* for OS layer, including scheduler */ char swapped; + char local; char big_requests; char closeDownMode; char clientGone; diff --git a/include/os.h b/include/os.h index 48ce32962..84dedd5cb 100644 --- a/include/os.h +++ b/include/os.h @@ -353,8 +353,6 @@ typedef struct sockaddr * sockaddrPtr; extern _X_EXPORT int InvalidHost(sockaddrPtr /*saddr*/, int /*len*/, ClientPtr client); -extern _X_EXPORT int LocalClient(ClientPtr /* client */); - extern _X_EXPORT int LocalClientCred(ClientPtr, int *, int *); #define LCC_UID_SET (1 << 0) diff --git a/os/access.c b/os/access.c index b609442de..ed13d0a0d 100644 --- a/os/access.c +++ b/os/access.c @@ -1045,13 +1045,6 @@ ComputeLocalClient(ClientPtr client) return FALSE; } -Bool LocalClient(ClientPtr client) -{ - if (!client->osPrivate) - return FALSE; - return ((OsCommPtr)client->osPrivate)->local_client; -} - /* * Return the uid and gid of a connected local client * @@ -1209,7 +1202,7 @@ AuthorizedClient(ClientPtr client) if (rc != Success) return rc; - return LocalClient(client) ? Success : BadAccess; + return client->local ? Success : BadAccess; } /* Add a host to the access control list. This is the external interface diff --git a/os/connection.c b/os/connection.c index 8a677a7ef..575cfb80f 100644 --- a/os/connection.c +++ b/os/connection.c @@ -745,7 +745,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time) free(oc); return NullClient; } - oc->local_client = ComputeLocalClient(client); + client->local = ComputeLocalClient(client); #if !defined(WIN32) ConnectionTranslation[fd] = client->index; #else diff --git a/os/osdep.h b/os/osdep.h index 5fe019f5f..60cef27a2 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -166,7 +166,6 @@ typedef struct _osComm { XID auth_id; /* authorization id */ CARD32 conn_time; /* timestamp if not established, else 0 */ struct _XtransConnInfo *trans_conn; /* transport connection object */ - Bool local_client; } OsCommRec, *OsCommPtr; extern int FlushClient( From 78fa121f4097d29458e5453c13473595df06e26e Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 17 Jun 2011 13:43:38 -0400 Subject: [PATCH 04/11] dix: Extend initial connection handshake for forwarding proxies Forwarding proxies like sshd will appear to be local, even though they aren't really. This leads to weird behaviour for extensions that truly require running under the same OS services as the client, like MIT-SHM and DRI2. Add two new legal values for the initial connection's byteOrder field, 'r' and 'R'. These act like 'l' and 'B' respectively, but have the side effect of forcing the client to be treated as non-local. Forwarding proxies should attempt to munge the first packet of the connection accordingly; older servers will reject connections thusly munged, so the proxy should fall back to passthrough if the munged connection attempt fails. Reviewed-by: Daniel Stone Signed-off-by: Adam Jackson --- dix/dispatch.c | 12 +++++++++--- os/connection.c | 10 +++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 048dff652..554462328 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3578,12 +3578,14 @@ ProcInitialConnection(ClientPtr client) REQUEST(xReq); xConnClientPrefix *prefix; int whichbyte = 1; + char order; prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq); - if ((prefix->byteOrder != 'l') && (prefix->byteOrder != 'B')) + order = prefix->byteOrder; + if (order != 'l' && order != 'B' && order != 'r' && order != 'R') return client->noClientException = -1; - if (((*(char *) &whichbyte) && (prefix->byteOrder == 'B')) || - (!(*(char *) &whichbyte) && (prefix->byteOrder == 'l'))) + if (((*(char *) &whichbyte) && (order == 'B' || order == 'R')) || + (!(*(char *) &whichbyte) && (order == 'l' || order == 'r'))) { client->swapped = TRUE; SwapConnClientPrefix(prefix); @@ -3595,6 +3597,10 @@ ProcInitialConnection(ClientPtr client) { swaps(&stuff->length); } + if (order == 'r' || order == 'R') + { + client->local = FALSE; + } ResetCurrentRequest(client); return Success; } diff --git a/os/connection.c b/os/connection.c index 575cfb80f..f25106bd7 100644 --- a/os/connection.c +++ b/os/connection.c @@ -880,7 +880,7 @@ ErrorConnMax(XtransConnInfo trans_conn) xConnSetupPrefix csp; char pad[3]; struct iovec iov[3]; - char byteOrder = 0; + char order = 0; int whichbyte = 1; struct timeval waittime; fd_set mask; @@ -893,16 +893,16 @@ ErrorConnMax(XtransConnInfo trans_conn) FD_SET(fd, &mask); (void)Select(fd + 1, &mask, NULL, NULL, &waittime); /* try to read the byte-order of the connection */ - (void)_XSERVTransRead(trans_conn, &byteOrder, 1); - if ((byteOrder == 'l') || (byteOrder == 'B')) + (void)_XSERVTransRead(trans_conn, &order, 1); + if (order == 'l' || order == 'B' || order == 'r' || order == 'R') { csp.success = xFalse; csp.lengthReason = sizeof(NOROOM) - 1; csp.length = (sizeof(NOROOM) + 2) >> 2; csp.majorVersion = X_PROTOCOL; csp.minorVersion = X_PROTOCOL_REVISION; - if (((*(char *) &whichbyte) && (byteOrder == 'B')) || - (!(*(char *) &whichbyte) && (byteOrder == 'l'))) + if (((*(char *) &whichbyte) && (order == 'B' || order == 'R')) || + (!(*(char *) &whichbyte) && (order == 'l' || order == 'r'))) { swaps(&csp.majorVersion); swaps(&csp.minorVersion); From 48e7a2ef574c8b38c4f8f07b45f54c8bfd02552b Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 17 Jun 2011 14:03:01 -0400 Subject: [PATCH 05/11] os: Hide the Connection{In,Out}put implementation details Reviewed-by: Daniel Stone Signed-off-by: Adam Jackson --- os/connection.c | 2 +- os/io.c | 19 ++++++++++++++++++- os/osdep.h | 18 ++---------------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/os/connection.c b/os/connection.c index f25106bd7..0f1f87925 100644 --- a/os/connection.c +++ b/os/connection.c @@ -1030,7 +1030,7 @@ CloseDownConnection(ClientPtr client) if (FlushCallback) CallCallbacks(&FlushCallback, NULL); - if (oc->output && oc->output->count) + if (oc->output) FlushClient(client, oc, (char *)NULL, 0); #ifdef XDMCP XdmcpCloseDisplay(oc->fd); diff --git a/os/io.c b/os/io.c index ebb821653..bc3b83786 100644 --- a/os/io.c +++ b/os/io.c @@ -84,6 +84,23 @@ SOFTWARE. CallbackListPtr ReplyCallback; CallbackListPtr FlushCallback; +typedef struct _connectionInput { + struct _connectionInput *next; + char *buffer; /* contains current client input */ + char *bufptr; /* pointer to current start of data */ + int bufcnt; /* count of bytes in buffer */ + int lenLastReq; + int size; + unsigned int ignoreBytes; /* bytes to ignore before the next request */ +} ConnectionInput, *ConnectionInputPtr; + +typedef struct _connectionOutput { + struct _connectionOutput *next; + unsigned char *buf; + int size; + int count; +} ConnectionOutput, *ConnectionOutputPtr; + static ConnectionInputPtr AllocateInputBuffer(void); static ConnectionOutputPtr AllocateOutputBuffer(void); @@ -889,7 +906,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount) long notWritten; long todo; - if (!oco) + if (!oco || !oco->count) return 0; written = 0; padsize = padlength[extraCount & 3]; diff --git a/os/osdep.h b/os/osdep.h index 60cef27a2..9b9dda958 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -112,22 +112,8 @@ typedef Bool (*AddAuthorFunc)(unsigned name_length, const char *name, unsigned data_length, char *data); #endif -typedef struct _connectionInput { - struct _connectionInput *next; - char *buffer; /* contains current client input */ - char *bufptr; /* pointer to current start of data */ - int bufcnt; /* count of bytes in buffer */ - int lenLastReq; - int size; - unsigned int ignoreBytes; /* bytes to ignore before the next request */ -} ConnectionInput, *ConnectionInputPtr; - -typedef struct _connectionOutput { - struct _connectionOutput *next; - unsigned char *buf; - int size; - int count; -} ConnectionOutput, *ConnectionOutputPtr; +typedef struct _connectionInput *ConnectionInputPtr; +typedef struct _connectionOutput *ConnectionOutputPtr; struct _osComm; From c44ef2e1ff7bad168c348da63477b4636b3054fd Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 17 Jun 2011 14:17:09 -0400 Subject: [PATCH 06/11] os: Minor header cleanup Move some constants near their only users, and remove some getdtablesize() logic that's second-guessing configure. Reviewed-by: Daniel Stone Signed-off-by: Adam Jackson --- os/connection.c | 2 ++ os/io.c | 2 ++ os/osdep.h | 4 ---- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/os/connection.c b/os/connection.c index 0f1f87925..2c90d72a9 100644 --- a/os/connection.c +++ b/os/connection.c @@ -873,6 +873,8 @@ EstablishNewConnections(ClientPtr clientUnused, pointer closure) * Fail a connection due to lack of client or file descriptor space ************/ +#define BOTIMEOUT 200 /* in milliseconds */ + static void ErrorConnMax(XtransConnInfo trans_conn) { diff --git a/os/io.c b/os/io.c index bc3b83786..78b7260c7 100644 --- a/os/io.c +++ b/os/io.c @@ -129,6 +129,8 @@ static OsCommPtr AvailableInput = (OsCommPtr)NULL; ((xBigReq *)(req))->length) #define MAX_TIMES_PER 10 +#define BUFSIZE 4096 +#define BUFWATERMARK 8192 /* * A lot of the code in this file manipulates a ConnectionInputPtr: diff --git a/os/osdep.h b/os/osdep.h index 9b9dda958..c9add48ee 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -52,10 +52,6 @@ SOFTWARE. #ifndef _OSDEP_H_ #define _OSDEP_H_ 1 -#define BOTIMEOUT 200 /* in milliseconds */ -#define BUFSIZE 4096 -#define BUFWATERMARK 8192 - #if defined(XDMCP) || defined(HASXDMAUTH) #include #endif From a4553019a10b4e01cc06f3081db71a83338697b4 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 17 Jun 2011 14:30:06 -0400 Subject: [PATCH 07/11] dix: Fix types in WindowOptRec No reason for these to be 64 bits on LP64. Reviewed-by: Daniel Stone Signed-off-by: Adam Jackson --- include/windowstr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/windowstr.h b/include/windowstr.h index 222de31dc..1124dfc4c 100644 --- a/include/windowstr.h +++ b/include/windowstr.h @@ -87,8 +87,8 @@ typedef struct _WindowOpt { struct _OtherClients *otherClients; /* default: NULL */ struct _GrabRec *passiveGrabs; /* default: NULL */ PropertyPtr userProps; /* default: NULL */ - unsigned long backingBitPlanes; /* default: ~0L */ - unsigned long backingPixel; /* default: 0 */ + CARD32 backingBitPlanes; /* default: ~0L */ + CARD32 backingPixel; /* default: 0 */ RegionPtr boundingShape; /* default: NULL */ RegionPtr clipShape; /* default: NULL */ RegionPtr inputShape; /* default: NULL */ From 11977fab546da35d579ebe285e3c26864007805e Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 13 Dec 2011 21:00:05 -0500 Subject: [PATCH 08/11] xace: ricer tuning for XaceHook gcc doesn't want to hoist the check for XaceHooks[hook] != NULL above the varargs code for some reason, so do it ourselves. Before: 40000000 trep @ 0.0010 msec (1050420.2/sec): PutImage 10x10 square 60000000 trep @ 0.0005 msec (1921147.6/sec): ShmPutImage 10x10 square After: 40000000 trep @ 0.0009 msec (1087458.5/sec): PutImage 10x10 square 60000000 trep @ 0.0005 msec (2012238.6/sec): ShmPutImage 10x10 square Reviewed-by: Alan Coopersmith Signed-off-by: Adam Jackson --- Xext/xace.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Xext/xace.c b/Xext/xace.c index c757cad05..ef69fe363 100644 --- a/Xext/xace.c +++ b/Xext/xace.c @@ -101,6 +101,10 @@ int XaceHook(int hook, ...) } u; int *prv = NULL; /* points to return value from callback */ va_list ap; /* argument list */ + + if (!XaceHooks[hook]) + return Success; + va_start(ap, hook); /* Marshal arguments for passing to callback. From 83a98543b58c661a22574a6f8d8f9d777c0955b8 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 13 Dec 2011 20:23:40 -0500 Subject: [PATCH 09/11] dix: Tune dtrace hooks around Dispatch Don't call LookupMajorName if the hooks aren't active, it's quite expensive. Before: 40000000 trep @ 0.0009 msec (1087458.5/sec): PutImage 10x10 square 60000000 trep @ 0.0005 msec (2012238.6/sec): ShmPutImage 10x10 square After: 40000000 trep @ 0.0009 msec (1109091.3/sec): PutImage 10x10 square 60000000 trep @ 0.0005 msec (2072652.2/sec): ShmPutImage 10x10 square Reviewed-by: Alan Coopersmith Signed-off-by: Adam Jackson --- dix/dispatch.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 554462328..b91b41f4a 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -425,9 +425,11 @@ Dispatch(void) client->minorOp = ext->MinorOpcode(client); } #ifdef XSERVER_DTRACE - XSERVER_REQUEST_START(LookupMajorName(client->majorOp), client->majorOp, - ((xReq *)client->requestBuffer)->length, - client->index, client->requestBuffer); + if (XSERVER_REQUEST_START_ENABLED()) + XSERVER_REQUEST_START(LookupMajorName(client->majorOp), + client->majorOp, + ((xReq *)client->requestBuffer)->length, + client->index, client->requestBuffer); #endif if (result > (maxBigRequestSize << 2)) result = BadLength; @@ -438,8 +440,10 @@ Dispatch(void) XaceHookAuditEnd(client, result); } #ifdef XSERVER_DTRACE - XSERVER_REQUEST_DONE(LookupMajorName(client->majorOp), client->majorOp, - client->sequence, client->index, result); + if (XSERVER_REQUEST_DONE_ENABLED()) + XSERVER_REQUEST_DONE(LookupMajorName(client->majorOp), + client->majorOp, client->sequence, + client->index, result); #endif if (client->noClientException != Success) From 8f9bdfd293ad8e45755efe8d764b4dcc2a724f51 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 13 Dec 2011 21:23:12 -0500 Subject: [PATCH 10/11] dix: Tune dixLookupDrawable for success The vast vast vast majority of resource lookups are successful. Move some work to the error paths so we don't punish success. Before: 40000000 trep @ 0.0009 msec (1109091.3/sec): PutImage 10x10 square 60000000 trep @ 0.0005 msec (2072652.2/sec): ShmPutImage 10x10 square After: 40000000 trep @ 0.0009 msec (1148346.9/sec): PutImage 10x10 square 60000000 trep @ 0.0005 msec (2091666.1/sec): ShmPutImage 10x10 square Reviewed-by: Alan Coopersmith Signed-off-by: Adam Jackson --- dix/dixutils.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dix/dixutils.c b/dix/dixutils.c index 00bbde67c..2b5391f2d 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -202,13 +202,12 @@ dixLookupDrawable(DrawablePtr *pDraw, XID id, ClientPtr client, int rc; *pDraw = NULL; - client->errorValue = id; - - if (id == INVALID) - return BadDrawable; rc = dixLookupResourceByClass((pointer *)&pTmp, id, RC_DRAWABLE, client, access); + if (rc != Success) + client->errorValue = id; + if (rc == BadValue) return BadDrawable; if (rc != Success) From 777bf90abeac37087a3d0538b847742523d5acf2 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Mon, 18 Jul 2011 15:07:07 -0400 Subject: [PATCH 11/11] xfree86: Remove the pretense of EDID v2 support We don't do anything with EDID v2 blocks besides publish them on the root window. Worse, the check deleted by this patch would attempt to take a checksum of arbitrary memory if the rawData array isn't 256+ bytes long (and, for the monitors mentioned, it probably is only 128). Reviewed-by: Mark Kettenis Signed-off-by: Adam Jackson --- hw/xfree86/ddc/ddcProperty.c | 47 +++--------------------------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/hw/xfree86/ddc/ddcProperty.c b/hw/xfree86/ddc/ddcProperty.c index 5d6eec927..c3aced5c2 100644 --- a/hw/xfree86/ddc/ddcProperty.c +++ b/hw/xfree86/ddc/ddcProperty.c @@ -33,7 +33,6 @@ #include #define EDID1_ATOM_NAME "XFree86_DDC_EDID1_RAWDATA" -#define EDID2_ATOM_NAME "XFree86_DDC_EDID2_RAWDATA" static void edidMakeAtom(int i, const char *name, CARD8 *data, int size) @@ -52,59 +51,21 @@ edidMakeAtom(int i, const char *name, CARD8 *data, int size) static void addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC) { - int i, scrnIndex = pScrn->scrnIndex; - Bool makeEDID1prop = FALSE; - Bool makeEDID2prop = FALSE; + int scrnIndex = pScrn->scrnIndex; if (DDC->flags & MONITOR_DISPLAYID) { /* Don't bother, use RANDR already */ return; } else if (DDC->ver.version == 1) { - makeEDID1prop = TRUE; - } else if (DDC->ver.version == 2) { - int checksum1; - int checksum2; - makeEDID2prop = TRUE; + int size = 128 + + (DDC->flags & EDID_COMPLETE_RAWDATA ? DDC->no_sections * 128 : 0); - /* Some monitors (eg Panasonic PanaSync4) - * report version==2 because they used EDID v2 spec document, - * although they use EDID v1 data structure :-( - * - * Try using checksum to determine when we have such a monitor. - */ - checksum2 = 0; - for (i = 0; i < 256; i++) - checksum2 += DDC->rawData[i]; - if (checksum2 % 256) { - xf86DrvMsg(scrnIndex, X_INFO, "Monitor EDID v2 checksum failed\n"); - xf86DrvMsg(scrnIndex, X_INFO, - "XFree86_DDC_EDID2_RAWDATA property may be bad\n"); - checksum1 = 0; - for (i = 0; i < 128; i++) - checksum1 += DDC->rawData[i]; - if (!(checksum1 % 256)) { - xf86DrvMsg(scrnIndex, X_INFO, - "Monitor EDID v1 checksum passed,\n"); - xf86DrvMsg(scrnIndex, X_INFO, - "XFree86_DDC_EDID1_RAWDATA property created\n"); - makeEDID1prop = TRUE; - } - } + edidMakeAtom(scrnIndex, EDID1_ATOM_NAME, DDC->rawData, size); } else { xf86DrvMsg(scrnIndex, X_PROBED, "unexpected EDID version %d.%d\n", DDC->ver.version, DDC->ver.revision); return; } - - if (makeEDID1prop) { - int size = 128 + - (DDC->flags & EDID_COMPLETE_RAWDATA ? DDC->no_sections * 128 : 0); - - edidMakeAtom(scrnIndex, EDID1_ATOM_NAME, DDC->rawData, size); - } - - if (makeEDID2prop) - edidMakeAtom(scrnIndex, EDID2_ATOM_NAME, DDC->rawData, 256); } Bool