Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp583295iog; Mon, 13 Jun 2022 08:34:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tgv3nSljaiqmGBT92dfw7+ktgwVT5euzlQ/6FPABmJFVmpns0NudP+CQZC0gctdDM52XX6 X-Received: by 2002:aa7:c0d1:0:b0:42d:ddda:7470 with SMTP id j17-20020aa7c0d1000000b0042dddda7470mr344120edp.196.1655134472968; Mon, 13 Jun 2022 08:34:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134472; cv=none; d=google.com; s=arc-20160816; b=0M3IbXEALSQUx/s7Ch6mrcoH1p9J/hrq1g+9ooPJzyFnhNf1TTMhhIThkWJNS3Po51 CuLrJy1r9TZusEiwrzPfrsK9YsX4aMVVp+0vZVVG4sULuPuZ7m9KDink8D19spfgNDFl zvx/sO7IhzPYhSwuQpNH1VCwIiyzTtIfkRbNusknWPiTNTsNggd03KuvdlUn0RHcFgYH 02dn85X8Zn6puPN30BlSYFOBKS39ZrficK0Dlj6ZEwjoWhhRSYFcNdzu9IwUq/PsOTYq j2wJJKvYf7sTJPgJ0jdtHKTdZ1Burqp/R5NLXfbw6CMLUCZOWFlSXd3E5Td3Oh/pYur4 HsCw== 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=mOl/tvWsEB4uQVerI3B6hthVCPgE+RqVsW4iIkS2j+I=; b=pidIRWTtuGmPgQw1Ow4r9sqRNXMD0uurvhomJjJDowOOLDxRQxpq5vc0eW9dsIgIZ6 wp4Golj3FvHlOhIhp6PCxOcR6/bg2cVnmwgC3Q/iSA5yiwlPdqMfvz/7hY1lAGYVWJfi bZa+Hb+TlyUyKN71SWaWDEiY+NvrJAfw+AIQEyyrItjcpfoD88oz9xmKIreNyfDLbbVH JW+i/wi/QXMvVZ++53UMPQi4sp6RDifzZKFe4E+FqbEtfwL7m7bE4+ZnvYl8GjhKr1aC mIwIa4IdhjrJSEFTSBhqZzvFQUERjZe4V4NfE8VYLlcvv0/XihwVy3RzwxHZQHDvI9rY u9iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PLRMXhSe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d10-20020a1709063cea00b006fef6d3ee02si6444561ejh.539.2022.06.13.08.34.07; Mon, 13 Jun 2022 08:34:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PLRMXhSe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241910AbiFMKRw (ORCPT + 99 others); Mon, 13 Jun 2022 06:17:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242127AbiFMKR1 (ORCPT ); Mon, 13 Jun 2022 06:17:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50D351FCDA; Mon, 13 Jun 2022 03:15:37 -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 dfw.source.kernel.org (Postfix) with ESMTPS id D6D7C614BA; Mon, 13 Jun 2022 10:15:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC4F8C34114; Mon, 13 Jun 2022 10:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115327; bh=Bf5QOHaJpiVUqhHBRSN35OBw5iZVamMzadF9hlHiv/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLRMXhSe4sYxym5RaDa2E/gMalRhek2hqMHHg++HmmzTv4VIkysjVXt8VPE3gZY1a Jittjj/NkVTftS04WdAfNPV7vyzn0DAhwcWy9b74ENHULCDVOoPsPCQd10Pqj56cxp DOQ2UXgZSUTJS+JlEQriNqacofcz9je6nJ3TnjB0= 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 4.9 036/167] drm: fix EDID struct for old ARM OABI format Date: Mon, 13 Jun 2022 12:08:30 +0200 Message-Id: <20220613094849.337255700@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094840.720778945@linuxfoundation.org> References: <20220613094840.720778945@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=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 c3a7d440bc11..514a02095983 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -114,7 +114,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 { @@ -147,7 +147,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 @@ -165,7 +165,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