Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp197306imm; Thu, 6 Sep 2018 00:34:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbOK5zUppmJBwpqjSBiCeeE+crmGr7VHHiaWYQw/E7dwox/57RfaLd7+GMbaY02QKhDdc6j X-Received: by 2002:a17:902:7145:: with SMTP id u5-v6mr1417183plm.259.1536219250124; Thu, 06 Sep 2018 00:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536219250; cv=none; d=google.com; s=arc-20160816; b=Oc+XbHX+3gjqQTO3qxvzYNd4MmB6aJ1ZQgg8saxHnlA4+68R4t5WRiJAs1cDgm9Njc P+f5u1qxC0CvQk55dOFg4SOdpVzv9YCfdW6e7Yb8/r4+IkGIaUZ+DyUV4afzcTWErBEy 3r9N29Wy2LmFEaMuNN+O3I+65lu+w9OLNUGxX65VLmicWT9Exzw3ngrPJjfcfflxm8Pg Tf8F3T19MeBT/NVdbZvS2jLCv+feoLqWifGe/JWMMrw6JYd0MYltapEK/5RIVBBChZ4l FyiZEC3aUKiKyj8v58bc3cAAr2T+WtRutjEJBqWQjSDBL8QEfjqRq5FhbySQtFIp6FnY j71Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=FNrlx7YGS0abSGmRRPluerfry9KZrzugJ+6tFq8LAcA=; b=DrmYYqfeIm6qaoq83dTdIIndL1+LVzMLK96BdT5eqh/VawDOUMMLNiaUg009W9aQFw PtTqO2sA7X4IICA+OS2E2CEsHF3yYNL/bZENnW35SZ6VrJ4D7SL+RQbIO1EvLW9EEqBB ArwoKEtip2VjoXg8W6iV5LPJkJeEuUbKyALMl8KyNZBY+HPRI/h3RKCFbL65S8t5nxom mEcQhhBPV7A9ISmEYMZcQUvrnqBWWqT+A1gAhqN8ivhVLLpm7zadM9wo6pM7j1peUZZs MNAgvJ1Gjo6/X4z9B03eC4iKN4XZvqyYuh+jG/AEslKXL3rICTm75jFIh3Mkz5OrB/x7 dQLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b="d+C4jD/3"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o21-v6si4397813pgk.337.2018.09.06.00.33.54; Thu, 06 Sep 2018 00:34:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b="d+C4jD/3"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727861AbeIFMGq (ORCPT + 99 others); Thu, 6 Sep 2018 08:06:46 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:37883 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725929AbeIFMGq (ORCPT ); Thu, 6 Sep 2018 08:06:46 -0400 Received: by mail-ed1-f68.google.com with SMTP id a20-v6so8083929edd.4 for ; Thu, 06 Sep 2018 00:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=FNrlx7YGS0abSGmRRPluerfry9KZrzugJ+6tFq8LAcA=; b=d+C4jD/3Op1SU7MKU2wuRkN37Exq31onwyc4w/TDL2dJxcoIr+bRSklDWBuxU2U5Ed gW25dggsTEuXBvasT+NSGs1A8aoZEyp+fC1D7+5y7SLzq7y0VGXWd+M0v0illP+DMA8O GWVOzWWQCbOlPLCsUJZ1HHjtlL0QiqrsnlZFs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=FNrlx7YGS0abSGmRRPluerfry9KZrzugJ+6tFq8LAcA=; b=SlKFjvfTs7MhtZtJpVK245n90GKeiVTwF5M1XQ8vm+nWV5qjdW3i1s8Xucv1fd3b9x NAfGpPPfZV60lmHu9RpMnA/wtx1bW5Zf6XmRVP76+5acjC4kXylIwRFthtwesudVIrai 9ceRqEvbftCx7e2qUsSvp8vJ8cgZgrGlTH49mlb5HdJOgmREoQDVACqMmf9UNeujsaVB lxK5B4APv6fRYur2viVEKKxnfrcgJjyAy/1P+Uvs0c60MzN8OYyPZ/8tRjbZ7f7FhB05 dl7U9aQqYF8RJRDT28vMJJ7VUsQ72uu7ZBk8+0ti/oR+bGbHlW7WuytSJ+lDkmBSEu/2 M4CA== X-Gm-Message-State: APzg51A01/yYv7nukbsPr8TgfMjK9RMgUXP1Qqb/jvQ0yfpcttNR6DBM 3Lt2Ypygh8Fqmecys1SDGIs1Xw== X-Received: by 2002:a50:aa83:: with SMTP id q3-v6mr2167908edc.64.1536219159513; Thu, 06 Sep 2018 00:32:39 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id f6-v6sm2961639ede.75.2018.09.06.00.32.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 00:32:38 -0700 (PDT) Date: Thu, 6 Sep 2018 09:32:36 +0200 From: Daniel Vetter To: Gerd Hoffmann Cc: dri-devel@lists.freedesktop.org, David Airlie , open list , Sean Paul Subject: Re: [PATCH] drm: refuse ADDFB2 ioctl for broken bigendian drivers Message-ID: <20180906073236.GL4929@phenom.ffwll.local> Mail-Followup-To: Gerd Hoffmann , dri-devel@lists.freedesktop.org, David Airlie , open list , Sean Paul References: <20180906072850.11150-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180906072850.11150-1-kraxel@redhat.com> X-Operating-System: Linux phenom 4.17.0-3-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 06, 2018 at 09:28:50AM +0200, Gerd Hoffmann wrote: > Drivers must set the quirk_addfb_prefer_host_byte_order quirk to make > the drm_mode_addfb() compat code work correctly on bigendian machines. > > If they don't they interpret pixel_format values incorrectly for bug > compatibility, which in turn implies the ADDFB2 ioctl does not work > correctly then. So block it to make userspace fallback to ADDFB. > > Signed-off-by: Gerd Hoffmann > --- > drivers/gpu/drm/drm_ioctl.c | 25 ++++++++++++++++++++++++- > 1 file changed, 24 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c > index ea10e9a26a..08e48bda23 100644 > --- a/drivers/gpu/drm/drm_ioctl.c > +++ b/drivers/gpu/drm/drm_ioctl.c > @@ -469,6 +469,29 @@ static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value) > return 0; > } > > +static int drm_mode_addfb2_check(struct drm_device *dev, > + void *data, struct drm_file *file_priv) > +{ > +#ifdef __BIG_ENDIAN > + if (!dev->mode_config.quirk_addfb_prefer_host_byte_order) { > + /* > + * Drivers must set the > + * quirk_addfb_prefer_host_byte_order quirk to make > + * the drm_mode_addfb() compat code work correctly on > + * bigendian machines. > + * > + * If they don't they interpret pixel_format values > + * incorrectly for bug compatibility, which in turn > + * implies the ADDFB2 ioctl does not work correctly > + * then. So block it to make userspace fallback to > + * ADDFB. > + */ DRM_DEBUG_KMS would be good here I think, just to help userspace people figure out why they got an -EINVAL. > + return -EINVAL; > + } > +#endif > + return drm_mode_addfb2(dev, data, file_priv); I think it'd be better if we have all the addfb code in drm_framebuffer.c. So leave the function name, and extract the common code into __drm_mode_addfb2 helper. With these two nits addressed: Reviewed-by: Daniel Vetter > +} > + > /* > * Get version information > * > @@ -645,7 +668,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = { > DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPBLOB, drm_mode_getblob_ioctl, DRM_UNLOCKED), > DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_UNLOCKED), > DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb_ioctl, DRM_UNLOCKED), > - DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB2, drm_mode_addfb2, DRM_UNLOCKED), > + DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB2, drm_mode_addfb2_check, DRM_UNLOCKED), > DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb_ioctl, DRM_UNLOCKED), > DRM_IOCTL_DEF(DRM_IOCTL_MODE_PAGE_FLIP, drm_mode_page_flip_ioctl, DRM_MASTER|DRM_UNLOCKED), > DRM_IOCTL_DEF(DRM_IOCTL_MODE_DIRTYFB, drm_mode_dirtyfb_ioctl, DRM_MASTER|DRM_UNLOCKED), > -- > 2.9.3 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch