Commits (6)
  • Ray Strode's avatar
    xkb: Drop check for XkbSetMapResizeTypes · 8b7f4d32
    Ray Strode authored and Ray Strode's avatar Ray Strode committed
    Commit 446ff2d3 added checks to
    prevalidate the size of incoming SetMap requests.
    
    That commit checks for the XkbSetMapResizeTypes flag to be set before
    allowing key types data to be processed.
    
    key types data can be changed or even just sent wholesale unchanged
    without the number of key types changing, however. The check for
    XkbSetMapResizeTypes rejects those legitimate requests. In particular,
    XkbChangeMap never sets XkbSetMapResizeTypes and so always fails now
    any time XkbKeyTypesMask is in the changed mask.
    
    This commit drops the check for XkbSetMapResizeTypes in flags when
    prevalidating the request length.
    8b7f4d32
  • Mario Kleiner's avatar
    modesetting: Enable GAMMA_LUT for lut's with up to 4096 slots. · 66e5a5bb
    Mario Kleiner authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
    A lut size of 4096 slots has been verified to work correctly,
    as tested with amdgpu-kms. Intel Tigerlake Gen12 hw has a very
    large GAMMA_LUT size of 262145 slots, but also issues with its
    current GAMMA_LUT implementation, as of Linux 5.14.
    
    Therefore we keep GAMMA_LUT off for large lut's. This currently
    excludes Intel Icelake, Tigerlake and later.
    
    This can be overriden via the "UseGammaLUT" boolean xorg.conf option
    to force use of GAMMA_LUT on or off.
    
    See following link for the Tigerlake situation:
    drm/intel#3916 (comment 1085315)
    
    Signed-off-by: Mario Kleiner's avatarMario Kleiner <mario.kleiner.de@gmail.com>
    66e5a5bb
  • Mario Kleiner's avatar
    modesetting: Handle mixed VRR and non-VRR display setups better. · 017ce263
    Mario Kleiner authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
    
    
    In a setup with both VRR capable and non-VRR capable displays,
    it was so far inconsistent if the driver would allow use of
    VRR support or not, as "is_connector_vrr_capable" was set to
    whatever the capabilities of the last added drm output were.
    Iow. the plugging order of monitors determined the outcome.
    
    Fix this: Now if at least one display is VRR capable, the driver
    will treat an X-Screen as capable for VRR, plugging order no
    longer matters.
    
    Tested with a dual-display setup with one VRR monitor and one
    non-VRR monitor. This is also beneficial with the new Option
    "AsyncFlipSecondaries".
    
    When we are at it, also add some so far missing description of
    the "VariableRefresh" driver option, copied from amdgpu-ddx.
    Signed-off-by: Mario Kleiner's avatarMario Kleiner <mario.kleiner.de@gmail.com>
    017ce263
  • Mario Kleiner's avatar
    modesetting: Consider RandR primary output for selectioh of sync crtc. · 4b75e657
    Mario Kleiner authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
    
    
    The "sync crtc" is the crtc used to drive the display timing of a
    drawable under DRI2 and DRI3/Present. If a drawable intersects
    multiple video outputs, then normally the crtc is chosen which has
    the largest intersection area with the drawable.
    
    If multiple outputs / crtc's have exacty the same intersection
    area then the crtc chosen was simply the first one with maximum
    intersection. Iow. the choice was random, depending on plugging
    order of displays.
    
    This adds the ability to choose a preferred output in such a tie
    situation. The RandR output marked as "primary output" is chosen
    on such a tie.
    
    This new behaviour and its implementation is consistent with other
    video ddx drivers. See amdgpu-ddx, ati-ddx and nouveau-ddx for
    reference. This commit is a straightforward port from amdgpu-ddx.
    Signed-off-by: Mario Kleiner's avatarMario Kleiner <mario.kleiner.de@gmail.com>
    4b75e657
  • nerdopolis's avatar
    xf86: Accept devices with the 'simpledrm' driver. · b9218fad
    nerdopolis authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
    SimpleDRM 'devices' are a fallback device, and do not have a busid
    so they are getting skipped. This will allow simpledrm to work
    with the modesetting driver
    b9218fad
  • Alexander Richardson's avatar
    dix/privates.c: Avoid undefined behaviour after realloc() · f9f705bf
    Alexander Richardson authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
    
    
    Adding the offset between the realloc result and the old allocation to
    update pointers into the new allocation is undefined behaviour: the
    old pointers are no longer valid after realloc() according to the C
    standard. While this works on almost all architectures and compilers,
    it causes  problems on architectures that track pointer bounds (e.g.
    CHERI or Arm's Morello): the DevPrivateKey pointers will still have the
    bounds of the previous allocation and therefore any dereference will
    result in a run-time trap.
    
    I found this due to a crash (dereferencing an invalid capability) while
    trying to run `XVnc` on a CHERI-RISC-V system. With this commit I can
    successfully connect to the XVnc instance running inside a QEMU with a
    VNC viewer on my host.
    
    This also changes the check whether the allocation was moved to use
    uintptr_t instead of a pointer since according to the C standard:
    "The value of a pointer becomes indeterminate when the object it
    points to (or just past) reaches the end of its lifetime." Casting to an
    integer type avoids this undefined behaviour.
    Signed-off-by: Alexander Richardson's avatarAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
    f9f705bf
......@@ -155,14 +155,13 @@ dixMovePrivates(PrivatePtr *privates, int new_offset, unsigned bytes)
static Bool
fixupOneScreen(ScreenPtr pScreen, FixupFunc fixup, unsigned bytes)
{
intptr_t dist;
char *old;
uintptr_t old;
char *new;
DevPrivateKey *keyp, key;
DevPrivateType type;
int size;
old = (char *) pScreen->devPrivates;
old = (uintptr_t) pScreen->devPrivates;
size = global_keys[PRIVATE_SCREEN].offset;
if (!fixup (&pScreen->devPrivates, size, bytes))
return FALSE;
......@@ -182,9 +181,7 @@ fixupOneScreen(ScreenPtr pScreen, FixupFunc fixup, unsigned bytes)
if (fixup == dixMovePrivates)
new += bytes;
dist = new - old;
if (dist) {
if ((uintptr_t) new != old) {
for (type = PRIVATE_XSELINUX; type < PRIVATE_LAST; type++)
/* Walk the privates list, being careful as the
......@@ -199,10 +196,11 @@ fixupOneScreen(ScreenPtr pScreen, FixupFunc fixup, unsigned bytes)
* is contained within the allocation. Privates
* stored elsewhere will be left alone
*/
if (old <= (char *) key && (char *) key < old + size)
if (old <= (uintptr_t) key && (uintptr_t) key < old + size)
{
/* Compute new location of key */
key = (DevPrivateKey) ((char *) key + dist);
/* Compute new location of key (deriving from the new
* allocation to avoid UB) */
key = (DevPrivateKey) (new + ((uintptr_t) key - old));
/* Patch the list */
*keyp = key;
......
......@@ -557,8 +557,13 @@ xf86platformProbeDev(DriverPtr drvp)
}
else {
/* for non-seat0 servers assume first device is the master */
if (ServerIsNotSeat0())
if (ServerIsNotSeat0()) {
break;
} else {
/* Accept the device if the driver is simpledrm */
if (strcmp(xf86_platform_devices[j].attribs->driver, "simpledrm") == 0)
break;
}
if (xf86IsPrimaryPlatform(&xf86_platform_devices[j]))
break;
......
......@@ -2404,10 +2404,23 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, MS_LOGLEVEL_DEBUG,
"Allocated crtc nr. %d to this screen.\n", num);
drmmode_crtc->use_gamma_lut =
drmmode_crtc->props[DRMMODE_CRTC_GAMMA_LUT_SIZE].prop_id &&
drmmode_crtc->props[DRMMODE_CRTC_GAMMA_LUT_SIZE].value &&
xf86ReturnOptValBool(drmmode->Options, OPTION_USE_GAMMA_LUT, TRUE);
if (drmmode_crtc->props[DRMMODE_CRTC_GAMMA_LUT_SIZE].prop_id &&
drmmode_crtc->props[DRMMODE_CRTC_GAMMA_LUT_SIZE].value) {
/*
* GAMMA_LUT property supported, and so far tested to be safe to use by
* default for lut sizes up to 4096 slots. Intel Tigerlake+ has some
* issues, and a large GAMMA_LUT with 262145 slots, so keep GAMMA_LUT
* off for large lut sizes by default for now.
*/
drmmode_crtc->use_gamma_lut = drmmode_crtc->props[DRMMODE_CRTC_GAMMA_LUT_SIZE].value <= 4096;
/* Allow config override. */
drmmode_crtc->use_gamma_lut = xf86ReturnOptValBool(drmmode->Options,
OPTION_USE_GAMMA_LUT,
drmmode_crtc->use_gamma_lut);
} else {
drmmode_crtc->use_gamma_lut = FALSE;
}
if (drmmode_crtc->use_gamma_lut &&
drmmode_crtc->props[DRMMODE_CRTC_CTM].prop_id) {
......@@ -3296,7 +3309,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
}
}
ms->is_connector_vrr_capable =
ms->is_connector_vrr_capable |=
drmmode_connector_check_vrr_capable(drmmode->fd,
drmmode_output->output_id);
return 1;
......
......@@ -71,6 +71,13 @@ One of \*qglamor\*q or \*qnone\*q. Default: glamor.
Enable DRI3 page flipping. The default is
.B on.
.TP
.BI "Option \*qVariableRefresh\*q \*q" boolean \*q
Enables support for enabling variable refresh on the Screen's CRTCs
when an suitable application is flipping via the Present extension.
.br
The default is
.B off.
.TP
.BI "Option \*qAsyncFlipSecondaries\*q \*q" boolean \*q
Use async flips for secondary video outputs on multi-display setups. If a screen
has multiple displays attached and DRI3 page flipping is used, then only one of
......@@ -99,8 +106,8 @@ will assign xrandr outputs LVDS and VGA-0 to this instance of the driver.
.BI "Option \*qUseGammaLUT\*q \*q" boolean \*q
Enable or disable use of the GAMMA_LUT property, when available.
When enabled, this option allows the driver to use gamma ramps with more
entries, if supported by the kernel.
Default: on.
entries, if supported by the kernel. By default, GAMMA_LUT will be used for
kms drivers which are known to be safe for use of GAMMA_LUT.
.TP
.SH "SEE ALSO"
@xservername@(@appmansuffix@), @xconfigfile@(@filemansuffix@), Xserver(@appmansuffix@),
......
......@@ -120,7 +120,8 @@ static RRCrtcPtr
rr_crtc_covering_box(ScreenPtr pScreen, BoxPtr box, Bool screen_is_xf86_hint)
{
rrScrPrivPtr pScrPriv;
RRCrtcPtr crtc, best_crtc;
RROutputPtr primary_output;
RRCrtcPtr crtc, best_crtc, primary_crtc;
int coverage, best_coverage;
int c;
BoxRec crtc_box, cover_box;
......@@ -136,6 +137,11 @@ rr_crtc_covering_box(ScreenPtr pScreen, BoxPtr box, Bool screen_is_xf86_hint)
if (!pScrPriv)
return NULL;
primary_crtc = NULL;
primary_output = RRFirstOutput(pScreen);
if (primary_output)
primary_crtc = primary_output->crtc;
for (c = 0; c < pScrPriv->numCrtcs; c++) {
crtc = pScrPriv->crtcs[c];
......@@ -146,7 +152,8 @@ rr_crtc_covering_box(ScreenPtr pScreen, BoxPtr box, Bool screen_is_xf86_hint)
rr_crtc_box(crtc, &crtc_box);
box_intersect(&cover_box, &crtc_box, box);
coverage = box_area(&cover_box);
if (coverage > best_coverage) {
if ((coverage > best_coverage) ||
(coverage == best_coverage && crtc == primary_crtc)) {
best_crtc = crtc;
best_coverage = coverage;
}
......
......@@ -2405,21 +2405,19 @@ _XkbSetMapCheckLength(xkbSetMapReq *req)
keytype = (xkbKeyTypeWireDesc *)(req + 1);
for (i = 0; i < req->nTypes; i++) {
_add_check_len(XkbPaddedSize(sz_xkbKeyTypeWireDesc));
if (req->flags & XkbSetMapResizeTypes) {
_add_check_len(keytype->nMapEntries
* sz_xkbKTSetMapEntryWireDesc);
preserve = keytype->preserve;
map_count = keytype->nMapEntries;
if (preserve) {
_add_check_len(map_count * sz_xkbModsWireDesc);
}
keytype += 1;
keytype = (xkbKeyTypeWireDesc *)
((xkbKTSetMapEntryWireDesc *)keytype + map_count);
if (preserve)
keytype = (xkbKeyTypeWireDesc *)
((xkbModsWireDesc *)keytype + map_count);
_add_check_len(keytype->nMapEntries
* sz_xkbKTSetMapEntryWireDesc);
preserve = keytype->preserve;
map_count = keytype->nMapEntries;
if (preserve) {
_add_check_len(map_count * sz_xkbModsWireDesc);
}
keytype += 1;
keytype = (xkbKeyTypeWireDesc *)
((xkbKTSetMapEntryWireDesc *)keytype + map_count);
if (preserve)
keytype = (xkbKeyTypeWireDesc *)
((xkbModsWireDesc *)keytype + map_count);
}
}
/* syms */
......