Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7067428ybp; Wed, 16 Oct 2019 03:20:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzteiFiLpij/x7Bb1X+6lSpkia5aq9SSXO4mSQsIN6S0Uy2DsUaSIvex1CmwkyRv3rY86el X-Received: by 2002:aa7:dd18:: with SMTP id i24mr39301887edv.239.1571221246096; Wed, 16 Oct 2019 03:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571221246; cv=none; d=google.com; s=arc-20160816; b=z1em85Q7dzvi8K6AFSJwn8E2H6gL9sVu4WKi7AlVTbXRBKmFJE7aGDyqoYWPQKfZsv 9PwSyZPL0W51MPTNLZkNapFITqepxPsaqEkmwXXBiq4WY3lX/XbwYv53K6A6lmi2CBrV m8BrSUL5CbxCsoAVjzFY0uXGpRhS5XF0ej6SPAZ/6gVdus7Mgx8RyjwkbVfdYQcaTw8V YN6AyuAJefawX6yPaFz8VBezST1fgAriwnGPObSHbHf9lHPRS0E+2+chB8aqbv6Ygapb sm/3h7t5Pc6enB2kOssQ8QxuMTq5/4seIAtvAimxmZvFDX42knST7XXrrJI4JYRWWTdc jZ7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=eInMsMe+BJaYRY1Pz9oWe+U9MwphvcdZCLcBAxvz7R0=; b=MmroSMugaxTHnAAqYJx+ZVigMvxgzh8uT57IPJVSavJEkgtQNIZw0FxI2a9RKDbm1h mmAafHhcNLmZANSFR5CQzUFoFtXZE6TAej3YfHGHXNQWFIFIOtzyjUmaqgnK2RiSKI2L tAd+QuG9werMDax95RjV2YNzbW9Lidk4bMy2lZ4tBC4Z0ptmC8y4K56ICPU37cBe7PBq F4Fwo/r9UGarlEHBCeEkDITzCnxBc0pIHU7s6/NC2bJhMYvf3bGRi9agN5uLYjSBkFuu JsRiddVmf7/CNWuwxW8b88Iv3/UKebeGAekJgqTIY0CkZ9ginUempjsbsXjLeF0jTiyf s51Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XPI8JjSs; 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 pk19si15173108ejb.257.2019.10.16.03.20.22; Wed, 16 Oct 2019 03:20:46 -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=XPI8JjSs; 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 S2389537AbfJPBvi (ORCPT + 99 others); Tue, 15 Oct 2019 21:51:38 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39232 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726236AbfJPBvh (ORCPT ); Tue, 15 Oct 2019 21:51:37 -0400 Received: by mail-pf1-f195.google.com with SMTP id v4so13645017pff.6 for ; Tue, 15 Oct 2019 18:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eInMsMe+BJaYRY1Pz9oWe+U9MwphvcdZCLcBAxvz7R0=; b=XPI8JjSsYj2wNPJu04c2XrN1/PeiTZfQIUnpdo/TyHS6cpar5/1bLRDjwA0cPCx6be n2YvCGW7epfY3GWj1ROYKCzbAYH8LTfKoC9HTIukwIP+IFA76LYQ38jP5uNUZ1+ydZx5 ZI4YJCpAjhjueDXz6a1lbLprnoEEeJpCKgx4XVW0vGzLcWfbVzzvm7tQChbAm8p5s7Ej k2ylWDmyDhfbh0bCaxt1fvxQb4bIfU44/U0wop9nrLb57GKqMxHajEPt1y8UzQLXV9C9 B76LN9xOBBh8AU7kAAG6T8ZJtmBpolQnOrUbbrEvzuZIv2s91bNWbNl1ScmVJZZv2Oqf hI5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eInMsMe+BJaYRY1Pz9oWe+U9MwphvcdZCLcBAxvz7R0=; b=pacwHh8HmigBi87FQIrgpFXRv3LRWekFYzoywHmYK1lvfWI3yGjSnwERnokLtzbTgd y0ntuy4ey1uOMWtq9D52geZg3HQ5f6Kh9h2KOOmUwSpsYMmApxCHBRahaCOOfDQJPeUN 3XW6MsFkO64m1EGlfGEpViY6TOvDx3GerzQBBJRai9JkZ0PkdbvIF/lhz2Sqsf/kd+LD kRuVyrWLPnF/kWePzRK8MZYcbACr1t+938CNMaapmlXMiEVkl7ydQIsUUmQUMpPe76c0 INLQZDG0D+EUcs4tX9XfQsxir+mzbY0Y/1mGoO00147mGIFCp/J7Qia4BFrC7AfD2Why 2Zew== X-Gm-Message-State: APjAAAU/wU6vOstMSphZJS53rLclNownPcgWM3J+Xb/L8C528i1B0IP0 kJClzv30Nvz913Rc39YTq7JNDpBEovBRxO/LnymghwF9uoM= X-Received: by 2002:a63:5a03:: with SMTP id o3mr4805222pgb.381.1571190696394; Tue, 15 Oct 2019 18:51:36 -0700 (PDT) MIME-Version: 1.0 References: <9e4d6378-5032-8521-13a9-d9d9519d07de@amd.com> <20191015202636.GA1671072@rani> In-Reply-To: <20191015202636.GA1671072@rani> From: Nick Desaulniers Date: Tue, 15 Oct 2019 18:51:26 -0700 Message-ID: Subject: Re: AMDGPU and 16B stack alignment To: Arvind Sankar Cc: Arnd Bergmann , "S, Shirish" , "Wentland, Harry" , "Deucher, Alexander" , "yshuiv7@gmail.com" , "andrew.cooper3@citrix.com" , clang-built-linux , Matthias Kaehlcke , "S, Shirish" , "Zhou, David(ChunMing)" , "Koenig, Christian" , amd-gfx list , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 15, 2019 at 1:26 PM Arvind Sankar wrote: > > On Tue, Oct 15, 2019 at 11:05:56AM -0700, Nick Desaulniers wrote: > > Hmmm...I would have liked to remove it outright, as it is an ABI > > mismatch that is likely to result in instability and non-fun-to-debug > > runtime issues in the future. I suspect my patch does work for GCC > > 7.1+. The question is: Do we want to either: > > 1. mark AMDGPU broken for GCC < 7.1, or > > 2. continue supporting it via stack alignment mismatch? > > > > 2 is brittle, and may break at any point in the future, but if it's > > working for someone it does make me feel bad to outright disable it. > > What I'd image 2 looks like is (psuedo code in a Makefile): > > > > if CC_IS_GCC && GCC_VERSION < 7.1: > > set stack alignment to 16B and hope for the best > > > > So my diff would be amended to keep the stack alignment flags, but > > only to support GCC < 7.1. And that assumes my change compiles with > > GCC 7.1+. (Looks like it does for me locally with GCC 8.3, but I would > > feel even more confident if someone with hardware to test on and GCC > > 7.1+ could boot test). > > -- > > Thanks, > > ~Nick Desaulniers > > If we do keep it, would adding -mstackrealign make it more robust? > That's simple and will only add the alignment to functions that require > 16-byte alignment (at least on gcc). I think there's also `-mincoming-stack-boundary=`. https://github.com/ClangBuiltLinux/linux/issues/735#issuecomment-540038017 > > Alternative is to use > __attribute__((force_align_arg_pointer)) on functions that might be > called from 8-byte-aligned code. Which is hard to automate and easy to forget. Likely a large diff to fix today. > > It looks like -mstackrealign should work from gcc 5.3 onwards. The kernel would generally like to support GCC 4.9+. There's plenty of different ways to keep layering on duct tape and bailing wire to support differing ABIs, but that's just adding technical debt that will have to be repaid one day. That's why the cleanest solution IMO is mark the driver broken for old toolchains, and use a code-base-consistent stack alignment. Bending over backwards to support old toolchains means accepting stack alignment mismatches, which is in the "unspecified behavior" ring of the "undefined behavior" Venn diagram. I have the same opinion on relying on explicitly undefined behavior. I'll send patches for fixing up Clang, but please consider my strong advice to generally avoid stack alignment mismatches, regardless of compiler. -- Thanks, ~Nick Desaulniers