Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1911835rdb; Sun, 11 Feb 2024 03:13:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMqoT/Rz4hZuCKOtdkaYnAdXi4eyyooiBqa+0KT1b3fPtoKv8FjwDq/AVLER8U9y2TQLPd X-Received: by 2002:a05:620a:444e:b0:785:350f:7c1d with SMTP id w14-20020a05620a444e00b00785350f7c1dmr4243057qkp.66.1707649980967; Sun, 11 Feb 2024 03:13:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707649980; cv=pass; d=google.com; s=arc-20160816; b=Q2le//dPJ74M7x/ipJKpthAy2TCW/cJIfRb4NsOpQt7jyPdL3QcJ/mBWJCuP77MEch Xm3Sq7hxAH9gGG8OclKfCR4XzvYQTY2juSvUuh4BsK+VG/GmE+TWyg6vxpHikSIYLqwB xl0H4V7TCTWRW65na+M5M0NF+CMl6exqsZtUSP+D7hBdVd1+xhdTEpaDqZ4AonVOHh2y sWkwmglACiRS6BfGDIAAgv1KLitleRgMP4+Pa9QfepRmGfsvT/UD6Q2zY/0Y7Varmxzf azQ1ZNcon+T/65gO9/3246oJlNycHoyuHEawU6l/LqPa95GzZ/SMcAeQ9t9FUgDDYlfe t1oA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=vwWjRV8qTzo9Iole9rjuD+6F66lQhLbrMJXfy7CCdXo=; fh=LaWuzGSvylN51DOIBkQvaXbilNYkHVQbdrcvJ2OtmyY=; b=BDFVd691zGyfhlRQskQ0tCPLAW1hIjNpyAI7mbBLWWh+/d8xbeyGYF1R/mNfXXurI2 0/9IVg7KkOC9q7QjAQGqX2csxaOoUatDAUJcp+Ddl+4JyQgUD+qe3F22zjk0WLNGfqwF UMCozUtAlnP/eX5QRPdzITSKjtXEximLB+VypKROlxvMuWoZAqrz1EpZE641oEx7urVb L6OIIAXsmasBc6i/8b6ImSIjPLNVfLXjXMLIT2H9rJUapejej9OQEuTTh1u3p+E9hYLL N/TF16YVHYqYACJj/ZINXm2P30uwCtz00p/0GUxPeLG6bZH+B49o9d3NYszYc37dGsF8 PBNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bzCE1iNQ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60709-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60709-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCWeu07UpFjm2y7DhEagcju7lb+9K7UUhIk3M9magQOAA7k4Kdy8imKlr6Jqx8VAzbmLlMdr8PYn0+qMwHj8aDPA1Q9btqMphOYev9G3Zw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f10-20020a05620a20ca00b00785c15908efsi3520661qka.427.2024.02.11.03.13.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 03:13:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60709-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bzCE1iNQ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60709-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60709-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A6AB71C21390 for ; Sun, 11 Feb 2024 11:13:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A43345A4E1; Sun, 11 Feb 2024 11:12:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bzCE1iNQ" Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10CCB39AFA; Sun, 11 Feb 2024 11:12:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707649969; cv=none; b=SBgOR6AY0HcNyESo+wfsyrfOiwW5K7ASsVciGlgVu9DXpWZEkG9rOa3RF/Qq9Xc6ToiuwtC626DCW4IX7rh7q7etxd94Wu8ENOQ4GVF0an+pNi8IStr1s5nGlB/pzHqTAu9Rocxk+vZ9Fypnux/rqkLlkhcHtZzeA1M9g+DhujY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707649969; c=relaxed/simple; bh=La7OPyJ0cjFPI7znPBQgdOqzPHNAmopoa+ktdnSjphQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=HdPoGvgRlPU5jwRrhOms2I2DBQ3Kualo9DQnEN+h8iiGA/nXHleELeCxlNRt1WH1N1ru+EK+I91L/mF9bCFdi1NXhgmMZAT5GbiFUpNPIz4Xnh3w9J6TC1sEcyGLGTrr+nygT4HmElq0wjTTUpPs24PSFOCge1aHk2TNWN8Ss1A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bzCE1iNQ; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5601eb97b29so4276069a12.0; Sun, 11 Feb 2024 03:12:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707649966; x=1708254766; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vwWjRV8qTzo9Iole9rjuD+6F66lQhLbrMJXfy7CCdXo=; b=bzCE1iNQOJqMravghe6PQYNt31HJn7dKt4oOqnHvso5KOD4a3hiW6qQeVqJISIIe/c xIZcXAVoktO+uv6sB6yMpnDdlPYIJ0NKq+wyU4WTGI54SYVsaFeYUxIGmsqMnFpgv5jm fVvR6ZfzCKlghU3Yk8Rz7oDUsqkSsm4JEWK4So1i0Ogbeme/lpkUu9I17J9xu4bDDJgC GcJZ/q/Heju6dR7cgtAK2pI13CE7XTiH+ztR4UBDaGT+78w8qRsfCmh4xtzevF+oB05S 79MXNaZulQ4OqjToMU/Y0O7+5s8PsRakTAy0bhtn69AiDKqS/dQ6GUNCe6keJCljsMNd cuPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707649966; x=1708254766; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vwWjRV8qTzo9Iole9rjuD+6F66lQhLbrMJXfy7CCdXo=; b=D6XosIiBuximfPTLN5KnLNpEFEbLCX1JBc9+AMHNSg8HFOGHDJ+ImDlQQ/FVIbM3Tx 2fSFPDYGbHuuLAGIoYimUC+fCLKiWJXPrMvWYXXIiOtOlsU5H260siO3c5xm6iV/EBr+ z7F9SbkwOKgZBSkVKEa0saGkocUEf6hvPgKzexT2VjDMtCywDRYwr0JjuIMiH5W4/gF8 kechyZt3fT6n9d+Bl5tusP+lD4JjZEM9TqpTj3wMdiaGOTMQFc9/mqAEtKEpXf8Jng8U kv2zd28lsQeGMk6x70Vcn5NV3ChDZqLeJG6IaV34YZq6nZ4XTEQEQk+LAdNhhdev5GRa GRHg== X-Gm-Message-State: AOJu0YxXL2ARe8bplTvGy5wKGtxH+Nsdkys3J2BdAT4YXatz//e2SWen q5rp7h/aDv4HPBSNPHyboh+GdZAM9P9RR5HUMAmsF2i3xTrTKV/Qaqu2e5TyqhOW4VuA+iNzki/ ZgMz28Hq0hBOCTkgPI1p0waIOTXs= X-Received: by 2002:a05:6402:528d:b0:561:64e6:b5c with SMTP id en13-20020a056402528d00b0056164e60b5cmr3499040edb.7.1707649965896; Sun, 11 Feb 2024 03:12:45 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240208220604.140859-1-seanjc@google.com> In-Reply-To: From: Uros Bizjak Date: Sun, 11 Feb 2024 12:12:37 +0100 Message-ID: Subject: Re: [PATCH] Kconfig: Explicitly disable asm goto w/ outputs on gcc-11 (and earlier) To: Linus Torvalds Cc: Nick Desaulniers , Jakub Jelinek , Sean Christopherson , "Andrew Pinski (QUIC)" , "linux-kernel@vger.kernel.org" , Masahiro Yamada , Peter Zijlstra , "kvm@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 9, 2024 at 9:39=E2=80=AFPM Linus Torvalds wrote: > > On Fri, 9 Feb 2024 at 11:01, Linus Torvalds > wrote: > > > > We should also probably get rid of the existing "asm_volatile_goto()" > > macro name entirely. That name was always pretty horrific, in that it > > didn't even mark the asm as volatile even in the case where it did > > anything. > > > > So the name of that macro made little sense, and the new workaround > > should be only for asm goto with outputs. So I'd suggest jmaking a new > > macro with that name: > > > > #define asm_goto_output(x...) > > > > and on gcc use that old workaround, and on clang just make it be a > > plain "asm goto". > > So here's a suggested patch that does this. > > It's largely done with "git grep" and "sed -i", plus some manual > fixups for the (few) cases where we have outputs. > > It looks superficially sane to me, and it passed an allmodconfig build > with gcc, but I'm not going to claim that it is really tested. > > Sean? Does this work for the case you noticed? > > Basically this gets rid of the old "asm_volatile_goto()" entirely as > useless, but replaces it with "asm_goto_outputs()" for the places > where we have outputs. > > And then for gcc, it makes those cases > > (a) use "asm volatile goto" to fix the fact that some versions of gcc > will have missed the "volatile" > > (b) adds that extra empty asm as a second barrier after the "real" > asm goto statement > > That (b) is very much voodoo programming, but it matches the old magic > barrier thing that Jakub Jelinek suggested for the really *old* gcc > bug wrt plain (non-output) "asm goto". The underlying bug for _that_ > was fixed long ago: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D58670 > > We removed that for plain "asm goto" workaround a couple of years ago, > so "asm_volatile_goto()" has been a no-op since June 2022, but this > now resurrects that hack for the output case. > > I'm not loving it, but Sean seemed to confirm that it fixes the code > generation problem, so ... > > Adding Uros to the cc, since he is both involved with gcc and with the > previous asm goto workaround removal, so maybe he has other > suggestions. Uros, see > > https://lore.kernel.org/all/20240208220604.140859-1-seanjc@google.com= / I'd suggest the original poster to file a bug report in the GCC bugzilla. This way, the bug can be properly analysed and eventually fixed. The detailed instructions are available at https://gcc.gnu.org/bugs/ > for background. > > Also adding Jakub since I'm re-using the hack he suggested for a > different - but similar - case. He may have strong opinions too, and > may object to that particular monkey-see-monkey-do voodoo programming. This big-hammer approach will effectively disable all optimizations around the asm, and should really be used only as a last resort. As learned from the PR58670 (linked above), these workarounds can stay in the kernel forever, and even when the compiler is fixed, there is little incentive to remove them - developers from the kernel world do not want to touch them, because "the workaround just works", and developers from the compiler world do not want to touch them either, because of unknown hidden consequences of removal. Please note, that the kernel is a heavy user of asm statements, and in GCC some forms of asm statements were developed specifically for kernel use, e.g. CC-output, and asm goto in all of its flavors. They have little or no use outside the kernel. If the kernel disables all optimizations around these statements, there actually remain no real-world testcases of how compiler optimizations interact with asm statements, and when new optimizations are introduced to the compiler, asm statemets are left behind (*). (*) When the GCC compiler nears its release, people start to test it on their code bases, and the kernel is one of the most important code bases as far as the compiler is concerned. We count on bugreports from these tests to fix possible fall-out from new optimizations, and the big-hammer workaround will just hide the possible problems. So, I'd suggest at least limit the workaround to known-bad compilers. Thanks, Uros.