mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	drm: refuse ADDFB2 ioctl for broken bigendian drivers
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 <kraxel@redhat.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20180907073213.20410-1-kraxel@redhat.com
This commit is contained in:
		
							parent
							
								
									ea4584c2f2
								
							
						
					
					
						commit
						eae06120f1
					
				
					 3 changed files with 29 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -182,6 +182,8 @@ void drm_fb_release(struct drm_file *file_priv);
 | 
			
		|||
 | 
			
		||||
int drm_mode_addfb(struct drm_device *dev, struct drm_mode_fb_cmd *or,
 | 
			
		||||
		   struct drm_file *file_priv);
 | 
			
		||||
int drm_mode_addfb2(struct drm_device *dev,
 | 
			
		||||
		    void *data, struct drm_file *file_priv);
 | 
			
		||||
int drm_mode_rmfb(struct drm_device *dev, u32 fb_id,
 | 
			
		||||
		  struct drm_file *file_priv);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -189,7 +191,7 @@ int drm_mode_rmfb(struct drm_device *dev, u32 fb_id,
 | 
			
		|||
/* IOCTL */
 | 
			
		||||
int drm_mode_addfb_ioctl(struct drm_device *dev,
 | 
			
		||||
			 void *data, struct drm_file *file_priv);
 | 
			
		||||
int drm_mode_addfb2(struct drm_device *dev,
 | 
			
		||||
int drm_mode_addfb2_ioctl(struct drm_device *dev,
 | 
			
		||||
			  void *data, struct drm_file *file_priv);
 | 
			
		||||
int drm_mode_rmfb_ioctl(struct drm_device *dev,
 | 
			
		||||
			void *data, struct drm_file *file_priv);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -369,6 +369,30 @@ int drm_mode_addfb2(struct drm_device *dev,
 | 
			
		|||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int drm_mode_addfb2_ioctl(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("addfb2 broken on bigendian");
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
	return drm_mode_addfb2(dev, data, file_priv);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct drm_mode_rmfb_work {
 | 
			
		||||
	struct work_struct work;
 | 
			
		||||
	struct list_head fbs;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -645,7 +645,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_ioctl, 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),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue