linux-stable/include/drm
Linus Torvalds 4188758b53 drm: fix EDID struct for old ARM OABI format
[ Upstream commit 47f15561b6 ]

When building the kernel for arm with the "-mabi=apcs-gnu" option, gcc
will force alignment of all structures and unions to a word boundary
(see also STRUCTURE_SIZE_BOUNDARY and the "-mstructure-size-boundary=XX"
option if you're a gcc person), even when the members of said structures
do not want or need said alignment.

This completely messes up the structure alignment of 'struct edid' on
those targets, because even though all the embedded structures are
marked with "__attribute__((packed))", the unions that contain them are
not.

This was exposed by commit f1e4c916f9 ("drm/edid: add EDID block count
and size helpers"), but the bug is pre-existing.  That commit just made
the structure layout problem cause a build failure due to the addition
of the

        BUILD_BUG_ON(sizeof(*edid) != EDID_LENGTH);

sanity check in drivers/gpu/drm/drm_edid.c:edid_block_data().

This legacy union alignment should probably not be used in the first
place, but we can fix the layout by adding the packed attribute to the
union entries even when each member is already packed and it shouldn't
matter in a sane build environment.

You can see this issue with a trivial test program:

  union {
	struct {
		char c[5];
	};
	struct {
		char d;
		unsigned e;
	} __attribute__((packed));
  } a = { "1234" };

where building this with a normal "gcc -S" will result in the expected
5-byte size of said union:

	.type	a, @object
	.size	a, 5

but with an ARM compiler and the old ABI:

    arm-linux-gnu-gcc -mabi=apcs-gnu -mfloat-abi=soft -S t.c

you get

	.type	a, %object
	.size	a, 8

instead, because even though each member of the union is packed, the
union itself still gets aligned.

This was reported by Sudip for the spear3xx_defconfig target.

Link: https://lore.kernel.org/lkml/YpCUzStDnSgQLNFN@debian/
Reported-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-14 16:52:30 +02:00
..
bridge drm/bridge: analogix_dp: Add analogix_dp_psr_supported 2016-10-04 08:23:16 +02:00
i2c
ttm drm/ttm, drm/vmwgfx: Relax permission checking when opening surfaces 2017-04-12 12:41:10 +02:00
ati_pcigart.h
drmP.h drm: Don't race connector registration 2017-06-17 06:41:53 +02:00
drm_agpsupport.h
drm_atomic.h
drm_atomic_helper.h
drm_auth.h
drm_blend.h drm: Fix plane type uabi breakage 2016-09-22 23:52:12 -07:00
drm_bridge.h
drm_cache.h drm: disable uncached DMA optimization for ARM and arm64 2019-03-13 14:05:01 -07:00
drm_color_mgmt.h drm/doc: Document color space handling 2016-09-22 00:04:03 -07:00
drm_connector.h drm: prevent double-(un)registration for connectors 2017-06-17 06:41:53 +02:00
drm_crtc.h drm/crtc: constify drm_crtc_index parameter 2016-10-10 17:28:58 +02:00
drm_crtc_helper.h drm: Allow determining if current task is output poll worker 2018-03-18 11:18:48 +01:00
drm_displayid.h
drm_dp_dual_mode_helper.h
drm_dp_helper.h drm: Add DP PSR2 sink enable bit 2018-08-03 07:55:26 +02:00
drm_dp_mst_helper.h drm: mst: Fix query_payload ack reply struct 2020-01-04 13:39:00 +01:00
drm_edid.h drm: fix EDID struct for old ARM OABI format 2022-06-14 16:52:30 +02:00
drm_encoder.h
drm_encoder_slave.h
drm_fb_cma_helper.h
drm_fb_helper.h drm/fb-helper: fix sphinx markup for DRM_FB_HELPER_DEFAULT_OPS 2016-10-10 11:19:42 +02:00
drm_fixed.h
drm_flip_work.h
drm_fourcc.h
drm_framebuffer.h
drm_gem.h
drm_gem_cma_helper.h
drm_global.h
drm_hashtab.h
drm_irq.h
drm_legacy.h
drm_mem_util.h
drm_mipi_dsi.h
drm_mm.h
drm_mode_object.h
drm_modes.h
drm_modeset_helper.h
drm_modeset_helper_vtables.h
drm_modeset_lock.h
drm_of.h
drm_os_linux.h
drm_panel.h
drm_pciids.h
drm_plane.h drm: Don't force all planes to be added to the state due to zpos 2016-10-26 18:48:05 +02:00
drm_plane_helper.h
drm_property.h
drm_rect.h
drm_simple_kms_helper.h drm: simple_kms_helper: Add prepare_fb and cleanup_fb hooks 2016-10-05 15:18:02 +02:00
drm_sysfs.h
drm_vma_manager.h drm/i915: Prevent writing into a read-only object via a GGTT mmap 2019-11-12 19:16:16 +01:00
gma_drm.h
i915_component.h
i915_drm.h
i915_pciids.h drm/i915: more .is_mobile cleanups for BDW 2017-04-12 12:41:18 +02:00
intel-gtt.h