Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp583179pxj; Thu, 13 May 2021 11:49:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUmRDdM7Kgxe0tXFbYK2YGYIR0hpf+NWyIZcMrXPS4G+0H61D7uwCeVPP5wlY2URawJ64K X-Received: by 2002:aca:484e:: with SMTP id v75mr3968720oia.149.1620931764699; Thu, 13 May 2021 11:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620931764; cv=none; d=google.com; s=arc-20160816; b=MXaKF617Z+FBRkx6kGZEBfMeHUvHJq36OTvDS+FJf/T9KHnOKDXJ+cSFprOnMsPSC6 YMWNaQWbMvWuxkk75vh/dqs3KmGk5pD3Us3WKoa4ae9pmhfdEPKURHrfmHKHxsF6eK1u QQj8Mt6yLKnk2ghayTnJgf1QHzMh+APiM68Fmwtqbmj+7xoF+4tYR93e/60wXKEnNwRi ze0IKbP4mnp3VT/yESewTje8d18OJ2x6ccTFWJR/GbutOeroV4m+S6NuJT8OViicMOae VSiwsQX74ZKYmkUFur2B+Cm+yYhCObGS3iOpLkKbxRlrQFcJxaQwnvl8hN/yyYARFdp3 FGTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=L1Rs0oxlRge0qzOeFq0tx+oSL+//C6msY0LMqH5lEJs=; b=w98KJathBdOcD/kL3hB1UxLoyh0jEdM4+ALc/IRiEH5b1VHjC7GiG2GwMmJrZWS4Y/ FwqpdywlLrBQV88Ylu7fnqkusa7fowyoX4lZ8JtfO/lHMvowygMwXhPhnU85Drrw4yN6 z6sou89LtIvSdLF6Ut79gwKYPKhTNFIpuRA66O8GvMgOlK8ypCyyiLN6xJkB1+vlgeSC wX7cRwYOcbiw0ubQ+9FkbwQPGWyrFpYSsArP7rOnzSc0RqTh5qT5CvQAN0FT7/jWDv4V cHTVc/uWDC6i64QEf5qm1yGwShKKMH7D2iE9HyFpVEyOIx5pv8pPsGjK8KX3wriWQ0wN u1gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UfmbqwKW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si3870373otn.41.2021.05.13.11.49.10; Thu, 13 May 2021 11:49:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UfmbqwKW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233097AbhEMLIw (ORCPT + 99 others); Thu, 13 May 2021 07:08:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbhEMLIc (ORCPT ); Thu, 13 May 2021 07:08:32 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0461AC061761 for ; Thu, 13 May 2021 04:07:22 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id b19-20020a05600c06d3b029014258a636e8so4465029wmn.2 for ; Thu, 13 May 2021 04:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=L1Rs0oxlRge0qzOeFq0tx+oSL+//C6msY0LMqH5lEJs=; b=UfmbqwKWPIdaOVfwjyMXYHlRMeuPfQe2tS1dxgzp9lcC2DKlB6n5x7sLOxwLQuQn7d V69lN0hMUMBgvquWzFmb51GU0aWKFtSn/+59BMg6Krr1aA+XsSNtSIVmf43riZWUNU3C OSZ6mwdBXsfsNjTyfNrPGpclohv341toj3iK6cRR9VILpW61HrMd1h9Sh84X0DALpnL5 ENei0SdPbb7t8pkgBfw/PKuqs9qLRFn3eiRf9r61KKMQlg4D7HYyRVLLfloygAWKiId9 HBlUhD08Su2HY49L+9lKhUfs5ypG0sHxOZeR283CD6+ON+tozDYW6QJks2QbIJv2RqTA xZtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=L1Rs0oxlRge0qzOeFq0tx+oSL+//C6msY0LMqH5lEJs=; b=p5AarRskn0eEnQKfeMvKgHIanD2S2yBNhAJQygsAgNOjY0tvp9pygQ/osLu1sJQO+2 uKCOEONd0zYfss0Plfrh+jITVy+JTuBusEVpe1zY7zCo+t2Ei7KZpSU8bGfdyQMm1kA8 1b5gfajGU/Efrd15Z72lzFCBQKfNyBqiaYgWkvmUQPPwigt97BmTlZ40Ll2ptJdp1vJe hxvHCK7sQvj6OfyzKHX/rq/a5uK9/FE3CClk9aZJ4CGaBEfBpMG9b1AILOdUpqYfNlSo 93MyaxDo+cFR2qzc1j5k4iiTepcI3obntvoaGlp3uoQJCjk1aHwriAIzbAGL4Udg5yZe wnoQ== X-Gm-Message-State: AOAM530jdK6wDgLcKxSyy6/UhAXY8CdG1WEOYswyF2+wJD/gflAF5PdB +leQiSKZygOk0K5GPj1aUAnNag== X-Received: by 2002:a1c:a507:: with SMTP id o7mr3293234wme.130.1620904040559; Thu, 13 May 2021 04:07:20 -0700 (PDT) Received: from maple.lan (cpc141216-aztw34-2-0-cust174.18-1.cable.virginm.net. [80.7.220.175]) by smtp.gmail.com with ESMTPSA id e38sm7979662wmp.21.2021.05.13.04.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 May 2021 04:07:19 -0700 (PDT) Date: Thu, 13 May 2021 12:07:17 +0100 From: Daniel Thompson To: Ard Biesheuvel Cc: Arnd Bergmann , Russell King , Arnd Bergmann , "# 3.4.x" , Marek Vasut , Nathan Chancellor , Nick Desaulniers , Linus Walleij , Nicolas Pitre , Geert Uytterhoeven , Mike Rapoport , Linux ARM , Linux Kernel Mailing List , clang-built-linux Subject: Re: [PATCH] ARM: fix gcc-10 thumb2-kernel regression Message-ID: <20210513110717.s2gr4l5upqzjkb5a@maple.lan> References: <20210512081211.200025-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 12, 2021 at 02:38:36PM +0200, Ard Biesheuvel wrote: > On Wed, 12 May 2021 at 10:13, Arnd Bergmann wrote: > > > > From: Arnd Bergmann > > > > When building the kernel wtih gcc-10 or higher using the > > CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y flag, the compiler picks a slightly > > different set of registers for the inline assembly in cpu_init() that > > subsequently results in a corrupt kernel stack as well as remaining in > > FIQ mode. If a banked register is used for the last argument, the wrong > > version of that register gets loaded into CPSR_c. When building in Arm > > mode, the arguments are passed as immediate values and the bug cannot > > happen. > > > > This got introduced when Daniel reworked the FIQ handling and was > > technically always broken, but happened to work with both clang and gcc > > before gcc-10 as long as they picked one of the lower registers. > > This is probably an indication that still very few people build the > > kernel in Thumb2 mode. > > > > Marek pointed out the problem on IRC, Arnd narrowed it down to this > > inline assembly and Russell pinpointed the exact bug. > > > > Change the constraints to force the final mode switch to use a non-banked > > register for the argument to ensure that the correct constant gets loaded. > > Another alternative would be to always use registers for the constant > > arguments to avoid the #ifdef that has now become more complex. > > > > Cc: # v3.18+ > > Cc: Daniel Thompson > > Reported-by: Marek Vasut > > Fixes: c0e7f7ee717e ("ARM: 8150/3: fiq: Replace default FIQ handler") > > Signed-off-by: Arnd Bergmann > > Nice bug! Indeed. Many thanks for those involved with the find and fix! Daniel.