linux-stable/include/drm
Linus Torvalds 254a62e9b6 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-09 10:25:35 +02:00
..
bridge
i2c
ttm drm/ttm: Clarify that the TTM_PL_SYSTEM is under TTMs control 2021-12-01 11:58:37 -05:00
amd_asic_type.h
drm_aperture.h
drm_atomic.h
drm_atomic_helper.h
drm_atomic_state_helper.h
drm_atomic_uapi.h
drm_audio_component.h
drm_auth.h
drm_blend.h
drm_bridge.h
drm_bridge_connector.h
drm_cache.h
drm_client.h
drm_color_mgmt.h
drm_connector.h drm/connector: Fix typo in documentation 2022-04-08 13:58:58 +02:00
drm_crtc.h
drm_crtc_helper.h
drm_damage_helper.h
drm_debugfs.h
drm_debugfs_crc.h
drm_device.h drm: Declare hashtable as legacy 2021-11-30 09:41:28 +01:00
drm_displayid.h
drm_dp_aux_bus.h
drm_dp_dual_mode_helper.h
drm_dp_helper.h drm/dp: Fix off-by-one in register cache size 2022-04-08 13:58:48 +02:00
drm_dp_mst_helper.h
drm_drv.h drm: Return error codes from struct drm_driver.gem_create_object 2021-12-02 11:12:39 +01:00
drm_dsc.h
drm_edid.h drm: fix EDID struct for old ARM OABI format 2022-06-09 10:25:35 +02:00
drm_encoder.h
drm_encoder_slave.h
drm_fb_cma_helper.h
drm_fb_helper.h
drm_file.h
drm_fixed.h
drm_flip_work.h
drm_format_helper.h drm/format-helper: Add drm_fb_xrgb8888_to_xrgb2101010_toio() 2021-12-16 11:06:30 +01:00
drm_fourcc.h
drm_framebuffer.h
drm_gem.h
drm_gem_atomic_helper.h drm/simpledrm: Support virtual screen sizes 2021-11-11 12:06:58 +01:00
drm_gem_cma_helper.h drm/cma-helper: Pass GEM CMA object in public interfaces 2021-11-30 09:49:58 +01:00
drm_gem_framebuffer_helper.h
drm_gem_shmem_helper.h drm/shmem-helper: Pass GEM shmem object in public interfaces 2021-11-15 11:46:13 +01:00
drm_gem_ttm_helper.h drm: Replace kernel.h with the necessary inclusions 2021-12-09 13:46:13 +01:00
drm_gem_vram_helper.h drm: Replace kernel.h with the necessary inclusions 2021-12-09 13:46:13 +01:00
drm_hdcp.h
drm_ioctl.h
drm_lease.h
drm_legacy.h drm: Declare hashtable as legacy 2021-11-30 09:41:28 +01:00
drm_managed.h
drm_mipi_dbi.h
drm_mipi_dsi.h
drm_mm.h drm: Replace kernel.h with the necessary inclusions 2021-12-09 13:46:13 +01:00
drm_mode_config.h drm: Clarify semantics of struct drm_mode_config.{min, max}_{width, height} 2021-11-11 12:06:58 +01:00
drm_mode_object.h
drm_modes.h
drm_modeset_helper.h
drm_modeset_helper_vtables.h
drm_modeset_lock.h drm/locking: fix drm_modeset_acquire_ctx kernel-doc 2022-04-08 13:57:56 +02:00
drm_of.h
drm_panel.h
drm_pciids.h
drm_plane.h
drm_plane_helper.h
drm_prime.h
drm_print.h
drm_privacy_screen_consumer.h
drm_privacy_screen_driver.h
drm_privacy_screen_machine.h
drm_probe_helper.h drm/probe-helper: add drm_kms_helper_connector_hotplug_event 2021-11-02 14:27:10 +01:00
drm_property.h
drm_rect.h
drm_scdc_helper.h
drm_self_refresh_helper.h
drm_simple_kms_helper.h
drm_syncobj.h
drm_sysfs.h drm/sysfs: introduce drm_sysfs_connector_hotplug_event 2021-11-02 14:27:06 +01:00
drm_util.h
drm_utils.h
drm_vblank.h
drm_vblank_work.h
drm_vma_manager.h
drm_writeback.h
gma_drm.h
gpu_scheduler.h drm/sched: Avoid lockdep spalt on killing a processes 2021-11-01 11:08:21 -04:00
gud.h
i915_component.h
i915_drm.h
i915_mei_hdcp_interface.h
i915_pciids.h drm/i915/rpl-s: Add PCI IDS for Raptor Lake S 2021-12-08 13:02:54 -08:00
i915_pxp_tee_interface.h
intel-gtt.h agp/intel-gtt: reduce intel-gtt dependencies more 2021-11-15 19:20:14 +02:00
intel_lpe_audio.h
spsc_queue.h
task_barrier.h