From patchwork Wed Oct 16 23:02:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 176537 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp102531ill; Wed, 16 Oct 2019 16:02:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqx52I0u5QXiEvDVKoYNzTsBvsD7SHz5bcSDLCz9uAXCoTA6E8hiV+Y2HlYPB1TGLuFiHNI9 X-Received: by 2002:a17:906:35cb:: with SMTP id p11mr767403ejb.128.1571266960559; Wed, 16 Oct 2019 16:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571266960; cv=none; d=google.com; s=arc-20160816; b=Z0SbFaZZY7Ug63eQBrn9HI5oojxvB/5AVqp2S56fKYodZYNfboBYCAJB0y2wryriVA b7QzqdK9OJk3O+euy3O2j6TRW6ISpCsVnIG7w2skqNfrCUqXHDAQ3ZJXaxRa0+2HMkTp 2LvQv00sCAUBcXViDzNLCegzCJOy0RbqURsuZ2L119qx0Srw9GOLWIn7CKfWwewa3/5C 6czxCidkx9hPsOuHaBnQAkV3b2kCNhFz+vkIeR9HFGmtmu+JFJYVckqxW+VUFahCzdyl sL7rI6zpLJ+RWJ4JpB1GOYfRTblhWrFEMtAdchusfUr820pp5Wh/2cPSJHcmQwCG/vrj hbTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=+9wE/YnttgoSYQLeI+fM6xNhxWRLjwkrvMn1N+1ady8=; b=BXQbW+WDnwQYpYeakzvy8z9S1YVjD13lpl4U/8d9W7G09upMiII8Oy+byq65rsFUaL I7oN1dDQC/4hZ3CN4sao04uPVVV5Dgr+kNfUG4p9kbAh39wyolmGzoyZ6KsBOsIulb3n WGJE+RFylOW9oZ582th7tIs4Nlc9z48ldFevWl36Lvm6nRyFhq7e/T3xY3jRe42nEueC tfKDBtSoRU7pcfX7KOk7u/z1RJTU+S3SjTfBb3djqAP83BLKcGjipKekgL+8TGiUaFvr t9vSy14CVub+Eqxil1m4DoXeiU7JQc65epdjyColBZI+rGW9b1KOV2UCpOMufM4wtzzk uEFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="KWxGWHf/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g17si297346ejd.123.2019.10.16.16.02.40; Wed, 16 Oct 2019 16:02:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="KWxGWHf/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395085AbfJPXCj (ORCPT + 26 others); Wed, 16 Oct 2019 19:02:39 -0400 Received: from mail-pl1-f201.google.com ([209.85.214.201]:45295 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391366AbfJPXCh (ORCPT ); Wed, 16 Oct 2019 19:02:37 -0400 Received: by mail-pl1-f201.google.com with SMTP id t12so151622plo.12 for ; Wed, 16 Oct 2019 16:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=+9wE/YnttgoSYQLeI+fM6xNhxWRLjwkrvMn1N+1ady8=; b=KWxGWHf/P+f67fdjVt7CHFaUPxIFnuczkzjPcZZra9YWURUHteNwdscbJ2znQA8eDV goEv3nDRQ4QVE54XSj97jGZSKnPPJYm/Ov6TLOC4DeDckmJ9hHj8QLEgDKRumt4d1Wnb 2fHWw5wBhp4xYmQWaql25ZVWU2ghWSggTBnMoDugXAH+1CekRsI4PmfIgmjNGx+fQQKi gO+rfcHvncvjMPD1muXY+aVIPjcsFjSyHleTPM06S5sISHbiSqlBsdVMUZE2yXEoXMpv Bz7Apmfek4PX7D1+ys3wMXOK7h2IXkN+PV4JxSSfBH/QpzCu4c/AagQYlV5ooJOlylQn wLuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+9wE/YnttgoSYQLeI+fM6xNhxWRLjwkrvMn1N+1ady8=; b=SIJXMHkDHFXDCky4zS4cnz0JUPSChGqwht7LgFnqLJZ4XYowEFY16tRqd18MXNCXuY DTUzO3k1J+oI6L9xRLwW8DkObQXYKnJHzOCdr24r8DHyf8M3Tv3fbdjiiHa88V/XCwr9 JJX+dleHrF3lhgQ8zAKi7ZqTtfwpIN92mQarXA6jF75Y4bVOtDbhgu3NG8iGhUjHt592 FjB11S+cGZO/VdVKxUyAR4V10FNlUNgXkygRYNOtYvRMdwy5XAbJr/SmsXMAwEIgyAz8 Mf2wMH+/+zojUstf6QLsunAYez6gYtRhLOSwWFEt1Lpjb9qBeM6sOQ1CfZE8Smbq3DI3 +YOQ== X-Gm-Message-State: APjAAAUoMmNziWfUpu6zoaYBD+SFWUkkz/I/fRPUd1b+gkni5wLHyQOR tQMeM0h0TkLcMwxPIMGHhIg0NZ/dhJd4BEi3eZY= X-Received: by 2002:a63:e057:: with SMTP id n23mr640963pgj.94.1571266956495; Wed, 16 Oct 2019 16:02:36 -0700 (PDT) Date: Wed, 16 Oct 2019 16:02:07 -0700 In-Reply-To: <20191016230209.39663-1-ndesaulniers@google.com> Message-Id: <20191016230209.39663-2-ndesaulniers@google.com> Mime-Version: 1.0 References: <20191016230209.39663-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog Subject: [PATCH 1/3] drm/amdgpu: fix stack alignment ABI mismatch for Clang From: Nick Desaulniers To: harry.wentland@amd.com, alexander.deucher@amd.com Cc: yshuiv7@gmail.com, andrew.cooper3@citrix.com, arnd@arndb.de, clang-built-linux@googlegroups.com, mka@google.com, shirish.s@amd.com, David1.Zhou@amd.com, christian.koenig@amd.com, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Nick Desaulniers Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The x86 kernel is compiled with an 8B stack alignment via `-mpreferred-stack-boundary=3` for GCC since 3.6-rc1 via commit d9b0cde91c60 ("x86-64, gcc: Use -mpreferred-stack-boundary=3 if supported") or `-mstack-alignment=8` for Clang. Parts of the AMDGPU driver are compiled with 16B stack alignment. Generally, the stack alignment is part of the ABI. Linking together two different translation units with differing stack alignment is dangerous, particularly when the translation unit with the smaller stack alignment makes calls into the translation unit with the larger stack alignment. While 8B aligned stacks are sometimes also 16B aligned, they are not always. Multiple users have reported General Protection Faults (GPF) when using the AMDGPU driver compiled with Clang. Clang is placing objects in stack slots assuming the stack is 16B aligned, and selecting instructions that require 16B aligned memory operands. At runtime, syscall handlers with 8B aligned stack call into code that assumes 16B stack alignment. When the stack is a multiple of 8B but not 16B, these instructions result in a GPF. Remove the code that added compatibility between the differing compiler flags, as it will result in runtime GPFs when built with Clang. Cleanups for GCC will be sent in later patches in the series. Link: https://github.com/ClangBuiltLinux/linux/issues/735 Debugged-by: Yuxuan Shui Reported-by: Shirish S Reported-by: Yuxuan Shui Suggested-by: Andrew Cooper Signed-off-by: Nick Desaulniers --- drivers/gpu/drm/amd/display/dc/calcs/Makefile | 10 ++++------ drivers/gpu/drm/amd/display/dc/dcn20/Makefile | 10 ++++------ drivers/gpu/drm/amd/display/dc/dcn21/Makefile | 10 ++++------ drivers/gpu/drm/amd/display/dc/dml/Makefile | 10 ++++------ drivers/gpu/drm/amd/display/dc/dsc/Makefile | 10 ++++------ 5 files changed, 20 insertions(+), 30 deletions(-) -- 2.23.0.700.g56cf767bdb-goog Tested-by: Shirish S Reported-by: Shirish S Reported-by: Yuxuan Shui Signed-off-by: Nick Desaulniers diff --git a/drivers/gpu/drm/amd/display/dc/calcs/Makefile b/drivers/gpu/drm/amd/display/dc/calcs/Makefile index 985633c08a26..4b1a8a08a5de 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/Makefile +++ b/drivers/gpu/drm/amd/display/dc/calcs/Makefile @@ -24,13 +24,11 @@ # It calculates Bandwidth and Watermarks values for HW programming # -ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) - cc_stack_align := -mpreferred-stack-boundary=4 -else ifneq ($(call cc-option, -mstack-alignment=16),) - cc_stack_align := -mstack-alignment=16 -endif +calcs_ccflags := -mhard-float -msse -calcs_ccflags := -mhard-float -msse $(cc_stack_align) +ifdef CONFIG_CC_IS_GCC +calcs_ccflags += -mpreferred-stack-boundary=4 +endif ifdef CONFIG_CC_IS_CLANG calcs_ccflags += -msse2 diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/Makefile b/drivers/gpu/drm/amd/display/dc/dcn20/Makefile index ddb8d5649e79..5fe3eb80075d 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn20/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dcn20/Makefile @@ -10,13 +10,11 @@ ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT DCN20 += dcn20_dsc.o endif -ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) - cc_stack_align := -mpreferred-stack-boundary=4 -else ifneq ($(call cc-option, -mstack-alignment=16),) - cc_stack_align := -mstack-alignment=16 -endif +CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := -mhard-float -msse -CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := -mhard-float -msse $(cc_stack_align) +ifdef CONFIG_CC_IS_GCC +CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o += -mpreferred-stack-boundary=4 +endif ifdef CONFIG_CC_IS_CLANG CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o += -msse2 diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile index ef673bffc241..7057e20748b9 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile @@ -3,13 +3,11 @@ DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o -ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) - cc_stack_align := -mpreferred-stack-boundary=4 -else ifneq ($(call cc-option, -mstack-alignment=16),) - cc_stack_align := -mstack-alignment=16 -endif +CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o := -mhard-float -msse -CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o := -mhard-float -msse $(cc_stack_align) +ifdef CONFIG_CC_IS_GCC +CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o += -mpreferred-stack-boundary=4 +endif ifdef CONFIG_CC_IS_CLANG CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o += -msse2 diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile index 5b2a65b42403..1bd6e307b7f8 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -24,13 +24,11 @@ # It provides the general basic services required by other DAL # subcomponents. -ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) - cc_stack_align := -mpreferred-stack-boundary=4 -else ifneq ($(call cc-option, -mstack-alignment=16),) - cc_stack_align := -mstack-alignment=16 -endif +dml_ccflags := -mhard-float -msse -dml_ccflags := -mhard-float -msse $(cc_stack_align) +ifdef CONFIG_CC_IS_GCC +dml_ccflags += -mpreferred-stack-boundary=4 +endif ifdef CONFIG_CC_IS_CLANG dml_ccflags += -msse2 diff --git a/drivers/gpu/drm/amd/display/dc/dsc/Makefile b/drivers/gpu/drm/amd/display/dc/dsc/Makefile index b456cd23c6fa..932c3055230e 100644 --- a/drivers/gpu/drm/amd/display/dc/dsc/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dsc/Makefile @@ -1,13 +1,11 @@ # # Makefile for the 'dsc' sub-component of DAL. -ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) - cc_stack_align := -mpreferred-stack-boundary=4 -else ifneq ($(call cc-option, -mstack-alignment=16),) - cc_stack_align := -mstack-alignment=16 -endif +dsc_ccflags := -mhard-float -msse -dsc_ccflags := -mhard-float -msse $(cc_stack_align) +ifdef CONFIG_CC_IS_GCC +dsc_ccflags += -mpreferred-stack-boundary=4 +endif ifdef CONFIG_CC_IS_CLANG dsc_ccflags += -msse2 From patchwork Wed Oct 16 23:02:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 176538 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp102692ill; Wed, 16 Oct 2019 16:02:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgfBW5/omQt4gVkhCbRF/4aboOmDzLLo0xpA2xXIGwQ+wHs9bNRdYK0BW6cDIgFFRb82D0 X-Received: by 2002:aa7:c890:: with SMTP id p16mr677525eds.296.1571266968574; Wed, 16 Oct 2019 16:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571266968; cv=none; d=google.com; s=arc-20160816; b=k2MHhh/bPy8AlVkN9AxAw06edVNNzYtKFjnfwEdtnSNUFfj9NVJlXgysyLqD27Si/v TGMqS3VDzrcOOPepM6A/q5dvu9vRZeaukflWZ7A+/6bZkiB+lDfRPgR13Pzsl1B4Knx2 meN6n1E5i3teng3QFblUw/Jtp1s8UrbqueaWN8lV4Z0arRpdAUyjuCftEOFnr8Tl8BhQ g8VUbAZ8zCeH8e/GMw7zBwfj3HuFq/oOt1zljmhGCfDF6P9OnuYMMAZikc/chIhPkq+7 nejhPW92zY6uaB68IuqimCDJ0l0PQd/gScEDAvI8fjLP+PhV7GP+pCcRlIF9hyhkPMRH bw9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=+HTLwtBsb8GklYcE8zHDNoq/yMsTyW1DbJyJzcZRL08=; b=mnfqiE1KExgth3bZnHndbtN3+sDSm5/zXocBEg5PR1rSyBlhN8JgS+7K8iNgDYHxPo oMFjukgcK0qS/EedCYmJOTvU4x4dvctSRy3QgGMZH9iWCo7NxZmP1TvVBLlImSOy1WwG ZPE1QcifmwwTWJzzHvn/QGM1RHfrfLRtXVah5EvUGDoTgFrYwQRpT16TRWXpqbxzWJ9O se32uSqBZlgmXe4J0oWFjVUpJmkazbAvkj7TJFuB4X+ujmrgdqQfkeoPoa7JKEfCmaSR WLa+SI25fVnmdETP7iLPcqNFvRicH0TUz/I8hEB5Dh3eilPzw/u7dWnGqoY3BhH5g2dv DfXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RLuFVPUM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t49si330865edd.198.2019.10.16.16.02.48; Wed, 16 Oct 2019 16:02:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RLuFVPUM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395451AbfJPXCn (ORCPT + 26 others); Wed, 16 Oct 2019 19:02:43 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:44912 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391366AbfJPXCl (ORCPT ); Wed, 16 Oct 2019 19:02:41 -0400 Received: by mail-pg1-f202.google.com with SMTP id z7so318991pgk.11 for ; Wed, 16 Oct 2019 16:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=+HTLwtBsb8GklYcE8zHDNoq/yMsTyW1DbJyJzcZRL08=; b=RLuFVPUMzPc1pMJytJNDhf0T00cd/XENdfqEGL/9yFMKxi0/KOv6x9ACs/02+0mo3S g8OZsQ2AJe6jSNHPgY1WFxvceih3ZJQeEaj7QPMFLGYUgax0sT32Ho1CTb1RSPrx2Oet PBov+kC+ZibuaEdC7BHcJxEVhMwsS14atR2hYzeLnSaUyFEqPY5lk+gZ1Tq9aab/mGg7 BWEk6HcAV5pR5WtFEO/WSEf+MgOI6ijaDroFmLWaJJxhU6Mud7WD89CMEQgFfkxNjq7E eTNFbIVEB1LzdbvAU+lSrksBuetCyMi4xo63aE0SlWnN4pFJkt5zTje5fLmOfyvJQv9E PeWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+HTLwtBsb8GklYcE8zHDNoq/yMsTyW1DbJyJzcZRL08=; b=L75bt2zFc70W0vyWvhPSDw0JkaIEDVmOVyoxWECNH0aJ7nzywolqSeCRYqBXfQanFg FKEHvK0eNZe9c1/9SMw8hp8lh5p9E8xgG5hfewVMY/IbpmvZy20cbbZuE+eQuqc5DGRc 89/QL41Sfh5rYxCXRgtwzT4V3j3nkOv3l4k6bYWBfY9B3Z0e0YuHvpr2rqnLsg0eo0AA r1AaExpnr3XkgRKlXIhrnT7T9RlOPHBpD1wPo9AJmKJSA7Lv8ElFUBwbHhS13Wnvkejk WzFni9eaSK9s/IVJJLBA73TSr48LezPMqcf0vTsXNW4RCXUbf/GghAW8c9FyKv1/K5OZ g8ug== X-Gm-Message-State: APjAAAUS9TnnAcqLD5m+xHm02N8+6Squ4ZHAdLWduyTHHFpU5T/XgY/a nQ8ySZNGtaCWQMHgycxH68AY0QKyUWJ6x4rdLIE= X-Received: by 2002:a63:c446:: with SMTP id m6mr648240pgg.136.1571266960259; Wed, 16 Oct 2019 16:02:40 -0700 (PDT) Date: Wed, 16 Oct 2019 16:02:08 -0700 In-Reply-To: <20191016230209.39663-1-ndesaulniers@google.com> Message-Id: <20191016230209.39663-3-ndesaulniers@google.com> Mime-Version: 1.0 References: <20191016230209.39663-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog Subject: [PATCH 2/3] drm/amdgpu: fix stack alignment ABI mismatch for GCC 7.1+ From: Nick Desaulniers To: harry.wentland@amd.com, alexander.deucher@amd.com Cc: yshuiv7@gmail.com, andrew.cooper3@citrix.com, arnd@arndb.de, clang-built-linux@googlegroups.com, mka@google.com, shirish.s@amd.com, David1.Zhou@amd.com, christian.koenig@amd.com, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Nick Desaulniers Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GCC earlier than 7.1 errors when compiling code that makes use of `double`s and sets a stack alignment outside of the range of [2^4-2^12]: $ cat foo.c double foo(double x, double y) { return x + y; } $ gcc-4.9 -mpreferred-stack-boundary=3 foo.c error: -mpreferred-stack-boundary=3 is not between 4 and 12 This is likely why the AMDGPU driver was ever compiled with a different stack alignment (and thus different ABI) than the rest of the x86 kernel. The kernel uses 8B stack alignment, while the driver was using 16B stack alignment in a few places. Since GCC 7.1+ doesn't error, fix the ABI mismatch for users of newer versions of GCC. There was discussion about whether to mark the driver broken or not for users of GCC earlier than 7.1, but since the driver currently is working, don't explicitly break the driver for them here. Relying on differing stack alignment is unspecified behavior, and brittle, and may break in the future. This patch is no functional change for GCC users earlier than 7.1. It's been compile tested on GCC 4.9 and 8.3 to check the correct flags. It should be boot tested when built with GCC 7.1+. -mincoming-stack-boundary= or -mstackrealign may help keep this code building for pre-GCC 7.1 users. The version check for GCC is broken into two conditionals, both because cc-ifversion is currently GCC specific, and it simplifies a subsequent patch. Signed-off-by: Nick Desaulniers --- drivers/gpu/drm/amd/display/dc/calcs/Makefile | 9 +++++++++ drivers/gpu/drm/amd/display/dc/dcn20/Makefile | 9 +++++++++ drivers/gpu/drm/amd/display/dc/dcn21/Makefile | 9 +++++++++ drivers/gpu/drm/amd/display/dc/dml/Makefile | 9 +++++++++ drivers/gpu/drm/amd/display/dc/dsc/Makefile | 9 +++++++++ 5 files changed, 45 insertions(+) -- 2.23.0.700.g56cf767bdb-goog diff --git a/drivers/gpu/drm/amd/display/dc/calcs/Makefile b/drivers/gpu/drm/amd/display/dc/calcs/Makefile index 4b1a8a08a5de..a1af55a86508 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/Makefile +++ b/drivers/gpu/drm/amd/display/dc/calcs/Makefile @@ -27,6 +27,15 @@ calcs_ccflags := -mhard-float -msse ifdef CONFIG_CC_IS_GCC +ifeq ($(call cc-ifversion, -lt, 0701, y), y) +IS_OLD_GCC = 1 +endif +endif + +ifdef IS_OLD_GCC +# Stack alignment mismatch, proceed with caution. +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 +# (8B stack alignment). calcs_ccflags += -mpreferred-stack-boundary=4 endif diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/Makefile b/drivers/gpu/drm/amd/display/dc/dcn20/Makefile index 5fe3eb80075d..cb0ac131f74a 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn20/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dcn20/Makefile @@ -13,6 +13,15 @@ endif CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := -mhard-float -msse ifdef CONFIG_CC_IS_GCC +ifeq ($(call cc-ifversion, -lt, 0701, y), y) +IS_OLD_GCC = 1 +endif +endif + +ifdef IS_OLD_GCC +# Stack alignment mismatch, proceed with caution. +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 +# (8B stack alignment). CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o += -mpreferred-stack-boundary=4 endif diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile index 7057e20748b9..f92320ddd27f 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile @@ -6,6 +6,15 @@ DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o := -mhard-float -msse ifdef CONFIG_CC_IS_GCC +ifeq ($(call cc-ifversion, -lt, 0701, y), y) +IS_OLD_GCC = 1 +endif +endif + +ifdef IS_OLD_GCC +# Stack alignment mismatch, proceed with caution. +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 +# (8B stack alignment). CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o += -mpreferred-stack-boundary=4 endif diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile index 1bd6e307b7f8..ef1bdd20b425 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -27,6 +27,15 @@ dml_ccflags := -mhard-float -msse ifdef CONFIG_CC_IS_GCC +ifeq ($(call cc-ifversion, -lt, 0701, y), y) +IS_OLD_GCC = 1 +endif +endif + +ifdef IS_OLD_GCC +# Stack alignment mismatch, proceed with caution. +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 +# (8B stack alignment). dml_ccflags += -mpreferred-stack-boundary=4 endif diff --git a/drivers/gpu/drm/amd/display/dc/dsc/Makefile b/drivers/gpu/drm/amd/display/dc/dsc/Makefile index 932c3055230e..3f7840828a9f 100644 --- a/drivers/gpu/drm/amd/display/dc/dsc/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dsc/Makefile @@ -4,6 +4,15 @@ dsc_ccflags := -mhard-float -msse ifdef CONFIG_CC_IS_GCC +ifeq ($(call cc-ifversion, -lt, 0701, y), y) +IS_OLD_GCC = 1 +endif +endif + +ifdef IS_OLD_GCC +# Stack alignment mismatch, proceed with caution. +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 +# (8B stack alignment). dsc_ccflags += -mpreferred-stack-boundary=4 endif From patchwork Wed Oct 16 23:02:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 176539 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp102722ill; Wed, 16 Oct 2019 16:02:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpOd19vcLlKWsvClbxh+tEtCp/KhtS/df47YI9nXFOLXKPoLY8rf+YB47EUc3j8K9Ib04K X-Received: by 2002:a17:906:250d:: with SMTP id i13mr720917ejb.275.1571266970196; Wed, 16 Oct 2019 16:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571266970; cv=none; d=google.com; s=arc-20160816; b=brESPFnPtXBqtzvhrvuBC7ZMsrOGEs1IXScVhnXaJ0OOLwPu/BD45qUsjWsMrbDMA6 P1FelzwiS4IRI/Xx9tV7wLzHOHQIGVU9xgm94fT7ZxM7jdJ6D63yqKegq3QwIjsy8NzW iGVhkwCQ6DbKw/dHJLzecBgVxuF7US6yVNk5FxV56rCZ4P1elu+DQpj0SEH2tZcQzcPn P6eyPDT0Y+cE4d5HsBOdMhTCaSOyY4sx0eX8/BuQCokVDJEIiDEc22Oy7PJXJj+7pJZR GwVw1P2+AdX+9b1AW0g9NhuqV7Oa14jIM38U0JRIsbg0sxKEgndDzY1GkE0Yq2N1diPw B6AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=5VeOMLWwE6g0WvRsIC8itj+v+Y0yf4dhqyzJ89LKDQw=; b=PdV8p+1SGpo/Mf3T7EDkkcW9o2va34xIy6l90Ss4NJLuFecxPwK0jekkkLzyQeJobE 4VoNkb7fWPhuGxcSBd9jJAtasb/WqYeogoWxjiSugaxKD5fGZDOb8UfW5Ng+fTUXBHvt xX1jAKRKZ8CsHnM7nLrGMK4byYb6lOwJSCEGUfVYl7WdwGI8W4yF3+vowE1PQJOleFm9 z8c/WpPTokazQh8D3HGSE6MkIMpSAzjGjvtRz6UGTXBhC2ouqnUK4RGrOtOnimg/ZZHo WxL4ONPw7+ZbdJAS5J3a/vvLG7PTLDQFeEqfpFHKpgsPKhDirRHg4L+5SaxTIChCDhRo PPUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=A40bHLsh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t49si330865edd.198.2019.10.16.16.02.49; Wed, 16 Oct 2019 16:02:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=A40bHLsh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405446AbfJPXCs (ORCPT + 26 others); Wed, 16 Oct 2019 19:02:48 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:46106 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391366AbfJPXCo (ORCPT ); Wed, 16 Oct 2019 19:02:44 -0400 Received: by mail-pg1-f202.google.com with SMTP id 195so314878pgc.13 for ; Wed, 16 Oct 2019 16:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=5VeOMLWwE6g0WvRsIC8itj+v+Y0yf4dhqyzJ89LKDQw=; b=A40bHLshrNkP45PQDK5L664W/1W68XMbbph48wGTPjAkUy/eye889BQYxk9m7kUSjt 9qxA81XbIZzgEbVf4Vlegiae0E/Jkr6VEEjwyY6Y9GnlGhFWgL6x3LgNodzcKaEaKeWT tiK2M0C6MBwGIlzb6c1NgMs6R5DPf4LEBCpBsk1MjimcIKe6nswxwOmjCx9qOmnEb0V9 NfVbsyRoCAFtoh6OyDGgEdV0KMiuUHV3INyF8rSa1O2nflcSyqLe1DrCZVUl3yNQTraB PQfvRpttT6HAVG1XvjGIuIWQQg/CmAup10Xuo4wruCy6VYcKNQv9DKOl3E0XxuY2mgGN N2WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=5VeOMLWwE6g0WvRsIC8itj+v+Y0yf4dhqyzJ89LKDQw=; b=uToqdhenDivi0UlogiAHFTYOBTp1g2UitXoSZSS+wTT2vL0VKWt22lLUZNevIqhzIt LAZFRRbTrWR7V8bbYXzoTZXLt6I91rWTTdekCw9JIRN6Dx0d1XIYhHlIktE8mLHfRoWB lPWUUfW8fB4UkxvmO6V/F8Y9vVEPm8ssp7qpDTvVKbwqFaTTT3d1w10uDMYbKqVsuo6/ M8mKf9/WX8u9XSDrh9Z2LkZ/YskbE6Fvdlhvnzy40JBx02z0gk6QptMhnYAl+ohxTLhL ckhkHIoXGQHYrasPk6tcGojkumn/m6a4V+16Vm+iJv7iqSJ1i3DB/awnuL8E2dnMONSC re9g== X-Gm-Message-State: APjAAAXYiEeP4NHnaQSUxuTsvnhASZpuSWj6MX9EfzFivCtfLnbvO68n MN+HipXwU0fuwrUCmxcc6VBuoAJ29U3l8/BTaME= X-Received: by 2002:a65:5cc8:: with SMTP id b8mr652311pgt.38.1571266963884; Wed, 16 Oct 2019 16:02:43 -0700 (PDT) Date: Wed, 16 Oct 2019 16:02:09 -0700 In-Reply-To: <20191016230209.39663-1-ndesaulniers@google.com> Message-Id: <20191016230209.39663-4-ndesaulniers@google.com> Mime-Version: 1.0 References: <20191016230209.39663-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog Subject: [PATCH 3/3] drm/amdgpu: enable -msse2 for GCC 7.1+ users From: Nick Desaulniers To: harry.wentland@amd.com, alexander.deucher@amd.com Cc: yshuiv7@gmail.com, andrew.cooper3@citrix.com, arnd@arndb.de, clang-built-linux@googlegroups.com, mka@google.com, shirish.s@amd.com, David1.Zhou@amd.com, christian.koenig@amd.com, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Nick Desaulniers Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A final attempt at enabling sse2 for GCC users. Orininally attempted in: commit 10117450735c ("drm/amd/display: add -msse2 to prevent Clang from emitting libcalls to undefined SW FP routines") Reverted due to "reported instability" in: commit 193392ed9f69 ("Revert "drm/amd/display: add -msse2 to prevent Clang from emitting libcalls to undefined SW FP routines"") Re-added just for Clang in: commit 0f0727d971f6 ("drm/amd/display: readd -msse2 to prevent Clang from emitting libcalls to undefined SW FP routines") The original report didn't have enough information to know if the GPF was due to misalignment, but I suspect that it was. (The missing information was the disassembly of the function at the bottom of the trace, to see if the instruction pointer pointed to an instruction with 16B alignment memory operand requirements. The stack trace does show the stack was only 8B but not 16B aligned though, which makes this a strong possibility). Now that the stack misalignment issue has been fixed for users of GCC 7.1+, reattempt adding -msse2. This matches Clang. It will likely never be safe to enable this for pre-GCC 7.1 AND use a 16B aligned stack in these translation units. This is only a functional change for GCC 7.1+ users, and should be boot tested. Link: https://bugs.freedesktop.org/show_bug.cgi?id=109487 Signed-off-by: Nick Desaulniers --- drivers/gpu/drm/amd/display/dc/calcs/Makefile | 4 +--- drivers/gpu/drm/amd/display/dc/dcn20/Makefile | 4 +--- drivers/gpu/drm/amd/display/dc/dcn21/Makefile | 4 +--- drivers/gpu/drm/amd/display/dc/dml/Makefile | 4 +--- drivers/gpu/drm/amd/display/dc/dsc/Makefile | 4 +--- 5 files changed, 5 insertions(+), 15 deletions(-) -- 2.23.0.700.g56cf767bdb-goog diff --git a/drivers/gpu/drm/amd/display/dc/calcs/Makefile b/drivers/gpu/drm/amd/display/dc/calcs/Makefile index a1af55a86508..26c6d735cdc7 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/Makefile +++ b/drivers/gpu/drm/amd/display/dc/calcs/Makefile @@ -37,9 +37,7 @@ ifdef IS_OLD_GCC # GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 # (8B stack alignment). calcs_ccflags += -mpreferred-stack-boundary=4 -endif - -ifdef CONFIG_CC_IS_CLANG +else calcs_ccflags += -msse2 endif diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/Makefile b/drivers/gpu/drm/amd/display/dc/dcn20/Makefile index cb0ac131f74a..63f3bddba7da 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn20/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dcn20/Makefile @@ -23,9 +23,7 @@ ifdef IS_OLD_GCC # GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 # (8B stack alignment). CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o += -mpreferred-stack-boundary=4 -endif - -ifdef CONFIG_CC_IS_CLANG +else CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o += -msse2 endif diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile index f92320ddd27f..ff50ae71fe27 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile @@ -16,9 +16,7 @@ ifdef IS_OLD_GCC # GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 # (8B stack alignment). CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o += -mpreferred-stack-boundary=4 -endif - -ifdef CONFIG_CC_IS_CLANG +else CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o += -msse2 endif diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile index ef1bdd20b425..8df251626e22 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -37,9 +37,7 @@ ifdef IS_OLD_GCC # GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 # (8B stack alignment). dml_ccflags += -mpreferred-stack-boundary=4 -endif - -ifdef CONFIG_CC_IS_CLANG +else dml_ccflags += -msse2 endif diff --git a/drivers/gpu/drm/amd/display/dc/dsc/Makefile b/drivers/gpu/drm/amd/display/dc/dsc/Makefile index 3f7840828a9f..970737217e53 100644 --- a/drivers/gpu/drm/amd/display/dc/dsc/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dsc/Makefile @@ -14,9 +14,7 @@ ifdef IS_OLD_GCC # GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 # (8B stack alignment). dsc_ccflags += -mpreferred-stack-boundary=4 -endif - -ifdef CONFIG_CC_IS_CLANG +else dsc_ccflags += -msse2 endif