Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1058480rdb; Fri, 9 Feb 2024 09:03:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIBDT9/ggqlFNliQIXgrNUBID+dPNbMJj9bQQGJWj0qVHDgUzaWAe2Ye3bZ+4nOrP+6bNo X-Received: by 2002:a17:906:7d5:b0:a3b:b334:2f29 with SMTP id m21-20020a17090607d500b00a3bb3342f29mr1925780ejc.4.1707498235185; Fri, 09 Feb 2024 09:03:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707498235; cv=pass; d=google.com; s=arc-20160816; b=p9Hrd8/G8LcNRWAfh70TvJdupsqLr83SOG/JSOcJ5KHx+o5ER8cqLhqtBla8DYxgZ8 OwSicCqIe2R19OVOd2kWmroacaNzz6UTgGXlV1FkvzA9+4CJUjtSiOTorXdbEyqgdA5l VFF5dcoRUbHmw+bjsOYfegMRxOpEYSb9TqM3unmW2JysfasoT7EUsEcjfZ6sGuWAqqTs 2GZRONvcc8uxksM7/u9LXqLIQjaTzyxxKBoBs03TE34L99WsGh2T03axWSaWDn2rgS+P pjxb3NM3XsX572Il522tUDCyVkTpq4YRtFEP1FsbCQsYleGCkHjPhFZ0PMxku4m5kqr3 4hHA== 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=COfj+FIwYG87zb/D26QSbuaV/9maoynPp4ohvDdXH4E=; fh=AOO3bG/1xB6c0ooqQAYys86VbsKjJO1CQkQvEgpi3bQ=; b=YB83n+G5XWlwkmH5c1ULH0Qi0CrkrFZ/4YxNeC35GSsss+QcG7yNaYHdqqfUZOIoU7 CVKrJlSTtt76KywaEcFUco+6Mb5D97ruJFUY/hOGTV1dAsmfyNwZXYIyTqQS2TZof+eG j03nHCMN11rBhbdpyDG5S1LBYKanc/YUJK/6Br6LHMg3AHboFQYKyKsMcHtLk0MziqlX fneZNPYucoQPmztSZ1r3GzLhq8UFas3pRyOuu4JJvJIABkQUpzLePj5P1//mGu/UHaZR eot7k1y0mMzIw4FioHW5x64ktwmJA1USFcM5rdoAXiCd7ixOxeK8sRtnux8ZuB9m7uEi ns2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rM43FmHX; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-59692-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59692-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCXpLCyug2aHA/pE1dT00hlQgLJPPRXnLrqZbsdC1KmQqTPzHaeXR+k/ZZJz1MCgqaZZDaQpmP58/LB6xRuMlxQz7btKAxdSGaKfs1HyQQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u6-20020a170906c40600b00a3838e471f2si975157ejz.522.2024.02.09.09.03.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 09:03:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59692-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rM43FmHX; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-59692-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59692-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 am.mirrors.kernel.org (Postfix) with ESMTPS id BBB991F22530 for ; Fri, 9 Feb 2024 17:03:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D076A7BAF6; Fri, 9 Feb 2024 17:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rM43FmHX" Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 DE8C278693 for ; Fri, 9 Feb 2024 17:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498222; cv=none; b=LqEyimtwCh30x6pEFZomerHHOyaBGeFBqGmCuIthMsjaNX4vZ7kG2geyLhDbC7hEZdowJIfgHM4j0KUULVdHd5D0zEF/BMD3rNRfr3x+ANl5AWI8RhEpfJHr9v5U8x1wSgj2kdDdv9EU5Ki129b8TfJ3Zw5mxhXa7K2yTGctZvk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498222; c=relaxed/simple; bh=o24d4mKDR3vggTFcW/wRBSGrkk5nNfwrmH+3ZFwE9RA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=J1Ox3XOEkWKoLSI39NhVfFTWwIpL1FJmJ/ueIWybGpVCvG+n0Xg0JjcETTjxY7Veq+ICu6Rgcdkc5IjHjuYQwCrzRmUqw0cmV5cWDrjDGtCivgk42hQongoWEQ2n56ywY4VvDU1lStYMc6KqLJTzzA5CaZ9/3FevD+6Go/p+Wrk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rM43FmHX; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3392b045e0aso616795f8f.2 for ; Fri, 09 Feb 2024 09:03:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707498217; x=1708103017; 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=COfj+FIwYG87zb/D26QSbuaV/9maoynPp4ohvDdXH4E=; b=rM43FmHXb0AKIb1B1rQRyhcpEwG06sOdvoLuaB9Q5XudTWcnpyaau6IzIUqC48NL+m Agow3y0nzo2ojXrSDvp6zLg9U5wPIlwi2WDx/QfP/3vMMtZPX5U+cjaSHcHPi8hycaXJ Rwly3yG1+8I2+Oy4bj/UiWyGb0swERohJYsF7xSDK0YJ+DhtRxujVeXTMgn8SRql2hl0 n3pb0nICfbzCq64nurIRx9x9nNPtWAFLKZP1q7g08oRkk67pmHh7JdH0mJkanwbPlNoy TqJNf310kRDZYCoszvwyY2ZRLK8Aw7zZB7SKDzY/DvecP+Knw+PF3Qd/EL1cW4chWll6 L2kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707498217; x=1708103017; 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=COfj+FIwYG87zb/D26QSbuaV/9maoynPp4ohvDdXH4E=; b=GCtTUUXzNrYx7hm9c+DgJnhpVZhs5kbqWkT8g9HZF9WhgGpK+x38EeM+PIJMJUDrQc NGKc86qmnSykT133mjKRushOublLu3Z+q0/s5G53GtxQRkoVmlQ/PVGE4cUwJBlA/L7n Nj126r02PoVeHq7YSAo0fBD1lDJZ1mwPlYGVH9hQxhtHEbLHGIKueGLb2dT4VVyvrXyM xUpTI2mPkAMDw1D/De1ieJNimCRbY4MsCqUBMfvLG4HxXNoVz2kFq+LQopmOMCjgBbbz 6Unt4n87pWnRm5AblCEZTEbOn+Jv/6EXfvuqVaIm76Ef8IFW4UjL0irMFda5i4IWPuLC 2hxQ== X-Gm-Message-State: AOJu0YxoIjq0Nty1oBw1M6KjKWxGFiw/l8hSQ9T5gv75FLwkrxPg0j7l tLndUsiJ5RLtEboCZoggTwNem3soF+cnYcvIKw5TiJ+7NMi485FPMPQAvDH4jPQTw2AZhNUba8c bSbD+1lViGPXlBRTC0EWlCuXkUbz4WYLc7XyUXpY4hsjFOr1t0cK7 X-Received: by 2002:a5d:4e0b:0:b0:33b:68bc:6e73 with SMTP id p11-20020a5d4e0b000000b0033b68bc6e73mr515018wrt.42.1707498216983; Fri, 09 Feb 2024 09:03:36 -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: <20240208220604.140859-1-seanjc@google.com> From: Nick Desaulniers Date: Fri, 9 Feb 2024 09:03:22 -0800 Message-ID: Subject: Re: [PATCH] Kconfig: Explicitly disable asm goto w/ outputs on gcc-11 (and earlier) To: Sean Christopherson , quic_apinski@quicinc.com Cc: Linus Torvalds , 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 + Andrew Andrew, here's the full thread, I cut most of it out: https://lore.kernel.org/lkml/20240208220604.140859-1-seanjc@google.com/ . On Thu, Feb 8, 2024 at 2:06=E2=80=AFPM Sean Christopherson wrote: > > Explicitly require gcc-12+ to enable asm goto with outputs on gcc to avoi= d > what is effectively a data corruption bug on gcc-11. As per > https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html, "asm goto" is > *supposed* be implicitly volatile, but gcc-11 fails to treat it as such. > When compiling with -O2, failure to treat the asm block as volatile can > result in the entire block being discarded during optimization. > > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103979 Shoot, I was cc'ed on that bug (I think I noticed it in testing as well, and pointed it out to Andrew on IRC who then cc'ed me to it). I probably should have asked if that would cause issues at some point for the kernel. I took a look at the test case added in that bug; it doesn't compile until gcc-13 (specifically gcc 13.2, not gcc 13.1). I'm curious since the bug says the fix was backported to gcc-12 and gcc-13. Are there specific versions of those that contain the fix? If so, should Sean amend his version checks below? For instance, was the fix backported to gcc 12.3, so users of gcc 12.2 would still have issues? I can't tell in godbolt since the added test case doesn't compile until gcc 13.2. https://godbolt.org/z/eqaa7dfo3 My implementation in clang still has some issues, too. It's hard to get new control flow right, and there are minimal users outside the kernel to help us validate. So as much of a fan of feature detection as I am, I admit some of these edge cases aren't perfect, and we may need to result to version detection when such bugs become observable to users. I'm happy to ack this patch, but I would like to wait for feedback from Andrew as to whether we can be even more precise with avoiding more specific versions of gcc 12 and 13 (if necessary). > Fixes: 587f17018a2c ("Kconfig: add config option for asm goto w/ outputs"= ) > Cc: Nick Desaulniers > Cc: Masahiro Yamada > Cc: Peter Zijlstra > Cc: kvm@vger.kernel.org > Cc: stable@vger.kernel.org > Signed-off-by: Sean Christopherson > --- > > Linus, I'm sending to you directly as this seems urgent enough to apply > straightaway, and this obviously affects much more than the build system. > > init/Kconfig | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/init/Kconfig b/init/Kconfig > index deda3d14135b..f4e46d64c1e7 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -82,6 +82,11 @@ config CC_CAN_LINK_STATIC > default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG= _FLAGS) $(USERCFLAGS) $(USERLDFLAGS) $(m32-flag) -static) > > config CC_HAS_ASM_GOTO_OUTPUT > + # gcc-11 has a nasty bug where it doesn't treat asm goto as volat= ile, > + # which can result in asm blocks being dropped when compiling wit= h -02. > + # Note, explicitly forcing volatile doesn't entirely fix the bug! > + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103979 > + depends on !CC_IS_GCC || GCC_VERSION >=3D 120000 LGTM; but we might need to be more specific about avoiding certain min versions of gcc 13 and 12. > def_bool $(success,echo 'int foo(int x) { asm goto ("": "=3Dr"(x)= ::: bar); return x; bar: return 0; }' | $(CC) -x c - -c -o /dev/null) > > config CC_HAS_ASM_GOTO_TIED_OUTPUT > > base-commit: 047371968ffc470769f541d6933e262dc7085456 > -- > 2.43.0.687.g38aa6559b0-goog > --=20 Thanks, ~Nick Desaulniers