Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp276477lqg; Thu, 11 Apr 2024 02:28:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWwjrkpif1dMEEdH/w6FaZpq8v8JOBLJ3il8ZVzuECBZTGm63WJi0mGBoiXXNFg7bMexD+q3vhFoRhBz5vNFNnoe+4I2aYipKESAkURkQ== X-Google-Smtp-Source: AGHT+IGrStaz3DOk8rDLA6tOZ1ZKp7wjFfUPfpYX97oDNfdPe14cLnDi826YB/bwr3/0LgC6aE1T X-Received: by 2002:a17:902:7618:b0:1e4:fd4:48db with SMTP id k24-20020a170902761800b001e40fd448dbmr5032871pll.43.1712827703881; Thu, 11 Apr 2024 02:28:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712827703; cv=pass; d=google.com; s=arc-20160816; b=JP1MIymuKPRrOMKFcuv2fAwaBIGHnBqfseXdznrBH3vOYj9qtzTKKiSbJsUdV+Cqfr +poV5hMNvv452+g8JvB/dH1Tg7gqxzme5xOgl73OKYHMK4H+1N4nKd1gIisWkgezkTIw RVYiMbnNfiF/RzNCMa/ul71w6mwJj4INdsu2DQivSK9EAzy52IqASPXMbRikJyKhZ3Zw gQhJeJPhFUxuIw7PfcsNNpNfRK4NSOanXia+iqOkA+UV88Ezo6DNcZ6FjqoiaTLLnco4 fX96mKuOk96UH56bKA7Gc9CTAUuuytkycY+xPv0Ro4mlt0AOpYwytmUYLkZxXBQliM4t Jy+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=F2bqcMDlTVEfs/wgJ/b/3udi6wvSHji0RNoYdm+0emc=; fh=cHmwoIT/hqKnRewV98KUBATXQCEMs3VvGKRs6+RLWmI=; b=RGrvVbAY23oGykKVWaoyO0zWd97298Y46iNU/pmmr/56hj2FSrJAXnGqAsD256Sj7d 8//jBxwVszVs764JOVENIWosagttXRJtgkW5J7vNp+wzOTK1i5JyYjI2/MMIWGyMqfY4 Cij+NMOf45laLDlsNEM0zKd0AEfjw8JChVogQW/2JfRt4olbde0oq1Y4TXkAGX5LWTC2 euNNR9u8Fs45NWw7fuZZmgj59rzpyEnojyzsef5cHl4B6sUWRFZgNNvpdBFTn7oBPMsH dFfEYXE1hf1u4JBLUDyFnPaQ4k8rZ638S9pTyBRboGWY0BWyPmSh3gACiqubth229hje 4XkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OHHacQgD; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-140174-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l21-20020a170902eb1500b001e3f6cba44csi927494plb.144.2024.04.11.02.28.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 02:28:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140174-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OHHacQgD; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-140174-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8A75028734C for ; Thu, 11 Apr 2024 09:28:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C32BB13DDDD; Thu, 11 Apr 2024 09:28:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OHHacQgD" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 228AB1448E4; Thu, 11 Apr 2024 09:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712827689; cv=none; b=NWcZmzuvRjNHBsoy+mKe7tSHnPUTswIq77PlpCnQibtZ6fot9IY8AqhsnRNtjzz5uEceCBxPmNbe/1IY24WUwb0nC+Qgk7LeRhjDSNOn/vstrTuHIXnlHNOWRgn1Y6CGc9vTI78Xgj8V2xhezgW+DyI5KFUh76ZMb+5VT613T4Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712827689; c=relaxed/simple; bh=zITqgZVojLh4dUSaGKV239z9RvbFs2+NfPNhuOaA6RY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kiKzvkUoW2M3UdHshXibZwI4Rp6HBTh4cululUDP5QG+4vUWIJpQDEeMXMoR3V6xzXVHYGfGfCB60VjG+rOi8VMzf7QF9kx8+d1MRRNqwYBMNGiu5d0U8anUxlpHYjUJGr0h7iJC99IKNV2VgV8G/yfLLWhfqHLWYgLrMS2uvqI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=OHHacQgD; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712827687; x=1744363687; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=zITqgZVojLh4dUSaGKV239z9RvbFs2+NfPNhuOaA6RY=; b=OHHacQgDYRiNowmTSbhA9P6GvF9lTuwW6mgJXtjAN9CVGs3v5hpa9Vwl Zc59bfEg+q8kR7mwDw9FFe7D2NYeVZ4GkfW6a7u+q2mfhdFgXRRm0MW4C LukqIi47l/0LlE2x9FMWiyrxQjqSr97ogBGszsoIgRTEw95bVFMzo+0vl 2l45m0l/QgvDIg2PrXvNbF+Daqj9cl/gHV8WdKQk9+2p70iDU8yWLoo34 J8xzKtFVL8KCAgywbAvbM2z0I5G0ljaNaWuGSArXV+QKMFifZcRBIPk8m IySOuRBZO0O88lwLkw6JkyjvoaS1XxQbjvBWuhZGBI/+9gEfZVnTqNtOW w==; X-CSE-ConnectionGUID: N9AKuPqDSkqw1ah5BaW1UA== X-CSE-MsgGUID: 9iM7Pl4AR+apieVATzFJ0A== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="8083353" X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="8083353" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 02:28:05 -0700 X-CSE-ConnectionGUID: off1ptQUS5SR8wQ5l3jZ/Q== X-CSE-MsgGUID: WwenVoetQbuHdgS5T+1EqA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="25622263" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.251.215.66]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 02:27:58 -0700 Message-ID: <4d429a10-eb45-4262-8e74-69af810ef1ac@intel.com> Date: Thu, 11 Apr 2024 12:27:53 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] bug: Fix no-return-statement warning with !CONFIG_BUG To: Christophe Leroy , Arnd Bergmann Cc: Naresh Kamboju , Michael Ellerman , Nicholas Piggin , "Aneesh Kumar K.V" , "Naveen N. Rao" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Ingo Molnar , Borislav Petkov , Dave Hansen , "x86@kernel.org" , "H. Peter Anvin" , Andy Lutomirski , Vincenzo Frascino , John Stultz , Stephen Boyd , Peter Zijlstra , Randy Dunlap , Bjorn Helgaas , Anna-Maria Gleixner , "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" , "linux-s390@vger.kernel.org" , Thomas Gleixner References: <20240410153212.127477-1-adrian.hunter@intel.com> <87be83da-6102-483d-b1dc-a77eecc9f780@app.fastmail.com> Content-Language: en-US From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 11/04/24 11:22, Christophe Leroy wrote: > > > Le 11/04/2024 à 10:12, Christophe Leroy a écrit : >> >> >> Le 11/04/2024 à 09:16, Adrian Hunter a écrit : >>> On 11/04/24 10:04, Arnd Bergmann wrote: >>>> On Wed, Apr 10, 2024, at 17:32, Adrian Hunter wrote: >>>>> BUG() does not return, and arch implementations of BUG() use >>>>> unreachable() >>>>> or other non-returning code. However with !CONFIG_BUG, the default >>>>> implementation is often used instead, and that does not do that. x86 >>>>> always >>>>> uses its own implementation, but powerpc with !CONFIG_BUG gives a build >>>>> error: >>>>> >>>>>    kernel/time/timekeeping.c: In function ‘timekeeping_debug_get_ns’: >>>>>    kernel/time/timekeeping.c:286:1: error: no return statement in >>>>> function >>>>>    returning non-void [-Werror=return-type] >>>>> >>>>> Add unreachable() to default !CONFIG_BUG BUG() implementation. >>>> >>>> I'm a bit worried about this patch, since we have had problems >>>> with unreachable() inside of BUG() in the past, and as far as I >>>> can remember, the current version was the only one that >>>> actually did the right thing on all compilers. >>>> >>>> One problem with an unreachable() annotation here is that if >>>> a compiler misanalyses the endless loop, it can decide to >>>> throw out the entire code path leading up to it and just >>>> run into undefined behavior instead of printing a BUG() >>>> message. >>>> >>>> Do you know which compiler version show the warning above? >>> >>> Original report has a list >>> >>>     https://lore.kernel.org/all/CA+G9fYvjdZCW=7ZGxS6A_3bysjQ56YF7S-+PNLQ_8a4DKh1Bhg@mail.gmail.com/ >>> >> >> Looking at the report, I think the correct fix should be to use >> BUILD_BUG() instead of BUG() > > I confirm the error goes away with the following change to next-20240411 > on powerpc tinyconfig with gcc 13.2 > > diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c > index 4e18db1819f8..3d5ac0cdd721 100644 > --- a/kernel/time/timekeeping.c > +++ b/kernel/time/timekeeping.c > @@ -282,7 +282,7 @@ static inline void timekeeping_check_update(struct > timekeeper *tk, u64 offset) > } > static inline u64 timekeeping_debug_get_ns(const struct tk_read_base *tkr) > { > - BUG(); > + BUILD_BUG(); > } > #endif > That is fragile because it depends on defined(__OPTIMIZE__), so it should still be: BUILD_BUG(); return 0;