Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2162523iof; Tue, 7 Jun 2022 21:50:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ8uVanhMcdZdW88NpJnfpsu8cYBzb7B9GUxviuzKYwYVSO9BU5vXru2ehMPK6ZlO8N3hY X-Received: by 2002:a17:902:e484:b0:164:1c:57a with SMTP id i4-20020a170902e48400b00164001c057amr32189837ple.12.1654663819464; Tue, 07 Jun 2022 21:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654663819; cv=none; d=google.com; s=arc-20160816; b=fHFAW4Ee7gOuA3G9zZqNzMBncPA2eH6uGSr2ZtgUpmK7BY7/re5AjMy4cKQXaIQSR3 poNu5e5XUoBMRcUij2yc0Ps2Imk+/16RwM/DQrXEf2Ed0YPP3Wx8xl62RRtMYioLrtDi yDiUobwOpy9rofaM63bnCv3qpjXUQknJYolMLuanHwKVnGrjeeaneFXuKN0Wsa1sGlcN ljSidqKRQY4VykotRZQPL3tT5lcmd9eaKxhj6Q/UY5kj76w/lJV3JAd69/VwFYz+WRA7 VyhoUVQPyY50omJp/0vhp7sjrecJQG5UccQV34r7VTDP1GTuW/4SGsBxPc1YUlWl2Oik rr7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XE2Wv9EGw7DJq2eq6p9DbmUrWD+tJBtD/RrqNnezQ8I=; b=O0RPYrKaj6c9ynsmBtfqxefSUJk7O1BG4knwyF1xBW4nxiCbseqqy+C6EFHBw1u6fY /2+cvLIt//w22tw78PBmRAtRrDGZznK2mSLSg4hbeIOJ0ReM6D3F9+tHGgBhGyfTgp11 Zq09usRMjs6KiE1DLNRM+Z1SfjEEbdro+DrOkapKcEY8+wjzjkQftjty8MwXXNdXGbxJ G3ZExC07v5iA2wD4OKSNGIPtC5XkDJpA4sIXSezThPA6WtsjSDxQ/2sdIu+1UwvruHqn JYgd6O135bxcLGJXkJylKZYa4I4uDRdKB43dRRiQPXu3iT1bcyFIWqBEVLIAh++qrg4P RXLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OJKPKFRG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id mi4-20020a17090b4b4400b001e881637bd7si10731596pjb.77.2022.06.07.21.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:50:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OJKPKFRG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7321314A913; Tue, 7 Jun 2022 21:20:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349967AbiFGWX3 (ORCPT + 99 others); Tue, 7 Jun 2022 18:23:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380637AbiFGVQz (ORCPT ); Tue, 7 Jun 2022 17:16:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7986F13E17; Tue, 7 Jun 2022 11:57:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3306EB822C0; Tue, 7 Jun 2022 18:57:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C877C385A2; Tue, 7 Jun 2022 18:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628227; bh=MmQJDZApS8UaiRibxxFyjqlEdDr50z7x4JFT5HUt8A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OJKPKFRGh4gKGnLOoSyMrEr9490zAKPxwDx0ddWOXUIMAYX9iuKcbWqF/PG3lt2oZ 2oPVM0+VclbsUWiW+ykgv73AR7AQEdDricyZ8Be+1g9gANZPU9v09Vhcz2nsXydyOS Vsy+F2AZlip1Dc6d4HBepvq+/2z6yh9PIx+a2wTU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sudip Mukherjee , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Linus Torvalds , Sasha Levin Subject: [PATCH 5.18 253/879] drm: fix EDID struct for old ARM OABI format Date: Tue, 7 Jun 2022 18:56:11 +0200 Message-Id: <20220607165010.194133714@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Torvalds [ Upstream commit 47f15561b69e226bfc034e94ff6dbec51a4662af ] 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 f1e4c916f97f ("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 Acked-by: Arnd Bergmann Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- include/drm/drm_edid.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 144c495b99c4..d6b2aeb34211 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -121,7 +121,7 @@ struct detailed_data_monitor_range { u8 supported_scalings; u8 preferred_refresh; } __attribute__((packed)) cvt; - } formula; + } __attribute__((packed)) formula; } __attribute__((packed)); struct detailed_data_wpindex { @@ -154,7 +154,7 @@ struct detailed_non_pixel { struct detailed_data_wpindex color; struct std_timing timings[6]; struct cvt_timing cvt[4]; - } data; + } __attribute__((packed)) data; } __attribute__((packed)); #define EDID_DETAIL_EST_TIMINGS 0xf7 @@ -172,7 +172,7 @@ struct detailed_timing { union { struct detailed_pixel_timing pixel_data; struct detailed_non_pixel other_data; - } data; + } __attribute__((packed)) data; } __attribute__((packed)); #define DRM_EDID_INPUT_SERRATION_VSYNC (1 << 0) -- 2.35.1